summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
committerMike Stump <mrs@apple.com>2009-09-09 15:08:12 +0000
commit1eb4433ac451dc16f4133a88af2d002ac26c58ef (patch)
tree07065b80cb7787bb7b9ffcb985196007a57e86f7
parent79d39f92590cf2e91bf81486b02cd1156d13ca54 (diff)
downloadclang-1eb4433ac451dc16f4133a88af2d002ac26c58ef.tar.gz
Remove tabs, and whitespace cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81346 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/APValue.h40
-rw-r--r--include/clang/AST/ASTConsumer.h12
-rw-r--r--include/clang/AST/ASTContext.h262
-rw-r--r--include/clang/AST/ASTDiagnostic.h2
-rw-r--r--include/clang/AST/Attr.h98
-rw-r--r--include/clang/AST/CanonicalType.h311
-rw-r--r--include/clang/AST/Decl.h292
-rw-r--r--include/clang/AST/DeclBase.h122
-rw-r--r--include/clang/AST/DeclCXX.h468
-rw-r--r--include/clang/AST/DeclContextInternals.h30
-rw-r--r--include/clang/AST/DeclGroup.h38
-rw-r--r--include/clang/AST/DeclObjC.h424
-rw-r--r--include/clang/AST/DeclTemplate.h302
-rw-r--r--include/clang/AST/DeclarationName.h36
-rw-r--r--include/clang/AST/Expr.h768
-rw-r--r--include/clang/AST/ExprCXX.h412
-rw-r--r--include/clang/AST/ExprObjC.h204
-rw-r--r--include/clang/AST/ExternalASTSource.h8
-rw-r--r--include/clang/AST/NestedNameSpecifier.h32
-rw-r--r--include/clang/AST/ParentMap.h10
-rw-r--r--include/clang/AST/PrettyPrinter.h2
-rw-r--r--include/clang/AST/RecordLayout.h66
-rw-r--r--include/clang/AST/Redeclarable.h12
-rw-r--r--include/clang/AST/Stmt.h430
-rw-r--r--include/clang/AST/StmtGraphTraits.h28
-rw-r--r--include/clang/AST/StmtIterator.h62
-rw-r--r--include/clang/AST/StmtObjC.h190
-rw-r--r--include/clang/AST/StmtVisitor.h20
-rw-r--r--include/clang/AST/TemplateName.h38
-rw-r--r--include/clang/AST/Type.h542
-rw-r--r--include/clang/AST/TypeLoc.h10
-rw-r--r--include/clang/AST/TypeOrdering.h6
-rw-r--r--include/clang/AST/TypeVisitor.h8
-rw-r--r--include/clang/Analysis/Analyses/LiveVariables.h42
-rw-r--r--include/clang/Analysis/Analyses/UninitializedValues.h24
-rw-r--r--include/clang/Analysis/AnalysisDiagnostic.h2
-rw-r--r--include/clang/Analysis/CFG.h132
-rw-r--r--include/clang/Analysis/FlowSensitive/DataflowSolver.h100
-rw-r--r--include/clang/Analysis/FlowSensitive/DataflowValues.h56
-rw-r--r--include/clang/Analysis/LocalCheckers.h20
-rw-r--r--include/clang/Analysis/PathDiagnostic.h208
-rw-r--r--include/clang/Analysis/PathSensitive/AnalysisContext.h20
-rw-r--r--include/clang/Analysis/PathSensitive/AnalysisManager.h42
-rw-r--r--include/clang/Analysis/PathSensitive/BasicValueFactory.h60
-rw-r--r--include/clang/Analysis/PathSensitive/BugReporter.h192
-rw-r--r--include/clang/Analysis/PathSensitive/Checker.h32
-rw-r--r--include/clang/Analysis/PathSensitive/CheckerVisitor.h10
-rw-r--r--include/clang/Analysis/PathSensitive/ConstraintManager.h14
-rw-r--r--include/clang/Analysis/PathSensitive/Environment.h32
-rw-r--r--include/clang/Analysis/PathSensitive/ExplodedGraph.h142
-rw-r--r--include/clang/Analysis/PathSensitive/GRAuditor.h8
-rw-r--r--include/clang/Analysis/PathSensitive/GRBlockCounter.h16
-rw-r--r--include/clang/Analysis/PathSensitive/GRCoreEngine.h190
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngine.h296
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h16
-rw-r--r--include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h6
-rw-r--r--include/clang/Analysis/PathSensitive/GRState.h244
-rw-r--r--include/clang/Analysis/PathSensitive/GRStateTrait.h82
-rw-r--r--include/clang/Analysis/PathSensitive/GRSubEngine.h18
-rw-r--r--include/clang/Analysis/PathSensitive/GRTransferFuncs.h32
-rw-r--r--include/clang/Analysis/PathSensitive/GRWorkList.h26
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h282
-rw-r--r--include/clang/Analysis/PathSensitive/SVals.h160
-rw-r--r--include/clang/Analysis/PathSensitive/SValuator.h22
-rw-r--r--include/clang/Analysis/PathSensitive/Store.h52
-rw-r--r--include/clang/Analysis/PathSensitive/SymbolManager.h138
-rw-r--r--include/clang/Analysis/PathSensitive/ValueManager.h59
-rw-r--r--include/clang/Analysis/ProgramPoint.h110
-rw-r--r--include/clang/Analysis/Support/BlkExprDeclBitVector.h126
-rw-r--r--include/clang/Analysis/Support/Optional.h12
-rw-r--r--include/clang/Analysis/Support/SaveAndRestore.h6
-rw-r--r--include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h14
-rw-r--r--include/clang/Analysis/Visitors/CFGRecStmtVisitor.h4
-rw-r--r--include/clang/Analysis/Visitors/CFGStmtVisitor.h60
-rw-r--r--include/clang/Analysis/Visitors/CFGVarDeclVisitor.h20
-rw-r--r--include/clang/Basic/Builtins.h16
-rw-r--r--include/clang/Basic/ConvertUTF.h24
-rw-r--r--include/clang/Basic/Diagnostic.h134
-rw-r--r--include/clang/Basic/FileManager.h34
-rw-r--r--include/clang/Basic/IdentifierTable.h118
-rw-r--r--include/clang/Basic/LangOptions.h30
-rw-r--r--include/clang/Basic/OnDiskHashTable.h88
-rw-r--r--include/clang/Basic/SourceLocation.h90
-rw-r--r--include/clang/Basic/SourceManager.h210
-rw-r--r--include/clang/Basic/SourceManagerInternals.h24
-rw-r--r--include/clang/Basic/TargetInfo.h80
-rw-r--r--include/clang/Basic/TokenKinds.h2
-rw-r--r--include/clang/CodeGen/ModuleBuilder.h6
-rw-r--r--include/clang/Driver/Action.h38
-rw-r--r--include/clang/Driver/Arg.h46
-rw-r--r--include/clang/Driver/ArgList.h26
-rw-r--r--include/clang/Driver/Compilation.h10
-rw-r--r--include/clang/Driver/Driver.h16
-rw-r--r--include/clang/Driver/DriverDiagnostic.h2
-rw-r--r--include/clang/Driver/HostInfo.h18
-rw-r--r--include/clang/Driver/Job.h22
-rw-r--r--include/clang/Driver/Option.h88
-rw-r--r--include/clang/Driver/Options.h4
-rw-r--r--include/clang/Driver/Tool.h8
-rw-r--r--include/clang/Frontend/ASTConsumers.h4
-rw-r--r--include/clang/Frontend/ASTUnit.h6
-rw-r--r--include/clang/Frontend/CommandLineSourceLoc.h14
-rw-r--r--include/clang/Frontend/CompileOptions.h2
-rw-r--r--include/clang/Frontend/DocumentXML.h59
-rw-r--r--include/clang/Frontend/FixItRewriter.h4
-rw-r--r--include/clang/Frontend/FrontendDiagnostic.h2
-rw-r--r--include/clang/Frontend/ManagerRegistry.h2
-rw-r--r--include/clang/Frontend/PCHBitCodes.h34
-rw-r--r--include/clang/Frontend/PCHReader.h112
-rw-r--r--include/clang/Frontend/PCHWriter.h24
-rw-r--r--include/clang/Frontend/PathDiagnosticClients.h8
-rw-r--r--include/clang/Frontend/TextDiagnosticPrinter.h8
-rw-r--r--include/clang/Frontend/Utils.h2
-rw-r--r--include/clang/Index/ASTLocation.h10
-rw-r--r--include/clang/Index/DeclReferenceMap.h8
-rw-r--r--include/clang/Index/Entity.h14
-rw-r--r--include/clang/Index/GlobalSelector.h14
-rw-r--r--include/clang/Index/Handlers.h2
-rw-r--r--include/clang/Index/Indexer.h6
-rw-r--r--include/clang/Index/Program.h2
-rw-r--r--include/clang/Index/STLExtras.h6
-rw-r--r--include/clang/Index/SelectorMap.h8
-rw-r--r--include/clang/Lex/DirectoryLookup.h40
-rw-r--r--include/clang/Lex/HeaderMap.h14
-rw-r--r--include/clang/Lex/HeaderSearch.h50
-rw-r--r--include/clang/Lex/LexDiagnostic.h2
-rw-r--r--include/clang/Lex/Lexer.h94
-rw-r--r--include/clang/Lex/LiteralSupport.h44
-rw-r--r--include/clang/Lex/MacroInfo.h54
-rw-r--r--include/clang/Lex/MultipleIncludeOpt.h22
-rw-r--r--include/clang/Lex/PPCallbacks.h28
-rw-r--r--include/clang/Lex/PTHLexer.h32
-rw-r--r--include/clang/Lex/PTHManager.h44
-rw-r--r--include/clang/Lex/Pragma.h14
-rw-r--r--include/clang/Lex/Preprocessor.h196
-rw-r--r--include/clang/Lex/PreprocessorLexer.h56
-rw-r--r--include/clang/Lex/ScratchBuffer.h4
-rw-r--r--include/clang/Lex/Token.h70
-rw-r--r--include/clang/Lex/TokenConcatenation.h16
-rw-r--r--include/clang/Lex/TokenLexer.h40
-rw-r--r--include/clang/Parse/Action.h344
-rw-r--r--include/clang/Parse/AttributeList.h26
-rw-r--r--include/clang/Parse/DeclSpec.h185
-rw-r--r--include/clang/Parse/Designator.h44
-rw-r--r--include/clang/Parse/Ownership.h66
-rw-r--r--include/clang/Parse/ParseDiagnostic.h2
-rw-r--r--include/clang/Parse/Parser.h182
-rw-r--r--include/clang/Parse/Scope.h46
-rw-r--r--include/clang/Rewrite/DeltaTree.h8
-rw-r--r--include/clang/Rewrite/HTMLRewrite.h20
-rw-r--r--include/clang/Rewrite/RewriteRope.h58
-rw-r--r--include/clang/Rewrite/Rewriter.h50
-rw-r--r--include/clang/Rewrite/TokenRewriter.h24
-rw-r--r--include/clang/Sema/ExternalSemaSource.h8
-rw-r--r--include/clang/Sema/ParseAST.h2
-rw-r--r--include/clang/Sema/SemaConsumer.h4
-rw-r--r--include/clang/Sema/SemaDiagnostic.h2
-rw-r--r--lib/AST/APValue.cpp2
-rw-r--r--lib/AST/ASTContext.cpp801
-rw-r--r--lib/AST/Decl.cpp92
-rw-r--r--lib/AST/DeclBase.cpp98
-rw-r--r--lib/AST/DeclCXX.cpp118
-rw-r--r--lib/AST/DeclObjC.cpp74
-rw-r--r--lib/AST/DeclPrinter.cpp125
-rw-r--r--lib/AST/DeclTemplate.cpp88
-rw-r--r--lib/AST/DeclarationName.cpp30
-rw-r--r--lib/AST/Expr.cpp245
-rw-r--r--lib/AST/ExprCXX.cpp111
-rw-r--r--lib/AST/ExprConstant.cpp218
-rw-r--r--lib/AST/InheritViz.cpp6
-rw-r--r--lib/AST/NestedNameSpecifier.cpp28
-rw-r--r--lib/AST/ParentMap.cpp10
-rw-r--r--lib/AST/RecordLayoutBuilder.cpp102
-rw-r--r--lib/AST/RecordLayoutBuilder.h18
-rw-r--r--lib/AST/Stmt.cpp48
-rw-r--r--lib/AST/StmtDumper.cpp66
-rw-r--r--lib/AST/StmtIterator.cpp40
-rw-r--r--lib/AST/StmtPrinter.cpp137
-rw-r--r--lib/AST/StmtProfile.cpp62
-rw-r--r--lib/AST/StmtViz.cpp12
-rw-r--r--lib/AST/TemplateName.cpp22
-rw-r--r--lib/AST/Type.cpp165
-rw-r--r--lib/AST/TypeLoc.cpp62
-rw-r--r--lib/Analysis/AnalysisContext.cpp18
-rw-r--r--lib/Analysis/AnalysisManager.cpp6
-rw-r--r--lib/Analysis/BasicConstraintManager.cpp62
-rw-r--r--lib/Analysis/BasicObjCFoundationChecks.cpp210
-rw-r--r--lib/Analysis/BasicObjCFoundationChecks.h14
-rw-r--r--lib/Analysis/BasicStore.cpp192
-rw-r--r--lib/Analysis/BasicValueFactory.cpp118
-rw-r--r--lib/Analysis/BugReporter.cpp641
-rw-r--r--lib/Analysis/BugReporterVisitors.cpp118
-rw-r--r--lib/Analysis/CFG.cpp194
-rw-r--r--lib/Analysis/CFRefCount.cpp1275
-rw-r--r--lib/Analysis/CallGraph.cpp18
-rw-r--r--lib/Analysis/CheckDeadStores.cpp90
-rw-r--r--lib/Analysis/CheckNSError.cpp90
-rw-r--r--lib/Analysis/CheckObjCDealloc.cpp122
-rw-r--r--lib/Analysis/CheckObjCInstMethSignature.cpp30
-rw-r--r--lib/Analysis/CheckObjCUnusedIVars.cpp24
-rw-r--r--lib/Analysis/CheckSecuritySyntaxOnly.cpp123
-rw-r--r--lib/Analysis/Environment.cpp66
-rw-r--r--lib/Analysis/ExplodedGraph.cpp70
-rw-r--r--lib/Analysis/GRBlockCounter.cpp2
-rw-r--r--lib/Analysis/GRCoreEngine.cpp230
-rw-r--r--lib/Analysis/GRExprEngine.cpp1247
-rw-r--r--lib/Analysis/GRExprEngineInternalChecks.cpp206
-rw-r--r--lib/Analysis/GRState.cpp84
-rw-r--r--lib/Analysis/LiveVariables.cpp120
-rw-r--r--lib/Analysis/MemRegion.cpp38
-rw-r--r--lib/Analysis/PathDiagnostic.cpp32
-rw-r--r--lib/Analysis/RangeConstraintManager.cpp60
-rw-r--r--lib/Analysis/RegionStore.cpp504
-rw-r--r--lib/Analysis/SVals.cpp60
-rw-r--r--lib/Analysis/SValuator.cpp64
-rw-r--r--lib/Analysis/SimpleConstraintManager.cpp40
-rw-r--r--lib/Analysis/SimpleConstraintManager.h18
-rw-r--r--lib/Analysis/SimpleSValuator.cpp88
-rw-r--r--lib/Analysis/Store.cpp54
-rw-r--r--lib/Analysis/SymbolManager.cpp62
-rw-r--r--lib/Analysis/UninitializedValues.cpp84
-rw-r--r--lib/Analysis/ValueManager.cpp26
-rw-r--r--lib/Basic/Builtins.cpp18
-rw-r--r--lib/Basic/ConvertUTF.c606
-rw-r--r--lib/Basic/Diagnostic.cpp98
-rw-r--r--lib/Basic/FileManager.cpp57
-rw-r--r--lib/Basic/IdentifierTable.cpp58
-rw-r--r--lib/Basic/SourceLocation.cpp4
-rw-r--r--lib/Basic/SourceManager.cpp200
-rw-r--r--lib/Basic/TargetInfo.cpp50
-rw-r--r--lib/Basic/Targets.cpp74
-rw-r--r--lib/CodeGen/CGBlocks.cpp30
-rw-r--r--lib/CodeGen/CGBlocks.h10
-rw-r--r--lib/CodeGen/CGBuiltin.cpp154
-rw-r--r--lib/CodeGen/CGCXX.cpp612
-rw-r--r--lib/CodeGen/CGCXX.h2
-rw-r--r--lib/CodeGen/CGCXXTemp.cpp56
-rw-r--r--lib/CodeGen/CGCall.cpp146
-rw-r--r--lib/CodeGen/CGCall.h8
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp170
-rw-r--r--lib/CodeGen/CGDebugInfo.h28
-rw-r--r--lib/CodeGen/CGDecl.cpp88
-rw-r--r--lib/CodeGen/CGExpr.cpp5
-rw-r--r--lib/CodeGen/CGExprAgg.cpp78
-rw-r--r--lib/CodeGen/CGExprConstant.cpp270
-rw-r--r--lib/CodeGen/CGExprScalar.cpp3
-rw-r--r--lib/CodeGen/CGObjC.cpp215
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp255
-rw-r--r--lib/CodeGen/CGObjCMac.cpp63
-rw-r--r--lib/CodeGen/CGObjCRuntime.h30
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.cpp122
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.h44
-rw-r--r--lib/CodeGen/CGStmt.cpp206
-rw-r--r--lib/CodeGen/CGValue.h40
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp222
-rw-r--r--lib/CodeGen/CodeGenFunction.h128
-rw-r--r--lib/CodeGen/CodeGenModule.cpp334
-rw-r--r--lib/CodeGen/CodeGenModule.h54
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp92
-rw-r--r--lib/CodeGen/CodeGenTypes.h52
-rw-r--r--lib/CodeGen/Mangle.cpp121
-rw-r--r--lib/CodeGen/Mangle.h6
-rw-r--r--lib/CodeGen/ModuleBuilder.cpp14
-rw-r--r--lib/CodeGen/TargetABIInfo.cpp12
-rw-r--r--lib/Driver/Action.cpp12
-rw-r--r--lib/Driver/Arg.cpp23
-rw-r--r--lib/Driver/ArgList.cpp30
-rw-r--r--lib/Driver/Compilation.cpp36
-rw-r--r--lib/Driver/Driver.cpp3
-rw-r--r--lib/Driver/HostInfo.cpp4
-rw-r--r--lib/Driver/Job.cpp6
-rw-r--r--lib/Driver/OptTable.cpp12
-rw-r--r--lib/Driver/Option.cpp57
-rw-r--r--lib/Driver/Tool.cpp2
-rw-r--r--lib/Driver/ToolChain.cpp6
-rw-r--r--lib/Driver/ToolChains.cpp39
-rw-r--r--lib/Driver/ToolChains.h6
-rw-r--r--lib/Driver/Tools.cpp50
-rw-r--r--lib/Driver/Tools.h100
-rw-r--r--lib/Driver/Types.cpp46
-rw-r--r--lib/Frontend/ASTConsumers.cpp50
-rw-r--r--lib/Frontend/ASTUnit.cpp36
-rw-r--r--lib/Frontend/AnalysisConsumer.cpp144
-rw-r--r--lib/Frontend/Backend.cpp58
-rw-r--r--lib/Frontend/CacheTokens.cpp178
-rw-r--r--lib/Frontend/DeclXML.cpp74
-rw-r--r--lib/Frontend/DependencyFile.cpp16
-rw-r--r--lib/Frontend/DiagChecker.cpp32
-rw-r--r--lib/Frontend/DocumentXML.cpp151
-rw-r--r--lib/Frontend/FixItRewriter.cpp22
-rw-r--r--lib/Frontend/GeneratePCH.cpp8
-rw-r--r--lib/Frontend/HTMLDiagnostics.cpp236
-rw-r--r--lib/Frontend/HTMLPrint.cpp8
-rw-r--r--lib/Frontend/InitHeaderSearch.cpp36
-rw-r--r--lib/Frontend/InitPreprocessor.cpp80
-rw-r--r--lib/Frontend/PCHReader.cpp302
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp50
-rw-r--r--lib/Frontend/PCHReaderStmt.cpp64
-rw-r--r--lib/Frontend/PCHWriter.cpp230
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp48
-rw-r--r--lib/Frontend/PCHWriterStmt.cpp52
-rw-r--r--lib/Frontend/PlistDiagnostics.cpp110
-rw-r--r--lib/Frontend/PrintParserCallbacks.cpp67
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp96
-rw-r--r--lib/Frontend/RewriteBlocks.cpp287
-rw-r--r--lib/Frontend/RewriteMacros.cpp36
-rw-r--r--lib/Frontend/RewriteObjC.cpp1167
-rw-r--r--lib/Frontend/RewriteTest.cpp4
-rw-r--r--lib/Frontend/StmtXML.cpp72
-rw-r--r--lib/Frontend/TextDiagnosticBuffer.cpp2
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp4
-rw-r--r--lib/Frontend/TypeXML.cpp72
-rw-r--r--lib/Frontend/Warnings.cpp14
-rw-r--r--lib/Headers/stdarg.h2
-rw-r--r--lib/Index/ASTLocation.cpp16
-rw-r--r--lib/Index/Analyzer.cpp30
-rw-r--r--lib/Index/DeclReferenceMap.cpp6
-rw-r--r--lib/Index/Entity.cpp22
-rw-r--r--lib/Index/EntityImpl.h4
-rw-r--r--lib/Index/GlobalSelector.cpp4
-rw-r--r--lib/Index/Indexer.cpp8
-rw-r--r--lib/Index/ProgramImpl.h6
-rw-r--r--lib/Index/ResolveLocation.cpp16
-rw-r--r--lib/Lex/HeaderMap.cpp44
-rw-r--r--lib/Lex/HeaderSearch.cpp112
-rw-r--r--lib/Lex/Lexer.cpp296
-rw-r--r--lib/Lex/LiteralSupport.cpp182
-rw-r--r--lib/Lex/MacroArgs.cpp34
-rw-r--r--lib/Lex/MacroArgs.h26
-rw-r--r--lib/Lex/MacroInfo.cpp12
-rw-r--r--lib/Lex/PPCaching.cpp2
-rw-r--r--lib/Lex/PPDirectives.cpp350
-rw-r--r--lib/Lex/PPExpressions.cpp96
-rw-r--r--lib/Lex/PPLexerChange.cpp68
-rw-r--r--lib/Lex/PPMacroExpansion.cpp160
-rw-r--r--lib/Lex/PTHLexer.cpp218
-rw-r--r--lib/Lex/Pragma.cpp130
-rw-r--r--lib/Lex/Preprocessor.cpp76
-rw-r--r--lib/Lex/PreprocessorLexer.cpp4
-rw-r--r--lib/Lex/ScratchBuffer.cpp10
-rw-r--r--lib/Lex/TokenConcatenation.cpp42
-rw-r--r--lib/Lex/TokenLexer.cpp120
-rw-r--r--lib/Parse/AttributeList.cpp18
-rw-r--r--lib/Parse/DeclSpec.cpp22
-rw-r--r--lib/Parse/ExtensionRAIIObject.h2
-rw-r--r--lib/Parse/MinimalAction.cpp44
-rw-r--r--lib/Parse/ParseCXXInlineMethods.cpp18
-rw-r--r--lib/Parse/ParseDecl.cpp356
-rw-r--r--lib/Parse/ParseDeclCXX.cpp245
-rw-r--r--lib/Parse/ParseExpr.cpp104
-rw-r--r--lib/Parse/ParseExprCXX.cpp100
-rw-r--r--lib/Parse/ParseInit.cpp40
-rw-r--r--lib/Parse/ParseObjc.cpp272
-rw-r--r--lib/Parse/ParsePragma.cpp34
-rw-r--r--lib/Parse/ParsePragma.h18
-rw-r--r--lib/Parse/ParseStmt.cpp94
-rw-r--r--lib/Parse/ParseTemplate.cpp162
-rw-r--r--lib/Parse/ParseTentative.cpp14
-rw-r--r--lib/Parse/Parser.cpp92
-rw-r--r--lib/Rewrite/DeltaTree.cpp106
-rw-r--r--lib/Rewrite/HTMLRewrite.cpp142
-rw-r--r--lib/Rewrite/RewriteRope.cpp184
-rw-r--r--lib/Rewrite/Rewriter.cpp44
-rw-r--r--lib/Rewrite/TokenRewriter.cpp20
-rw-r--r--lib/Sema/IdentifierResolver.cpp16
-rw-r--r--lib/Sema/IdentifierResolver.h10
-rw-r--r--lib/Sema/JumpDiagnostics.cpp60
-rw-r--r--lib/Sema/ParseAST.cpp14
-rw-r--r--lib/Sema/Sema.cpp100
-rw-r--r--lib/Sema/Sema.h688
-rw-r--r--lib/Sema/SemaAccess.cpp19
-rw-r--r--lib/Sema/SemaAttr.cpp38
-rw-r--r--lib/Sema/SemaCXXCast.cpp67
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp126
-rw-r--r--lib/Sema/SemaChecking.cpp340
-rw-r--r--lib/Sema/SemaDecl.cpp722
-rw-r--r--lib/Sema/SemaDeclAttr.cpp17
-rw-r--r--lib/Sema/SemaDeclCXX.cpp803
-rw-r--r--lib/Sema/SemaDeclObjC.cpp574
-rw-r--r--lib/Sema/SemaExpr.cpp697
-rw-r--r--lib/Sema/SemaExprCXX.cpp233
-rw-r--r--lib/Sema/SemaExprObjC.cpp161
-rw-r--r--lib/Sema/SemaInherit.cpp40
-rw-r--r--lib/Sema/SemaInherit.h25
-rw-r--r--lib/Sema/SemaInit.cpp300
-rw-r--r--lib/Sema/SemaLookup.cpp256
-rw-r--r--lib/Sema/SemaOverload.cpp743
-rw-r--r--lib/Sema/SemaOverload.h20
-rw-r--r--lib/Sema/SemaStmt.cpp196
-rw-r--r--lib/Sema/SemaTemplate.cpp726
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp544
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp219
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp352
-rw-r--r--lib/Sema/SemaType.cpp213
-rw-r--r--lib/Sema/TreeTransform.h2219
-rw-r--r--test/Analysis/cfref_rdar6080742.c18
-rw-r--r--test/CodeGen/asm.c2
-rw-r--r--test/CodeGen/attr-cleanup.c2
-rw-r--r--test/CodeGen/conditional.c21
-rw-r--r--test/CodeGen/debug-info.c6
-rw-r--r--test/CodeGen/exprs.c6
-rw-r--r--test/CodeGen/functions.c4
-rw-r--r--test/CodeGen/global-with-initialiser.c6
-rw-r--r--test/CodeGen/globalinit.c2
-rw-r--r--test/CodeGen/init-with-member-expr.c2
-rw-r--r--test/CodeGen/regparm.c5
-rw-r--r--test/CodeGen/staticinit.c6
-rw-r--r--test/CodeGen/struct-init.c4
-rw-r--r--test/CodeGen/struct.c43
-rw-r--r--test/CodeGen/union-init.c28
-rw-r--r--test/CodeGen/vector.c10
-rw-r--r--test/CodeGenCXX/constructor-conversion.cpp35
-rw-r--r--test/CodeGenCXX/constructor-default-arg.cpp36
-rw-r--r--test/CodeGenCXX/constructor-for-array-members.cpp9
-rw-r--r--test/CodeGenCXX/constructor-init.cpp27
-rw-r--r--test/CodeGenCXX/constructor-template.cpp4
-rw-r--r--test/CodeGenCXX/conversion-function.cpp80
-rw-r--r--test/CodeGenCXX/copy-assign-synthesis-1.cpp14
-rw-r--r--test/CodeGenCXX/copy-constructor-elim.cpp29
-rw-r--r--test/CodeGenCXX/copy-constructor-synthesis.cpp79
-rw-r--r--test/CodeGenCXX/default-constructor-for-members.cpp4
-rw-r--r--test/CodeGenCXX/default-destructor-synthesis.cpp24
-rw-r--r--test/CodeGenCXX/nested-base-member-access.cpp17
-rw-r--r--test/CodeGenCXX/virt.cpp2
-rw-r--r--test/Lexer/comment-escape.c2
-rw-r--r--test/Parser/MicrosoftExtensions.c16
-rw-r--r--test/Parser/cxx-friend.cpp2
-rw-r--r--test/Parser/cxx-template-decl.cpp2
-rw-r--r--test/Preprocessor/assembler-with-cpp.c2
-rw-r--r--test/Sema/array-init.c17
-rw-r--r--test/Sema/attr-deprecated.c2
-rw-r--r--test/Sema/block-call.c52
-rw-r--r--test/Sema/block-explicit-return-type.c66
-rw-r--r--test/Sema/block-literal.c42
-rw-r--r--test/Sema/block-misc.c24
-rw-r--r--test/Sema/block-printf-attribute-1.c17
-rw-r--r--test/Sema/block-return.c4
-rw-r--r--test/Sema/block-sentinel-attribute.c25
-rw-r--r--test/Sema/c89-2.c2
-rw-r--r--test/Sema/c89.c2
-rw-r--r--test/Sema/complex-int.c5
-rw-r--r--test/Sema/conditional.c10
-rw-r--r--test/Sema/darwin-align-cast.c4
-rw-r--r--test/Sema/floating-point-compare.c4
-rw-r--r--test/Sema/function-pointer-sentinel-attribute.c23
-rw-r--r--test/Sema/function-sentinel-attr.c2
-rw-r--r--test/Sema/implicit-int.c6
-rw-r--r--test/Sema/predefined-function.c17
-rw-r--r--test/Sema/static-init.c4
-rw-r--r--test/Sema/struct-decl.c20
-rw-r--r--test/Sema/transparent-union-pointer.c8
-rw-r--r--test/SemaCXX/abstract.cpp57
-rw-r--r--test/SemaCXX/access-control-check.cpp2
-rw-r--r--test/SemaCXX/attr-format.cpp12
-rw-r--r--test/SemaCXX/class-base-member-init.cpp6
-rw-r--r--test/SemaCXX/constructor-initializer.cpp14
-rw-r--r--test/SemaCXX/copy-constructor-error.cpp6
-rw-r--r--test/SemaCXX/default-assignment-operator.cpp16
-rw-r--r--test/SemaCXX/default-constructor-initializers.cpp6
-rw-r--r--test/SemaCXX/enum.cpp11
-rw-r--r--test/SemaCXX/illegal-member-initialization.cpp10
-rw-r--r--test/SemaCXX/inherit.cpp2
-rw-r--r--test/SemaCXX/member-expr-static.cpp18
-rw-r--r--test/SemaCXX/static-initializers.cpp10
-rw-r--r--test/SemaCXX/warn-reorder-ctor-initialization.cpp8
-rw-r--r--tools/clang-cc/clang-cc.cpp308
-rw-r--r--tools/index-test/index-test.cpp26
467 files changed, 23013 insertions, 23310 deletions
diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h
index 80d1107ce2..94d258d9e4 100644
--- a/include/clang/AST/APValue.h
+++ b/include/clang/AST/APValue.h
@@ -37,16 +37,16 @@ public:
};
private:
ValueKind Kind;
-
- struct ComplexAPSInt {
- APSInt Real, Imag;
+
+ struct ComplexAPSInt {
+ APSInt Real, Imag;
ComplexAPSInt() : Real(1), Imag(1) {}
};
struct ComplexAPFloat {
APFloat Real, Imag;
ComplexAPFloat() : Real(0.0), Imag(0.0) {}
};
-
+
struct LV {
Expr* Base;
uint64_t Offset;
@@ -57,9 +57,9 @@ private:
Vec() : Elts(0), NumElts(0) {}
~Vec() { delete[] Elts; }
};
-
+
enum {
- MaxSize = (sizeof(ComplexAPSInt) > sizeof(ComplexAPFloat) ?
+ MaxSize = (sizeof(ComplexAPSInt) > sizeof(ComplexAPFloat) ?
sizeof(ComplexAPSInt) : sizeof(ComplexAPFloat))
};
@@ -94,7 +94,7 @@ public:
~APValue() {
MakeUninit();
}
-
+
ValueKind getKind() const { return Kind; }
bool isUninit() const { return Kind == Uninitialized; }
bool isInt() const { return Kind == Int; }
@@ -103,10 +103,10 @@ public:
bool isComplexFloat() const { return Kind == ComplexFloat; }
bool isLValue() const { return Kind == LValue; }
bool isVector() const { return Kind == Vector; }
-
+
void print(llvm::raw_ostream &OS) const;
void dump() const;
-
+
APSInt &getInt() {
assert(isInt() && "Invalid accessor");
return *(APSInt*)(char*)Data;
@@ -114,7 +114,7 @@ public:
const APSInt &getInt() const {
return const_cast<APValue*>(this)->getInt();
}
-
+
APFloat &getFloat() {
assert(isFloat() && "Invalid accessor");
return *(APFloat*)(char*)Data;
@@ -122,7 +122,7 @@ public:
const APFloat &getFloat() const {
return const_cast<APValue*>(this)->getFloat();
}
-
+
APValue &getVectorElt(unsigned i) const {
assert(isVector() && "Invalid accessor");
return ((Vec*)(char*)Data)->Elts[i];
@@ -131,7 +131,7 @@ public:
assert(isVector() && "Invalid accessor");
return ((Vec*)(void *)Data)->NumElts;
}
-
+
APSInt &getComplexIntReal() {
assert(isComplexInt() && "Invalid accessor");
return ((ComplexAPSInt*)(char*)Data)->Real;
@@ -139,7 +139,7 @@ public:
const APSInt &getComplexIntReal() const {
return const_cast<APValue*>(this)->getComplexIntReal();
}
-
+
APSInt &getComplexIntImag() {
assert(isComplexInt() && "Invalid accessor");
return ((ComplexAPSInt*)(char*)Data)->Imag;
@@ -147,7 +147,7 @@ public:
const APSInt &getComplexIntImag() const {
return const_cast<APValue*>(this)->getComplexIntImag();
}
-
+
APFloat &getComplexFloatReal() {
assert(isComplexFloat() && "Invalid accessor");
return ((ComplexAPFloat*)(char*)Data)->Real;
@@ -172,7 +172,7 @@ public:
assert(isLValue() && "Invalid accessor");
return ((const LV*)(const void*)Data)->Offset;
}
-
+
void setInt(const APSInt &I) {
assert(isInt() && "Invalid accessor");
*(APSInt*)(char*)Data = I;
@@ -189,14 +189,14 @@ public:
((Vec*)(char*)Data)->Elts[i] = E[i];
}
void setComplexInt(const APSInt &R, const APSInt &I) {
- assert(R.getBitWidth() == I.getBitWidth() &&
+ assert(R.getBitWidth() == I.getBitWidth() &&
"Invalid complex int (type mismatch).");
assert(isComplexInt() && "Invalid accessor");
((ComplexAPSInt*)(char*)Data)->Real = R;
((ComplexAPSInt*)(char*)Data)->Imag = I;
}
void setComplexFloat(const APFloat &R, const APFloat &I) {
- assert(&R.getSemantics() == &I.getSemantics() &&
+ assert(&R.getSemantics() == &I.getSemantics() &&
"Invalid complex float (type mismatch).");
assert(isComplexFloat() && "Invalid accessor");
((ComplexAPFloat*)(char*)Data)->Real = R;
@@ -207,9 +207,9 @@ public:
((LV*)(char*)Data)->Base = B;
((LV*)(char*)Data)->Offset = O;
}
-
+
const APValue &operator=(const APValue &RHS);
-
+
private:
void MakeUninit();
void MakeInt() {
@@ -248,7 +248,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const APValue &V) {
V.print(OS);
return OS;
}
-
+
} // end namespace clang.
#endif
diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h
index 6dc7e13d8f..af6bf30b68 100644
--- a/include/clang/AST/ASTConsumer.h
+++ b/include/clang/AST/ASTConsumer.h
@@ -36,27 +36,27 @@ public:
ASTConsumer() : SemaConsumer(false) { }
virtual ~ASTConsumer() {}
-
+
/// Initialize - This is called to initialize the consumer, providing the
/// ASTContext and the Action.
virtual void Initialize(ASTContext &Context) {}
-
+
/// HandleTopLevelDecl - Handle the specified top-level declaration. This is
/// called by the parser to process every top-level Decl*. Note that D can
/// be the head of a chain of Decls (e.g. for `int a, b` the chain will have
/// two elements). Use Decl::getNextDeclarator() to walk the chain.
virtual void HandleTopLevelDecl(DeclGroupRef D);
-
+
/// HandleTranslationUnit - This method is called when the ASTs for entire
/// translation unit have been parsed.
- virtual void HandleTranslationUnit(ASTContext &Ctx) {}
-
+ virtual void HandleTranslationUnit(ASTContext &Ctx) {}
+
/// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
/// (e.g. struct, union, enum, class) is completed. This allows the client to
/// hack on the type, which can occur at any point in the file (because these
/// can be defined in declspecs).
virtual void HandleTagDeclDefinition(TagDecl *D) {}
-
+
/// \brief Callback invoked at the end of a translation unit to
/// notify the consumer that the given tentative definition should
/// be completed.
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index f9419fb3c2..9c5e31cd74 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -56,12 +56,12 @@ namespace clang {
class TypedefDecl;
class UnresolvedUsingDecl;
class UsingDecl;
-
+
namespace Builtin { class Context; }
-
+
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
-class ASTContext {
+class ASTContext {
std::vector<Type*> Types;
llvm::FoldingSet<ExtQualType> ExtQualTypes;
llvm::FoldingSet<ComplexType> ComplexTypes;
@@ -87,7 +87,7 @@ class ASTContext {
llvm::FoldingSet<ObjCInterfaceType> ObjCInterfaceTypes;
llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
-
+
llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
@@ -108,7 +108,7 @@ class ASTContext {
llvm::DenseMap<unsigned, FixedWidthIntType*> SignedFixedWidthIntTypes;
llvm::DenseMap<unsigned, FixedWidthIntType*> UnsignedFixedWidthIntTypes;
-
+
/// BuiltinVaListType - built-in va list type.
/// This is initially null and set by Sema::LazilyCreateBuiltin when
/// a builtin that takes a valist is encountered.
@@ -116,33 +116,33 @@ class ASTContext {
/// ObjCIdType - a pseudo built-in typedef type (set by Sema).
QualType ObjCIdTypedefType;
-
+
/// ObjCSelType - another pseudo built-in typedef type (set by Sema).
QualType ObjCSelType;
const RecordType *SelStructType;
-
+
/// ObjCProtoType - another pseudo built-in typedef type (set by Sema).
QualType ObjCProtoType;
const RecordType *ProtoStructType;
/// ObjCClassType - another pseudo built-in typedef type (set by Sema).
QualType ObjCClassTypedefType;
-
+
QualType ObjCConstantStringType;
RecordDecl *CFConstantStringTypeDecl;
RecordDecl *ObjCFastEnumerationStateTypeDecl;
-
+
/// \brief The type for the C FILE type.
TypeDecl *FILEDecl;
-
+
/// \brief The type for the C jmp_buf type.
TypeDecl *jmp_bufDecl;
-
+
/// \brief The type for the C sigjmp_buf type.
TypeDecl *sigjmp_bufDecl;
-
- /// \brief Keeps track of all declaration attributes.
+
+ /// \brief Keeps track of all declaration attributes.
///
/// Since so few decls have attrs, we keep them in a hash map instead of
/// wasting space in the Decl class.
@@ -153,7 +153,7 @@ class ASTContext {
///
/// This data structure stores the mapping from instantiations of static
/// data members to the static data member representations within the
- /// class template from which they were instantiated.
+ /// class template from which they were instantiated.
///
/// Given the following example:
///
@@ -169,11 +169,11 @@ class ASTContext {
/// int *x = &X<int>::value;
/// \endcode
///
- /// This mapping will contain an entry that maps from the VarDecl for
+ /// This mapping will contain an entry that maps from the VarDecl for
/// X<int>::value to the corresponding VarDecl for X<T>::value (within the
- /// class template X).
+ /// class template X).
llvm::DenseMap<VarDecl *, VarDecl *> InstantiatedFromStaticDataMember;
-
+
/// \brief Keeps track of the UnresolvedUsingDecls from which UsingDecls
/// where created during instantiation.
///
@@ -196,14 +196,14 @@ class ASTContext {
/// B<int> to the UnresolvedUsingDecl in B<T>.
llvm::DenseMap<UsingDecl *, UnresolvedUsingDecl *>
InstantiatedFromUnresolvedUsingDecl;
-
+
llvm::DenseMap<FieldDecl *, FieldDecl *> InstantiatedFromUnnamedFieldDecl;
-
+
TranslationUnitDecl *TUDecl;
/// SourceMgr - The associated SourceManager object.
SourceManager &SourceMgr;
-
+
/// LangOpts - The language options used to create the AST associated with
/// this ASTContext object.
LangOptions LangOpts;
@@ -211,17 +211,17 @@ class ASTContext {
/// \brief Whether we have already loaded comment source ranges from an
/// external source.
bool LoadedExternalComments;
-
+
/// MallocAlloc/BumpAlloc - The allocator objects used to create AST objects.
bool FreeMemory;
llvm::MallocAllocator MallocAlloc;
llvm::BumpPtrAllocator BumpAlloc;
-
+
/// \brief Mapping from declarations to their comments, once we have
/// already looked up the comment associated with a given declaration.
llvm::DenseMap<const Decl *, std::string> DeclComments;
-
-public:
+
+public:
TargetInfo &Target;
IdentifierTable &Idents;
SelectorTable &Selectors;
@@ -238,38 +238,38 @@ public:
/// \brief Source ranges for all of the comments in the source file,
/// sorted in order of appearance in the translation unit.
std::vector<SourceRange> Comments;
-
+
SourceManager& getSourceManager() { return SourceMgr; }
const SourceManager& getSourceManager() const { return SourceMgr; }
void *Allocate(unsigned Size, unsigned Align = 8) {
return FreeMemory ? MallocAlloc.Allocate(Size, Align) :
BumpAlloc.Allocate(Size, Align);
}
- void Deallocate(void *Ptr) {
+ void Deallocate(void *Ptr) {
if (FreeMemory)
- MallocAlloc.Deallocate(Ptr);
+ MallocAlloc.Deallocate(Ptr);
}
const LangOptions& getLangOptions() const { return LangOpts; }
-
- FullSourceLoc getFullLoc(SourceLocation Loc) const {
+
+ FullSourceLoc getFullLoc(SourceLocation Loc) const {
return FullSourceLoc(Loc,SourceMgr);
}
/// \brief Retrieve the attributes for the given declaration.
Attr*& getDeclAttrs(const Decl *D) { return DeclAttrs[D]; }
-
+
/// \brief Erase the attributes corresponding to the given declaration.
void eraseDeclAttrs(const Decl *D) { DeclAttrs.erase(D); }
/// \brief If this variable is an instantiated static data member of a
- /// class template specialization, returns the templated static data member
+ /// class template specialization, returns the templated static data member
/// from which it was instantiated.
VarDecl *getInstantiatedFromStaticDataMember(VarDecl *Var);
-
+
/// \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);
-
+ void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl);
+
/// \brief If this using decl is instantiated from an unresolved using decl,
/// return it.
UnresolvedUsingDecl *getInstantiatedFromUnresolvedUsingDecl(UsingDecl *UUD);
@@ -278,17 +278,17 @@ public:
/// the unresolved using decl \p Tmpl of a class template.
void setInstantiatedFromUnresolvedUsingDecl(UsingDecl *Inst,
UnresolvedUsingDecl *Tmpl);
-
-
+
+
FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field);
-
+
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl);
-
+
TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
-
+
const char *getCommentForDecl(const Decl *D);
-
+
// Builtin Types.
QualType VoidTy;
QualType BoolTy;
@@ -331,27 +331,27 @@ public:
//===--------------------------------------------------------------------===//
// Type Constructors
//===--------------------------------------------------------------------===//
-
- /// getAddSpaceQualType - Return the uniqued reference to the type for an
- /// address space qualified type with the specified type and address space.
- /// The resulting type has a union of the qualifiers from T and the address
- /// space. If T already has an address space specifier, it is silently
+
+ /// getAddSpaceQualType - Return the uniqued reference to the type for an
+ /// address space qualified type with the specified type and address space.
+ /// The resulting type has a union of the qualifiers from T and the address
+ /// space. If T already has an address space specifier, it is silently
/// replaced.
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace);
-
+
/// getObjCGCQualType - Returns the uniqued reference to the type for an
/// objc gc qualified type. The retulting type has a union of the qualifiers
/// from T and the gc attribute.
QualType getObjCGCQualType(QualType T, QualType::GCAttrTypes gcAttr);
-
+
/// getNoReturnType - Add the noreturn attribute to the given type which must
/// be a FunctionType or a pointer to an allowable type or a BlockPointer.
QualType getNoReturnType(QualType T);
-
+
/// getComplexType - Return the uniqued reference to the type for a complex
/// number with the specified element type.
QualType getComplexType(QualType T);
-
+
/// getPointerType - Return the uniqued reference to the type for a pointer to
/// the specified type.
QualType getPointerType(QualType T);
@@ -379,7 +379,7 @@ public:
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals,
SourceRange Brackets);
-
+
/// getDependentSizedArrayType - Returns a non-unique reference to
/// the type for a dependently-sized array of the specified element
/// type. FIXME: We will need these to be uniqued, or at least
@@ -430,7 +430,7 @@ public:
/// the type for a dependently-sized vector of the specified element
/// type. FIXME: We will need these to be uniqued, or at least
/// comparable, at some point.
- QualType getDependentSizedExtVectorType(QualType VectorType,
+ QualType getDependentSizedExtVectorType(QualType VectorType,
Expr *SizeExpr,
SourceLocation AttrLoc);
@@ -455,7 +455,7 @@ public:
/// specified typename decl.
QualType getTypedefType(TypedefDecl *Decl);
- QualType getTemplateTypeParmType(unsigned Depth, unsigned Index,
+ QualType getTemplateTypeParmType(unsigned Depth, unsigned Index,
bool ParameterPack,
IdentifierInfo *Name = 0);
@@ -466,17 +466,17 @@ public:
QualType getQualifiedNameType(NestedNameSpecifier *NNS,
QualType NamedType);
- QualType getTypenameType(NestedNameSpecifier *NNS,
+ QualType getTypenameType(NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
QualType Canon = QualType());
- QualType getTypenameType(NestedNameSpecifier *NNS,
+ QualType getTypenameType(NestedNameSpecifier *NNS,
const TemplateSpecializationType *TemplateId,
QualType Canon = QualType());
QualType getElaboratedType(QualType UnderlyingType,
ElaboratedType::TagKind Tag);
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
- ObjCProtocolDecl **Protocols = 0,
+ ObjCProtocolDecl **Protocols = 0,
unsigned NumProtocols = 0);
/// getObjCObjectPointerType - Return a ObjCObjectPointerType type for the
@@ -484,18 +484,18 @@ public:
QualType getObjCObjectPointerType(QualType OIT,
ObjCProtocolDecl **ProtocolList = 0,
unsigned NumProtocols = 0);
-
+
/// getTypeOfType - GCC extension.
QualType getTypeOfExprType(Expr *e);
QualType getTypeOfType(QualType t);
-
+
/// getDecltypeType - C++0x decltype.
QualType getDecltypeType(Expr *e);
-
+
/// getTagDeclType - Return the unique reference to the type for the
/// specified TagDecl (struct/union/class/enum) decl.
QualType getTagDeclType(const TagDecl *Decl);
-
+
/// getSizeType - Return the unique type for "size_t" (C99 7.17), defined
/// in <stddef.h>. The sizeof operator requires this (C99 6.5.3.4p4).
QualType getSizeType() const;
@@ -512,15 +512,15 @@ public:
/// getUnsignedWCharType - Return the type of "unsigned wchar_t".
/// Used when in C++, as a GCC extension.
QualType getUnsignedWCharType() const;
-
+
/// getPointerDiffType - Return the unique type for "ptrdiff_t" (ref?)
/// defined in <stddef.h>. Pointer - pointer requires this (C99 6.5.6p9).
QualType getPointerDiffType() const;
-
+
// getCFConstantStringType - Return the C structure type used to represent
// constant CFStrings.
- QualType getCFConstantStringType();
-
+ QualType getCFConstantStringType();
+
/// Get the structure type used to representation CFStrings, or NULL
/// if it hasn't yet been built.
QualType getRawCFConstantStringType() {
@@ -532,13 +532,13 @@ public:
// This setter/getter represents the ObjC type for an NSConstantString.
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);
- QualType getObjCConstantStringInterface() const {
- return ObjCConstantStringType;
+ QualType getObjCConstantStringInterface() const {
+ return ObjCConstantStringType;
}
//// This gets the struct used to keep track of fast enumerations.
QualType getObjCFastEnumerationStateType();
-
+
/// Get the ObjCFastEnumerationState type, or NULL if it hasn't yet
/// been built.
QualType getRawObjCFastEnumerationStateType() {
@@ -551,10 +551,10 @@ public:
/// \brief Set the type for the C FILE type.
void setFILEDecl(TypeDecl *FILEDecl) { this->FILEDecl = FILEDecl; }
-
+
/// \brief Retrieve the C FILE type.
- QualType getFILEType() {
- if (FILEDecl)
+ QualType getFILEType() {
+ if (FILEDecl)
return getTypeDeclType(FILEDecl);
return QualType();
}
@@ -563,10 +563,10 @@ public:
void setjmp_bufDecl(TypeDecl *jmp_bufDecl) {
this->jmp_bufDecl = jmp_bufDecl;
}
-
+
/// \brief Retrieve the C jmp_buf type.
- QualType getjmp_bufType() {
- if (jmp_bufDecl)
+ QualType getjmp_bufType() {
+ if (jmp_bufDecl)
return getTypeDeclType(jmp_bufDecl);
return QualType();
}
@@ -575,41 +575,41 @@ public:
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl) {
this->sigjmp_bufDecl = sigjmp_bufDecl;
}
-
+
/// \brief Retrieve the C sigjmp_buf type.
- QualType getsigjmp_bufType() {
- if (sigjmp_bufDecl)
+ QualType getsigjmp_bufType() {
+ if (sigjmp_bufDecl)
return getTypeDeclType(sigjmp_bufDecl);
return QualType();
}
-
+
/// getObjCEncodingForType - Emit the ObjC type encoding for the
/// given type into \arg S. If \arg NameFields is specified then
/// record field names are also encoded.
- void getObjCEncodingForType(QualType t, std::string &S,
+ void getObjCEncodingForType(QualType t, std::string &S,
const FieldDecl *Field=0);
void getLegacyIntegralTypeEncoding(QualType &t) const;
-
+
// Put the string version of type qualifiers into S.
- void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
+ void getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
std::string &S) const;
-
+
/// getObjCEncodingForMethodDecl - Return the encoded type for this method
/// declaration.
void getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl, std::string &S);
-
+
/// getObjCEncodingForPropertyDecl - Return the encoded type for
/// this method declaration. If non-NULL, Container must be either
/// an ObjCCategoryImplDecl or ObjCImplementationDecl; it should
/// only be NULL when getting encodings for protocol properties.
- void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
+ void getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
const Decl *Container,
std::string &S);
-
+
bool ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto,
ObjCProtocolDecl *rProto);
-
+
/// getObjCEncodingTypeSize returns size of type for objective-c encoding
/// purpose.
int getObjCEncodingTypeSize(QualType t);
@@ -618,32 +618,32 @@ public:
/// Sema. id is always a (typedef for a) pointer type, a pointer to a struct.
QualType getObjCIdType() const { return ObjCIdTypedefType; }
void setObjCIdType(QualType T);
-
+
void setObjCSelType(QualType T);
QualType getObjCSelType() const { return ObjCSelType; }
-
+
void setObjCProtoType(QualType QT);
QualType getObjCProtoType() const { return ObjCProtoType; }
-
+
/// This setter/getter repreents the ObjC 'Class' type. It is setup lazily, by
/// Sema. 'Class' is always a (typedef for a) pointer type, a pointer to a
/// struct.
QualType getObjCClassType() const { return ObjCClassTypedefType; }
void setObjCClassType(QualType T);
-
+
void setBuiltinVaListType(QualType T);
QualType getBuiltinVaListType() const { return BuiltinVaListType; }
QualType getFixedWidthIntType(unsigned Width, bool Signed);
- TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
+ TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
TemplateDecl *Template);
- TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
+ TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
OverloadedFunctionDecl *Template);
-
- TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
+
+ TemplateName getDependentTemplateName(NestedNameSpecifier *NNS,
const IdentifierInfo *Name);
enum GetBuiltinTypeError {
@@ -651,42 +651,42 @@ public:
GE_Missing_stdio, //< Missing a type from <stdio.h>
GE_Missing_setjmp //< Missing a type from <setjmp.h>
};
-
+
/// GetBuiltinType - Return the type for the specified builtin.
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error);
-
+
private:
QualType getFromTargetType(unsigned Type) const;
//===--------------------------------------------------------------------===//
// Type Predicates.
//===--------------------------------------------------------------------===//
-
+
public:
/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
/// garbage collection attribute.
///
QualType::GCAttrTypes getObjCGCAttrKind(const QualType &Ty) const;
-
+
/// isObjCNSObjectType - Return true if this is an NSObject object with
/// its NSObject attribute set.
bool isObjCNSObjectType(QualType Ty) const;
-
+
//===--------------------------------------------------------------------===//
// Type Sizing and Analysis
//===--------------------------------------------------------------------===//
-
+
/// getFloatTypeSemantics - Return the APFloat 'semantics' for the specified
/// scalar floating point type.
const llvm::fltSemantics &getFloatTypeSemantics(QualType T) const;
-
+
/// getTypeInfo - Get the size and alignment of the specified complete type in
/// bits.
std::pair<uint64_t, unsigned> getTypeInfo(const Type *T);
std::pair<uint64_t, unsigned> getTypeInfo(QualType T) {
return getTypeInfo(T.getTypePtr());
}
-
+
/// getTypeSize - Return the size of the specified type, in bits. This method
/// does not work on incomplete types.
uint64_t getTypeSize(QualType T) {
@@ -695,7 +695,7 @@ public:
uint64_t getTypeSize(const Type *T) {
return getTypeInfo(T).first;
}
-
+
/// getTypeAlign - Return the ABI-specified alignment of a type, in bits.
/// This method does not work on incomplete types.
unsigned getTypeAlign(QualType T) {
@@ -704,23 +704,23 @@ public:
unsigned getTypeAlign(const Type *T) {
return getTypeInfo(T).second;
}
-
+
/// getPreferredTypeAlign - Return the "preferred" alignment of the specified
/// type for the current target in bits. This can be different than the ABI
/// alignment in cases where it is beneficial for performance to overalign
/// a data type.
unsigned getPreferredTypeAlign(const Type *T);
-
+
/// getDeclAlignInBytes - Return the alignment of the specified decl
/// that should be returned by __alignof(). Note that bitfields do
/// not have a valid alignment, so this method will assert on them.
unsigned getDeclAlignInBytes(const Decl *D);
-
+
/// getASTRecordLayout - Get or compute information about the layout of the
/// specified record (struct/union/class), which indicates its size and field
/// position information.
const ASTRecordLayout &getASTRecordLayout(const RecordDecl *D);
-
+
/// getASTObjCInterfaceLayout - Get or compute information about the
/// layout of the specified Objective-C interface.
const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D);
@@ -747,7 +747,7 @@ public:
//===--------------------------------------------------------------------===//
// Type Operators
//===--------------------------------------------------------------------===//
-
+
/// getCanonicalType - Return the canonical (structural) type corresponding to
/// the specified potentially non-canonical type. The non-canonical version
/// of a type may have many "decorated" versions of types. Decorators can
@@ -763,7 +763,7 @@ public:
bool hasSameType(QualType T1, QualType T2) {
return getCanonicalType(T1) == getCanonicalType(T2);
}
-
+
/// \brief Determine whether the given types are equivalent after
/// cvr-qualifiers have been removed.
bool hasSameUnqualifiedType(QualType T1, QualType T2) {
@@ -772,7 +772,7 @@ public:
return T1.getUnqualifiedType() == T2.getUnqualifiedType();
}
- /// \brief Retrieves the "canonical" declaration of
+ /// \brief Retrieves the "canonical" declaration of
/// \brief Retrieves the "canonical" nested name specifier for a
/// given nested name specifier.
@@ -822,11 +822,11 @@ public:
/// \brief Retrieve the "canonical" template argument.
///
- /// The canonical template argument is the simplest template argument
- /// (which may be a type, value, expression, or declaration) that
+ /// The canonical template argument is the simplest template argument
+ /// (which may be a type, value, expression, or declaration) that
/// expresses the value of the argument.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg);
-
+
/// Type Query functions. If the type is an instance of the specified class,
/// return the Type pointer for the underlying maximally pretty type. This
/// is a member of ASTContext because this may need to do some amount of
@@ -849,10 +849,10 @@ public:
/// getBaseElementType - Returns the innermost element type of a type
/// (which needn't actually be an array type).
QualType getBaseElementType(QualType QT);
-
+
/// getConstantArrayElementCount - Returns number of constant array elements.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const;
-
+
/// getArrayDecayedType - Return the properly qualified result of decaying the
/// specified array type to a pointer. This operation is non-trivial when
/// handling typedefs etc. The canonical type of "T" must be an array type,
@@ -860,7 +860,7 @@ public:
///
/// See C99 6.7.5.3p7 and C99 6.3.2.1p3.
QualType getArrayDecayedType(QualType T);
-
+
/// getPromotedIntegerType - Returns the type that Promotable will
/// promote to: C99 6.3.1.1p2, assuming that Promotable is a promotable
/// integer type.
@@ -873,22 +873,22 @@ public:
/// promotion occurs.
QualType isPromotableBitField(Expr *E);
- /// getIntegerTypeOrder - Returns the highest ranked integer type:
+ /// getIntegerTypeOrder - Returns the highest ranked integer type:
/// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If
- /// LHS < RHS, return -1.
+ /// LHS < RHS, return -1.
int getIntegerTypeOrder(QualType LHS, QualType RHS);
-
+
/// getFloatingTypeOrder - Compare the rank of the two specified floating
/// point types, ignoring the domain of the type (i.e. 'double' ==
/// '_Complex double'). If LHS > RHS, return 1. If LHS == RHS, return 0. If
- /// LHS < RHS, return -1.
+ /// LHS < RHS, return -1.
int getFloatingTypeOrder(QualType LHS, QualType RHS);
- /// getFloatingTypeOfSizeWithinDomain - Returns a real floating
- /// point or a complex type (based on typeDomain/typeSize).
+ /// getFloatingTypeOfSizeWithinDomain - Returns a real floating
+ /// point or a complex type (based on typeDomain/typeSize).
/// 'typeDomain' is a real floating point or complex type.
/// 'typeSize' is a real floating point or complex type.
- QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
+ QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
QualType typeDomain) const;
private:
@@ -900,10 +900,10 @@ public:
//===--------------------------------------------------------------------===//
// Type Compatibility Predicates
//===--------------------------------------------------------------------===//
-
+
/// Compatibility predicates used to check assignment expressions.
bool typesAreCompatible(QualType, QualType); // C99 6.2.7p1
-
+
bool isObjCIdType(QualType T) const {
return T == ObjCIdTypedefType;
}
@@ -950,15 +950,15 @@ public:
//===--------------------------------------------------------------------===//
// Type Iterators.
//===--------------------------------------------------------------------===//
-
+
typedef std::vector<Type*>::iterator type_iterator;
typedef std::vector<Type*>::const_iterator const_type_iterator;
-
+
type_iterator types_begin() { return Types.begin(); }
type_iterator types_end() { return Types.end(); }
const_type_iterator types_begin() const { return Types.begin(); }
- const_type_iterator types_end() const { return Types.end(); }
-
+ const_type_iterator types_end() const { return Types.end(); }
+
//===--------------------------------------------------------------------===//
// Integer Values
//===--------------------------------------------------------------------===//
@@ -996,12 +996,12 @@ public:
private:
ASTContext(const ASTContext&); // DO NOT IMPLEMENT
void operator=(const ASTContext&); // DO NOT IMPLEMENT
-
+
void InitBuiltinTypes();
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
-
+
// Return the ObjC type encoding for a given type.
- void getObjCEncodingForTypeImpl(QualType t, std::string &S,
+ void getObjCEncodingForTypeImpl(QualType t, std::string &S,
bool ExpandPointedToStructures,
bool ExpandStructures,
const FieldDecl *Field,
@@ -1009,7 +1009,7 @@ private:
bool EncodingProperty = false);
const ASTRecordLayout &getObjCLayout(const ObjCInterfaceDecl *D,
- const ObjCImplementationDecl *Impl);
+ const ObjCImplementationDecl *Impl);
};
} // end namespace clang
diff --git a/include/clang/AST/ASTDiagnostic.h b/include/clang/AST/ASTDiagnostic.h
index e9f150574b..abd36f7e5f 100644
--- a/include/clang/AST/ASTDiagnostic.h
+++ b/include/clang/AST/ASTDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define ASTSTART
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h
index 43844d6e82..f7a47364a7 100644
--- a/include/clang/AST/Attr.h
+++ b/include/clang/AST/Attr.h
@@ -57,7 +57,7 @@ public:
DLLImport,
Deprecated,
Destructor,
- FastCall,
+ FastCall,
Format,
FormatArg,
GNUInline,
@@ -83,14 +83,14 @@ public:
StdCall,
TransparentUnion,
Unavailable,
- Unused,
+ Unused,
Used,
Visibility,
WarnUnusedResult,
Weak,
WeakImport
};
-
+
private:
Attr *Next;
Kind AttrKind;
@@ -104,16 +104,16 @@ protected:
void operator delete(void* data) throw() {
assert(0 && "Attrs cannot be released with regular 'delete'.");
}
-
+
protected:
Attr(Kind AK) : Next(0), AttrKind(AK), Inherited(false) {}
virtual ~Attr() {
assert(Next == 0 && "Destroy didn't work");
}
public:
-
+
void Destroy(ASTContext &C);
-
+
/// \brief Whether this attribute should be merged to new
/// declarations.
virtual bool isMerged() const { return true; }
@@ -130,18 +130,18 @@ public:
return V;
return 0;
}
-
+
bool isInherited() const { return Inherited; }
void setInherited(bool value) { Inherited = value; }
void addAttr(Attr *attr) {
assert((attr != 0) && "addAttr(): attr is null");
-
+
// FIXME: This doesn't preserve the order in any way.
attr->Next = Next;
Next = attr;
}
-
+
// Clone this attribute.
virtual Attr* clone(ASTContext &C) const = 0;
@@ -169,8 +169,8 @@ public:
/// getAlignment - The specified alignment in bits.
unsigned getAlignment() const { return Alignment; }
- virtual Attr* clone(ASTContext &C) const {
- return ::new (C) PragmaPackAttr(Alignment);
+ virtual Attr* clone(ASTContext &C) const {
+ return ::new (C) PragmaPackAttr(Alignment);
}
// Implement isa/cast/dyncast/etc.
@@ -179,7 +179,7 @@ public:
}
static bool classof(const PragmaPackAttr *A) { return true; }
};
-
+
class AlignedAttr : public Attr {
unsigned Alignment;
public:
@@ -189,7 +189,7 @@ public:
unsigned getAlignment() const { return Alignment; }
virtual Attr* clone(ASTContext &C) const { return ::new (C) AlignedAttr(Alignment); }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() == Aligned;
@@ -201,11 +201,11 @@ class AnnotateAttr : public Attr {
std::string Annotation;
public:
AnnotateAttr(const std::string &ann) : Attr(Annotate), Annotation(ann) {}
-
+
const std::string& getAnnotation() const { return Annotation; }
virtual Attr* clone(ASTContext &C) const { return ::new (C) AnnotateAttr(Annotation); }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() == Annotate;
@@ -217,11 +217,11 @@ class AsmLabelAttr : public Attr {
std::string Label;
public:
AsmLabelAttr(const std::string &L) : Attr(AsmLabel), Label(L) {}
-
+
const std::string& getLabel() const { return Label; }
-
+
virtual Attr* clone(ASTContext &C) const { return ::new (C) AsmLabelAttr(Label); }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() == AsmLabel;
@@ -251,28 +251,28 @@ public:
ConstructorAttr(int p) : Attr(Constructor), priority(p) {}
int getPriority() const { return priority; }
-
+
virtual Attr *clone(ASTContext &C) const { return ::new (C) ConstructorAttr(priority); }
// Implement isa/cast/dyncast/etc.
- static bool classof(const Attr *A) { return A->getKind() == Constructor; }
+ static bool classof(const Attr *A) { return A->getKind() == Constructor; }
static bool classof(const ConstructorAttr *A) { return true; }
-};
-
+};
+
class DestructorAttr : public Attr {
int priority;
public:
DestructorAttr(int p) : Attr(Destructor), priority(p) {}
int getPriority() const { return priority; }
-
+
virtual Attr *clone(ASTContext &C) const { return ::new (C) DestructorAttr(priority); }
// Implement isa/cast/dyncast/etc.
- static bool classof(const Attr *A) { return A->getKind() == Destructor; }
+ static bool classof(const Attr *A) { return A->getKind() == Destructor; }
static bool classof(const DestructorAttr *A) { return true; }
-};
-
+};
+
class GNUInlineAttr : public Attr {
public:
GNUInlineAttr() : Attr(GNUInline) {}
@@ -301,14 +301,14 @@ public:
DEF_SIMPLE_ATTR(Malloc);
DEF_SIMPLE_ATTR(NoReturn);
-DEF_SIMPLE_ATTR(AnalyzerNoReturn);
+DEF_SIMPLE_ATTR(AnalyzerNoReturn);
DEF_SIMPLE_ATTR(Deprecated);
class SectionAttr : public Attr {
std::string Name;
public:
SectionAttr(const std::string &N) : Attr(Section), Name(N) {}
-
+
const std::string& getName() const { return Name; }
virtual Attr *clone(ASTContext &C) const { return ::new (C) SectionAttr(Name); }
@@ -322,8 +322,8 @@ public:
DEF_SIMPLE_ATTR(Unavailable);
DEF_SIMPLE_ATTR(Unused);
-DEF_SIMPLE_ATTR(Used);
-DEF_SIMPLE_ATTR(Weak);
+DEF_SIMPLE_ATTR(Used);
+DEF_SIMPLE_ATTR(Weak);
DEF_SIMPLE_ATTR(WeakImport);
DEF_SIMPLE_ATTR(NoThrow);
DEF_SIMPLE_ATTR(Const);
@@ -335,14 +335,14 @@ class NonNullAttr : public Attr {
public:
NonNullAttr(unsigned* arg_nums = 0, unsigned size = 0) : Attr(NonNull),
ArgNums(0), Size(0) {
-
+
if (size == 0) return;
assert(arg_nums);
ArgNums = new unsigned[size];
Size = size;
memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size);
}
-
+
virtual ~NonNullAttr() {
delete [] ArgNums;
}
@@ -354,7 +354,7 @@ public:
bool isNonNull(unsigned arg) const {
return ArgNums ? std::binary_search(ArgNums, ArgNums+Size, arg) : true;
- }
+ }
virtual Attr *clone(ASTContext &C) const { return ::new (C) NonNullAttr(ArgNums, Size); }
@@ -374,8 +374,8 @@ public:
int getFormatIdx() const { return formatIdx; }
int getFirstArg() const { return firstArg; }
- virtual Attr *clone(ASTContext &C) const {
- return ::new (C) FormatAttr(Type, formatIdx, firstArg);
+ virtual Attr *clone(ASTContext &C) const {
+ return ::new (C) FormatAttr(Type, formatIdx, firstArg);
}
// Implement isa/cast/dyncast/etc.
@@ -452,8 +452,8 @@ public:
virtual bool isMerged() const { return false; }
- virtual Attr *clone(ASTContext &C) const {
- return ::new (C) OverloadableAttr;
+ virtual Attr *clone(ASTContext &C) const {
+ return ::new (C) OverloadableAttr;
}
static bool classof(const Attr *A) { return A->getKind() == Overloadable; }
@@ -480,15 +480,15 @@ public:
};
class FunctionDecl;
-
+
class CleanupAttr : public Attr {
FunctionDecl *FD;
-
+
public:
CleanupAttr(FunctionDecl *fd) : Attr(Cleanup), FD(fd) {}
const FunctionDecl *getFunctionDecl() const { return FD; }
-
+
virtual Attr *clone(ASTContext &C) const { return ::new (C) CleanupAttr(FD); }
// Implement isa/cast/dyncast/etc.
@@ -497,7 +497,7 @@ public:
};
DEF_SIMPLE_ATTR(NoDebug);
-DEF_SIMPLE_ATTR(WarnUnusedResult);
+DEF_SIMPLE_ATTR(WarnUnusedResult);
DEF_SIMPLE_ATTR(NoInline);
class RegparmAttr : public Attr {
@@ -508,11 +508,11 @@ public:
unsigned getNumParams() const { return NumParams; }
- virtual Attr *clone(ASTContext &C) const {
- return ::new (C) RegparmAttr(NumParams);
+ virtual Attr *clone(ASTContext &C) const {
+ return ::new (C) RegparmAttr(NumParams);
}
- // Implement isa/cast/dyncast/etc.
+ // Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) { return A->getKind() == Regparm; }
static bool classof(const RegparmAttr *A) { return true; }
};
@@ -527,23 +527,23 @@ public:
unsigned getYDim() const { return Y; }
unsigned getZDim() const { return Z; }
- virtual Attr *clone(ASTContext &C) const {
- return ::new (C) ReqdWorkGroupSizeAttr(X, Y, Z);
+ virtual Attr *clone(ASTContext &C) const {
+ return ::new (C) ReqdWorkGroupSizeAttr(X, Y, Z);
}
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() == ReqdWorkGroupSize;
}
static bool classof(const ReqdWorkGroupSizeAttr *A) { return true; }
};
-
+
// Checker-specific attributes.
DEF_SIMPLE_ATTR(CFReturnsRetained);
DEF_SIMPLE_ATTR(NSReturnsRetained);
#undef DEF_SIMPLE_ATTR
-
+
} // end namespace clang
#endif
diff --git a/include/clang/AST/CanonicalType.h b/include/clang/AST/CanonicalType.h
index 186c677411..be163eb5a8 100644
--- a/include/clang/AST/CanonicalType.h
+++ b/include/clang/AST/CanonicalType.h
@@ -21,69 +21,69 @@
#include <iterator>
namespace clang {
-
+
template<typename T> class CanProxy;
template<typename T> struct CanProxyAdaptor;
//----------------------------------------------------------------------------//
// Canonical, qualified type template
//----------------------------------------------------------------------------//
-
+
/// \brief Represents a canonical, potentially-qualified type.
///
/// The CanQual template is a lightweight smart pointer that provides access
/// to the canonical representation of a type, where all typedefs and other
-/// syntactic sugar has been eliminated. A CanQualType may also have various
+/// syntactic sugar has been eliminated. A CanQualType may also have various
/// qualifiers (const, volatile, restrict) attached to it.
///
-/// The template type parameter @p T is one of the Type classes (PointerType,
+/// The template type parameter @p T is one of the Type classes (PointerType,
/// BuiltinType, etc.). The type stored within @c CanQual<T> will be of that
/// type (or some subclass of that type). The typedef @c CanQualType is just
/// a shorthand for @c CanQual<Type>.
///
-/// An instance of @c CanQual<T> can be implicitly converted to a
+/// An instance of @c CanQual<T> can be implicitly converted to a
/// @c CanQual<U> when T is derived from U, which essentially provides an
-/// implicit upcast. For example, @c CanQual<LValueReferenceType> can be
-/// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can
+/// implicit upcast. For example, @c CanQual<LValueReferenceType> can be
+/// converted to @c CanQual<ReferenceType>. Note that any @c CanQual type can
/// be implicitly converted to a QualType, but the reverse operation requires
/// a call to ASTContext::getCanonicalType().
-///
-///
+///
+///
template<typename T = Type>
class CanQual {
- /// \brief The actual, canonical type.
+ /// \brief The actual, canonical type.
QualType Stored;
-
+
public:
/// \brief Constructs a NULL canonical type.
CanQual() : Stored() { }
-
+
/// \brief Converting constructor that permits implicit upcasting of
/// canonical type pointers.
template<typename U>
- CanQual(const CanQual<U>& Other,
+ CanQual(const CanQual<U>& Other,
typename llvm::enable_if<llvm::is_base_of<T, U>, int>::type = 0);
-
+
/// \brief Implicit conversion to the underlying pointer.
///
/// Also provides the ability to use canonical types in a boolean context,
- /// e.g.,
+ /// e.g.,
/// @code
/// if (CanQual<PointerType> Ptr = T->getAs<PointerType>()) { ... }
/// @endcode
operator const T*() const { return getTypePtr(); }
-
- /// \brief Retrieve the underlying type pointer, which refers to a
+
+ /// \brief Retrieve the underlying type pointer, which refers to a
/// canonical type.
T *getTypePtr() const { return cast_or_null<T>(Stored.getTypePtr()); }
-
+
/// \brief Implicit conversion to a qualified type.
operator QualType() const { return Stored; }
-
+
/// \brief Retrieve a canonical type pointer with a different static type,
/// upcasting or downcasting as needed.
///
- /// The getAs() function is typically used to try to downcast to a
+ /// The getAs() function is typically used to try to downcast to a
/// more specific (canonical) type in the type system. For example:
///
/// @code
@@ -98,17 +98,17 @@ public:
/// static type (@p U). If the dynamic type is not the specified static type
/// or a derived class thereof, a NULL canonical type.
template<typename U> CanProxy<U> getAs() const;
-
+
/// \brief Overloaded arrow operator that produces a canonical type
/// proxy.
CanProxy<T> operator->() const;
-
+
/// \brief Retrieve the const/volatile/restrict qualifiers.
unsigned getCVRQualifiers() const { return Stored.getCVRQualifiers(); }
-
+
/// \brief Set the const/volatile/restrict qualifiers
void setCVRQualifiers(unsigned Quals) { Stored.setCVRQualifiers(Quals); }
-
+
bool isConstQualified() const {
return (getCVRQualifiers() & QualType::Const) ? true : false;
}
@@ -117,42 +117,42 @@ public:
}
bool isRestrictQualified() const {
return (getCVRQualifiers() & QualType::Restrict) ? true : false;
- }
-
+ }
+
/// \brief Retrieve the unqualified form of this type.
CanQual<T> getUnqualifiedType() const;
-
+
CanQual<T> getQualifiedType(unsigned TQs) const {
return CanQual<T>::CreateUnsafe(QualType(getTypePtr(), TQs));
}
-
- /// \brief Determines whether this canonical type is more qualified than
+
+ /// \brief Determines whether this canonical type is more qualified than
/// the @p Other canonical type.
bool isMoreQualifiedThan(CanQual<T> Other) const {
return Stored.isMoreQualifiedThan(Other.Stored);
}
-
+
/// \brief Determines whether this canonical type is at least as qualified as
/// the @p Other canonical type.
bool isAtLeastAsQualifiedAs(CanQual<T> Other) const {
return Stored.isAtLeastAsQualifiedAs(Other.Stored);
}
-
+
/// \brief If the canonical type is a reference type, returns the type that
/// it refers to; otherwise, returns the type itself.
CanQual<Type> getNonReferenceType() const;
-
+
/// \brief Retrieve the internal representation of this canonical type.
void *getAsOpaquePtr() const { return Stored.getAsOpaquePtr(); }
-
+
/// \brief Construct a canonical type from its internal representation.
static CanQual<T> getFromOpaquePtr(void *Ptr);
-
+
/// \brief Builds a canonical type from a QualType.
///
- /// This routine is inherently unsafe, because it requires the user to
- /// ensure that the given type is a canonical type with the correct
- // (dynamic) type.
+ /// This routine is inherently unsafe, because it requires the user to
+ /// ensure that the given type is a canonical type with the correct
+ // (dynamic) type.
static CanQual<T> CreateUnsafe(QualType Other);
};
@@ -172,7 +172,7 @@ typedef CanQual<Type> CanQualType;
//----------------------------------------------------------------------------//
// Internal proxy classes used by canonical types
//----------------------------------------------------------------------------//
-
+
#define LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(Accessor) \
CanQualType Accessor() const { \
return CanQualType::CreateUnsafe(this->getTypePtr()->Accessor()); \
@@ -183,32 +183,32 @@ Type Accessor() const { return this->getTypePtr()->Accessor(); }
/// \brief Base class of all canonical proxy types, which is responsible for
/// storing the underlying canonical type and providing basic conversions.
-template<typename T>
+template<typename T>
class CanProxyBase {
protected:
CanQual<T> Stored;
-
+
public:
/// \brief Retrieve the pointer to the underlying Type
T* getTypePtr() const { return Stored.getTypePtr(); }
-
+
/// \brief Implicit conversion to the underlying pointer.
///
/// Also provides the ability to use canonical type proxies in a Boolean
- // context,e.g.,
+ // context,e.g.,
/// @code
/// if (CanQual<PointerType> Ptr = T->getAs<PointerType>()) { ... }
/// @endcode
operator const T*() const { return this->Stored.getTypePtr(); }
-
+
/// \brief Try to convert the given canonical type to a specific structural
/// type.
- template<typename U> CanProxy<U> getAs() const {
- return this->Stored.template getAs<U>();
+ template<typename U> CanProxy<U> getAs() const {
+ return this->Stored.template getAs<U>();
}
-
+
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Type::TypeClass, getTypeClass)
-
+
// Type predicates
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjectType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteType)
@@ -271,44 +271,44 @@ public:
/// that provide accessors returning canonical types (@c CanQualType) rather
/// than the more typical @c QualType, to propagate the notion of "canonical"
/// through the system.
-template<typename T>
+template<typename T>
struct CanProxyAdaptor : CanProxyBase<T> { };
/// \brief Canonical proxy type returned when retrieving the members of a
-/// canonical type or as the result of the @c CanQual<T>::getAs member
+/// canonical type or as the result of the @c CanQual<T>::getAs member
/// function.
///
/// The CanProxy type mainly exists as a proxy through which operator-> will
-/// look to either map down to a raw T* (e.g., PointerType*) or to a proxy
+/// look to either map down to a raw T* (e.g., PointerType*) or to a proxy
/// type that provides canonical-type access to the fields of the type.
template<typename T>
class CanProxy : public CanProxyAdaptor<T> {
public:
/// \brief Build a NULL proxy.
CanProxy() { }
-
+
/// \brief Build a proxy to the given canonical type.
CanProxy(CanQual<T> Stored) { this->Stored = Stored; }
-
+
/// \brief Implicit conversion to the stored canonical type.
operator CanQual<T>() const { return this->Stored; }
};
-
+
} // end namespace clang
namespace llvm {
-
-/// Implement simplify_type for CanQual<T>, so that we can dyn_cast from
+
+/// Implement simplify_type for CanQual<T>, so that we can dyn_cast from
/// CanQual<T> to a specific Type class. We're prefer isa/dyn_cast/cast/etc.
/// to return smart pointer (proxies?).
-template<typename T>
+template<typename T>
struct simplify_type<const ::clang::CanQual<T> > {
typedef T* SimpleType;
static SimpleType getSimplifiedValue(const ::clang::CanQual<T> &Val) {
return Val.getTypePtr();
}
};
-template<typename T>
+template<typename T>
struct simplify_type< ::clang::CanQual<T> >
: public simplify_type<const ::clang::CanQual<T> > {};
@@ -325,21 +325,21 @@ public:
// CVR qualifiers go in low bits.
enum { NumLowBitsAvailable = 0 };
};
-
+
} // end namespace llvm
namespace clang {
-
+
//----------------------------------------------------------------------------//
// Canonical proxy adaptors for canonical type nodes.
//----------------------------------------------------------------------------//
-
-/// \brief Iterator adaptor that turns an iterator over canonical QualTypes
+
+/// \brief Iterator adaptor that turns an iterator over canonical QualTypes
/// into an iterator over CanQualTypes.
template<typename InputIterator>
class CanTypeIterator {
InputIterator Iter;
-
+
public:
typedef CanQualType value_type;
typedef value_type reference;
@@ -348,62 +348,62 @@ public:
difference_type;
typedef typename std::iterator_traits<InputIterator>::iterator_category
iterator_category;
-
+
CanTypeIterator() : Iter() { }
explicit CanTypeIterator(InputIterator Iter) : Iter(Iter) { }
-
+
// Input iterator
reference operator*() const {
return CanQualType::CreateUnsafe(*Iter);
}
-
+
pointer operator->() const;
-
+
CanTypeIterator &operator++() {
++Iter;
return *this;
}
-
+
CanTypeIterator operator++(int) {
CanTypeIterator Tmp(*this);
++Iter;
return Tmp;
}
-
+
friend bool operator==(const CanTypeIterator& X, const CanTypeIterator &Y) {
return X.Iter == Y.Iter;
}
friend bool operator!=(const CanTypeIterator& X, const CanTypeIterator &Y) {
return X.Iter != Y.Iter;
}
-
+
// Bidirectional iterator
CanTypeIterator &operator--() {
--Iter;
return *this;
}
-
+
CanTypeIterator operator--(int) {
CanTypeIterator Tmp(*this);
--Iter;
return Tmp;
}
-
+
// Random access iterator
reference operator[](difference_type n) const {
return CanQualType::CreateUnsafe(Iter[n]);
}
-
+
CanTypeIterator &operator+=(difference_type n) {
Iter += n;
return *this;
}
-
+
CanTypeIterator &operator-=(difference_type n) {
Iter -= n;
return *this;
}
-
+
friend CanTypeIterator operator+(CanTypeIterator X, difference_type n) {
X += n;
return X;
@@ -413,15 +413,15 @@ public:
X += n;
return X;
}
-
+
friend CanTypeIterator operator-(CanTypeIterator X, difference_type n) {
X -= n;
return X;
}
-
- friend difference_type operator-(const CanTypeIterator &X,
+
+ friend difference_type operator-(const CanTypeIterator &X,
const CanTypeIterator &Y) {
- return X - Y;
+ return X - Y;
}
};
@@ -431,7 +431,7 @@ struct CanProxyAdaptor<ExtQualType> : public CanProxyBase<ExtQualType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(QualType::GCAttrTypes, getObjCGCAttr)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace)
};
-
+
template<>
struct CanProxyAdaptor<ComplexType> : public CanProxyBase<ComplexType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
@@ -441,66 +441,60 @@ template<>
struct CanProxyAdaptor<PointerType> : public CanProxyBase<PointerType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
};
-
+
template<>
-struct CanProxyAdaptor<BlockPointerType>
- : public CanProxyBase<BlockPointerType>
-{
+struct CanProxyAdaptor<BlockPointerType>
+ : public CanProxyBase<BlockPointerType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
};
-
+
template<>
struct CanProxyAdaptor<ReferenceType> : public CanProxyBase<ReferenceType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
};
template<>
-struct CanProxyAdaptor<LValueReferenceType>
- : public CanProxyBase<LValueReferenceType>
-{
+struct CanProxyAdaptor<LValueReferenceType>
+ : public CanProxyBase<LValueReferenceType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
};
template<>
-struct CanProxyAdaptor<RValueReferenceType>
- : public CanProxyBase<RValueReferenceType>
-{
+struct CanProxyAdaptor<RValueReferenceType>
+ : public CanProxyBase<RValueReferenceType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
};
template<>
-struct CanProxyAdaptor<MemberPointerType>
- : public CanProxyBase<MemberPointerType>
-{
+struct CanProxyAdaptor<MemberPointerType>
+ : public CanProxyBase<MemberPointerType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Type *, getClass)
};
-
+
template<>
struct CanProxyAdaptor<ArrayType> : public CanProxyBase<ArrayType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
};
template<>
-struct CanProxyAdaptor<ConstantArrayType>
- : public CanProxyBase<ConstantArrayType>
-{
+struct CanProxyAdaptor<ConstantArrayType>
+ : public CanProxyBase<ConstantArrayType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize)
};
template<>
-struct CanProxyAdaptor<ConstantArrayWithExprType>
- : public CanProxyBase<ConstantArrayWithExprType>
-{
+struct CanProxyAdaptor<ConstantArrayWithExprType>
+ : public CanProxyBase<ConstantArrayWithExprType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize)
@@ -509,34 +503,31 @@ struct CanProxyAdaptor<ConstantArrayWithExprType>
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getLBracketLoc)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getRBracketLoc)
};
-
+
template<>
-struct CanProxyAdaptor<ConstantArrayWithoutExprType>
- : public CanProxyBase<ConstantArrayWithoutExprType>
-{
+struct CanProxyAdaptor<ConstantArrayWithoutExprType>
+ : public CanProxyBase<ConstantArrayWithoutExprType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const llvm::APInt &, getSize)
};
template<>
-struct CanProxyAdaptor<IncompleteArrayType>
- : public CanProxyBase<IncompleteArrayType>
-{
+struct CanProxyAdaptor<IncompleteArrayType>
+ : public CanProxyBase<IncompleteArrayType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
};
-
+
template<>
-struct CanProxyAdaptor<VariableArrayType>
- : public CanProxyBase<VariableArrayType>
-{
+struct CanProxyAdaptor<VariableArrayType>
+ : public CanProxyBase<VariableArrayType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(ArrayType::ArraySizeModifier,
getSizeModifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndexTypeQualifier)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Expr *, getSizeExpr)
@@ -546,9 +537,8 @@ struct CanProxyAdaptor<VariableArrayType>
};
template<>
-struct CanProxyAdaptor<DependentSizedArrayType>
- : public CanProxyBase<DependentSizedArrayType>
-{
+struct CanProxyAdaptor<DependentSizedArrayType>
+ : public CanProxyBase<DependentSizedArrayType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(Expr *, getSizeExpr)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceRange, getBracketsRange)
@@ -557,14 +547,13 @@ struct CanProxyAdaptor<DependentSizedArrayType>
};
template<>
-struct CanProxyAdaptor<DependentSizedExtVectorType>
- : public CanProxyBase<DependentSizedExtVectorType>
-{
+struct CanProxyAdaptor<DependentSizedExtVectorType>
+ : public CanProxyBase<DependentSizedExtVectorType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const Expr *, getSizeExpr)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getAttributeLoc)
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(SourceLocation, getAttributeLoc)
};
-
+
template<>
struct CanProxyAdaptor<VectorType> : public CanProxyBase<VectorType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getElementType)
@@ -583,28 +572,26 @@ struct CanProxyAdaptor<FunctionType> : public CanProxyBase<FunctionType> {
};
template<>
-struct CanProxyAdaptor<FunctionNoProtoType>
- : public CanProxyBase<FunctionNoProtoType>
-{
+struct CanProxyAdaptor<FunctionNoProtoType>
+ : public CanProxyBase<FunctionNoProtoType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getResultType)
};
-
+
template<>
-struct CanProxyAdaptor<FunctionProtoType>
- : public CanProxyBase<FunctionProtoType>
-{
+struct CanProxyAdaptor<FunctionProtoType>
+ : public CanProxyBase<FunctionProtoType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getResultType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs);
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumArgs);
CanQualType getArgType(unsigned i) const {
return CanQualType::CreateUnsafe(this->getTypePtr()->getArgType(i));
}
-
+
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariadic)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getTypeQuals)
-
- typedef CanTypeIterator<FunctionProtoType::arg_type_iterator>
+
+ typedef CanTypeIterator<FunctionProtoType::arg_type_iterator>
arg_type_iterator;
-
+
arg_type_iterator arg_type_begin() const {
return arg_type_iterator(this->getTypePtr()->arg_type_begin());
}
@@ -612,10 +599,10 @@ struct CanProxyAdaptor<FunctionProtoType>
arg_type_iterator arg_type_end() const {
return arg_type_iterator(this->getTypePtr()->arg_type_end());
}
-
+
// Note: canonical function types never have exception specifications
};
-
+
template<>
struct CanProxyAdaptor<TypeOfType> : public CanProxyBase<TypeOfType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getUnderlyingType)
@@ -638,44 +625,42 @@ struct CanProxyAdaptor<RecordType> : public CanProxyBase<RecordType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(RecordDecl *, getDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasConstFields)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace)
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getAddressSpace)
};
-
+
template<>
struct CanProxyAdaptor<EnumType> : public CanProxyBase<EnumType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(EnumDecl *, getDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isBeingDefined)
};
-
+
template<>
-struct CanProxyAdaptor<TemplateTypeParmType>
- : public CanProxyBase<TemplateTypeParmType>
-{
+struct CanProxyAdaptor<TemplateTypeParmType>
+ : public CanProxyBase<TemplateTypeParmType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getDepth)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getIndex)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isParameterPack)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getName)
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(IdentifierInfo *, getName)
};
-
+
template<>
-struct CanProxyAdaptor<ObjCObjectPointerType>
- : public CanProxyBase<ObjCObjectPointerType>
-{
+struct CanProxyAdaptor<ObjCObjectPointerType>
+ : public CanProxyBase<ObjCObjectPointerType> {
LLVM_CLANG_CANPROXY_TYPE_ACCESSOR(getPointeeType)
- LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *,
+ LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(const ObjCInterfaceType *,
getInterfaceType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCIdType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCClassType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedIdType)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjCQualifiedClassType)
-
+
typedef ObjCObjectPointerType::qual_iterator qual_iterator;
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_begin)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(qual_iterator, qual_end)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, qual_empty)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(unsigned, getNumProtocols)
};
-
+
//----------------------------------------------------------------------------//
// Method and function definitions
//----------------------------------------------------------------------------//
@@ -698,12 +683,12 @@ template<typename T>
CanQual<T> CanQual<T>::getFromOpaquePtr(void *Ptr) {
CanQual<T> Result;
Result.Stored.setFromOpaqueValue(Ptr);
- assert((!Result || Result.Stored.isCanonical())
+ assert((!Result || Result.Stored.isCanonical())
&& "Type is not canonical!");
return Result;
}
-template<typename T>
+template<typename T>
CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
assert((Other.isNull() || Other->isCanonical()) && "Type is not canonical!");
assert((Other.isNull() || isa<T>(Other.getTypePtr())) &&
@@ -713,19 +698,19 @@ CanQual<T> CanQual<T>::CreateUnsafe(QualType Other) {
return Result;
}
-template<typename T>
-template<typename U>
+template<typename T>
+template<typename U>
CanProxy<U> CanQual<T>::getAs() const {
if (Stored.isNull())
return CanProxy<U>();
-
+
if (isa<U>(Stored.getTypePtr()))
return CanQual<U>::CreateUnsafe(Stored);
-
+
if (const ExtQualType *EQ = Stored->getAs<ExtQualType>())
return CanQual<T>::CreateUnsafe(QualType(EQ->getBaseType(), 0))
.template getAs<U>();
-
+
return CanProxy<U>();
}
@@ -733,13 +718,13 @@ template<typename T>
CanProxy<T> CanQual<T>::operator->() const {
return CanProxy<T>(*this);
}
-
+
template<typename InputIterator>
-typename CanTypeIterator<InputIterator>::pointer
+typename CanTypeIterator<InputIterator>::pointer
CanTypeIterator<InputIterator>::operator->() const {
return CanProxy<Type>(*this);
}
-
+
}
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index b91816e2ad..c4c7d26c51 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -53,18 +53,18 @@ public:
/// TranslationUnitDecl - The top declaration context.
class TranslationUnitDecl : public Decl, public DeclContext {
ASTContext &Ctx;
-
+
explicit TranslationUnitDecl(ASTContext &ctx)
: Decl(TranslationUnit, 0, SourceLocation()),
DeclContext(TranslationUnit),
Ctx(ctx) {}
public:
ASTContext &getASTContext() const { return Ctx; }
-
+
static TranslationUnitDecl *Create(ASTContext &C);
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == TranslationUnit; }
- static bool classof(const TranslationUnitDecl *D) { return true; }
+ static bool classof(const TranslationUnitDecl *D) { return true; }
static DeclContext *castToDeclContext(const TranslationUnitDecl *D) {
return static_cast<DeclContext *>(const_cast<TranslationUnitDecl*>(D));
}
@@ -113,7 +113,7 @@ public:
/// manipulation, so it should be called only when performance doesn't matter.
/// For simple declarations, getNameAsCString() should suffice.
std::string getNameAsString() const { return Name.getAsString(); }
-
+
/// getQualifiedNameAsString - Returns human-readable qualified name for
/// declaration, like A::B::i, for i being member of namespace A::B.
/// If declaration is not member of context which can be named (record,
@@ -141,7 +141,7 @@ public:
const NamedDecl *getUnderlyingDecl() const {
return const_cast<NamedDecl*>(this)->getUnderlyingDecl();
}
-
+
static bool classof(const Decl *D) {
return D->getKind() >= NamedFirst && D->getKind() <= NamedLast;
}
@@ -151,7 +151,7 @@ public:
/// NamespaceDecl - Represent a C++ namespace.
class NamespaceDecl : public NamedDecl, public DeclContext {
SourceLocation LBracLoc, RBracLoc;
-
+
// For extended namespace definitions:
//
// namespace A { int x; }
@@ -162,7 +162,7 @@ class NamespaceDecl : public NamedDecl, public DeclContext {
// OrigNamespace points to the original namespace declaration.
// OrigNamespace of the first namespace decl points to itself.
NamespaceDecl *OrigNamespace, *NextNamespace;
-
+
NamespaceDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
: NamedDecl(Namespace, DC, L, Id), DeclContext(Namespace) {
OrigNamespace = this;
@@ -171,7 +171,7 @@ class NamespaceDecl : public NamedDecl, public DeclContext {
public:
static NamespaceDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
-
+
virtual void Destroy(ASTContext& C);
NamespaceDecl *getNextNamespace() { return NextNamespace; }
@@ -182,7 +182,7 @@ public:
return OrigNamespace;
}
void setOriginalNamespace(NamespaceDecl *ND) { OrigNamespace = ND; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(getLocation(), RBracLoc);
}
@@ -191,7 +191,7 @@ public:
SourceLocation getRBracLoc() const { return RBracLoc; }
void setLBracLoc(SourceLocation LBrace) { LBracLoc = LBrace; }
void setRBracLoc(SourceLocation RBrace) { RBracLoc = RBrace; }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == Namespace; }
static bool classof(const NamespaceDecl *D) { return true; }
@@ -203,20 +203,20 @@ public:
}
};
-/// ValueDecl - Represent the declaration of a variable (in which case it is
+/// ValueDecl - Represent the declaration of a variable (in which case it is
/// an lvalue) a function (in which case it is a function designator) or
-/// an enum constant.
+/// an enum constant.
class ValueDecl : public NamedDecl {
QualType DeclType;
protected:
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L,
- DeclarationName N, QualType T)
+ DeclarationName N, QualType T)
: NamedDecl(DK, DC, L, N), DeclType(T) {}
public:
QualType getType() const { return DeclType; }
void setType(QualType newType) { DeclType = newType; }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= ValueFirst && D->getKind() <= ValueLast;
@@ -287,23 +287,23 @@ protected:
/// argument.
struct UnparsedDefaultArgument;
- /// \brief Placeholder type used in Init to denote an uninstantiated C++
+ /// \brief Placeholder type used in Init to denote an uninstantiated C++
/// default argument.
struct UninstantiatedDefaultArgument;
- typedef llvm::PointerUnion4<Stmt *, EvaluatedStmt *,
- UnparsedDefaultArgument *,
+ typedef llvm::PointerUnion4<Stmt *, EvaluatedStmt *,
+ UnparsedDefaultArgument *,
UninstantiatedDefaultArgument *> InitType;
-
- /// \brief The initializer for this variable or, for a ParmVarDecl, the
+
+ /// \brief The initializer for this variable or, for a ParmVarDecl, the
/// C++ default argument.
mutable InitType Init;
-
+
private:
// FIXME: This can be packed into the bitfields in Decl.
unsigned SClass : 3;
bool ThreadSpecified : 1;
- bool HasCXXDirectInit : 1;
+ bool HasCXXDirectInit : 1;
/// DeclaredInCondition - Whether this variable was declared in a
/// condition, e.g., if (int x = foo()) { ... }.
@@ -315,8 +315,8 @@ protected:
QualType T, DeclaratorInfo *DInfo, StorageClass SC)
: DeclaratorDecl(DK, DC, L, Id, T, DInfo), Init(),
ThreadSpecified(false), HasCXXDirectInit(false),
- DeclaredInCondition(false) {
- SClass = SC;
+ DeclaredInCondition(false) {
+ SClass = SC;
}
typedef Redeclarable<VarDecl> redeclarable_base;
@@ -326,7 +326,7 @@ public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
return redeclarable_base::redecls_begin();
- }
+ }
redecl_iterator redecls_end() const {
return redeclarable_base::redecls_end();
}
@@ -340,10 +340,10 @@ public:
StorageClass getStorageClass() const { return (StorageClass)SClass; }
void setStorageClass(StorageClass SC) { SClass = SC; }
-
+
virtual SourceRange getSourceRange() const;
- const Expr *getInit() const {
+ const Expr *getInit() const {
if (Init.isNull())
return 0;
@@ -352,9 +352,9 @@ public:
if (EvaluatedStmt *ES = Init.dyn_cast<EvaluatedStmt*>())
S = ES->Value;
}
- return (const Expr*) S;
+ return (const Expr*) S;
}
- Expr *getInit() {
+ Expr *getInit() {
if (Init.isNull())
return 0;
@@ -364,26 +364,26 @@ public:
S = ES->Value;
}
- return (Expr*) S;
+ return (Expr*) S;
}
/// \brief Retrieve the address of the initializer expression.
Stmt **getInitAddress() {
if (EvaluatedStmt *ES = Init.dyn_cast<EvaluatedStmt*>())
return &ES->Value;
-
+
// This union hack tip-toes around strict-aliasing rules.
union {
InitType *InitPtr;
Stmt **StmtPtr;
};
-
+
InitPtr = &Init;
return StmtPtr;
}
void setInit(ASTContext &C, Expr *I);
-
+
/// \brief Note that constant evaluation has computed the given
/// value for this variable's initializer.
void setEvaluatedValue(ASTContext &C, const APValue &Value) const {
@@ -398,7 +398,7 @@ public:
Eval->WasEvaluated = true;
Eval->Evaluated = Value;
}
-
+
/// \brief Return the already-evaluated value of this variable's
/// initializer, or NULL if the value is not yet known.
APValue *getEvaluatedValue() const {
@@ -423,7 +423,7 @@ public:
///
/// \pre isInitKnownICE()
bool isInitICE() const {
- assert(isInitKnownICE() &&
+ assert(isInitKnownICE() &&
"Check whether we already know that the initializer is an ICE");
return Init.get<EvaluatedStmt *>()->IsICE;
}
@@ -465,7 +465,7 @@ public:
bool hasCXXDirectInitializer() const {
return HasCXXDirectInit;
}
-
+
/// isDeclaredInCondition - Whether this variable was declared as
/// part of a condition in an if/switch/while statement, e.g.,
/// @code
@@ -474,8 +474,8 @@ public:
bool isDeclaredInCondition() const {
return DeclaredInCondition;
}
- void setDeclaredInCondition(bool InCondition) {
- DeclaredInCondition = InCondition;
+ void setDeclaredInCondition(bool InCondition) {
+ DeclaredInCondition = InCondition;
}
virtual VarDecl *getCanonicalDecl();
@@ -485,10 +485,10 @@ public:
bool hasLocalStorage() const {
if (getStorageClass() == None)
return !isFileVarDecl();
-
+
// Return true for: Auto, Register.
// Return false for: Extern, Static, PrivateExtern.
-
+
return getStorageClass() <= Register;
}
@@ -515,7 +515,7 @@ public:
return DC->getLookupContext()->isFunctionOrMethod();
return false;
}
-
+
/// \brief Determines whether this is a static data member.
///
/// This will only be true in C++, and applies to, e.g., the
@@ -530,10 +530,10 @@ public:
}
/// \brief If this variable is an instantiated static data member of a
- /// class template specialization, returns the templated static data member
+ /// class template specialization, returns the templated static data member
/// from which it was instantiated.
- VarDecl *getInstantiatedFromStaticDataMember();
-
+ VarDecl *getInstantiatedFromStaticDataMember();
+
/// isFileVarDecl - Returns true for file scoped variable declaration.
bool isFileVarDecl() const {
if (getKind() != Decl::Var)
@@ -545,14 +545,14 @@ public:
}
if (isStaticDataMember())
return true;
-
+
return false;
}
/// \brief Determine whether this is a tentative definition of a
/// variable in C.
bool isTentativeDefinition(ASTContext &Context) const;
-
+
/// \brief Determines whether this variable is a variable with
/// external, C linkage.
bool isExternC(ASTContext &Context) const;
@@ -567,7 +567,7 @@ public:
class ImplicitParamDecl : public VarDecl {
protected:
ImplicitParamDecl(Kind DK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, QualType Tw)
+ IdentifierInfo *Id, QualType Tw)
: VarDecl(DK, DC, L, Id, Tw, /*DInfo=*/0, VarDecl::None) {}
public:
static ImplicitParamDecl *Create(ASTContext &C, DeclContext *DC,
@@ -584,15 +584,15 @@ class ParmVarDecl : public VarDecl {
/// FIXME: Also can be paced into the bitfields in Decl.
/// in, inout, etc.
unsigned objcDeclQualifier : 6;
-
- /// \brief Retrieves the fake "value" of an unparsed
+
+ /// \brief Retrieves the fake "value" of an unparsed
static Expr *getUnparsedDefaultArgValue() {
uintptr_t Value = (uintptr_t)-1;
// Mask off the low bits
Value &= ~(uintptr_t)0x07;
return reinterpret_cast<Expr*> (Value);
}
-
+
protected:
ParmVarDecl(Kind DK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo,
@@ -606,27 +606,27 @@ public:
SourceLocation L,IdentifierInfo *Id,
QualType T, DeclaratorInfo *DInfo,
StorageClass S, Expr *DefArg);
-
+
ObjCDeclQualifier getObjCDeclQualifier() const {
return ObjCDeclQualifier(objcDeclQualifier);
}
void setObjCDeclQualifier(ObjCDeclQualifier QTVal) {
objcDeclQualifier = QTVal;
}
-
- const Expr *getDefaultArg() const {
+
+ const Expr *getDefaultArg() const {
assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
- assert(!hasUninstantiatedDefaultArg() &&
+ assert(!hasUninstantiatedDefaultArg() &&
"Default argument is not yet instantiated!");
return getInit();
}
- Expr *getDefaultArg() {
+ Expr *getDefaultArg() {
assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
- assert(!hasUninstantiatedDefaultArg() &&
+ assert(!hasUninstantiatedDefaultArg() &&
"Default argument is not yet instantiated!");
return getInit();
}
- void setDefaultArg(Expr *defarg) {
+ void setDefaultArg(Expr *defarg) {
Init = reinterpret_cast<Stmt *>(defarg);
}
@@ -636,14 +636,14 @@ public:
Expr *getUninstantiatedDefaultArg() {
return (Expr *)Init.get<UninstantiatedDefaultArgument *>();
}
-
+
/// hasDefaultArg - Determines whether this parameter has a default argument,
/// either parsed or not.
bool hasDefaultArg() const {
- return getInit() || hasUnparsedDefaultArg() ||
+ return getInit() || hasUnparsedDefaultArg() ||
hasUninstantiatedDefaultArg();
}
-
+
/// hasUnparsedDefaultArg - Determines whether this parameter has a
/// default argument that has not yet been parsed. This will occur
/// during the processing of a C++ class whose member functions have
@@ -661,18 +661,18 @@ public:
bool hasUninstantiatedDefaultArg() const {
return Init.is<UninstantiatedDefaultArgument*>();
}
-
+
/// setUnparsedDefaultArg - Specify that this parameter has an
/// unparsed default argument. The argument will be replaced with a
/// real default argument via setDefaultArg when the class
/// definition enclosing the function declaration that owns this
/// default argument is completed.
- void setUnparsedDefaultArg() {
+ void setUnparsedDefaultArg() {
Init = (UnparsedDefaultArgument *)0;
}
QualType getOriginalType() const;
-
+
/// setOwningFunction - Sets the function declaration that owns this
/// ParmVarDecl. Since ParmVarDecls are often created before the
/// FunctionDecls that own them, this routine is required to update
@@ -680,9 +680,9 @@ public:
void setOwningFunction(DeclContext *FD) { setDeclContext(FD); }
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return (D->getKind() == ParmVar ||
- D->getKind() == OriginalParmVar);
+ D->getKind() == OriginalParmVar);
}
static bool classof(const ParmVarDecl *D) { return true; }
};
@@ -698,7 +698,7 @@ protected:
private:
OriginalParmVarDecl(DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T,
- DeclaratorInfo *DInfo,
+ DeclaratorInfo *DInfo,
QualType OT, StorageClass S,
Expr *DefArg)
: ParmVarDecl(OriginalParmVar, DC, L, Id, T, DInfo, S, DefArg),
@@ -715,7 +715,7 @@ public:
static bool classof(const Decl *D) { return D->getKind() == OriginalParmVar; }
static bool classof(const OriginalParmVarDecl *D) { return true; }
};
-
+
// \brief Describes the kind of template specialization that a
// particular template specialization declaration represents.
enum TemplateSpecializationKind {
@@ -730,17 +730,17 @@ enum TemplateSpecializationKind {
/// specialization (C++ [temp.class.spec]).
TSK_ExplicitSpecialization,
/// This template specialization was instantiated from a template
- /// due to an explicit instantiation declaration request
+ /// due to an explicit instantiation declaration request
/// (C++0x [temp.explicit]).
TSK_ExplicitInstantiationDeclaration,
/// This template specialization was instantiated from a template
- /// due to an explicit instantiation definition request
+ /// due to an explicit instantiation definition request
/// (C++ [temp.explicit]).
- TSK_ExplicitInstantiationDefinition
+ TSK_ExplicitInstantiationDefinition
};
-
+
/// FunctionDecl - An instance of this class is created to represent a
-/// function declaration or definition.
+/// function declaration or definition.
///
/// Since a given function can be declared several times in a program,
/// there may be several FunctionDecls that correspond to that
@@ -749,20 +749,20 @@ enum TemplateSpecializationKind {
/// FunctionDecl (e.g., the translation unit); this FunctionDecl
/// contains all of the information known about the function. Other,
/// previous declarations of the function are available via the
-/// getPreviousDeclaration() chain.
+/// getPreviousDeclaration() chain.
class FunctionDecl : public DeclaratorDecl, public DeclContext,
public Redeclarable<FunctionDecl> {
public:
enum StorageClass {
None, Extern, Static, PrivateExtern
};
-
-private:
+
+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
/// no formals.
ParmVarDecl **ParamInfo;
-
+
LazyDeclStmtPtr Body;
// FIXME: This can be packed into the bitfields in Decl.
@@ -778,7 +778,7 @@ private:
bool IsTrivial : 1; // sunk from CXXMethodDecl
bool IsCopyAssignment : 1; // sunk from CXXMethodDecl
bool HasImplicitReturnZero : 1;
-
+
/// \brief End part of this FunctionDecl's source range.
///
/// We could compute the full range in getSourceRange(). However, when we're
@@ -790,15 +790,15 @@ private:
/// \brief The template or declaration that this declaration
/// describes or was instantiated from, respectively.
- ///
+ ///
/// For non-templates, this value will be NULL. For function
/// declarations that describe a function template, this will be a
/// pointer to a FunctionTemplateDecl. For member functions
/// of class template specializations, this will be the
/// FunctionDecl from which the member function was instantiated.
- /// For function template specializations, this will be a
+ /// For function template specializations, this will be a
/// FunctionTemplateSpecializationInfo, which contains information about
- /// the template being specialized and the template arguments involved in
+ /// the template being specialized and the template arguments involved in
/// that specialization.
llvm::PointerUnion3<FunctionTemplateDecl*, FunctionDecl*,
FunctionTemplateSpecializationInfo*>
@@ -808,11 +808,11 @@ protected:
FunctionDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName N, QualType T, DeclaratorInfo *DInfo,
StorageClass S, bool isInline)
- : DeclaratorDecl(DK, DC, L, N, T, DInfo),
+ : DeclaratorDecl(DK, DC, L, N, T, DInfo),
DeclContext(DK),
ParamInfo(0), Body(),
- SClass(S), IsInline(isInline), C99InlineDefinition(false),
- IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
+ SClass(S), IsInline(isInline), C99InlineDefinition(false),
+ IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
IsCopyAssignment(false),
HasImplicitReturnZero(false),
@@ -828,7 +828,7 @@ public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
return redeclarable_base::redecls_begin();
- }
+ }
redecl_iterator redecls_end() const {
return redeclarable_base::redecls_end();
}
@@ -888,7 +888,7 @@ public:
/// the class has been fully built by Sema.
bool isTrivial() const { return IsTrivial; }
void setTrivial(bool IT) { IsTrivial = IT; }
-
+
bool isCopyAssignment() const { return IsCopyAssignment; }
void setCopyAssignment(bool CA) { IsCopyAssignment = CA; }
@@ -902,10 +902,10 @@ public:
/// was explicitly written or because it was "inherited" by merging
/// a declaration without a prototype with a declaration that has a
/// prototype.
- bool hasPrototype() const {
- return HasWrittenPrototype || HasInheritedPrototype;
+ bool hasPrototype() const {
+ return HasWrittenPrototype || HasInheritedPrototype;
}
-
+
bool hasWrittenPrototype() const { return HasWrittenPrototype; }
void setHasWrittenPrototype(bool P) { HasWrittenPrototype = P; }
@@ -953,23 +953,23 @@ public:
unsigned getBuiltinID(ASTContext &Context) const;
unsigned getNumParmVarDeclsFromType() const;
-
+
// Iterator access to formal parameters.
unsigned param_size() const { return getNumParams(); }
typedef ParmVarDecl **param_iterator;
typedef ParmVarDecl * const *param_const_iterator;
-
+
param_iterator param_begin() { return ParamInfo; }
param_iterator param_end() { return ParamInfo+param_size(); }
-
+
param_const_iterator param_begin() const { return ParamInfo; }
param_const_iterator param_end() const { return ParamInfo+param_size(); }
-
+
/// getNumParams - Return the number of parameters this function must have
/// based on its functiontype. This is the length of the PararmInfo array
/// after it has been created.
unsigned getNumParams() const;
-
+
const ParmVarDecl *getParamDecl(unsigned i) const {
assert(i < getNumParams() && "Illegal param #");
return ParamInfo[i];
@@ -986,7 +986,7 @@ public:
/// arguments (in C++).
unsigned getMinRequiredArguments() const;
- QualType getResultType() const {
+ QualType getResultType() const {
return getType()->getAsFunctionType()->getResultType();
}
StorageClass getStorageClass() const { return StorageClass(SClass); }
@@ -1015,7 +1015,7 @@ public:
/// isOverloadedOperator - Whether this function declaration
/// represents an C++ overloaded operator, e.g., "operator+".
- bool isOverloadedOperator() const {
+ bool isOverloadedOperator() const {
return getOverloadedOperator() != OO_None;
};
@@ -1048,7 +1048,7 @@ public:
/// \brief Specify that this record is an instantiation of the
/// member function RD.
- void setInstantiationOfMemberFunction(FunctionDecl *RD) {
+ void setInstantiationOfMemberFunction(FunctionDecl *RD) {
TemplateOrSpecialization = RD;
}
@@ -1078,14 +1078,14 @@ public:
/// If this function declaration is not a function template specialization,
/// returns NULL.
FunctionTemplateDecl *getPrimaryTemplate() const;
-
+
/// \brief Retrieve the template arguments used to produce this function
/// template specialization from the primary template.
///
/// If this function declaration is not a function template specialization,
/// returns NULL.
- const TemplateArgumentList *getTemplateSpecializationArgs() const;
-
+ const TemplateArgumentList *getTemplateSpecializationArgs() const;
+
/// \brief Specify that this function declaration is actually a function
/// template specialization.
///
@@ -1108,7 +1108,7 @@ public:
/// \brief Determine what kind of template instantiation this function
/// represents.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK);
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= FunctionFirst && D->getKind() <= FunctionLast;
@@ -1123,21 +1123,21 @@ public:
};
-/// FieldDecl - An instance of this class is created by Sema::ActOnField to
+/// FieldDecl - An instance of this class is created by Sema::ActOnField to
/// represent a member of a struct/union/class.
class FieldDecl : public DeclaratorDecl {
// FIXME: This can be packed into the bitfields in Decl.
bool Mutable : 1;
Expr *BitWidth;
protected:
- FieldDecl(Kind DK, DeclContext *DC, SourceLocation L,
+ FieldDecl(Kind DK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T, DeclaratorInfo *DInfo,
Expr *BW, bool Mutable)
- : DeclaratorDecl(DK, DC, L, Id, T, DInfo), Mutable(Mutable), BitWidth(BW)
- { }
+ : DeclaratorDecl(DK, DC, L, Id, T, DInfo), Mutable(Mutable), BitWidth(BW) {
+ }
public:
- static FieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
+ static FieldDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T,
DeclaratorInfo *DInfo, Expr *BW, bool Mutable);
@@ -1189,7 +1189,7 @@ public:
SourceLocation L, IdentifierInfo *Id,
QualType T, Expr *E,
const llvm::APSInt &V);
-
+
virtual void Destroy(ASTContext& C);
const Expr *getInitExpr() const { return (const Expr*) Init; }
@@ -1198,11 +1198,11 @@ public:
void setInitExpr(Expr *E) { Init = (Stmt*) E; }
void setInitVal(const llvm::APSInt &V) { Val = V; }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == EnumConstant; }
static bool classof(const EnumConstantDecl *D) { return true; }
-
+
friend class StmtIteratorBase;
};
@@ -1244,16 +1244,16 @@ class TypedefDecl : public TypeDecl {
/// UnderlyingType - This is the type the typedef is set to.
QualType UnderlyingType;
TypedefDecl(DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, QualType T)
+ IdentifierInfo *Id, QualType T)
: TypeDecl(Typedef, DC, L, Id), UnderlyingType(T) {}
virtual ~TypedefDecl() {}
public:
-
+
static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,IdentifierInfo *Id,
QualType T);
-
+
QualType getUnderlyingType() const { return UnderlyingType; }
void setUnderlyingType(QualType newType) { UnderlyingType = newType; }
@@ -1263,9 +1263,9 @@ public:
};
class TypedefDecl;
-
+
/// TagDecl - Represents the declaration of a struct/union/class/enum.
-class TagDecl
+class TagDecl
: public TypeDecl, public DeclContext, public Redeclarable<TagDecl> {
public:
// This is really ugly.
@@ -1283,7 +1283,7 @@ private:
/// IsDefinition - True if this is a definition ("struct foo {};"), false if
/// it is a declaration ("struct foo;").
bool IsDefinition : 1;
-
+
/// TypedefForAnonDecl - If a TagDecl is anonymous and part of a typedef,
/// this points to the TypedefDecl. Used for mangling.
TypedefDecl *TypedefForAnonDecl;
@@ -1302,19 +1302,19 @@ protected:
IsDefinition = false;
setPreviousDeclaration(PrevDecl);
}
-
+
typedef Redeclarable<TagDecl> redeclarable_base;
virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
-
+
public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
return redeclarable_base::redecls_begin();
- }
+ }
redecl_iterator redecls_end() const {
return redeclarable_base::redecls_end();
}
-
+
SourceLocation getRBraceLoc() const { return RBraceLoc; }
void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
@@ -1322,7 +1322,7 @@ public:
void setTagKeywordLoc(SourceLocation TKL) { TagKeywordLoc = TKL; }
virtual SourceRange getSourceRange() const;
-
+
virtual TagDecl* getCanonicalDecl();
/// isDefinition - Return true if this decl has its body specified.
@@ -1336,7 +1336,7 @@ public:
bool isDependentType() const { return isDependentContext(); }
/// @brief Starts the definition of this tag declaration.
- ///
+ ///
/// This method should be invoked at the beginning of the definition
/// of this tag declaration. It will set the tag type into a state
/// where it is in the process of being defined.
@@ -1345,7 +1345,7 @@ public:
/// @brief Completes the definition of this tag declaration.
void completeDefinition();
- /// getDefinition - Returns the TagDecl that actually defines this
+ /// getDefinition - Returns the TagDecl that actually defines this
/// struct/union/class/enum. When determining whether or not a
/// struct/union/class/enum is completely defined, one should use this method
/// as opposed to 'isDefinition'. 'isDefinition' indicates whether or not a
@@ -1353,7 +1353,7 @@ public:
/// struct/union/class/enum type is defined. This method returns NULL if
/// there is no TagDecl that defines the struct/union/class/enum.
TagDecl* getDefinition(ASTContext& C) const;
-
+
const char *getKindName() const {
return ElaboratedType::getNameForTagKind(getTagKind());
}
@@ -1373,10 +1373,10 @@ public:
bool isClass() const { return getTagKind() == TK_class; }
bool isUnion() const { return getTagKind() == TK_union; }
bool isEnum() const { return getTagKind() == TK_enum; }
-
+
TypedefDecl *getTypedefForAnonDecl() const { return TypedefForAnonDecl; }
void setTypedefForAnonDecl(TypedefDecl *TDD) { TypedefForAnonDecl = TDD; }
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= TagFirst && D->getKind() <= TagLast;
@@ -1419,7 +1419,7 @@ public:
static EnumDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
SourceLocation TKL, EnumDecl *PrevDecl);
-
+
virtual void Destroy(ASTContext& C);
/// completeDefinition - When created, the EnumDecl corresponds to a
@@ -1428,16 +1428,16 @@ public:
/// added (via DeclContext::addDecl). NewType is the new underlying
/// type of the enumeration type.
void completeDefinition(ASTContext &C, QualType NewType);
-
+
// enumerator_iterator - Iterates through the enumerators of this
// enumeration.
typedef specific_decl_iterator<EnumConstantDecl> enumerator_iterator;
- enumerator_iterator enumerator_begin() const {
+ enumerator_iterator enumerator_begin() const {
return enumerator_iterator(this->decls_begin());
}
- enumerator_iterator enumerator_end() const {
+ enumerator_iterator enumerator_end() const {
return enumerator_iterator(this->decls_end());
}
@@ -1477,14 +1477,14 @@ class RecordDecl : public TagDecl {
/// AnonymousStructOrUnion - Whether this is the type of an
/// anonymous struct or union.
bool AnonymousStructOrUnion : 1;
-
+
/// HasObjectMember - This is true if this struct has at least one
- /// member containing an object
+ /// member containing an object
bool HasObjectMember : 1;
protected:
RecordDecl(Kind DK, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id,
+ SourceLocation L, IdentifierInfo *Id,
RecordDecl *PrevDecl, SourceLocation TKL);
virtual ~RecordDecl();
@@ -1495,7 +1495,7 @@ public:
RecordDecl* PrevDecl = 0);
virtual void Destroy(ASTContext& C);
-
+
bool hasFlexibleArrayMember() const { return HasFlexibleArrayMember; }
void setHasFlexibleArrayMember(bool V) { HasFlexibleArrayMember = V; }
@@ -1505,7 +1505,7 @@ public:
/// type declared, e.g.,
/// @code
/// union { int i; float f; };
- /// @endcode
+ /// @endcode
/// is an anonymous union but neither of the following are:
/// @code
/// union X { int i; float f; };
@@ -1518,7 +1518,7 @@ public:
bool hasObjectMember() const { return HasObjectMember; }
void setHasObjectMember (bool val) { HasObjectMember = val; }
-
+
/// \brief Determines whether this declaration represents the
/// injected class name.
///
@@ -1534,7 +1534,7 @@ public:
/// \endcode
bool isInjectedClassName() const;
- /// getDefinition - Returns the RecordDecl that actually defines this
+ /// getDefinition - Returns the RecordDecl that actually defines this
/// struct/union/class. When determining whether or not a struct/union/class
/// is completely defined, one should use this method as opposed to
/// 'isDefinition'. 'isDefinition' indicates whether or not a specific
@@ -1544,7 +1544,7 @@ public:
RecordDecl* getDefinition(ASTContext& C) const {
return cast_or_null<RecordDecl>(TagDecl::getDefinition(C));
}
-
+
// Iterator access to field members. The field iterator only visits
// the non-static data members of this class, ignoring any static
// data members, functions, constructors, destructors, etc.
@@ -1559,7 +1559,7 @@ public:
// field_empty - Whether there are any fields (non-static data
// members) in this record.
- bool field_empty() const {
+ bool field_empty() const {
return field_begin() == field_end();
}
@@ -1588,7 +1588,7 @@ public:
static bool classof(const Decl *D) {
return D->getKind() == FileScopeAsm;
}
- static bool classof(const FileScopeAsmDecl *D) { return true; }
+ static bool classof(const FileScopeAsmDecl *D) { return true; }
};
/// BlockDecl - This represents a block literal declaration, which is like an
@@ -1603,12 +1603,12 @@ class BlockDecl : public Decl, public DeclContext {
/// no formals.
ParmVarDecl **ParamInfo;
unsigned NumParams;
-
+
Stmt *Body;
-
+
protected:
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
- : Decl(Block, DC, CaretLoc), DeclContext(Block),
+ : Decl(Block, DC, CaretLoc), DeclContext(Block),
isVariadic(false), ParamInfo(0), NumParams(0), Body(0) {}
virtual ~BlockDecl();
@@ -1621,7 +1621,7 @@ public:
bool IsVariadic() const { return isVariadic; }
void setIsVariadic(bool value) { isVariadic = value; }
-
+
CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; }
Stmt *getBody() const { return (Stmt*) Body; }
void setBody(CompoundStmt *B) { Body = (Stmt*) B; }
@@ -1630,14 +1630,14 @@ public:
unsigned param_size() const { return getNumParams(); }
typedef ParmVarDecl **param_iterator;
typedef ParmVarDecl * const *param_const_iterator;
-
+
bool param_empty() const { return NumParams == 0; }
param_iterator param_begin() { return ParamInfo; }
param_iterator param_end() { return ParamInfo+param_size(); }
-
+
param_const_iterator param_begin() const { return ParamInfo; }
param_const_iterator param_end() const { return ParamInfo+param_size(); }
-
+
unsigned getNumParams() const;
const ParmVarDecl *getParamDecl(unsigned i) const {
assert(i < getNumParams() && "Illegal param #");
@@ -1648,10 +1648,10 @@ public:
return ParamInfo[i];
}
void setParams(ASTContext& C, ParmVarDecl **NewParamInfo, unsigned NumParams);
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == Block; }
- static bool classof(const BlockDecl *D) { return true; }
+ static bool classof(const BlockDecl *D) { return true; }
static DeclContext *castToDeclContext(const BlockDecl *D) {
return static_cast<DeclContext *>(const_cast<BlockDecl*>(D));
}
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 6e04e55312..342eecbf57 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -60,8 +60,8 @@ public:
namespace clang {
-/// Decl - This represents one declaration (or definition), e.g. a variable,
-/// typedef, function, struct, etc.
+/// Decl - This represents one declaration (or definition), e.g. a variable,
+/// typedef, function, struct, etc.
///
class Decl {
public:
@@ -69,7 +69,7 @@ public:
enum Kind {
#define DECL(Derived, Base) Derived,
#define DECL_RANGE(CommonBase, Start, End) \
- CommonBase##First = Start, CommonBase##Last = 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"
@@ -93,7 +93,7 @@ public:
IDNS_OrdinaryFriend = 0x80,
IDNS_TagFriend = 0x100
};
-
+
/// ObjCDeclQualifier - Qualifier used on types in method declarations
/// for remote messaging. They are meant for the arguments though and
/// applied to the Decls (ObjCMethodDecl and ParmVarDecl).
@@ -106,7 +106,7 @@ public:
OBJC_TQ_Byref = 0x10,
OBJC_TQ_Oneway = 0x20
};
-
+
private:
/// NextDeclInContext - The next declaration within the same lexical
/// DeclContext. These pointers form the linked list that is
@@ -119,8 +119,8 @@ private:
DeclContext *SemanticDC;
DeclContext *LexicalDC;
};
-
-
+
+
/// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
/// For declarations that don't contain C++ scope specifiers, it contains
/// the DeclContext where the Decl was declared.
@@ -144,16 +144,16 @@ private:
inline DeclContext *getSemanticDC() const {
return DeclCtx.get<DeclContext*>();
}
-
+
/// Loc - The location that this decl.
SourceLocation Loc;
-
+
/// DeclKind - This indicates which class this is.
Kind DeclKind : 8;
-
+
/// InvalidDecl - This indicates a semantic error occurred.
unsigned int InvalidDecl : 1;
-
+
/// HasAttrs - This indicates whether the decl has attributes or not.
unsigned int HasAttrs : 1;
@@ -168,22 +168,22 @@ private:
protected:
/// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
unsigned IdentifierNamespace : 16;
-
+
private:
#ifndef NDEBUG
void CheckAccessDeclContext() const;
#else
void CheckAccessDeclContext() const { }
#endif
-
+
protected:
/// Access - Used by C++ decls for the access specifier.
// NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
unsigned Access : 2;
friend class CXXClassMemberWrapper;
- Decl(Kind DK, DeclContext *DC, SourceLocation L)
- : NextDeclInContext(0), DeclCtx(DC),
+ Decl(Kind DK, DeclContext *DC, SourceLocation L)
+ : NextDeclInContext(0), DeclCtx(DC),
Loc(L), DeclKind(DK), InvalidDecl(0),
HasAttrs(false), Implicit(false), Used(false),
IdentifierNamespace(getIdentifierNamespaceForKind(DK)), Access(AS_none) {
@@ -206,7 +206,7 @@ public:
Kind getKind() const { return DeclKind; }
const char *getDeclKindName() const;
-
+
Decl *getNextDeclInContext() { return NextDeclInContext; }
const Decl *getNextDeclInContext() const { return NextDeclInContext; }
@@ -225,15 +225,15 @@ public:
}
ASTContext &getASTContext() const;
-
+
void setAccess(AccessSpecifier AS) {
- Access = AS;
+ Access = AS;
CheckAccessDeclContext();
}
-
- AccessSpecifier getAccess() const {
+
+ AccessSpecifier getAccess() const {
CheckAccessDeclContext();
- return AccessSpecifier(Access);
+ return AccessSpecifier(Access);
}
bool hasAttrs() const { return HasAttrs; }
@@ -251,11 +251,11 @@ public:
return V;
return 0;
}
-
+
template<typename T> bool hasAttr() const {
return getAttr<T>() != 0;
}
-
+
/// setInvalidDecl - Indicates the Decl had a semantic error. This
/// allows for graceful error recovery.
void setInvalidDecl(bool Invalid = true) { InvalidDecl = Invalid; }
@@ -266,12 +266,12 @@ public:
/// was written explicitly in the source code.
bool isImplicit() const { return Implicit; }
void setImplicit(bool I = true) { Implicit = I; }
-
+
/// \brief Whether this declaration was used, meaning that a definition
/// is required.
bool isUsed() const { return Used; }
void setUsed(bool U = true) { Used = U; }
-
+
unsigned getIdentifierNamespace() const {
return IdentifierNamespace;
}
@@ -280,7 +280,7 @@ public:
}
static unsigned getIdentifierNamespaceForKind(Kind DK);
-
+
/// getLexicalDeclContext - The declaration context where this Decl was
/// lexically declared (LexicalDC). May be different from
/// getDeclContext() (SemanticDC).
@@ -303,7 +303,7 @@ public:
bool isOutOfLine() const {
return getLexicalDeclContext() != getDeclContext();
}
-
+
/// setDeclContext - Set both the semantic and lexical DeclContext
/// to DC.
void setDeclContext(DeclContext *DC);
@@ -324,7 +324,7 @@ public:
/// \brief Whether this particular Decl is a canonical one.
bool isCanonicalDecl() const { return getCanonicalDecl() == this; }
-
+
protected:
/// \brief Returns the next redeclaration or itself if this is the only decl.
///
@@ -367,10 +367,10 @@ public:
return tmp;
}
- friend bool operator==(redecl_iterator x, redecl_iterator y) {
+ friend bool operator==(redecl_iterator x, redecl_iterator y) {
return x.Current == y.Current;
}
- friend bool operator!=(redecl_iterator x, redecl_iterator y) {
+ friend bool operator!=(redecl_iterator x, redecl_iterator y) {
return x.Current != y.Current;
}
};
@@ -398,11 +398,11 @@ public:
static void addDeclKind(Kind k);
static bool CollectingStats(bool Enable = false);
static void PrintStats();
-
+
/// isTemplateParameter - Determines whether this declaration is a
/// template parameter.
bool isTemplateParameter() const;
-
+
/// isTemplateParameter - Determines whether this declaration is a
/// template parameter pack.
bool isTemplateParameterPack() const;
@@ -445,12 +445,12 @@ public:
if (!mask) return FOK_None;
return (mask & (IDNS_Tag | IDNS_Ordinary) ? FOK_Declared : FOK_Undeclared);
}
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *) { return true; }
static DeclContext *castToDeclContext(const Decl *);
static Decl *castFromDeclContext(const DeclContext *);
-
+
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
@@ -478,10 +478,10 @@ public:
PrettyStackTraceDecl(Decl *theDecl, SourceLocation L,
SourceManager &sm, const char *Msg)
: TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
-
+
virtual void print(llvm::raw_ostream &OS) const;
-};
-
+};
+
/// DeclContext - This is used only as base class of specific decl types that
/// can act as declaration contexts. These decls are (only the top classes
@@ -526,9 +526,9 @@ class DeclContext {
mutable Decl *LastDecl;
protected:
- DeclContext(Decl::Kind K)
+ DeclContext(Decl::Kind K)
: DeclKind(K), ExternalLexicalStorage(false),
- ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0),
+ ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0),
LastDecl(0) { }
void DestroyDecls(ASTContext &C);
@@ -548,7 +548,7 @@ public:
const DeclContext *getParent() const {
return const_cast<DeclContext*>(this)->getParent();
}
-
+
/// getLexicalParent - Returns the containing lexical DeclContext. May be
/// different from getParent, e.g.:
///
@@ -563,7 +563,7 @@ public:
}
const DeclContext *getLexicalParent() const {
return const_cast<DeclContext*>(this)->getLexicalParent();
- }
+ }
ASTContext &getParentASTContext() const {
return cast<Decl>(this)->getASTContext();
@@ -604,10 +604,10 @@ public:
/// context are semantically declared in the nearest enclosing
/// non-transparent (opaque) context but are lexically declared in
/// this context. For example, consider the enumerators of an
- /// enumeration type:
+ /// enumeration type:
/// @code
/// enum E {
- /// Val1
+ /// Val1
/// };
/// @endcode
/// Here, E is a transparent context, so its enumerator (Val1) will
@@ -622,7 +622,7 @@ public:
bool Equals(DeclContext *DC) {
return this->getPrimaryContext() == DC->getPrimaryContext();
}
-
+
/// \brief Determine whether this declaration context encloses the
/// declaration context DC.
bool Encloses(DeclContext *DC);
@@ -643,7 +643,7 @@ public:
const DeclContext *getLookupContext() const {
return const_cast<DeclContext *>(this)->getLookupContext();
}
-
+
/// \brief Retrieve the nearest enclosing namespace context.
DeclContext *getEnclosingNamespaceContext();
const DeclContext *getEnclosingNamespaceContext() const {
@@ -699,16 +699,16 @@ public:
return tmp;
}
- friend bool operator==(decl_iterator x, decl_iterator y) {
+ friend bool operator==(decl_iterator x, decl_iterator y) {
return x.Current == y.Current;
}
- friend bool operator!=(decl_iterator x, decl_iterator y) {
+ friend bool operator!=(decl_iterator x, decl_iterator y) {
return x.Current != y.Current;
}
};
/// decls_begin/decls_end - Iterate over the declarations stored in
- /// this context.
+ /// this context.
decl_iterator decls_begin() const;
decl_iterator decls_end() const;
bool decls_empty() const;
@@ -724,7 +724,7 @@ public:
/// will either be NULL or will point to a declaration of
/// type SpecificDecl.
DeclContext::decl_iterator Current;
-
+
/// SkipToNextDecl - Advances the current position up to the next
/// declaration of type SpecificDecl that also meets the criteria
/// required by Acceptable.
@@ -769,13 +769,13 @@ public:
++(*this);
return tmp;
}
-
+
friend bool
operator==(const specific_decl_iterator& x, const specific_decl_iterator& y) {
return x.Current == y.Current;
}
-
- friend bool
+
+ friend bool
operator!=(const specific_decl_iterator& x, const specific_decl_iterator& y) {
return x.Current != y.Current;
}
@@ -796,7 +796,7 @@ public:
/// will either be NULL or will point to a declaration of
/// type SpecificDecl.
DeclContext::decl_iterator Current;
-
+
/// SkipToNextDecl - Advances the current position up to the next
/// declaration of type SpecificDecl that also meets the criteria
/// required by Acceptable.
@@ -843,13 +843,13 @@ public:
++(*this);
return tmp;
}
-
+
friend bool
operator==(const filtered_decl_iterator& x, const filtered_decl_iterator& y) {
return x.Current == y.Current;
}
-
- friend bool
+
+ friend bool
operator!=(const filtered_decl_iterator& x, const filtered_decl_iterator& y) {
return x.Current != y.Current;
}
@@ -920,7 +920,7 @@ public:
/// udir_iterator - Iterates through the using-directives stored
/// within this context.
typedef UsingDirectiveDecl * const * udir_iterator;
-
+
typedef std::pair<udir_iterator, udir_iterator> udir_iterator_range;
udir_iterator_range getUsingDirectives() const;
@@ -944,8 +944,8 @@ public:
/// \brief State whether this DeclContext has external storage for
/// declarations lexically in this context.
- void setHasExternalLexicalStorage(bool ES = true) {
- ExternalLexicalStorage = ES;
+ void setHasExternalLexicalStorage(bool ES = true) {
+ ExternalLexicalStorage = ES;
}
/// \brief Whether this DeclContext has external storage containing
@@ -954,8 +954,8 @@ public:
/// \brief State whether this DeclContext has external storage for
/// declarations visible in this context.
- void setHasExternalVisibleStorage(bool ES = true) {
- ExternalVisibleStorage = ES;
+ void setHasExternalVisibleStorage(bool ES = true) {
+ ExternalVisibleStorage = ES;
}
static bool classof(const Decl *D);
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index ce6e925a9a..23da3e0283 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -28,33 +28,33 @@ class CXXConversionDecl;
class CXXMethodDecl;
class ClassTemplateSpecializationDecl;
-/// \brief Represents any kind of function declaration, whether it is a
+/// \brief Represents any kind of function declaration, whether it is a
/// concrete function or a function template.
class AnyFunctionDecl {
NamedDecl *Function;
-
+
AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
-
+
public:
AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
AnyFunctionDecl(FunctionTemplateDecl *FTD);
-
- /// \brief Implicily converts any function or function template into a
+
+ /// \brief Implicily converts any function or function template into a
/// named declaration.
operator NamedDecl *() const { return Function; }
-
+
/// \brief Retrieve the underlying function or function template.
NamedDecl *get() const { return Function; }
-
- static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) {
+
+ static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) {
return AnyFunctionDecl(ND);
}
};
-
+
} // end namespace clang
namespace llvm {
- /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from
+ /// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from
/// AnyFunctionDecl to any function or function template declaration.
template<> struct simplify_type<const ::clang::AnyFunctionDecl> {
typedef ::clang::NamedDecl* SimpleType;
@@ -64,26 +64,26 @@ namespace llvm {
};
template<> struct simplify_type< ::clang::AnyFunctionDecl>
: public simplify_type<const ::clang::AnyFunctionDecl> {};
-
+
// Provide PointerLikeTypeTraits for non-cvr pointers.
template<>
class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
public:
static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
- return F.get();
+ return F.get();
}
static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
return ::clang::AnyFunctionDecl::getFromNamedDecl(
static_cast< ::clang::NamedDecl*>(P));
}
-
+
enum { NumLowBitsAvailable = 2 };
};
-
+
} // end namespace llvm
namespace clang {
-
+
/// OverloadedFunctionDecl - An instance of this class represents a
/// set of overloaded functions. All of the functions have the same
/// name and occur within the same scope.
@@ -128,56 +128,56 @@ public:
unsigned size() const { return Functions.size(); }
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
- return D->getKind() == OverloadedFunction;
+ static bool classof(const Decl *D) {
+ return D->getKind() == OverloadedFunction;
}
static bool classof(const OverloadedFunctionDecl *D) { return true; }
};
-
-/// \brief Provides uniform iteration syntax for an overload set, function,
+
+/// \brief Provides uniform iteration syntax for an overload set, function,
/// or function template.
class OverloadIterator {
/// \brief An overloaded function set, function declaration, or
/// function template declaration.
NamedDecl *D;
-
+
/// \brief If the declaration is an overloaded function set, this is the
/// iterator pointing to the current position within that overloaded
/// function set.
OverloadedFunctionDecl::function_iterator Iter;
-
+
public:
typedef AnyFunctionDecl value_type;
typedef value_type reference;
typedef NamedDecl *pointer;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
-
+
OverloadIterator() : D(0) { }
-
+
OverloadIterator(FunctionDecl *FD) : D(FD) { }
- OverloadIterator(FunctionTemplateDecl *FTD)
+ OverloadIterator(FunctionTemplateDecl *FTD)
: D(reinterpret_cast<NamedDecl*>(FTD)) { }
- OverloadIterator(OverloadedFunctionDecl *Ovl)
+ OverloadIterator(OverloadedFunctionDecl *Ovl)
: D(Ovl), Iter(Ovl->function_begin()) { }
-
+
OverloadIterator(NamedDecl *ND);
-
+
reference operator*() const;
-
+
pointer operator->() const { return (**this).get(); }
-
+
OverloadIterator &operator++();
-
+
OverloadIterator operator++(int) {
OverloadIterator Temp(*this);
++(*this);
return Temp;
}
-
+
bool Equals(const OverloadIterator &Other) const;
};
-
+
inline bool operator==(const OverloadIterator &X, const OverloadIterator &Y) {
return X.Equals(Y);
}
@@ -215,7 +215,7 @@ class CXXBaseSpecifier {
/// struct (false). This determines the mapping from the access
/// specifier as written in the source code to the access specifier
/// used for semantic analysis.
- bool BaseOfClass : 1;
+ bool BaseOfClass : 1;
/// Access - Access specifier as written in the source code (which
/// may be AS_none). The actual type of data stored here is an
@@ -226,7 +226,7 @@ class CXXBaseSpecifier {
/// BaseType - The type of the base class. This will be a class or
/// struct (or a typedef of such).
QualType BaseType;
-
+
public:
CXXBaseSpecifier() { }
@@ -236,7 +236,7 @@ public:
/// getSourceRange - Retrieves the source range that contains the
/// entire base specifier.
SourceRange getSourceRange() const { return Range; }
-
+
/// isVirtual - Determines whether the base class is a virtual base
/// class (or not).
bool isVirtual() const { return Virtual; }
@@ -246,11 +246,11 @@ public:
/// semantic analysis, so the result can never be AS_none. To
/// retrieve the access specifier as written in the source code, use
/// getAccessSpecifierAsWritten().
- AccessSpecifier getAccessSpecifier() const {
+ AccessSpecifier getAccessSpecifier() const {
if ((AccessSpecifier)Access == AS_none)
return BaseOfClass? AS_private : AS_public;
else
- return (AccessSpecifier)Access;
+ return (AccessSpecifier)Access;
}
/// getAccessSpecifierAsWritten - Retrieves the access specifier as
@@ -271,7 +271,7 @@ public:
/// to deal with C++-specific things.
class CXXRecordDecl : public RecordDecl {
/// UserDeclaredConstructor - True when this class has a
- /// user-declared constructor.
+ /// user-declared constructor.
bool UserDeclaredConstructor : 1;
/// UserDeclaredCopyConstructor - True when this class has a
@@ -315,7 +315,7 @@ class CXXRecordDecl : public RecordDecl {
/// * for all the nonstatic data members of its class that are of class type
/// (or array thereof), each such class has a trivial constructor.
bool HasTrivialConstructor : 1;
-
+
/// HasTrivialCopyConstructor - True when this class has a trivial copy
/// constructor.
///
@@ -340,7 +340,7 @@ class CXXRecordDecl : public RecordDecl {
/// operator;
/// otherwise the copy assignment operator is non-trivial.
bool HasTrivialCopyAssignment : 1;
-
+
/// HasTrivialDestructor - True when this class has a trivial destructor.
///
/// C++ [class.dtor]p3. A destructor is trivial if it is an
@@ -360,10 +360,10 @@ class CXXRecordDecl : public RecordDecl {
/// VBases - direct and indirect virtual base classes of this class.
CXXBaseSpecifier *VBases;
-
+
/// NumVBases - The number of virtual base class specifiers in VBases.
unsigned NumVBases;
-
+
/// Conversions - Overload set containing the conversion functions
/// of this C++ class (but not its inherited conversion
/// functions). Each of the entries in this overload set is a
@@ -372,7 +372,7 @@ class CXXRecordDecl : public RecordDecl {
/// \brief The template or declaration that this declaration
/// describes or was instantiated from, respectively.
- ///
+ ///
/// For non-templates, this value will be NULL. For record
/// declarations that describe a class template, this will be a
/// pointer to a ClassTemplateDecl. For member
@@ -417,9 +417,9 @@ public:
SourceLocation TKL = SourceLocation(),
CXXRecordDecl* PrevDecl=0,
bool DelayTypeCreation = false);
-
+
virtual void Destroy(ASTContext& C);
-
+
bool isDynamicClass() const {
return Polymorphic || NumVBases!=0;
}
@@ -448,11 +448,11 @@ public:
reverse_base_class_const_iterator bases_rend() const {
return reverse_base_class_const_iterator(bases_begin());
}
-
+
/// getNumVBases - Retrieves the number of virtual base classes of this
/// class.
unsigned getNumVBases() const { return NumVBases; }
-
+
base_class_iterator vbases_begin() { return VBases; }
base_class_const_iterator vbases_begin() const { return VBases; }
base_class_iterator vbases_end() { return VBases + NumVBases; }
@@ -474,7 +474,7 @@ public:
/// all method members of the class, including non-instance methods,
/// special methods, etc.
typedef specific_decl_iterator<CXXMethodDecl> method_iterator;
-
+
/// method_begin - Method begin iterator. Iterates in the order the methods
/// were declared.
method_iterator method_begin() const {
@@ -487,7 +487,7 @@ public:
/// Iterator access to constructor members.
typedef specific_decl_iterator<CXXConstructorDecl> ctor_iterator;
-
+
ctor_iterator ctor_begin() const {
return ctor_iterator(decls_begin());
}
@@ -500,13 +500,13 @@ public:
bool hasConstCopyConstructor(ASTContext &Context) const;
/// getCopyConstructor - Returns the copy constructor for this class
- CXXConstructorDecl *getCopyConstructor(ASTContext &Context,
+ 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,
+ bool hasConstCopyAssignment(ASTContext &Context,
const CXXMethodDecl *&MD) const;
/// addedConstructor - Notify the class that another constructor has
@@ -517,9 +517,9 @@ public:
/// hasUserDeclaredConstructor - Whether this class has any
/// user-declared constructors. When true, a default constructor
/// will not be implicitly declared.
- bool hasUserDeclaredConstructor() const {
+ bool hasUserDeclaredConstructor() const {
assert((isDefinition() ||
- cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
+ cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
"Incomplete record decl!");
return UserDeclaredConstructor;
}
@@ -551,23 +551,23 @@ public:
/// setUserDeclaredDestructor - Set whether this class has a
/// user-declared destructor. If not set by the time the class is
/// fully defined, a destructor will be implicitly declared.
- void setUserDeclaredDestructor(bool UCD) {
- UserDeclaredDestructor = UCD;
+ void setUserDeclaredDestructor(bool UCD) {
+ UserDeclaredDestructor = UCD;
}
/// getConversions - Retrieve the overload set containing all of the
/// conversion functions in this class.
- OverloadedFunctionDecl *getConversionFunctions() {
- assert((this->isDefinition() ||
+ OverloadedFunctionDecl *getConversionFunctions() {
+ assert((this->isDefinition() ||
cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
"getConversionFunctions() called on incomplete type");
- return &Conversions;
+ return &Conversions;
}
- const OverloadedFunctionDecl *getConversionFunctions() const {
- assert((this->isDefinition() ||
+ const OverloadedFunctionDecl *getConversionFunctions() const {
+ assert((this->isDefinition() ||
cast<RecordType>(getTypeForDecl())->isBeingDefined()) &&
"getConversionFunctions() called on incomplete type");
- return &Conversions;
+ return &Conversions;
}
/// addConversionFunction - Add a new conversion function to the
@@ -576,7 +576,7 @@ public:
/// \brief Add a new conversion function template to the list of conversion
/// functions.
- void addConversionFunction(ASTContext &Context,
+ void addConversionFunction(ASTContext &Context,
FunctionTemplateDecl *ConvDecl);
/// isAggregate - Whether this class is an aggregate (C++
@@ -618,22 +618,22 @@ public:
/// isAbstract - Whether this class is abstract (C++ [class.abstract]),
/// which means that the class contains or inherits a pure virtual function.
bool isAbstract() const { return Abstract; }
-
+
/// setAbstract - Set whether this class is abstract (C++ [class.abstract])
void setAbstract(bool Abs) { Abstract = Abs; }
-
+
// hasTrivialConstructor - Whether this class has a trivial constructor
// (C++ [class.ctor]p5)
bool hasTrivialConstructor() const { return HasTrivialConstructor; }
-
+
// setHasTrivialConstructor - Set whether this class has a trivial constructor
// (C++ [class.ctor]p5)
void setHasTrivialConstructor(bool TC) { HasTrivialConstructor = TC; }
-
+
// hasTrivialCopyConstructor - Whether this class has a trivial copy
// constructor (C++ [class.copy]p6)
bool hasTrivialCopyConstructor() const { return HasTrivialCopyConstructor; }
-
+
// setHasTrivialCopyConstructor - Set whether this class has a trivial
// copy constructor (C++ [class.copy]p6)
void setHasTrivialCopyConstructor(bool TC) { HasTrivialCopyConstructor = TC; }
@@ -641,7 +641,7 @@ public:
// hasTrivialCopyAssignment - Whether this class has a trivial copy
// assignment operator (C++ [class.copy]p11)
bool hasTrivialCopyAssignment() const { return HasTrivialCopyAssignment; }
-
+
// setHasTrivialCopyAssignment - Set whether this class has a
// trivial copy assignment operator (C++ [class.copy]p11)
void setHasTrivialCopyAssignment(bool TC) { HasTrivialCopyAssignment = TC; }
@@ -649,11 +649,11 @@ public:
// hasTrivialDestructor - Whether this class has a trivial destructor
// (C++ [class.dtor]p3)
bool hasTrivialDestructor() const { return HasTrivialDestructor; }
-
+
// setHasTrivialDestructor - Set whether this class has a trivial destructor
// (C++ [class.dtor]p3)
void setHasTrivialDestructor(bool TC) { HasTrivialDestructor = TC; }
-
+
/// \brief If this record is an instantiation of a member class,
/// retrieves the member class from which it was instantiated.
///
@@ -679,7 +679,7 @@ public:
/// \brief Specify that this record is an instantiation of the
/// member class RD.
- void setInstantiationOfMemberClass(CXXRecordDecl *RD) {
+ void setInstantiationOfMemberClass(CXXRecordDecl *RD) {
TemplateOrInstantiation = RD;
}
@@ -704,16 +704,16 @@ public:
/// getDefaultConstructor - Returns the default constructor for this class
CXXConstructorDecl *getDefaultConstructor(ASTContext &Context);
-
+
/// getDestructor - Returns the destructor decl for this class.
const CXXDestructorDecl *getDestructor(ASTContext &Context);
-
+
/// isLocalClass - If the class is a local class [class.local], returns
/// the enclosing function declaration.
const FunctionDecl *isLocalClass() const {
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(getDeclContext()))
return RD->isLocalClass();
-
+
return dyn_cast<FunctionDecl>(getDeclContext());
}
@@ -722,14 +722,14 @@ public:
/// GraphViz.
void viewInheritance(ASTContext& Context) const;
- static bool classof(const Decl *D) {
- return D->getKind() == CXXRecord ||
+ static bool classof(const Decl *D) {
+ return D->getKind() == CXXRecord ||
D->getKind() == ClassTemplateSpecialization ||
- D->getKind() == ClassTemplatePartialSpecialization;
+ D->getKind() == ClassTemplatePartialSpecialization;
}
static bool classof(const CXXRecordDecl *D) { return true; }
- static bool classof(const ClassTemplateSpecializationDecl *D) {
- return true;
+ static bool classof(const ClassTemplateSpecializationDecl *D) {
+ return true;
}
};
@@ -749,32 +749,32 @@ public:
QualType T, DeclaratorInfo *DInfo,
bool isStatic = false,
bool isInline = false);
-
+
bool isStatic() const { return getStorageClass() == Static; }
bool isInstance() const { return !isStatic(); }
- bool isVirtual() const {
+ bool isVirtual() const {
return isVirtualAsWritten() ||
(begin_overridden_methods() != end_overridden_methods());
}
- ///
+ ///
void addOverriddenMethod(const CXXMethodDecl *MD);
-
+
typedef const CXXMethodDecl ** method_iterator;
-
+
method_iterator begin_overridden_methods() const;
method_iterator end_overridden_methods() const;
-
+
/// getParent - Returns the parent of this method declaration, which
/// is the class in which this method is defined.
- const CXXRecordDecl *getParent() const {
- return cast<CXXRecordDecl>(FunctionDecl::getParent());
+ const CXXRecordDecl *getParent() const {
+ return cast<CXXRecordDecl>(FunctionDecl::getParent());
}
-
+
/// getParent - Returns the parent of this method declaration, which
/// is the class in which this method is defined.
- CXXRecordDecl *getParent() {
+ CXXRecordDecl *getParent() {
return const_cast<CXXRecordDecl *>(
cast<CXXRecordDecl>(FunctionDecl::getParent()));
}
@@ -788,7 +788,7 @@ public:
}
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() >= CXXMethod && D->getKind() <= CXXConversion;
}
static bool classof(const CXXMethodDecl *D) { return true; }
@@ -818,13 +818,13 @@ class CXXBaseOrMemberInitializer {
/// Args - The arguments used to initialize the base or member.
Stmt **Args;
unsigned NumArgs;
-
+
/// \brief Stores either the constructor to call to initialize this base or
/// member (a CXXConstructorDecl pointer), or stores the anonymous union of
/// which the initialized value is a member.
///
- /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's
- /// anonymous union data member, this field holds the FieldDecl for the
+ /// When the value is a FieldDecl pointer, 'BaseOrMember' is class's
+ /// anonymous union data member, this field holds the FieldDecl for the
/// member of the anonymous union being initialized.
/// @code
/// struct X {
@@ -838,7 +838,7 @@ class CXXBaseOrMemberInitializer {
/// In above example, BaseOrMember holds the field decl. for anonymous union
/// and AnonUnionMember holds field decl for au_i1.
llvm::PointerUnion<CXXConstructorDecl *, FieldDecl *> CtorOrAnonUnion;
-
+
/// IdLoc - Location of the id in ctor-initializer list.
SourceLocation IdLoc;
@@ -847,13 +847,13 @@ class CXXBaseOrMemberInitializer {
public:
/// CXXBaseOrMemberInitializer - Creates a new base-class initializer.
- explicit
+ explicit
CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs,
CXXConstructorDecl *C,
SourceLocation L, SourceLocation R);
/// CXXBaseOrMemberInitializer - Creates a new member initializer.
- explicit
+ explicit
CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs,
CXXConstructorDecl *C,
SourceLocation L, SourceLocation R);
@@ -872,7 +872,7 @@ public:
/// getBaseOrMember - get the generic 'member' representing either the field
/// or a base class.
void* getBaseOrMember() const { return reinterpret_cast<void*>(BaseOrMember); }
-
+
/// isBaseInitializer - Returns true when this initializer is
/// initializing a base class.
bool isBaseInitializer() const { return (BaseOrMember & 0x1) != 0; }
@@ -885,8 +885,8 @@ public:
/// type used to specify the initializer. The resulting type will be
/// a class type or a typedef of a class type. If this is not a base
/// class initializer, returns NULL.
- Type *getBaseClass() {
- if (isBaseInitializer())
+ Type *getBaseClass() {
+ if (isBaseInitializer())
return reinterpret_cast<Type*>(BaseOrMember & ~0x01);
else
return 0;
@@ -896,8 +896,8 @@ public:
/// type used to specify the initializer. The resulting type will be
/// a class type or a typedef of a class type. If this is not a base
/// class initializer, returns NULL.
- const Type *getBaseClass() const {
- if (isBaseInitializer())
+ const Type *getBaseClass() const {
+ if (isBaseInitializer())
return reinterpret_cast<const Type*>(BaseOrMember & ~0x01);
else
return 0;
@@ -906,9 +906,9 @@ public:
/// getMember - If this is a member initializer, returns the
/// declaration of the non-static data member being
/// initialized. Otherwise, returns NULL.
- FieldDecl *getMember() {
+ FieldDecl *getMember() {
if (isMemberInitializer())
- return reinterpret_cast<FieldDecl *>(BaseOrMember);
+ return reinterpret_cast<FieldDecl *>(BaseOrMember);
else
return 0;
}
@@ -916,21 +916,21 @@ public:
void setMember(FieldDecl * anonUnionField) {
BaseOrMember = reinterpret_cast<uintptr_t>(anonUnionField);
}
-
+
FieldDecl *getAnonUnionMember() const {
return CtorOrAnonUnion.dyn_cast<FieldDecl *>();
}
void setAnonUnionMember(FieldDecl *anonMember) {
CtorOrAnonUnion = anonMember;
}
-
- const CXXConstructorDecl *getConstructor() const {
+
+ const CXXConstructorDecl *getConstructor() const {
return CtorOrAnonUnion.dyn_cast<CXXConstructorDecl *>();
}
-
+
SourceLocation getSourceLocation() const { return IdLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
-
+
/// arg_begin() - Retrieve an iterator to the first initializer argument.
arg_iterator arg_begin() { return Args; }
/// arg_begin() - Retrieve an iterator to the first initializer argument.
@@ -948,7 +948,7 @@ public:
/// CXXConstructorDecl - Represents a C++ constructor within a
/// class. For example:
-///
+///
/// @code
/// class X {
/// public:
@@ -966,23 +966,23 @@ class CXXConstructorDecl : public CXXMethodDecl {
/// explicitly defaulted (i.e., defined with " = default") will have
/// @c !Implicit && ImplicitlyDefined.
bool ImplicitlyDefined : 1;
-
+
/// Support for base and member initializers.
- /// BaseOrMemberInitializers - The arguments used to initialize the base
+ /// BaseOrMemberInitializers - The arguments used to initialize the base
/// or member.
CXXBaseOrMemberInitializer **BaseOrMemberInitializers;
unsigned NumBaseOrMemberInitializers;
-
+
CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
DeclarationName N, QualType T, DeclaratorInfo *DInfo,
bool isExplicit, bool isInline, bool isImplicitlyDeclared)
: CXXMethodDecl(CXXConstructor, RD, L, N, T, DInfo, false, isInline),
Explicit(isExplicit), ImplicitlyDefined(false),
- BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
+ BaseOrMemberInitializers(0), NumBaseOrMemberInitializers(0) {
setImplicit(isImplicitlyDeclared);
}
virtual void Destroy(ASTContext& C);
-
+
public:
static CXXConstructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,
@@ -990,59 +990,59 @@ public:
bool isExplicit,
bool isInline, bool isImplicitlyDeclared);
- /// isExplicit - Whether this constructor was marked "explicit" or not.
+ /// isExplicit - Whether this constructor was marked "explicit" or not.
bool isExplicit() const { return Explicit; }
/// isImplicitlyDefined - Whether this constructor was implicitly
/// defined. If false, then this constructor was defined by the
/// user. This operation can only be invoked if the constructor has
/// already been defined.
- bool isImplicitlyDefined(ASTContext &C) const {
- assert(isThisDeclarationADefinition() &&
+ bool isImplicitlyDefined(ASTContext &C) const {
+ assert(isThisDeclarationADefinition() &&
"Can only get the implicit-definition flag once the "
"constructor has been defined");
- return ImplicitlyDefined;
+ return ImplicitlyDefined;
}
/// setImplicitlyDefined - Set whether this constructor was
/// implicitly defined or not.
- void setImplicitlyDefined(bool ID) {
- assert(isThisDeclarationADefinition() &&
+ void setImplicitlyDefined(bool ID) {
+ assert(isThisDeclarationADefinition() &&
"Can only set the implicit-definition flag once the constructor "
"has been defined");
- ImplicitlyDefined = ID;
+ ImplicitlyDefined = ID;
}
-
+
/// init_iterator - Iterates through the member/base initializer list.
typedef CXXBaseOrMemberInitializer **init_iterator;
-
+
/// init_const_iterator - Iterates through the memberbase initializer list.
typedef CXXBaseOrMemberInitializer * const * init_const_iterator;
-
+
/// init_begin() - Retrieve an iterator to the first initializer.
init_iterator init_begin() { return BaseOrMemberInitializers; }
/// begin() - Retrieve an iterator to the first initializer.
init_const_iterator init_begin() const { return BaseOrMemberInitializers; }
-
+
/// init_end() - Retrieve an iterator past the last initializer.
- init_iterator init_end() {
- return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
+ init_iterator init_end() {
+ return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
}
/// end() - Retrieve an iterator past the last initializer.
- init_const_iterator init_end() const {
- return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
+ init_const_iterator init_end() const {
+ return BaseOrMemberInitializers + NumBaseOrMemberInitializers;
}
-
+
/// getNumArgs - Determine the number of arguments used to
/// initialize the member or base.
- unsigned getNumBaseOrMemberInitializers() const {
- return NumBaseOrMemberInitializers;
+ unsigned getNumBaseOrMemberInitializers() const {
+ return NumBaseOrMemberInitializers;
}
-
+
void setNumBaseOrMemberInitializers(unsigned numBaseOrMemberInitializers) {
NumBaseOrMemberInitializers = numBaseOrMemberInitializers;
}
-
+
void setBaseOrMemberInitializers(CXXBaseOrMemberInitializer ** initializers) {
BaseOrMemberInitializers = initializers;
}
@@ -1079,7 +1079,7 @@ public:
bool isConvertingConstructor(bool AllowExplicit) const;
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == CXXConstructor;
}
static bool classof(const CXXConstructorDecl *D) { return true; }
@@ -1087,7 +1087,7 @@ public:
/// CXXDestructorDecl - Represents a C++ destructor within a
/// class. For example:
-///
+///
/// @code
/// class X {
/// public:
@@ -1109,97 +1109,97 @@ private:
/// explicitly defaulted (i.e., defined with " = default") will have
/// @c !Implicit && ImplicitlyDefined.
bool ImplicitlyDefined : 1;
-
+
/// Support for base and member destruction.
- /// BaseOrMemberDestructions - The arguments used to destruct the base
+ /// BaseOrMemberDestructions - The arguments used to destruct the base
/// or member. Each uintptr_t value represents one of base classes (either
/// virtual or direct non-virtual base), or non-static data member
/// to be destroyed. The low two bits encode the kind of object
/// being destroyed.
uintptr_t *BaseOrMemberDestructions;
unsigned NumBaseOrMemberDestructions;
-
+
CXXDestructorDecl(CXXRecordDecl *RD, SourceLocation L,
DeclarationName N, QualType T,
bool isInline, bool isImplicitlyDeclared)
: CXXMethodDecl(CXXDestructor, RD, L, N, T, /*DInfo=*/0, false, isInline),
ImplicitlyDefined(false),
- BaseOrMemberDestructions(0), NumBaseOrMemberDestructions(0) {
+ BaseOrMemberDestructions(0), NumBaseOrMemberDestructions(0) {
setImplicit(isImplicitlyDeclared);
}
virtual void Destroy(ASTContext& C);
-
+
public:
static CXXDestructorDecl *Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,
- QualType T, bool isInline,
+ QualType T, bool isInline,
bool isImplicitlyDeclared);
/// isImplicitlyDefined - Whether this destructor was implicitly
/// defined. If false, then this destructor was defined by the
/// user. This operation can only be invoked if the destructor has
/// already been defined.
- bool isImplicitlyDefined() const {
- assert(isThisDeclarationADefinition() &&
+ bool isImplicitlyDefined() const {
+ assert(isThisDeclarationADefinition() &&
"Can only get the implicit-definition flag once the destructor has been defined");
- return ImplicitlyDefined;
+ return ImplicitlyDefined;
}
/// setImplicitlyDefined - Set whether this destructor was
/// implicitly defined or not.
- void setImplicitlyDefined(bool ID) {
- assert(isThisDeclarationADefinition() &&
+ void setImplicitlyDefined(bool ID) {
+ assert(isThisDeclarationADefinition() &&
"Can only set the implicit-definition flag once the destructor has been defined");
- ImplicitlyDefined = ID;
+ ImplicitlyDefined = ID;
}
/// destr_iterator - Iterates through the member/base destruction list.
-
+
/// destr_const_iterator - Iterates through the member/base destruction list.
typedef uintptr_t const destr_const_iterator;
-
+
/// destr_begin() - Retrieve an iterator to the first destructed member/base.
- uintptr_t* destr_begin() {
- return BaseOrMemberDestructions;
+ uintptr_t* destr_begin() {
+ return BaseOrMemberDestructions;
}
/// destr_begin() - Retrieve an iterator to the first destructed member/base.
- uintptr_t* destr_begin() const {
- return BaseOrMemberDestructions;
+ uintptr_t* destr_begin() const {
+ return BaseOrMemberDestructions;
}
-
+
/// destr_end() - Retrieve an iterator past the last destructed member/base.
- uintptr_t* destr_end() {
- return BaseOrMemberDestructions + NumBaseOrMemberDestructions;
+ uintptr_t* destr_end() {
+ return BaseOrMemberDestructions + NumBaseOrMemberDestructions;
}
/// destr_end() - Retrieve an iterator past the last destructed member/base.
- uintptr_t* destr_end() const {
- return BaseOrMemberDestructions + NumBaseOrMemberDestructions;
+ uintptr_t* destr_end() const {
+ return BaseOrMemberDestructions + NumBaseOrMemberDestructions;
}
-
+
/// getNumBaseOrMemberDestructions - Number of base and non-static members
/// to destroy.
- unsigned getNumBaseOrMemberDestructions() const {
- return NumBaseOrMemberDestructions;
+ unsigned getNumBaseOrMemberDestructions() const {
+ return NumBaseOrMemberDestructions;
}
-
+
/// setNumBaseOrMemberDestructions - Set number of base and non-static members
/// to destroy.
void setNumBaseOrMemberDestructions(unsigned numBaseOrMemberDestructions) {
NumBaseOrMemberDestructions = numBaseOrMemberDestructions;
}
-
- /// getBaseOrMemberToDestroy - get the generic 'member' representing either
+
+ /// getBaseOrMemberToDestroy - get the generic 'member' representing either
/// the field or a base class.
uintptr_t* getBaseOrMemberToDestroy() const {
- return BaseOrMemberDestructions;
+ return BaseOrMemberDestructions;
}
-
- /// setBaseOrMemberToDestroy - set the generic 'member' representing either
+
+ /// setBaseOrMemberToDestroy - set the generic 'member' representing either
/// the field or a base class.
void setBaseOrMemberDestructions(uintptr_t* baseOrMemberDestructions) {
BaseOrMemberDestructions = baseOrMemberDestructions;
}
-
+
/// isVbaseToDestroy - returns true, if object is virtual base.
bool isVbaseToDestroy(uintptr_t Vbase) const {
return (Vbase & VBASE) != 0;
@@ -1209,7 +1209,7 @@ public:
bool isDirectNonVBaseToDestroy(uintptr_t DrctNonVbase) const {
return (DrctNonVbase & DRCTNONVBASE) != 0;
}
- /// isAnyBaseToDestroy - returns true, if object is any base (virtual or
+ /// isAnyBaseToDestroy - returns true, if object is any base (virtual or
/// direct non-virtual)
bool isAnyBaseToDestroy(uintptr_t AnyBase) const {
return (AnyBase & ANYBASE) != 0;
@@ -1225,9 +1225,9 @@ public:
return 0;
}
/// getMemberToDestroy - Get the member for the given object.
- FieldDecl *getMemberToDestroy(uintptr_t Member) const {
+ FieldDecl *getMemberToDestroy(uintptr_t Member) const {
if (isMemberToDestroy(Member))
- return reinterpret_cast<FieldDecl *>(Member);
+ return reinterpret_cast<FieldDecl *>(Member);
return 0;
}
/// getVbaseClassToDestroy - Get the virtual base.
@@ -1242,9 +1242,9 @@ public:
return reinterpret_cast<Type*>(Base & ~0x02);
return 0;
}
-
+
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == CXXDestructor;
}
static bool classof(const CXXDestructorDecl *D) { return true; }
@@ -1252,7 +1252,7 @@ public:
/// CXXConversionDecl - Represents a C++ conversion function within a
/// class. For example:
-///
+///
/// @code
/// class X {
/// public:
@@ -1266,7 +1266,7 @@ class CXXConversionDecl : public CXXMethodDecl {
bool Explicit : 1;
CXXConversionDecl(CXXRecordDecl *RD, SourceLocation L,
- DeclarationName N, QualType T, DeclaratorInfo *DInfo,
+ DeclarationName N, QualType T, DeclaratorInfo *DInfo,
bool isInline, bool isExplicit)
: CXXMethodDecl(CXXConversion, RD, L, N, T, DInfo, false, isInline),
Explicit(isExplicit) { }
@@ -1284,12 +1284,12 @@ public:
/// getConversionType - Returns the type that this conversion
/// function is converting to.
- QualType getConversionType() const {
- return getType()->getAsFunctionType()->getResultType();
+ QualType getConversionType() const {
+ return getType()->getAsFunctionType()->getResultType();
}
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == CXXConversion;
}
static bool classof(const CXXConversionDecl *D) { return true; }
@@ -1325,8 +1325,8 @@ private:
SourceLocation FriendL)
: Decl(Decl::Friend, DC, L),
Friend(Friend),
- FriendLoc(FriendL)
- {}
+ FriendLoc(FriendL) {
+ }
public:
static FriendDecl *Create(ASTContext &C, DeclContext *DC,
@@ -1353,12 +1353,12 @@ public:
}
// Implement isa/cast/dyncast/etc.
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == Decl::Friend;
}
static bool classof(const FriendDecl *D) { return true; }
};
-
+
/// LinkageSpecDecl - This represents a linkage specification. For example:
/// extern "C" void foo();
///
@@ -1378,14 +1378,14 @@ private:
/// HadBraces - Whether this linkage specification had curly braces or not.
bool HadBraces : 1;
- LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
+ LinkageSpecDecl(DeclContext *DC, SourceLocation L, LanguageIDs lang,
bool Braces)
- : Decl(LinkageSpec, DC, L),
+ : Decl(LinkageSpec, DC, L),
DeclContext(LinkageSpec), Language(lang), HadBraces(Braces) { }
public:
- static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, LanguageIDs Lang,
+ static LinkageSpecDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L, LanguageIDs Lang,
bool Braces);
LanguageIDs getLanguage() const { return Language; }
@@ -1452,8 +1452,8 @@ class UsingDirectiveDecl : public NamedDecl {
NamespaceDecl *Nominated,
DeclContext *CommonAncestor)
: NamedDecl(Decl::UsingDirective, DC, L, getName()),
- NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange),
- Qualifier(Qualifier), IdentLoc(IdentLoc),
+ NamespaceLoc(NamespcLoc), QualifierRange(QualifierRange),
+ Qualifier(Qualifier), IdentLoc(IdentLoc),
NominatedNamespace(Nominated? Nominated->getOriginalNamespace() : 0),
CommonAncestor(CommonAncestor) {
}
@@ -1518,20 +1518,20 @@ class NamespaceAliasDecl : public NamedDecl {
/// \brief The nested-name-specifier that precedes the namespace
/// name, if any.
NestedNameSpecifier *Qualifier;
-
+
/// IdentLoc - Location of namespace identifier.
SourceLocation IdentLoc;
-
- /// Namespace - The Decl that this alias points to. Can either be a
+
+ /// Namespace - The Decl that this alias points to. Can either be a
/// NamespaceDecl or a NamespaceAliasDecl.
NamedDecl *Namespace;
-
- NamespaceAliasDecl(DeclContext *DC, SourceLocation L,
- SourceLocation AliasLoc, IdentifierInfo *Alias,
+
+ NamespaceAliasDecl(DeclContext *DC, SourceLocation L,
+ SourceLocation AliasLoc, IdentifierInfo *Alias,
SourceRange QualifierRange,
NestedNameSpecifier *Qualifier,
SourceLocation IdentLoc, NamedDecl *Namespace)
- : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc),
+ : NamedDecl(Decl::NamespaceAlias, DC, L, Alias), AliasLoc(AliasLoc),
QualifierRange(QualifierRange), Qualifier(Qualifier),
IdentLoc(IdentLoc), Namespace(Namespace) { }
@@ -1550,7 +1550,7 @@ public:
return cast<NamespaceDecl>(Namespace);
}
-
+
const NamespaceDecl *getNamespace() const {
return const_cast<NamespaceAliasDecl*>(this)->getNamespace();
}
@@ -1559,14 +1559,14 @@ public:
/// may either be a NamespaceDecl or a NamespaceAliasDecl.
NamedDecl *getAliasedNamespace() const { return Namespace; }
- static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L, SourceLocation AliasLoc,
- IdentifierInfo *Alias,
+ static NamespaceAliasDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L, SourceLocation AliasLoc,
+ IdentifierInfo *Alias,
SourceRange QualifierRange,
NestedNameSpecifier *Qualifier,
- SourceLocation IdentLoc,
+ SourceLocation IdentLoc,
NamedDecl *Namespace);
-
+
static bool classof(const Decl *D) {
return D->getKind() == Decl::NamespaceAlias;
}
@@ -1579,16 +1579,16 @@ class UsingDecl : public NamedDecl {
/// \brief The source range that covers the nested-name-specifier
/// preceding the declaration name.
SourceRange NestedNameRange;
-
+
/// \brief The source location of the target declaration name.
SourceLocation TargetNameLocation;
-
+
/// \brief The source location of the "using" location itself.
SourceLocation UsingLocation;
-
+
/// \brief Target declaration.
NamedDecl* TargetDecl;
-
+
/// \brief Target nested name specifier.
NestedNameSpecifier* TargetNestedNameDecl;
@@ -1601,7 +1601,7 @@ class UsingDecl : public NamedDecl {
: NamedDecl(Decl::Using, DC, L, Target->getDeclName()),
NestedNameRange(NNR), TargetNameLocation(TargetNL),
UsingLocation(UL), TargetDecl(Target),
- TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) {
+ TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) {
this->IdentifierNamespace = TargetDecl->getIdentifierNamespace();
}
@@ -1609,22 +1609,22 @@ public:
/// \brief Returns the source range that covers the nested-name-specifier
/// preceding the namespace name.
SourceRange getNestedNameRange() { return NestedNameRange; }
-
+
/// \brief Returns the source location of the target declaration name.
SourceLocation getTargetNameLocation() { return TargetNameLocation; }
-
+
/// \brief Returns the source location of the "using" location itself.
SourceLocation getUsingLocation() { return UsingLocation; }
-
+
/// \brief getTargetDecl - Returns target specified by using-decl.
NamedDecl *getTargetDecl() { return TargetDecl; }
const NamedDecl *getTargetDecl() const { return TargetDecl; }
-
+
/// \brief Get target nested name declaration.
- NestedNameSpecifier* getTargetNestedNameDecl() {
- return TargetNestedNameDecl;
+ NestedNameSpecifier* getTargetNestedNameDecl() {
+ return TargetNestedNameDecl;
}
-
+
/// isTypeName - Return true if using decl has 'typename'.
bool isTypeName() const { return IsTypeName; }
@@ -1645,39 +1645,39 @@ class UnresolvedUsingDecl : public NamedDecl {
/// \brief The source range that covers the nested-name-specifier
/// preceding the declaration name.
SourceRange TargetNestedNameRange;
-
+
/// \brief The source location of the target declaration name.
SourceLocation TargetNameLocation;
-
+
NestedNameSpecifier *TargetNestedNameSpecifier;
-
+
DeclarationName TargetName;
-
+
// \brief Has 'typename' keyword.
bool IsTypeName;
-
+
UnresolvedUsingDecl(DeclContext *DC, SourceLocation UsingLoc,
SourceRange TargetNNR, NestedNameSpecifier *TargetNNS,
SourceLocation TargetNameLoc, DeclarationName TargetName,
bool IsTypeNameArg)
: NamedDecl(Decl::UnresolvedUsing, DC, UsingLoc, TargetName),
- TargetNestedNameRange(TargetNNR), TargetNameLocation(TargetNameLoc),
- TargetNestedNameSpecifier(TargetNNS), TargetName(TargetName),
+ TargetNestedNameRange(TargetNNR), TargetNameLocation(TargetNameLoc),
+ TargetNestedNameSpecifier(TargetNNS), TargetName(TargetName),
IsTypeName(IsTypeNameArg) { }
public:
/// \brief Returns the source range that covers the nested-name-specifier
/// preceding the namespace name.
SourceRange getTargetNestedNameRange() const { return TargetNestedNameRange; }
-
+
/// \brief Get target nested name declaration.
- NestedNameSpecifier* getTargetNestedNameSpecifier() {
- return TargetNestedNameSpecifier;
+ NestedNameSpecifier* getTargetNestedNameSpecifier() {
+ return TargetNestedNameSpecifier;
}
-
+
/// \brief Returns the source location of the target declaration name.
SourceLocation getTargetNameLocation() const { return TargetNameLocation; }
-
+
/// \brief Returns the source location of the target declaration name.
DeclarationName getTargetName() const { return TargetName; }
@@ -1690,33 +1690,33 @@ public:
SourceLocation TargetNameLoc,
DeclarationName TargetName,
bool IsTypeNameArg);
-
+
static bool classof(const Decl *D) {
return D->getKind() == Decl::UnresolvedUsing;
}
static bool classof(const UnresolvedUsingDecl *D) { return true; }
};
-
+
/// StaticAssertDecl - Represents a C++0x static_assert declaration.
class StaticAssertDecl : public Decl {
Expr *AssertExpr;
StringLiteral *Message;
- StaticAssertDecl(DeclContext *DC, SourceLocation L,
+ StaticAssertDecl(DeclContext *DC, SourceLocation L,
Expr *assertexpr, StringLiteral *message)
: Decl(StaticAssert, DC, L), AssertExpr(assertexpr), Message(message) { }
-
+
public:
static StaticAssertDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, Expr *AssertExpr,
StringLiteral *Message);
-
+
Expr *getAssertExpr() { return AssertExpr; }
const Expr *getAssertExpr() const { return AssertExpr; }
-
+
StringLiteral *getMessage() { return Message; }
const StringLiteral *getMessage() const { return Message; }
-
+
virtual ~StaticAssertDecl();
virtual void Destroy(ASTContext& C);
@@ -1730,7 +1730,7 @@ public:
/// into a diagnostic with <<.
const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
AccessSpecifier AS);
-
+
} // end namespace clang
#endif
diff --git a/include/clang/AST/DeclContextInternals.h b/include/clang/AST/DeclContextInternals.h
index 6c1231c0a7..d9e40d4789 100644
--- a/include/clang/AST/DeclContextInternals.h
+++ b/include/clang/AST/DeclContextInternals.h
@@ -57,13 +57,13 @@ public:
Data = reinterpret_cast<uintptr_t>(New) | (Data & 0x03);
}
}
-
+
~StoredDeclsList() {
// If this is a vector-form, free the vector.
if (VectorTy *Vector = getAsVector())
delete Vector;
}
-
+
StoredDeclsList &operator=(const StoredDeclsList &RHS) {
if (VectorTy *Vector = getAsVector())
delete Vector;
@@ -74,9 +74,9 @@ public:
}
return *this;
}
-
+
bool isNull() const { return (Data & ~0x03) == 0; }
-
+
NamedDecl *getAsDecl() const {
if ((Data & 0x03) != DK_Decl)
return 0;
@@ -135,27 +135,27 @@ public:
DeclContext::lookup_result getLookupResult(ASTContext &Context) {
if (isNull())
return DeclContext::lookup_result(0, 0);
-
+
if (hasDeclarationIDs())
materializeDecls(Context);
// If we have a single NamedDecl, return it.
if (getAsDecl()) {
assert(!isNull() && "Empty list isn't allowed");
-
+
// Data is a raw pointer to a NamedDecl*, return it.
void *Ptr = &Data;
return DeclContext::lookup_result((NamedDecl**)Ptr, (NamedDecl**)Ptr+1);
}
-
+
assert(getAsVector() && "Must have a vector at this point");
VectorTy &Vector = *getAsVector();
-
+
// Otherwise, we have a range result.
- return DeclContext::lookup_result((NamedDecl **)&Vector[0],
+ return DeclContext::lookup_result((NamedDecl **)&Vector[0],
(NamedDecl **)&Vector[0]+Vector.size());
}
-
+
/// HandleRedeclaration - If this is a redeclaration of an existing decl,
/// replace the old one with D and return true. Otherwise return false.
bool HandleRedeclaration(ASTContext &Context, NamedDecl *D) {
@@ -169,7 +169,7 @@ public:
setOnlyValue(D);
return true;
}
-
+
// Determine if this declaration is actually a redeclaration.
VectorTy &Vec = *getAsVector();
for (VectorTy::iterator OD = Vec.begin(), ODEnd = Vec.end();
@@ -183,10 +183,10 @@ public:
return false;
}
-
+
/// AddSubsequentDecl - This is called on the second and later decl when it is
/// not a redeclaration to merge it into the appropriate place in our list.
- ///
+ ///
void AddSubsequentDecl(NamedDecl *D) {
assert(!hasDeclarationIDs() && "Must materialize before adding decls");
@@ -197,7 +197,7 @@ public:
VT->push_back(reinterpret_cast<uintptr_t>(OldD));
Data = reinterpret_cast<uintptr_t>(VT) | DK_Decl_Vector;
}
-
+
VectorTy &Vec = *getAsVector();
if (isa<UsingDirectiveDecl>(D) ||
D->getIdentifierNamespace() == Decl::IDNS_Tag)
@@ -217,4 +217,4 @@ typedef llvm::DenseMap<DeclarationName, StoredDeclsList> StoredDeclsMap;
} // end namespace clang
-#endif
+#endif
diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h
index 15a8adef8e..790ea3ca06 100644
--- a/include/clang/AST/DeclGroup.h
+++ b/include/clang/AST/DeclGroup.h
@@ -18,7 +18,7 @@
#include <cassert>
namespace clang {
-
+
class ASTContext;
class Decl;
class DeclGroup;
@@ -27,7 +27,7 @@ class DeclGroupIterator;
class DeclGroup {
// FIXME: Include a TypeSpecifier object.
unsigned NumDecls;
-
+
private:
DeclGroup() : NumDecls(0) {}
DeclGroup(unsigned numdecls, Decl** decls);
@@ -38,34 +38,34 @@ public:
unsigned size() const { return NumDecls; }
- Decl*& operator[](unsigned i) {
+ Decl*& operator[](unsigned i) {
assert (i < NumDecls && "Out-of-bounds access.");
return *((Decl**) (this+1));
}
-
- Decl* const& operator[](unsigned i) const {
+
+ Decl* const& operator[](unsigned i) const {
assert (i < NumDecls && "Out-of-bounds access.");
return *((Decl* const*) (this+1));
}
};
-
+
class DeclGroupRef {
// Note this is not a PointerIntPair because we need the address of the
// non-group case to be valid as a Decl** for iteration.
- enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 };
+ enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 };
Decl* D;
Kind getKind() const {
return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask);
- }
-
-public:
+ }
+
+public:
DeclGroupRef() : D(0) {}
-
+
explicit DeclGroupRef(Decl* d) : D(d) {}
explicit DeclGroupRef(DeclGroup* dg)
: D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {}
-
+
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls) {
if (NumDecls == 0)
return DeclGroupRef();
@@ -73,10 +73,10 @@ public:
return DeclGroupRef(Decls[0]);
return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls));
}
-
+
typedef Decl** iterator;
typedef Decl* const * const_iterator;
-
+
bool isNull() const { return D == 0; }
bool isSingleDecl() const { return getKind() == SingleDeclKind; }
bool isDeclGroup() const { return getKind() == DeclGroupKind; }
@@ -88,7 +88,7 @@ public:
const Decl *getSingleDecl() const {
return const_cast<DeclGroupRef*>(this)->getSingleDecl();
}
-
+
DeclGroup &getDeclGroup() {
assert(isDeclGroup() && "Isn't a declgroup");
return *((DeclGroup*)(reinterpret_cast<uintptr_t>(D) & ~Mask));
@@ -96,7 +96,7 @@ public:
const DeclGroup &getDeclGroup() const {
return const_cast<DeclGroupRef*>(this)->getDeclGroup();
}
-
+
iterator begin() {
if (isSingleDecl())
return D ? &D : 0;
@@ -109,13 +109,13 @@ public:
DeclGroup &G = getDeclGroup();
return &G[0] + G.size();
}
-
+
const_iterator begin() const {
if (isSingleDecl())
return D ? &D : 0;
return &getDeclGroup()[0];
}
-
+
const_iterator end() const {
if (isSingleDecl())
return D ? &D+1 : 0;
@@ -130,7 +130,7 @@ public:
return X;
}
};
-
+
} // end clang namespace
namespace llvm {
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 5faa5d54b3..6263246acf 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -43,17 +43,17 @@ public:
~ObjCListBase() {
assert(List == 0 && "Destroy should have been called before dtor");
}
-
+
void Destroy(ASTContext &Ctx);
-
+
unsigned size() const { return NumElts; }
bool empty() const { return NumElts == 0; }
-
+
protected:
void set(void *const* InList, unsigned Elts, ASTContext &Ctx);
};
-
-
+
+
/// ObjCList - This is a simple template class used to hold various lists of
/// decls etc, which is heavily used by the ObjC front-end. This only use case
/// this supports is setting the list all at once and then reading elements out
@@ -64,30 +64,30 @@ public:
void set(T* const* InList, unsigned Elts, ASTContext &Ctx) {
ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx);
}
-
+
typedef T* const * iterator;
iterator begin() const { return (iterator)List; }
iterator end() const { return (iterator)List+NumElts; }
-
+
T* operator[](unsigned Idx) const {
assert(Idx < NumElts && "Invalid access");
return (T*)List[Idx];
}
};
-
+
/// ObjCMethodDecl - Represents an instance or class method declaration.
/// ObjC methods can be declared within 4 contexts: class interfaces,
/// categories, protocols, and class implementations. While C++ member
-/// functions leverage C syntax, Objective-C method syntax is modeled after
-/// Smalltalk (using colons to specify argument types/expressions).
+/// functions leverage C syntax, Objective-C method syntax is modeled after
+/// Smalltalk (using colons to specify argument types/expressions).
/// Here are some brief examples:
///
/// Setter/getter instance methods:
/// - (void)setMenu:(NSMenu *)menu;
-/// - (NSMenu *)menu;
-///
+/// - (NSMenu *)menu;
+///
/// Instance method that takes 2 NSView arguments:
/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
///
@@ -106,27 +106,27 @@ private:
/// instance (true) or class (false) method.
bool IsInstance : 1;
bool IsVariadic : 1;
-
+
// Synthesized declaration method for a property setter/getter
bool IsSynthesized : 1;
-
+
// NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
/// @required/@optional
unsigned DeclImplementation : 2;
-
+
// NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
/// in, inout, etc.
unsigned objcDeclQualifier : 6;
-
+
// Type of this method.
QualType MethodDeclType;
/// ParamInfo - List of pointers to VarDecls for the formal parameters of this
/// Method.
ObjCList<ParmVarDecl> ParamInfo;
-
+
/// List of attributes for this method declaration.
SourceLocation EndLoc; // the location of the ';' or '}'.
-
+
// The following are only used for method definitions, null otherwise.
// FIXME: space savings opportunity, consider a sub-class.
Stmt *Body;
@@ -137,7 +137,7 @@ private:
/// CmdDecl - Decl for the implicit _cmd parameter. This is lazily
/// constructed by createImplicitParams.
ImplicitParamDecl *CmdDecl;
-
+
ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
Selector SelInfo, QualType T,
DeclContext *contextDecl,
@@ -150,7 +150,7 @@ private:
IsInstance(isInstance), IsVariadic(isVariadic),
IsSynthesized(isSynthesized),
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
- MethodDeclType(T),
+ MethodDeclType(T),
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
virtual ~ObjCMethodDecl() {}
@@ -161,12 +161,12 @@ private:
virtual ObjCMethodDecl *getNextRedeclaration();
public:
-
+
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
static ObjCMethodDecl *Create(ASTContext &C,
- SourceLocation beginLoc,
+ SourceLocation beginLoc,
SourceLocation endLoc, Selector SelInfo,
QualType T, DeclContext *contextDecl,
bool isInstance = true,
@@ -180,25 +180,25 @@ public:
return ObjCDeclQualifier(objcDeclQualifier);
}
void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
-
+
// Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); }
SourceLocation getLocEnd() const { return EndLoc; }
void setEndLoc(SourceLocation Loc) { EndLoc = Loc; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(getLocation(), EndLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(getLocation(), EndLoc);
}
-
+
ObjCInterfaceDecl *getClassInterface();
const ObjCInterfaceDecl *getClassInterface() const {
return const_cast<ObjCMethodDecl*>(this)->getClassInterface();
}
-
+
Selector getSelector() const { return getDeclName().getObjCSelector(); }
QualType getResultType() const { return MethodDeclType; }
void setResultType(QualType T) { MethodDeclType = T; }
-
+
// Iterator access to formal parameters.
unsigned param_size() const { return ParamInfo.size(); }
typedef ObjCList<ParmVarDecl>::iterator param_iterator;
@@ -219,7 +219,7 @@ public:
arg_type_iterator arg_type_end() const {
return llvm::map_iterator(param_end(), deref_fun(&ParmVarDecl::getType));
}
-
+
/// createImplicitParams - Used to lazily create the self and cmd
/// implict parameters. This must be called prior to using getSelfDecl()
/// or getCmdDecl(). The call is ignored if the implicit paramters
@@ -230,27 +230,27 @@ public:
void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; }
ImplicitParamDecl * getCmdDecl() const { return CmdDecl; }
void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; }
-
+
bool isInstanceMethod() const { return IsInstance; }
void setInstanceMethod(bool isInst) { IsInstance = isInst; }
bool isVariadic() const { return IsVariadic; }
void setVariadic(bool isVar) { IsVariadic = isVar; }
-
+
bool isClassMethod() const { return !IsInstance; }
bool isSynthesized() const { return IsSynthesized; }
void setSynthesized(bool isSynth) { IsSynthesized = isSynth; }
-
+
// Related to protocols declared in @protocol
- void setDeclImplementation(ImplementationControl ic) {
- DeclImplementation = ic;
+ void setDeclImplementation(ImplementationControl ic) {
+ DeclImplementation = ic;
}
- ImplementationControl getImplementationControl() const {
- return ImplementationControl(DeclImplementation);
+ ImplementationControl getImplementationControl() const {
+ return ImplementationControl(DeclImplementation);
}
- virtual Stmt *getBody() const {
- return (Stmt*) Body;
+ virtual Stmt *getBody() const {
+ return (Stmt*) Body;
}
CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; }
void setBody(Stmt *B) { Body = B; }
@@ -273,9 +273,9 @@ public:
struct ObjCMethodList {
ObjCMethodDecl *Method;
ObjCMethodList *Next;
-
+
ObjCMethodList() {
- Method = 0;
+ Method = 0;
Next = 0;
}
ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) {
@@ -286,13 +286,13 @@ struct ObjCMethodList {
/// ObjCContainerDecl - Represents a container for method declarations.
/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
-/// ObjCProtocolDecl, and ObjCImplDecl.
+/// ObjCProtocolDecl, and ObjCImplDecl.
///
class ObjCContainerDecl : public NamedDecl, public DeclContext {
SourceLocation AtEndLoc; // marks the end of the method container.
public:
- ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L,
+ ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id)
: NamedDecl(DK, DC, L, Id), DeclContext(DK) {}
@@ -300,24 +300,24 @@ public:
// Iterator access to properties.
typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
- prop_iterator prop_begin() const {
+ prop_iterator prop_begin() const {
return prop_iterator(decls_begin());
}
- prop_iterator prop_end() const {
+ prop_iterator prop_end() const {
return prop_iterator(decls_end());
}
-
+
// Iterator access to instance/class methods.
typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
- method_iterator meth_begin() const {
+ method_iterator meth_begin() const {
return method_iterator(decls_begin());
}
- method_iterator meth_end() const {
+ method_iterator meth_end() const {
return method_iterator(decls_end());
}
- typedef filtered_decl_iterator<ObjCMethodDecl,
- &ObjCMethodDecl::isInstanceMethod>
+ typedef filtered_decl_iterator<ObjCMethodDecl,
+ &ObjCMethodDecl::isInstanceMethod>
instmeth_iterator;
instmeth_iterator instmeth_begin() const {
return instmeth_iterator(decls_begin());
@@ -326,8 +326,8 @@ public:
return instmeth_iterator(decls_end());
}
- typedef filtered_decl_iterator<ObjCMethodDecl,
- &ObjCMethodDecl::isClassMethod>
+ typedef filtered_decl_iterator<ObjCMethodDecl,
+ &ObjCMethodDecl::isClassMethod>
classmeth_iterator;
classmeth_iterator classmeth_begin() const {
return classmeth_iterator(decls_begin());
@@ -345,7 +345,7 @@ public:
return getMethod(Sel, false/*isInstance*/);
}
ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
-
+
ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
// Marks the end of the container.
@@ -355,10 +355,10 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(getLocation(), getAtEndLoc());
}
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
- return D->getKind() >= ObjCContainerFirst &&
+ return D->getKind() >= ObjCContainerFirst &&
D->getKind() <= ObjCContainerLast;
}
static bool classof(const ObjCContainerDecl *D) { return true; }
@@ -374,11 +374,11 @@ public:
/// ObjCInterfaceDecl - Represents an ObjC class declaration. For example:
///
/// // MostPrimitive declares no super class (not particularly useful).
-/// @interface MostPrimitive
+/// @interface MostPrimitive
/// // no instance variables or methods.
/// @end
///
-/// // NSResponder inherits from NSObject & implements NSCoding (a protocol).
+/// // NSResponder inherits from NSObject & implements NSCoding (a protocol).
/// @interface NSResponder : NSObject <NSCoding>
/// { // instance variables are represented by ObjCIvarDecl.
/// id nextResponder; // nextResponder instance variable.
@@ -397,32 +397,32 @@ class ObjCInterfaceDecl : public ObjCContainerDecl {
/// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
mutable Type *TypeForDecl;
friend class ASTContext;
-
+
/// Class's super class.
ObjCInterfaceDecl *SuperClass;
-
+
/// Protocols referenced in interface header declaration
ObjCList<ObjCProtocolDecl> ReferencedProtocols;
-
+
/// Instance variables in the interface.
ObjCList<ObjCIvarDecl> IVars;
-
+
/// List of categories defined for this class.
/// FIXME: Why is this a linked list??
ObjCCategoryDecl *CategoryList;
-
+
bool ForwardDecl:1; // declared with @class.
bool InternalInterface:1; // true - no @interface for @implementation
-
+
SourceLocation ClassLoc; // location of the class identifier.
SourceLocation SuperClassLoc; // location of the super class identifier.
SourceLocation EndLoc; // marks the '>', '}', or identifier.
ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
SourceLocation CLoc, bool FD, bool isInternal);
-
+
virtual ~ObjCInterfaceDecl() {}
-
+
public:
/// Destroy - Call destructors and release memory.
@@ -430,24 +430,24 @@ public:
static ObjCInterfaceDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation atLoc,
- IdentifierInfo *Id,
+ IdentifierInfo *Id,
SourceLocation ClassLoc = SourceLocation(),
bool ForwardDecl = false,
bool isInternal = false);
- const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
- return ReferencedProtocols;
+ const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
+ return ReferencedProtocols;
}
ObjCImplementationDecl *getImplementation() const;
void setImplementation(ObjCImplementationDecl *ImplD);
ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const;
-
+
// Get the local instance/class method declared in a category.
ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const;
ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const;
ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const {
- return isInstance ? getInstanceMethod(Sel)
+ return isInstance ? getInstanceMethod(Sel)
: getClassMethod(Sel);
}
@@ -461,29 +461,29 @@ public:
ivar_iterator ivar_end() const { return IVars.end(); }
unsigned ivar_size() const { return IVars.size(); }
bool ivar_empty() const { return IVars.empty(); }
-
+
/// setProtocolList - Set the list of protocols that this interface
/// implements.
void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num,
ASTContext &C) {
ReferencedProtocols.set(List, Num, C);
}
-
+
void setIVarList(ObjCIvarDecl * const *List, unsigned Num, ASTContext &C) {
IVars.set(List, Num, C);
}
bool isForwardDecl() const { return ForwardDecl; }
void setForwardDecl(bool val) { ForwardDecl = val; }
-
+
ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
-
+
ObjCCategoryDecl* getCategoryList() const { return CategoryList; }
- void setCategoryList(ObjCCategoryDecl *category) {
+ void setCategoryList(ObjCCategoryDecl *category) {
CategoryList = category;
}
-
+
/// isSuperClassOf - Return true if this class is the specified class or is a
/// super class of the specified interface class.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const {
@@ -495,7 +495,7 @@ public:
}
return false;
}
-
+
ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
ObjCInterfaceDecl *&ClassDeclared);
ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
@@ -518,25 +518,25 @@ public:
SourceLocation getLocStart() const { return getLocation(); } // '@'interface
SourceLocation getLocEnd() const { return EndLoc; }
void setLocEnd(SourceLocation LE) { EndLoc = LE; };
-
+
void setClassLoc(SourceLocation Loc) { ClassLoc = Loc; }
SourceLocation getClassLoc() const { return ClassLoc; }
void setSuperClassLoc(SourceLocation Loc) { SuperClassLoc = Loc; }
SourceLocation getSuperClassLoc() const { return SuperClassLoc; }
-
+
/// isImplicitInterfaceDecl - check that this is an implicitly declared
/// ObjCInterfaceDecl node. This is for legacy objective-c @implementation
/// declaration without an @interface declaration.
bool isImplicitInterfaceDecl() const { return InternalInterface; }
void setImplicitInterfaceDecl(bool val) { InternalInterface = val; }
-
+
/// ClassImplementsProtocol - Checks that 'lProto' protocol
/// has been implemented in IDecl class, its super class or categories (if
/// lookupCategory is true).
bool ClassImplementsProtocol(ObjCProtocolDecl *lProto,
bool lookupCategory,
bool RHSIsQualifiedID = false);
-
+
// Low-level accessor
Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(Type *TD) const { TypeForDecl = TD; }
@@ -565,19 +565,19 @@ public:
enum AccessControl {
None, Private, Protected, Public, Package
};
-
+
private:
ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
QualType T, DeclaratorInfo *DInfo, AccessControl ac, Expr *BW)
- : FieldDecl(ObjCIvar, DC, L, Id, T, DInfo, BW, /*Mutable=*/false),
+ : FieldDecl(ObjCIvar, DC, L, Id, T, DInfo, BW, /*Mutable=*/false),
DeclAccess(ac) {}
-
+
public:
static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, QualType T,
DeclaratorInfo *DInfo,
AccessControl ac, Expr *BW = NULL);
-
+
void setAccessControl(AccessControl ac) { DeclAccess = ac; }
AccessControl getAccessControl() const { return AccessControl(DeclAccess); }
@@ -585,7 +585,7 @@ public:
AccessControl getCanonicalAccessControl() const {
return DeclAccess == None ? Protected : AccessControl(DeclAccess);
}
-
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == ObjCIvar; }
static bool classof(const ObjCIvarDecl *D) { return true; }
@@ -594,7 +594,7 @@ private:
unsigned DeclAccess : 3;
};
-
+
/// ObjCAtDefsFieldDecl - Represents a field declaration created by an
/// @defs(...).
class ObjCAtDefsFieldDecl : public FieldDecl {
@@ -604,13 +604,13 @@ private:
: FieldDecl(ObjCAtDefsField, DC, L, Id, T,
/*DInfo=*/0, // FIXME: Do ObjCAtDefs have declarators ?
BW, /*Mutable=*/false) {}
-
+
public:
static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
IdentifierInfo *Id, QualType T,
Expr *BW);
-
+
virtual void Destroy(ASTContext& C);
// Implement isa/cast/dyncast/etc.
@@ -619,8 +619,8 @@ public:
};
/// ObjCProtocolDecl - Represents a protocol declaration. ObjC protocols
-/// declare a pure abstract type (i.e no instance variables are permitted).
-/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++
+/// declare a pure abstract type (i.e no instance variables are permitted).
+/// Protocols orginally drew inspiration from C++ pure virtual functions (a C++
/// feature with nice semantics and lousy syntax:-). Here is an example:
///
/// @protocol NSDraggingInfo <refproto1, refproto2>
@@ -637,7 +637,7 @@ public:
///
/// ObjC protocols inspired Java interfaces. Unlike Java, ObjC classes and
/// protocols are in distinct namespaces. For example, Cocoa defines both
-/// an NSObject protocol and class (which isn't allowed in Java). As a result,
+/// an NSObject protocol and class (which isn't allowed in Java). As a result,
/// protocols are referenced using angle brackets as follows:
///
/// id <NSDraggingInfo> anyObjectThatImplementsNSDraggingInfo;
@@ -645,42 +645,42 @@ public:
class ObjCProtocolDecl : public ObjCContainerDecl {
/// Referenced protocols
ObjCList<ObjCProtocolDecl> ReferencedProtocols;
-
+
bool isForwardProtoDecl; // declared with @protocol.
-
+
SourceLocation EndLoc; // marks the '>' or identifier.
-
+
ObjCProtocolDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
- : ObjCContainerDecl(ObjCProtocol, DC, L, Id),
+ : ObjCContainerDecl(ObjCProtocol, DC, L, Id),
isForwardProtoDecl(true) {
}
-
+
virtual ~ObjCProtocolDecl() {}
-
+
public:
- static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
+ static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
-
- const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
+
+ const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
return ReferencedProtocols;
}
typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
unsigned protocol_size() const { return ReferencedProtocols.size(); }
-
+
/// setProtocolList - Set the list of protocols that this interface
/// implements.
void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num,
ASTContext &C) {
ReferencedProtocols.set(List, Num, C);
}
-
+
ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName);
-
+
// Lookup a method. First, we search locally. If a method isn't
// found, we search referenced protocols and class categories.
ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
@@ -694,34 +694,34 @@ public:
bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; }
- // Location information, modeled after the Stmt API.
+ // Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'protocol
SourceLocation getLocEnd() const { return EndLoc; }
void setLocEnd(SourceLocation LE) { EndLoc = LE; };
-
+
static bool classof(const Decl *D) { return D->getKind() == ObjCProtocol; }
static bool classof(const ObjCProtocolDecl *D) { return true; }
};
-
+
/// ObjCClassDecl - Specifies a list of forward class declarations. For example:
///
/// @class NSCursor, NSImage, NSPasteboard, NSWindow;
///
class ObjCClassDecl : public Decl {
ObjCList<ObjCInterfaceDecl> ForwardDecls;
-
- ObjCClassDecl(DeclContext *DC, SourceLocation L,
+
+ ObjCClassDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *const *Elts, unsigned nElts, ASTContext &C);
virtual ~ObjCClassDecl() {}
public:
-
+
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
-
+
static ObjCClassDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L,
- ObjCInterfaceDecl *const *Elts = 0,
+ ObjCInterfaceDecl *const *Elts = 0,
unsigned nElts = 0);
-
+
typedef ObjCList<ObjCInterfaceDecl>::iterator iterator;
iterator begin() const { return ForwardDecls.begin(); }
iterator end() const { return ForwardDecls.end(); }
@@ -731,33 +731,33 @@ public:
void setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, unsigned Num) {
ForwardDecls.set(List, Num, C);
}
-
+
static bool classof(const Decl *D) { return D->getKind() == ObjCClass; }
static bool classof(const ObjCClassDecl *D) { return true; }
};
/// ObjCForwardProtocolDecl - Specifies a list of forward protocol declarations.
/// For example:
-///
+///
/// @protocol NSTextInput, NSChangeSpelling, NSDraggingInfo;
-///
+///
class ObjCForwardProtocolDecl : public Decl {
ObjCList<ObjCProtocolDecl> ReferencedProtocols;
-
+
ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
ObjCProtocolDecl *const *Elts, unsigned nElts,
- ASTContext &C);
+ ASTContext &C);
virtual ~ObjCForwardProtocolDecl() {}
-
+
public:
static ObjCForwardProtocolDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+ SourceLocation L,
ObjCProtocolDecl *const *Elts = 0,
unsigned Num = 0);
/// Destroy - Call destructors and release memory.
virtual void Destroy(ASTContext& C);
-
+
typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
@@ -776,7 +776,7 @@ public:
/// ObjCCategoryDecl - Represents a category declaration. A category allows
/// you to add methods to an existing class (without subclassing or modifying
-/// the original class interface or implementation:-). Categories don't allow
+/// the original class interface or implementation:-). Categories don't allow
/// you to add instance data. The following example adds "myMethod" to all
/// NSView's within a process:
///
@@ -788,31 +788,31 @@ public:
/// several files (a feature more naturally supported in C++).
///
/// Categories were originally inspired by dynamic languages such as Common
-/// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
+/// Lisp and Smalltalk. More traditional class-based languages (C++, Java)
/// don't support this level of dynamism, which is both powerful and dangerous.
///
class ObjCCategoryDecl : public ObjCContainerDecl {
/// Interface belonging to this category
ObjCInterfaceDecl *ClassInterface;
-
+
/// referenced protocols in this category.
ObjCList<ObjCProtocolDecl> ReferencedProtocols;
-
+
/// Next category belonging to this class.
/// FIXME: this should not be a singly-linked list. Move storage elsewhere.
ObjCCategoryDecl *NextClassCategory;
-
+
SourceLocation EndLoc; // marks the '>' or identifier.
-
+
ObjCCategoryDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id)
: ObjCContainerDecl(ObjCCategory, DC, L, Id),
ClassInterface(0), NextClassCategory(0){
}
public:
-
+
static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id);
-
+
ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
@@ -826,16 +826,16 @@ public:
ASTContext &C) {
ReferencedProtocols.set(List, Num, C);
}
-
- const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
+
+ const ObjCList<ObjCProtocolDecl> &getReferencedProtocols() const {
return ReferencedProtocols;
}
-
+
typedef ObjCList<ObjCProtocolDecl>::iterator protocol_iterator;
protocol_iterator protocol_begin() const {return ReferencedProtocols.begin();}
protocol_iterator protocol_end() const { return ReferencedProtocols.end(); }
unsigned protocol_size() const { return ReferencedProtocols.size(); }
-
+
ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; }
void setNextClassCategory(ObjCCategoryDecl *Cat) {
NextClassCategory = Cat;
@@ -844,11 +844,11 @@ public:
NextClassCategory = ClassInterface->getCategoryList();
ClassInterface->setCategoryList(this);
}
- // Location information, modeled after the Stmt API.
+ // Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } // '@'interface
SourceLocation getLocEnd() const { return EndLoc; }
void setLocEnd(SourceLocation LE) { EndLoc = LE; };
-
+
static bool classof(const Decl *D) { return D->getKind() == ObjCCategory; }
static bool classof(const ObjCCategoryDecl *D) { return true; }
};
@@ -856,43 +856,43 @@ public:
class ObjCImplDecl : public ObjCContainerDecl {
/// Class interface for this category implementation
ObjCInterfaceDecl *ClassInterface;
-
+
protected:
ObjCImplDecl(Kind DK, DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *classInterface)
- : ObjCContainerDecl(DK, DC, L,
- classInterface? classInterface->getIdentifier() : 0),
+ : ObjCContainerDecl(DK, DC, L,
+ classInterface? classInterface->getIdentifier() : 0),
ClassInterface(classInterface) {}
-
+
public:
virtual ~ObjCImplDecl() {}
-
+
const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
ObjCInterfaceDecl *getClassInterface() { return ClassInterface; }
void setClassInterface(ObjCInterfaceDecl *IFace);
- void addInstanceMethod(ObjCMethodDecl *method) {
+ void addInstanceMethod(ObjCMethodDecl *method) {
// FIXME: Context should be set correctly before we get here.
method->setLexicalDeclContext(this);
- addDecl(method);
+ addDecl(method);
}
- void addClassMethod(ObjCMethodDecl *method) {
+ void addClassMethod(ObjCMethodDecl *method) {
// FIXME: Context should be set correctly before we get here.
method->setLexicalDeclContext(this);
- addDecl(method);
+ addDecl(method);
}
-
+
void addPropertyImplementation(ObjCPropertyImplDecl *property);
-
+
ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId) const;
ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const;
// Iterator access to properties.
typedef specific_decl_iterator<ObjCPropertyImplDecl> propimpl_iterator;
- propimpl_iterator propimpl_begin() const {
+ propimpl_iterator propimpl_begin() const {
return propimpl_iterator(decls_begin());
}
- propimpl_iterator propimpl_end() const {
+ propimpl_iterator propimpl_end() const {
return propimpl_iterator(decls_end());
}
@@ -901,10 +901,10 @@ public:
}
static bool classof(const ObjCImplDecl *D) { return true; }
};
-
-/// ObjCCategoryImplDecl - An object of this class encapsulates a category
-/// @implementation declaration. If a category class has declaration of a
-/// property, its implementation must be specified in the category's
+
+/// ObjCCategoryImplDecl - An object of this class encapsulates a category
+/// @implementation declaration. If a category class has declaration of a
+/// property, its implementation must be specified in the category's
/// @implementation declaration. Example:
/// @interface I @end
/// @interface I(CATEGORY)
@@ -926,14 +926,14 @@ public:
static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
ObjCInterfaceDecl *classInterface);
-
+
/// getIdentifier - Get the identifier that names the class
/// interface associated with this implementation.
- IdentifierInfo *getIdentifier() const {
- return Id;
+ IdentifierInfo *getIdentifier() const {
+ return Id;
}
void setIdentifier(IdentifierInfo *II) { Id = II; }
-
+
ObjCCategoryDecl *getCategoryClass() const;
/// getNameAsCString - Get the name of identifier for the class
@@ -942,12 +942,12 @@ public:
const char *getNameAsCString() const {
return Id ? Id->getName() : "";
}
-
+
/// @brief Get the name of the class associated with this interface.
std::string getNameAsString() const {
return Id ? Id->getName() : "";
}
-
+
static bool classof(const Decl *D) { return D->getKind() == ObjCCategoryImpl;}
static bool classof(const ObjCCategoryImplDecl *D) { return true; }
};
@@ -961,30 +961,30 @@ public:
/// @end
/// @endcode
///
-/// Typically, instance variables are specified in the class interface,
+/// Typically, instance variables are specified in the class interface,
/// *not* in the implementation. Nevertheless (for legacy reasons), we
/// allow instance variables to be specified in the implementation. When
/// specified, they need to be *identical* to the interface.
///
-class ObjCImplementationDecl : public ObjCImplDecl {
+class ObjCImplementationDecl : public ObjCImplDecl {
/// Implementation Class's super class.
ObjCInterfaceDecl *SuperClass;
-
- ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
+
+ ObjCImplementationDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl)
- : ObjCImplDecl(ObjCImplementation, DC, L, classInterface),
+ : ObjCImplDecl(ObjCImplementation, DC, L, classInterface),
SuperClass(superDecl){}
-public:
- static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+public:
+ static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl);
-
+
/// getIdentifier - Get the identifier that names the class
/// interface associated with this implementation.
- IdentifierInfo *getIdentifier() const {
- return getClassInterface()->getIdentifier();
+ IdentifierInfo *getIdentifier() const {
+ return getClassInterface()->getIdentifier();
}
/// getNameAsCString - Get the name of identifier for the class
@@ -1002,35 +1002,35 @@ public:
const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; }
ObjCInterfaceDecl *getSuperClass() { return SuperClass; }
-
+
void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; }
-
+
typedef specific_decl_iterator<ObjCIvarDecl> ivar_iterator;
- ivar_iterator ivar_begin() const {
- return ivar_iterator(decls_begin());
+ ivar_iterator ivar_begin() const {
+ return ivar_iterator(decls_begin());
}
- ivar_iterator ivar_end() const {
+ ivar_iterator ivar_end() const {
return ivar_iterator(decls_end());
}
- unsigned ivar_size() const {
+ unsigned ivar_size() const {
return std::distance(ivar_begin(), ivar_end());
}
- bool ivar_empty() const {
+ bool ivar_empty() const {
return ivar_begin() == ivar_end();
}
-
+
static bool classof(const Decl *D) {
return D->getKind() == ObjCImplementation;
}
static bool classof(const ObjCImplementationDecl *D) { return true; }
};
-/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
+/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
/// declared as @compatibility_alias alias class.
class ObjCCompatibleAliasDecl : public NamedDecl {
/// Class that this is an alias of.
ObjCInterfaceDecl *AliasedClass;
-
+
ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
ObjCInterfaceDecl* aliasedClass)
: NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {}
@@ -1042,12 +1042,12 @@ public:
const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; }
ObjCInterfaceDecl *getClassInterface() { return AliasedClass; }
void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; }
-
+
static bool classof(const Decl *D) {
return D->getKind() == ObjCCompatibleAlias;
}
static bool classof(const ObjCCompatibleAliasDecl *D) { return true; }
-
+
};
/// ObjCPropertyDecl - Represents one property declaration in an interface.
@@ -1057,13 +1057,13 @@ public:
class ObjCPropertyDecl : public NamedDecl {
public:
enum PropertyAttributeKind {
- OBJC_PR_noattr = 0x00,
- OBJC_PR_readonly = 0x01,
+ OBJC_PR_noattr = 0x00,
+ OBJC_PR_readonly = 0x01,
OBJC_PR_getter = 0x02,
- OBJC_PR_assign = 0x04,
- OBJC_PR_readwrite = 0x08,
+ OBJC_PR_assign = 0x04,
+ OBJC_PR_readwrite = 0x08,
OBJC_PR_retain = 0x10,
- OBJC_PR_copy = 0x20,
+ OBJC_PR_copy = 0x20,
OBJC_PR_nonatomic = 0x40,
OBJC_PR_setter = 0x80
};
@@ -1073,27 +1073,27 @@ public:
private:
QualType DeclType;
unsigned PropertyAttributes : 8;
-
+
// @required/@optional
unsigned PropertyImplementation : 2;
-
+
Selector GetterName; // getter name of NULL if no getter
Selector SetterName; // setter name of NULL if no setter
-
+
ObjCMethodDecl *GetterMethodDecl; // Declaration of getter instance method
ObjCMethodDecl *SetterMethodDecl; // Declaration of setter instance method
ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property
- ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
+ ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
QualType T)
: NamedDecl(ObjCProperty, DC, L, Id), DeclType(T),
PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None),
- GetterName(Selector()),
+ GetterName(Selector()),
SetterName(Selector()),
GetterMethodDecl(0), SetterMethodDecl(0) , PropertyIvarDecl(0) {}
public:
- static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+ static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L,
IdentifierInfo *Id, QualType T,
PropertyControl propControl = None);
QualType getType() const { return DeclType; }
@@ -1102,14 +1102,14 @@ public:
PropertyAttributeKind getPropertyAttributes() const {
return PropertyAttributeKind(PropertyAttributes);
}
- void setPropertyAttributes(PropertyAttributeKind PRVal) {
+ void setPropertyAttributes(PropertyAttributeKind PRVal) {
PropertyAttributes |= PRVal;
}
void makeitReadWriteAttribute(void) {
PropertyAttributes &= ~OBJC_PR_readonly;
PropertyAttributes |= OBJC_PR_readwrite;
- }
+ }
// Helper methods for accessing attributes.
@@ -1131,38 +1131,38 @@ public:
Selector getGetterName() const { return GetterName; }
void setGetterName(Selector Sel) { GetterName = Sel; }
-
+
Selector getSetterName() const { return SetterName; }
void setSetterName(Selector Sel) { SetterName = Sel; }
-
+
ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; }
void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; }
ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; }
void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; }
-
+
// Related to @optional/@required declared in @protocol
void setPropertyImplementation(PropertyControl pc) {
PropertyImplementation = pc;
}
PropertyControl getPropertyImplementation() const {
return PropertyControl(PropertyImplementation);
- }
-
+ }
+
void setPropertyIvarDecl(ObjCIvarDecl *Ivar) {
PropertyIvarDecl = Ivar;
}
ObjCIvarDecl *getPropertyIvarDecl() const {
return PropertyIvarDecl;
}
-
+
static bool classof(const Decl *D) {
return D->getKind() == ObjCProperty;
}
static bool classof(const ObjCPropertyDecl *D) { return true; }
};
-/// ObjCPropertyImplDecl - Represents implementation declaration of a property
+/// ObjCPropertyImplDecl - Represents implementation declaration of a property
/// in a class or category implementation block. For example:
/// @synthesize prop1 = ivar1;
///
@@ -1181,23 +1181,23 @@ private:
ObjCIvarDecl *PropertyIvarDecl;
ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L,
- ObjCPropertyDecl *property,
- Kind PK,
+ ObjCPropertyDecl *property,
+ Kind PK,
ObjCIvarDecl *ivarDecl)
- : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
+ : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc),
PropertyDecl(property), PropertyIvarDecl(ivarDecl) {
assert (PK == Dynamic || PropertyIvarDecl);
}
-
+
public:
static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC,
- SourceLocation atLoc, SourceLocation L,
- ObjCPropertyDecl *property,
- Kind PK,
+ SourceLocation atLoc, SourceLocation L,
+ ObjCPropertyDecl *property,
+ Kind PK,
ObjCIvarDecl *ivarDecl);
- virtual SourceRange getSourceRange() const {
- return SourceRange(AtLoc, getLocation());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtLoc, getLocation());
}
SourceLocation getLocStart() const { return AtLoc; }
void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
@@ -1210,7 +1210,7 @@ public:
Kind getPropertyImplementation() const {
return PropertyIvarDecl ? Synthesize : Dynamic;
}
-
+
ObjCIvarDecl *getPropertyIvarDecl() const {
return PropertyIvarDecl;
}
@@ -1219,7 +1219,7 @@ public:
static bool classof(const Decl *D) {
return D->getKind() == ObjCPropertyImpl;
}
- static bool classof(const ObjCPropertyImplDecl *D) { return true; }
+ static bool classof(const ObjCPropertyImplDecl *D) { return true; }
};
} // end namespace clang
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 24524dff38..0232d9382e 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -53,7 +53,7 @@ class TemplateParameterList {
SourceLocation RAngleLoc);
public:
- static TemplateParameterList *Create(ASTContext &C,
+ static TemplateParameterList *Create(ASTContext &C,
SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
Decl **Params,
@@ -115,10 +115,10 @@ class TemplateArgument {
bool CopyArgs;
} Args;
};
-
+
/// \brief Location of the beginning of this template argument.
SourceLocation StartLoc;
-
+
public:
/// \brief The type of template argument we're storing.
enum ArgKind {
@@ -133,21 +133,21 @@ public:
/// The template argument is a value- or type-dependent expression
/// stored in an Expr*.
Expression = 4,
-
+
/// The template argument is actually a parameter pack. Arguments are stored
/// in the Args struct.
Pack = 5
} Kind;
-
+
/// \brief Construct an empty, invalid template argument.
TemplateArgument() : TypeOrValue(0), StartLoc(), Kind(Null) { }
-
+
/// \brief Construct a template type argument.
TemplateArgument(SourceLocation Loc, QualType T) : Kind(Type) {
TypeOrValue = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
StartLoc = Loc;
}
-
+
/// \brief Construct a template argument that refers to a
/// declaration, which is either an external declaration or a
/// template declaration.
@@ -156,7 +156,7 @@ public:
TypeOrValue = reinterpret_cast<uintptr_t>(D);
StartLoc = Loc;
}
-
+
/// \brief Construct an integral constant template argument.
TemplateArgument(SourceLocation Loc, const llvm::APSInt &Value,
QualType Type)
@@ -165,14 +165,14 @@ public:
Integer.Type = Type.getAsOpaquePtr();
StartLoc = Loc;
}
-
- /// \brief Construct a template argument that is an expression.
+
+ /// \brief Construct a template argument that is an expression.
///
/// This form of template argument only occurs in template argument
/// lists used for dependent types and for expression; it will not
/// occur in a non-dependent, canonical template argument list.
TemplateArgument(Expr *E);
-
+
/// \brief Copy constructor for a template argument.
TemplateArgument(const TemplateArgument &Other) : Kind(Other.Kind) {
if (Kind == Integral) {
@@ -188,27 +188,27 @@ public:
TypeOrValue = Other.TypeOrValue;
StartLoc = Other.StartLoc;
}
-
+
TemplateArgument& operator=(const TemplateArgument& Other) {
// FIXME: Does not provide the strong guarantee for exception
// safety.
using llvm::APSInt;
-
+
// FIXME: Handle Packs
assert(Kind != Pack && "FIXME: Handle packs");
assert(Other.Kind != Pack && "FIXME: Handle packs");
-
+
if (Kind == Other.Kind && Kind == Integral) {
// Copy integral values.
*this->getAsIntegral() = *Other.getAsIntegral();
- Integer.Type = Other.Integer.Type;
+ Integer.Type = Other.Integer.Type;
} else {
// Destroy the current integral value, if that's what we're holding.
if (Kind == Integral)
getAsIntegral()->~APSInt();
-
+
Kind = Other.Kind;
-
+
if (Other.Kind == Integral) {
new (Integer.Value) llvm::APSInt(*Other.getAsIntegral());
Integer.Type = Other.Integer.Type;
@@ -216,127 +216,127 @@ public:
TypeOrValue = Other.TypeOrValue;
}
StartLoc = Other.StartLoc;
-
+
return *this;
}
-
+
~TemplateArgument() {
using llvm::APSInt;
-
+
if (Kind == Integral)
getAsIntegral()->~APSInt();
else if (Kind == Pack && Args.CopyArgs)
delete[] Args.Args;
}
-
+
/// \brief Return the kind of stored template argument.
ArgKind getKind() const { return Kind; }
-
+
/// \brief Determine whether this template argument has no value.
bool isNull() const { return Kind == Null; }
-
+
/// \brief Retrieve the template argument as a type.
QualType getAsType() const {
if (Kind != Type)
return QualType();
-
+
return QualType::getFromOpaquePtr(reinterpret_cast<void*>(TypeOrValue));
}
-
+
/// \brief Retrieve the template argument as a declaration.
Decl *getAsDecl() const {
if (Kind != Declaration)
return 0;
return reinterpret_cast<Decl *>(TypeOrValue);
}
-
+
/// \brief Retrieve the template argument as an integral value.
llvm::APSInt *getAsIntegral() {
if (Kind != Integral)
return 0;
return reinterpret_cast<llvm::APSInt*>(&Integer.Value[0]);
}
-
+
const llvm::APSInt *getAsIntegral() const {
return const_cast<TemplateArgument*>(this)->getAsIntegral();
}
-
+
/// \brief Retrieve the type of the integral value.
QualType getIntegralType() const {
if (Kind != Integral)
return QualType();
-
+
return QualType::getFromOpaquePtr(Integer.Type);
}
-
+
void setIntegralType(QualType T) {
- assert(Kind == Integral &&
+ assert(Kind == Integral &&
"Cannot set the integral type of a non-integral template argument");
Integer.Type = T.getAsOpaquePtr();
};
-
+
/// \brief Retrieve the template argument as an expression.
Expr *getAsExpr() const {
if (Kind != Expression)
return 0;
-
+
return reinterpret_cast<Expr *>(TypeOrValue);
}
-
+
/// \brief Iterator that traverses the elements of a template argument pack.
typedef const TemplateArgument * pack_iterator;
-
- /// \brief Iterator referencing the first argument of a template argument
+
+ /// \brief Iterator referencing the first argument of a template argument
/// pack.
pack_iterator pack_begin() const {
assert(Kind == Pack);
return Args.Args;
}
-
+
/// \brief Iterator referencing one past the last argument of a template
/// argument pack.
pack_iterator pack_end() const {
assert(Kind == Pack);
return Args.Args + Args.NumArgs;
}
-
+
/// \brief The number of template arguments in the given template argument
/// pack.
unsigned pack_size() const {
assert(Kind == Pack);
return Args.NumArgs;
}
-
+
/// \brief Retrieve the location where the template argument starts.
SourceLocation getLocation() const { return StartLoc; }
-
+
/// \brief Construct a template argument pack.
void setArgumentPack(TemplateArgument *Args, unsigned NumArgs, bool CopyArgs);
-
+
/// \brief Used to insert TemplateArguments into FoldingSets.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context) const {
ID.AddInteger(Kind);
switch (Kind) {
case Null:
break;
-
+
case Type:
getAsType().Profile(ID);
break;
-
+
case Declaration:
ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : 0);
break;
-
+
case Integral:
getAsIntegral()->Profile(ID);
getIntegralType().Profile(ID);
break;
-
+
case Expression:
getAsExpr()->Profile(ID, Context, true);
break;
-
+
case Pack:
ID.AddInteger(Args.NumArgs);
for (unsigned I = 0; I != Args.NumArgs; ++I)
@@ -350,47 +350,47 @@ class TemplateArgumentListBuilder {
TemplateArgument *StructuredArgs;
unsigned MaxStructuredArgs;
unsigned NumStructuredArgs;
-
+
TemplateArgument *FlatArgs;
unsigned MaxFlatArgs;
unsigned NumFlatArgs;
-
+
bool AddingToPack;
unsigned PackBeginIndex;
-
+
public:
TemplateArgumentListBuilder(const TemplateParameterList *Parameters,
unsigned NumTemplateArgs)
- : StructuredArgs(0), MaxStructuredArgs(Parameters->size()),
- NumStructuredArgs(0), FlatArgs(0),
+ : StructuredArgs(0), MaxStructuredArgs(Parameters->size()),
+ NumStructuredArgs(0), FlatArgs(0),
MaxFlatArgs(std::max(MaxStructuredArgs, NumTemplateArgs)), NumFlatArgs(0),
AddingToPack(false), PackBeginIndex(0) { }
-
+
void Append(const TemplateArgument& Arg);
void BeginPack();
void EndPack();
-
+
void ReleaseArgs();
-
- unsigned flatSize() const {
+
+ unsigned flatSize() const {
return NumFlatArgs;
}
const TemplateArgument *getFlatArguments() const {
return FlatArgs;
}
-
+
unsigned structuredSize() const {
// If we don't have any structured args, just reuse the flat size.
if (!StructuredArgs)
return flatSize();
-
+
return NumStructuredArgs;
}
const TemplateArgument *getStructuredArguments() const {
// If we don't have any structured args, just reuse the flat args.
if (!StructuredArgs)
return getFlatArguments();
-
+
return StructuredArgs;
}
};
@@ -406,44 +406,44 @@ class TemplateArgumentList {
/// The integer value will be non-zero to indicate that this
/// template argument list does not own the pointer.
llvm::PointerIntPair<const TemplateArgument *, 1> FlatArguments;
-
+
/// \brief The number of template arguments in this template
/// argument list.
unsigned NumFlatArguments;
-
+
llvm::PointerIntPair<const TemplateArgument *, 1> StructuredArguments;
unsigned NumStructuredArguments;
-
+
public:
TemplateArgumentList(ASTContext &Context,
TemplateArgumentListBuilder &Builder,
bool TakeArgs);
-
+
~TemplateArgumentList();
-
+
/// \brief Retrieve the template argument at a given index.
- const TemplateArgument &get(unsigned Idx) const {
+ const TemplateArgument &get(unsigned Idx) const {
assert(Idx < NumFlatArguments && "Invalid template argument index");
return getFlatArgumentList()[Idx];
}
-
+
/// \brief Retrieve the template argument at a given index.
const TemplateArgument &operator[](unsigned Idx) const { return get(Idx); }
-
+
/// \brief Retrieve the number of template arguments in this
/// template argument list.
unsigned size() const { return NumFlatArguments; }
-
+
/// \brief Retrieve the number of template arguments in the
/// flattened template argument list.
unsigned flat_size() const { return NumFlatArguments; }
-
+
/// \brief Retrieve the flattened template argument list.
- const TemplateArgument *getFlatArgumentList() const {
+ const TemplateArgument *getFlatArgumentList() const {
return FlatArguments.getPointer();
}
};
-
+
//===----------------------------------------------------------------------===//
// Kinds of Templates
//===----------------------------------------------------------------------===//
@@ -457,15 +457,13 @@ protected:
// This is probably never used.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName Name)
- : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(0)
- { }
+ : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(0) { }
// Construct a template decl with the given name and parameters.
// Used when there is not templated element (tt-params, alias?).
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName Name, TemplateParameterList *Params)
- : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(Params)
- { }
+ : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(Params) { }
// Construct a template decl with name, parameters, and templated element.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
@@ -497,26 +495,26 @@ protected:
NamedDecl *TemplatedDecl;
TemplateParameterList* TemplateParams;
};
-
-/// \brief Provides information about a function template specialization,
+
+/// \brief Provides information about a function template specialization,
/// which is a FunctionDecl that has been explicitly specialization or
/// instantiated from a function template.
class FunctionTemplateSpecializationInfo : public llvm::FoldingSetNode {
public:
- /// \brief The function template specialization that this structure
+ /// \brief The function template specialization that this structure
/// describes.
FunctionDecl *Function;
-
- /// \brief The function template from which this function template
+
+ /// \brief The function template from which this function template
/// specialization was generated.
///
/// The two bits are contain the top 4 values of TemplateSpecializationKind.
llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
-
+
/// \brief The template arguments used to produce the function template
/// specialization from the function template.
const TemplateArgumentList *TemplateArguments;
-
+
/// \brief Retrieve the template from which this function was specialized.
FunctionTemplateDecl *getTemplate() const { return Template.getPointer(); }
@@ -527,61 +525,61 @@ public:
/// \brief Set the template specialization kind.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
- assert(TSK != TSK_Undeclared &&
+ assert(TSK != TSK_Undeclared &&
"Cannot encode TSK_Undeclared for a function template specialization");
Template.setInt(TSK - 1);
}
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, TemplateArguments->getFlatArgumentList(),
+ Profile(ID, TemplateArguments->getFlatArgumentList(),
TemplateArguments->flat_size(),
- Function->getASTContext());
+ Function->getASTContext());
}
-
- static void
- Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
+
+ static void
+ Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs, ASTContext &Context) {
ID.AddInteger(NumTemplateArgs);
for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg)
TemplateArgs[Arg].Profile(ID, Context);
- }
+ }
};
-
+
/// Declaration of a template function.
-class FunctionTemplateDecl : public TemplateDecl {
+class FunctionTemplateDecl : public TemplateDecl {
protected:
/// \brief Data that is common to all of the declarations of a given
/// function template.
struct Common {
Common() : InstantiatedFromMember(0) { }
-
+
/// \brief The function template specializations for this function
/// template, including explicit specializations and instantiations.
llvm::FoldingSet<FunctionTemplateSpecializationInfo> Specializations;
-
+
/// \brief The member function template from which this was most
/// directly instantiated (or null).
- FunctionTemplateDecl *InstantiatedFromMember;
+ FunctionTemplateDecl *InstantiatedFromMember;
};
-
+
/// \brief A pointer to the previous declaration (if this is a redeclaration)
/// or to the data that is common to all declarations of this function
/// template.
llvm::PointerUnion<Common*, FunctionTemplateDecl*> CommonOrPrev;
-
- /// \brief Retrieves the "common" pointer shared by all
+
+ /// \brief Retrieves the "common" pointer shared by all
/// (re-)declarations of the same function template. Calling this routine
/// may implicitly allocate memory for the common pointer.
Common *getCommonPtr();
-
+
FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
TemplateParameterList *Params, NamedDecl *Decl)
: TemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl),
CommonOrPrev((Common*)0) { }
-
+
public:
void Destroy(ASTContext &C);
-
+
/// Get the underlying function declaration of the template.
FunctionDecl *getTemplatedDecl() const {
return static_cast<FunctionDecl*>(TemplatedDecl);
@@ -592,7 +590,7 @@ public:
llvm::FoldingSet<FunctionTemplateSpecializationInfo> &getSpecializations() {
return getCommonPtr()->Specializations;
}
-
+
/// \brief Retrieve the previous declaration of this function template, or
/// NULL if no such declaration exists.
const FunctionTemplateDecl *getPreviousDeclaration() const {
@@ -604,16 +602,16 @@ public:
FunctionTemplateDecl *getPreviousDeclaration() {
return CommonOrPrev.dyn_cast<FunctionTemplateDecl*>();
}
-
+
/// \brief Set the previous declaration of this function template.
void setPreviousDeclaration(FunctionTemplateDecl *Prev) {
if (Prev)
CommonOrPrev = Prev;
}
-
+
virtual FunctionTemplateDecl *getCanonicalDecl();
-
- /// \brief Retrieve the member function template that this function template
+
+ /// \brief Retrieve the member function template that this function template
/// was instantiated from.
///
/// This routine will return non-NULL for member function templates of
@@ -627,23 +625,23 @@ public:
/// \endcode
///
/// X<int>::A<float> is a CXXMethodDecl (whose parent is X<int>, a
- /// ClassTemplateSpecializationDecl) for which getPrimaryTemplate() will
+ /// ClassTemplateSpecializationDecl) for which getPrimaryTemplate() will
/// return X<int>::f, a FunctionTemplateDecl (whose parent is again
/// X<int>) for which getInstantiatedFromMemberTemplate() will return
- /// X<T>::f, a FunctionTemplateDecl (whose parent is X<T>, a
+ /// X<T>::f, a FunctionTemplateDecl (whose parent is X<T>, a
/// ClassTemplateDecl).
///
- /// \returns NULL if this is not an instantiation of a member function
+ /// \returns NULL if this is not an instantiation of a member function
/// template.
FunctionTemplateDecl *getInstantiatedFromMemberTemplate() {
return getCommonPtr()->InstantiatedFromMember;
}
-
+
void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *FTD) {
assert(!getCommonPtr()->InstantiatedFromMember);
getCommonPtr()->InstantiatedFromMember = FTD;
}
-
+
/// Create a template function node.
static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
@@ -669,8 +667,7 @@ public:
/// the occurrence within the parameter list.
/// This class is inheritedly privately by different kinds of template
/// parameters and is not part of the Decl hierarchy. Just a facility.
-class TemplateParmPosition
-{
+class TemplateParmPosition {
protected:
// FIXME: This should probably never be called, but it's here as
TemplateParmPosition()
@@ -692,7 +689,7 @@ public:
/// Get the position of the template parameter within its parameter list.
unsigned getPosition() const { return Position; }
-
+
/// Get the index of the template parameter within its parameter list.
unsigned getIndex() const { return Position; }
};
@@ -721,10 +718,10 @@ class TemplateTypeParmDecl : public TypeDecl {
/// \brief The default template argument, if any.
QualType DefaultArgument;
- TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
+ TemplateTypeParmDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
bool Typename, QualType Type, bool ParameterPack)
: TypeDecl(TemplateTypeParm, DC, L, Id), Typename(Typename),
- InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() {
+ InheritedDefault(false), ParameterPack(ParameterPack), DefaultArgument() {
TypeForDecl = Type.getTypePtr();
}
@@ -787,7 +784,7 @@ class NonTypeTemplateParmDecl
unsigned P, IdentifierInfo *Id, QualType T,
DeclaratorInfo *DInfo)
: VarDecl(NonTypeTemplateParm, DC, L, Id, T, DInfo, VarDecl::None),
- TemplateParmPosition(D, P), DefaultArgument(0)
+ TemplateParmPosition(D, P), DefaultArgument(0)
{ }
public:
@@ -798,7 +795,7 @@ public:
using TemplateParmPosition::getDepth;
using TemplateParmPosition::getPosition;
using TemplateParmPosition::getIndex;
-
+
/// \brief Determine whether this template parameter has a default
/// argument.
bool hasDefaultArgument() const { return DefaultArgument; }
@@ -850,7 +847,7 @@ public:
using TemplateParmPosition::getDepth;
using TemplateParmPosition::getPosition;
using TemplateParmPosition::getIndex;
-
+
/// \brief Determine whether this template parameter has a default
/// argument.
bool hasDefaultArgument() const { return DefaultArgument; }
@@ -882,26 +879,26 @@ public:
///
/// \code
/// template<typename T> class array;
-///
-/// template<>
+///
+/// template<>
/// class array<bool> { }; // class template specialization array<bool>
/// \endcode
-class ClassTemplateSpecializationDecl
+class ClassTemplateSpecializationDecl
: public CXXRecordDecl, public llvm::FoldingSetNode {
-
- /// \brief Structure that stores information about a class template
+
+ /// \brief Structure that stores information about a class template
/// specialization that was instantiated from a class template partial
/// specialization.
struct SpecializedPartialSpecialization {
/// \brief The class template partial specialization from which this
/// class template specialization was instantiated.
ClassTemplatePartialSpecializationDecl *PartialSpecialization;
-
+
/// \brief The template argument list deduced for the class template
/// partial specialization itself.
TemplateArgumentList *TemplateArgs;
};
-
+
/// \brief The template that this specialization specializes
llvm::PointerUnion<ClassTemplateDecl *, SpecializedPartialSpecialization *>
SpecializedTemplate;
@@ -919,7 +916,7 @@ protected:
ClassTemplateDecl *SpecializedTemplate,
TemplateArgumentListBuilder &Builder,
ClassTemplateSpecializationDecl *PrevDecl);
-
+
public:
static ClassTemplateSpecializationDecl *
Create(ASTContext &Context, DeclContext *DC, SourceLocation L,
@@ -932,9 +929,9 @@ public:
/// \brief Retrieve the template that this specialization specializes.
ClassTemplateDecl *getSpecializedTemplate() const;
- /// \brief Retrieve the template arguments of the class template
+ /// \brief Retrieve the template arguments of the class template
/// specialization.
- const TemplateArgumentList &getTemplateArgs() const {
+ const TemplateArgumentList &getTemplateArgs() const {
return TemplateArgs;
}
@@ -952,22 +949,22 @@ public:
/// a template (rather than an explicit specialization), return the
/// class template or class template partial specialization from which it
/// was instantiated.
- llvm::PointerUnion<ClassTemplateDecl *,
+ llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
getInstantiatedFrom() const {
if (getSpecializationKind() != TSK_ImplicitInstantiation &&
getSpecializationKind() != TSK_ExplicitInstantiationDefinition &&
getSpecializationKind() != TSK_ExplicitInstantiationDeclaration)
return (ClassTemplateDecl*)0;
-
- if (SpecializedPartialSpecialization *PartialSpec
+
+ if (SpecializedPartialSpecialization *PartialSpec
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
return PartialSpec->PartialSpecialization;
-
+
return const_cast<ClassTemplateDecl*>(
SpecializedTemplate.get<ClassTemplateDecl*>());
}
-
+
/// \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
@@ -980,25 +977,25 @@ public:
/// deduced template arguments for the class template partial specialization
/// itself.
const TemplateArgumentList &getTemplateInstantiationArgs() const {
- if (SpecializedPartialSpecialization *PartialSpec
+ if (SpecializedPartialSpecialization *PartialSpec
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
return *PartialSpec->TemplateArgs;
-
+
return getTemplateArgs();
}
-
+
/// \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,
TemplateArgumentList *TemplateArgs) {
- SpecializedPartialSpecialization *PS
+ SpecializedPartialSpecialization *PS
= new (getASTContext()) SpecializedPartialSpecialization();
PS->PartialSpecialization = PartialSpec;
PS->TemplateArgs = TemplateArgs;
SpecializedTemplate = PS;
}
-
+
/// \brief Sets the type of this specialization as it was written by
/// the user. This will be a class template specialization type.
void setTypeAsWritten(QualType T) {
@@ -1010,15 +1007,15 @@ public:
getASTContext());
}
- static void
- Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
+ static void
+ Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs, ASTContext &Context) {
ID.AddInteger(NumTemplateArgs);
for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg)
TemplateArgs[Arg].Profile(ID, Context);
}
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == ClassTemplateSpecialization ||
D->getKind() == ClassTemplatePartialSpecialization;
}
@@ -1032,10 +1029,9 @@ public:
}
};
-class ClassTemplatePartialSpecializationDecl
- : public ClassTemplateSpecializationDecl
-{
- /// \brief The list of template parameters
+class ClassTemplatePartialSpecializationDecl
+ : public ClassTemplateSpecializationDecl {
+ /// \brief The list of template parameters
TemplateParameterList* TemplateParams;
ClassTemplatePartialSpecializationDecl(ASTContext &Context,
@@ -1044,7 +1040,7 @@ class ClassTemplatePartialSpecializationDecl
ClassTemplateDecl *SpecializedTemplate,
TemplateArgumentListBuilder &Builder,
ClassTemplatePartialSpecializationDecl *PrevDecl)
- : ClassTemplateSpecializationDecl(Context,
+ : ClassTemplateSpecializationDecl(Context,
ClassTemplatePartialSpecialization,
DC, L, SpecializedTemplate, Builder,
PrevDecl),
@@ -1065,7 +1061,7 @@ public:
// FIXME: Add Profile support!
- static bool classof(const Decl *D) {
+ static bool classof(const Decl *D) {
return D->getKind() == ClassTemplatePartialSpecialization;
}
@@ -1088,7 +1084,7 @@ protected:
/// \brief The class template partial specializations for this class
/// template.
- llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>
+ llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>
PartialSpecializations;
/// \brief The injected-class-name type for this class template.
@@ -1104,11 +1100,11 @@ protected:
/// \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;
-
+
ClassTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
TemplateParameterList *Params, NamedDecl *Decl,
ClassTemplateDecl *PrevDecl, Common *CommonPtr)
@@ -1127,7 +1123,7 @@ public:
ClassTemplateDecl *getPreviousDeclaration() const {
return PreviousDeclaration;
}
-
+
virtual ClassTemplateDecl *getCanonicalDecl();
/// Create a class template node.
@@ -1159,7 +1155,7 @@ public:
/// \returns the class template partial specialization that exactly matches
/// the type \p T, or NULL if no such partial specialization exists.
ClassTemplatePartialSpecializationDecl *findPartialSpecialization(QualType T);
-
+
/// \brief Retrieve the type of the injected-class-name for this
/// class template.
///
@@ -1215,7 +1211,7 @@ public:
};
/// Implementation of inline functions that require the template declarations
-inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD)
+inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD)
: Function(FTD) { }
} /* end of namespace clang */
diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h
index 3d571b1ac0..9850e8fff0 100644
--- a/include/clang/AST/DeclarationName.h
+++ b/include/clang/AST/DeclarationName.h
@@ -101,7 +101,7 @@ private:
/// CXXSpecialName, returns a pointer to it. Otherwise, returns
/// a NULL pointer.
CXXSpecialName *getAsCXXSpecialName() const {
- if (getNameKind() >= CXXConstructorName &&
+ if (getNameKind() >= CXXConstructorName &&
getNameKind() <= CXXConversionFunctionName)
return reinterpret_cast<CXXSpecialName *>(Ptr & ~PtrMask);
return 0;
@@ -116,16 +116,16 @@ private:
// Construct a declaration name from the name of a C++ constructor,
// destructor, or conversion function.
- DeclarationName(CXXSpecialName *Name)
- : Ptr(reinterpret_cast<uintptr_t>(Name)) {
+ DeclarationName(CXXSpecialName *Name)
+ : Ptr(reinterpret_cast<uintptr_t>(Name)) {
assert((Ptr & PtrMask) == 0 && "Improperly aligned CXXSpecialName");
Ptr |= StoredDeclarationNameExtra;
}
// Construct a declaration name from the name of a C++ overloaded
// operator.
- DeclarationName(CXXOperatorIdName *Name)
- : Ptr(reinterpret_cast<uintptr_t>(Name)) {
+ DeclarationName(CXXOperatorIdName *Name)
+ : Ptr(reinterpret_cast<uintptr_t>(Name)) {
assert((Ptr & PtrMask) == 0 && "Improperly aligned CXXOperatorId");
Ptr |= StoredDeclarationNameExtra;
}
@@ -145,8 +145,8 @@ public:
DeclarationName() : Ptr(0) { }
// Construct a declaration name from an IdentifierInfo *.
- DeclarationName(const IdentifierInfo *II)
- : Ptr(reinterpret_cast<uintptr_t>(II)) {
+ DeclarationName(const IdentifierInfo *II)
+ : Ptr(reinterpret_cast<uintptr_t>(II)) {
assert((Ptr & PtrMask) == 0 && "Improperly aligned IdentifierInfo");
}
@@ -158,8 +158,8 @@ public:
// operator bool() - Evaluates true when this declaration name is
// non-empty.
- operator bool() const {
- return ((Ptr & PtrMask) != 0) ||
+ operator bool() const {
+ return ((Ptr & PtrMask) != 0) ||
(reinterpret_cast<IdentifierInfo *>(Ptr & ~PtrMask));
}
@@ -171,10 +171,10 @@ public:
bool isObjCOneArgSelector() const {
return getStoredNameKind() == StoredObjCOneArgSelector;
}
-
+
/// getNameKind - Determine what kind of name this is.
NameKind getNameKind() const;
-
+
/// getName - Retrieve the human-readable string for this name.
std::string getAsString() const;
@@ -182,7 +182,7 @@ public:
/// getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in
/// this declaration name, or NULL if this declaration name isn't a
/// simple identifier.
- IdentifierInfo *getAsIdentifierInfo() const {
+ IdentifierInfo *getAsIdentifierInfo() const {
if (isIdentifier())
return reinterpret_cast<IdentifierInfo *>(Ptr);
return 0;
@@ -201,7 +201,7 @@ public:
N.Ptr = P;
return N;
}
-
+
/// getCXXNameType - If this name is one of the C++ names (of a
/// constructor, destructor, or conversion function), return the
/// type associated with that name.
@@ -310,13 +310,13 @@ public:
/// getCXXSpecialName - Returns a declaration name for special kind
/// of C++ name, e.g., for a constructor, destructor, or conversion
/// function.
- DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind,
+ DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind,
CanQualType Ty);
/// getCXXOperatorName - Get the name of the overloadable C++
/// operator corresponding to Op.
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op);
-};
+};
/// Insertion operator for diagnostics. This allows sending DeclarationName's
/// into a diagnostic with <<.
@@ -326,8 +326,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
Diagnostic::ak_declarationname);
return DB;
}
-
-
+
+
} // end namespace clang
namespace llvm {
@@ -345,7 +345,7 @@ struct DenseMapInfo<clang::DeclarationName> {
static unsigned getHashValue(clang::DeclarationName);
- static inline bool
+ static inline bool
isEqual(clang::DeclarationName LHS, clang::DeclarationName RHS) {
return LHS == RHS;
}
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 9c376c50a3..604765f66d 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -42,20 +42,20 @@ class Expr : public Stmt {
QualType TR;
protected:
- /// TypeDependent - Whether this expression is type-dependent
+ /// TypeDependent - Whether this expression is type-dependent
/// (C++ [temp.dep.expr]).
bool TypeDependent : 1;
- /// ValueDependent - Whether this expression is value-dependent
+ /// ValueDependent - Whether this expression is value-dependent
/// (C++ [temp.dep.constexpr]).
bool ValueDependent : 1;
// FIXME: Eventually, this constructor should go away and we should
// require every subclass to provide type/value-dependence
// information.
- Expr(StmtClass SC, QualType T)
+ Expr(StmtClass SC, QualType T)
: Stmt(SC), TypeDependent(false), ValueDependent(false) {
- setType(T);
+ setType(T);
}
Expr(StmtClass SC, QualType T, bool TD, bool VD)
@@ -66,7 +66,7 @@ protected:
/// \brief Construct an empty expression.
explicit Expr(StmtClass SC, EmptyShell) : Stmt(SC) { }
-public:
+public:
/// \brief Increases the reference count for this expression.
///
/// Invoke the Retain() operation when this expression
@@ -75,9 +75,9 @@ public:
Stmt::Retain();
return this;
}
-
+
QualType getType() const { return TR; }
- void setType(QualType t) {
+ void setType(QualType t) {
// In C++, the type of an expression is always adjusted so that it
// will not have reference type an expression will never have
// reference type (C++ [expr]p6). Use
@@ -85,16 +85,16 @@ public:
// type. Additionally, inspect Expr::isLvalue to determine whether
// an expression that is adjusted in this manner should be
// considered an lvalue.
- assert((TR.isNull() || !TR->isReferenceType()) &&
+ assert((TR.isNull() || !TR->isReferenceType()) &&
"Expressions can't have reference type");
- TR = t;
+ TR = t;
}
/// isValueDependent - Determines whether this expression is
/// value-dependent (C++ [temp.dep.constexpr]). For example, the
/// array bound of "Chars" in the following example is
- /// value-dependent.
+ /// value-dependent.
/// @code
/// template<int Size, char (&Chars)[Size]> struct meta_string;
/// @endcode
@@ -109,7 +109,7 @@ public:
/// example, the expressions "x" and "x + y" are type-dependent in
/// the following code, but "y" is not type-dependent:
/// @code
- /// template<typename T>
+ /// template<typename T>
/// void add(T x, int y) {
/// x + y;
/// }
@@ -127,14 +127,14 @@ public:
/// getExprLoc - Return the preferred location for the arrow when diagnosing
/// a problem with a generic expression.
virtual SourceLocation getExprLoc() const { return getLocStart(); }
-
+
/// isUnusedResultAWarning - Return true if this immediate expression should
/// be warned about if the result is unused. If so, fill in Loc and Ranges
/// with location to warn on and the source range[s] to report with the
/// warning.
bool isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
SourceRange &R2) const;
-
+
/// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or
/// incomplete type other than void. Nonarray expressions that can be lvalues:
/// - name, where name must be a variable
@@ -159,10 +159,10 @@ public:
// 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,
+ /// and if it is a structure or union, does not have any member (including,
/// recursively, any member or element of all contained aggregates or unions)
/// with a const-qualified type.
///
@@ -186,7 +186,7 @@ public:
};
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx,
SourceLocation *Loc = 0) const;
-
+
/// \brief If this expression refers to a bit-field, retrieve the
/// declaration of that bit-field.
FieldDecl *getBitField();
@@ -194,7 +194,7 @@ public:
const FieldDecl *getBitField() const {
return const_cast<Expr*>(this)->getBitField();
}
-
+
/// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location
@@ -209,16 +209,16 @@ public:
/// isConstantInitializer - Returns true if this expression is a constant
/// initializer, which can be emitted at compile-time.
bool isConstantInitializer(ASTContext &Ctx) const;
-
+
/// EvalResult is a struct with detailed info about an evaluated expression.
struct EvalResult {
/// Val - This is the value the expression can be folded to.
APValue Val;
-
+
/// HasSideEffects - Whether the evaluated expression has side effects.
/// For example, (f() && 0) can be folded, but it still has side effects.
bool HasSideEffects;
-
+
/// Diag - If the expression is unfoldable, then Diag contains a note
/// diagnostic indicating why it's not foldable. DiagLoc indicates a caret
/// position for the error, and DiagExpr is the expression that caused
@@ -230,7 +230,7 @@ public:
unsigned Diag;
const Expr *DiagExpr;
SourceLocation DiagLoc;
-
+
EvalResult() : HasSideEffects(false), Diag(0), DiagExpr(0) {}
};
@@ -257,11 +257,11 @@ public:
bool isNullPointerConstant(ASTContext &Ctx) const;
/// isOBJCGCCandidate - Return true if this expression may be used in a read/
- /// write barrier.
+ /// write barrier.
bool isOBJCGCCandidate(ASTContext &Ctx) const;
-
+
/// IgnoreParens - Ignore parentheses. If this Expr is a ParenExpr, return
- /// its subexpression. If that subexpression is also a ParenExpr,
+ /// its subexpression. If that subexpression is also a ParenExpr,
/// then this method recursively returns its subexpression, and so forth.
/// Otherwise, the method returns the current Expr.
Expr* IgnoreParens();
@@ -269,12 +269,12 @@ public:
/// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr
/// or CastExprs, returning their operand.
Expr *IgnoreParenCasts();
-
+
/// IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the
/// value (including ptr->int casts of the same size). Strip off any
/// ParenExpr or CastExprs, returning their operand.
Expr *IgnoreParenNoopCasts(ASTContext &Ctx);
-
+
const Expr* IgnoreParens() const {
return const_cast<Expr*>(this)->IgnoreParens();
}
@@ -284,18 +284,18 @@ public:
const Expr *IgnoreParenNoopCasts(ASTContext &Ctx) const {
return const_cast<Expr*>(this)->IgnoreParenNoopCasts(Ctx);
}
-
+
static bool hasAnyTypeDependentArguments(Expr** Exprs, unsigned NumExprs);
static bool hasAnyValueDependentArguments(Expr** Exprs, unsigned NumExprs);
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstExprConstant &&
- T->getStmtClass() <= lastExprConstant;
+ T->getStmtClass() <= lastExprConstant;
}
static bool classof(const Expr *) { return true; }
};
-
+
//===----------------------------------------------------------------------===//
// Primary Expressions.
//===----------------------------------------------------------------------===//
@@ -303,7 +303,7 @@ public:
/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
/// enum, etc.
class DeclRefExpr : public Expr {
- NamedDecl *D;
+ NamedDecl *D;
SourceLocation Loc;
protected:
@@ -319,14 +319,14 @@ protected:
public:
// FIXME: Eventually, this constructor will go away and all clients
// will have to provide the type- and value-dependent flags.
- DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) :
+ DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l) :
Expr(DeclRefExprClass, t), D(d), Loc(l) {}
- DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) :
+ DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) :
Expr(DeclRefExprClass, t, TD, VD), D(d), Loc(l) {}
-
+
/// \brief Construct an empty declaration reference expression.
- explicit DeclRefExpr(EmptyShell Empty)
+ explicit DeclRefExpr(EmptyShell Empty)
: Expr(DeclRefExprClass, Empty) { }
NamedDecl *getDecl() { return D; }
@@ -336,14 +336,14 @@ public:
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == DeclRefExprClass ||
T->getStmtClass() == CXXConditionDeclExprClass ||
- T->getStmtClass() == QualifiedDeclRefExprClass;
+ T->getStmtClass() == QualifiedDeclRefExprClass;
}
static bool classof(const DeclRefExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -357,16 +357,16 @@ public:
Function,
PrettyFunction
};
-
+
private:
SourceLocation Loc;
IdentType Type;
public:
- PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
+ PredefinedExpr(SourceLocation l, QualType type, IdentType IT)
: Expr(PredefinedExprClass, type), Loc(l), Type(IT) {}
-
+
/// \brief Construct an empty predefined expression.
- explicit PredefinedExpr(EmptyShell Empty)
+ explicit PredefinedExpr(EmptyShell Empty)
: Expr(PredefinedExprClass, Empty) { }
IdentType getIdentType() const { return Type; }
@@ -380,11 +380,11 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == PredefinedExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == PredefinedExprClass;
}
static bool classof(const PredefinedExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -394,7 +394,7 @@ class IntegerLiteral : public Expr {
llvm::APInt Value;
SourceLocation Loc;
public:
- // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
+ // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
// or UnsignedLongLongTy
IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l)
: Expr(IntegerLiteralClass, type), Value(V), Loc(l) {
@@ -402,7 +402,7 @@ public:
}
/// \brief Construct an empty integer literal.
- explicit IntegerLiteral(EmptyShell Empty)
+ explicit IntegerLiteral(EmptyShell Empty)
: Expr(IntegerLiteralClass, Empty) { }
const llvm::APInt &getValue() const { return Value; }
@@ -414,11 +414,11 @@ public:
void setValue(const llvm::APInt &Val) { Value = Val; }
void setLocation(SourceLocation Location) { Loc = Location; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == IntegerLiteralClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == IntegerLiteralClass;
}
static bool classof(const IntegerLiteral *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -439,17 +439,17 @@ public:
SourceLocation getLocation() const { return Loc; }
bool isWide() const { return IsWide; }
-
+
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
-
+
unsigned getValue() const { return Value; }
void setLocation(SourceLocation Location) { Loc = Location; }
void setWide(bool W) { IsWide = W; }
void setValue(unsigned Val) { Value = Val; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CharacterLiteralClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CharacterLiteralClass;
}
static bool classof(const CharacterLiteral *) { return true; }
@@ -463,12 +463,12 @@ class FloatingLiteral : public Expr {
bool IsExact : 1;
SourceLocation Loc;
public:
- FloatingLiteral(const llvm::APFloat &V, bool isexact,
+ FloatingLiteral(const llvm::APFloat &V, bool isexact,
QualType Type, SourceLocation L)
- : Expr(FloatingLiteralClass, Type), Value(V), IsExact(isexact), Loc(L) {}
+ : Expr(FloatingLiteralClass, Type), Value(V), IsExact(isexact), Loc(L) {}
/// \brief Construct an empty floating-point literal.
- explicit FloatingLiteral(EmptyShell Empty)
+ explicit FloatingLiteral(EmptyShell Empty)
: Expr(FloatingLiteralClass, Empty), Value(0.0) { }
const llvm::APFloat &getValue() const { return Value; }
@@ -481,7 +481,7 @@ public:
/// double. Note that this may cause loss of precision, but is useful for
/// debugging dumps, etc.
double getValueAsApproximateDouble() const;
-
+
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
@@ -489,14 +489,14 @@ public:
// into a method here that takes the inner-most code decl (a block, function
// or objc method) that the expr lives in. This would allow sema and codegen
// to be consistent for things like sizeof(__func__) etc.
-
+
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == FloatingLiteralClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == FloatingLiteralClass;
}
static bool classof(const FloatingLiteral *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -512,9 +512,9 @@ class ImaginaryLiteral : public Expr {
public:
ImaginaryLiteral(Expr *val, QualType Ty)
: Expr(ImaginaryLiteralClass, Ty), Val(val) {}
-
+
/// \brief Build an empty imaginary literal.
- explicit ImaginaryLiteral(EmptyShell Empty)
+ explicit ImaginaryLiteral(EmptyShell Empty)
: Expr(ImaginaryLiteralClass, Empty) { }
const Expr *getSubExpr() const { return cast<Expr>(Val); }
@@ -522,11 +522,11 @@ public:
void setSubExpr(Expr *E) { Val = E; }
virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ImaginaryLiteralClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ImaginaryLiteralClass;
}
static bool classof(const ImaginaryLiteral *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -556,7 +556,7 @@ class StringLiteral : public Expr {
SourceLocation TokLocs[1];
StringLiteral(QualType Ty) : Expr(StringLiteralClass, Ty) {}
-
+
protected:
virtual void DoDestroy(ASTContext &C);
@@ -568,7 +568,7 @@ public:
const SourceLocation *Loc, unsigned NumStrs);
/// Simple constructor for string literals made from one token.
- static StringLiteral *Create(ASTContext &C, const char *StrData,
+ static StringLiteral *Create(ASTContext &C, const char *StrData,
unsigned ByteLength,
bool Wide, QualType Ty, SourceLocation Loc) {
return Create(C, StrData, ByteLength, Wide, Ty, &Loc, 1);
@@ -595,12 +595,12 @@ public:
/// getNumConcatenated - Get the number of string literal tokens that were
/// concatenated in translation phase #6 to form this string literal.
unsigned getNumConcatenated() const { return NumConcatenated; }
-
+
SourceLocation getStrTokenLoc(unsigned TokNum) const {
assert(TokNum < NumConcatenated && "Invalid tok number");
return TokLocs[TokNum];
}
- void setStrTokenLoc(unsigned TokNum, SourceLocation L) {
+ void setStrTokenLoc(unsigned TokNum, SourceLocation L) {
assert(TokNum < NumConcatenated && "Invalid tok number");
TokLocs[TokNum] = L;
}
@@ -609,14 +609,14 @@ public:
tokloc_iterator tokloc_begin() const { return TokLocs; }
tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == StringLiteralClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == StringLiteralClass;
}
static bool classof(const StringLiteral *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -630,11 +630,11 @@ class ParenExpr : public Expr {
public:
ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
: Expr(ParenExprClass, val->getType(),
- val->isTypeDependent(), val->isValueDependent()),
+ val->isTypeDependent(), val->isValueDependent()),
L(l), R(r), Val(val) {}
-
+
/// \brief Construct an empty parenthesized expression.
- explicit ParenExpr(EmptyShell Empty)
+ explicit ParenExpr(EmptyShell Empty)
: Expr(ParenExprClass, Empty) { }
const Expr *getSubExpr() const { return cast<Expr>(Val); }
@@ -651,11 +651,11 @@ public:
SourceLocation getRParen() const { return R; }
void setRParen(SourceLocation Loc) { R = Loc; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ParenExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ParenExprClass;
}
static bool classof(const ParenExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -673,7 +673,7 @@ public:
/// later returns zero in the type of the operand.
///
/// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose
-/// subexpression is a compound literal with the various MemberExpr and
+/// subexpression is a compound literal with the various MemberExpr and
/// ArraySubscriptExpr's applied to it.
///
class UnaryOperator : public Expr {
@@ -693,16 +693,16 @@ private:
Stmt *Val;
Opcode Opc;
SourceLocation Loc;
-public:
+public:
UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l)
: Expr(UnaryOperatorClass, type,
input->isTypeDependent() && opc != OffsetOf,
- input->isValueDependent()),
+ input->isValueDependent()),
Val(input), Opc(opc), Loc(l) {}
/// \brief Build an empty unary operator.
- explicit UnaryOperator(EmptyShell Empty)
+ explicit UnaryOperator(EmptyShell Empty)
: Expr(UnaryOperatorClass, Empty), Opc(AddrOf) { }
Opcode getOpcode() const { return Opc; }
@@ -731,8 +731,8 @@ public:
bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
bool isOffsetOfOp() const { return Opc == OffsetOf; }
static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; }
- bool isArithmeticOp() const { return isArithmeticOp(Opc); }
-
+ bool isArithmeticOp() const { return isArithmeticOp(Opc); }
+
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
/// corresponds to, e.g. "sizeof" or "[pre]++"
static const char *getOpcodeStr(Opcode Op);
@@ -752,12 +752,12 @@ public:
return SourceRange(Loc, Val->getLocEnd());
}
virtual SourceLocation getExprLoc() const { return Loc; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == UnaryOperatorClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == UnaryOperatorClass;
}
static bool classof(const UnaryOperator *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -778,7 +778,7 @@ protected:
virtual void DoDestroy(ASTContext& C);
public:
- SizeOfAlignOfExpr(bool issizeof, QualType T,
+ SizeOfAlignOfExpr(bool issizeof, QualType T,
QualType resultType, SourceLocation op,
SourceLocation rp) :
Expr(SizeOfAlignOfExprClass, resultType,
@@ -789,7 +789,7 @@ public:
Argument.Ty = T.getAsOpaquePtr();
}
- SizeOfAlignOfExpr(bool issizeof, Expr *E,
+ SizeOfAlignOfExpr(bool issizeof, Expr *E,
QualType resultType, SourceLocation op,
SourceLocation rp) :
Expr(SizeOfAlignOfExprClass, resultType,
@@ -821,9 +821,9 @@ public:
}
void setArgument(Expr *E) { Argument.Ex = E; isType = false; }
- void setArgument(QualType T) {
- Argument.Ty = T.getAsOpaquePtr();
- isType = true;
+ void setArgument(QualType T) {
+ Argument.Ty = T.getAsOpaquePtr();
+ isType = true;
}
/// Gets the argument type, or the type of the argument expression, whichever
@@ -842,11 +842,11 @@ public:
return SourceRange(OpLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == SizeOfAlignOfExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SizeOfAlignOfExprClass;
}
static bool classof(const SizeOfAlignOfExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -859,7 +859,7 @@ public:
/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
class ArraySubscriptExpr : public Expr {
enum { LHS, RHS, END_EXPR=2 };
- Stmt* SubExprs[END_EXPR];
+ Stmt* SubExprs[END_EXPR];
SourceLocation RBracketLoc;
public:
ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,
@@ -871,7 +871,7 @@ public:
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
}
-
+
/// \brief Create an empty array subscript expression.
explicit ArraySubscriptExpr(EmptyShell Shell)
: Expr(ArraySubscriptExprClass, Shell) { }
@@ -892,37 +892,37 @@ public:
Expr *getRHS() { return cast<Expr>(SubExprs[RHS]); }
const Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
void setRHS(Expr *E) { SubExprs[RHS] = E; }
-
- Expr *getBase() {
+
+ Expr *getBase() {
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getLHS():getRHS());
}
-
- const Expr *getBase() const {
+
+ const Expr *getBase() const {
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getLHS():getRHS());
}
-
- Expr *getIdx() {
+
+ Expr *getIdx() {
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
}
-
+
const Expr *getIdx() const {
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
- }
-
- virtual SourceRange getSourceRange() const {
+ }
+
+ virtual SourceRange getSourceRange() const {
return SourceRange(getLHS()->getLocStart(), RBracketLoc);
}
-
+
SourceLocation getRBracketLoc() const { return RBracketLoc; }
void setRBracketLoc(SourceLocation L) { RBracketLoc = L; }
virtual SourceLocation getExprLoc() const { return getBase()->getExprLoc(); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ArraySubscriptExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ArraySubscriptExprClass;
}
static bool classof(const ArraySubscriptExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -930,9 +930,9 @@ public:
/// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
-/// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
+/// CallExpr itself represents a normal function call, e.g., "f(x, 2)",
/// while its subclasses may represent alternative syntax that (semantically)
-/// results in a function call. For example, CXXOperatorCallExpr is
+/// results in a function call. For example, CXXOperatorCallExpr is
/// a subclass for overloaded operator calls that use operator syntax, e.g.,
/// "str1 + str2" to resolve to a function call.
class CallExpr : public Expr {
@@ -940,23 +940,23 @@ class CallExpr : public Expr {
Stmt **SubExprs;
unsigned NumArgs;
SourceLocation RParenLoc;
-
+
protected:
// This version of the constructor is for derived classes.
CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args, unsigned numargs,
QualType t, SourceLocation rparenloc);
virtual void DoDestroy(ASTContext& C);
-
+
public:
- CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t,
+ CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, QualType t,
SourceLocation rparenloc);
-
+
/// \brief Build an empty call expression.
CallExpr(ASTContext &C, StmtClass SC, EmptyShell Empty);
~CallExpr() {}
-
+
const Expr *getCallee() const { return cast<Expr>(SubExprs[FN]); }
Expr *getCallee() { return cast<Expr>(SubExprs[FN]); }
void setCallee(Expr *F) { SubExprs[FN] = F; }
@@ -967,7 +967,7 @@ public:
/// getNumArgs - Return the number of actual arguments to this call.
///
unsigned getNumArgs() const { return NumArgs; }
-
+
/// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) {
assert(Arg < NumArgs && "Arg access out of range!");
@@ -977,26 +977,26 @@ public:
assert(Arg < NumArgs && "Arg access out of range!");
return cast<Expr>(SubExprs[Arg+ARGS_START]);
}
-
+
/// setArg - Set the specified argument.
void setArg(unsigned Arg, Expr *ArgExpr) {
assert(Arg < NumArgs && "Arg access out of range!");
SubExprs[Arg+ARGS_START] = ArgExpr;
}
-
+
/// setNumArgs - This changes the number of arguments present in this call.
/// Any orphaned expressions are deleted by this, and any new operands are set
/// to null.
void setNumArgs(ASTContext& C, unsigned NumArgs);
-
+
typedef ExprIterator arg_iterator;
typedef ConstExprIterator const_arg_iterator;
-
+
arg_iterator arg_begin() { return SubExprs+ARGS_START; }
arg_iterator arg_end() { return SubExprs+ARGS_START+getNumArgs(); }
const_arg_iterator arg_begin() const { return SubExprs+ARGS_START; }
const_arg_iterator arg_end() const { return SubExprs+ARGS_START+getNumArgs();}
-
+
/// getNumCommas - Return the number of commas that must have been present in
/// this function call.
unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; }
@@ -1004,23 +1004,23 @@ public:
/// isBuiltinCall - If this is a call to a builtin, return the builtin ID. If
/// not, return 0.
unsigned isBuiltinCall(ASTContext &Context) const;
-
- /// getCallReturnType - Get the return type of the call expr. This is not
- /// always the type of the expr itself, if the return type is a reference
+
+ /// getCallReturnType - Get the return type of the call expr. This is not
+ /// always the type of the expr itself, if the return type is a reference
/// type.
QualType getCallReturnType() const;
-
+
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- virtual SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(getCallee()->getLocStart(), RParenLoc);
}
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CallExprClass ||
T->getStmtClass() == CXXOperatorCallExprClass ||
- T->getStmtClass() == CXXMemberCallExprClass;
+ T->getStmtClass() == CXXMemberCallExprClass;
}
static bool classof(const CallExpr *) { return true; }
static bool classof(const CXXOperatorCallExpr *) { return true; }
@@ -1031,75 +1031,75 @@ public:
virtual child_iterator child_end();
};
-/// \brief Represents the qualifier that may precede a C++ name, e.g., the
+/// \brief Represents the qualifier that may precede a C++ name, e.g., the
/// "std::" in "std::sort".
struct NameQualifier {
/// \brief The nested name specifier.
NestedNameSpecifier *NNS;
-
+
/// \brief The source range covered by the nested name specifier.
SourceRange Range;
};
/// \brief Represents an explicit template argument list in C++, e.g.,
-/// the "<int>" in "sort<int>".
+/// the "<int>" in "sort<int>".
struct ExplicitTemplateArgumentList {
/// \brief The source location of the left angle bracket ('<');
SourceLocation LAngleLoc;
-
+
/// \brief The source location of the right angle bracket ('>');
SourceLocation RAngleLoc;
-
+
/// \brief The number of template arguments in TemplateArgs.
- /// The actual template arguments (if any) are stored after the
+ /// The actual template arguments (if any) are stored after the
/// ExplicitTemplateArgumentList structure.
unsigned NumTemplateArgs;
-
+
/// \brief Retrieve the template arguments
- TemplateArgument *getTemplateArgs() {
- return reinterpret_cast<TemplateArgument *> (this + 1);
+ TemplateArgument *getTemplateArgs() {
+ return reinterpret_cast<TemplateArgument *> (this + 1);
}
/// \brief Retrieve the template arguments
const TemplateArgument *getTemplateArgs() const {
- return reinterpret_cast<const TemplateArgument *> (this + 1);
+ return reinterpret_cast<const TemplateArgument *> (this + 1);
}
};
-
+
/// MemberExpr - [C99 6.5.2.3] Structure and Union Members. X->F and X.F.
///
class MemberExpr : public Expr {
/// Base - the expression for the base pointer or structure references. In
/// X.F, this is "X".
Stmt *Base;
-
+
/// MemberDecl - This is the decl being referenced by the field/member name.
/// In X.F, this is the decl referenced by F.
NamedDecl *MemberDecl;
-
+
/// MemberLoc - This is the location of the member name.
SourceLocation MemberLoc;
-
+
/// IsArrow - True if this is "X->F", false if this is "X.F".
bool IsArrow : 1;
-
+
/// \brief True if this member expression used a nested-name-specifier to
- /// refer to the member, e.g., "x->Base::f". When true, a NameQualifier
+ /// refer to the member, e.g., "x->Base::f". When true, a NameQualifier
/// structure is allocated immediately after the MemberExpr.
bool HasQualifier : 1;
-
+
/// \brief True if this member expression specified a template argument list
/// explicitly, e.g., x->f<int>. When true, an ExplicitTemplateArgumentList
/// structure (and its TemplateArguments) are allocated immediately after
/// the MemberExpr or, if the member expression also has a qualifier, after
/// the NameQualifier structure.
bool HasExplicitTemplateArgumentList : 1;
-
+
/// \brief Retrieve the qualifier that preceded the member name, if any.
NameQualifier *getMemberQualifier() {
if (!HasQualifier)
return 0;
-
+
return reinterpret_cast<NameQualifier *> (this + 1);
}
@@ -1107,48 +1107,48 @@ class MemberExpr : public Expr {
const NameQualifier *getMemberQualifier() const {
return const_cast<MemberExpr *>(this)->getMemberQualifier();
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name, if any.
ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() {
if (!HasExplicitTemplateArgumentList)
return 0;
-
+
if (!HasQualifier)
return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
-
+
return reinterpret_cast<ExplicitTemplateArgumentList *>(
getMemberQualifier() + 1);
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name, if any.
const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
return const_cast<MemberExpr *>(this)->getExplicitTemplateArgumentList();
}
-
- MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual,
+
+ MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual,
SourceRange qualrange, NamedDecl *memberdecl, SourceLocation l,
- bool has_explicit, SourceLocation langle,
- const TemplateArgument *targs, unsigned numtargs,
- SourceLocation rangle, QualType ty);
+ bool has_explicit, SourceLocation langle,
+ const TemplateArgument *targs, unsigned numtargs,
+ SourceLocation rangle, QualType ty);
public:
MemberExpr(Expr *base, bool isarrow, NamedDecl *memberdecl, SourceLocation l,
- QualType ty)
- : Expr(MemberExprClass, ty,
+ QualType ty)
+ : Expr(MemberExprClass, ty,
base->isTypeDependent(), base->isValueDependent()),
Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow),
HasQualifier(false), HasExplicitTemplateArgumentList(false) {}
/// \brief Build an empty member reference expression.
- explicit MemberExpr(EmptyShell Empty)
- : Expr(MemberExprClass, Empty), HasQualifier(false),
+ explicit MemberExpr(EmptyShell Empty)
+ : Expr(MemberExprClass, Empty), HasQualifier(false),
HasExplicitTemplateArgumentList(false) { }
- static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow,
+ static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow,
NestedNameSpecifier *qual, SourceRange qualrange,
- NamedDecl *memberdecl,
+ NamedDecl *memberdecl,
SourceLocation l,
bool has_explicit,
SourceLocation langle,
@@ -1156,7 +1156,7 @@ public:
unsigned numtargs,
SourceLocation rangle,
QualType ty);
-
+
void setBase(Expr *E) { Base = E; }
Expr *getBase() const { return cast<Expr>(Base); }
@@ -1167,73 +1167,73 @@ public:
NamedDecl *getMemberDecl() const { return MemberDecl; }
void setMemberDecl(NamedDecl *D) { MemberDecl = D; }
- /// \brief Determines whether this member expression actually had
+ /// \brief Determines whether this member expression actually had
/// a C++ nested-name-specifier prior to the name of the member, e.g.,
/// x->Base::foo.
bool hasQualifier() const { return HasQualifier; }
-
+
/// \brief If the member name was qualified, retrieves the source range of
/// the nested-name-specifier that precedes the member name. Otherwise,
/// returns an empty source range.
- SourceRange getQualifierRange() const {
+ SourceRange getQualifierRange() const {
if (!HasQualifier)
return SourceRange();
-
+
return getMemberQualifier()->Range;
}
-
- /// \brief If the member name was qualified, retrieves the
+
+ /// \brief If the member name was qualified, retrieves the
/// nested-name-specifier that precedes the member name. Otherwise, returns
/// NULL.
- NestedNameSpecifier *getQualifier() const {
+ NestedNameSpecifier *getQualifier() const {
if (!HasQualifier)
return 0;
-
+
return getMemberQualifier()->NNS;
}
/// \brief Determines whether this member expression actually had a C++
/// template argument list explicitly specified, e.g., x.f<int>.
- bool hasExplicitTemplateArgumentList() {
- return HasExplicitTemplateArgumentList;
+ bool hasExplicitTemplateArgumentList() {
+ return HasExplicitTemplateArgumentList;
}
-
- /// \brief Retrieve the location of the left angle bracket following the
+
+ /// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any.
- SourceLocation getLAngleLoc() const {
+ SourceLocation getLAngleLoc() const {
if (!HasExplicitTemplateArgumentList)
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->LAngleLoc;
}
-
+
/// \brief Retrieve the template arguments provided as part of this
/// template-id.
- const TemplateArgument *getTemplateArgs() const {
+ const TemplateArgument *getTemplateArgs() const {
if (!HasExplicitTemplateArgumentList)
- return 0;
-
+ return 0;
+
return getExplicitTemplateArgumentList()->getTemplateArgs();
}
-
+
/// \brief Retrieve the number of template arguments provided as part of this
/// template-id.
- unsigned getNumTemplateArgs() const {
+ unsigned getNumTemplateArgs() const {
if (!HasExplicitTemplateArgumentList)
- return 0;
-
+ return 0;
+
return getExplicitTemplateArgumentList()->NumTemplateArgs;
}
-
- /// \brief Retrieve the location of the right angle bracket following the
+
+ /// \brief Retrieve the location of the right angle bracket following the
/// template arguments ('>').
- SourceLocation getRAngleLoc() const {
+ SourceLocation getRAngleLoc() const {
if (!HasExplicitTemplateArgumentList)
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->RAngleLoc;
}
-
+
bool isArrow() const { return IsArrow; }
void setArrow(bool A) { IsArrow = A; }
@@ -1248,26 +1248,26 @@ public:
SourceLocation EndLoc = MemberLoc;
if (HasExplicitTemplateArgumentList)
EndLoc = getRAngleLoc();
-
+
SourceLocation BaseLoc = getBase()->getLocStart();
if (BaseLoc.isInvalid())
return SourceRange(MemberLoc, EndLoc);
return SourceRange(BaseLoc, EndLoc);
}
-
+
virtual SourceLocation getExprLoc() const { return MemberLoc; }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == MemberExprClass;
}
static bool classof(const MemberExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-/// CompoundLiteralExpr - [C99 6.5.2.5]
+/// CompoundLiteralExpr - [C99 6.5.2.5]
///
class CompoundLiteralExpr : public Expr {
/// LParenLoc - If non-null, this is the location of the left paren in a
@@ -1281,7 +1281,7 @@ public:
bool fileScope)
: Expr(CompoundLiteralExprClass, ty), LParenLoc(lparenloc), Init(init),
FileScope(fileScope) {}
-
+
/// \brief Construct an empty compound literal.
explicit CompoundLiteralExpr(EmptyShell Empty)
: Expr(CompoundLiteralExprClass, Empty) { }
@@ -1305,11 +1305,11 @@ public:
return SourceRange(LParenLoc, Init->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CompoundLiteralExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CompoundLiteralExprClass;
}
static bool classof(const CompoundLiteralExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1324,74 +1324,74 @@ public:
/// CastKind - the kind of cast this represents.
enum CastKind {
/// CK_Unknown - Unknown cast kind.
- /// FIXME: The goal is to get rid of this and make all casts have a
+ /// FIXME: The goal is to get rid of this and make all casts have a
/// kind so that the AST client doesn't have to try to figure out what's
/// going on.
CK_Unknown,
-
+
/// CK_BitCast - Used for reinterpret_cast.
CK_BitCast,
-
+
/// CK_NoOp - Used for const_cast.
CK_NoOp,
-
+
/// CK_DerivedToBase - Derived to base class casts.
CK_DerivedToBase,
-
+
/// CK_Dynamic - Dynamic cast.
CK_Dynamic,
-
+
/// CK_ToUnion - Cast to union (GCC extension).
CK_ToUnion,
-
+
/// CK_ArrayToPointerDecay - Array to pointer decay.
CK_ArrayToPointerDecay,
-
+
// CK_FunctionToPointerDecay - Function to pointer decay.
CK_FunctionToPointerDecay,
-
+
/// CK_NullToMemberPointer - Null pointer to member pointer.
CK_NullToMemberPointer,
-
+
/// CK_BaseToDerivedMemberPointer - Member pointer in base class to
/// member pointer in derived class.
CK_BaseToDerivedMemberPointer,
- /// CK_UserDefinedConversion - Conversion using a user defined type
+ /// CK_UserDefinedConversion - Conversion using a user defined type
/// conversion function.
CK_UserDefinedConversion,
/// CK_ConstructorConversion - Conversion by constructor
CK_ConstructorConversion
};
-
+
struct CastInfo {
const CastKind Kind;
-
+
// FIXME: This should assert that the CastKind does not require extra
// information.
CastInfo(CastKind Kind)
: Kind(Kind) { }
};
-
+
private:
CastKind Kind;
Stmt *Op;
protected:
- CastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op) :
+ CastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op) :
Expr(SC, ty,
// Cast expressions are type-dependent if the type is
// dependent (C++ [temp.dep.expr]p3).
ty->isDependentType(),
// Cast expressions are value-dependent if the type is
// dependent or if the subexpression is value-dependent.
- ty->isDependentType() || (op && op->isValueDependent())),
+ ty->isDependentType() || (op && op->isValueDependent())),
Kind(info.Kind), Op(op) {}
-
+
/// \brief Construct an empty cast.
- CastExpr(StmtClass SC, EmptyShell Empty)
+ CastExpr(StmtClass SC, EmptyShell Empty)
: Expr(SC, Empty) { }
-
+
public:
CastKind getCastKind() const { return Kind; }
void setCastKind(CastKind K) { Kind = K; }
@@ -1401,7 +1401,7 @@ public:
const Expr *getSubExpr() const { return cast<Expr>(Op); }
void setSubExpr(Expr *E) { Op = E; }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
StmtClass SC = T->getStmtClass();
if (SC >= CXXNamedCastExprClass && SC <= CXXFunctionalCastExprClass)
return true;
@@ -1412,7 +1412,7 @@ public:
return false;
}
static bool classof(const CastExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1430,7 +1430,7 @@ public:
/// @code
/// class Base { };
/// class Derived : public Base { };
-/// void f(Derived d) {
+/// void f(Derived d) {
/// Base& b = d; // initializer is an ImplicitCastExpr to an lvalue of type Base
/// }
/// @endcode
@@ -1439,11 +1439,11 @@ class ImplicitCastExpr : public CastExpr {
bool LvalueCast;
public:
- ImplicitCastExpr(QualType ty, const CastInfo &info, Expr *op, bool Lvalue) :
+ ImplicitCastExpr(QualType ty, const CastInfo &info, Expr *op, bool Lvalue) :
CastExpr(ImplicitCastExprClass, ty, info, op), LvalueCast(Lvalue) { }
/// \brief Construct an empty implicit cast.
- explicit ImplicitCastExpr(EmptyShell Shell)
+ explicit ImplicitCastExpr(EmptyShell Shell)
: CastExpr(ImplicitCastExprClass, Shell) { }
@@ -1457,14 +1457,14 @@ public:
/// setLvalueCast - Set whether this cast produces an lvalue.
void setLvalueCast(bool Lvalue) { LvalueCast = Lvalue; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ImplicitCastExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ImplicitCastExprClass;
}
static bool classof(const ImplicitCastExpr *) { return true; }
};
/// ExplicitCastExpr - An explicit cast written in the source
-/// code.
+/// code.
///
/// This class is effectively an abstract class, because it provides
/// the basic representation of an explicitly-written cast without
@@ -1486,11 +1486,11 @@ class ExplicitCastExpr : public CastExpr {
protected:
ExplicitCastExpr(StmtClass SC, QualType exprTy, const CastInfo &info,
- Expr *op, QualType writtenTy)
+ Expr *op, QualType writtenTy)
: CastExpr(SC, exprTy, info, op), TypeAsWritten(writtenTy) {}
/// \brief Construct an empty explicit cast.
- ExplicitCastExpr(StmtClass SC, EmptyShell Shell)
+ ExplicitCastExpr(StmtClass SC, EmptyShell Shell)
: CastExpr(SC, Shell) { }
public:
@@ -1499,7 +1499,7 @@ public:
QualType getTypeAsWritten() const { return TypeAsWritten; }
void setTypeAsWritten(QualType T) { TypeAsWritten = T; }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
StmtClass SC = T->getStmtClass();
if (SC >= ExplicitCastExprClass && SC <= CStyleCastExprClass)
return true;
@@ -1518,13 +1518,13 @@ class CStyleCastExpr : public ExplicitCastExpr {
SourceLocation LPLoc; // the location of the left paren
SourceLocation RPLoc; // the location of the right paren
public:
- CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, QualType writtenTy,
- SourceLocation l, SourceLocation r) :
- ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy),
+ CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, QualType writtenTy,
+ SourceLocation l, SourceLocation r) :
+ ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy),
LPLoc(l), RPLoc(r) {}
/// \brief Construct an empty C-style explicit cast.
- explicit CStyleCastExpr(EmptyShell Shell)
+ explicit CStyleCastExpr(EmptyShell Shell)
: ExplicitCastExpr(CStyleCastExprClass, Shell) { }
SourceLocation getLParenLoc() const { return LPLoc; }
@@ -1536,8 +1536,8 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CStyleCastExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CStyleCastExprClass;
}
static bool classof(const CStyleCastExpr *) { return true; }
};
@@ -1589,22 +1589,22 @@ private:
Stmt* SubExprs[END_EXPR];
Opcode Opc;
SourceLocation OpLoc;
-public:
-
+public:
+
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
SourceLocation opLoc)
: Expr(BinaryOperatorClass, ResTy,
lhs->isTypeDependent() || rhs->isTypeDependent(),
- lhs->isValueDependent() || rhs->isValueDependent()),
+ lhs->isValueDependent() || rhs->isValueDependent()),
Opc(opc), OpLoc(opLoc) {
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
- assert(!isCompoundAssignmentOp() &&
+ assert(!isCompoundAssignmentOp() &&
"Use ArithAssignBinaryOperator for compound assignments");
}
/// \brief Construct an empty binary operator.
- explicit BinaryOperator(EmptyShell Empty)
+ explicit BinaryOperator(EmptyShell Empty)
: Expr(BinaryOperatorClass, Empty), Opc(Comma) { }
SourceLocation getOperatorLoc() const { return OpLoc; }
@@ -1621,7 +1621,7 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
}
-
+
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
/// corresponds to, e.g. "<<=".
static const char *getOpcodeStr(Opcode Op);
@@ -1643,19 +1643,19 @@ public:
static bool isRelationalOp(Opcode Opc) { return Opc >= LT && Opc <= GE; }
bool isRelationalOp() const { return isRelationalOp(Opc); }
- static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; }
+ static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; }
bool isEqualityOp() const { return isEqualityOp(Opc); }
-
+
static bool isLogicalOp(Opcode Opc) { return Opc == LAnd || Opc == LOr; }
bool isLogicalOp() const { return isLogicalOp(Opc); }
bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; }
bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;}
bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
-
- static bool classof(const Stmt *S) {
+
+ static bool classof(const Stmt *S) {
return S->getStmtClass() == BinaryOperatorClass ||
- S->getStmtClass() == CompoundAssignOperatorClass;
+ S->getStmtClass() == CompoundAssignOperatorClass;
}
static bool classof(const BinaryOperator *) { return true; }
@@ -1671,7 +1671,7 @@ protected:
SubExprs[RHS] = rhs;
}
- BinaryOperator(StmtClass SC, EmptyShell Empty)
+ BinaryOperator(StmtClass SC, EmptyShell Empty)
: Expr(SC, Empty), Opc(MulAssign) { }
};
@@ -1692,7 +1692,7 @@ public:
: BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
ComputationLHSType(CompLHSType),
ComputationResultType(CompResultType) {
- assert(isCompoundAssignmentOp() &&
+ assert(isCompoundAssignmentOp() &&
"Only should be used for compound assignments");
}
@@ -1710,8 +1710,8 @@ public:
void setComputationResultType(QualType T) { ComputationResultType = T; }
static bool classof(const CompoundAssignOperator *) { return true; }
- static bool classof(const Stmt *S) {
- return S->getStmtClass() == CompoundAssignOperatorClass;
+ static bool classof(const Stmt *S) {
+ return S->getStmtClass() == CompoundAssignOperatorClass;
}
};
@@ -1730,7 +1730,7 @@ public:
// depend on the type of the conditional, but the standard
// seems to imply that it could. File a bug!
((lhs && lhs->isTypeDependent()) || (rhs && rhs->isTypeDependent())),
- (cond->isValueDependent() ||
+ (cond->isValueDependent() ||
(lhs && lhs->isValueDependent()) ||
(rhs && rhs->isValueDependent()))),
QuestionLoc(QLoc),
@@ -1754,15 +1754,15 @@ public:
// will be the same as getLHS() except a GCC extension allows the left
// subexpression to be omitted, and instead of the condition be returned.
// e.g: x ?: y is shorthand for x ? x : y, except that the expression "x"
- // is only evaluated once.
+ // is only evaluated once.
Expr *getTrueExpr() const {
return cast<Expr>(SubExprs[LHS] ? SubExprs[LHS] : SubExprs[COND]);
}
-
+
// getTrueExpr - Return the subexpression representing the value of the ?:
// expression if the condition evaluates to false. This is the same as getRHS.
Expr *getFalseExpr() const { return cast<Expr>(SubExprs[RHS]); }
-
+
Expr *getLHS() const { return cast_or_null<Expr>(SubExprs[LHS]); }
void setLHS(Expr *E) { SubExprs[LHS] = E; }
@@ -1778,11 +1778,11 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ConditionalOperatorClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ConditionalOperatorClass;
}
static bool classof(const ConditionalOperator *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1796,9 +1796,9 @@ public:
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
QualType t)
: Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
-
+
/// \brief Build an empty address of a label expression.
- explicit AddrLabelExpr(EmptyShell Empty)
+ explicit AddrLabelExpr(EmptyShell Empty)
: Expr(AddrLabelExprClass, Empty) { }
SourceLocation getAmpAmpLoc() const { return AmpAmpLoc; }
@@ -1809,15 +1809,15 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(AmpAmpLoc, LabelLoc);
}
-
+
LabelStmt *getLabel() const { return Label; }
void setLabel(LabelStmt *S) { Label = S; }
static bool classof(const Stmt *T) {
- return T->getStmtClass() == AddrLabelExprClass;
+ return T->getStmtClass() == AddrLabelExprClass;
}
static bool classof(const AddrLabelExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1833,7 +1833,7 @@ public:
StmtExpr(CompoundStmt *substmt, QualType T,
SourceLocation lp, SourceLocation rp) :
Expr(StmtExprClass, T), SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
-
+
/// \brief Build an empty statement expression.
explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
@@ -1844,17 +1844,17 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(LParenLoc, RParenLoc);
}
-
+
SourceLocation getLParenLoc() const { return LParenLoc; }
void setLParenLoc(SourceLocation L) { LParenLoc = L; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
-
+
static bool classof(const Stmt *T) {
- return T->getStmtClass() == StmtExprClass;
+ return T->getStmtClass() == StmtExprClass;
}
static bool classof(const StmtExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1869,8 +1869,8 @@ class TypesCompatibleExpr : public Expr {
QualType Type2;
SourceLocation BuiltinLoc, RParenLoc;
public:
- TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
- QualType t1, QualType t2, SourceLocation RP) :
+ TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
+ QualType t1, QualType t2, SourceLocation RP) :
Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
BuiltinLoc(BLoc), RParenLoc(RP) {}
@@ -1882,21 +1882,21 @@ public:
void setArgType1(QualType T) { Type1 = T; }
QualType getArgType2() const { return Type2; }
void setArgType2(QualType T) { Type2 = T; }
-
+
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
+
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() == TypesCompatibleExprClass;
+ return T->getStmtClass() == TypesCompatibleExprClass;
}
static bool classof(const TypesCompatibleExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1919,27 +1919,27 @@ class ShuffleVectorExpr : public Expr {
unsigned NumExprs;
protected:
- virtual void DoDestroy(ASTContext &C);
+ virtual void DoDestroy(ASTContext &C);
public:
ShuffleVectorExpr(ASTContext &C, Expr **args, unsigned nexpr,
- QualType Type, SourceLocation BLoc,
- SourceLocation RP) :
+ QualType Type, SourceLocation BLoc,
+ SourceLocation RP) :
Expr(ShuffleVectorExprClass, Type), BuiltinLoc(BLoc),
RParenLoc(RP), NumExprs(nexpr) {
-
+
SubExprs = new (C) Stmt*[nexpr];
for (unsigned i = 0; i < nexpr; i++)
SubExprs[i] = args[i];
}
/// \brief Build an empty vector-shuffle expression.
- explicit ShuffleVectorExpr(EmptyShell Empty)
+ explicit ShuffleVectorExpr(EmptyShell Empty)
: Expr(ShuffleVectorExprClass, Empty), SubExprs(0) { }
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
+
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
@@ -1947,17 +1947,17 @@ public:
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() == ShuffleVectorExprClass;
+ return T->getStmtClass() == ShuffleVectorExprClass;
}
static bool classof(const ShuffleVectorExpr *) { return true; }
-
+
~ShuffleVectorExpr() {}
-
+
/// getNumSubExprs - Return the size of the SubExprs array. This includes the
/// constant expression, the actual arguments passed in, and the function
/// pointers.
unsigned getNumSubExprs() const { return NumExprs; }
-
+
/// getExpr - Return the Expr at the specified index.
Expr *getExpr(unsigned Index) {
assert((Index < NumExprs) && "Arg access out of range!");
@@ -1967,21 +1967,21 @@ public:
assert((Index < NumExprs) && "Arg access out of range!");
return cast<Expr>(SubExprs[Index]);
}
-
+
void setExprs(ASTContext &C, Expr ** Exprs, unsigned NumExprs);
unsigned getShuffleMaskIdx(ASTContext &Ctx, unsigned N) {
assert((N < NumExprs - 2) && "Shuffle idx out of range!");
return getExpr(N+2)->EvaluateAsInt(Ctx).getZExtValue();
}
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
-/// This AST node is similar to the conditional operator (?:) in C, with
+/// This AST node is similar to the conditional operator (?:) in C, with
/// the following exceptions:
/// - the test expression must be a integer constant expression.
/// - the expression returned acts like the chosen subexpression in every
@@ -1996,12 +1996,12 @@ class ChooseExpr : public Expr {
public:
ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
SourceLocation RP)
- : Expr(ChooseExprClass, t),
+ : Expr(ChooseExprClass, t),
BuiltinLoc(BLoc), RParenLoc(RP) {
SubExprs[COND] = cond;
SubExprs[LHS] = lhs;
SubExprs[RHS] = rhs;
- }
+ }
/// \brief Build an empty __builtin_choose_expr.
explicit ChooseExpr(EmptyShell Empty) : Expr(ChooseExprClass, Empty) { }
@@ -2025,7 +2025,7 @@ public:
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
+
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
@@ -2033,10 +2033,10 @@ public:
return SourceRange(BuiltinLoc, RParenLoc);
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() == ChooseExprClass;
+ return T->getStmtClass() == ChooseExprClass;
}
static bool classof(const ChooseExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -2053,7 +2053,7 @@ class GNUNullExpr : public Expr {
SourceLocation TokenLoc;
public:
- GNUNullExpr(QualType Ty, SourceLocation Loc)
+ GNUNullExpr(QualType Ty, SourceLocation Loc)
: Expr(GNUNullExprClass, Ty), TokenLoc(Loc) { }
/// \brief Build an empty GNU __null expression.
@@ -2067,10 +2067,10 @@ public:
return SourceRange(TokenLoc);
}
static bool classof(const Stmt *T) {
- return T->getStmtClass() == GNUNullExprClass;
+ return T->getStmtClass() == GNUNullExprClass;
}
static bool classof(const GNUNullExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -2086,7 +2086,7 @@ public:
Val(e),
BuiltinLoc(BLoc),
RParenLoc(RPLoc) { }
-
+
/// \brief Create an empty __builtin_va_start expression.
explicit VAArgExpr(EmptyShell Empty) : Expr(VAArgExprClass, Empty) { }
@@ -2096,23 +2096,23 @@ public:
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
-
+
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
virtual SourceRange getSourceRange() const {
return SourceRange(BuiltinLoc, RParenLoc);
- }
+ }
static bool classof(const Stmt *T) {
return T->getStmtClass() == VAArgExprClass;
}
static bool classof(const VAArgExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
- virtual child_iterator child_end();
+ virtual child_iterator child_end();
};
-
+
/// @brief Describes an C or C++ initializer list.
///
/// InitListExpr describes an initializer list, which can be used to
@@ -2154,7 +2154,7 @@ class InitListExpr : public Expr {
// FIXME: Eliminate this vector in favor of ASTContext allocation
std::vector<Stmt *> InitExprs;
SourceLocation LBraceLoc, RBraceLoc;
-
+
/// Contains the initializer list that describes the syntactic form
/// written in the source code.
InitListExpr *SyntacticForm;
@@ -2173,27 +2173,27 @@ public:
/// \brief Build an empty initializer list.
explicit InitListExpr(EmptyShell Empty) : Expr(InitListExprClass, Empty) { }
-
+
unsigned getNumInits() const { return InitExprs.size(); }
-
- const Expr* getInit(unsigned Init) const {
+
+ const Expr* getInit(unsigned Init) const {
assert(Init < getNumInits() && "Initializer access out of range!");
return cast_or_null<Expr>(InitExprs[Init]);
}
-
- Expr* getInit(unsigned Init) {
+
+ Expr* getInit(unsigned Init) {
assert(Init < getNumInits() && "Initializer access out of range!");
return cast_or_null<Expr>(InitExprs[Init]);
}
-
- void setInit(unsigned Init, Expr *expr) {
+
+ void setInit(unsigned Init, Expr *expr) {
assert(Init < getNumInits() && "Initializer access out of range!");
InitExprs[Init] = expr;
}
/// \brief Reserve space for some number of initializers.
void reserveInits(unsigned NumInits);
-
+
/// @brief Specify the number of initializers
///
/// If there are more than @p NumInits initializers, the remaining
@@ -2225,7 +2225,7 @@ public:
bool isExplicit() {
return LBraceLoc.isValid() && RBraceLoc.isValid();
}
-
+
SourceLocation getLBraceLoc() const { return LBraceLoc; }
void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
SourceLocation getRBraceLoc() const { return RBraceLoc; }
@@ -2234,30 +2234,30 @@ public:
/// @brief Retrieve the initializer list that describes the
/// syntactic form of the initializer.
///
- ///
+ ///
InitListExpr *getSyntacticForm() const { return SyntacticForm; }
void setSyntacticForm(InitListExpr *Init) { SyntacticForm = Init; }
bool hadArrayRangeDesignator() const { return HadArrayRangeDesignator; }
- void sawArrayRangeDesignator(bool ARD = true) {
+ void sawArrayRangeDesignator(bool ARD = true) {
HadArrayRangeDesignator = ARD;
}
virtual SourceRange getSourceRange() const {
return SourceRange(LBraceLoc, RBraceLoc);
- }
+ }
static bool classof(const Stmt *T) {
- return T->getStmtClass() == InitListExprClass;
+ return T->getStmtClass() == InitListExprClass;
}
static bool classof(const InitListExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
typedef std::vector<Stmt *>::iterator iterator;
typedef std::vector<Stmt *>::reverse_iterator reverse_iterator;
-
+
iterator begin() { return InitExprs.begin(); }
iterator end() { return InitExprs.end(); }
reverse_iterator rbegin() { return InitExprs.rbegin(); }
@@ -2271,7 +2271,7 @@ public:
/// designators, or GNU array-range designators) followed by an
/// expression that initializes the field or element(s) that the
/// designators refer to. For example, given:
-///
+///
/// @code
/// struct point {
/// double x;
@@ -2311,7 +2311,7 @@ private:
unsigned NumSubExprs : 16;
- DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
+ DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
const Designator *Designators,
SourceLocation EqualOrColonLoc, bool GNUSyntax,
Expr **IndexExprs, unsigned NumIndexExprs,
@@ -2322,7 +2322,7 @@ private:
NumDesignators(0), Designators(0), NumSubExprs(NumSubExprs) { }
protected:
- virtual void DoDestroy(ASTContext &C);
+ virtual void DoDestroy(ASTContext &C);
public:
/// A field designator, e.g., ".x".
@@ -2334,10 +2334,10 @@ public:
/// IdentifierInfo*. After semantic analysis has resolved that
/// name, the field designator will instead store a FieldDecl*.
uintptr_t NameOrField;
-
+
/// The location of the '.' in the designated initializer.
unsigned DotLoc;
-
+
/// The location of the field name in the designated initializer.
unsigned FieldLoc;
};
@@ -2353,7 +2353,7 @@ public:
/// indices. Only valid for GNU array-range designators.
unsigned EllipsisLoc;
/// The location of the ']' terminating the array range designator.
- unsigned RBracketLoc;
+ unsigned RBracketLoc;
};
/// @brief Represents a single C99 designator.
@@ -2382,8 +2382,8 @@ public:
Designator() {}
/// @brief Initializes a field designator.
- Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc,
- SourceLocation FieldLoc)
+ Designator(const IdentifierInfo *FieldName, SourceLocation DotLoc,
+ SourceLocation FieldLoc)
: Kind(FieldDesignator) {
Field.NameOrField = reinterpret_cast<uintptr_t>(FieldName) | 0x01;
Field.DotLoc = DotLoc.getRawEncoding();
@@ -2391,7 +2391,7 @@ public:
}
/// @brief Initializes an array designator.
- Designator(unsigned Index, SourceLocation LBracketLoc,
+ Designator(unsigned Index, SourceLocation LBracketLoc,
SourceLocation RBracketLoc)
: Kind(ArrayDesignator) {
ArrayOrRange.Index = Index;
@@ -2401,7 +2401,7 @@ public:
}
/// @brief Initializes a GNU array-range designator.
- Designator(unsigned Index, SourceLocation LBracketLoc,
+ Designator(unsigned Index, SourceLocation LBracketLoc,
SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
: Kind(ArrayRangeDesignator) {
ArrayOrRange.Index = Index;
@@ -2471,7 +2471,7 @@ public:
}
};
- static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators,
+ static DesignatedInitExpr *Create(ASTContext &C, Designator *Designators,
unsigned NumDesignators,
Expr **IndexExprs, unsigned NumIndexExprs,
SourceLocation EqualOrColonLoc,
@@ -2485,8 +2485,8 @@ public:
// Iterator access to the designators.
typedef Designator* designators_iterator;
designators_iterator designators_begin() { return Designators; }
- designators_iterator designators_end() {
- return Designators + NumDesignators;
+ designators_iterator designators_end() {
+ return Designators + NumDesignators;
}
Designator *getDesignator(unsigned Idx) { return &designators_begin()[Idx]; }
@@ -2508,7 +2508,7 @@ public:
void setGNUSyntax(bool GNU) { GNUSyntax = GNU; }
/// @brief Retrieve the initializer value.
- Expr *getInit() const {
+ Expr *getInit() const {
return cast<Expr>(*const_cast<DesignatedInitExpr*>(this)->child_begin());
}
@@ -2538,19 +2538,19 @@ public:
/// \brief Replaces the designator at index @p Idx with the series
/// of designators in [First, Last).
- void ExpandDesignator(unsigned Idx, const Designator *First,
+ void ExpandDesignator(unsigned Idx, const Designator *First,
const Designator *Last);
virtual SourceRange getSourceRange() const;
static bool classof(const Stmt *T) {
- return T->getStmtClass() == DesignatedInitExprClass;
+ return T->getStmtClass() == DesignatedInitExprClass;
}
static bool classof(const DesignatedInitExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
- virtual child_iterator child_end();
+ virtual child_iterator child_end();
};
/// \brief Represents an implicitly-generated value initialization of
@@ -2561,16 +2561,16 @@ public:
/// initializations not explicitly specified by the user.
///
/// \see InitListExpr
-class ImplicitValueInitExpr : public Expr {
+class ImplicitValueInitExpr : public Expr {
public:
- explicit ImplicitValueInitExpr(QualType ty)
+ explicit ImplicitValueInitExpr(QualType ty)
: Expr(ImplicitValueInitExprClass, ty) { }
/// \brief Construct an empty implicit value initialization.
explicit ImplicitValueInitExpr(EmptyShell Empty)
: Expr(ImplicitValueInitExprClass, Empty) { }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == ImplicitValueInitExprClass;
}
static bool classof(const ImplicitValueInitExpr *) { return true; }
@@ -2581,7 +2581,7 @@ public:
// Iterators
virtual child_iterator child_begin();
- virtual child_iterator child_end();
+ virtual child_iterator child_end();
};
@@ -2590,49 +2590,49 @@ class ParenListExpr : public Expr {
unsigned NumExprs;
SourceLocation LParenLoc, RParenLoc;
-protected:
+protected:
virtual void DoDestroy(ASTContext& C);
-
+
public:
- ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs,
+ ParenListExpr(ASTContext& C, SourceLocation lparenloc, Expr **exprs,
unsigned numexprs, SourceLocation rparenloc);
~ParenListExpr() {}
/// \brief Build an empty paren list.
//explicit ParenListExpr(EmptyShell Empty) : Expr(ParenListExprClass, Empty) { }
-
+
unsigned getNumExprs() const { return NumExprs; }
-
- const Expr* getExpr(unsigned Init) const {
+
+ const Expr* getExpr(unsigned Init) const {
assert(Init < getNumExprs() && "Initializer access out of range!");
return cast_or_null<Expr>(Exprs[Init]);
}
-
- Expr* getExpr(unsigned Init) {
+
+ Expr* getExpr(unsigned Init) {
assert(Init < getNumExprs() && "Initializer access out of range!");
return cast_or_null<Expr>(Exprs[Init]);
}
Expr **getExprs() { return reinterpret_cast<Expr **>(Exprs); }
-
+
SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
virtual SourceRange getSourceRange() const {
return SourceRange(LParenLoc, RParenLoc);
- }
+ }
static bool classof(const Stmt *T) {
- return T->getStmtClass() == ParenListExprClass;
+ return T->getStmtClass() == ParenListExprClass;
}
static bool classof(const ParenListExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
//===----------------------------------------------------------------------===//
// Clang Extensions
//===----------------------------------------------------------------------===//
@@ -2652,9 +2652,9 @@ class ExtVectorElementExpr : public Expr {
public:
ExtVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
SourceLocation loc)
- : Expr(ExtVectorElementExprClass, ty),
+ : Expr(ExtVectorElementExprClass, ty),
Base(base), Accessor(&accessor), AccessorLoc(loc) {}
-
+
/// \brief Build an empty vector element expression.
explicit ExtVectorElementExpr(EmptyShell Empty)
: Expr(ExtVectorElementExprClass, Empty) { }
@@ -2671,28 +2671,28 @@ public:
/// getNumElements - Get the number of components being selected.
unsigned getNumElements() const;
-
+
/// containsDuplicateElements - Return true if any element access is
/// repeated.
bool containsDuplicateElements() const;
-
+
/// getEncodedElementAccess - Encode the elements accessed into an llvm
/// aggregate Constant of ConstantInt(s).
void getEncodedElementAccess(llvm::SmallVectorImpl<unsigned> &Elts) const;
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(getBase()->getLocStart(), AccessorLoc);
}
-
+
/// isArrow - Return true if the base expression is a pointer to vector,
/// return false if the base expression is a vector.
bool isArrow() const;
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ExtVectorElementExprClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ExtVectorElementExprClass;
}
static bool classof(const ExtVectorElementExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -2707,7 +2707,7 @@ protected:
bool HasBlockDeclRefExprs;
public:
BlockExpr(BlockDecl *BD, QualType ty, bool hasBlockDeclRefExprs)
- : Expr(BlockExprClass, ty),
+ : Expr(BlockExprClass, ty),
TheBlock(BD), HasBlockDeclRefExprs(hasBlockDeclRefExprs) {}
/// \brief Build an empty block expression.
@@ -2734,25 +2734,25 @@ public:
bool hasBlockDeclRefExprs() const { return HasBlockDeclRefExprs; }
void setHasBlockDeclRefExprs(bool BDRE) { HasBlockDeclRefExprs = BDRE; }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == BlockExprClass;
}
static bool classof(const BlockExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// BlockDeclRefExpr - A reference to a declared variable, function,
/// enum, etc.
class BlockDeclRefExpr : public Expr {
- ValueDecl *D;
+ ValueDecl *D;
SourceLocation Loc;
bool IsByRef : 1;
bool ConstQualAdded : 1;
public:
- BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef,
+ BlockDeclRefExpr(ValueDecl *d, QualType t, SourceLocation l, bool ByRef,
bool constAdded = false) :
Expr(BlockDeclRefExprClass, t), D(d), Loc(l), IsByRef(ByRef),
ConstQualAdded(constAdded) {}
@@ -2761,7 +2761,7 @@ public:
// block.
explicit BlockDeclRefExpr(EmptyShell Empty)
: Expr(BlockDeclRefExprClass, Empty) { }
-
+
ValueDecl *getDecl() { return D; }
const ValueDecl *getDecl() const { return D; }
void setDecl(ValueDecl *VD) { D = VD; }
@@ -2770,18 +2770,18 @@ public:
void setLocation(SourceLocation L) { Loc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
-
+
bool isByRef() const { return IsByRef; }
void setByRef(bool BR) { IsByRef = BR; }
-
+
bool isConstQualAdded() const { return ConstQualAdded; }
void setConstQualAdded(bool C) { ConstQualAdded = C; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == BlockDeclRefExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == BlockDeclRefExprClass;
}
static bool classof(const BlockDeclRefExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 0d9b4cef54..91b5fd2707 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -47,14 +47,14 @@ class CXXOperatorCallExpr : public CallExpr {
OverloadedOperatorKind Operator;
public:
- CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
- Expr **args, unsigned numargs, QualType t,
+ CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn,
+ Expr **args, unsigned numargs, QualType t,
SourceLocation operatorloc)
: CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc),
Operator(Op) {}
- explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
+ explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) :
CallExpr(C, CXXOperatorCallExprClass, Empty) { }
-
+
/// getOperator - Returns the kind of overloaded operator that this
/// expression refers to.
@@ -69,9 +69,9 @@ public:
SourceLocation getOperatorLoc() const { return getRParenLoc(); }
virtual SourceRange getSourceRange() const;
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CXXOperatorCallExprClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CXXOperatorCallExprClass;
}
static bool classof(const CXXOperatorCallExpr *) { return true; }
};
@@ -95,7 +95,7 @@ public:
/// operation would return "x".
Expr *getImplicitObjectArgument();
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXMemberCallExprClass;
}
static bool classof(const CXXMemberCallExpr *) { return true; }
@@ -113,7 +113,7 @@ private:
SourceLocation Loc; // the location of the casting op
protected:
- CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op,
+ CXXNamedCastExpr(StmtClass SC, QualType ty, const CastInfo &info, Expr *op,
QualType writtenTy, SourceLocation l)
: ExplicitCastExpr(SC, ty, info, op, writtenTy), Loc(l) {}
@@ -128,7 +128,7 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
switch (T->getStmtClass()) {
case CXXNamedCastExprClass:
case CXXStaticCastExprClass:
@@ -144,34 +144,34 @@ public:
};
/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]).
-///
+///
/// This expression node represents a C++ static cast, e.g.,
/// @c static_cast<int>(1.0).
class CXXStaticCastExpr : public CXXNamedCastExpr {
public:
- CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op,
+ CXXStaticCastExpr(QualType ty, const CastInfo &info, Expr *op,
QualType writtenTy, SourceLocation l)
: CXXNamedCastExpr(CXXStaticCastExprClass, ty, info, op, writtenTy, l) {}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXStaticCastExprClass;
}
static bool classof(const CXXStaticCastExpr *) { return true; }
};
/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression
-/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
+/// (C++ [expr.dynamic.cast]), which may perform a run-time check to
/// determine how to perform the type cast.
-///
+///
/// This expression node represents a dynamic cast, e.g.,
/// @c dynamic_cast<Derived*>(BasePtr).
class CXXDynamicCastExpr : public CXXNamedCastExpr {
public:
- CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy,
+ CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDynamicCastExprClass;
}
static bool classof(const CXXDynamicCastExpr *) { return true; }
@@ -180,17 +180,17 @@ public:
/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++
/// [expr.reinterpret.cast]), which provides a differently-typed view
/// of a value but performs no actual work at run time.
-///
+///
/// This expression node represents a reinterpret cast, e.g.,
/// @c reinterpret_cast<int>(VoidPtr).
class CXXReinterpretCastExpr : public CXXNamedCastExpr {
public:
- CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
+ CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
SourceLocation l)
- : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op,
+ : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op,
writtenTy, l) {}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXReinterpretCastExprClass;
}
static bool classof(const CXXReinterpretCastExpr *) { return true; }
@@ -198,39 +198,39 @@ public:
/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]),
/// which can remove type qualifiers but does not change the underlying value.
-///
+///
/// This expression node represents a const cast, e.g.,
/// @c const_cast<char*>(PtrToConstChar).
class CXXConstCastExpr : public CXXNamedCastExpr {
public:
- CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
+ CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConstCastExprClass;
}
static bool classof(const CXXConstCastExpr *) { return true; }
};
/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal.
-///
+///
class CXXBoolLiteralExpr : public Expr {
bool Value;
SourceLocation Loc;
public:
- CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
+ CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) :
Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {}
bool getValue() const { return Value; }
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXBoolLiteralExprClass;
}
static bool classof(const CXXBoolLiteralExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -322,7 +322,7 @@ class CXXThisExpr : public Expr {
SourceLocation Loc;
public:
- CXXThisExpr(SourceLocation L, QualType Type)
+ CXXThisExpr(SourceLocation L, QualType Type)
: Expr(CXXThisExprClass, Type,
// 'this' is type-dependent if the class type of the enclosing
// member function is dependent (C++ [temp.dep.expr]p2)
@@ -331,7 +331,7 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXThisExprClass;
}
static bool classof(const CXXThisExpr *) { return true; }
@@ -383,14 +383,14 @@ public:
/// supply arguments for all of the parameters.
class CXXDefaultArgExpr : public Expr {
ParmVarDecl *Param;
-
+
protected:
- CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param)
- : Expr(SC, param->hasUnparsedDefaultArg() ?
+ CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param)
+ : Expr(SC, param->hasUnparsedDefaultArg() ?
param->getType().getNonReferenceType()
: param->getDefaultArg()->getType()),
Param(param) { }
-
+
public:
// Param is the parameter whose default argument is used by this
// expression.
@@ -426,39 +426,39 @@ public:
class CXXTemporary {
/// Destructor - The destructor that needs to be called.
const CXXDestructorDecl *Destructor;
-
+
CXXTemporary(const CXXDestructorDecl *destructor)
: Destructor(destructor) { }
~CXXTemporary() { }
public:
- static CXXTemporary *Create(ASTContext &C,
+ static CXXTemporary *Create(ASTContext &C,
const CXXDestructorDecl *Destructor);
-
+
void Destroy(ASTContext &Ctx);
-
+
const CXXDestructorDecl *getDestructor() const { return Destructor; }
};
-/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
+/// CXXBindTemporaryExpr - Represents binding an expression to a temporary,
/// so its destructor can be called later.
class CXXBindTemporaryExpr : public Expr {
CXXTemporary *Temp;
-
+
Stmt *SubExpr;
- CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
+ CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
: Expr(CXXBindTemporaryExprClass,
subexpr->getType()), Temp(temp), SubExpr(subexpr) { }
- ~CXXBindTemporaryExpr() { }
+ ~CXXBindTemporaryExpr() { }
protected:
virtual void DoDestroy(ASTContext &C);
public:
- static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
+ static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp,
Expr* SubExpr);
-
+
CXXTemporary *getTemporary() { return Temp; }
const CXXTemporary *getTemporary() const { return Temp; }
@@ -484,24 +484,24 @@ class CXXConstructExpr : public Expr {
CXXConstructorDecl *Constructor;
bool Elidable;
-
+
Stmt **Args;
unsigned NumArgs;
-
+
protected:
- CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
+ CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
CXXConstructorDecl *d, bool elidable,
Expr **args, unsigned numargs);
- ~CXXConstructExpr() { }
+ ~CXXConstructExpr() { }
virtual void DoDestroy(ASTContext &C);
public:
static CXXConstructExpr *Create(ASTContext &C, QualType T,
- CXXConstructorDecl *D, bool Elidable,
+ CXXConstructorDecl *D, bool Elidable,
Expr **Args, unsigned NumArgs);
-
-
+
+
CXXConstructorDecl* getConstructor() const { return Constructor; }
/// \brief Whether this construction is elidable.
@@ -509,7 +509,7 @@ public:
typedef ExprIterator arg_iterator;
typedef ConstExprIterator const_arg_iterator;
-
+
arg_iterator arg_begin() { return Args; }
arg_iterator arg_end() { return Args + NumArgs; }
const_arg_iterator arg_begin() const { return Args; }
@@ -526,7 +526,7 @@ public:
assert(Arg < NumArgs && "Arg access out of range!");
return cast<Expr>(Args[Arg]);
}
-
+
/// setArg - Set the specified argument.
void setArg(unsigned Arg, Expr *ArgExpr) {
assert(Arg < NumArgs && "Arg access out of range!");
@@ -535,12 +535,12 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(); }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
}
static bool classof(const CXXConstructExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -554,24 +554,24 @@ class CXXFunctionalCastExpr : public ExplicitCastExpr {
SourceLocation TyBeginLoc;
SourceLocation RParenLoc;
public:
- CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
- SourceLocation tyBeginLoc, CastKind kind,
+ CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
+ SourceLocation tyBeginLoc, CastKind kind,
Expr *castExpr, CXXMethodDecl *typeConversionMethod,
- SourceLocation rParenLoc) :
+ SourceLocation rParenLoc) :
ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, writtenTy),
TypeConversionMethod(typeConversionMethod),
TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
- CXXMethodDecl *getTypeConversionMethod() const
+ CXXMethodDecl *getTypeConversionMethod() const
{ return TypeConversionMethod; }
SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(TyBeginLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CXXFunctionalCastExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CXXFunctionalCastExprClass;
}
static bool classof(const CXXFunctionalCastExpr *) { return true; }
};
@@ -579,7 +579,7 @@ public:
/// @brief Represents a C++ functional cast expression that builds a
/// temporary object.
///
-/// This expression type represents a C++ "functional" cast
+/// 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
@@ -600,12 +600,12 @@ class CXXTemporaryObjectExpr : public CXXConstructExpr {
SourceLocation RParenLoc;
public:
- CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
- QualType writtenTy, SourceLocation tyBeginLoc,
- Expr **Args,unsigned NumArgs,
+ CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons,
+ QualType writtenTy, SourceLocation tyBeginLoc,
+ Expr **Args,unsigned NumArgs,
SourceLocation rParenLoc);
- ~CXXTemporaryObjectExpr() { }
+ ~CXXTemporaryObjectExpr() { }
SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
@@ -613,7 +613,7 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(TyBeginLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXTemporaryObjectExprClass;
}
static bool classof(const CXXTemporaryObjectExpr *) { return true; }
@@ -630,28 +630,28 @@ class CXXZeroInitValueExpr : public Expr {
public:
CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc,
- SourceLocation rParenLoc ) :
+ SourceLocation rParenLoc ) :
Expr(CXXZeroInitValueExprClass, ty, false, false),
TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
-
+
SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
/// @brief Whether this initialization expression was
/// implicitly-generated.
- bool isImplicit() const {
- return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
+ bool isImplicit() const {
+ return TyBeginLoc.isInvalid() && RParenLoc.isInvalid();
}
virtual SourceRange getSourceRange() const {
return SourceRange(TyBeginLoc, RParenLoc);
}
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXZeroInitValueExprClass;
}
static bool classof(const CXXZeroInitValueExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -666,26 +666,26 @@ class CXXConditionDeclExpr : public DeclRefExpr {
public:
CXXConditionDeclExpr(SourceLocation startLoc,
SourceLocation eqLoc, VarDecl *var)
- : DeclRefExpr(CXXConditionDeclExprClass, var,
+ : DeclRefExpr(CXXConditionDeclExprClass, var,
var->getType().getNonReferenceType(), startLoc,
var->getType()->isDependentType(),
/*FIXME:integral constant?*/
var->getType()->isDependentType()) {}
SourceLocation getStartLoc() const { return getLocation(); }
-
+
VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); }
const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); }
virtual SourceRange getSourceRange() const {
return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConditionDeclExprClass;
}
static bool classof(const CXXConditionDeclExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -866,7 +866,7 @@ public:
/// Example:
///
/// \code
-/// template<typename T>
+/// template<typename T>
/// void destroy(T* ptr) {
/// ptr->~T();
/// }
@@ -874,67 +874,67 @@ public:
///
/// When the template is parsed, the expression \c ptr->~T will be stored as
/// a member reference expression. If it then instantiated with a scalar type
-/// as a template argument for T, the resulting expression will be a
+/// as a template argument for T, the resulting expression will be a
/// pseudo-destructor expression.
class CXXPseudoDestructorExpr : public Expr {
/// \brief The base expression (that is being destroyed).
Stmt *Base;
-
+
/// \brief Whether the operator was an arrow ('->'); otherwise, it was a
/// period ('.').
bool IsArrow : 1;
-
+
/// \brief The location of the '.' or '->' operator.
SourceLocation OperatorLoc;
-
+
/// \brief The nested-name-specifier that follows the operator, if present.
NestedNameSpecifier *Qualifier;
-
- /// \brief The source range that covers the nested-name-specifier, if
+
+ /// \brief The source range that covers the nested-name-specifier, if
/// present.
SourceRange QualifierRange;
-
+
/// \brief The type being destroyed.
QualType DestroyedType;
-
+
/// \brief The location of the type after the '~'.
SourceLocation DestroyedTypeLoc;
-
+
public:
CXXPseudoDestructorExpr(ASTContext &Context,
Expr *Base, bool isArrow, SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- QualType DestroyedType,
+ QualType DestroyedType,
SourceLocation DestroyedTypeLoc)
- : Expr(CXXPseudoDestructorExprClass,
+ : Expr(CXXPseudoDestructorExprClass,
Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
false, 0)),
/*isTypeDependent=*/false,
/*isValueDependent=*/Base->isValueDependent()),
- Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
+ Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
OperatorLoc(OperatorLoc), Qualifier(Qualifier),
QualifierRange(QualifierRange), DestroyedType(DestroyedType),
DestroyedTypeLoc(DestroyedTypeLoc) { }
-
+
void setBase(Expr *E) { Base = E; }
Expr *getBase() const { return cast<Expr>(Base); }
-
- /// \brief Determines whether this member expression actually had
+
+ /// \brief Determines whether this member expression actually had
/// a C++ nested-name-specifier prior to the name of the member, e.g.,
/// x->Base::foo.
bool hasQualifier() const { return Qualifier != 0; }
-
+
/// \brief If the member name was qualified, retrieves the source range of
/// the nested-name-specifier that precedes the member name. Otherwise,
/// returns an empty source range.
SourceRange getQualifierRange() const { return QualifierRange; }
-
- /// \brief If the member name was qualified, retrieves the
+
+ /// \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; }
-
+
/// \brief Determine whether this pseudo-destructor expression was written
/// using an '->' (otherwise, it used a '.').
bool isArrow() const { return IsArrow; }
@@ -942,27 +942,27 @@ public:
/// \brief Retrieve the location of the '.' or '->' operator.
SourceLocation getOperatorLoc() const { return OperatorLoc; }
-
+
/// \brief Retrieve the type that is being destroyed.
QualType getDestroyedType() const { return DestroyedType; }
-
+
/// \brief Retrieve the location of the type being destroyed.
SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(Base->getLocStart(), DestroyedTypeLoc);
}
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXPseudoDestructorExprClass;
}
static bool classof(const CXXPseudoDestructorExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
- virtual child_iterator child_end();
+ virtual child_iterator child_end();
};
-
+
/// \brief Represents the name of a function that has not been
/// resolved to any declaration.
///
@@ -980,7 +980,7 @@ public:
/// }
/// @endcode
class UnresolvedFunctionNameExpr : public Expr {
- /// The name that was present in the source
+ /// The name that was present in the source
DeclarationName Name;
/// The location of this name in the source code
@@ -999,7 +999,7 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == UnresolvedFunctionNameExprClass;
}
static bool classof(const UnresolvedFunctionNameExpr *) { return true; }
@@ -1064,9 +1064,9 @@ class QualifiedDeclRefExpr : public DeclRefExpr {
NestedNameSpecifier *NNS;
public:
- QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD,
+ QualifiedDeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD,
bool VD, SourceRange R, NestedNameSpecifier *NNS)
- : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD),
+ : DeclRefExpr(QualifiedDeclRefExprClass, d, t, l, TD, VD),
QualifierRange(R), NNS(NNS) { }
/// \brief Retrieve the source range of the nested-name-specifier.
@@ -1076,8 +1076,8 @@ public:
/// declaration.
NestedNameSpecifier *getQualifier() const { return NNS; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(QualifierRange.getBegin(), getLocation());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(QualifierRange.getBegin(), getLocation());
}
static bool classof(const Stmt *T) {
@@ -1117,13 +1117,13 @@ class UnresolvedDeclRefExpr : public Expr {
/// \brief Whether this expr is an address of (&) operand.
bool IsAddressOfOperand;
-
+
public:
UnresolvedDeclRefExpr(DeclarationName N, QualType T, SourceLocation L,
- SourceRange R, NestedNameSpecifier *NNS,
+ SourceRange R, NestedNameSpecifier *NNS,
bool IsAddressOfOperand)
- : Expr(UnresolvedDeclRefExprClass, T, true, true),
- Name(N), Loc(L), QualifierRange(R), NNS(NNS),
+ : Expr(UnresolvedDeclRefExprClass, T, true, true),
+ Name(N), Loc(L), QualifierRange(R), NNS(NNS),
IsAddressOfOperand(IsAddressOfOperand) { }
/// \brief Retrieve the name that this expression refers to.
@@ -1140,10 +1140,10 @@ public:
NestedNameSpecifier *getQualifier() const { return NNS; }
/// \brief Retrieve whether this is an address of (&) operand.
-
+
bool isAddressOfOperand() const { return IsAddressOfOperand; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(QualifierRange.getBegin(), getLocation());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(QualifierRange.getBegin(), getLocation());
}
static bool classof(const Stmt *T) {
@@ -1155,42 +1155,42 @@ public:
virtual StmtIterator child_end();
};
-/// \brief An expression that refers to a C++ template-id, such as
-/// @c isa<FunctionDecl>.
+/// \brief An expression that refers to a C++ template-id, such as
+/// @c isa<FunctionDecl>.
class TemplateIdRefExpr : public Expr {
/// \brief If this template-id was qualified-id, e.g., @c std::sort<int>,
/// this nested name specifier contains the @c std::.
NestedNameSpecifier *Qualifier;
-
+
/// \brief If this template-id was a qualified-id, e.g., @c std::sort<int>,
/// this covers the source code range of the @c std::.
SourceRange QualifierRange;
-
+
/// \brief The actual template to which this template-id refers.
TemplateName Template;
-
+
/// \brief The source location of the template name.
SourceLocation TemplateNameLoc;
/// \brief The source location of the left angle bracket ('<');
SourceLocation LAngleLoc;
-
+
/// \brief The source location of the right angle bracket ('>');
SourceLocation RAngleLoc;
-
+
/// \brief The number of template arguments in TemplateArgs.
unsigned NumTemplateArgs;
-
+
TemplateIdRefExpr(QualType T,
NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
TemplateName Template, SourceLocation TemplateNameLoc,
- SourceLocation LAngleLoc,
+ SourceLocation LAngleLoc,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc);
-
+
virtual void DoDestroy(ASTContext &Context);
-
+
public:
static TemplateIdRefExpr *
Create(ASTContext &Context, QualType T,
@@ -1198,66 +1198,66 @@ public:
TemplateName Template, SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc, const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs, SourceLocation RAngleLoc);
-
+
/// \brief Retrieve the nested name specifier used to qualify the name of
/// this template-id, e.g., the "std::sort" in @c std::sort<int>, or NULL
/// if this template-id was an unqualified-id.
NestedNameSpecifier *getQualifier() const { return Qualifier; }
-
+
/// \brief Retrieve the source range describing the nested name specifier
/// used to qualified the name of this template-id, if the name was qualified.
SourceRange getQualifierRange() const { return QualifierRange; }
-
+
/// \brief Retrieve the name of the template referenced, e.g., "sort" in
/// @c std::sort<int>;
TemplateName getTemplateName() const { return Template; }
-
+
/// \brief Retrieve the location of the name of the template referenced, e.g.,
/// the location of "sort" in @c std::sort<int>.
SourceLocation getTemplateNameLoc() const { return TemplateNameLoc; }
-
- /// \brief Retrieve the location of the left angle bracket following the
+
+ /// \brief Retrieve the location of the left angle bracket following the
/// template name ('<').
SourceLocation getLAngleLoc() const { return LAngleLoc; }
-
+
/// \brief Retrieve the template arguments provided as part of this
/// template-id.
- const TemplateArgument *getTemplateArgs() const {
+ const TemplateArgument *getTemplateArgs() const {
return reinterpret_cast<const TemplateArgument *>(this + 1);
}
-
+
/// \brief Retrieve the number of template arguments provided as part of this
/// template-id.
unsigned getNumTemplateArgs() const { return NumTemplateArgs; }
-
- /// \brief Retrieve the location of the right angle bracket following the
+
+ /// \brief Retrieve the location of the right angle bracket following the
/// template arguments ('>').
SourceLocation getRAngleLoc() const { return RAngleLoc; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(Qualifier? QualifierRange.getBegin() : TemplateNameLoc,
RAngleLoc);
}
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == TemplateIdRefExprClass;
}
static bool classof(const TemplateIdRefExpr *) { return true; }
};
-
+
class CXXExprWithTemporaries : public Expr {
Stmt *SubExpr;
-
+
CXXTemporary **Temps;
unsigned NumTemps;
bool ShouldDestroyTemps;
-
- CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
+
+ CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
unsigned NumTemps, bool ShouldDestroyTemps);
~CXXExprWithTemporaries();
@@ -1268,7 +1268,7 @@ public:
static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
CXXTemporary **Temps, unsigned NumTemps,
bool ShouldDestroyTemporaries);
-
+
unsigned getNumTemporaries() const { return NumTemps; }
CXXTemporary *getTemporary(unsigned i) {
assert(i < NumTemps && "Index out of range");
@@ -1278,11 +1278,11 @@ public:
assert(i < NumTemps && "Index out of range");
return Temps[i];
}
-
+
bool shouldDestroyTemporaries() const { return ShouldDestroyTemps; }
-
+
void removeLastTemporary() { NumTemps--; }
-
+
Expr *getSubExpr() { return cast<Expr>(SubExpr); }
const Expr *getSubExpr() const { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; }
@@ -1336,7 +1336,7 @@ class CXXUnresolvedConstructExpr : public Expr {
/// \brief The number of arguments used to construct the type.
unsigned NumArgs;
-
+
CXXUnresolvedConstructExpr(SourceLocation TyBegin,
QualType T,
SourceLocation LParenLoc,
@@ -1345,7 +1345,7 @@ class CXXUnresolvedConstructExpr : public Expr {
SourceLocation RParenLoc);
public:
- static CXXUnresolvedConstructExpr *Create(ASTContext &C,
+ static CXXUnresolvedConstructExpr *Create(ASTContext &C,
SourceLocation TyBegin,
QualType T,
SourceLocation LParenLoc,
@@ -1387,7 +1387,7 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(TyBeginLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXUnresolvedConstructExprClass;
}
static bool classof(const CXXUnresolvedConstructExpr *) { return true; }
@@ -1404,7 +1404,7 @@ class CXXUnresolvedMemberExpr : public Expr {
/// \brief The expression for the base pointer or class reference,
/// e.g., the \c x in x.f.
Stmt *Base;
-
+
/// \brief Whether this member expression used the '->' operator or
/// the '.' operator.
bool IsArrow : 1;
@@ -1412,25 +1412,25 @@ class CXXUnresolvedMemberExpr : public Expr {
/// \brief Whether this member expression has explicitly-specified template
/// arguments.
bool HasExplicitTemplateArgumentList : 1;
-
+
/// \brief The location of the '->' or '.' operator.
SourceLocation OperatorLoc;
/// \brief The nested-name-specifier that precedes the member name, if any.
NestedNameSpecifier *Qualifier;
-
+
/// \brief The source range covering the nested name specifier.
SourceRange QualifierRange;
-
+
/// \brief In a qualified member access expression such as t->Base::f, this
- /// member stores the resolves of name lookup in the context of the member
+ /// member stores the resolves of name lookup in the context of the member
/// access expression, to be used at instantiation time.
///
/// FIXME: This member, along with the Qualifier and QualifierRange, could
/// be stuck into a structure that is optionally allocated at the end of
/// the CXXUnresolvedMemberExpr, to save space in the common case.
NamedDecl *FirstQualifierFoundInScope;
-
+
/// \brief The member to which this member expression refers, which
/// can be name, overloaded operator, or destructor.
/// FIXME: could also be a template-id
@@ -1438,25 +1438,25 @@ class CXXUnresolvedMemberExpr : 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() {
if (!HasExplicitTemplateArgumentList)
return 0;
-
+
return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
}
-
+
/// \brief Retrieve the explicit template argument list that followed the
/// member template name, if any.
const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const {
return const_cast<CXXUnresolvedMemberExpr *>(this)
->getExplicitTemplateArgumentList();
}
-
- CXXUnresolvedMemberExpr(ASTContext &C,
- Expr *Base, bool IsArrow,
+
+ CXXUnresolvedMemberExpr(ASTContext &C,
+ Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
@@ -1468,10 +1468,10 @@ class CXXUnresolvedMemberExpr : public Expr {
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc);
-
+
public:
- CXXUnresolvedMemberExpr(ASTContext &C,
- Expr *Base, bool IsArrow,
+ CXXUnresolvedMemberExpr(ASTContext &C,
+ Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
@@ -1484,10 +1484,10 @@ public:
Qualifier(Qualifier), QualifierRange(QualifierRange),
FirstQualifierFoundInScope(FirstQualifierFoundInScope),
Member(Member), MemberLoc(MemberLoc) { }
-
+
static CXXUnresolvedMemberExpr *
- Create(ASTContext &C,
- Expr *Base, bool IsArrow,
+ Create(ASTContext &C,
+ Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
@@ -1499,7 +1499,7 @@ public:
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc);
-
+
/// \brief Retrieve the base object of this member expressions,
/// e.g., the \c x in \c x.m.
Expr *getBase() { return cast<Expr>(Base); }
@@ -1517,26 +1517,26 @@ public:
/// \brief Retrieve the nested-name-specifier that qualifies the member
/// name.
NestedNameSpecifier *getQualifier() const { return Qualifier; }
-
+
/// \brief Retrieve the source range covering the nested-name-specifier
/// that qualifies the member name.
SourceRange getQualifierRange() const { return QualifierRange; }
-
+
/// \brief Retrieve the first part of the nested-name-specifier that was
/// found in the scope of the member access expression when the member access
/// was initially parsed.
///
/// This function only returns a useful result when member access expression
- /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
- /// returned by this function describes what was found by unqualified name
+ /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration
+ /// returned by this function describes what was found by unqualified name
/// lookup for the identifier "Base" within the scope of the member access
/// expression itself. At template instantiation time, this information is
/// combined with the results of name lookup into the type of the object
/// expression itself (the class type of x).
- NamedDecl *getFirstQualifierFoundInScope() const {
+ NamedDecl *getFirstQualifierFoundInScope() const {
return FirstQualifierFoundInScope;
}
-
+
/// \brief Retrieve the name of the member that this expression
/// refers to.
DeclarationName getMember() const { return Member; }
@@ -1549,56 +1549,56 @@ public:
/// \brief Determines whether this member expression actually had a C++
/// template argument list explicitly specified, e.g., x.f<int>.
- bool hasExplicitTemplateArgumentList() {
- return HasExplicitTemplateArgumentList;
+ bool hasExplicitTemplateArgumentList() {
+ return HasExplicitTemplateArgumentList;
}
-
- /// \brief Retrieve the location of the left angle bracket following the
+
+ /// \brief Retrieve the location of the left angle bracket following the
/// member name ('<'), if any.
- SourceLocation getLAngleLoc() const {
+ SourceLocation getLAngleLoc() const {
if (!HasExplicitTemplateArgumentList)
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->LAngleLoc;
}
-
+
/// \brief Retrieve the template arguments provided as part of this
/// template-id.
- const TemplateArgument *getTemplateArgs() const {
+ const TemplateArgument *getTemplateArgs() const {
if (!HasExplicitTemplateArgumentList)
- return 0;
-
+ return 0;
+
return getExplicitTemplateArgumentList()->getTemplateArgs();
}
-
+
/// \brief Retrieve the number of template arguments provided as part of this
/// template-id.
- unsigned getNumTemplateArgs() const {
+ unsigned getNumTemplateArgs() const {
if (!HasExplicitTemplateArgumentList)
- return 0;
-
+ return 0;
+
return getExplicitTemplateArgumentList()->NumTemplateArgs;
}
-
- /// \brief Retrieve the location of the right angle bracket following the
+
+ /// \brief Retrieve the location of the right angle bracket following the
/// template arguments ('>').
- SourceLocation getRAngleLoc() const {
+ SourceLocation getRAngleLoc() const {
if (!HasExplicitTemplateArgumentList)
return SourceLocation();
-
+
return getExplicitTemplateArgumentList()->RAngleLoc;
}
-
+
virtual SourceRange getSourceRange() const {
if (HasExplicitTemplateArgumentList)
return SourceRange(Base->getSourceRange().getBegin(),
getRAngleLoc());
-
+
return SourceRange(Base->getSourceRange().getBegin(),
MemberLoc);
}
-
- static bool classof(const Stmt *T) {
+
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXUnresolvedMemberExprClass;
}
static bool classof(const CXXUnresolvedMemberExpr *) { return true; }
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h
index 1070a11eb3..0613f4c095 100644
--- a/include/clang/AST/ExprObjC.h
+++ b/include/clang/AST/ExprObjC.h
@@ -22,7 +22,7 @@ namespace clang {
class ASTContext;
class ObjCMethodDecl;
class ObjCPropertyDecl;
-
+
/// ObjCStringLiteral, used for Objective-C string literals
/// i.e. @"foo".
class ObjCStringLiteral : public Expr {
@@ -41,20 +41,20 @@ public:
SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
- virtual SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, String->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCStringLiteralClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCStringLiteralClass;
}
- static bool classof(const ObjCStringLiteral *) { return true; }
-
+ static bool classof(const ObjCStringLiteral *) { return true; }
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// ObjCEncodeExpr, used for @encode in Objective-C. @encode has the same type
/// and behavior as StringLiteral except that the string initializer is obtained
/// from ASTContext with the encoding type as an argument.
@@ -62,32 +62,32 @@ class ObjCEncodeExpr : public Expr {
QualType EncType;
SourceLocation AtLoc, RParenLoc;
public:
- ObjCEncodeExpr(QualType T, QualType ET,
+ ObjCEncodeExpr(QualType T, QualType ET,
SourceLocation at, SourceLocation rp)
- : Expr(ObjCEncodeExprClass, T, ET->isDependentType(),
+ : Expr(ObjCEncodeExprClass, T, ET->isDependentType(),
ET->isDependentType()), EncType(ET), AtLoc(at), RParenLoc(rp) {}
-
+
explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
-
+
SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
-
+
QualType getEncodedType() const { return EncType; }
void setEncodedType(QualType T) { EncType = T; }
-
+
virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCEncodeExprClass;
}
static bool classof(const ObjCEncodeExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -106,7 +106,7 @@ public:
Selector getSelector() const { return SelName; }
void setSelector(Selector S) { SelName = S; }
-
+
SourceLocation getAtLoc() const { return AtLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
@@ -115,26 +115,26 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
-
+
/// getNumArgs - Return the number of actual arguments to this call.
unsigned getNumArgs() const { return SelName.getNumArgs(); }
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCSelectorExprClass;
}
static bool classof(const ObjCSelectorExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// ObjCProtocolExpr used for protocol expression in Objective-C. This is used
/// as: @protocol(foo), as in:
/// obj conformsToProtocol:@protocol(foo)]
/// The return type is "Protocol*".
-class ObjCProtocolExpr : public Expr {
- ObjCProtocolDecl *TheProtocol;
+class ObjCProtocolExpr : public Expr {
+ ObjCProtocolDecl *TheProtocol;
SourceLocation AtLoc, RParenLoc;
public:
ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol,
@@ -146,7 +146,7 @@ public:
ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
-
+
SourceLocation getAtLoc() const { return AtLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; }
@@ -155,12 +155,12 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, RParenLoc);
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCProtocolExprClass;
}
static bool classof(const ObjCProtocolExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -173,44 +173,44 @@ class ObjCIvarRefExpr : public Expr {
Stmt *Base;
bool IsArrow:1; // True if this is "X->F", false if this is "X.F".
bool IsFreeIvar:1; // True if ivar reference has no base (self assumed).
-
+
public:
ObjCIvarRefExpr(ObjCIvarDecl *d,
- QualType t, SourceLocation l, Expr *base=0,
- bool arrow = false, bool freeIvar = false) :
+ QualType t, SourceLocation l, Expr *base=0,
+ bool arrow = false, bool freeIvar = false) :
Expr(ObjCIvarRefExprClass, t), D(d),
Loc(l), Base(base), IsArrow(arrow),
IsFreeIvar(freeIvar) {}
-
+
explicit ObjCIvarRefExpr(EmptyShell Empty)
: Expr(ObjCIvarRefExprClass, Empty) {}
ObjCIvarDecl *getDecl() { return D; }
const ObjCIvarDecl *getDecl() const { return D; }
void setDecl(ObjCIvarDecl *d) { D = d; }
-
+
const Expr *getBase() const { return cast<Expr>(Base); }
Expr *getBase() { return cast<Expr>(Base); }
void setBase(Expr * base) { Base = base; }
-
+
bool isArrow() const { return IsArrow; }
bool isFreeIvar() const { return IsFreeIvar; }
void setIsArrow(bool A) { IsArrow = A; }
void setIsFreeIvar(bool A) { IsFreeIvar = A; }
-
+
SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; }
- virtual SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return isFreeIvar() ? SourceRange(Loc)
- : SourceRange(getBase()->getLocStart(), Loc);
+ : SourceRange(getBase()->getLocStart(), Loc);
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCIvarRefExprClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCIvarRefExprClass;
}
static bool classof(const ObjCIvarRefExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -225,48 +225,48 @@ private:
SourceLocation IdLoc;
Stmt *Base;
public:
- ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
+ ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
SourceLocation l, Expr *base)
: Expr(ObjCPropertyRefExprClass, t), AsProperty(PD), IdLoc(l), Base(base) {
}
-
+
explicit ObjCPropertyRefExpr(EmptyShell Empty)
: Expr(ObjCPropertyRefExprClass, Empty) {}
ObjCPropertyDecl *getProperty() const { return AsProperty; }
void setProperty(ObjCPropertyDecl *D) { AsProperty = D; }
-
+
const Expr *getBase() const { return cast<Expr>(Base); }
Expr *getBase() { return cast<Expr>(Base); }
void setBase(Expr *base) { Base = base; }
-
+
SourceLocation getLocation() const { return IdLoc; }
void setLocation(SourceLocation L) { IdLoc = L; }
virtual SourceRange getSourceRange() const {
return SourceRange(getBase()->getLocStart(), IdLoc);
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCPropertyRefExprClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCPropertyRefExprClass;
}
static bool classof(const ObjCPropertyRefExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-/// ObjCImplicitSetterGetterRefExpr - A dot-syntax expression to access two
-/// methods; one to set a value to an 'ivar' (Setter) and the other to access
-/// an 'ivar' (Setter).
+/// ObjCImplicitSetterGetterRefExpr - A dot-syntax expression to access two
+/// methods; one to set a value to an 'ivar' (Setter) and the other to access
+/// an 'ivar' (Setter).
/// An example for use of this AST is:
/// @code
/// @interface Test { }
/// - (Test *)crash;
/// - (void)setCrash: (Test*)value;
/// @end
-/// void foo(Test *p1, Test *p2)
+/// void foo(Test *p1, Test *p2)
/// {
/// p2.crash = p1.crash; // Uses ObjCImplicitSetterGetterRefExpr AST
/// }
@@ -285,10 +285,10 @@ class ObjCImplicitSetterGetterRefExpr : public Expr {
/// Location of the receiver class in the dot syntax notation
/// used to call a class method setter/getter.
SourceLocation ClassLoc;
-
+
public:
ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter,
- QualType t,
+ QualType t,
ObjCMethodDecl *setter,
SourceLocation l, Expr *base)
: Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter),
@@ -296,13 +296,13 @@ public:
ClassLoc(SourceLocation()) {
}
ObjCImplicitSetterGetterRefExpr(ObjCMethodDecl *getter,
- QualType t,
+ QualType t,
ObjCMethodDecl *setter,
SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL)
: Expr(ObjCImplicitSetterGetterRefExprClass, t), Setter(setter),
Getter(getter), MemberLoc(l), Base(0), InterfaceDecl(C), ClassLoc(CL) {
}
- explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty)
+ explicit ObjCImplicitSetterGetterRefExpr(EmptyShell Empty)
: Expr(ObjCImplicitSetterGetterRefExprClass, Empty){}
ObjCMethodDecl *getGetterMethod() const { return Getter; }
@@ -311,7 +311,7 @@ public:
void setGetterMethod(ObjCMethodDecl *D) { Getter = D; }
void setSetterMethod(ObjCMethodDecl *D) { Setter = D; }
void setInterfaceDecl(ObjCInterfaceDecl *D) { InterfaceDecl = D; }
-
+
virtual SourceRange getSourceRange() const {
if (Base)
return SourceRange(getBase()->getLocStart(), MemberLoc);
@@ -320,34 +320,34 @@ public:
const Expr *getBase() const { return cast_or_null<Expr>(Base); }
Expr *getBase() { return cast_or_null<Expr>(Base); }
void setBase(Expr *base) { Base = base; }
-
+
SourceLocation getLocation() const { return MemberLoc; }
void setLocation(SourceLocation L) { MemberLoc = L; }
SourceLocation getClassLoc() const { return ClassLoc; }
void setClassLoc(SourceLocation L) { ClassLoc = L; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCImplicitSetterGetterRefExprClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCImplicitSetterGetterRefExprClass;
}
static bool classof(const ObjCImplicitSetterGetterRefExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
class ObjCMessageExpr : public Expr {
// SubExprs - The receiver and arguments of the message expression.
Stmt **SubExprs;
-
+
// NumArgs - The number of arguments (not including the receiver) to the
// message expression.
unsigned NumArgs;
-
+
// A unigue name for this message.
Selector SelName;
-
- // A method prototype for this message (optional).
+
+ // A method prototype for this message (optional).
// FIXME: Since method decls contain the selector, and most messages have a
// prototype, consider devising a scheme for unifying SelName/MethodProto.
ObjCMethodDecl *MethodProto;
@@ -360,7 +360,7 @@ class ObjCMessageExpr : public Expr {
// Bit-swizzling flags.
enum { IsInstMeth=0, IsClsMethDeclUnknown, IsClsMethDeclKnown, Flags=0x3 };
unsigned getFlag() const { return (uintptr_t) SubExprs[RECEIVER] & Flags; }
-
+
public:
/// This constructor is used to represent class messages where the
/// ObjCInterfaceDecl* of the receiver is not known.
@@ -376,28 +376,28 @@ public:
QualType retType, ObjCMethodDecl *methDecl,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned NumArgs);
-
+
// constructor for instance messages.
ObjCMessageExpr(Expr *receiver, Selector selInfo,
QualType retType, ObjCMethodDecl *methDecl,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned NumArgs);
-
+
explicit ObjCMessageExpr(EmptyShell Empty)
: Expr(ObjCMessageExprClass, Empty), SubExprs(0), NumArgs(0) {}
-
+
~ObjCMessageExpr() {
delete [] SubExprs;
}
-
+
/// getReceiver - Returns the receiver of the message expression.
/// This can be NULL if the message is for class methods. For
/// class methods, use getClassName.
/// FIXME: need to handle/detect 'super' usage within a class method.
- Expr *getReceiver() {
+ Expr *getReceiver() {
uintptr_t x = (uintptr_t) SubExprs[RECEIVER];
return (x & Flags) == IsInstMeth ? (Expr*) x : 0;
- }
+ }
const Expr *getReceiver() const {
return const_cast<ObjCMessageExpr*>(this)->getReceiver();
}
@@ -405,36 +405,36 @@ public:
void setReceiver(Expr *rec) { SubExprs[RECEIVER] = rec; }
Selector getSelector() const { return SelName; }
void setSelector(Selector S) { SelName = S; }
-
+
const ObjCMethodDecl *getMethodDecl() const { return MethodProto; }
ObjCMethodDecl *getMethodDecl() { return MethodProto; }
void setMethodDecl(ObjCMethodDecl *MD) { MethodProto = MD; }
-
+
typedef std::pair<ObjCInterfaceDecl*, IdentifierInfo*> ClassInfo;
-
+
/// getClassInfo - For class methods, this returns both the ObjCInterfaceDecl*
/// and IdentifierInfo* of the invoked class. Both can be NULL if this
/// is an instance message, and the ObjCInterfaceDecl* can be NULL if none
- /// was available when this ObjCMessageExpr object was constructed.
- ClassInfo getClassInfo() const;
+ /// was available when this ObjCMessageExpr object was constructed.
+ ClassInfo getClassInfo() const;
void setClassInfo(const ClassInfo &C);
-
+
/// getClassName - For class methods, this returns the invoked class,
- /// and returns NULL otherwise. For instance methods, use getReceiver.
+ /// and returns NULL otherwise. For instance methods, use getReceiver.
IdentifierInfo *getClassName() const {
return getClassInfo().second;
}
-
+
/// getNumArgs - Return the number of actual arguments to this call.
unsigned getNumArgs() const { return NumArgs; }
- void setNumArgs(unsigned nArgs) {
- NumArgs = nArgs;
+ void setNumArgs(unsigned nArgs) {
+ NumArgs = nArgs;
// FIXME: should always allocate SubExprs via the ASTContext's
// allocator.
if (!SubExprs)
SubExprs = new Stmt* [NumArgs + 1];
}
-
+
/// getArg - Return the specified argument.
Expr *getArg(unsigned Arg) {
assert(Arg < NumArgs && "Arg access out of range!");
@@ -449,13 +449,13 @@ public:
assert(Arg < NumArgs && "Arg access out of range!");
SubExprs[Arg+ARGS_START] = ArgExpr;
}
-
+
SourceLocation getLeftLoc() const { return LBracloc; }
SourceLocation getRightLoc() const { return RBracloc; }
void setLeftLoc(SourceLocation L) { LBracloc = L; }
void setRightLoc(SourceLocation L) { RBracloc = L; }
-
+
void setSourceRange(SourceRange R) {
LBracloc = R.getBegin();
RBracloc = R.getEnd();
@@ -468,14 +468,14 @@ public:
return T->getStmtClass() == ObjCMessageExprClass;
}
static bool classof(const ObjCMessageExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
typedef ExprIterator arg_iterator;
typedef ConstExprIterator const_arg_iterator;
-
+
arg_iterator arg_begin() { return &SubExprs[ARGS_START]; }
arg_iterator arg_end() { return &SubExprs[ARGS_START] + NumArgs; }
const_arg_iterator arg_begin() const { return &SubExprs[ARGS_START]; }
@@ -487,16 +487,16 @@ public:
class ObjCSuperExpr : public Expr {
SourceLocation Loc;
public:
- ObjCSuperExpr(SourceLocation L, QualType Type)
+ ObjCSuperExpr(SourceLocation L, QualType Type)
: Expr(ObjCSuperExprClass, Type), Loc(L) { }
explicit ObjCSuperExpr(EmptyShell Empty) : Expr(ObjCSuperExprClass, Empty) {}
SourceLocation getLoc() const { return Loc; }
void setLoc(SourceLocation L) { Loc = L; }
-
+
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
- static bool classof(const Stmt *T) {
+ static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCSuperExprClass;
}
static bool classof(const ObjCSuperExpr *) { return true; }
@@ -511,23 +511,23 @@ public:
class ObjCIsaExpr : public Expr {
/// Base - the expression for the base object pointer.
Stmt *Base;
-
+
/// IsaMemberLoc - This is the location of the 'isa'.
SourceLocation IsaMemberLoc;
-
+
/// IsArrow - True if this is "X->F", false if this is "X.F".
bool IsArrow;
public:
- ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty)
+ ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty)
: Expr(ObjCIsaExprClass, ty),
Base(base), IsaMemberLoc(l), IsArrow(isarrow) {}
-
+
/// \brief Build an empty expression.
explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) { }
-
+
void setBase(Expr *E) { Base = E; }
Expr *getBase() const { return cast<Expr>(Base); }
-
+
bool isArrow() const { return IsArrow; }
void setArrow(bool A) { IsArrow = A; }
@@ -539,14 +539,14 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(getBase()->getLocStart(), IsaMemberLoc);
}
-
+
virtual SourceLocation getExprLoc() const { return IsaMemberLoc; }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCIsaExprClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCIsaExprClass;
}
static bool classof(const ObjCIsaExpr *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h
index 6f862a55d4..0670d1a620 100644
--- a/include/clang/AST/ExternalASTSource.h
+++ b/include/clang/AST/ExternalASTSource.h
@@ -33,7 +33,7 @@ struct VisibleDeclaration {
/// \brief The name of the declarations.
DeclarationName Name;
- /// \brief The ID numbers of all of the declarations with this name.
+ /// \brief The ID numbers of all of the declarations with this name.
///
/// These declarations have not necessarily been de-serialized.
llvm::SmallVector<unsigned, 4> Declarations;
@@ -65,7 +65,7 @@ public:
/// replaced with the sorted set of source ranges corresponding to
/// comments in the source code.
virtual void ReadComments(std::vector<SourceRange> &Comments) = 0;
-
+
/// \brief Resolve a type ID into a type, potentially building a new
/// type.
virtual QualType GetType(uint32_t ID) = 0;
@@ -151,7 +151,7 @@ public:
this->Ptr = reinterpret_cast<uint64_t>(Ptr);
return *this;
}
-
+
LazyOffsetPtr &operator=(uint64_t Offset) {
assert((Offset << 1 >> 1) == Offset && "Offsets must require < 63 bits");
if (Offset == 0)
@@ -177,7 +177,7 @@ public:
/// \returns a pointer to the AST node.
T* get(ExternalASTSource *Source) const {
if (isOffset()) {
- assert(Source &&
+ assert(Source &&
"Cannot deserialize a lazy pointer without an AST source");
Ptr = reinterpret_cast<uint64_t>((Source->*Get)(Ptr >> 1));
}
diff --git a/include/clang/AST/NestedNameSpecifier.h b/include/clang/AST/NestedNameSpecifier.h
index 5c76064ae1..1594b090fe 100644
--- a/include/clang/AST/NestedNameSpecifier.h
+++ b/include/clang/AST/NestedNameSpecifier.h
@@ -81,8 +81,8 @@ private:
/// \brief Copy constructor used internally to clone nested name
/// specifiers.
- NestedNameSpecifier(const NestedNameSpecifier &Other)
- : llvm::FoldingSetNode(Other), Prefix(Other.Prefix),
+ NestedNameSpecifier(const NestedNameSpecifier &Other)
+ : llvm::FoldingSetNode(Other), Prefix(Other.Prefix),
Specifier(Other.Specifier) {
}
@@ -90,7 +90,7 @@ private:
/// \brief Either find or insert the given nested name specifier
/// mockup in the given context.
- static NestedNameSpecifier *FindOrInsert(ASTContext &Context,
+ static NestedNameSpecifier *FindOrInsert(ASTContext &Context,
const NestedNameSpecifier &Mockup);
public:
@@ -99,18 +99,18 @@ public:
/// The prefix must be dependent, since nested name specifiers
/// referencing an identifier are only permitted when the identifier
/// cannot be resolved.
- static NestedNameSpecifier *Create(ASTContext &Context,
- NestedNameSpecifier *Prefix,
+ static NestedNameSpecifier *Create(ASTContext &Context,
+ NestedNameSpecifier *Prefix,
IdentifierInfo *II);
/// \brief Builds a nested name specifier that names a namespace.
- static NestedNameSpecifier *Create(ASTContext &Context,
- NestedNameSpecifier *Prefix,
+ static NestedNameSpecifier *Create(ASTContext &Context,
+ NestedNameSpecifier *Prefix,
NamespaceDecl *NS);
/// \brief Builds a nested name specifier that names a type.
- static NestedNameSpecifier *Create(ASTContext &Context,
- NestedNameSpecifier *Prefix,
+ static NestedNameSpecifier *Create(ASTContext &Context,
+ NestedNameSpecifier *Prefix,
bool Template, Type *T);
/// \brief Builds a specifier that consists of just an identifier.
@@ -120,7 +120,7 @@ public:
/// nested name specifier, e.g., in "x->Base::f", the "x" has a dependent
/// type.
static NestedNameSpecifier *Create(ASTContext &Context, IdentifierInfo *II);
-
+
/// \brief Returns the nested name specifier representing the global
/// scope.
static NestedNameSpecifier *GlobalSpecifier(ASTContext &Context);
@@ -135,10 +135,10 @@ public:
NestedNameSpecifier *getPrefix() const { return Prefix.getPointer(); }
/// \brief Determine what kind of nested name specifier is stored.
- SpecifierKind getKind() const {
+ SpecifierKind getKind() const {
if (Specifier == 0)
return Global;
- return (SpecifierKind)Prefix.getInt();
+ return (SpecifierKind)Prefix.getInt();
}
/// \brief Retrieve the identifier stored in this nested name
@@ -149,7 +149,7 @@ public:
return 0;
}
-
+
/// \brief Retrieve the namespace stored in this nested name
/// specifier.
NamespaceDecl *getAsNamespace() const {
@@ -161,7 +161,7 @@ public:
/// \brief Retrieve the type stored in this nested name specifier.
Type *getAsType() const {
- if (Prefix.getInt() == TypeSpec ||
+ if (Prefix.getInt() == TypeSpec ||
Prefix.getInt() == TypeSpecWithTemplate)
return (Type *)Specifier;
@@ -192,11 +192,11 @@ public:
/// into a diagnostic with <<.
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
NestedNameSpecifier *NNS) {
- DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS),
+ DB.AddTaggedVal(reinterpret_cast<intptr_t>(NNS),
Diagnostic::ak_nestednamespec);
return DB;
}
-
+
}
#endif
diff --git a/include/clang/AST/ParentMap.h b/include/clang/AST/ParentMap.h
index c669991ccc..f826e1117b 100644
--- a/include/clang/AST/ParentMap.h
+++ b/include/clang/AST/ParentMap.h
@@ -17,7 +17,7 @@
namespace clang {
class Stmt;
class Expr;
-
+
class ParentMap {
void* Impl;
public:
@@ -30,7 +30,7 @@ public:
const Stmt *getParent(const Stmt* S) const {
return getParent(const_cast<Stmt*>(S));
}
-
+
const Stmt *getParentIgnoreParens(const Stmt *S) const {
return getParentIgnoreParens(const_cast<Stmt*>(S));
}
@@ -38,13 +38,13 @@ public:
bool hasParent(Stmt* S) const {
return getParent(S) != 0;
}
-
+
bool isConsumedExpr(Expr *E) const;
-
+
bool isConsumedExpr(const Expr *E) const {
return isConsumedExpr(const_cast<Expr*>(E));
}
};
-
+
} // end clang namespace
#endif
diff --git a/include/clang/AST/PrettyPrinter.h b/include/clang/AST/PrettyPrinter.h
index bc4c82f2be..0635ec5dcd 100644
--- a/include/clang/AST/PrettyPrinter.h
+++ b/include/clang/AST/PrettyPrinter.h
@@ -34,7 +34,7 @@ public:
/// declarations should be printed.
struct PrintingPolicy {
/// \brief Create a default printing policy for C.
- PrintingPolicy(const LangOptions &LO)
+ PrintingPolicy(const LangOptions &LO)
: Indentation(2), LangOpts(LO), SuppressSpecifiers(false),
SuppressTag(false), SuppressTagKind(false), SuppressScope(false),
Dump(false), ConstantArraySizeAsWritten(false) { }
diff --git a/include/clang/AST/RecordLayout.h b/include/clang/AST/RecordLayout.h
index 77e8553d74..66792d715d 100644
--- a/include/clang/AST/RecordLayout.h
+++ b/include/clang/AST/RecordLayout.h
@@ -22,38 +22,38 @@ namespace clang {
class RecordDecl;
class CXXRecordDecl;
-/// ASTRecordLayout -
+/// ASTRecordLayout -
/// This class contains layout information for one RecordDecl,
/// which is a struct/union/class. The decl represented must be a definition,
-/// not a forward declaration.
-/// This class is also used to contain layout information for one
+/// not a forward declaration.
+/// This class is also used to contain layout information for one
/// ObjCInterfaceDecl. FIXME - Find appropriate name.
/// These objects are managed by ASTContext.
class ASTRecordLayout {
/// Size - Size of record in bits.
uint64_t Size;
-
+
/// DataSize - Size of record in bits without tail padding.
uint64_t DataSize;
-
+
/// FieldOffsets - Array of field offsets in bits.
uint64_t *FieldOffsets;
-
+
// Alignment - Alignment of record in bits.
- unsigned Alignment;
-
+ unsigned Alignment;
+
// FieldCount - Number of fields.
unsigned FieldCount;
struct CXXRecordLayoutInfo {
- /// NonVirtualSize - The non-virtual size (in bits) of an object, which is
+ /// NonVirtualSize - The non-virtual size (in bits) of an object, which is
/// the size of the object without virtual bases.
uint64_t NonVirtualSize;
-
+
/// NonVirtualAlign - The non-virtual alignment (in bits) of an object,
/// which is the alignment of the object without virtual bases.
uint64_t NonVirtualAlign;
-
+
/// PrimaryBase - The primary base for our vtable.
const CXXRecordDecl *PrimaryBase;
/// PrimaryBase - Wether or not the primary base was a virtual base.
@@ -67,16 +67,16 @@ class ASTRecordLayout {
/// FIXME: This should really use a SmallPtrMap, once we have one in LLVM :)
llvm::DenseMap<const CXXRecordDecl *, uint64_t> VBaseOffsets;
};
-
- /// CXXInfo - If the record layout is for a C++ record, this will have
+
+ /// CXXInfo - If the record layout is for a C++ record, this will have
/// C++ specific information about the record.
CXXRecordLayoutInfo *CXXInfo;
-
+
friend class ASTContext;
friend class ASTRecordLayoutBuilder;
ASTRecordLayout(uint64_t size, unsigned alignment, unsigned datasize,
- const uint64_t *fieldoffsets, unsigned fieldcount)
+ const uint64_t *fieldoffsets, unsigned fieldcount)
: Size(size), DataSize(datasize), FieldOffsets(0), Alignment(alignment),
FieldCount(fieldcount), CXXInfo(0) {
if (FieldCount > 0) {
@@ -85,7 +85,7 @@ class ASTRecordLayout {
FieldOffsets[i] = fieldoffsets[i];
}
}
-
+
// Constructor for C++ records.
ASTRecordLayout(uint64_t size, unsigned alignment, uint64_t datasize,
const uint64_t *fieldoffsets, unsigned fieldcount,
@@ -101,7 +101,7 @@ class ASTRecordLayout {
for (unsigned i = 0; i < FieldCount; ++i)
FieldOffsets[i] = fieldoffsets[i];
}
-
+
CXXInfo->PrimaryBase = PB;
CXXInfo->PrimaryBaseWasVirtual = PBVirtual;
CXXInfo->NonVirtualSize = nonvirtualsize;
@@ -111,7 +111,7 @@ class ASTRecordLayout {
for (unsigned i = 0; i != vbasecount; ++i)
CXXInfo->VBaseOffsets[vbases[i]] = vbaseoffsets[i];
}
-
+
~ASTRecordLayout() {
delete [] FieldOffsets;
delete CXXInfo;
@@ -120,55 +120,55 @@ class ASTRecordLayout {
ASTRecordLayout(const ASTRecordLayout&); // DO NOT IMPLEMENT
void operator=(const ASTRecordLayout&); // DO NOT IMPLEMENT
public:
-
+
/// getAlignment - Get the record alignment in bits.
unsigned getAlignment() const { return Alignment; }
/// getSize - Get the record size in bits.
uint64_t getSize() const { return Size; }
-
+
/// getFieldCount - Get the number of fields in the layout.
unsigned getFieldCount() const { return FieldCount; }
-
+
/// getFieldOffset - Get the offset of the given field index, in
/// bits.
uint64_t getFieldOffset(unsigned FieldNo) const {
assert (FieldNo < FieldCount && "Invalid Field No");
return FieldOffsets[FieldNo];
}
-
+
/// getDataSize() - Get the record data size, which is the record size
/// without tail padding, in bits.
uint64_t getDataSize() const {
return DataSize;
}
-
- /// getNonVirtualSize - Get the non-virtual size (in bits) of an object,
+
+ /// getNonVirtualSize - Get the non-virtual size (in bits) of an object,
/// which is the size of the object without virtual bases.
- uint64_t getNonVirtualSize() const {
+ uint64_t getNonVirtualSize() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
-
+
return CXXInfo->NonVirtualSize;
}
-
+
/// getNonVirtualSize - Get the non-virtual alignment (in bits) of an object,
/// which is the alignment of the object without virtual bases.
unsigned getNonVirtualAlign() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
-
+
return CXXInfo->NonVirtualAlign;
}
-
+
/// getPrimaryBase - Get the primary base.
const CXXRecordDecl *getPrimaryBase() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
-
+
return CXXInfo->PrimaryBase;
}
/// getPrimaryBaseWasVirtual - Indicates if the primary base was virtual.
bool getPrimaryBaseWasVirtual() const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
-
+
return CXXInfo->PrimaryBaseWasVirtual;
}
@@ -176,7 +176,7 @@ public:
uint64_t getBaseClassOffset(const CXXRecordDecl *Base) const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!");
-
+
return CXXInfo->BaseOffsets[Base];
}
@@ -184,7 +184,7 @@ public:
uint64_t getVBaseClassOffset(const CXXRecordDecl *VBase) const {
assert(CXXInfo && "Record layout does not have C++ specific info!");
assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!");
-
+
return CXXInfo->VBaseOffsets[VBase];
}
};
diff --git a/include/clang/AST/Redeclarable.h b/include/clang/AST/Redeclarable.h
index ea36353bf2..5cd50686c5 100644
--- a/include/clang/AST/Redeclarable.h
+++ b/include/clang/AST/Redeclarable.h
@@ -26,10 +26,10 @@ protected:
struct DeclLink : public llvm::PointerIntPair<decl_type *, 1, bool> {
DeclLink(decl_type *D, bool isLatest)
: llvm::PointerIntPair<decl_type *, 1, bool>(D, isLatest) { }
-
+
typedef llvm::PointerIntPair<decl_type *, 1, bool> base_type;
- bool NextIsPrevious() const { return base_type::getInt() == false; }
+ bool NextIsPrevious() const { return base_type::getInt() == false; }
bool NextIsLatest() const { return base_type::getInt() == true; }
decl_type *getNext() const { return base_type::getPointer(); }
};
@@ -69,7 +69,7 @@ public:
return const_cast<decl_type *>(
static_cast<const decl_type*>(this))->getPreviousDeclaration();
}
-
+
/// \brief Return the first declaration of this declaration or itself if this
/// is the only declaration.
decl_type *getFirstDeclaration() {
@@ -91,7 +91,7 @@ public:
assert(First->RedeclLink.NextIsLatest() && "Expected first");
} else {
// Make this first.
- First = static_cast<decl_type*>(this);
+ First = static_cast<decl_type*>(this);
}
// First one will point to this one as latest.
@@ -131,10 +131,10 @@ public:
return tmp;
}
- friend bool operator==(redecl_iterator x, redecl_iterator y) {
+ friend bool operator==(redecl_iterator x, redecl_iterator y) {
return x.Current == y.Current;
}
- friend bool operator!=(redecl_iterator x, redecl_iterator y) {
+ friend bool operator!=(redecl_iterator x, redecl_iterator y) {
return x.Current != y.Current;
}
};
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index f34776373b..125279c1ed 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -39,21 +39,21 @@ namespace clang {
class SourceManager;
class StringLiteral;
class SwitchStmt;
-
+
//===----------------------------------------------------------------------===//
// ExprIterator - Iterators for iterating over Stmt* arrays that contain
// only Expr*. This is needed because AST nodes use Stmt* arrays to store
// references to children (to be compatible with StmtIterator).
//===----------------------------------------------------------------------===//
-
+
class Stmt;
class Expr;
-
+
class ExprIterator {
Stmt** I;
public:
ExprIterator(Stmt** i) : I(i) {}
- ExprIterator() : I(0) {}
+ ExprIterator() : I(0) {}
ExprIterator& operator++() { ++I; return *this; }
ExprIterator operator-(size_t i) { return I-i; }
ExprIterator operator+(size_t i) { return I+i; }
@@ -67,12 +67,12 @@ namespace clang {
bool operator>(const ExprIterator& R) const { return I > R.I; }
bool operator>=(const ExprIterator& R) const { return I >= R.I; }
};
-
+
class ConstExprIterator {
Stmt* const * I;
public:
ConstExprIterator(Stmt* const* i) : I(i) {}
- ConstExprIterator() : I(0) {}
+ ConstExprIterator() : I(0) {}
ConstExprIterator& operator++() { ++I; return *this; }
ConstExprIterator operator+(size_t i) { return I+i; }
ConstExprIterator operator-(size_t i) { return I-i; }
@@ -84,12 +84,12 @@ namespace clang {
bool operator!=(const ConstExprIterator& R) const { return I != R.I; }
bool operator>(const ConstExprIterator& R) const { return I > R.I; }
bool operator>=(const ConstExprIterator& R) const { return I >= R.I; }
- };
-
+ };
+
//===----------------------------------------------------------------------===//
// AST classes for statements.
//===----------------------------------------------------------------------===//
-
+
/// Stmt - This represents one statement.
///
class Stmt {
@@ -106,7 +106,7 @@ public:
private:
/// \brief The statement class.
const unsigned sClass : 8;
-
+
/// \brief The reference count for this statement.
unsigned RefCount : 24;
@@ -119,20 +119,20 @@ protected:
void operator delete(void* data) throw() {
assert(0 && "Stmts cannot be released with regular 'delete'.");
}
-
+
public:
// Only allow allocation of Stmts using the allocator in ASTContext
- // or by doing a placement new.
+ // or by doing a placement new.
void* operator new(size_t bytes, ASTContext& C,
unsigned alignment = 16) throw() {
return ::operator new(bytes, C, alignment);
}
-
+
void* operator new(size_t bytes, ASTContext* C,
unsigned alignment = 16) throw() {
return ::operator new(bytes, *C, alignment);
}
-
+
void* operator new(size_t bytes, void* mem) throw() {
return mem;
}
@@ -152,9 +152,9 @@ protected:
/// DestroyChildren - Invoked by destructors of subclasses of Stmt to
/// recursively release child AST nodes.
void DestroyChildren(ASTContext& Ctx);
-
+
/// \brief Construct an empty statement.
- explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
+ explicit Stmt(StmtClass SC, EmptyShell) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
@@ -164,18 +164,18 @@ protected:
/// Subclasses should override this method (not Destroy()) to
/// provide class-specific destruction.
virtual void DoDestroy(ASTContext &Ctx);
-
+
public:
- Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
+ Stmt(StmtClass SC) : sClass(SC), RefCount(1) {
if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
}
virtual ~Stmt() {}
-
+
/// \brief Destroy the current statement and its children.
- void Destroy(ASTContext &Ctx) {
+ void Destroy(ASTContext &Ctx) {
assert(RefCount >= 1);
if (--RefCount == 0)
- DoDestroy(Ctx);
+ DoDestroy(Ctx);
}
/// \brief Increases the reference count for this statement.
@@ -187,10 +187,10 @@ public:
++RefCount;
return this;
}
-
+
StmtClass getStmtClass() const { return (StmtClass)sClass; }
const char *getStmtClassName() const;
-
+
/// SourceLocation tokens are not useful in isolation - they are low level
/// value objects created/interpreted by SourceManager. We assume AST
/// clients will have a pointer to the respective SourceManager.
@@ -216,23 +216,23 @@ public:
/// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
/// back to its original source language syntax.
void dumpPretty(ASTContext& Context) const;
- void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper,
+ void printPretty(llvm::raw_ostream &OS, PrinterHelper *Helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0) const {
printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation);
}
void printPretty(llvm::raw_ostream &OS, ASTContext &Context,
- PrinterHelper *Helper,
+ PrinterHelper *Helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0) const;
-
+
/// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
/// works on systems with GraphViz (Mac OS X) or dot+gv installed.
void viewAST() const;
-
+
// Implement isa<T> support.
- static bool classof(const Stmt *) { return true; }
-
+ static bool classof(const Stmt *) { return true; }
+
/// hasImplicitControlFlow - Some statements (e.g. short circuited operations)
/// contain implicit control-flow in the order their subexpressions
/// are evaluated. This predicate returns true if this statement has
@@ -245,14 +245,14 @@ public:
/// AST node. This permits easy iteration over all nodes in the AST.
typedef StmtIterator child_iterator;
typedef ConstStmtIterator const_child_iterator;
-
+
virtual child_iterator child_begin() = 0;
virtual child_iterator child_end() = 0;
-
+
const_child_iterator child_begin() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_begin());
}
-
+
const_child_iterator child_end() const {
return const_child_iterator(const_cast<Stmt*>(this)->child_end());
}
@@ -266,7 +266,7 @@ public:
///
/// \brief Canonical whether the profile should be based on the canonical
/// representation of this statement (e.g., where non-type template
- /// parameters are identified by index/level rather than their
+ /// parameters are identified by index/level rather than their
/// declaration pointers) or the exact representation of the statement as
/// written in the source.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
@@ -275,18 +275,18 @@ public:
/// DeclStmt - Adaptor class for mixing declarations with statements and
/// expressions. For example, CompoundStmt mixes statements, expressions
-/// and declarations (variables, types). Another example is ForStmt, where
+/// and declarations (variables, types). Another example is ForStmt, where
/// the first statement can be an expression or a declaration.
///
class DeclStmt : public Stmt {
DeclGroupRef DG;
SourceLocation StartLoc, EndLoc;
-
+
public:
- DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
+ DeclStmt(DeclGroupRef dg, SourceLocation startLoc,
SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
StartLoc(startLoc), EndLoc(endLoc) {}
-
+
/// \brief Build an empty declaration statement.
explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
@@ -295,10 +295,10 @@ public:
bool isSingleDecl() const {
return DG.isSingleDecl();
}
-
+
const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
- Decl *getSingleDecl() { return DG.getSingleDecl(); }
-
+ Decl *getSingleDecl() { return DG.getSingleDecl(); }
+
const DeclGroupRef getDeclGroup() const { return DG; }
DeclGroupRef getDeclGroup() { return DG; }
void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
@@ -311,19 +311,19 @@ public:
SourceRange getSourceRange() const {
return SourceRange(StartLoc, EndLoc);
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DeclStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DeclStmtClass;
}
static bool classof(const DeclStmt *) { return true; }
-
+
// Iterators over subexpressions.
virtual child_iterator child_begin();
virtual child_iterator child_end();
-
+
typedef DeclGroupRef::iterator decl_iterator;
typedef DeclGroupRef::const_iterator const_decl_iterator;
-
+
decl_iterator decl_begin() { return DG.begin(); }
decl_iterator decl_end() { return DG.end(); }
const_decl_iterator decl_begin() const { return DG.begin(); }
@@ -344,12 +344,12 @@ public:
void setSemiLoc(SourceLocation L) { SemiLoc = L; }
virtual SourceRange getSourceRange() const { return SourceRange(SemiLoc); }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == NullStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == NullStmtClass;
}
static bool classof(const NullStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -362,24 +362,24 @@ class CompoundStmt : public Stmt {
unsigned NumStmts;
SourceLocation LBracLoc, RBracLoc;
public:
- CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts,
+ CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned numStmts,
SourceLocation LB, SourceLocation RB)
: Stmt(CompoundStmtClass), NumStmts(numStmts), LBracLoc(LB), RBracLoc(RB) {
if (NumStmts == 0) {
Body = 0;
return;
}
-
+
Body = new (C) Stmt*[NumStmts];
memcpy(Body, StmtStart, numStmts * sizeof(*Body));
- }
+ }
// \brief Build an empty compound statement.
explicit CompoundStmt(EmptyShell Empty)
: Stmt(CompoundStmtClass, Empty), Body(0), NumStmts(0) { }
void setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts);
-
+
bool body_empty() const { return NumStmts == 0; }
unsigned size() const { return NumStmts; }
@@ -407,25 +407,25 @@ public:
const_reverse_body_iterator body_rbegin() const {
return const_reverse_body_iterator(body_end());
}
-
+
const_reverse_body_iterator body_rend() const {
return const_reverse_body_iterator(body_begin());
}
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(LBracLoc, RBracLoc);
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(LBracLoc, RBracLoc);
}
-
+
SourceLocation getLBracLoc() const { return LBracLoc; }
void setLBracLoc(SourceLocation L) { LBracLoc = L; }
SourceLocation getRBracLoc() const { return RBracLoc; }
void setRBracLoc(SourceLocation L) { RBracLoc = L; }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CompoundStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CompoundStmtClass;
}
static bool classof(const CompoundStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -439,7 +439,7 @@ protected:
SwitchCase *NextSwitchCase;
SwitchCase(StmtClass SC) : Stmt(SC), NextSwitchCase(0) {}
-
+
public:
const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
@@ -450,19 +450,19 @@ public:
Stmt *getSubStmt() { return v_getSubStmt(); }
virtual SourceRange getSourceRange() const { return SourceRange(); }
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CaseStmtClass ||
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CaseStmtClass ||
T->getStmtClass() == DefaultStmtClass;
}
static bool classof(const SwitchCase *) { return true; }
protected:
- virtual Stmt* v_getSubStmt() = 0;
+ virtual Stmt* v_getSubStmt() = 0;
};
class CaseStmt : public SwitchCase {
enum { SUBSTMT, LHS, RHS, END_EXPR };
- Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
+ Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
// GNU "case 1 ... 4" extension
SourceLocation CaseLoc;
SourceLocation EllipsisLoc;
@@ -471,7 +471,7 @@ class CaseStmt : public SwitchCase {
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
- SourceLocation ellipsisLoc, SourceLocation colonLoc)
+ SourceLocation ellipsisLoc, SourceLocation colonLoc)
: SwitchCase(CaseStmtClass) {
SubExprs[SUBSTMT] = 0;
SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
@@ -495,32 +495,32 @@ public:
Expr *getRHS() { return reinterpret_cast<Expr*>(SubExprs[RHS]); }
Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
- const Expr *getLHS() const {
- return reinterpret_cast<const Expr*>(SubExprs[LHS]);
+ const Expr *getLHS() const {
+ return reinterpret_cast<const Expr*>(SubExprs[LHS]);
}
- const Expr *getRHS() const {
- return reinterpret_cast<const Expr*>(SubExprs[RHS]);
+ const Expr *getRHS() const {
+ return reinterpret_cast<const Expr*>(SubExprs[RHS]);
}
const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
-
-
+
+
virtual SourceRange getSourceRange() const {
// Handle deeply nested case statements with iteration instead of recursion.
const CaseStmt *CS = this;
while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
CS = CS2;
-
- return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
+
+ return SourceRange(CaseLoc, CS->getSubStmt()->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == CaseStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == CaseStmtClass;
}
static bool classof(const CaseStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -532,7 +532,7 @@ class DefaultStmt : public SwitchCase {
SourceLocation ColonLoc;
virtual Stmt* v_getSubStmt() { return getSubStmt(); }
public:
- DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
+ DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) :
SwitchCase(DefaultStmtClass), SubStmt(substmt), DefaultLoc(DL),
ColonLoc(CL) {}
@@ -548,14 +548,14 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(DefaultLoc, SubStmt->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(DefaultLoc, SubStmt->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DefaultStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DefaultStmtClass;
}
static bool classof(const DefaultStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -566,13 +566,13 @@ class LabelStmt : public Stmt {
Stmt *SubStmt;
SourceLocation IdentLoc;
public:
- LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt)
- : Stmt(LabelStmtClass), Label(label),
+ LabelStmt(SourceLocation IL, IdentifierInfo *label, Stmt *substmt)
+ : Stmt(LabelStmtClass), Label(label),
SubStmt(substmt), IdentLoc(IL) {}
// \brief Build an empty label statement.
explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
-
+
SourceLocation getIdentLoc() const { return IdentLoc; }
IdentifierInfo *getID() const { return Label; }
void setID(IdentifierInfo *II) { Label = II; }
@@ -582,14 +582,14 @@ public:
void setIdentLoc(SourceLocation L) { IdentLoc = L; }
void setSubStmt(Stmt *SS) { SubStmt = SS; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(IdentLoc, SubStmt->getLocEnd());
- }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == LabelStmtClass;
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(IdentLoc, SubStmt->getLocEnd());
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == LabelStmtClass;
}
static bool classof(const LabelStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -604,8 +604,8 @@ class IfStmt : public Stmt {
SourceLocation IfLoc;
SourceLocation ElseLoc;
public:
- IfStmt(SourceLocation IL, Expr *cond, Stmt *then,
- SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
+ IfStmt(SourceLocation IL, Expr *cond, Stmt *then,
+ SourceLocation EL = SourceLocation(), Stmt *elsev = 0)
: Stmt(IfStmtClass) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[THEN] = then;
@@ -613,14 +613,14 @@ public:
IfLoc = IL;
ElseLoc = EL;
}
-
+
/// \brief Build an empty if/then/else statement
explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
const Stmt *getThen() const { return SubExprs[THEN]; }
- void setThen(Stmt *S) { SubExprs[THEN] = S; }
+ void setThen(Stmt *S) { SubExprs[THEN] = S; }
const Stmt *getElse() const { return SubExprs[ELSE]; }
void setElse(Stmt *S) { SubExprs[ELSE] = S; }
@@ -633,18 +633,18 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; }
- virtual SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
else
return SourceRange(IfLoc, SubExprs[THEN]->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == IfStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == IfStmtClass;
}
static bool classof(const IfStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -654,20 +654,20 @@ public:
///
class SwitchStmt : public Stmt {
enum { COND, BODY, END_EXPR };
- Stmt* SubExprs[END_EXPR];
+ Stmt* SubExprs[END_EXPR];
// This points to a linked list of case and default statements.
SwitchCase *FirstCase;
SourceLocation SwitchLoc;
-
+
protected:
virtual void DoDestroy(ASTContext &Ctx);
-
+
public:
SwitchStmt(Expr *cond) : Stmt(SwitchStmtClass), FirstCase(0) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = NULL;
}
-
+
/// \brief Build a empty switch statement.
explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
@@ -680,7 +680,7 @@ public:
Stmt *getBody() { return SubExprs[BODY]; }
void setBody(Stmt *S) { SubExprs[BODY] = S; }
SwitchCase *getSwitchCaseList() { return FirstCase; }
-
+
/// \brief Set the case list for this switch statement.
///
/// The caller is responsible for incrementing the retain counts on
@@ -690,24 +690,24 @@ public:
SourceLocation getSwitchLoc() const { return SwitchLoc; }
void setSwitchLoc(SourceLocation L) { SwitchLoc = L; }
- void setBody(Stmt *S, SourceLocation SL) {
- SubExprs[BODY] = S;
+ void setBody(Stmt *S, SourceLocation SL) {
+ SubExprs[BODY] = S;
SwitchLoc = SL;
- }
+ }
void addSwitchCase(SwitchCase *SC) {
assert(!SC->getNextSwitchCase() && "case/default already added to a switch");
SC->Retain();
SC->setNextSwitchCase(FirstCase);
FirstCase = SC;
}
- virtual SourceRange getSourceRange() const {
- return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == SwitchStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == SwitchStmtClass;
}
static bool classof(const SwitchStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -726,7 +726,7 @@ public:
SubExprs[BODY] = body;
WhileLoc = WL;
}
-
+
/// \brief Build an empty while statement.
explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
@@ -740,14 +740,14 @@ public:
SourceLocation getWhileLoc() const { return WhileLoc; }
void setWhileLoc(SourceLocation L) { WhileLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == WhileStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == WhileStmtClass;
}
static bool classof(const WhileStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -768,16 +768,16 @@ public:
: Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
SubExprs[BODY] = body;
- }
+ }
/// \brief Build an empty do-while statement.
explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
-
+
Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
Stmt *getBody() { return SubExprs[BODY]; }
- const Stmt *getBody() const { return SubExprs[BODY]; }
+ const Stmt *getBody() const { return SubExprs[BODY]; }
void setBody(Stmt *S) { SubExprs[BODY] = S; }
SourceLocation getDoLoc() const { return DoLoc; }
@@ -788,11 +788,11 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(DoLoc, RParenLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(DoLoc, RParenLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == DoStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == DoStmtClass;
}
static bool classof(const DoStmt *) { return true; }
@@ -814,7 +814,7 @@ class ForStmt : public Stmt {
public:
ForStmt(Stmt *Init, Expr *Cond, Expr *Inc, Stmt *Body, SourceLocation FL,
- SourceLocation LP, SourceLocation RP)
+ SourceLocation LP, SourceLocation RP)
: Stmt(ForStmtClass) {
SubExprs[INIT] = Init;
SubExprs[COND] = reinterpret_cast<Stmt*>(Cond);
@@ -824,7 +824,7 @@ public:
LParenLoc = LP;
RParenLoc = RP;
}
-
+
/// \brief Build an empty for statement.
explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
@@ -850,19 +850,19 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ForStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ForStmtClass;
}
static bool classof(const ForStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// GotoStmt - This represents a direct goto.
///
class GotoStmt : public Stmt {
@@ -870,9 +870,9 @@ class GotoStmt : public Stmt {
SourceLocation GotoLoc;
SourceLocation LabelLoc;
public:
- GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL)
+ GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL)
: Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
-
+
/// \brief Build an empty goto statement.
explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
@@ -884,14 +884,14 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(GotoLoc, LabelLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(GotoLoc, LabelLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == GotoStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == GotoStmtClass;
}
static bool classof(const GotoStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -904,20 +904,20 @@ class IndirectGotoStmt : public Stmt {
SourceLocation StarLoc;
Stmt *Target;
public:
- IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
+ IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc,
Expr *target)
: Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
Target((Stmt*)target) {}
/// \brief Build an empty indirect goto statement.
- explicit IndirectGotoStmt(EmptyShell Empty)
+ explicit IndirectGotoStmt(EmptyShell Empty)
: Stmt(IndirectGotoStmtClass, Empty) { }
-
+
void setGotoLoc(SourceLocation L) { GotoLoc = L; }
SourceLocation getGotoLoc() const { return GotoLoc; }
void setStarLoc(SourceLocation L) { StarLoc = L; }
SourceLocation getStarLoc() const { return StarLoc; }
-
+
Expr *getTarget();
const Expr *getTarget() const;
void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
@@ -925,12 +925,12 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(GotoLoc, Target->getLocEnd());
}
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == IndirectGotoStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == IndirectGotoStmtClass;
}
static bool classof(const IndirectGotoStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -943,22 +943,22 @@ class ContinueStmt : public Stmt {
SourceLocation ContinueLoc;
public:
ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
-
+
/// \brief Build an empty continue statement.
explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
SourceLocation getContinueLoc() const { return ContinueLoc; }
void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(ContinueLoc);
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ContinueLoc);
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ContinueStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ContinueStmtClass;
}
static bool classof(const ContinueStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -970,7 +970,7 @@ class BreakStmt : public Stmt {
SourceLocation BreakLoc;
public:
BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {}
-
+
/// \brief Build an empty break statement.
explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
@@ -979,11 +979,11 @@ public:
virtual SourceRange getSourceRange() const { return SourceRange(BreakLoc); }
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == BreakStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == BreakStmtClass;
}
static bool classof(const BreakStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1003,7 +1003,7 @@ class ReturnStmt : public Stmt {
Stmt *RetExpr;
SourceLocation RetLoc;
public:
- ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass),
+ ReturnStmt(SourceLocation RL, Expr *E = 0) : Stmt(ReturnStmtClass),
RetExpr((Stmt*) E), RetLoc(RL) {}
/// \brief Build an empty return expression.
@@ -1017,12 +1017,12 @@ public:
void setReturnLoc(SourceLocation L) { RetLoc = L; }
virtual SourceRange getSourceRange() const;
-
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ReturnStmtClass;
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ReturnStmtClass;
}
static bool classof(const ReturnStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
@@ -1036,18 +1036,18 @@ class AsmStmt : public Stmt {
bool IsSimple;
bool IsVolatile;
-
+
unsigned NumOutputs;
unsigned NumInputs;
-
+
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<StringLiteral*, 4> Constraints;
llvm::SmallVector<Stmt*, 4> Exprs;
llvm::SmallVector<StringLiteral*, 4> Clobbers;
public:
- AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
- unsigned numoutputs, unsigned numinputs,
+ AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
+ unsigned numoutputs, unsigned numinputs,
std::string *names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc);
@@ -1090,10 +1090,10 @@ public:
: MyKind(Operand), Str(), OperandNo(OpNo) {
Str += Modifier;
}
-
+
bool isString() const { return MyKind == String; }
bool isOperand() const { return MyKind == Operand; }
-
+
const std::string &getString() const {
assert(isString());
return Str;
@@ -1103,7 +1103,7 @@ public:
assert(isOperand());
return OperandNo;
}
-
+
/// getModifier - Get the modifier for this operand, if present. This
/// returns '\0' if there was no modifier.
char getModifier() const {
@@ -1111,16 +1111,16 @@ public:
return Str[0];
}
};
-
+
/// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
/// it into pieces. If the asm string is erroneous, emit errors and return
/// true, otherwise return false. This handles canonicalization and
/// translation of strings from GCC syntax to LLVM IR syntax, and handles
- //// flattening of named references like %[foo] to Operand AsmStringPiece's.
+ //// flattening of named references like %[foo] to Operand AsmStringPiece's.
unsigned AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece> &Pieces,
ASTContext &C, unsigned &DiagOffs) const;
-
-
+
+
//===--- Output operands ---===//
unsigned getNumOutputs() const { return NumOutputs; }
@@ -1133,72 +1133,72 @@ public:
/// output operand. All output constraints are known to be non-empty (either
/// '=' or '+').
std::string getOutputConstraint(unsigned i) const;
-
+
const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
return Constraints[i];
}
StringLiteral *getOutputConstraintLiteral(unsigned i) {
return Constraints[i];
}
-
-
+
+
Expr *getOutputExpr(unsigned i);
-
+
const Expr *getOutputExpr(unsigned i) const {
return const_cast<AsmStmt*>(this)->getOutputExpr(i);
}
-
+
/// isOutputPlusConstraint - Return true if the specified output constraint
/// is a "+" constraint (which is both an input and an output) or false if it
/// is an "=" constraint (just an output).
bool isOutputPlusConstraint(unsigned i) const {
return getOutputConstraint(i)[0] == '+';
}
-
+
/// getNumPlusOperands - Return the number of output operands that have a "+"
/// constraint.
unsigned getNumPlusOperands() const;
-
+
//===--- Input operands ---===//
-
- unsigned getNumInputs() const { return NumInputs; }
-
+
+ unsigned getNumInputs() const { return NumInputs; }
+
const std::string &getInputName(unsigned i) const {
return Names[i + NumOutputs];
}
-
+
/// getInputConstraint - Return the specified input constraint. Unlike output
/// constraints, these can be empty.
std::string getInputConstraint(unsigned i) const;
-
+
const StringLiteral *getInputConstraintLiteral(unsigned i) const {
return Constraints[i + NumOutputs];
}
StringLiteral *getInputConstraintLiteral(unsigned i) {
return Constraints[i + NumOutputs];
}
-
-
+
+
Expr *getInputExpr(unsigned i);
-
+
const Expr *getInputExpr(unsigned i) const {
return const_cast<AsmStmt*>(this)->getInputExpr(i);
}
void setOutputsAndInputs(unsigned NumOutputs,
- unsigned NumInputs,
+ unsigned NumInputs,
const std::string *Names,
StringLiteral **Constraints,
Stmt **Exprs);
//===--- Other ---===//
-
+
/// getNamedOperand - Given a symbolic operand reference like %[foo],
/// translate this into a numeric value needed to reference the same operand.
/// This returns -1 if the operand name is invalid.
int getNamedOperand(const std::string &SymbolicName) const;
-
+
unsigned getNumClobbers() const { return Clobbers.size(); }
StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
@@ -1208,62 +1208,62 @@ public:
virtual SourceRange getSourceRange() const {
return SourceRange(AsmLoc, RParenLoc);
}
-
+
static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;}
static bool classof(const AsmStmt *) { return true; }
-
+
// Input expr iterators.
-
+
typedef ExprIterator inputs_iterator;
typedef ConstExprIterator const_inputs_iterator;
-
+
inputs_iterator begin_inputs() {
return Exprs.data() + NumOutputs;
}
-
+
inputs_iterator end_inputs() {
return Exprs.data() + NumOutputs + NumInputs;
}
-
+
const_inputs_iterator begin_inputs() const {
return Exprs.data() + NumOutputs;
}
-
+
const_inputs_iterator end_inputs() const {
return Exprs.data() + NumOutputs + NumInputs;
}
-
+
// Output expr iterators.
-
+
typedef ExprIterator outputs_iterator;
typedef ConstExprIterator const_outputs_iterator;
-
+
outputs_iterator begin_outputs() {
return Exprs.data();
}
outputs_iterator end_outputs() {
return Exprs.data() + NumOutputs;
}
-
+
const_outputs_iterator begin_outputs() const {
return Exprs.data();
}
const_outputs_iterator end_outputs() const {
return Exprs.data() + NumOutputs;
}
-
+
// Input name iterator.
-
+
const std::string *begin_output_names() const {
return &Names[0];
}
-
+
const std::string *end_output_names() const {
return &Names[0] + NumOutputs;
}
-
- // Child iterators
-
+
+ // Child iterators
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
diff --git a/include/clang/AST/StmtGraphTraits.h b/include/clang/AST/StmtGraphTraits.h
index 1bfac6a958..25d015287b 100644
--- a/include/clang/AST/StmtGraphTraits.h
+++ b/include/clang/AST/StmtGraphTraits.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines a template specialization of llvm::GraphTraits to
+// This file defines a template specialization of llvm::GraphTraits to
// treat ASTs (Stmt*) as graphs
//
//===----------------------------------------------------------------------===//
@@ -20,7 +20,7 @@
#include "llvm/ADT/DepthFirstIterator.h"
namespace llvm {
-
+
//template <typename T> struct GraphTraits;
@@ -28,23 +28,23 @@ template <> struct GraphTraits<clang::Stmt*> {
typedef clang::Stmt NodeType;
typedef clang::Stmt::child_iterator ChildIteratorType;
typedef llvm::df_iterator<clang::Stmt*> nodes_iterator;
-
+
static NodeType* getEntryNode(clang::Stmt* S) { return S; }
-
+
static inline ChildIteratorType child_begin(NodeType* N) {
if (N) return N->child_begin();
else return ChildIteratorType();
}
-
+
static inline ChildIteratorType child_end(NodeType* N) {
if (N) return N->child_end();
else return ChildIteratorType();
}
-
+
static nodes_iterator nodes_begin(clang::Stmt* S) {
return df_begin(S);
}
-
+
static nodes_iterator nodes_end(clang::Stmt* S) {
return df_end(S);
}
@@ -55,29 +55,29 @@ template <> struct GraphTraits<const clang::Stmt*> {
typedef const clang::Stmt NodeType;
typedef clang::Stmt::const_child_iterator ChildIteratorType;
typedef llvm::df_iterator<const clang::Stmt*> nodes_iterator;
-
+
static NodeType* getEntryNode(const clang::Stmt* S) { return S; }
-
+
static inline ChildIteratorType child_begin(NodeType* N) {
if (N) return N->child_begin();
- else return ChildIteratorType();
+ else return ChildIteratorType();
}
-
+
static inline ChildIteratorType child_end(NodeType* N) {
if (N) return N->child_end();
else return ChildIteratorType();
}
-
+
static nodes_iterator nodes_begin(const clang::Stmt* S) {
return df_begin(S);
}
-
+
static nodes_iterator nodes_end(const clang::Stmt* S) {
return df_end(S);
}
};
-
+
} // end namespace llvm
#endif
diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h
index 2a4adc6f79..2d523fffce 100644
--- a/include/clang/AST/StmtIterator.h
+++ b/include/clang/AST/StmtIterator.h
@@ -23,45 +23,45 @@ namespace clang {
class Stmt;
class Decl;
class VariableArrayType;
-
+
class StmtIteratorBase {
protected:
enum { DeclMode = 0x1, SizeOfTypeVAMode = 0x2, DeclGroupMode = 0x3,
Flags = 0x3 };
-
+
union { Stmt** stmt; Decl* decl; Decl** DGI; };
- uintptr_t RawVAPtr;
+ uintptr_t RawVAPtr;
Decl** DGE;
bool inDecl() const {
return (RawVAPtr & Flags) == DeclMode;
}
-
+
bool inDeclGroup() const {
return (RawVAPtr & Flags) == DeclGroupMode;
}
-
- bool inSizeOfTypeVA() const {
+
+ bool inSizeOfTypeVA() const {
return (RawVAPtr & Flags) == SizeOfTypeVAMode;
}
-
+
bool inStmt() const {
return (RawVAPtr & Flags) == 0;
}
-
+
VariableArrayType* getVAPtr() const {
return reinterpret_cast<VariableArrayType*>(RawVAPtr & ~Flags);
}
-
+
void setVAPtr(VariableArrayType* P) {
- assert (inDecl() || inDeclGroup() || inSizeOfTypeVA());
+ assert (inDecl() || inDeclGroup() || inSizeOfTypeVA());
RawVAPtr = reinterpret_cast<uintptr_t>(P) | (RawVAPtr & Flags);
}
-
+
void NextDecl(bool ImmediateAdvance = true);
bool HandleDecl(Decl* D);
void NextVA();
-
+
Stmt*& GetDeclExpr() const;
StmtIteratorBase(Stmt** s) : stmt(s), RawVAPtr(0) {}
@@ -70,22 +70,22 @@ protected:
StmtIteratorBase(Decl** dgi, Decl** dge);
StmtIteratorBase() : stmt(NULL), RawVAPtr(0) {}
};
-
-
+
+
template <typename DERIVED, typename REFERENCE>
-class StmtIteratorImpl : public StmtIteratorBase,
+class StmtIteratorImpl : public StmtIteratorBase,
public std::iterator<std::forward_iterator_tag,
- REFERENCE, ptrdiff_t,
- REFERENCE, REFERENCE> {
+ REFERENCE, ptrdiff_t,
+ REFERENCE, REFERENCE> {
protected:
StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {}
public:
- StmtIteratorImpl() {}
+ StmtIteratorImpl() {}
StmtIteratorImpl(Stmt** s) : StmtIteratorBase(s) {}
StmtIteratorImpl(Decl** dgi, Decl** dge) : StmtIteratorBase(dgi, dge) {}
StmtIteratorImpl(Decl* d) : StmtIteratorBase(d) {}
StmtIteratorImpl(VariableArrayType* t) : StmtIteratorBase(t) {}
-
+
DERIVED& operator++() {
if (inDecl() || inDeclGroup()) {
if (getVAPtr()) NextVA();
@@ -95,36 +95,36 @@ public:
NextVA();
else
++stmt;
-
+
return static_cast<DERIVED&>(*this);
}
-
+
DERIVED operator++(int) {
DERIVED tmp = static_cast<DERIVED&>(*this);
operator++();
return tmp;
}
-
+
bool operator==(const DERIVED& RHS) const {
return stmt == RHS.stmt && RawVAPtr == RHS.RawVAPtr;
}
-
+
bool operator!=(const DERIVED& RHS) const {
return stmt != RHS.stmt || RawVAPtr != RHS.RawVAPtr;
}
-
- REFERENCE operator*() const {
+
+ REFERENCE operator*() const {
return (REFERENCE) (inStmt() ? *stmt : GetDeclExpr());
}
-
- REFERENCE operator->() const { return operator*(); }
+
+ REFERENCE operator->() const { return operator*(); }
};
struct StmtIterator : public StmtIteratorImpl<StmtIterator,Stmt*&> {
explicit StmtIterator() : StmtIteratorImpl<StmtIterator,Stmt*&>() {}
StmtIterator(Stmt** S) : StmtIteratorImpl<StmtIterator,Stmt*&>(S) {}
- StmtIterator(Decl** dgi, Decl** dge)
+ StmtIterator(Decl** dgi, Decl** dge)
: StmtIteratorImpl<StmtIterator,Stmt*&>(dgi, dge) {}
StmtIterator(VariableArrayType* t):StmtIteratorImpl<StmtIterator,Stmt*&>(t) {}
@@ -133,10 +133,10 @@ struct StmtIterator : public StmtIteratorImpl<StmtIterator,Stmt*&> {
struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
const Stmt*> {
- explicit ConstStmtIterator() :
+ explicit ConstStmtIterator() :
StmtIteratorImpl<ConstStmtIterator,const Stmt*>() {}
-
- ConstStmtIterator(const StmtIterator& RHS) :
+
+ ConstStmtIterator(const StmtIterator& RHS) :
StmtIteratorImpl<ConstStmtIterator,const Stmt*>(RHS) {}
};
diff --git a/include/clang/AST/StmtObjC.h b/include/clang/AST/StmtObjC.h
index 8ae7071744..3fd8f1672d 100644
--- a/include/clang/AST/StmtObjC.h
+++ b/include/clang/AST/StmtObjC.h
@@ -27,47 +27,47 @@ class ObjCForCollectionStmt : public Stmt {
SourceLocation ForLoc;
SourceLocation RParenLoc;
public:
- ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body,
+ ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body,
SourceLocation FCL, SourceLocation RPL);
- explicit ObjCForCollectionStmt(EmptyShell Empty) :
+ explicit ObjCForCollectionStmt(EmptyShell Empty) :
Stmt(ObjCForCollectionStmtClass, Empty) { }
-
+
Stmt *getElement() { return SubExprs[ELEM]; }
- Expr *getCollection() {
- return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);
+ Expr *getCollection() {
+ return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);
}
Stmt *getBody() { return SubExprs[BODY]; }
-
+
const Stmt *getElement() const { return SubExprs[ELEM]; }
- const Expr *getCollection() const {
+ const Expr *getCollection() const {
return reinterpret_cast<Expr*>(SubExprs[COLLECTION]);
}
const Stmt *getBody() const { return SubExprs[BODY]; }
-
+
void setElement(Stmt *S) { SubExprs[ELEM] = S; }
- void setCollection(Expr *E) {
+ void setCollection(Expr *E) {
SubExprs[COLLECTION] = reinterpret_cast<Stmt*>(E);
}
void setBody(Stmt *S) { SubExprs[BODY] = S; }
-
+
SourceLocation getForLoc() const { return ForLoc; }
void setForLoc(SourceLocation Loc) { ForLoc = Loc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
}
- static bool classof(const Stmt *T) {
- return T->getStmtClass() == ObjCForCollectionStmtClass;
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == ObjCForCollectionStmtClass;
}
static bool classof(const ObjCForCollectionStmt *) { return true; }
-
+
// Iterators
virtual child_iterator child_begin();
virtual child_iterator child_end();
-};
-
+};
+
/// ObjCAtCatchStmt - This represents objective-c's @catch statement.
class ObjCAtCatchStmt : public Stmt {
private:
@@ -78,95 +78,95 @@ private:
public:
ObjCAtCatchStmt(SourceLocation atCatchLoc, SourceLocation rparenloc,
- ParmVarDecl *catchVarDecl,
+ ParmVarDecl *catchVarDecl,
Stmt *atCatchStmt, Stmt *atCatchList);
- explicit ObjCAtCatchStmt(EmptyShell Empty) :
+ explicit ObjCAtCatchStmt(EmptyShell Empty) :
Stmt(ObjCAtCatchStmtClass, Empty) { }
-
+
const Stmt *getCatchBody() const { return SubExprs[BODY]; }
Stmt *getCatchBody() { return SubExprs[BODY]; }
void setCatchBody(Stmt *S) { SubExprs[BODY] = S; }
-
+
const ObjCAtCatchStmt *getNextCatchStmt() const {
return static_cast<const ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
}
- ObjCAtCatchStmt *getNextCatchStmt() {
+ ObjCAtCatchStmt *getNextCatchStmt() {
return static_cast<ObjCAtCatchStmt*>(SubExprs[NEXT_CATCH]);
}
void setNextCatchStmt(Stmt *S) { SubExprs[NEXT_CATCH] = S; }
-
- const ParmVarDecl *getCatchParamDecl() const {
- return ExceptionDecl;
+
+ const ParmVarDecl *getCatchParamDecl() const {
+ return ExceptionDecl;
}
- ParmVarDecl *getCatchParamDecl() {
- return ExceptionDecl;
+ ParmVarDecl *getCatchParamDecl() {
+ return ExceptionDecl;
}
void setCatchParamDecl(ParmVarDecl *D) { ExceptionDecl = D; }
-
+
SourceLocation getAtCatchLoc() const { return AtCatchLoc; }
void setAtCatchLoc(SourceLocation Loc) { AtCatchLoc = Loc; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd());
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd());
}
bool hasEllipsis() const { return getCatchParamDecl() == 0; }
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtCatchStmtClass;
}
static bool classof(const ObjCAtCatchStmt *) { return true; }
-
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
-/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement
+
+/// ObjCAtFinallyStmt - This represent objective-c's @finally Statement
class ObjCAtFinallyStmt : public Stmt {
Stmt *AtFinallyStmt;
- SourceLocation AtFinallyLoc;
+ SourceLocation AtFinallyLoc;
public:
ObjCAtFinallyStmt(SourceLocation atFinallyLoc, Stmt *atFinallyStmt)
- : Stmt(ObjCAtFinallyStmtClass),
+ : Stmt(ObjCAtFinallyStmtClass),
AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {}
- explicit ObjCAtFinallyStmt(EmptyShell Empty) :
+ explicit ObjCAtFinallyStmt(EmptyShell Empty) :
Stmt(ObjCAtFinallyStmtClass, Empty) { }
-
+
const Stmt *getFinallyBody() const { return AtFinallyStmt; }
Stmt *getFinallyBody() { return AtFinallyStmt; }
void setFinallyBody(Stmt *S) { AtFinallyStmt = S; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
}
-
+
SourceLocation getAtFinallyLoc() const { return AtFinallyLoc; }
void setAtFinallyLoc(SourceLocation Loc) { AtFinallyLoc = Loc; }
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtFinallyStmtClass;
}
static bool classof(const ObjCAtFinallyStmt *) { return true; }
-
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
-/// ObjCAtTryStmt - This represent objective-c's over-all
+
+/// ObjCAtTryStmt - This represent objective-c's over-all
/// @try ... @catch ... @finally statement.
class ObjCAtTryStmt : public Stmt {
private:
enum { TRY, CATCH, FINALLY, END_EXPR };
- Stmt* SubStmts[END_EXPR];
-
- SourceLocation AtTryLoc;
+ Stmt* SubStmts[END_EXPR];
+
+ SourceLocation AtTryLoc;
public:
- ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
- Stmt *atCatchStmt,
+ ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
+ Stmt *atCatchStmt,
Stmt *atFinallyStmt)
: Stmt(ObjCAtTryStmtClass) {
SubStmts[TRY] = atTryStmt;
@@ -174,41 +174,41 @@ public:
SubStmts[FINALLY] = atFinallyStmt;
AtTryLoc = atTryLoc;
}
- explicit ObjCAtTryStmt(EmptyShell Empty) :
+ explicit ObjCAtTryStmt(EmptyShell Empty) :
Stmt(ObjCAtTryStmtClass, Empty) { }
-
+
SourceLocation getAtTryLoc() const { return AtTryLoc; }
void setAtTryLoc(SourceLocation Loc) { AtTryLoc = Loc; }
-
+
const Stmt *getTryBody() const { return SubStmts[TRY]; }
Stmt *getTryBody() { return SubStmts[TRY]; }
void setTryBody(Stmt *S) { SubStmts[TRY] = S; }
-
- const ObjCAtCatchStmt *getCatchStmts() const {
- return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
+
+ const ObjCAtCatchStmt *getCatchStmts() const {
+ return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
}
- ObjCAtCatchStmt *getCatchStmts() {
- return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
+ ObjCAtCatchStmt *getCatchStmts() {
+ return dyn_cast_or_null<ObjCAtCatchStmt>(SubStmts[CATCH]);
}
void setCatchStmts(Stmt *S) { SubStmts[CATCH] = S; }
-
- const ObjCAtFinallyStmt *getFinallyStmt() const {
- return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
+
+ const ObjCAtFinallyStmt *getFinallyStmt() const {
+ return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
}
- ObjCAtFinallyStmt *getFinallyStmt() {
- return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
+ ObjCAtFinallyStmt *getFinallyStmt() {
+ return dyn_cast_or_null<ObjCAtFinallyStmt>(SubStmts[FINALLY]);
}
void setFinallyStmt(Stmt *S) { SubStmts[FINALLY] = S; }
- virtual SourceRange getSourceRange() const {
- return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd());
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd());
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtTryStmtClass;
}
static bool classof(const ObjCAtTryStmt *) { return true; }
-
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
@@ -223,7 +223,7 @@ private:
enum { SYNC_EXPR, SYNC_BODY, END_EXPR };
Stmt* SubStmts[END_EXPR];
SourceLocation AtSynchronizedLoc;
-
+
public:
ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Stmt *synchExpr,
Stmt *synchBody)
@@ -232,41 +232,41 @@ public:
SubStmts[SYNC_BODY] = synchBody;
AtSynchronizedLoc = atSynchronizedLoc;
}
- explicit ObjCAtSynchronizedStmt(EmptyShell Empty) :
+ explicit ObjCAtSynchronizedStmt(EmptyShell Empty) :
Stmt(ObjCAtSynchronizedStmtClass, Empty) { }
-
+
SourceLocation getAtSynchronizedLoc() const { return AtSynchronizedLoc; }
void setAtSynchronizedLoc(SourceLocation Loc) { AtSynchronizedLoc = Loc; }
-
+
const CompoundStmt *getSynchBody() const {
return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);
}
- CompoundStmt *getSynchBody() {
- return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);
+ CompoundStmt *getSynchBody() {
+ return reinterpret_cast<CompoundStmt*>(SubStmts[SYNC_BODY]);
}
void setSynchBody(Stmt *S) { SubStmts[SYNC_BODY] = S; }
-
- const Expr *getSynchExpr() const {
- return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
+
+ const Expr *getSynchExpr() const {
+ return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
}
- Expr *getSynchExpr() {
- return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
+ Expr *getSynchExpr() {
+ return reinterpret_cast<Expr*>(SubStmts[SYNC_EXPR]);
}
void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; }
-
- virtual SourceRange getSourceRange() const {
- return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd());
+
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd());
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtSynchronizedStmtClass;
}
static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
-
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
-
+
/// ObjCAtThrowStmt - This represents objective-c's @throw statement.
class ObjCAtThrowStmt : public Stmt {
Stmt *Throw;
@@ -276,28 +276,28 @@ public:
: Stmt(ObjCAtThrowStmtClass), Throw(throwExpr) {
AtThrowLoc = atThrowLoc;
}
- explicit ObjCAtThrowStmt(EmptyShell Empty) :
+ explicit ObjCAtThrowStmt(EmptyShell Empty) :
Stmt(ObjCAtThrowStmtClass, Empty) { }
-
+
const Expr *getThrowExpr() const { return reinterpret_cast<Expr*>(Throw); }
Expr *getThrowExpr() { return reinterpret_cast<Expr*>(Throw); }
void setThrowExpr(Stmt *S) { Throw = S; }
-
+
SourceLocation getThrowLoc() { return AtThrowLoc; }
void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; }
-
+
virtual SourceRange getSourceRange() const {
if (Throw)
- return SourceRange(AtThrowLoc, Throw->getLocEnd());
- else
+ return SourceRange(AtThrowLoc, Throw->getLocEnd());
+ else
return SourceRange(AtThrowLoc);
}
-
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtThrowStmtClass;
}
static bool classof(const ObjCAtThrowStmt *) { return true; }
-
+
virtual child_iterator child_begin();
virtual child_iterator child_end();
};
diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h
index 4f4066ab86..3a525507da 100644
--- a/include/clang/AST/StmtVisitor.h
+++ b/include/clang/AST/StmtVisitor.h
@@ -20,17 +20,17 @@
#include "clang/AST/StmtObjC.h"
namespace clang {
-
+
#define DISPATCH(NAME, CLASS) \
return static_cast<ImplClass*>(this)->Visit ## NAME(static_cast<CLASS*>(S))
-
+
/// StmtVisitor - This class implements a simple visitor for Stmt subclasses.
/// Since Expr derives from Stmt, this also includes support for visiting Exprs.
template<typename ImplClass, typename RetTy=void>
class StmtVisitor {
public:
RetTy Visit(Stmt *S) {
-
+
// 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.
@@ -53,7 +53,7 @@ public:
case BinaryOperator::GE: DISPATCH(BinGE, BinaryOperator);
case BinaryOperator::EQ: DISPATCH(BinEQ, BinaryOperator);
case BinaryOperator::NE: DISPATCH(BinNE, BinaryOperator);
-
+
case BinaryOperator::And: DISPATCH(BinAnd, BinaryOperator);
case BinaryOperator::Xor: DISPATCH(BinXor, BinaryOperator);
case BinaryOperator::Or : DISPATCH(BinOr, BinaryOperator);
@@ -101,7 +101,7 @@ public:
case UnaryOperator::OffsetOf: DISPATCH(UnaryOffsetOf, UnaryOperator);
}
}
-
+
// Top switch stmt: dispatch to VisitFooStmt for each FooStmt.
switch (S->getStmtClass()) {
default: assert(0 && "Unknown stmt kind!");
@@ -110,7 +110,7 @@ public:
#include "clang/AST/StmtNodes.def"
}
}
-
+
// 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) \
@@ -127,7 +127,7 @@ public:
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)
@@ -148,7 +148,7 @@ public:
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) \
@@ -158,13 +158,13 @@ public:
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
-
+
// Base case, ignore it. :)
RetTy VisitStmt(Stmt *Node) { return RetTy(); }
};
diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h
index 67d3f73c37..66ff34cf1e 100644
--- a/include/clang/AST/TemplateName.h
+++ b/include/clang/AST/TemplateName.h
@@ -61,7 +61,7 @@ class OverloadedFunctionDecl;
/// only be understood in the context of
class TemplateName {
typedef llvm::PointerUnion4<TemplateDecl *, OverloadedFunctionDecl *,
- QualifiedTemplateName *,
+ QualifiedTemplateName *,
DependentTemplateName *> StorageType;
StorageType Storage;
@@ -80,25 +80,25 @@ public:
/// \brief Determine whether this template name is NULL.
bool isNull() const { return Storage.isNull(); }
-
+
/// \brief Retrieve the the underlying template declaration that
/// this template name refers to, if known.
///
/// \returns The template declaration that this template name refers
/// to, if any. If the template name does not refer to a specific
- /// declaration because it is a dependent name, or if it refers to a
+ /// declaration because it is a dependent name, or if it refers to a
/// set of function templates, returns NULL.
TemplateDecl *getAsTemplateDecl() const;
- /// \brief Retrieve the the underlying, overloaded function template
+ /// \brief Retrieve the the underlying, overloaded function template
// declarations that this template name refers to, if known.
///
- /// \returns The set of overloaded function templates that this template
- /// name refers to, if known. If the template name does not refer to a
+ /// \returns The set of overloaded function templates that this template
+ /// name refers to, if known. If the template name does not refer to a
/// specific set of function templates because it is a dependent name or
/// refers to a single template, returns NULL.
OverloadedFunctionDecl *getAsOverloadedFunctionDecl() const;
-
+
/// \brief Retrieve the underlying qualified template name
/// structure, if any.
QualifiedTemplateName *getAsQualifiedTemplateName() const {
@@ -137,8 +137,8 @@ public:
void *getAsVoidPointer() const { return Storage.getOpaqueValue(); }
/// \brief Build a template name from a void pointer.
- static TemplateName getFromVoidPointer(void *Ptr) {
- return TemplateName(Ptr);
+ static TemplateName getFromVoidPointer(void *Ptr) {
+ return TemplateName(Ptr);
}
};
@@ -171,14 +171,14 @@ class QualifiedTemplateName : public llvm::FoldingSetNode {
QualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword,
TemplateDecl *Template)
- : Qualifier(NNS, TemplateKeyword? 1 : 0),
+ : Qualifier(NNS, TemplateKeyword? 1 : 0),
Template(reinterpret_cast<NamedDecl *>(Template)) { }
QualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword,
OverloadedFunctionDecl *Template)
- : Qualifier(NNS, TemplateKeyword? 1 : 0),
+ : Qualifier(NNS, TemplateKeyword? 1 : 0),
Template(reinterpret_cast<NamedDecl *>(Template)) { }
-
+
public:
/// \brief Return the nested name specifier that qualifies this name.
NestedNameSpecifier *getQualifier() const { return Qualifier.getPointer(); }
@@ -190,22 +190,22 @@ public:
/// \brief The template declaration or set of overloaded functions that
/// that qualified name refers to.
NamedDecl *getDecl() const { return Template; }
-
+
/// \brief The template declaration to which this qualified name
/// refers, or NULL if this qualified name refers to a set of overloaded
/// function templates.
TemplateDecl *getTemplateDecl() const;
/// \brief The set of overloaded function tempaltes to which this qualified
- /// name refers, or NULL if this qualified name refers to a single
+ /// name refers, or NULL if this qualified name refers to a single
/// template declaration.
OverloadedFunctionDecl *getOverloadedFunctionDecl() const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getQualifier(), hasTemplateKeyword(), getDecl());
}
- static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS,
+ static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS,
bool TemplateKeyword, NamedDecl *Template) {
ID.AddPointer(NNS);
ID.AddBoolean(TemplateKeyword);
@@ -239,11 +239,11 @@ class DependentTemplateName : public llvm::FoldingSetNode {
friend class ASTContext;
- DependentTemplateName(NestedNameSpecifier *Qualifier,
+ DependentTemplateName(NestedNameSpecifier *Qualifier,
const IdentifierInfo *Name)
: Qualifier(Qualifier), Name(Name), CanonicalTemplateName(this) { }
- DependentTemplateName(NestedNameSpecifier *Qualifier,
+ DependentTemplateName(NestedNameSpecifier *Qualifier,
const IdentifierInfo *Name,
TemplateName Canon)
: Qualifier(Qualifier), Name(Name), CanonicalTemplateName(Canon) { }
@@ -260,7 +260,7 @@ public:
Profile(ID, getQualifier(), getName());
}
- static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS,
+ static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS,
const IdentifierInfo *Name) {
ID.AddPointer(NNS);
ID.AddPointer(Name);
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 4cebdcdf21..4ebda908a3 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -92,7 +92,7 @@ public:
Volatile = 0x4,
CVRFlags = Const|Restrict|Volatile
};
-
+
enum GCAttrTypes {
GCNone = 0,
Weak,
@@ -101,23 +101,23 @@ public:
// 24 bits should be enough for anyone.
static const unsigned MaxAddressSpace = 0xffffffu;
-
+
QualType() {}
-
+
QualType(const Type *Ptr, unsigned Quals)
: Value(const_cast<Type*>(Ptr), Quals) {}
unsigned getCVRQualifiers() const { return Value.getInt(); }
void setCVRQualifiers(unsigned Quals) { Value.setInt(Quals); }
Type *getTypePtr() const { return Value.getPointer(); }
-
+
void *getAsOpaquePtr() const { return Value.getOpaqueValue(); }
static QualType getFromOpaquePtr(void *Ptr) {
QualType T;
T.Value.setFromOpaqueValue(Ptr);
return T;
}
-
+
Type &operator*() const {
return *getTypePtr();
}
@@ -125,7 +125,7 @@ public:
Type *operator->() const {
return getTypePtr();
}
-
+
/// isNull - Return true if this QualType doesn't point to a type yet.
bool isNull() const {
return getTypePtr() == 0;
@@ -142,7 +142,7 @@ public:
}
bool isConstant(ASTContext& Ctx) const;
-
+
/// addConst/addVolatile/addRestrict - add the specified type qual to this
/// QualType.
void addConst() { Value.setInt(Value.getInt() | Const); }
@@ -163,12 +163,12 @@ public:
QualType withConst() const { return getWithAdditionalQualifiers(Const); }
QualType withVolatile() const { return getWithAdditionalQualifiers(Volatile);}
QualType withRestrict() const { return getWithAdditionalQualifiers(Restrict);}
-
+
QualType getUnqualifiedType() const;
bool isMoreQualifiedThan(QualType Other) const;
bool isAtLeastAsQualifiedAs(QualType Other) const;
QualType getNonReferenceType() const;
-
+
/// getDesugaredType - Return the specified type with any "sugar" removed from
/// the type. This takes off typedefs, typeof's etc. If the outer level of
/// the type is already concrete, it returns it unmodified. This is similar
@@ -194,19 +194,19 @@ public:
}
void getAsStringInternal(std::string &Str,
const PrintingPolicy &Policy) const;
-
+
void dump(const char *s) const;
void dump() const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddPointer(getAsOpaquePtr());
}
public:
-
+
/// getAddressSpace - Return the address space of this type.
inline unsigned getAddressSpace() const;
-
+
/// GCAttrTypesAttr - Returns gc attribute of this type.
inline QualType::GCAttrTypes getObjCGCAttr() const;
@@ -238,7 +238,7 @@ template<> struct simplify_type<const ::clang::QualType> {
};
template<> struct simplify_type< ::clang::QualType>
: public simplify_type<const ::clang::QualType> {};
-
+
// Teach SmallPtrSet that QualType is "basically a pointer".
template<>
class PointerLikeTypeTraits<clang::QualType> {
@@ -252,7 +252,7 @@ public:
// CVR qualifiers go in low bits.
enum { NumLowBitsAvailable = 0 };
};
-
+
} // end namespace llvm
namespace clang {
@@ -316,15 +316,15 @@ protected:
virtual ~Type() {}
virtual void Destroy(ASTContext& C);
friend class ASTContext;
-
+
public:
TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); }
-
+
bool isCanonical() const { return CanonicalType.getTypePtr() == this; }
- /// Types are partitioned into 3 broad categories (C99 6.2.5p1):
+ /// Types are partitioned into 3 broad categories (C99 6.2.5p1):
/// object types, function types, and incomplete types.
-
+
/// \brief Determines whether the type describes an object in memory.
///
/// Note that this definition of object type corresponds to the C++
@@ -336,7 +336,7 @@ public:
/// isIncompleteType - Return true if this is an incomplete type.
/// A type that can describe objects, but which lacks information needed to
/// determine its size (e.g. void, or a fwd declared struct). Clients of this
- /// routine will need to determine if the size is actually required.
+ /// routine will need to determine if the size is actually required.
bool isIncompleteType() const;
/// isIncompleteOrObjectType - Return true if this is an incomplete or object
@@ -351,13 +351,13 @@ public:
/// isVariablyModifiedType (C99 6.7.5.2p2) - Return true for variable array
/// types that have a non-constant expression. This does not include "[]".
bool isVariablyModifiedType() const;
-
+
/// Helper methods to distinguish type categories. All type predicates
/// operate on the canonical type, ignoring typedefs and qualifiers.
/// isSpecificBuiltinType - Test for a particular builtin type.
bool isSpecificBuiltinType(unsigned K) const;
-
+
/// isIntegerType() does *not* include complex integers (a GCC extension).
/// isComplexIntegerType() can be used to test for complex integers.
bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum)
@@ -366,7 +366,7 @@ public:
bool isCharType() const;
bool isWideCharType() const;
bool isIntegralType() const;
-
+
/// Floating point categories.
bool isRealFloatingType() const; // C99 6.2.5p10 (float, double, long double)
/// isComplexType() does *not* include complex integers (a GCC extension).
@@ -380,7 +380,7 @@ public:
bool isDerivedType() const; // C99 6.2.5p20
bool isScalarType() const; // C99 6.2.5p21 (arithmetic + pointers)
bool isAggregateType() const;
-
+
// Type Predicates: Check to see if this type is structurally the specified
// type, ignoring typedefs and qualifiers.
bool isFunctionType() const;
@@ -402,8 +402,8 @@ public:
bool isVariableArrayType() const;
bool isDependentSizedArrayType() const;
bool isRecordType() const;
- bool isClassType() const;
- bool isStructureType() const;
+ bool isClassType() const;
+ bool isStructureType() const;
bool isUnionType() const;
bool isComplexIntegerType() const; // GCC _Complex integer type.
bool isVectorType() const; // GCC vector type.
@@ -422,7 +422,7 @@ public:
bool isNullPtrType() const; // C++0x nullptr_t
/// isDependentType - Whether this type is a dependent type, meaning
- /// that its definition somehow depends on a template parameter
+ /// that its definition somehow depends on a template parameter
/// (C++ [temp.dep.type]).
bool isDependentType() const { return Dependent; }
bool isOverloadableType() const;
@@ -435,7 +435,7 @@ public:
/// hasObjCPointerRepresentation - Whether this type can represent
/// an objective pointer type for the purpose of GC'ability
- bool hasObjCPointerRepresentation() const;
+ bool hasObjCPointerRepresentation() const;
// Type Checking Functions: Check to see if this type is structurally the
// specified type, ignoring typedefs and qualifiers, and return a pointer to
@@ -462,14 +462,14 @@ public:
const ObjCInterfaceType *getAsObjCQualifiedInterfaceType() const;
const TemplateTypeParmType *getAsTemplateTypeParmType() const;
const CXXRecordDecl *getCXXRecordDeclForPointerType() const;
-
+
// Member-template getAs<specific type>'. This scheme will eventually
// replace the specific getAsXXXX methods above.
template <typename T> const T *getAs() const;
-
+
const TemplateSpecializationType *
getAsTemplateSpecializationType() const;
-
+
/// getAsPointerToObjCInterfaceType - If this is a pointer to an ObjC
/// interface, return the interface type, otherwise return null.
const ObjCInterfaceType *getAsPointerToObjCInterfaceType() const;
@@ -478,11 +478,11 @@ public:
/// element type of the array, potentially with type qualifiers missing.
/// This method should never be used when type qualifiers are meaningful.
const Type *getArrayElementTypeNoTypeQual() const;
-
+
/// getPointeeType - If this is a pointer, ObjC object pointer, or block
/// pointer, this returns the respective pointee.
QualType getPointeeType() const;
-
+
/// getDesugaredType - Return the specified type with any "sugar" removed from
/// the type. This takes off typedefs, typeof's etc. If the outer level of
/// the type is already concrete, it returns it unmodified. This is similar
@@ -490,7 +490,7 @@ public:
/// example, it returns "T*" as "T*", (not as "int*"), because the pointer is
/// concrete.
QualType getDesugaredType(bool ForDisplay = false) const;
-
+
/// More type predicates useful for type checking/promotion
bool isPromotableIntegerType() const; // C99 6.3.1.1p2
@@ -517,12 +517,12 @@ public:
QualType getCanonicalTypeInternal() const { return CanonicalType; }
void dump() const;
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const = 0;
static bool classof(const Type *) { return true; }
};
-/// ExtQualType - TR18037 (C embedded extensions) 6.2.5p26
+/// ExtQualType - TR18037 (C embedded extensions) 6.2.5p26
/// This supports all kinds of type attributes; including,
/// address space qualified types, objective-c's __weak and
/// __strong attributes.
@@ -537,7 +537,7 @@ class ExtQualType : public Type, public llvm::FoldingSetNode {
unsigned AddressSpace;
/// GC __weak/__strong attributes
QualType::GCAttrTypes GCAttrType;
-
+
ExtQualType(Type *Base, QualType CanonicalPtr, unsigned AddrSpace,
QualType::GCAttrTypes gcAttr) :
Type(ExtQual, CanonicalPtr, Base->isDependentType()), BaseType(Base),
@@ -551,19 +551,19 @@ public:
QualType::GCAttrTypes getObjCGCAttr() const { return GCAttrType; }
unsigned getAddressSpace() const { return AddressSpace; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getBaseType(), AddressSpace, GCAttrType);
}
- static void Profile(llvm::FoldingSetNodeID &ID, Type *Base,
+ static void Profile(llvm::FoldingSetNodeID &ID, Type *Base,
unsigned AddrSpace, QualType::GCAttrTypes gcAttr) {
ID.AddPointer(Base);
ID.AddInteger(AddrSpace);
ID.AddInteger(gcAttr);
}
-
+
static bool classof(const Type *T) { return T->getTypeClass() == ExtQual; }
static bool classof(const ExtQualType *) { return true; }
};
@@ -637,7 +637,7 @@ public:
}
bool operator==(QualifierSet& Other) { return Mask == Other.Mask; }
-
+
private:
void setAddressSpace(unsigned space) {
assert(space <= MaxAddressSpace);
@@ -668,7 +668,7 @@ class BuiltinType : public Type {
public:
enum Kind {
Void,
-
+
Bool, // This is bool and/or _Bool.
Char_U, // This is 'char' for targets where char is unsigned.
UChar, // This is explicitly qualified unsigned char.
@@ -679,7 +679,7 @@ public:
ULong,
ULongLong,
UInt128, // __uint128_t
-
+
Char_S, // This is 'char' for targets where char is signed.
SChar, // This is explicitly qualified signed char.
WChar, // This is 'wchar_t' for C++.
@@ -688,14 +688,14 @@ public:
Long,
LongLong,
Int128, // __int128_t
-
+
Float, Double, LongDouble,
NullPtr, // This is the type of C++0x 'nullptr'.
Overload, // This represents the type of an overloaded function declaration.
Dependent, // This represents the type of a type-dependent expression.
-
+
UndeducedAuto, // In C++0x, this represents the type of an auto variable
// that has not been deduced yet.
ObjCId, // This represents the ObjC 'id' type.
@@ -704,16 +704,16 @@ public:
private:
Kind TypeKind;
public:
- BuiltinType(Kind K)
- : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent)),
+ BuiltinType(Kind K)
+ : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent)),
TypeKind(K) {}
-
+
Kind getKind() const { return TypeKind; }
const char *getName(const LangOptions &LO) const;
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
static bool classof(const BuiltinType *) { return true; }
};
@@ -728,14 +728,14 @@ private:
public:
FixedWidthIntType(unsigned W, bool S) : Type(FixedWidthInt, QualType(), false),
Width(W), Signed(S) {}
-
+
unsigned getWidth() const { return Width; }
bool isSigned() const { return Signed; }
const char *getName() const;
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
static bool classof(const Type *T) { return T->getTypeClass() == FixedWidthInt; }
static bool classof(const FixedWidthIntType *) { return true; }
};
@@ -746,23 +746,23 @@ public:
class ComplexType : public Type, public llvm::FoldingSetNode {
QualType ElementType;
ComplexType(QualType Element, QualType CanonicalPtr) :
- Type(Complex, CanonicalPtr, Element->isDependentType()),
+ Type(Complex, CanonicalPtr, Element->isDependentType()),
ElementType(Element) {
}
friend class ASTContext; // ASTContext creates these.
public:
QualType getElementType() const { return ElementType; }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType Element) {
ID.AddPointer(Element.getAsOpaquePtr());
}
-
+
static bool classof(const Type *T) { return T->getTypeClass() == Complex; }
static bool classof(const ComplexType *) { return true; }
};
@@ -777,10 +777,10 @@ class PointerType : public Type, public llvm::FoldingSetNode {
}
friend class ASTContext; // ASTContext creates these.
public:
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
QualType getPointeeType() const { return PointeeType; }
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -789,7 +789,7 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) {
ID.AddPointer(Pointee.getAsOpaquePtr());
}
-
+
static bool classof(const Type *T) { return T->getTypeClass() == Pointer; }
static bool classof(const PointerType *) { return true; }
};
@@ -801,27 +801,27 @@ public:
class BlockPointerType : public Type, public llvm::FoldingSetNode {
QualType PointeeType; // Block is some kind of pointer type
BlockPointerType(QualType Pointee, QualType CanonicalCls) :
- Type(BlockPointer, CanonicalCls, Pointee->isDependentType()),
+ Type(BlockPointer, CanonicalCls, Pointee->isDependentType()),
PointeeType(Pointee) {
}
friend class ASTContext; // ASTContext creates these.
public:
-
+
// Get the pointee type. Pointee is required to always be a function type.
QualType getPointeeType() const { return PointeeType; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getPointeeType());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee) {
ID.AddPointer(Pointee.getAsOpaquePtr());
}
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == BlockPointer;
+
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == BlockPointer;
}
static bool classof(const BlockPointerType *) { return true; }
};
@@ -861,7 +861,7 @@ class LValueReferenceType : public ReferenceType {
}
friend class ASTContext; // ASTContext creates these
public:
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) {
@@ -878,7 +878,7 @@ class RValueReferenceType : public ReferenceType {
}
friend class ASTContext; // ASTContext creates these
public:
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) {
@@ -907,7 +907,7 @@ public:
const Type *getClass() const { return Class; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -939,15 +939,15 @@ public:
private:
/// ElementType - The element type of the array.
QualType ElementType;
-
+
// NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum
/// NOTE: These fields are packed into the bitfields space in the Type class.
unsigned SizeModifier : 2;
-
+
/// IndexTypeQuals - Capture qualifiers in declarations like:
/// 'int X[static restrict 4]'. For function parameters only.
unsigned IndexTypeQuals : 3;
-
+
protected:
// C++ [temp.dep.type]p1:
// A type is dependent if it is...
@@ -966,7 +966,7 @@ public:
return ArraySizeModifier(SizeModifier);
}
unsigned getIndexTypeQualifier() const { return IndexTypeQuals; }
-
+
static bool classof(const Type *T) {
return T->getTypeClass() == ConstantArray ||
T->getTypeClass() == ConstantArrayWithExpr ||
@@ -984,7 +984,7 @@ public:
/// type is 'int' and the size is 404.
class ConstantArrayType : public ArrayType {
llvm::APInt Size; // Allows us to unique the type.
-
+
ConstantArrayType(QualType et, QualType can, const llvm::APInt &size,
ArraySizeModifier sm, unsigned tq)
: ArrayType(ConstantArray, et, can, sm, tq),
@@ -996,11 +996,11 @@ protected:
friend class ASTContext; // ASTContext creates these.
public:
const llvm::APInt &getSize() const { return Size; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getElementType(), getSize(),
+ Profile(ID, getElementType(), getSize(),
getSizeModifier(), getIndexTypeQualifier());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
@@ -1096,20 +1096,20 @@ class IncompleteArrayType : public ArrayType {
: ArrayType(IncompleteArray, et, can, sm, tq) {}
friend class ASTContext; // ASTContext creates these.
public:
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
- static bool classof(const Type *T) {
- return T->getTypeClass() == IncompleteArray;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == IncompleteArray;
}
static bool classof(const IncompleteArrayType *) { return true; }
-
+
friend class StmtIteratorBase;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getSizeModifier(), getIndexTypeQualifier());
}
-
+
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
ArraySizeModifier SizeMod, unsigned TypeQuals) {
ID.AddPointer(ET.getAsOpaquePtr());
@@ -1134,8 +1134,8 @@ public:
/// }
///
class VariableArrayType : public ArrayType {
- /// SizeExpr - An assignment expression. VLA's are only permitted within
- /// a function block.
+ /// SizeExpr - An assignment expression. VLA's are only permitted within
+ /// a function block.
Stmt *SizeExpr;
/// Brackets - The left and right array brackets.
SourceRange Brackets;
@@ -1149,7 +1149,7 @@ class VariableArrayType : public ArrayType {
virtual void Destroy(ASTContext& C);
public:
- Expr *getSizeExpr() const {
+ Expr *getSizeExpr() const {
// We use C-style casts instead of cast<> here because we do not wish
// to have a dependency of Type.h on Stmt.h/Expr.h.
return (Expr*) SizeExpr;
@@ -1157,17 +1157,17 @@ public:
SourceRange getBracketsRange() const { return Brackets; }
SourceLocation getLBracketLoc() const { return Brackets.getBegin(); }
SourceLocation getRBracketLoc() const { return Brackets.getEnd(); }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == VariableArray;
+
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == VariableArray;
}
static bool classof(const VariableArrayType *) { return true; }
-
+
friend class StmtIteratorBase;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
assert(0 && "Cannnot unique VariableArrayTypes.");
}
@@ -1176,7 +1176,7 @@ public:
/// DependentSizedArrayType - This type represents an array type in
/// C++ whose size is a value-dependent expression. For example:
/// @code
-/// template<typename T, int Size>
+/// template<typename T, int Size>
/// class array {
/// T data[Size];
/// };
@@ -1186,14 +1186,14 @@ public:
/// become either a ConstantArrayType or a VariableArrayType.
class DependentSizedArrayType : public ArrayType {
ASTContext &Context;
-
+
/// SizeExpr - An assignment expression that will instantiate to the
/// size of the array.
Stmt *SizeExpr;
/// Brackets - The left and right array brackets.
SourceRange Brackets;
-
- DependentSizedArrayType(ASTContext &Context, QualType et, QualType can,
+
+ DependentSizedArrayType(ASTContext &Context, QualType et, QualType can,
Expr *e, ArraySizeModifier sm, unsigned tq,
SourceRange brackets)
: ArrayType(DependentSizedArray, et, can, sm, tq),
@@ -1202,7 +1202,7 @@ class DependentSizedArrayType : public ArrayType {
virtual void Destroy(ASTContext& C);
public:
- Expr *getSizeExpr() const {
+ Expr *getSizeExpr() const {
// We use C-style casts instead of cast<> here because we do not wish
// to have a dependency of Type.h on Stmt.h/Expr.h.
return (Expr*) SizeExpr;
@@ -1210,25 +1210,25 @@ public:
SourceRange getBracketsRange() const { return Brackets; }
SourceLocation getLBracketLoc() const { return Brackets.getBegin(); }
SourceLocation getRBracketLoc() const { return Brackets.getEnd(); }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == DependentSizedArray;
+
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == DependentSizedArray;
}
static bool classof(const DependentSizedArrayType *) { return true; }
-
+
friend class StmtIteratorBase;
-
-
+
+
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, Context, getElementType(),
+ Profile(ID, Context, getElementType(),
getSizeModifier(), getIndexTypeQualifier(), getSizeExpr());
}
-
- static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
- QualType ET, ArraySizeModifier SizeMod,
+
+ static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
+ QualType ET, ArraySizeModifier SizeMod,
unsigned TypeQuals, Expr *E);
};
@@ -1246,11 +1246,11 @@ class DependentSizedExtVectorType : public Type, public llvm::FoldingSetNode {
/// ElementType - The element type of the array.
QualType ElementType;
SourceLocation loc;
-
- DependentSizedExtVectorType(ASTContext &Context, QualType ElementType,
+
+ DependentSizedExtVectorType(ASTContext &Context, QualType ElementType,
QualType can, Expr *SizeExpr, SourceLocation loc)
- : Type (DependentSizedExtVector, can, true),
- Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
+ : Type (DependentSizedExtVector, can, true),
+ Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
loc(loc) {}
friend class ASTContext;
virtual void Destroy(ASTContext& C);
@@ -1260,62 +1260,62 @@ public:
QualType getElementType() const { return ElementType; }
SourceLocation getAttributeLoc() const { return loc; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == DependentSizedExtVector;
+
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == DependentSizedExtVector;
}
- static bool classof(const DependentSizedExtVectorType *) { return true; }
+ static bool classof(const DependentSizedExtVectorType *) { return true; }
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Context, getElementType(), getSizeExpr());
}
-
+
static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
QualType ElementType, Expr *SizeExpr);
};
-
+
/// VectorType - GCC generic vector type. This type is created using
-/// __attribute__((vector_size(n)), where "n" specifies the vector size in
-/// bytes. Since the constructor takes the number of vector elements, the
+/// __attribute__((vector_size(n)), where "n" specifies the vector size in
+/// bytes. Since the constructor takes the number of vector elements, the
/// client is responsible for converting the size into the number of elements.
class VectorType : public Type, public llvm::FoldingSetNode {
protected:
/// ElementType - The element type of the vector.
QualType ElementType;
-
+
/// NumElements - The number of elements in the vector.
unsigned NumElements;
-
+
VectorType(QualType vecType, unsigned nElements, QualType canonType) :
- Type(Vector, canonType, vecType->isDependentType()),
- ElementType(vecType), NumElements(nElements) {}
- VectorType(TypeClass tc, QualType vecType, unsigned nElements,
- QualType canonType)
- : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType),
- NumElements(nElements) {}
+ Type(Vector, canonType, vecType->isDependentType()),
+ ElementType(vecType), NumElements(nElements) {}
+ VectorType(TypeClass tc, QualType vecType, unsigned nElements,
+ QualType canonType)
+ : Type(tc, canonType, vecType->isDependentType()), ElementType(vecType),
+ NumElements(nElements) {}
friend class ASTContext; // ASTContext creates these.
public:
-
+
QualType getElementType() const { return ElementType; }
- unsigned getNumElements() const { return NumElements; }
+ unsigned getNumElements() const { return NumElements; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getNumElements(), getTypeClass());
}
- static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
+ static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
unsigned NumElements, TypeClass TypeClass) {
ID.AddPointer(ElementType.getAsOpaquePtr());
ID.AddInteger(NumElements);
ID.AddInteger(TypeClass);
}
- static bool classof(const Type *T) {
- return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector;
}
static bool classof(const VectorType *) { return true; }
};
@@ -1327,7 +1327,7 @@ public:
/// points, colors, and textures (modeled after OpenGL Shading Language).
class ExtVectorType : public VectorType {
ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) :
- VectorType(ExtVector, vecType, nElements, canonType) {}
+ VectorType(ExtVector, vecType, nElements, canonType) {}
friend class ASTContext; // ASTContext creates these.
public:
static int getPointAccessorIdx(char c) {
@@ -1366,22 +1366,22 @@ public:
case 'f': return 15;
}
}
-
+
static int getAccessorIdx(char c) {
if (int idx = getPointAccessorIdx(c)+1) return idx-1;
return getNumericAccessorIdx(c);
}
-
+
bool isAccessorWithinNumElements(char c) const {
if (int idx = getAccessorIdx(c)+1)
return unsigned(idx-1) < NumElements;
return false;
}
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
- static bool classof(const Type *T) {
- return T->getTypeClass() == ExtVector;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == ExtVector;
}
static bool classof(const ExtVectorType *) { return true; }
};
@@ -1405,7 +1405,7 @@ class FunctionType : public Type {
/// NoReturn - Indicates if the function type is attribute noreturn.
unsigned NoReturn : 1;
-
+
// The type returned by the function.
QualType ResultType;
protected:
@@ -1418,11 +1418,11 @@ protected:
bool getSubClassData() const { return SubClassData; }
unsigned getTypeQuals() const { return TypeQuals; }
public:
-
+
QualType getResultType() const { return ResultType; }
bool getNoReturnAttr() const { return NoReturn; }
-
+
static bool classof(const Type *T) {
return T->getTypeClass() == FunctionNoProto ||
T->getTypeClass() == FunctionProto;
@@ -1435,13 +1435,13 @@ public:
class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode {
FunctionNoProtoType(QualType Result, QualType Canonical,
bool NoReturn = false)
- : FunctionType(FunctionNoProto, Result, false, 0, Canonical,
+ : FunctionType(FunctionNoProto, Result, false, 0, Canonical,
/*Dependent=*/false, NoReturn) {}
friend class ASTContext; // ASTContext creates these.
public:
// No additional state past what FunctionType provides.
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -1452,7 +1452,7 @@ public:
ID.AddInteger(NoReturn);
ID.AddPointer(ResultType.getAsOpaquePtr());
}
-
+
static bool classof(const Type *T) {
return T->getTypeClass() == FunctionNoProto;
}
@@ -1480,7 +1480,7 @@ class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode {
bool hasAnyExs, const QualType *ExArray,
unsigned numExs, QualType Canonical, bool NoReturn)
: FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical,
- (Result->isDependentType() ||
+ (Result->isDependentType() ||
hasAnyDependentType(ArgArray, numArgs)), NoReturn),
NumArgs(numArgs), NumExceptions(numExs), HasExceptionSpec(hasExs),
AnyExceptionSpec(hasAnyExs) {
@@ -1528,14 +1528,14 @@ public:
assert(i < NumExceptions && "Invalid exception number!");
return exception_begin()[i];
}
- bool hasEmptyExceptionSpec() const {
- return hasExceptionSpec() && !hasAnyExceptionSpec() &&
+ bool hasEmptyExceptionSpec() const {
+ return hasExceptionSpec() && !hasAnyExceptionSpec() &&
getNumExceptions() == 0;
}
bool isVariadic() const { return getSubClassData(); }
unsigned getTypeQuals() const { return FunctionType::getTypeQuals(); }
-
+
typedef const QualType *arg_type_iterator;
arg_type_iterator arg_type_begin() const {
return reinterpret_cast<const QualType *>(this+1);
@@ -1551,7 +1551,7 @@ public:
return exception_begin() + NumExceptions;
}
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) {
@@ -1572,15 +1572,15 @@ public:
class TypedefType : public Type {
TypedefDecl *Decl;
protected:
- TypedefType(TypeClass tc, TypedefDecl *D, QualType can)
+ TypedefType(TypeClass tc, TypedefDecl *D, QualType can)
: Type(tc, can, can->isDependentType()), Decl(D) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
-
+
TypedefDecl *getDecl() const { return Decl; }
-
+
/// LookThroughTypedefs - Return the ultimate type this typedef corresponds to
/// potentially looking through *all* consecutive typedefs. This returns the
/// sum of the type qualifiers, so if you have:
@@ -1588,8 +1588,8 @@ public:
/// typedef volatile A B;
/// looking through the typedefs for B will give you "const volatile A".
QualType LookThroughTypedefs() const;
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
@@ -1599,50 +1599,50 @@ public:
/// TypeOfExprType (GCC extension).
class TypeOfExprType : public Type {
Expr *TOExpr;
-
+
protected:
TypeOfExprType(Expr *E, QualType can = QualType());
friend class ASTContext; // ASTContext creates these.
public:
Expr *getUnderlyingExpr() const { return TOExpr; }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExpr; }
static bool classof(const TypeOfExprType *) { return true; }
};
-/// Subclass of TypeOfExprType that is used for canonical, dependent
-/// typeof(expr) types.
-class DependentTypeOfExprType
+/// Subclass of TypeOfExprType that is used for canonical, dependent
+/// typeof(expr) types.
+class DependentTypeOfExprType
: public TypeOfExprType, public llvm::FoldingSetNode {
ASTContext &Context;
-
+
public:
- DependentTypeOfExprType(ASTContext &Context, Expr *E)
+ DependentTypeOfExprType(ASTContext &Context, Expr *E)
: TypeOfExprType(E), Context(Context) { }
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Context, getUnderlyingExpr());
}
-
+
static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
Expr *E);
};
-
+
/// TypeOfType (GCC extension).
class TypeOfType : public Type {
QualType TOType;
- TypeOfType(QualType T, QualType can)
+ TypeOfType(QualType T, QualType can)
: Type(TypeOf, can, T->isDependentType()), TOType(T) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
friend class ASTContext; // ASTContext creates these.
public:
QualType getUnderlyingType() const { return TOType; }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
static bool classof(const Type *T) { return T->getTypeClass() == TypeOf; }
@@ -1652,12 +1652,12 @@ public:
/// DecltypeType (C++0x)
class DecltypeType : public Type {
Expr *E;
-
+
// FIXME: We could get rid of UnderlyingType if we wanted to: We would have to
// Move getDesugaredType to ASTContext so that it can call getDecltypeForExpr
// from it.
QualType UnderlyingType;
-
+
protected:
DecltypeType(Expr *E, QualType underlyingType, QualType can = QualType());
friend class ASTContext; // ASTContext creates these.
@@ -1665,29 +1665,29 @@ public:
Expr *getUnderlyingExpr() const { return E; }
QualType getUnderlyingType() const { return UnderlyingType; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
static bool classof(const Type *T) { return T->getTypeClass() == Decltype; }
static bool classof(const DecltypeType *) { return true; }
};
-
-/// Subclass of DecltypeType that is used for canonical, dependent
-/// C++0x decltype types.
+
+/// Subclass of DecltypeType that is used for canonical, dependent
+/// C++0x decltype types.
class DependentDecltypeType : public DecltypeType, public llvm::FoldingSetNode {
ASTContext &Context;
-
+
public:
DependentDecltypeType(ASTContext &Context, Expr *E);
-
+
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Context, getUnderlyingExpr());
}
-
+
static void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
- Expr *E);
+ Expr *E);
};
-
+
class TagType : public Type {
/// Stores the TagDecl associated with this type. The decl will
/// point to the TagDecl that actually defines the entity (or is a
@@ -1701,18 +1701,18 @@ class TagType : public Type {
protected:
TagType(TypeClass TC, TagDecl *D, QualType can);
-public:
+public:
TagDecl *getDecl() const { return decl.getPointer(); }
-
+
/// @brief Determines whether this type is in the process of being
- /// defined.
+ /// defined.
bool isBeingDefined() const { return decl.getInt(); }
void setBeingDefined(bool Def) { decl.setInt(Def? 1 : 0); }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
- static bool classof(const Type *T) {
+ static bool classof(const Type *T) {
return T->getTypeClass() >= TagFirst && T->getTypeClass() <= TagLast;
}
static bool classof(const TagType *) { return true; }
@@ -1730,20 +1730,20 @@ protected:
: TagType(TC, reinterpret_cast<TagDecl*>(D), QualType()) { }
friend class ASTContext; // ASTContext creates these.
public:
-
+
RecordDecl *getDecl() const {
return reinterpret_cast<RecordDecl*>(TagType::getDecl());
}
-
- // FIXME: This predicate is a helper to QualType/Type. It needs to
+
+ // FIXME: This predicate is a helper to QualType/Type. It needs to
// recursively check all fields for const-ness. If any field is declared
- // const, it needs to return false.
+ // const, it needs to return false.
bool hasConstFields() const { return false; }
// FIXME: RecordType needs to check when it is created that all fields are in
// the same address space, and return that.
unsigned getAddressSpace() const { return 0; }
-
+
static bool classof(const TagType *T);
static bool classof(const Type *T) {
return isa<TagType>(T) && classof(cast<TagType>(T));
@@ -1758,11 +1758,11 @@ class EnumType : public TagType {
: TagType(Enum, reinterpret_cast<TagDecl*>(D), QualType()) { }
friend class ASTContext; // ASTContext creates these.
public:
-
+
EnumDecl *getDecl() const {
return reinterpret_cast<EnumDecl*>(TagType::getDecl());
}
-
+
static bool classof(const TagType *T);
static bool classof(const Type *T) {
return isa<TagType>(T) && classof(cast<TagType>(T));
@@ -1814,7 +1814,7 @@ public:
}
}
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -1835,12 +1835,12 @@ class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
unsigned ParameterPack : 1;
IdentifierInfo *Name;
- TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N,
- QualType Canon)
+ TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N,
+ QualType Canon)
: Type(TemplateTypeParm, Canon, /*Dependent=*/true),
Depth(D), Index(I), ParameterPack(PP), Name(N) { }
- TemplateTypeParmType(unsigned D, unsigned I, bool PP)
+ TemplateTypeParmType(unsigned D, unsigned I, bool PP)
: Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true),
Depth(D), Index(I), ParameterPack(PP), Name(0) { }
@@ -1851,16 +1851,16 @@ public:
unsigned getIndex() const { return Index; }
bool isParameterPack() const { return ParameterPack; }
IdentifierInfo *getName() const { return Name; }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Depth, Index, ParameterPack, Name);
}
- static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth,
- unsigned Index, bool ParameterPack,
+ static void Profile(llvm::FoldingSetNodeID &ID, unsigned Depth,
+ unsigned Index, bool ParameterPack,
IdentifierInfo *Name) {
ID.AddInteger(Depth);
ID.AddInteger(Index);
@@ -1868,8 +1868,8 @@ public:
ID.AddPointer(Name);
}
- static bool classof(const Type *T) {
- return T->getTypeClass() == TemplateTypeParm;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == TemplateTypeParm;
}
static bool classof(const TemplateTypeParmType *T) { return true; }
};
@@ -1883,18 +1883,18 @@ public:
/// type will point to some other type node that represents the
/// instantiation or class template specialization. For example, a
/// class template specialization type of @c vector<int> will refer to
-/// a tag type for the instantiation
+/// a tag type for the instantiation
/// @c std::vector<int, std::allocator<int>>.
///
/// Other template specialization types, for which the template name
/// is dependent, may be canonical types. These types are always
/// dependent.
-class TemplateSpecializationType
+class TemplateSpecializationType
: public Type, public llvm::FoldingSetNode {
// FIXME: Currently needed for profiling expressions; can we avoid this?
ASTContext &Context;
-
+
/// \brief The name of the template being specialized.
TemplateName Template;
@@ -1915,7 +1915,7 @@ public:
/// \brief Determine whether any of the given template arguments are
/// dependent.
static bool anyDependentTemplateArguments(const TemplateArgument *Args,
- unsigned NumArgs);
+ unsigned NumArgs);
/// \brief Print a template argument list, including the '<' and '>'
/// enclosing the template arguments.
@@ -1932,7 +1932,7 @@ public:
TemplateName getTemplateName() const { return Template; }
/// \brief Retrieve the template arguments.
- const TemplateArgument *getArgs() const {
+ const TemplateArgument *getArgs() const {
return reinterpret_cast<const TemplateArgument *>(this + 1);
}
@@ -1943,7 +1943,7 @@ public:
/// \precondition @c isArgType(Arg)
const TemplateArgument &getArg(unsigned Idx) const;
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -1954,8 +1954,8 @@ public:
const TemplateArgument *Args, unsigned NumArgs,
ASTContext &Context);
- static bool classof(const Type *T) {
- return T->getTypeClass() == TemplateSpecialization;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == TemplateSpecialization;
}
static bool classof(const TemplateSpecializationType *T) { return true; }
};
@@ -1988,7 +1988,7 @@ public:
/// \brief Retrieve the type named by the qualified-id.
QualType getNamedType() const { return NamedType; }
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -2001,8 +2001,8 @@ public:
NamedType.Profile(ID);
}
- static bool classof(const Type *T) {
- return T->getTypeClass() == QualifiedName;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == QualifiedName;
}
static bool classof(const QualifiedNameType *T) { return true; }
};
@@ -2023,7 +2023,7 @@ class TypenameType : public Type, public llvm::FoldingSetNode {
/// \brief The nested name specifier containing the qualifier.
NestedNameSpecifier *NNS;
- typedef llvm::PointerUnion<const IdentifierInfo *,
+ typedef llvm::PointerUnion<const IdentifierInfo *,
const TemplateSpecializationType *> NameType;
/// \brief The type that this typename specifier refers to.
@@ -2031,15 +2031,15 @@ class TypenameType : public Type, public llvm::FoldingSetNode {
TypenameType(NestedNameSpecifier *NNS, const IdentifierInfo *Name,
QualType CanonType)
- : Type(Typename, CanonType, true), NNS(NNS), Name(Name) {
- assert(NNS->isDependent() &&
+ : Type(Typename, CanonType, true), NNS(NNS), Name(Name) {
+ assert(NNS->isDependent() &&
"TypenameType requires a dependent nested-name-specifier");
}
TypenameType(NestedNameSpecifier *NNS, const TemplateSpecializationType *Ty,
QualType CanonType)
- : Type(Typename, CanonType, true), NNS(NNS), Name(Ty) {
- assert(NNS->isDependent() &&
+ : Type(Typename, CanonType, true), NNS(NNS), Name(Ty) {
+ assert(NNS->isDependent() &&
"TypenameType requires a dependent nested-name-specifier");
}
@@ -2055,8 +2055,8 @@ public:
/// This routine will return a non-NULL identifier pointer when the
/// form of the original typename was terminated by an identifier,
/// e.g., "typename T::type".
- const IdentifierInfo *getIdentifier() const {
- return Name.dyn_cast<const IdentifierInfo *>();
+ const IdentifierInfo *getIdentifier() const {
+ return Name.dyn_cast<const IdentifierInfo *>();
}
/// \brief Retrieve the type named by the typename specifier as a
@@ -2065,7 +2065,7 @@ public:
return Name.dyn_cast<const TemplateSpecializationType *>();
}
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
void Profile(llvm::FoldingSetNodeID &ID) {
@@ -2078,8 +2078,8 @@ public:
ID.AddPointer(Name.getOpaqueValue());
}
- static bool classof(const Type *T) {
- return T->getTypeClass() == Typename;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == Typename;
}
static bool classof(const TypenameType *T) { return true; }
};
@@ -2097,13 +2097,13 @@ class ObjCInterfaceType : public Type, public llvm::FoldingSetNode {
llvm::SmallVector<ObjCProtocolDecl*, 4> Protocols;
ObjCInterfaceType(ObjCInterfaceDecl *D,
- ObjCProtocolDecl **Protos, unsigned NumP) :
- Type(ObjCInterface, QualType(), /*Dependent=*/false),
+ ObjCProtocolDecl **Protos, unsigned NumP) :
+ Type(ObjCInterface, QualType(), /*Dependent=*/false),
Decl(D), Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
public:
ObjCInterfaceDecl *getDecl() const { return Decl; }
-
+
/// getNumProtocols - Return the number of qualifying protocols in this
/// interface type, or 0 if there are none.
unsigned getNumProtocols() const { return Protocols.size(); }
@@ -2114,17 +2114,17 @@ public:
qual_iterator qual_begin() const { return Protocols.begin(); }
qual_iterator qual_end() const { return Protocols.end(); }
bool qual_empty() const { return Protocols.size() == 0; }
-
- virtual void getAsStringInternal(std::string &InnerString,
+
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
-
+
void Profile(llvm::FoldingSetNodeID &ID);
- static void Profile(llvm::FoldingSetNodeID &ID,
+ static void Profile(llvm::FoldingSetNodeID &ID,
const ObjCInterfaceDecl *Decl,
ObjCProtocolDecl **protocols, unsigned NumProtocols);
-
- static bool classof(const Type *T) {
- return T->getTypeClass() == ObjCInterface;
+
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == ObjCInterface;
}
static bool classof(const ObjCInterfaceType *) { return true; }
};
@@ -2136,7 +2136,7 @@ public:
/// alphabetical order.
class ObjCObjectPointerType : public Type, public llvm::FoldingSetNode {
QualType PointeeType; // A builtin or interface type.
-
+
// List of protocols for this protocol conforming object type
// List is sorted on protocol name. No protocol is entered more than once.
llvm::SmallVector<ObjCProtocolDecl*, 8> Protocols;
@@ -2145,7 +2145,7 @@ class ObjCObjectPointerType : public Type, public llvm::FoldingSetNode {
Type(ObjCObjectPointer, QualType(), /*Dependent=*/false),
PointeeType(T), Protocols(Protos, Protos+NumP) { }
friend class ASTContext; // ASTContext creates these.
-
+
public:
// Get the pointee type. Pointee will either be:
// - a built-in type (for 'id' and 'Class').
@@ -2154,8 +2154,8 @@ public:
// For example: typedef NSObject T; T *var;
QualType getPointeeType() const { return PointeeType; }
- const ObjCInterfaceType *getInterfaceType() const {
- return PointeeType->getAsObjCInterfaceType();
+ const ObjCInterfaceType *getInterfaceType() const {
+ return PointeeType->getAsObjCInterfaceType();
}
/// getInterfaceDecl - returns an interface decl for user-defined types.
ObjCInterfaceDecl *getInterfaceDecl() const {
@@ -2163,22 +2163,22 @@ public:
}
/// isObjCIdType - true for "id".
bool isObjCIdType() const {
- return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
+ return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
!Protocols.size();
}
/// isObjCClassType - true for "Class".
bool isObjCClassType() const {
- return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
+ return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
!Protocols.size();
}
/// isObjCQualifiedIdType - true for "id <p>".
- bool isObjCQualifiedIdType() const {
- return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
- Protocols.size();
+ bool isObjCQualifiedIdType() const {
+ return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
+ Protocols.size();
}
/// isObjCQualifiedClassType - true for "Class <p>".
bool isObjCQualifiedClassType() const {
- return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
+ return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
Protocols.size();
}
/// qual_iterator and friends: this provides access to the (potentially empty)
@@ -2196,10 +2196,10 @@ public:
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID, QualType T,
ObjCProtocolDecl **protocols, unsigned NumProtocols);
- virtual void getAsStringInternal(std::string &InnerString,
+ virtual void getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const;
- static bool classof(const Type *T) {
- return T->getTypeClass() == ObjCObjectPointer;
+ static bool classof(const Type *T) {
+ return T->getTypeClass() == ObjCObjectPointer;
}
static bool classof(const ObjCObjectPointerType *) { return true; }
};
@@ -2234,10 +2234,10 @@ inline QualType::GCAttrTypes QualType::getObjCGCAttr() const {
if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(CT))
return EXTQT->getObjCGCAttr();
if (const ObjCObjectPointerType *PT = CT->getAsObjCObjectPointerType())
- return PT->getPointeeType().getObjCGCAttr();
+ return PT->getPointeeType().getObjCGCAttr();
// We most look at all pointer types, not just pointer to interface types.
if (const PointerType *PT = CT->getAs<PointerType>())
- return PT->getPointeeType().getObjCGCAttr();
+ return PT->getPointeeType().getObjCGCAttr();
return GCNone;
}
@@ -2253,7 +2253,7 @@ inline bool QualType::getNoReturnAttr() const {
return false;
}
-
+
/// isMoreQualifiedThan - Determine whether this type is more
/// qualified than the Other type. For example, "const volatile int"
/// is more qualified than "const int", "volatile int", and
@@ -2303,20 +2303,20 @@ inline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const {
return PT->getPointeeType()->getAsObjCInterfaceType();
return 0;
}
-
+
// NOTE: All of these methods use "getUnqualifiedType" to strip off address
// space qualifiers if present.
inline bool Type::isFunctionType() const {
return isa<FunctionType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isPointerType() const {
- return isa<PointerType>(CanonicalType.getUnqualifiedType());
+ return isa<PointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isAnyPointerType() const {
return isPointerType() || isObjCObjectPointerType();
}
inline bool Type::isBlockPointerType() const {
- return isa<BlockPointerType>(CanonicalType.getUnqualifiedType());
+ return isa<BlockPointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isReferenceType() const {
return isa<ReferenceType>(CanonicalType.getUnqualifiedType());
@@ -2417,12 +2417,12 @@ inline bool Type::isOverloadableType() const {
inline bool Type::hasPointerRepresentation() const {
return (isPointerType() || isReferenceType() || isBlockPointerType() ||
- isObjCInterfaceType() || isObjCObjectPointerType() ||
+ isObjCInterfaceType() || isObjCObjectPointerType() ||
isObjCQualifiedInterfaceType() || isNullPtrType());
}
inline bool Type::hasObjCPointerRepresentation() const {
- return (isObjCInterfaceType() || isObjCObjectPointerType() ||
+ return (isObjCInterfaceType() || isObjCObjectPointerType() ||
isObjCQualifiedInterfaceType());
}
@@ -2434,13 +2434,13 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
Diagnostic::ak_qualtype);
return DB;
}
-
+
/// Member-template getAs<specific type>'.
template <typename T> const T *Type::getAs() const {
// If this is directly a T type, return it.
if (const T *Ty = dyn_cast<T>(this))
return Ty;
-
+
// If the canonical form of this type isn't the right kind, reject it.
if (!isa<T>(CanonicalType)) {
// Look through type qualifiers
@@ -2448,11 +2448,11 @@ template <typename T> const T *Type::getAs() const {
return CanonicalType.getUnqualifiedType()->getAs<T>();
return 0;
}
-
+
// If this is a typedef for a pointer type, strip the typedef off without
// losing all typedef information.
return cast<T>(getDesugaredType());
-}
+}
} // end namespace clang
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index 29955d37a9..bb9744a202 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -30,7 +30,7 @@ class TypeLoc {
protected:
QualType Ty;
void *Data;
-
+
TypeLoc(QualType ty, void *data) : Ty(ty), Data(data) { }
static TypeLoc Create(QualType ty, void *data) { return TypeLoc(ty,data); }
friend class DeclaratorInfo;
@@ -86,7 +86,7 @@ public:
class DeclaratorLoc : public TypeLoc {
public:
/// \brief Find the TypeSpecLoc that is part of this DeclaratorLoc.
- TypeSpecLoc getTypeSpecLoc() const;
+ TypeSpecLoc getTypeSpecLoc() const;
static bool classof(const TypeLoc *TL);
static bool classof(const DeclaratorLoc *TL) { return true; }
@@ -98,7 +98,7 @@ class DefaultTypeSpecLoc : public TypeSpecLoc {
struct Info {
SourceLocation StartLoc;
};
-
+
public:
SourceLocation getStartLoc() const {
return static_cast<Info*>(Data)->StartLoc;
@@ -137,7 +137,7 @@ public:
SourceRange getSourceRange() const {
return SourceRange(getNameLoc(), getNameLoc());
}
-
+
/// \brief Returns the size of the type source info data block that is
/// specific to this type.
unsigned getLocalDataSize() const { return sizeof(Info); }
@@ -445,7 +445,7 @@ class TypeLocVisitor {
#define TYPELOC(CLASS, PARENT, TYPE) \
RetTy Visit##TYPE(TYPE *) { \
return Impl->Visit##CLASS(reinterpret_cast<CLASS&>(TyLoc)); \
- }
+ }
#include "clang/AST/TypeLocNodes.def"
};
diff --git a/include/clang/AST/TypeOrdering.h b/include/clang/AST/TypeOrdering.h
index 4f60273d68..652f4f70bd 100644
--- a/include/clang/AST/TypeOrdering.h
+++ b/include/clang/AST/TypeOrdering.h
@@ -37,7 +37,7 @@ namespace llvm {
template<> struct DenseMapInfo<clang::QualType> {
static inline clang::QualType getEmptyKey() { return clang::QualType(); }
- static inline clang::QualType getTombstoneKey() {
+ static inline clang::QualType getTombstoneKey() {
using clang::QualType;
return QualType::getFromOpaquePtr(reinterpret_cast<clang::Type *>(-1));
}
@@ -51,11 +51,11 @@ namespace llvm {
return LHS == RHS;
}
- static bool isPod() {
+ static bool isPod() {
// QualType isn't *technically* a POD type. However, we can get
// away with calling it a POD type since its copy constructor,
// copy assignment operator, and destructor are all trivial.
- return true;
+ return true;
}
};
}
diff --git a/include/clang/AST/TypeVisitor.h b/include/clang/AST/TypeVisitor.h
index 8386bfc620..19f7f42a89 100644
--- a/include/clang/AST/TypeVisitor.h
+++ b/include/clang/AST/TypeVisitor.h
@@ -17,10 +17,10 @@
#include "clang/AST/Type.h"
namespace clang {
-
+
#define DISPATCH(CLASS) \
return static_cast<ImplClass*>(this)->Visit ## CLASS(static_cast<CLASS*>(T))
-
+
template<typename ImplClass, typename RetTy=void>
class TypeVisitor {
public:
@@ -28,12 +28,12 @@ public:
// Top switch stmt: dispatch to VisitFooStmt for each FooStmt.
switch (T->getTypeClass()) {
default: assert(0 && "Unknown type class!");
-#define ABSTRACT_TYPE(CLASS, PARENT)
+#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) case Type::CLASS: DISPATCH(CLASS##Type);
#include "clang/AST/TypeNodes.def"
}
}
-
+
// If the implementation chooses not to implement a certain visit method, fall
// back on superclass.
#define TYPE(CLASS, PARENT) RetTy Visit##CLASS##Type(CLASS##Type *T) { \
diff --git a/include/clang/Analysis/Analyses/LiveVariables.h b/include/clang/Analysis/Analyses/LiveVariables.h
index b41cd684e9..17f772da0c 100644
--- a/include/clang/Analysis/Analyses/LiveVariables.h
+++ b/include/clang/Analysis/Analyses/LiveVariables.h
@@ -23,7 +23,7 @@ namespace clang {
class Stmt;
class DeclRefExpr;
class SourceManager;
-
+
struct LiveVariables_ValueTypes {
struct ObserverTy;
@@ -35,77 +35,77 @@ struct LiveVariables_ValueTypes {
// (so that we don't explore such expressions twice). We also want
// to compute liveness information for block-level expressions, since these
// act as "temporary" values.
-
+
struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy {
ObserverTy* Observer;
ValTy AlwaysLive;
-
+
AnalysisDataTy() : Observer(NULL) {}
};
-
+
//===-----------------------------------------------------===//
// ObserverTy - Observer for uninitialized values queries.
//===-----------------------------------------------------===//
struct ObserverTy {
virtual ~ObserverTy() {}
-
+
/// ObserveStmt - A callback invoked right before invoking the
/// liveness transfer function on the given statement.
- virtual void ObserveStmt(Stmt* S, const AnalysisDataTy& AD,
+ virtual void ObserveStmt(Stmt* S, const AnalysisDataTy& AD,
const ValTy& V) {}
-
+
virtual void ObserverKill(DeclRefExpr* DR) {}
};
};
class LiveVariables : public DataflowValues<LiveVariables_ValueTypes,
dataflow::backward_analysis_tag> {
-
-
+
+
public:
typedef LiveVariables_ValueTypes::ObserverTy ObserverTy;
-
+
LiveVariables(ASTContext& Ctx, CFG& cfg);
-
+
/// IsLive - Return true if a variable is live at beginning of a
/// specified block.
bool isLive(const CFGBlock* B, const VarDecl* D) const;
-
+
/// IsLive - Returns true if a variable is live at the beginning of the
/// the statement. This query only works if liveness information
/// has been recorded at the statement level (see runOnAllBlocks), and
/// only returns liveness information for block-level expressions.
bool isLive(const Stmt* S, const VarDecl* D) const;
-
+
/// IsLive - Returns true the block-level expression "value" is live
/// before the given block-level expression (see runOnAllBlocks).
bool isLive(const Stmt* Loc, const Stmt* StmtVal) const;
-
+
/// IsLive - Return true if a variable is live according to the
/// provided livness bitvector.
bool isLive(const ValTy& V, const VarDecl* D) const;
-
+
/// dumpLiveness - Print to stderr the liveness information encoded
/// by a specified bitvector.
void dumpLiveness(const ValTy& V, SourceManager& M) const;
-
+
/// dumpBlockLiveness - Print to stderr the liveness information
/// associated with each basic block.
void dumpBlockLiveness(SourceManager& M) const;
-
+
/// getNumDecls - Return the number of variables (declarations) that
/// whose liveness status is being tracked by the dataflow
/// analysis.
unsigned getNumDecls() const { return getAnalysisData().getNumDecls(); }
-
+
/// IntializeValues - This routine can perform extra initialization, but
/// for LiveVariables this does nothing since all that logic is in
- /// the constructor.
+ /// the constructor.
void InitializeValues(const CFG& cfg) {}
-
+
void runOnCFG(CFG& cfg);
-
+
/// runOnAllBlocks - Propagate the dataflow values once for each block,
/// starting from the current dataflow values. 'recordStmtValues' indicates
/// whether the method should store dataflow values per each individual
diff --git a/include/clang/Analysis/Analyses/UninitializedValues.h b/include/clang/Analysis/Analyses/UninitializedValues.h
index 7a9da03e4b..8a967c3f6e 100644
--- a/include/clang/Analysis/Analyses/UninitializedValues.h
+++ b/include/clang/Analysis/Analyses/UninitializedValues.h
@@ -24,7 +24,7 @@ namespace clang {
class Expr;
class DeclRefExpr;
class VarDecl;
-
+
/// UninitializedValues_ValueTypes - Utility class to wrap type declarations
/// for dataflow values and dataflow analysis state for the
/// Unitialized Values analysis.
@@ -32,39 +32,39 @@ class UninitializedValues_ValueTypes {
public:
struct ObserverTy;
-
- struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy {
+
+ struct AnalysisDataTy : public StmtDeclBitVector_Types::AnalysisDataTy {
AnalysisDataTy() : Observer(NULL), FullUninitTaint(true) {}
virtual ~AnalysisDataTy() {};
-
+
ObserverTy* Observer;
bool FullUninitTaint;
};
-
+
typedef StmtDeclBitVector_Types::ValTy ValTy;
-
+
//===--------------------------------------------------------------------===//
// ObserverTy - Observer for querying DeclRefExprs that use an uninitalized
// value.
//===--------------------------------------------------------------------===//
-
+
struct ObserverTy {
virtual ~ObserverTy();
- virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD,
+ virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD,
DeclRefExpr* DR, VarDecl* VD) = 0;
- };
+ };
};
/// UninitializedValues - Objects of this class encapsulate dataflow analysis
/// information regarding what variable declarations in a function are
/// potentially unintialized.
-class UninitializedValues :
- public DataflowValues<UninitializedValues_ValueTypes> {
+class UninitializedValues :
+ public DataflowValues<UninitializedValues_ValueTypes> {
public:
typedef UninitializedValues_ValueTypes::ObserverTy ObserverTy;
UninitializedValues(CFG &cfg) { getAnalysisData().setCFG(cfg); }
-
+
/// IntializeValues - Create initial dataflow values and meta data for
/// a given CFG. This is intended to be called by the dataflow solver.
void InitializeValues(const CFG& cfg);
diff --git a/include/clang/Analysis/AnalysisDiagnostic.h b/include/clang/Analysis/AnalysisDiagnostic.h
index 3ee7335185..114ae74b0c 100644
--- a/include/clang/Analysis/AnalysisDiagnostic.h
+++ b/include/clang/Analysis/AnalysisDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define ANALYSISSTART
diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h
index 34dedc074a..dab718cbac 100644
--- a/include/clang/Analysis/CFG.h
+++ b/include/clang/Analysis/CFG.h
@@ -65,27 +65,27 @@ class CFGBlock {
/// statements in the block. When this variable is non-NULL, it is
/// either an instance of LabelStmt or SwitchCase.
Stmt *Label;
-
+
/// Terminator - The terminator for a basic block that
/// indicates the type of control-flow that occurs between a block
/// and its successors.
Stmt *Terminator;
-
+
/// LoopTarget - Some blocks are used to represent the "loop edge" to
/// the start of a loop from within the loop body. This Stmt* will be
/// refer to the loop statement for such blocks (and be null otherwise).
- const Stmt *LoopTarget;
-
+ const Stmt *LoopTarget;
+
/// BlockID - A numerical ID assigned to a CFGBlock during construction
/// of the CFG.
unsigned BlockID;
-
+
/// Predecessors/Successors - Keep track of the predecessor / successor
/// CFG blocks.
typedef std::vector<CFGBlock*> AdjacentBlocks;
AdjacentBlocks Preds;
AdjacentBlocks Succs;
-
+
public:
explicit CFGBlock(unsigned blockid) : Label(NULL), Terminator(NULL),
LoopTarget(NULL), BlockID(blockid) {}
@@ -96,25 +96,25 @@ public:
typedef StatementListTy::const_iterator const_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
-
+
Stmt* front() const { return Stmts.front(); }
Stmt* back() const { return Stmts.back(); }
-
+
iterator begin() { return Stmts.begin(); }
iterator end() { return Stmts.end(); }
const_iterator begin() const { return Stmts.begin(); }
- const_iterator end() const { return Stmts.end(); }
+ const_iterator end() const { return Stmts.end(); }
reverse_iterator rbegin() { return Stmts.rbegin(); }
reverse_iterator rend() { return Stmts.rend(); }
const_reverse_iterator rbegin() const { return Stmts.rbegin(); }
const_reverse_iterator rend() const { return Stmts.rend(); }
-
+
unsigned size() const { return Stmts.size(); }
bool empty() const { return Stmts.empty(); }
Stmt* operator[](size_t i) const { assert (i < size()); return Stmts[i]; }
-
+
// CFG iterators
typedef AdjacentBlocks::iterator pred_iterator;
typedef AdjacentBlocks::const_iterator const_pred_iterator;
@@ -125,22 +125,22 @@ public:
typedef AdjacentBlocks::const_iterator const_succ_iterator;
typedef AdjacentBlocks::reverse_iterator succ_reverse_iterator;
typedef AdjacentBlocks::const_reverse_iterator const_succ_reverse_iterator;
-
+
pred_iterator pred_begin() { return Preds.begin(); }
pred_iterator pred_end() { return Preds.end(); }
const_pred_iterator pred_begin() const { return Preds.begin(); }
const_pred_iterator pred_end() const { return Preds.end(); }
-
+
pred_reverse_iterator pred_rbegin() { return Preds.rbegin(); }
- pred_reverse_iterator pred_rend() { return Preds.rend(); }
+ pred_reverse_iterator pred_rend() { return Preds.rend(); }
const_pred_reverse_iterator pred_rbegin() const { return Preds.rbegin(); }
const_pred_reverse_iterator pred_rend() const { return Preds.rend(); }
- succ_iterator succ_begin() { return Succs.begin(); }
+ succ_iterator succ_begin() { return Succs.begin(); }
succ_iterator succ_end() { return Succs.end(); }
const_succ_iterator succ_begin() const { return Succs.begin(); }
- const_succ_iterator succ_end() const { return Succs.end(); }
-
+ const_succ_iterator succ_end() const { return Succs.end(); }
+
succ_reverse_iterator succ_rbegin() { return Succs.rbegin(); }
succ_reverse_iterator succ_rend() { return Succs.rend(); }
const_succ_reverse_iterator succ_rbegin() const { return Succs.rbegin(); }
@@ -151,9 +151,9 @@ public:
unsigned pred_size() const { return Preds.size(); }
bool pred_empty() const { return Preds.empty(); }
-
+
// Manipulation of block contents
-
+
void appendStmt(Stmt* Statement) { Stmts.push_back(Statement); }
void setTerminator(Stmt* Statement) { Terminator = Statement; }
void setLabel(Stmt* Statement) { Label = Statement; }
@@ -161,35 +161,35 @@ public:
Stmt* getTerminator() { return Terminator; }
const Stmt* getTerminator() const { return Terminator; }
-
+
Stmt* getTerminatorCondition();
-
+
const Stmt* getTerminatorCondition() const {
return const_cast<CFGBlock*>(this)->getTerminatorCondition();
}
-
+
const Stmt *getLoopTarget() const { return LoopTarget; }
-
+
bool hasBinaryBranchTerminator() const;
-
+
Stmt* getLabel() { return Label; }
const Stmt* getLabel() const { return Label; }
-
+
void reverseStmts();
-
+
void addSuccessor(CFGBlock* Block) {
if (Block)
Block->Preds.push_back(this);
Succs.push_back(Block);
}
-
+
unsigned getBlockID() const { return BlockID; }
-
+
void dump(const CFG *cfg, const LangOptions &LO) const;
void print(llvm::raw_ostream &OS, const CFG* cfg, const LangOptions &LO) const;
void printTerminator(llvm::raw_ostream &OS, const LangOptions &LO) const;
};
-
+
/// CFG - Represents a source-level, intra-procedural CFG that represents the
/// control-flow of a Stmt. The Stmt can represent an entire function body,
@@ -205,28 +205,28 @@ public:
//===--------------------------------------------------------------------===//
/// buildCFG - Builds a CFG from an AST. The responsibility to free the
- /// constructed CFG belongs to the caller.
- static CFG* buildCFG(Stmt* AST, ASTContext *C);
-
+ /// constructed CFG belongs to the caller.
+ static CFG* buildCFG(Stmt* AST, ASTContext *C);
+
/// createBlock - Create a new block in the CFG. The CFG owns the block;
/// the caller should not directly free it.
CFGBlock* createBlock();
-
+
/// setEntry - Set the entry block of the CFG. This is typically used
/// only during CFG construction. Most CFG clients expect that the
/// entry block has no predecessors and contains no statements.
void setEntry(CFGBlock *B) { Entry = B; }
-
+
/// setIndirectGotoBlock - Set the block used for indirect goto jumps.
/// This is typically used only during CFG construction.
void setIndirectGotoBlock(CFGBlock* B) { IndirectGotoBlock = B; }
-
+
//===--------------------------------------------------------------------===//
// Block Iterators
//===--------------------------------------------------------------------===//
typedef std::list<CFGBlock> CFGBlockListTy;
-
+
typedef CFGBlockListTy::iterator iterator;
typedef CFGBlockListTy::const_iterator const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
@@ -234,17 +234,17 @@ public:
CFGBlock& front() { return Blocks.front(); }
CFGBlock& back() { return Blocks.back(); }
-
+
iterator begin() { return Blocks.begin(); }
iterator end() { return Blocks.end(); }
const_iterator begin() const { return Blocks.begin(); }
- const_iterator end() const { return Blocks.end(); }
-
+ const_iterator end() const { return Blocks.end(); }
+
reverse_iterator rbegin() { return Blocks.rbegin(); }
reverse_iterator rend() { return Blocks.rend(); }
const_reverse_iterator rbegin() const { return Blocks.rbegin(); }
const_reverse_iterator rend() const { return Blocks.rend(); }
-
+
CFGBlock& getEntry() { return *Entry; }
const CFGBlock& getEntry() const { return *Entry; }
CFGBlock& getExit() { return *Exit; }
@@ -252,18 +252,18 @@ public:
CFGBlock* getIndirectGotoBlock() { return IndirectGotoBlock; }
const CFGBlock* getIndirectGotoBlock() const { return IndirectGotoBlock; }
-
+
//===--------------------------------------------------------------------===//
// Member templates useful for various batch operations over CFGs.
//===--------------------------------------------------------------------===//
-
+
template <typename CALLBACK>
void VisitBlockStmts(CALLBACK& O) const {
for (const_iterator I=begin(), E=end(); I != E; ++I)
for (CFGBlock::const_iterator BI=I->begin(), BE=I->end(); BI != BE; ++BI)
O(*BI);
- }
-
+ }
+
//===--------------------------------------------------------------------===//
// CFG Introspection.
//===--------------------------------------------------------------------===//
@@ -275,11 +275,11 @@ public:
operator bool() const { return Idx >= 0; }
operator unsigned() const { assert(Idx >=0); return (unsigned) Idx; }
};
-
+
bool isBlkExpr(const Stmt* S) { return getBlkExprNum(S); }
BlkExprNumTy getBlkExprNum(const Stmt* S);
unsigned getNumBlkExprs();
-
+
/// getNumBlockIDs - Returns the total number of BlockIDs allocated (which
/// start at 0).
unsigned getNumBlockIDs() const { return NumBlockIDs; }
@@ -296,15 +296,15 @@ public:
// Internal: constructors and data.
//===--------------------------------------------------------------------===//
- CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0),
+ CFG() : Entry(NULL), Exit(NULL), IndirectGotoBlock(NULL), NumBlockIDs(0),
BlkExprMap(NULL) {};
-
+
~CFG();
-
+
llvm::BumpPtrAllocator& getAllocator() {
return Alloc;
}
-
+
private:
CFGBlock* Entry;
CFGBlock* Exit;
@@ -312,14 +312,14 @@ private:
// for indirect gotos
CFGBlockListTy Blocks;
unsigned NumBlockIDs;
-
+
// BlkExprMap - An opaque pointer to prevent inclusion of DenseMap.h.
- // It represents a map from Expr* to integers to record the set of
+ // It represents a map from Expr* to integers to record the set of
// block-level expressions and their "statement number" in the CFG.
void* BlkExprMap;
-
+
/// Alloc - An internal allocator.
- llvm::BumpPtrAllocator Alloc;
+ llvm::BumpPtrAllocator Alloc;
};
} // end namespace clang
@@ -334,13 +334,13 @@ namespace llvm {
template <> struct GraphTraits<clang::CFGBlock* > {
typedef clang::CFGBlock NodeType;
typedef clang::CFGBlock::succ_iterator ChildIteratorType;
-
+
static NodeType* getEntryNode(clang::CFGBlock* BB)
{ return BB; }
static inline ChildIteratorType child_begin(NodeType* N)
{ return N->succ_begin(); }
-
+
static inline ChildIteratorType child_end(NodeType* N)
{ return N->succ_end(); }
};
@@ -348,13 +348,13 @@ template <> struct GraphTraits<clang::CFGBlock* > {
template <> struct GraphTraits<const clang::CFGBlock* > {
typedef const clang::CFGBlock NodeType;
typedef clang::CFGBlock::const_succ_iterator ChildIteratorType;
-
+
static NodeType* getEntryNode(const clang::CFGBlock* BB)
{ return BB; }
-
+
static inline ChildIteratorType child_begin(NodeType* N)
{ return N->succ_begin(); }
-
+
static inline ChildIteratorType child_end(NodeType* N)
{ return N->succ_end(); }
};
@@ -368,27 +368,27 @@ template <> struct GraphTraits<Inverse<const clang::CFGBlock*> > {
static inline ChildIteratorType child_begin(NodeType* N)
{ return N->pred_begin(); }
-
+
static inline ChildIteratorType child_end(NodeType* N)
{ return N->pred_end(); }
};
// Traits for: CFG
-template <> struct GraphTraits<clang::CFG* >
+template <> struct GraphTraits<clang::CFG* >
: public GraphTraits<clang::CFGBlock* > {
typedef clang::CFG::iterator nodes_iterator;
-
- static NodeType *getEntryNode(clang::CFG* F) { return &F->getEntry(); }
+
+ static NodeType *getEntryNode(clang::CFG* F) { return &F->getEntry(); }
static nodes_iterator nodes_begin(clang::CFG* F) { return F->begin(); }
static nodes_iterator nodes_end(clang::CFG* F) { return F->end(); }
};
-template <> struct GraphTraits< const clang::CFG* >
+template <> struct GraphTraits< const clang::CFG* >
: public GraphTraits< const clang::CFGBlock* > {
- typedef clang::CFG::const_iterator nodes_iterator;
+ typedef clang::CFG::const_iterator nodes_iterator;
static NodeType *getEntryNode( const clang::CFG* F) { return &F->getEntry(); }
static nodes_iterator nodes_begin( const clang::CFG* F) { return F->begin(); }
@@ -404,7 +404,7 @@ template <> struct GraphTraits<Inverse<const clang::CFG*> >
static nodes_iterator nodes_begin(const clang::CFG* F) { return F->begin();}
static nodes_iterator nodes_end(const clang::CFG* F) { return F->end(); }
};
-
+
} // end llvm namespace
#endif
diff --git a/include/clang/Analysis/FlowSensitive/DataflowSolver.h b/include/clang/Analysis/FlowSensitive/DataflowSolver.h
index b0614e824f..da4913206d 100644
--- a/include/clang/Analysis/FlowSensitive/DataflowSolver.h
+++ b/include/clang/Analysis/FlowSensitive/DataflowSolver.h
@@ -33,15 +33,15 @@ public:
/// enqueue - Add a block to the worklist. Blocks already on the
/// worklist are not added a second time.
void enqueue(const CFGBlock* B) { wlist.insert(B); }
-
+
/// dequeue - Remove a block from the worklist.
const CFGBlock* dequeue() {
assert (!wlist.empty());
const CFGBlock* B = *wlist.begin();
wlist.erase(B);
- return B;
+ return B;
}
-
+
/// isEmpty - Return true if the worklist is empty.
bool isEmpty() const { return wlist.empty(); }
};
@@ -59,20 +59,20 @@ template <> struct ItrTraits<forward_analysis_tag> {
typedef CFGBlock::const_pred_iterator PrevBItr;
typedef CFGBlock::const_succ_iterator NextBItr;
typedef CFGBlock::const_iterator StmtItr;
-
+
static PrevBItr PrevBegin(const CFGBlock* B) { return B->pred_begin(); }
static PrevBItr PrevEnd(const CFGBlock* B) { return B->pred_end(); }
-
- static NextBItr NextBegin(const CFGBlock* B) { return B->succ_begin(); }
+
+ static NextBItr NextBegin(const CFGBlock* B) { return B->succ_begin(); }
static NextBItr NextEnd(const CFGBlock* B) { return B->succ_end(); }
-
+
static StmtItr StmtBegin(const CFGBlock* B) { return B->begin(); }
static StmtItr StmtEnd(const CFGBlock* B) { return B->end(); }
-
+
static BlockEdge PrevEdge(const CFGBlock* B, const CFGBlock* Prev) {
return BlockEdge(Prev, B, 0);
}
-
+
static BlockEdge NextEdge(const CFGBlock* B, const CFGBlock* Next) {
return BlockEdge(B, Next, 0);
}
@@ -82,20 +82,20 @@ template <> struct ItrTraits<backward_analysis_tag> {
typedef CFGBlock::const_succ_iterator PrevBItr;
typedef CFGBlock::const_pred_iterator NextBItr;
typedef CFGBlock::const_reverse_iterator StmtItr;
-
- static PrevBItr PrevBegin(const CFGBlock* B) { return B->succ_begin(); }
+
+ static PrevBItr PrevBegin(const CFGBlock* B) { return B->succ_begin(); }
static PrevBItr PrevEnd(const CFGBlock* B) { return B->succ_end(); }
-
- static NextBItr NextBegin(const CFGBlock* B) { return B->pred_begin(); }
+
+ static NextBItr NextBegin(const CFGBlock* B) { return B->pred_begin(); }
static NextBItr NextEnd(const CFGBlock* B) { return B->pred_end(); }
-
+
static StmtItr StmtBegin(const CFGBlock* B) { return B->rbegin(); }
- static StmtItr StmtEnd(const CFGBlock* B) { return B->rend(); }
-
+ static StmtItr StmtEnd(const CFGBlock* B) { return B->rend(); }
+
static BlockEdge PrevEdge(const CFGBlock* B, const CFGBlock* Prev) {
return BlockEdge(B, Prev, 0);
}
-
+
static BlockEdge NextEdge(const CFGBlock* B, const CFGBlock* Next) {
return BlockEdge(Next, B, 0);
}
@@ -105,7 +105,7 @@ template <> struct ItrTraits<backward_analysis_tag> {
//===----------------------------------------------------------------------===//
/// DataflowSolverTy - Generic dataflow solver.
//===----------------------------------------------------------------------===//
-
+
template <typename _DFValuesTy, // Usually a subclass of DataflowValues
typename _TransferFuncsTy,
typename _MergeOperatorTy,
@@ -120,7 +120,7 @@ public:
typedef _DFValuesTy DFValuesTy;
typedef _TransferFuncsTy TransferFuncsTy;
typedef _MergeOperatorTy MergeOperatorTy;
-
+
typedef typename _DFValuesTy::AnalysisDirTag AnalysisDirTag;
typedef typename _DFValuesTy::ValTy ValTy;
typedef typename _DFValuesTy::EdgeDataMapTy EdgeDataMapTy;
@@ -130,24 +130,24 @@ public:
typedef typename ItrTraits::NextBItr NextBItr;
typedef typename ItrTraits::PrevBItr PrevBItr;
typedef typename ItrTraits::StmtItr StmtItr;
-
+
//===----------------------------------------------------===//
// External interface: constructing and running the solver.
//===----------------------------------------------------===//
-
+
public:
DataflowSolver(DFValuesTy& d) : D(d), TF(d.getAnalysisData()) {}
- ~DataflowSolver() {}
-
+ ~DataflowSolver() {}
+
/// runOnCFG - Computes dataflow values for all blocks in a CFG.
void runOnCFG(CFG& cfg, bool recordStmtValues = false) {
// Set initial dataflow values and boundary conditions.
- D.InitializeValues(cfg);
+ D.InitializeValues(cfg);
// Solve the dataflow equations. This will populate D.EdgeDataMap
// with dataflow values.
SolveDataflowEquations(cfg, recordStmtValues);
}
-
+
/// runOnBlock - Computes dataflow values for a given block. This
/// should usually be invoked only after previously computing
/// dataflow values using runOnCFG, as runOnBlock is intended to
@@ -162,10 +162,10 @@ public:
ProcessBlock(B, recordStmtValues, AnalysisDirTag());
}
}
-
+
void runOnBlock(const CFGBlock& B, bool recordStmtValues) {
runOnBlock(&B, recordStmtValues);
- }
+ }
void runOnBlock(CFG::iterator& I, bool recordStmtValues) {
runOnBlock(*I, recordStmtValues);
}
@@ -177,13 +177,13 @@ public:
for (CFG::const_iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
runOnBlock(I, recordStmtValues);
}
-
+
//===----------------------------------------------------===//
// Internal solver logic.
//===----------------------------------------------------===//
-
+
private:
-
+
/// SolveDataflowEquations - Perform the actual worklist algorithm
/// to compute dataflow values.
void SolveDataflowEquations(CFG& cfg, bool recordStmtValues) {
@@ -191,27 +191,27 @@ private:
// for every block. Not all blocks are guaranteed to reach the exit block.
for (CFG::iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
WorkList.enqueue(&*I);
-
+
while (!WorkList.isEmpty()) {
const CFGBlock* B = WorkList.dequeue();
ProcessMerge(cfg, B);
ProcessBlock(B, recordStmtValues, AnalysisDirTag());
UpdateEdges(cfg, B, TF.getVal());
}
- }
-
+ }
+
void ProcessMerge(CFG& cfg, const CFGBlock* B) {
- ValTy& V = TF.getVal();
+ ValTy& V = TF.getVal();
TF.SetTopValue(V);
// Merge dataflow values from all predecessors of this block.
MergeOperatorTy Merge;
-
+
EdgeDataMapTy& M = D.getEdgeDataMap();
bool firstMerge = true;
-
+
for (PrevBItr I=ItrTraits::PrevBegin(B),E=ItrTraits::PrevEnd(B); I!=E; ++I){
-
+
CFGBlock *PrevBlk = *I;
if (!PrevBlk)
@@ -229,35 +229,35 @@ private:
Merge(V, EI->second);
}
}
-
+
// Set the data for the block.
D.getBlockDataMap()[B].copyValues(V);
- }
+ }
/// ProcessBlock - Process the transfer functions for a given block.
void ProcessBlock(const CFGBlock* B, bool recordStmtValues,
dataflow::forward_analysis_tag) {
-
+
for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I)
ProcessStmt(*I, recordStmtValues, AnalysisDirTag());
-
- TF.VisitTerminator(const_cast<CFGBlock*>(B));
+
+ TF.VisitTerminator(const_cast<CFGBlock*>(B));
}
-
+
void ProcessBlock(const CFGBlock* B, bool recordStmtValues,
dataflow::backward_analysis_tag) {
-
+
TF.VisitTerminator(const_cast<CFGBlock*>(B));
for (StmtItr I=ItrTraits::StmtBegin(B), E=ItrTraits::StmtEnd(B); I!=E;++I)
ProcessStmt(*I, recordStmtValues, AnalysisDirTag());
}
-
+
void ProcessStmt(const Stmt* S, bool record, dataflow::forward_analysis_tag) {
if (record) D.getStmtDataMap()[S] = TF.getVal();
- TF.BlockStmt_Visit(const_cast<Stmt*>(S));
+ TF.BlockStmt_Visit(const_cast<Stmt*>(S));
}
-
+
void ProcessStmt(const Stmt* S, bool record, dataflow::backward_analysis_tag){
TF.BlockStmt_Visit(const_cast<Stmt*>(S));
if (record) D.getStmtDataMap()[S] = TF.getVal();
@@ -272,12 +272,12 @@ private:
if (CFGBlock *NextBlk = *I)
UpdateEdgeValue(ItrTraits::NextEdge(B, NextBlk),V, NextBlk);
}
-
+
/// UpdateEdgeValue - Update the value associated with a given edge.
void UpdateEdgeValue(BlockEdge E, ValTy& V, const CFGBlock* TargetBlock) {
EdgeDataMapTy& M = D.getEdgeDataMap();
typename EdgeDataMapTy::iterator I = M.find(E);
-
+
if (I == M.end()) { // First computed value for this edge?
M[E].copyValues(V);
WorkList.enqueue(TargetBlock);
@@ -287,7 +287,7 @@ private:
WorkList.enqueue(TargetBlock);
}
}
-
+
private:
DFValuesTy& D;
DataflowWorkListTy WorkList;
diff --git a/include/clang/Analysis/FlowSensitive/DataflowValues.h b/include/clang/Analysis/FlowSensitive/DataflowValues.h
index 8d7ba94b46..648fe33ab0 100644
--- a/include/clang/Analysis/FlowSensitive/DataflowValues.h
+++ b/include/clang/Analysis/FlowSensitive/DataflowValues.h
@@ -24,7 +24,7 @@
/// Dataflow Directional Tag Classes. These are used for tag dispatching
/// within the dataflow solver/transfer functions to determine what direction
/// a dataflow analysis flows.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace clang {
namespace dataflow {
@@ -34,19 +34,19 @@ namespace dataflow {
//===----------------------------------------------------------------------===//
/// DataflowValues. Container class to store dataflow values for a CFG.
-//===----------------------------------------------------------------------===//
-
+//===----------------------------------------------------------------------===//
+
template <typename ValueTypes,
typename _AnalysisDirTag = dataflow::forward_analysis_tag >
class DataflowValues {
//===--------------------------------------------------------------------===//
// Type declarations.
- //===--------------------------------------------------------------------===//
+ //===--------------------------------------------------------------------===//
public:
typedef typename ValueTypes::ValTy ValTy;
- typedef typename ValueTypes::AnalysisDataTy AnalysisDataTy;
+ typedef typename ValueTypes::AnalysisDataTy AnalysisDataTy;
typedef _AnalysisDirTag AnalysisDirTag;
typedef llvm::DenseMap<ProgramPoint, ValTy> EdgeDataMapTy;
typedef llvm::DenseMap<const CFGBlock*, ValTy> BlockDataMapTy;
@@ -60,15 +60,15 @@ public:
/// isForwardAnalysis - Returns true if the dataflow values are computed
/// from a forward analysis.
bool isForwardAnalysis() { return isForwardAnalysis(AnalysisDirTag()); }
-
+
/// isBackwardAnalysis - Returns true if the dataflow values are computed
/// from a backward analysis.
bool isBackwardAnalysis() { return !isForwardAnalysis(); }
-
+
private:
bool isForwardAnalysis(dataflow::forward_analysis_tag) { return true; }
- bool isForwardAnalysis(dataflow::backward_analysis_tag) { return false; }
-
+ bool isForwardAnalysis(dataflow::backward_analysis_tag) { return false; }
+
//===--------------------------------------------------------------------===//
// Initialization and accessors methods.
//===--------------------------------------------------------------------===//
@@ -76,10 +76,10 @@ private:
public:
DataflowValues() : StmtDataMap(NULL) {}
~DataflowValues() { delete StmtDataMap; }
-
+
/// InitializeValues - Invoked by the solver to initialize state needed for
/// dataflow analysis. This method is usually specialized by subclasses.
- void InitializeValues(const CFG& cfg) {};
+ void InitializeValues(const CFG& cfg) {};
/// getEdgeData - Retrieves the dataflow values associated with a
@@ -89,28 +89,28 @@ public:
assert (I != EdgeDataMap.end() && "No data associated with Edge.");
return I->second;
}
-
+
const ValTy& getEdgeData(const BlockEdge& E) const {
return reinterpret_cast<DataflowValues*>(this)->getEdgeData(E);
- }
+ }
- /// getBlockData - Retrieves the dataflow values associated with a
+ /// getBlockData - Retrieves the dataflow values associated with a
/// specified CFGBlock. If the dataflow analysis is a forward analysis,
/// this data is associated with the END of the block. If the analysis
- /// is a backwards analysis, it is associated with the ENTRY of the block.
+ /// is a backwards analysis, it is associated with the ENTRY of the block.
ValTy& getBlockData(const CFGBlock* B) {
typename BlockDataMapTy::iterator I = BlockDataMap.find(B);
assert (I != BlockDataMap.end() && "No data associated with block.");
return I->second;
}
-
+
const ValTy& getBlockData(const CFGBlock* B) const {
return const_cast<DataflowValues*>(this)->getBlockData(B);
}
-
- /// getStmtData - Retrieves the dataflow values associated with a
+
+ /// getStmtData - Retrieves the dataflow values associated with a
/// specified Stmt. If the dataflow analysis is a forward analysis,
- /// this data corresponds to the point immediately before a Stmt.
+ /// this data corresponds to the point immediately before a Stmt.
/// If the analysis is a backwards analysis, it is associated with
/// the point after a Stmt. This data is only computed for block-level
/// expressions, and only when requested when the analysis is executed.
@@ -120,11 +120,11 @@ public:
assert (I != StmtDataMap->end() && "No data associated with statement.");
return I->second;
}
-
+
const ValTy& getStmtData(const Stmt* S) const {
return const_cast<DataflowValues*>(this)->getStmtData(S);
}
-
+
/// getEdgeDataMap - Retrieves the internal map between CFG edges and
/// dataflow values. Usually used by a dataflow solver to compute
/// values for blocks.
@@ -138,35 +138,35 @@ public:
/// to the dataflow values at the end of the block.
BlockDataMapTy& getBlockDataMap() { return BlockDataMap; }
const BlockDataMapTy& getBlockDataMap() const { return BlockDataMap; }
-
+
/// getStmtDataMap - Retrieves the internal map between Stmts and
/// dataflow values.
StmtDataMapTy& getStmtDataMap() {
if (!StmtDataMap) StmtDataMap = new StmtDataMapTy();
return *StmtDataMap;
}
-
+
const StmtDataMapTy& getStmtDataMap() const {
return const_cast<DataflowValues*>(this)->getStmtDataMap();
}
- /// getAnalysisData - Retrieves the meta data associated with a
- /// dataflow analysis for analyzing a particular CFG.
+ /// getAnalysisData - Retrieves the meta data associated with a
+ /// dataflow analysis for analyzing a particular CFG.
/// This is typically consumed by transfer function code (via the solver).
/// This can also be used by subclasses to interpret the dataflow values.
AnalysisDataTy& getAnalysisData() { return AnalysisData; }
const AnalysisDataTy& getAnalysisData() const { return AnalysisData; }
-
+
//===--------------------------------------------------------------------===//
// Internal data.
//===--------------------------------------------------------------------===//
-
+
protected:
EdgeDataMapTy EdgeDataMap;
BlockDataMapTy BlockDataMap;
StmtDataMapTy* StmtDataMap;
AnalysisDataTy AnalysisData;
-};
+};
} // end namespace clang
#endif
diff --git a/include/clang/Analysis/LocalCheckers.h b/include/clang/Analysis/LocalCheckers.h
index c6d53e60ef..ffcffe3305 100644
--- a/include/clang/Analysis/LocalCheckers.h
+++ b/include/clang/Analysis/LocalCheckers.h
@@ -31,28 +31,28 @@ class BugReporter;
class ObjCImplementationDecl;
class LangOptions;
class GRExprEngine;
-
-void CheckDeadStores(LiveVariables& L, BugReporter& BR);
-
+
+void CheckDeadStores(LiveVariables& L, BugReporter& BR);
+
void CheckUninitializedValues(CFG& cfg, ASTContext& Ctx, Diagnostic& Diags,
bool FullUninitTaint=false);
-
+
GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
- const LangOptions& lopts);
-
+ const LangOptions& lopts);
+
void CheckObjCDealloc(const ObjCImplementationDecl* D, const LangOptions& L,
BugReporter& BR);
-
+
void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID,
BugReporter& BR);
void CheckObjCUnusedIvar(const ObjCImplementationDecl *D, BugReporter& BR);
-
+
void RegisterAppleChecks(GRExprEngine& Eng, const Decl &D);
-
+
void CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR);
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Analysis/PathDiagnostic.h b/include/clang/Analysis/PathDiagnostic.h
index 994b35e5ef..809c83161f 100644
--- a/include/clang/Analysis/PathDiagnostic.h
+++ b/include/clang/Analysis/PathDiagnostic.h
@@ -38,21 +38,21 @@ class PathDiagnosticClient : public DiagnosticClient {
public:
PathDiagnosticClient() {}
virtual ~PathDiagnosticClient() {}
-
+
virtual void SetPreprocessor(Preprocessor *PP) {}
-
+
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info);
-
+
virtual void HandlePathDiagnostic(const PathDiagnostic* D) = 0;
-
- enum PathGenerationScheme { Minimal, Extensive };
- virtual PathGenerationScheme getGenerationScheme() const { return Minimal; }
+
+ enum PathGenerationScheme { Minimal, Extensive };
+ virtual PathGenerationScheme getGenerationScheme() const { return Minimal; }
virtual bool supportsLogicalOpControlFlow() const { return false; }
virtual bool supportsAllBlockEdges() const { return false; }
virtual bool useVerboseDescription() const { return true; }
-};
-
+};
+
//===----------------------------------------------------------------------===//
// Path-sensitive diagnostics.
//===----------------------------------------------------------------------===//
@@ -60,11 +60,11 @@ public:
class PathDiagnosticRange : public SourceRange {
public:
const bool isPoint;
-
+
PathDiagnosticRange(const SourceRange &R, bool isP = false)
: SourceRange(R), isPoint(isP) {}
};
-
+
class PathDiagnosticLocation {
private:
enum Kind { RangeK, SingleLocK, StmtK, DeclK } K;
@@ -75,27 +75,27 @@ private:
public:
PathDiagnosticLocation()
: K(SingleLocK), S(0), D(0), SM(0) {}
-
+
PathDiagnosticLocation(FullSourceLoc L)
: K(SingleLocK), R(L, L), S(0), D(0), SM(&L.getManager()) {}
-
+
PathDiagnosticLocation(const Stmt *s, const SourceManager &sm)
: K(StmtK), S(s), D(0), SM(&sm) {}
-
+
PathDiagnosticLocation(SourceRange r, const SourceManager &sm)
: K(RangeK), R(r), S(0), D(0), SM(&sm) {}
-
+
PathDiagnosticLocation(const Decl *d, const SourceManager &sm)
: K(DeclK), S(0), D(d), SM(&sm) {}
-
+
bool operator==(const PathDiagnosticLocation &X) const {
return K == X.K && R == X.R && S == X.S && D == X.D;
}
-
+
bool operator!=(const PathDiagnosticLocation &X) const {
return K != X.K || R != X.R || S != X.S || D != X.D;;
}
-
+
PathDiagnosticLocation& operator=(const PathDiagnosticLocation &X) {
K = X.K;
R = X.R;
@@ -104,26 +104,26 @@ public:
SM = X.SM;
return *this;
}
-
+
bool isValid() const {
return SM != 0;
}
-
+
const SourceManager& getSourceManager() const { assert(isValid());return *SM;}
-
+
FullSourceLoc asLocation() const;
PathDiagnosticRange asRange() const;
const Stmt *asStmt() const { assert(isValid()); return S; }
const Decl *asDecl() const { assert(isValid()); return D; }
-
+
bool hasRange() const { return K == StmtK || K == RangeK || K == DeclK; }
-
+
void invalidate() {
*this = PathDiagnosticLocation();
}
-
+
void flatten();
-
+
const SourceManager& getManager() const { assert(isValid()); return *SM; }
};
@@ -134,10 +134,10 @@ public:
PathDiagnosticLocationPair(const PathDiagnosticLocation &start,
const PathDiagnosticLocation &end)
: Start(start), End(end) {}
-
+
const PathDiagnosticLocation &getStart() const { return Start; }
const PathDiagnosticLocation &getEnd() const { return End; }
-
+
void flatten() {
Start.flatten();
End.flatten();
@@ -146,7 +146,7 @@ public:
//===----------------------------------------------------------------------===//
// Path "pieces" for path-sensitive diagnostics.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
class PathDiagnosticPiece {
public:
@@ -159,7 +159,7 @@ private:
const Kind kind;
const DisplayHint Hint;
std::vector<SourceRange> ranges;
-
+
// Do not implement:
PathDiagnosticPiece();
PathDiagnosticPiece(const PathDiagnosticPiece &P);
@@ -167,42 +167,42 @@ private:
protected:
PathDiagnosticPiece(const std::string& s, Kind k, DisplayHint hint = Below);
-
+
PathDiagnosticPiece(const char* s, Kind k, DisplayHint hint = Below);
PathDiagnosticPiece(Kind k, DisplayHint hint = Below);
-
+
public:
virtual ~PathDiagnosticPiece();
-
+
const std::string& getString() const { return str; }
-
+
/// getDisplayHint - Return a hint indicating where the diagnostic should
/// be displayed by the PathDiagnosticClient.
DisplayHint getDisplayHint() const { return Hint; }
-
+
virtual PathDiagnosticLocation getLocation() const = 0;
virtual void flattenLocations() = 0;
-
+
Kind getKind() const { return kind; }
-
+
void addRange(SourceRange R) { ranges.push_back(R); }
-
+
void addRange(SourceLocation B, SourceLocation E) {
ranges.push_back(SourceRange(B,E));
}
-
+
void addCodeModificationHint(const CodeModificationHint& Hint) {
CodeModificationHints.push_back(Hint);
}
-
+
typedef const SourceRange* range_iterator;
-
+
range_iterator ranges_begin() const {
return ranges.empty() ? NULL : &ranges[0];
}
-
- range_iterator ranges_end() const {
+
+ range_iterator ranges_end() const {
return ranges_begin() + ranges.size();
}
@@ -213,7 +213,7 @@ public:
}
code_modifications_iterator code_modifications_end() const {
- return CodeModificationHints.empty()? 0
+ return CodeModificationHints.empty()? 0
: &CodeModificationHints[0] + CodeModificationHints.size();
}
@@ -221,7 +221,7 @@ public:
return true;
}
};
-
+
class PathDiagnosticSpotPiece : public PathDiagnosticPiece {
private:
PathDiagnosticLocation Pos;
@@ -234,30 +234,30 @@ public:
assert(Pos.asLocation().isValid() &&
"PathDiagnosticSpotPiece's must have a valid location.");
if (addPosRange && Pos.hasRange()) addRange(Pos.asRange());
- }
+ }
PathDiagnosticLocation getLocation() const { return Pos; }
virtual void flattenLocations() { Pos.flatten(); }
};
-
+
class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
public:
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos,
const std::string& s, bool addPosRange = true)
: PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
-
+
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos, const char* s,
bool addPosRange = true)
: PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
-
+
~PathDiagnosticEventPiece();
static inline bool classof(const PathDiagnosticPiece* P) {
return P->getKind() == Event;
}
};
-
+
class PathDiagnosticControlFlowPiece : public PathDiagnosticPiece {
std::vector<PathDiagnosticLocationPair> LPairs;
public:
@@ -267,40 +267,40 @@ public:
: PathDiagnosticPiece(s, ControlFlow) {
LPairs.push_back(PathDiagnosticLocationPair(startPos, endPos));
}
-
+
PathDiagnosticControlFlowPiece(const PathDiagnosticLocation &startPos,
const PathDiagnosticLocation &endPos,
const char* s)
: PathDiagnosticPiece(s, ControlFlow) {
LPairs.push_back(PathDiagnosticLocationPair(startPos, endPos));
}
-
+
PathDiagnosticControlFlowPiece(const PathDiagnosticLocation &startPos,
const PathDiagnosticLocation &endPos)
: PathDiagnosticPiece(ControlFlow) {
LPairs.push_back(PathDiagnosticLocationPair(startPos, endPos));
}
-
+
~PathDiagnosticControlFlowPiece();
-
+
PathDiagnosticLocation getStartLocation() const {
assert(!LPairs.empty() &&
"PathDiagnosticControlFlowPiece needs at least one location.");
return LPairs[0].getStart();
}
-
+
PathDiagnosticLocation getEndLocation() const {
assert(!LPairs.empty() &&
"PathDiagnosticControlFlowPiece needs at least one location.");
return LPairs[0].getEnd();
}
-
+
void push_back(const PathDiagnosticLocationPair &X) { LPairs.push_back(X); }
-
+
virtual PathDiagnosticLocation getLocation() const {
return getStartLocation();
}
-
+
typedef std::vector<PathDiagnosticLocationPair>::iterator iterator;
iterator begin() { return LPairs.begin(); }
iterator end() { return LPairs.end(); }
@@ -308,7 +308,7 @@ public:
virtual void flattenLocations() {
for (iterator I=begin(), E=end(); I!=E; ++I) I->flatten();
}
-
+
typedef std::vector<PathDiagnosticLocationPair>::const_iterator
const_iterator;
const_iterator begin() const { return LPairs.begin(); }
@@ -318,32 +318,32 @@ public:
return P->getKind() == ControlFlow;
}
};
-
+
class PathDiagnosticMacroPiece : public PathDiagnosticSpotPiece {
std::vector<PathDiagnosticPiece*> SubPieces;
public:
PathDiagnosticMacroPiece(const PathDiagnosticLocation &pos)
: PathDiagnosticSpotPiece(pos, "", Macro) {}
-
+
~PathDiagnosticMacroPiece();
-
+
bool containsEvent() const;
void push_back(PathDiagnosticPiece* P) { SubPieces.push_back(P); }
-
+
typedef std::vector<PathDiagnosticPiece*>::iterator iterator;
iterator begin() { return SubPieces.begin(); }
iterator end() { return SubPieces.end(); }
-
+
virtual void flattenLocations() {
PathDiagnosticSpotPiece::flattenLocations();
for (iterator I=begin(), E=end(); I!=E; ++I) (*I)->flattenLocations();
}
-
+
typedef std::vector<PathDiagnosticPiece*>::const_iterator const_iterator;
const_iterator begin() const { return SubPieces.begin(); }
const_iterator end() const { return SubPieces.end(); }
-
+
static inline bool classof(const PathDiagnosticPiece* P) {
return P->getKind() == Macro;
}
@@ -359,129 +359,129 @@ class PathDiagnostic {
std::string Desc;
std::string Category;
std::deque<std::string> OtherDesc;
-
-public:
+
+public:
PathDiagnostic();
-
+
PathDiagnostic(const char* bugtype, const char* desc, const char* category);
-
- PathDiagnostic(const std::string& bugtype, const std::string& desc,
+
+ PathDiagnostic(const std::string& bugtype, const std::string& desc,
const std::string& category);
-
+
~PathDiagnostic();
-
+
const std::string& getDescription() const { return Desc; }
const std::string& getBugType() const { return BugType; }
- const std::string& getCategory() const { return Category; }
-
+ const std::string& getCategory() const { return Category; }
+
typedef std::deque<std::string>::const_iterator meta_iterator;
meta_iterator meta_begin() const { return OtherDesc.begin(); }
meta_iterator meta_end() const { return OtherDesc.end(); }
void addMeta(const std::string& s) { OtherDesc.push_back(s); }
void addMeta(const char* s) { OtherDesc.push_back(s); }
-
+
PathDiagnosticLocation getLocation() const {
assert(Size > 0 && "getLocation() requires a non-empty PathDiagnostic.");
return rbegin()->getLocation();
}
-
+
void push_front(PathDiagnosticPiece* piece) {
path.push_front(piece);
++Size;
}
-
+
void push_back(PathDiagnosticPiece* piece) {
path.push_back(piece);
++Size;
}
-
+
PathDiagnosticPiece* back() {
return path.back();
}
-
+
const PathDiagnosticPiece* back() const {
return path.back();
}
-
+
unsigned size() const { return Size; }
bool empty() const { return Size == 0; }
-
+
void resetPath(bool deletePieces = true);
-
+
class iterator {
- public:
+ public:
typedef std::deque<PathDiagnosticPiece*>::iterator ImplTy;
-
+
typedef PathDiagnosticPiece value_type;
typedef value_type& reference;
typedef value_type* pointer;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
-
+
private:
ImplTy I;
-
+
public:
iterator(const ImplTy& i) : I(i) {}
-
+
bool operator==(const iterator& X) const { return I == X.I; }
bool operator!=(const iterator& X) const { return I != X.I; }
-
+
PathDiagnosticPiece& operator*() const { return **I; }
PathDiagnosticPiece* operator->() const { return *I; }
-
+
iterator& operator++() { ++I; return *this; }
iterator& operator--() { --I; return *this; }
};
-
+
class const_iterator {
- public:
+ public:
typedef std::deque<PathDiagnosticPiece*>::const_iterator ImplTy;
-
+
typedef const PathDiagnosticPiece value_type;
typedef value_type& reference;
typedef value_type* pointer;
typedef ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
-
+
private:
ImplTy I;
-
+
public:
const_iterator(const ImplTy& i) : I(i) {}
-
+
bool operator==(const const_iterator& X) const { return I == X.I; }
bool operator!=(const const_iterator& X) const { return I != X.I; }
-
+
reference operator*() const { return **I; }
pointer operator->() const { return *I; }
-
+
const_iterator& operator++() { ++I; return *this; }
const_iterator& operator--() { --I; return *this; }
};
-
+
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-
+
// forward iterator creation methods.
-
+
iterator begin() { return path.begin(); }
iterator end() { return path.end(); }
-
+
const_iterator begin() const { return path.begin(); }
const_iterator end() const { return path.end(); }
-
+
// reverse iterator creation methods.
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
-
+
void flattenLocations() {
for (iterator I = begin(), E = end(); I != E; ++I) I->flattenLocations();
}
};
-
-
+
+
} //end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/AnalysisContext.h b/include/clang/Analysis/PathSensitive/AnalysisContext.h
index e69b4f529f..22f9902975 100644
--- a/include/clang/Analysis/PathSensitive/AnalysisContext.h
+++ b/include/clang/Analysis/PathSensitive/AnalysisContext.h
@@ -27,7 +27,7 @@ class CFG;
class LiveVariables;
class ParentMap;
class ImplicitParamDecl;
-
+
/// AnalysisContext contains the context data for the function or method under
/// analysis.
class AnalysisContext {
@@ -47,7 +47,7 @@ public:
CFG *getCFG();
ParentMap &getParentMap();
LiveVariables *getLiveVariables();
-
+
/// Return the ImplicitParamDecl* associated with 'self' if this
/// AnalysisContext wraps an ObjCMethodDecl. Returns NULL otherwise.
const ImplicitParamDecl *getSelfDecl() const;
@@ -58,7 +58,7 @@ class AnalysisContextManager {
ContextMap Contexts;
public:
~AnalysisContextManager();
-
+
AnalysisContext *getContext(const Decl *D);
};
@@ -87,10 +87,10 @@ public:
CFG *getCFG() const { return getAnalysisContext()->getCFG(); }
- LiveVariables *getLiveVariables() const {
+ LiveVariables *getLiveVariables() const {
return getAnalysisContext()->getLiveVariables();
}
-
+
const ImplicitParamDecl *getSelfDecl() const {
return Ctx->getSelfDecl();
}
@@ -120,8 +120,8 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
const LocationContext *parent, const Stmt *s);
- static bool classof(const LocationContext* Ctx) {
- return Ctx->getKind() == StackFrame;
+ static bool classof(const LocationContext* Ctx) {
+ return Ctx->getKind() == StackFrame;
}
};
@@ -140,8 +140,8 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
const LocationContext *parent, const Stmt *s);
- static bool classof(const LocationContext* Ctx) {
- return Ctx->getKind() == Scope;
+ static bool classof(const LocationContext* Ctx) {
+ return Ctx->getKind() == Scope;
}
};
@@ -156,6 +156,6 @@ public:
ScopeContext *getScope(AnalysisContext *ctx, const LocationContext *parent,
const Stmt *s);
};
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/AnalysisManager.h b/include/clang/Analysis/PathSensitive/AnalysisManager.h
index 97534c8716..948bb1fe8a 100644
--- a/include/clang/Analysis/PathSensitive/AnalysisManager.h
+++ b/include/clang/Analysis/PathSensitive/AnalysisManager.h
@@ -38,7 +38,7 @@ class AnalysisManager : public BugReporterData {
ConstraintManagerCreator CreateConstraintMgr;
enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
-
+
bool DisplayedFunction;
bool VisualizeEGDot;
bool VisualizeEGUbi;
@@ -55,13 +55,13 @@ class AnalysisManager : public BugReporterData {
bool TrimGraph;
public:
- AnalysisManager(Decl *d, ASTContext &ctx, Diagnostic &diags,
+ AnalysisManager(Decl *d, ASTContext &ctx, Diagnostic &diags,
const LangOptions &lang, PathDiagnosticClient *pd,
StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr,
- bool displayProgress, bool vizdot, bool vizubi,
+ bool displayProgress, bool vizdot, bool vizubi,
bool purge, bool eager, bool trim)
- : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
+ : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
AScope(ScopeDecl), DisplayedFunction(!displayProgress),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
@@ -69,15 +69,15 @@ public:
EntryContext = ContextMgr.getContext(d);
}
-
- AnalysisManager(ASTContext &ctx, Diagnostic &diags,
+
+ AnalysisManager(ASTContext &ctx, Diagnostic &diags,
const LangOptions &lang, PathDiagnosticClient *pd,
StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr,
- bool displayProgress, bool vizdot, bool vizubi,
+ bool displayProgress, bool vizdot, bool vizubi,
bool purge, bool eager, bool trim)
- : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
+ : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd),
CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
AScope(ScopeDecl), DisplayedFunction(!displayProgress),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
@@ -90,17 +90,17 @@ public:
EntryContext = ContextMgr.getContext(D);
DisplayedFunction = false;
}
-
- const Decl *getCodeDecl() const {
+
+ const Decl *getCodeDecl() const {
assert (AScope == ScopeDecl);
return EntryContext->getDecl();
}
-
+
Stmt *getBody() const {
assert (AScope == ScopeDecl);
return EntryContext->getBody();
}
-
+
StoreManagerCreator getStoreManagerCreator() {
return CreateStoreMgr;
};
@@ -108,11 +108,11 @@ public:
ConstraintManagerCreator getConstraintManagerCreator() {
return CreateConstraintMgr;
}
-
+
virtual CFG *getCFG() {
return EntryContext->getCFG();
}
-
+
virtual ParentMap &getParentMap() {
return EntryContext->getParentMap();
}
@@ -120,31 +120,31 @@ public:
virtual LiveVariables *getLiveVariables() {
return EntryContext->getLiveVariables();
}
-
+
virtual ASTContext &getASTContext() {
return Ctx;
}
-
+
virtual SourceManager &getSourceManager() {
return getASTContext().getSourceManager();
}
-
+
virtual Diagnostic &getDiagnostic() {
return Diags;
}
-
+
const LangOptions &getLangOptions() const {
return LangInfo;
}
-
+
virtual PathDiagnosticClient *getPathDiagnosticClient() {
- return PD.get();
+ return PD.get();
}
StackFrameContext *getEntryStackFrame() {
return LocCtxMgr.getStackFrame(EntryContext, 0, 0);
}
-
+
bool shouldVisualizeGraphviz() const { return VisualizeEGDot; }
bool shouldVisualizeUbigraph() const { return VisualizeEGUbi; }
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
index 74d08e8410..69cd9db77c 100644
--- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h
+++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//
// This file defines BasicValueFactory, a class that manages the lifetime
-// of APSInt objects and symbolic constraints used by GRExprEngine
+// of APSInt objects and symbolic constraints used by GRExprEngine
// and related classes.
//
//===----------------------------------------------------------------------===//
@@ -24,7 +24,7 @@
#include "llvm/ADT/ImmutableList.h"
namespace clang {
-
+
class GRState;
class CompoundValData : public llvm::FoldingSetNode {
@@ -32,13 +32,13 @@ class CompoundValData : public llvm::FoldingSetNode {
llvm::ImmutableList<SVal> L;
public:
- CompoundValData(QualType t, llvm::ImmutableList<SVal> l)
+ CompoundValData(QualType t, llvm::ImmutableList<SVal> l)
: T(t), L(l) {}
typedef llvm::ImmutableList<SVal>::iterator iterator;
iterator begin() const { return L.begin(); }
- iterator end() const { return L.end(); }
-
+ iterator end() const { return L.end(); }
+
static void Profile(llvm::FoldingSetNodeID& ID, QualType T,
llvm::ImmutableList<SVal> L);
@@ -51,16 +51,16 @@ class LazyCompoundValData : public llvm::FoldingSetNode {
public:
LazyCompoundValData(const GRState *st, const TypedRegion *r)
: state(st), region(r) {}
-
+
const GRState *getState() const { return state; }
const TypedRegion *getRegion() const { return region; }
-
+
static void Profile(llvm::FoldingSetNodeID& ID, const GRState *state,
const TypedRegion *region);
-
+
void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, state, region); }
};
-
+
class BasicValueFactory {
typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<llvm::APSInt> >
APSIntSetTy;
@@ -77,28 +77,28 @@ class BasicValueFactory {
llvm::FoldingSet<LazyCompoundValData> LazyCompoundValDataSet;
public:
- BasicValueFactory(ASTContext& ctx, llvm::BumpPtrAllocator& Alloc)
+ BasicValueFactory(ASTContext& ctx, llvm::BumpPtrAllocator& Alloc)
: Ctx(ctx), BPAlloc(Alloc), PersistentSVals(0), PersistentSValPairs(0),
SValListFactory(Alloc) {}
~BasicValueFactory();
- ASTContext& getContext() const { return Ctx; }
+ ASTContext& getContext() const { return Ctx; }
const llvm::APSInt& getValue(const llvm::APSInt& X);
const llvm::APSInt& getValue(const llvm::APInt& X, bool isUnsigned);
const llvm::APSInt& getValue(uint64_t X, unsigned BitWidth, bool isUnsigned);
const llvm::APSInt& getValue(uint64_t X, QualType T);
-
+
/// Convert - Create a new persistent APSInt with the same value as 'From'
/// but with the bitwidth and signedness of 'To'.
const llvm::APSInt& Convert(const llvm::APSInt& To,
const llvm::APSInt& From) {
-
+
if (To.isUnsigned() == From.isUnsigned() &&
To.getBitWidth() == From.getBitWidth())
return From;
-
+
return getValue(From.getSExtValue(),
To.getBitWidth(),
To.isUnsigned());
@@ -108,11 +108,11 @@ public:
QualType T = isUnsigned ? Ctx.UnsignedIntTy : Ctx.IntTy;
return getValue(X, T);
}
-
+
inline const llvm::APSInt& getMaxValue(const llvm::APSInt &v) {
return getValue(llvm::APSInt::getMaxValue(v.getBitWidth(), v.isUnsigned()));
}
-
+
inline const llvm::APSInt& getMinValue(const llvm::APSInt &v) {
return getValue(llvm::APSInt::getMinValue(v.getBitWidth(), v.isUnsigned()));
}
@@ -122,25 +122,25 @@ public:
bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
return getValue(llvm::APSInt::getMaxValue(Ctx.getTypeSize(T), isUnsigned));
}
-
+
inline const llvm::APSInt& getMinValue(QualType T) {
assert(T->isIntegerType() || Loc::IsLocType(T));
bool isUnsigned = T->isUnsignedIntegerType() || Loc::IsLocType(T);
return getValue(llvm::APSInt::getMinValue(Ctx.getTypeSize(T), isUnsigned));
}
-
+
inline const llvm::APSInt& Add1(const llvm::APSInt& V) {
llvm::APSInt X = V;
++X;
return getValue(X);
}
-
+
inline const llvm::APSInt& Sub1(const llvm::APSInt& V) {
llvm::APSInt X = V;
--X;
return getValue(X);
}
-
+
inline const llvm::APSInt& getZeroWithPtrWidth(bool isUnsigned = true) {
return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
}
@@ -152,21 +152,21 @@ public:
inline const llvm::APSInt& getTruthValue(bool b, QualType T) {
return getValue(b ? 1 : 0, Ctx.getTypeSize(T), false);
}
-
+
inline const llvm::APSInt& getTruthValue(bool b) {
return getTruthValue(b, Ctx.IntTy);
}
-
- const CompoundValData *getCompoundValData(QualType T,
+
+ const CompoundValData *getCompoundValData(QualType T,
llvm::ImmutableList<SVal> Vals);
-
+
const LazyCompoundValData *getLazyCompoundValData(const GRState *state,
const TypedRegion *region);
-
+
llvm::ImmutableList<SVal> getEmptySValList() {
return SValListFactory.GetEmptyList();
}
-
+
llvm::ImmutableList<SVal> consVals(SVal X, llvm::ImmutableList<SVal> L) {
return SValListFactory.Add(X, L);
}
@@ -174,13 +174,13 @@ public:
const llvm::APSInt* EvaluateAPSInt(BinaryOperator::Opcode Op,
const llvm::APSInt& V1,
const llvm::APSInt& V2);
-
+
const std::pair<SVal, uintptr_t>&
getPersistentSValWithData(const SVal& V, uintptr_t Data);
-
+
const std::pair<SVal, SVal>&
- getPersistentSValPair(const SVal& V1, const SVal& V2);
-
+ getPersistentSValPair(const SVal& V1, const SVal& V2);
+
const SVal* getPersistentSVal(SVal X);
};
diff --git a/include/clang/Analysis/PathSensitive/BugReporter.h b/include/clang/Analysis/PathSensitive/BugReporter.h
index 0997edc6bb..55555c6df0 100644
--- a/include/clang/Analysis/PathSensitive/BugReporter.h
+++ b/include/clang/Analysis/PathSensitive/BugReporter.h
@@ -27,7 +27,7 @@
#include <list>
namespace clang {
-
+
class PathDiagnostic;
class PathDiagnosticPiece;
class PathDiagnosticClient;
@@ -40,7 +40,7 @@ class GRState;
class Stmt;
class BugType;
class ParentMap;
-
+
//===----------------------------------------------------------------------===//
// Interface for individual bug reports.
//===----------------------------------------------------------------------===//
@@ -51,10 +51,10 @@ public:
virtual PathDiagnosticPiece* VisitNode(const ExplodedNode* N,
const ExplodedNode* PrevN,
BugReporterContext& BRC) = 0;
-
+
virtual bool isOwnedByReporterContext() { return true; }
};
-
+
// FIXME: Combine this with RangedBugReport and remove RangedBugReport.
class BugReport : public BugReporterVisitor {
protected:
@@ -63,7 +63,7 @@ protected:
std::string Description;
const ExplodedNode *EndNode;
SourceRange R;
-
+
protected:
friend class BugReporter;
friend class BugReportEquivClass;
@@ -71,7 +71,7 @@ protected:
virtual void Profile(llvm::FoldingSetNodeID& hash) const {
hash.AddInteger(getLocation().getRawEncoding());
}
-
+
public:
class NodeResolver {
public:
@@ -79,58 +79,58 @@ public:
virtual const ExplodedNode*
getOriginalNode(const ExplodedNode* N) = 0;
};
-
+
BugReport(BugType& bt, const char* desc, const ExplodedNode *n)
: BT(bt), Description(desc), EndNode(n) {}
-
+
BugReport(BugType& bt, const char* shortDesc, const char* desc,
const ExplodedNode *n)
: BT(bt), ShortDescription(shortDesc), Description(desc), EndNode(n) {}
virtual ~BugReport();
-
+
virtual bool isOwnedByReporterContext() { return false; }
const BugType& getBugType() const { return BT; }
BugType& getBugType() { return BT; }
-
+
// FIXME: Perhaps this should be moved into a subclass?
const ExplodedNode* getEndNode() const { return EndNode; }
-
+
// FIXME: Do we need this? Maybe getLocation() should return a ProgramPoint
// object.
// FIXME: If we do need it, we can probably just make it private to
// BugReporter.
const Stmt* getStmt() const;
-
+
const std::string& getDescription() const { return Description; }
const std::string& getShortDescription() const {
return ShortDescription.empty() ? Description : ShortDescription;
}
-
+
// FIXME: Is this needed?
virtual std::pair<const char**,const char**> getExtraDescriptiveText() {
return std::make_pair((const char**)0,(const char**)0);
}
-
+
// FIXME: Perhaps move this into a subclass.
virtual PathDiagnosticPiece* getEndPath(BugReporterContext& BRC,
const ExplodedNode* N);
-
+
/// getLocation - Return the "definitive" location of the reported bug.
/// While a bug can span an entire path, usually there is a specific
/// location that can be used to identify where the key issue occured.
/// This location is used by clients rendering diagnostics.
virtual SourceLocation getLocation() const;
-
+
/// getRanges - Returns the source ranges associated with this bug.
virtual void getRanges(const SourceRange*& beg, const SourceRange*& end);
virtual PathDiagnosticPiece* VisitNode(const ExplodedNode* N,
const ExplodedNode* PrevN,
BugReporterContext& BR);
-
+
virtual void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N) {}
};
@@ -138,11 +138,11 @@ public:
//===----------------------------------------------------------------------===//
// BugTypes (collections of related reports).
//===----------------------------------------------------------------------===//
-
+
class BugReportEquivClass : public llvm::FoldingSetNode {
// List of *owned* BugReport objects.
std::list<BugReport*> Reports;
-
+
friend class BugReporter;
void AddReport(BugReport* R) { Reports.push_back(R); }
public:
@@ -164,7 +164,7 @@ public:
BugReport* operator*() const { return *impl; }
BugReport* operator->() const { return *impl; }
};
-
+
class const_iterator {
std::list<BugReport*>::const_iterator impl;
public:
@@ -175,14 +175,14 @@ public:
const BugReport* operator*() const { return *impl; }
const BugReport* operator->() const { return *impl; }
};
-
+
iterator begin() { return iterator(Reports.begin()); }
iterator end() { return iterator(Reports.end()); }
-
+
const_iterator begin() const { return const_iterator(Reports.begin()); }
const_iterator end() const { return const_iterator(Reports.end()); }
};
-
+
class BugType {
private:
const std::string Name;
@@ -192,45 +192,45 @@ private:
public:
BugType(const char *name, const char* cat) : Name(name), Category(cat) {}
virtual ~BugType();
-
+
// FIXME: Should these be made strings as well?
const std::string& getName() const { return Name; }
const std::string& getCategory() const { return Category; }
- virtual void FlushReports(BugReporter& BR);
+ virtual void FlushReports(BugReporter& BR);
typedef llvm::FoldingSet<BugReportEquivClass>::iterator iterator;
iterator begin() { return EQClasses.begin(); }
iterator end() { return EQClasses.end(); }
-
+
typedef llvm::FoldingSet<BugReportEquivClass>::const_iterator const_iterator;
const_iterator begin() const { return EQClasses.begin(); }
const_iterator end() const { return EQClasses.end(); }
};
-
+
//===----------------------------------------------------------------------===//
// Specialized subclasses of BugReport.
//===----------------------------------------------------------------------===//
-
+
// FIXME: Collapse this with the default BugReport class.
class RangedBugReport : public BugReport {
std::vector<SourceRange> Ranges;
public:
RangedBugReport(BugType& D, const char* description, ExplodedNode *n)
: BugReport(D, description, n) {}
-
+
RangedBugReport(BugType& D, const char *shortDescription,
const char *description, ExplodedNode *n)
: BugReport(D, shortDescription, description, n) {}
-
+
~RangedBugReport();
// FIXME: Move this out of line.
void addRange(SourceRange R) { Ranges.push_back(R); }
-
+
// FIXME: Move this out of line.
void getRanges(const SourceRange*& beg, const SourceRange*& end) {
-
+
if (Ranges.empty()) {
beg = NULL;
end = NULL;
@@ -241,36 +241,36 @@ public:
}
}
};
-
+
class EnhancedBugReport : public RangedBugReport {
public:
typedef void (*VisitorCreator)(BugReporterContext &BRcC, const void *data,
const ExplodedNode *N);
-
+
private:
typedef std::vector<std::pair<VisitorCreator, const void*> > Creators;
Creators creators;
-
+
public:
EnhancedBugReport(BugType& D, const char* description, ExplodedNode *n)
: RangedBugReport(D, description, n) {}
-
+
EnhancedBugReport(BugType& D, const char *shortDescription,
const char *description, ExplodedNode *n)
: RangedBugReport(D, shortDescription, description, n) {}
-
+
~EnhancedBugReport() {}
-
- void registerInitialVisitors(BugReporterContext& BRC, const ExplodedNode* N) {
+
+ void registerInitialVisitors(BugReporterContext& BRC, const ExplodedNode* N) {
for (Creators::iterator I = creators.begin(), E = creators.end(); I!=E; ++I)
I->first(BRC, I->second, N);
}
-
+
void addVisitorCreator(VisitorCreator creator, const void *data) {
creators.push_back(std::make_pair(creator, data));
}
};
-
+
//===----------------------------------------------------------------------===//
// BugReporter and friends.
//===----------------------------------------------------------------------===//
@@ -278,15 +278,15 @@ public:
class BugReporterData {
public:
virtual ~BugReporterData();
- virtual Diagnostic& getDiagnostic() = 0;
- virtual PathDiagnosticClient* getPathDiagnosticClient() = 0;
+ virtual Diagnostic& getDiagnostic() = 0;
+ virtual PathDiagnosticClient* getPathDiagnosticClient() = 0;
virtual ASTContext& getASTContext() = 0;
virtual SourceManager& getSourceManager() = 0;
virtual CFG* getCFG() = 0;
virtual ParentMap& getParentMap() = 0;
virtual LiveVariables* getLiveVariables() = 0;
};
-
+
class BugReporter {
public:
enum Kind { BaseBRKind, GRBugReporterKind };
@@ -296,9 +296,9 @@ private:
BugTypesTy::Factory F;
BugTypesTy BugTypes;
- const Kind kind;
+ const Kind kind;
BugReporterData& D;
-
+
void FlushReport(BugReportEquivClass& EQ);
protected:
@@ -307,40 +307,40 @@ protected:
public:
BugReporter(BugReporterData& d) : BugTypes(F.GetEmptySet()), kind(BaseBRKind), D(d) {}
virtual ~BugReporter();
-
+
void FlushReports();
-
+
Kind getKind() const { return kind; }
-
+
Diagnostic& getDiagnostic() {
return D.getDiagnostic();
}
-
+
PathDiagnosticClient* getPathDiagnosticClient() {
return D.getPathDiagnosticClient();
}
-
+
typedef BugTypesTy::iterator iterator;
iterator begin() { return BugTypes.begin(); }
iterator end() { return BugTypes.end(); }
-
+
ASTContext& getContext() { return D.getASTContext(); }
-
+
SourceManager& getSourceManager() { return D.getSourceManager(); }
-
+
CFG* getCFG() { return D.getCFG(); }
-
+
ParentMap& getParentMap() { return D.getParentMap(); }
-
+
LiveVariables* getLiveVariables() { return D.getLiveVariables(); }
-
+
virtual void GeneratePathDiagnostic(PathDiagnostic& PD,
BugReportEquivClass& EQ) {}
void Register(BugType *BT);
-
+
void EmitReport(BugReport *R);
-
+
void EmitBasicReport(const char* BugName, const char* BugStr,
SourceLocation Loc,
SourceRange* RangeBeg, unsigned NumRanges);
@@ -348,28 +348,28 @@ public:
void EmitBasicReport(const char* BugName, const char* BugCategory,
const char* BugStr, SourceLocation Loc,
SourceRange* RangeBeg, unsigned NumRanges);
-
-
+
+
void EmitBasicReport(const char* BugName, const char* BugStr,
SourceLocation Loc) {
EmitBasicReport(BugName, BugStr, Loc, 0, 0);
}
-
+
void EmitBasicReport(const char* BugName, const char* BugCategory,
const char* BugStr, SourceLocation Loc) {
EmitBasicReport(BugName, BugCategory, BugStr, Loc, 0, 0);
}
-
+
void EmitBasicReport(const char* BugName, const char* BugStr,
SourceLocation Loc, SourceRange R) {
EmitBasicReport(BugName, BugStr, Loc, &R, 1);
}
-
+
void EmitBasicReport(const char* BugName, const char* Category,
const char* BugStr, SourceLocation Loc, SourceRange R) {
EmitBasicReport(BugName, Category, BugStr, Loc, &R, 1);
}
-
+
static bool classof(const BugReporter* R) { return true; }
};
@@ -377,12 +377,12 @@ public:
class GRBugReporter : public BugReporter {
GRExprEngine& Eng;
llvm::SmallSet<SymbolRef, 10> NotableSymbols;
-public:
+public:
GRBugReporter(BugReporterData& d, GRExprEngine& eng)
: BugReporter(d, GRBugReporterKind), Eng(eng) {}
-
+
virtual ~GRBugReporter();
-
+
/// getEngine - Return the analysis engine used to analyze a given
/// function or method.
GRExprEngine &getEngine() { return Eng; }
@@ -390,76 +390,76 @@ public:
/// getGraph - Get the exploded graph created by the analysis engine
/// for the analyzed method or function.
ExplodedGraph &getGraph();
-
+
/// getStateManager - Return the state manager used by the analysis
/// engine.
GRStateManager &getStateManager();
-
+
virtual void GeneratePathDiagnostic(PathDiagnostic& PD,
BugReportEquivClass& R);
void addNotableSymbol(SymbolRef Sym) {
NotableSymbols.insert(Sym);
}
-
+
bool isNotable(SymbolRef Sym) const {
return (bool) NotableSymbols.count(Sym);
}
-
+
/// classof - Used by isa<>, cast<>, and dyn_cast<>.
static bool classof(const BugReporter* R) {
return R->getKind() == GRBugReporterKind;
}
};
-
+
class BugReporterContext {
GRBugReporter &BR;
std::vector<BugReporterVisitor*> Callbacks;
public:
BugReporterContext(GRBugReporter& br) : BR(br) {}
virtual ~BugReporterContext();
-
+
void addVisitor(BugReporterVisitor* visitor) {
if (visitor) Callbacks.push_back(visitor);
}
-
+
typedef std::vector<BugReporterVisitor*>::iterator visitor_iterator;
visitor_iterator visitor_begin() { return Callbacks.begin(); }
- visitor_iterator visitor_end() { return Callbacks.end(); }
-
- GRBugReporter& getBugReporter() { return BR; }
-
+ visitor_iterator visitor_end() { return Callbacks.end(); }
+
+ GRBugReporter& getBugReporter() { return BR; }
+
ExplodedGraph &getGraph() { return BR.getGraph(); }
-
+
void addNotableSymbol(SymbolRef Sym) {
// FIXME: For now forward to GRBugReporter.
BR.addNotableSymbol(Sym);
}
-
+
bool isNotable(SymbolRef Sym) const {
// FIXME: For now forward to GRBugReporter.
return BR.isNotable(Sym);
}
-
+
GRStateManager& getStateManager() {
return BR.getStateManager();
}
-
+
ValueManager& getValueManager() {
return getStateManager().getValueManager();
}
-
+
ASTContext& getASTContext() {
return BR.getContext();
}
-
+
SourceManager& getSourceManager() {
return BR.getSourceManager();
}
-
+
const Decl &getCodeDecl();
const CFG &getCFG();
- virtual BugReport::NodeResolver& getNodeResolver() = 0;
+ virtual BugReport::NodeResolver& getNodeResolver() = 0;
};
class DiagBugReport : public RangedBugReport {
@@ -468,24 +468,24 @@ class DiagBugReport : public RangedBugReport {
public:
DiagBugReport(BugType& D, const char* desc, FullSourceLoc l) :
RangedBugReport(D, desc, 0), L(l) {}
-
+
virtual ~DiagBugReport() {}
-
+
// FIXME: Move out-of-line (virtual function).
SourceLocation getLocation() const { return L; }
-
- void addString(const std::string& s) { Strs.push_back(s); }
-
+
+ void addString(const std::string& s) { Strs.push_back(s); }
+
typedef std::list<std::string>::const_iterator str_iterator;
str_iterator str_begin() const { return Strs.begin(); }
str_iterator str_end() const { return Strs.end(); }
};
-
+
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
-
+
namespace bugreporter {
-
+
const Stmt *GetDerefExpr(const ExplodedNode *N);
const Stmt *GetReceiverExpr(const ExplodedNode *N);
const Stmt *GetDenomExpr(const ExplodedNode *N);
@@ -496,7 +496,7 @@ void registerTrackNullOrUndefValue(BugReporterContext& BRC, const void *stmt,
const ExplodedNode* N);
} // end namespace clang::bugreporter
-
+
//===----------------------------------------------------------------------===//
} // end clang namespace
diff --git a/include/clang/Analysis/PathSensitive/Checker.h b/include/clang/Analysis/PathSensitive/Checker.h
index 3dc484569d..4e00d69cdb 100644
--- a/include/clang/Analysis/PathSensitive/Checker.h
+++ b/include/clang/Analysis/PathSensitive/Checker.h
@@ -46,21 +46,21 @@ public:
GRExprEngine &eng,
ExplodedNode *pred,
const void *tag, bool preVisit)
- : Dst(dst), B(builder), Eng(eng), Pred(pred),
+ : Dst(dst), B(builder), Eng(eng), Pred(pred),
OldSink(B.BuildSinks), OldTag(B.Tag),
OldPointKind(B.PointKind), OldHasGen(B.HasGeneratedNode) {
- //assert(Dst.empty()); // This is a fake assertion.
+ //assert(Dst.empty()); // This is a fake assertion.
// See GRExprEngine::CheckerVisit(), CurrSet is repeatedly used.
B.Tag = tag;
if (preVisit)
- B.PointKind = ProgramPoint::PreStmtKind;
+ B.PointKind = ProgramPoint::PreStmtKind;
}
-
+
~CheckerContext() {
if (!B.BuildSinks && !B.HasGeneratedNode)
Dst.Add(Pred);
}
-
+
ConstraintManager &getConstraintManager() {
return Eng.getConstraintManager();
}
@@ -68,7 +68,7 @@ public:
GRStmtNodeBuilder &getNodeBuilder() { return B; }
ExplodedNode *&getPredecessor() { return Pred; }
const GRState *getState() { return B.GetState(Pred); }
-
+
ASTContext &getASTContext() {
return Eng.getContext();
}
@@ -76,26 +76,26 @@ public:
ExplodedNode *GenerateNode(const Stmt *S, bool markAsSink = false) {
return GenerateNode(S, getState(), markAsSink);
}
-
+
ExplodedNode *GenerateNode(const Stmt* S, const GRState *state,
- bool markAsSink = false) {
+ bool markAsSink = false) {
ExplodedNode *node = B.generateNode(S, state, Pred);
-
+
if (markAsSink && node)
node->markAsSink();
-
+
return node;
}
-
+
void addTransition(ExplodedNode *node) {
Dst.Add(node);
}
-
+
void EmitReport(BugReport *R) {
Eng.getBugReporter().EmitReport(R);
}
};
-
+
class Checker {
private:
friend class GRExprEngine;
@@ -105,11 +105,11 @@ private:
GRExprEngine &Eng,
const Stmt *stmt,
ExplodedNode *Pred, bool isPrevisit) {
- CheckerContext C(Dst, Builder, Eng, Pred, getTag(), isPrevisit);
+ CheckerContext C(Dst, Builder, Eng, Pred, getTag(), isPrevisit);
assert(isPrevisit && "Only previsit supported for now.");
_PreVisit(C, stmt);
}
-
+
public:
virtual ~Checker() {}
virtual void _PreVisit(CheckerContext &C, const Stmt *stmt) = 0;
@@ -119,4 +119,4 @@ public:
} // end clang namespace
#endif
-
+
diff --git a/include/clang/Analysis/PathSensitive/CheckerVisitor.h b/include/clang/Analysis/PathSensitive/CheckerVisitor.h
index 6ec192adee..e74f49c9a7 100644
--- a/include/clang/Analysis/PathSensitive/CheckerVisitor.h
+++ b/include/clang/Analysis/PathSensitive/CheckerVisitor.h
@@ -14,14 +14,14 @@
#ifndef LLVM_CLANG_ANALYSIS_CHECKERVISITOR
#define LLVM_CLANG_ANALYSIS_CHECKERVISITOR
#include "clang/Analysis/PathSensitive/Checker.h"
-
+
namespace clang {
//===----------------------------------------------------------------------===//
// Checker visitor interface. Used by subclasses of Checker to specify their
// own checker visitor logic.
//===----------------------------------------------------------------------===//
-
+
/// CheckerVisitor - This class implements a simple visitor for Stmt subclasses.
/// Since Expr derives from Stmt, this also includes support for visiting Exprs.
template<typename ImplClass>
@@ -47,13 +47,13 @@ break;
#include "clang/Analysis/PathSensitive/CheckerVisitor.def"
}
}
-
+
#define PREVISIT(NAME) \
void PreVisit ## NAME(CheckerContext &C, const NAME* S) {}
#include "clang/Analysis/PathSensitive/CheckerVisitor.def"
};
-
+
} // end clang namespace
#endif
-
+
diff --git a/include/clang/Analysis/PathSensitive/ConstraintManager.h b/include/clang/Analysis/PathSensitive/ConstraintManager.h
index e3b6489ad0..1e758d8cb8 100644
--- a/include/clang/Analysis/PathSensitive/ConstraintManager.h
+++ b/include/clang/Analysis/PathSensitive/ConstraintManager.h
@@ -30,32 +30,32 @@ class SVal;
class ConstraintManager {
public:
virtual ~ConstraintManager();
- virtual const GRState *Assume(const GRState *state, SVal Cond,
+ virtual const GRState *Assume(const GRState *state, SVal Cond,
bool Assumption) = 0;
- virtual const GRState *AssumeInBound(const GRState *state, SVal Idx,
+ virtual const GRState *AssumeInBound(const GRState *state, SVal Idx,
SVal UpperBound, bool Assumption) = 0;
-
+
std::pair<const GRState*, const GRState*> AssumeDual(const GRState *state,
DefinedSVal Cond) {
return std::make_pair(Assume(state, Cond, true),
- Assume(state, Cond, false));
+ Assume(state, Cond, false));
}
virtual const llvm::APSInt* getSymVal(const GRState *state,
SymbolRef sym) const = 0;
- virtual bool isEqual(const GRState *state, SymbolRef sym,
+ virtual bool isEqual(const GRState *state, SymbolRef sym,
const llvm::APSInt& V) const = 0;
virtual const GRState *RemoveDeadBindings(const GRState *state,
SymbolReaper& SymReaper) = 0;
- virtual void print(const GRState *state, llvm::raw_ostream& Out,
+ virtual void print(const GRState *state, llvm::raw_ostream& Out,
const char* nl, const char *sep) = 0;
virtual void EndPath(const GRState *state) {}
-
+
/// canReasonAbout - Not all ConstraintManagers can accurately reason about
/// all SVal values. This method returns true if the ConstraintManager can
/// reasonably handle a given SVal value. This is typically queried by
diff --git a/include/clang/Analysis/PathSensitive/Environment.h b/include/clang/Analysis/PathSensitive/Environment.h
index b96b1a77b6..6d5c5678e5 100644
--- a/include/clang/Analysis/PathSensitive/Environment.h
+++ b/include/clang/Analysis/PathSensitive/Environment.h
@@ -35,61 +35,61 @@ class LiveVariables;
class Environment {
private:
friend class EnvironmentManager;
-
+
// Type definitions.
typedef llvm::ImmutableMap<const Stmt*,SVal> BindingsTy;
// Data.
BindingsTy ExprBindings;
AnalysisContext *ACtx;
-
+
Environment(BindingsTy eb, AnalysisContext *aCtx)
: ExprBindings(eb), ACtx(aCtx) {}
-
-public:
+
+public:
typedef BindingsTy::iterator iterator;
iterator begin() const { return ExprBindings.begin(); }
iterator end() const { return ExprBindings.end(); }
-
+
SVal LookupExpr(const Stmt* E) const {
const SVal* X = ExprBindings.lookup(E);
return X ? *X : UnknownVal();
}
-
+
SVal GetSVal(const Stmt* Ex, ValueManager& ValMgr) const;
-
+
AnalysisContext &getAnalysisContext() const { return *ACtx; }
-
+
/// Profile - Profile the contents of an Environment object for use
/// in a FoldingSet.
static void Profile(llvm::FoldingSetNodeID& ID, const Environment* E) {
E->ExprBindings.Profile(ID);
}
-
+
/// Profile - Used to profile the contents of this object for inclusion
/// in a FoldingSet.
void Profile(llvm::FoldingSetNodeID& ID) const {
Profile(ID, this);
}
-
+
bool operator==(const Environment& RHS) const {
return ExprBindings == RHS.ExprBindings;
}
};
-
+
class EnvironmentManager {
private:
typedef Environment::BindingsTy::Factory FactoryTy;
FactoryTy F;
-
-public:
+
+public:
EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {}
~EnvironmentManager() {}
-
+
Environment getInitialEnvironment(AnalysisContext *ACtx) {
return Environment(F.GetEmptyMap(), ACtx);
}
-
+
Environment BindExpr(Environment Env, const Stmt *S, SVal V,
bool Invalidate);
@@ -97,7 +97,7 @@ public:
SymbolReaper &SymReaper, const GRState *ST,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
};
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
index 4ffed8950a..fc41333f27 100644
--- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h
+++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h
@@ -38,7 +38,7 @@ class ASTContext;
// contain a specific kind of state. Typed-specialized versions are defined
// on top of these classes.
//===----------------------------------------------------------------------===//
-
+
class ExplodedNode : public llvm::FoldingSetNode {
friend class ExplodedGraph;
friend class GRCoreEngine;
@@ -46,16 +46,16 @@ class ExplodedNode : public llvm::FoldingSetNode {
friend class GRBranchNodeBuilder;
friend class GRIndirectGotoNodeBuilder;
friend class GRSwitchNodeBuilder;
- friend class GREndPathNodeBuilder;
-
+ friend class GREndPathNodeBuilder;
+
class NodeGroup {
enum { Size1 = 0x0, SizeOther = 0x1, AuxFlag = 0x2, Mask = 0x3 };
uintptr_t P;
-
+
unsigned getKind() const {
return P & 0x1;
}
-
+
void* getPtr() const {
assert (!getFlag());
return reinterpret_cast<void*>(P & ~Mask);
@@ -64,55 +64,55 @@ class ExplodedNode : public llvm::FoldingSetNode {
ExplodedNode *getNode() const {
return reinterpret_cast<ExplodedNode*>(getPtr());
}
-
+
public:
NodeGroup() : P(0) {}
-
+
~NodeGroup();
-
+
ExplodedNode** begin() const;
-
+
ExplodedNode** end() const;
-
+
unsigned size() const;
-
+
bool empty() const { return size() == 0; }
-
+
void addNode(ExplodedNode* N);
-
+
void setFlag() {
assert (P == 0);
P = AuxFlag;
}
-
+
bool getFlag() const {
return P & AuxFlag ? true : false;
}
- };
-
+ };
+
/// Location - The program location (within a function body) associated
/// with this node.
const ProgramPoint Location;
-
+
/// State - The state associated with this node.
const GRState* State;
-
+
/// Preds - The predecessors of this node.
NodeGroup Preds;
-
+
/// Succs - The successors of this node.
NodeGroup Succs;
public:
- explicit ExplodedNode(const ProgramPoint& loc, const GRState* state)
+ explicit ExplodedNode(const ProgramPoint& loc, const GRState* state)
: Location(loc), State(state) {}
/// getLocation - Returns the edge associated with the given node.
ProgramPoint getLocation() const { return Location; }
- const LocationContext *getLocationContext() const {
- return getLocation().getLocationContext();
+ const LocationContext *getLocationContext() const {
+ return getLocation().getLocationContext();
}
const Decl &getCodeDecl() const { return *getLocationContext()->getDecl(); }
@@ -126,14 +126,14 @@ public:
template <typename T>
const T* getLocationAs() const { return llvm::dyn_cast<T>(&Location); }
- static void Profile(llvm::FoldingSetNodeID &ID,
+ static void Profile(llvm::FoldingSetNodeID &ID,
const ProgramPoint& Loc, const GRState* state);
void Profile(llvm::FoldingSetNodeID& ID) const {
Profile(ID, getLocation(), getState());
}
- /// addPredeccessor - Adds a predecessor to the current node, and
+ /// addPredeccessor - Adds a predecessor to the current node, and
/// in tandem add this node as a successor of the other node.
void addPredecessor(ExplodedNode* V);
@@ -141,18 +141,18 @@ public:
unsigned pred_size() const { return Preds.size(); }
bool succ_empty() const { return Succs.empty(); }
bool pred_empty() const { return Preds.empty(); }
-
+
bool isSink() const { return Succs.getFlag(); }
- void markAsSink() { Succs.setFlag(); }
+ void markAsSink() { Succs.setFlag(); }
ExplodedNode* getFirstPred() {
return pred_empty() ? NULL : *(pred_begin());
}
-
+
const ExplodedNode* getFirstPred() const {
return const_cast<ExplodedNode*>(this)->getFirstPred();
}
-
+
// Iterators over successor and predecessor vertices.
typedef ExplodedNode** succ_iterator;
typedef const ExplodedNode* const * const_succ_iterator;
@@ -164,7 +164,7 @@ public:
const_pred_iterator pred_begin() const {
return const_cast<ExplodedNode*>(this)->pred_begin();
- }
+ }
const_pred_iterator pred_end() const {
return const_cast<ExplodedNode*>(this)->pred_end();
}
@@ -180,26 +180,26 @@ public:
}
// For debugging.
-
+
public:
-
+
class Auditor {
public:
virtual ~Auditor();
virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst) = 0;
};
-
+
static void SetAuditor(Auditor* A);
};
// FIXME: Is this class necessary?
class InterExplodedGraphMap {
llvm::DenseMap<const ExplodedNode*, ExplodedNode*> M;
- friend class ExplodedGraph;
+ friend class ExplodedGraph;
public:
ExplodedNode* getMappedNode(const ExplodedNode* N) const;
-
+
InterExplodedGraphMap() {};
virtual ~InterExplodedGraphMap() {}
};
@@ -211,7 +211,7 @@ protected:
// Type definitions.
typedef llvm::SmallVector<ExplodedNode*,2> RootsTy;
typedef llvm::SmallVector<ExplodedNode*,10> EndNodesTy;
-
+
/// Roots - The roots of the simulation graph. Usually there will be only
/// one, but clients are free to establish multiple subgraphs within a single
/// SimulGraph. Moreover, these subgraphs can often merge when paths from
@@ -227,10 +227,10 @@ protected:
/// Allocator - BumpPtrAllocator to create nodes.
llvm::BumpPtrAllocator Allocator;
-
+
/// Ctx - The ASTContext used to "interpret" CodeDecl.
ASTContext& Ctx;
-
+
/// NumNodes - The number of nodes in the graph.
unsigned NumNodes;
@@ -242,7 +242,7 @@ public:
ExplodedNode* getNode(const ProgramPoint& L, const GRState *State,
bool* IsNew = 0);
-
+
ExplodedGraph* MakeEmptyGraph() const {
return new ExplodedGraph(Ctx);
}
@@ -265,7 +265,7 @@ public:
unsigned num_roots() const { return Roots.size(); }
unsigned num_eops() const { return EndNodes.size(); }
-
+
bool empty() const { return NumNodes == 0; }
unsigned size() const { return NumNodes; }
@@ -278,29 +278,29 @@ public:
typedef NodeTy* const * const_eop_iterator;
typedef AllNodesTy::iterator node_iterator;
typedef AllNodesTy::const_iterator const_node_iterator;
-
+
node_iterator nodes_begin() { return Nodes.begin(); }
node_iterator nodes_end() { return Nodes.end(); }
-
+
const_node_iterator nodes_begin() const { return Nodes.begin(); }
-
+
const_node_iterator nodes_end() const { return Nodes.end(); }
-
+
roots_iterator roots_begin() { return Roots.begin(); }
-
+
roots_iterator roots_end() { return Roots.end(); }
-
+
const_roots_iterator roots_begin() const { return Roots.begin(); }
-
- const_roots_iterator roots_end() const { return Roots.end(); }
+
+ const_roots_iterator roots_end() const { return Roots.end(); }
eop_iterator eop_begin() { return EndNodes.begin(); }
-
+
eop_iterator eop_end() { return EndNodes.end(); }
-
+
const_eop_iterator eop_begin() const { return EndNodes.begin(); }
-
+
const_eop_iterator eop_end() const { return EndNodes.end(); }
llvm::BumpPtrAllocator& getAllocator() { return Allocator; }
@@ -322,24 +322,24 @@ public:
class ExplodedNodeSet {
typedef llvm::SmallPtrSet<ExplodedNode*,5> ImplTy;
ImplTy Impl;
-
+
public:
ExplodedNodeSet(ExplodedNode* N) {
assert (N && !static_cast<ExplodedNode*>(N)->isSink());
Impl.insert(N);
}
-
+
ExplodedNodeSet() {}
-
+
inline void Add(ExplodedNode* N) {
if (N && !static_cast<ExplodedNode*>(N)->isSink()) Impl.insert(N);
}
-
+
ExplodedNodeSet& operator=(const ExplodedNodeSet &X) {
Impl = X.Impl;
return *this;
}
-
+
typedef ImplTy::iterator iterator;
typedef ImplTy::const_iterator const_iterator;
@@ -347,14 +347,14 @@ public:
inline bool empty() const { return Impl.empty(); }
inline void clear() { Impl.clear(); }
-
+
inline iterator begin() { return Impl.begin(); }
inline iterator end() { return Impl.end(); }
-
+
inline const_iterator begin() const { return Impl.begin(); }
inline const_iterator end() const { return Impl.end(); }
-};
-
+};
+
} // end clang namespace
// GraphTraits
@@ -364,54 +364,54 @@ namespace llvm {
typedef clang::ExplodedNode NodeType;
typedef NodeType::succ_iterator ChildIteratorType;
typedef llvm::df_iterator<NodeType*> nodes_iterator;
-
+
static inline NodeType* getEntryNode(NodeType* N) {
return N;
}
-
+
static inline ChildIteratorType child_begin(NodeType* N) {
return N->succ_begin();
}
-
+
static inline ChildIteratorType child_end(NodeType* N) {
return N->succ_end();
}
-
+
static inline nodes_iterator nodes_begin(NodeType* N) {
return df_begin(N);
}
-
+
static inline nodes_iterator nodes_end(NodeType* N) {
return df_end(N);
}
};
-
+
template<> struct GraphTraits<const clang::ExplodedNode*> {
typedef const clang::ExplodedNode NodeType;
typedef NodeType::const_succ_iterator ChildIteratorType;
typedef llvm::df_iterator<NodeType*> nodes_iterator;
-
+
static inline NodeType* getEntryNode(NodeType* N) {
return N;
}
-
+
static inline ChildIteratorType child_begin(NodeType* N) {
return N->succ_begin();
}
-
+
static inline ChildIteratorType child_end(NodeType* N) {
return N->succ_end();
}
-
+
static inline nodes_iterator nodes_begin(NodeType* N) {
return df_begin(N);
}
-
+
static inline nodes_iterator nodes_end(NodeType* N) {
return df_end(N);
}
};
-
+
} // end llvm namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/GRAuditor.h b/include/clang/Analysis/PathSensitive/GRAuditor.h
index 6233ca8908..015c82e80b 100644
--- a/include/clang/Analysis/PathSensitive/GRAuditor.h
+++ b/include/clang/Analysis/PathSensitive/GRAuditor.h
@@ -1,5 +1,5 @@
//==- GRAuditor.h - Observers of the creation of ExplodedNodes------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -22,14 +22,14 @@ namespace clang {
class ExplodedNode;
class GRStateManager;
-
+
class GRAuditor {
public:
virtual ~GRAuditor() {}
virtual bool Audit(ExplodedNode* N, GRStateManager& M) = 0;
};
-
-
+
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/GRBlockCounter.h b/include/clang/Analysis/PathSensitive/GRBlockCounter.h
index b4fd2704b8..67ed9532db 100644
--- a/include/clang/Analysis/PathSensitive/GRBlockCounter.h
+++ b/include/clang/Analysis/PathSensitive/GRBlockCounter.h
@@ -1,5 +1,5 @@
//==- GRBlockCounter.h - ADT for counting block visits -------------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -24,27 +24,27 @@ namespace clang {
class GRBlockCounter {
void* Data;
-
- GRBlockCounter(void* D) : Data(D) {}
+
+ GRBlockCounter(void* D) : Data(D) {}
public:
GRBlockCounter() : Data(0) {}
-
+
unsigned getNumVisited(unsigned BlockID) const;
-
+
class Factory {
void* F;
public:
Factory(llvm::BumpPtrAllocator& Alloc);
~Factory();
-
+
GRBlockCounter GetEmptyCounter();
GRBlockCounter IncrementCount(GRBlockCounter BC, unsigned BlockID);
};
-
+
friend class Factory;
};
} // end clang namespace
-
+
#endif
diff --git a/include/clang/Analysis/PathSensitive/GRCoreEngine.h b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
index 72aaf6ebb5..48b86b9eaf 100644
--- a/include/clang/Analysis/PathSensitive/GRCoreEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRCoreEngine.h
@@ -1,5 +1,5 @@
//==- GRCoreEngine.h - Path-Sensitive Dataflow Engine --------------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -26,7 +26,7 @@
namespace clang {
//===----------------------------------------------------------------------===//
-/// GRCoreEngine - Implements the core logic of the graph-reachability
+/// GRCoreEngine - Implements the core logic of the graph-reachability
/// analysis. It traverses the CFG and generates the ExplodedGraph.
/// Program "states" are treated as opaque void pointers.
/// The template class GRCoreEngine (which subclasses GRCoreEngine)
@@ -45,61 +45,61 @@ class GRCoreEngine {
/// G - The simulation graph. Each node is a (location,state) pair.
llvm::OwningPtr<ExplodedGraph> G;
-
+
/// WList - A set of queued nodes that need to be processed by the
/// worklist algorithm. It is up to the implementation of WList to decide
/// the order that nodes are processed.
GRWorkList* WList;
-
+
/// BCounterFactory - A factory object for created GRBlockCounter objects.
/// These are used to record for key nodes in the ExplodedGraph the
/// number of times different CFGBlocks have been visited along a path.
GRBlockCounter::Factory BCounterFactory;
-
+
void GenerateNode(const ProgramPoint& Loc, const GRState* State,
ExplodedNode* Pred);
-
+
void HandleBlockEdge(const BlockEdge& E, ExplodedNode* Pred);
void HandleBlockEntrance(const BlockEntrance& E, ExplodedNode* Pred);
void HandleBlockExit(CFGBlock* B, ExplodedNode* Pred);
void HandlePostStmt(const PostStmt& S, CFGBlock* B,
unsigned StmtIdx, ExplodedNode *Pred);
-
+
void HandleBranch(Stmt* Cond, Stmt* Term, CFGBlock* B,
- ExplodedNode* Pred);
+ ExplodedNode* Pred);
/// Get the initial state from the subengine.
- const GRState* getInitialState(const LocationContext *InitLoc) {
+ const GRState* getInitialState(const LocationContext *InitLoc) {
return SubEngine.getInitialState(InitLoc);
}
void ProcessEndPath(GREndPathNodeBuilder& Builder);
-
+
void ProcessStmt(Stmt* S, GRStmtNodeBuilder& Builder);
-
+
bool ProcessBlockEntrance(CFGBlock* Blk, const GRState* State,
GRBlockCounter BC);
-
+
void ProcessBranch(Stmt* Condition, Stmt* Terminator,
GRBranchNodeBuilder& Builder);
void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& Builder);
-
+
void ProcessSwitch(GRSwitchNodeBuilder& Builder);
private:
GRCoreEngine(const GRCoreEngine&); // Do not implement.
GRCoreEngine& operator=(const GRCoreEngine&);
-
+
public:
/// Construct a GRCoreEngine object to analyze the provided CFG using
/// a DFS exploration of the exploded graph.
GRCoreEngine(ASTContext& ctx, GRSubEngine& subengine)
- : SubEngine(subengine), G(new ExplodedGraph(ctx)),
+ : SubEngine(subengine), G(new ExplodedGraph(ctx)),
WList(GRWorkList::MakeBFS()),
BCounterFactory(G->getAllocator()) {}
@@ -116,7 +116,7 @@ public:
/// getGraph - Returns the exploded graph.
ExplodedGraph& getGraph() { return *G.get(); }
-
+
/// takeGraph - Returns the exploded graph. Ownership of the graph is
/// transfered to the caller.
ExplodedGraph* takeGraph() { return G.take(); }
@@ -125,13 +125,13 @@ public:
/// steps. Returns true if there is still simulation state on the worklist.
bool ExecuteWorkList(const LocationContext *L, unsigned Steps);
};
-
+
class GRStmtNodeBuilder {
GRCoreEngine& Eng;
CFGBlock& B;
const unsigned Idx;
ExplodedNode* Pred;
- ExplodedNode* LastNode;
+ ExplodedNode* LastNode;
GRStateManager& Mgr;
GRAuditor* Auditor;
@@ -141,23 +141,23 @@ public:
bool HasGeneratedNode;
ProgramPoint::Kind PointKind;
const void *Tag;
-
- const GRState* CleanedState;
-
+
+ const GRState* CleanedState;
+
typedef llvm::SmallPtrSet<ExplodedNode*,5> DeferredTy;
DeferredTy Deferred;
-
+
void GenerateAutoTransition(ExplodedNode* N);
-
+
public:
- GRStmtNodeBuilder(CFGBlock* b, unsigned idx, ExplodedNode* N,
- GRCoreEngine* e, GRStateManager &mgr);
-
+ GRStmtNodeBuilder(CFGBlock* b, unsigned idx, ExplodedNode* N,
+ GRCoreEngine* e, GRStateManager &mgr);
+
~GRStmtNodeBuilder();
-
+
ExplodedNode* getBasePredecessor() const { return Pred; }
-
+
ExplodedNode* getLastNode() const {
return LastNode ? (LastNode->isSink() ? NULL : LastNode) : NULL;
}
@@ -167,26 +167,26 @@ public:
}
GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
-
+
unsigned getCurrentBlockCount() const {
return getBlockCounter().getNumVisited(B.getBlockID());
- }
+ }
ExplodedNode* generateNode(PostStmt PP,const GRState* St,ExplodedNode* Pred) {
HasGeneratedNode = true;
return generateNodeInternal(PP, St, Pred);
}
-
+
ExplodedNode* generateNode(const Stmt *S, const GRState *St,
ExplodedNode *Pred, ProgramPoint::Kind K) {
HasGeneratedNode = true;
- if (PurgingDeadSymbols)
- K = ProgramPoint::PostPurgeDeadSymbolsKind;
+ if (PurgingDeadSymbols)
+ K = ProgramPoint::PostPurgeDeadSymbolsKind;
return generateNodeInternal(S, St, Pred, K, Tag);
}
-
+
ExplodedNode* generateNode(const Stmt *S, const GRState *St,
ExplodedNode *Pred) {
return generateNode(S, St, Pred, PointKind);
@@ -195,16 +195,16 @@ public:
ExplodedNode*
generateNodeInternal(const ProgramPoint &PP, const GRState* State,
ExplodedNode* Pred);
-
+
ExplodedNode*
generateNodeInternal(const Stmt* S, const GRState* State, ExplodedNode* Pred,
ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
const void *tag = 0);
-
+
/// getStmt - Return the current block-level expression associated with
/// this builder.
Stmt* getStmt() const { return B[Idx]; }
-
+
/// getBlock - Return the CFGBlock associated with the block-level expression
/// of this builder.
CFGBlock* getBlock() const { return &B; }
@@ -218,40 +218,40 @@ public:
return Pred->getState();
}
- ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred,
+ ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred,
const GRState* St) {
return MakeNode(Dst, S, Pred, St, PointKind);
}
-
+
ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred,
- const GRState* St, ProgramPoint::Kind K) {
-
+ const GRState* St, ProgramPoint::Kind K) {
+
const GRState* PredState = GetState(Pred);
-
+
// If the state hasn't changed, don't generate a new node.
if (!BuildSinks && St == PredState && Auditor == 0) {
Dst.Add(Pred);
return NULL;
}
-
+
ExplodedNode* N = generateNode(S, St, Pred, K);
-
- if (N) {
+
+ if (N) {
if (BuildSinks)
N->markAsSink();
else {
if (Auditor && Auditor->Audit(N, Mgr))
N->markAsSink();
-
+
Dst.Add(N);
}
}
-
+
return N;
}
-
+
ExplodedNode* MakeSinkNode(ExplodedNodeSet& Dst, Stmt* S,
- ExplodedNode* Pred, const GRState* St) {
+ ExplodedNode* Pred, const GRState* St) {
bool Tmp = BuildSinks;
BuildSinks = true;
ExplodedNode* N = MakeNode(Dst, S, Pred, St);
@@ -260,7 +260,7 @@ public:
}
};
-
+
class GRBranchNodeBuilder {
GRCoreEngine& Eng;
CFGBlock* Src;
@@ -270,44 +270,44 @@ class GRBranchNodeBuilder {
typedef llvm::SmallVector<ExplodedNode*,3> DeferredTy;
DeferredTy Deferred;
-
+
bool GeneratedTrue;
bool GeneratedFalse;
bool InFeasibleTrue;
bool InFeasibleFalse;
-
+
public:
GRBranchNodeBuilder(CFGBlock* src, CFGBlock* dstT, CFGBlock* dstF,
- ExplodedNode* pred, GRCoreEngine* e)
+ ExplodedNode* pred, GRCoreEngine* e)
: Eng(*e), Src(src), DstT(dstT), DstF(dstF), Pred(pred),
GeneratedTrue(false), GeneratedFalse(false),
InFeasibleTrue(!DstT), InFeasibleFalse(!DstF) {}
-
+
~GRBranchNodeBuilder();
-
+
ExplodedNode* getPredecessor() const { return Pred; }
const ExplodedGraph& getGraph() const { return *Eng.G; }
GRBlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter();}
-
+
ExplodedNode* generateNode(const GRState* State, bool branch);
-
+
CFGBlock* getTargetBlock(bool branch) const {
return branch ? DstT : DstF;
- }
-
+ }
+
void markInfeasible(bool branch) {
if (branch)
InFeasibleTrue = GeneratedTrue = true;
else
InFeasibleFalse = GeneratedFalse = true;
}
-
+
bool isFeasible(bool branch) {
return branch ? !InFeasibleTrue : !InFeasibleFalse;
}
-
+
const GRState* getState() const {
return getPredecessor()->getState();
}
@@ -318,81 +318,81 @@ class GRIndirectGotoNodeBuilder {
CFGBlock* Src;
CFGBlock& DispatchBlock;
Expr* E;
- ExplodedNode* Pred;
+ ExplodedNode* Pred;
public:
- GRIndirectGotoNodeBuilder(ExplodedNode* pred, CFGBlock* src, Expr* e,
+ GRIndirectGotoNodeBuilder(ExplodedNode* pred, CFGBlock* src, Expr* e,
CFGBlock* dispatch, GRCoreEngine* eng)
: Eng(*eng), Src(src), DispatchBlock(*dispatch), E(e), Pred(pred) {}
class iterator {
CFGBlock::succ_iterator I;
-
- friend class GRIndirectGotoNodeBuilder;
- iterator(CFGBlock::succ_iterator i) : I(i) {}
+
+ friend class GRIndirectGotoNodeBuilder;
+ iterator(CFGBlock::succ_iterator i) : I(i) {}
public:
-
+
iterator& operator++() { ++I; return *this; }
bool operator!=(const iterator& X) const { return I != X.I; }
-
+
LabelStmt* getLabel() const {
return llvm::cast<LabelStmt>((*I)->getLabel());
}
-
+
CFGBlock* getBlock() const {
return *I;
}
};
-
+
iterator begin() { return iterator(DispatchBlock.succ_begin()); }
iterator end() { return iterator(DispatchBlock.succ_end()); }
-
+
ExplodedNode* generateNode(const iterator& I, const GRState* State,
bool isSink = false);
-
+
Expr* getTarget() const { return E; }
const GRState* getState() const { return Pred->State; }
};
-
+
class GRSwitchNodeBuilder {
GRCoreEngine& Eng;
CFGBlock* Src;
Expr* Condition;
- ExplodedNode* Pred;
+ ExplodedNode* Pred;
public:
GRSwitchNodeBuilder(ExplodedNode* pred, CFGBlock* src,
Expr* condition, GRCoreEngine* eng)
: Eng(*eng), Src(src), Condition(condition), Pred(pred) {}
-
+
class iterator {
CFGBlock::succ_reverse_iterator I;
-
- friend class GRSwitchNodeBuilder;
- iterator(CFGBlock::succ_reverse_iterator i) : I(i) {}
+
+ friend class GRSwitchNodeBuilder;
+ iterator(CFGBlock::succ_reverse_iterator i) : I(i) {}
public:
iterator& operator++() { ++I; return *this; }
bool operator!=(const iterator& X) const { return I != X.I; }
-
+
CaseStmt* getCase() const {
return llvm::cast<CaseStmt>((*I)->getLabel());
}
-
+
CFGBlock* getBlock() const {
return *I;
}
};
-
+
iterator begin() { return iterator(Src->succ_rbegin()+1); }
iterator end() { return iterator(Src->succ_rend()); }
-
+
ExplodedNode* generateCaseStmtNode(const iterator& I, const GRState* State);
-
+
ExplodedNode* generateDefaultCaseNode(const GRState* State,
bool isSink = false);
-
+
Expr* getCondition() const { return Condition; }
const GRState* getState() const { return Pred->State; }
@@ -401,28 +401,28 @@ public:
class GREndPathNodeBuilder {
GRCoreEngine& Eng;
CFGBlock& B;
- ExplodedNode* Pred;
+ ExplodedNode* Pred;
bool HasGeneratedNode;
-
+
public:
GREndPathNodeBuilder(CFGBlock* b, ExplodedNode* N, GRCoreEngine* e)
- : Eng(*e), B(*b), Pred(N), HasGeneratedNode(false) {}
-
+ : Eng(*e), B(*b), Pred(N), HasGeneratedNode(false) {}
+
~GREndPathNodeBuilder();
-
+
ExplodedNode* getPredecessor() const { return Pred; }
-
- GRBlockCounter getBlockCounter() const {
+
+ GRBlockCounter getBlockCounter() const {
return Eng.WList->getBlockCounter();
}
-
+
unsigned getCurrentBlockCount() const {
return getBlockCounter().getNumVisited(B.getBlockID());
- }
-
+ }
+
ExplodedNode* generateNode(const GRState* State, const void *tag = 0,
ExplodedNode *P = 0);
-
+
CFGBlock* getBlock() const { return &B; }
const GRState* getState() const {
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index 1410c011c7..bd8f714a63 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -26,54 +26,54 @@
#include "clang/AST/Type.h"
#include "clang/AST/ExprObjC.h"
-namespace clang {
-
+namespace clang {
+
class PathDiagnosticClient;
class Diagnostic;
class ObjCForCollectionStmt;
class Checker;
-class GRExprEngine : public GRSubEngine {
+class GRExprEngine : public GRSubEngine {
AnalysisManager &AMgr;
GRCoreEngine CoreEngine;
-
+
/// G - the simulation graph.
ExplodedGraph& G;
-
+
/// Builder - The current GRStmtNodeBuilder which is used when building the
/// nodes for a given statement.
GRStmtNodeBuilder* Builder;
-
+
/// StateMgr - Object that manages the data for all created states.
GRStateManager StateMgr;
/// SymMgr - Object that manages the symbol information.
SymbolManager& SymMgr;
-
+
/// ValMgr - Object that manages/creates SVals.
ValueManager &ValMgr;
-
+
/// SVator - SValuator object that creates SVals from expressions.
SValuator &SVator;
-
+
/// EntryNode - The immediate predecessor node.
ExplodedNode* EntryNode;
/// CleanedState - The state for EntryNode "cleaned" of all dead
/// variables and symbols (as determined by a liveness analysis).
- const GRState* CleanedState;
-
+ const GRState* CleanedState;
+
/// CurrentStmt - The current block-level statement.
Stmt* CurrentStmt;
-
+
// Obj-C Class Identifiers.
IdentifierInfo* NSExceptionII;
-
+
// Obj-C Selectors.
Selector* NSExceptionInstanceRaiseSelectors;
Selector RaiseSel;
-
+
llvm::OwningPtr<GRSimpleAPICheck> BatchAuditor;
std::vector<Checker*> Checkers;
@@ -81,21 +81,21 @@ class GRExprEngine : public GRSubEngine {
// this object be placed at the very end of member variables so that its
// destructor is called before the rest of the GRExprEngine is destroyed.
GRBugReporter BR;
-
+
public:
- typedef llvm::SmallPtrSet<ExplodedNode*,2> ErrorNodes;
+ typedef llvm::SmallPtrSet<ExplodedNode*,2> ErrorNodes;
typedef llvm::DenseMap<ExplodedNode*, Expr*> UndefArgsTy;
-
+
/// NilReceiverStructRetExplicit - Nodes in the ExplodedGraph that resulted
/// from [x ...] with 'x' definitely being nil and the result was a 'struct'
// (an undefined value).
ErrorNodes NilReceiverStructRetExplicit;
-
+
/// NilReceiverStructRetImplicit - Nodes in the ExplodedGraph that resulted
/// from [x ...] with 'x' possibly being nil and the result was a 'struct'
// (an undefined value).
ErrorNodes NilReceiverStructRetImplicit;
-
+
/// NilReceiverLargerThanVoidPtrRetExplicit - Nodes in the ExplodedGraph that
/// resulted from [x ...] with 'x' definitely being nil and the result's size
// was larger than sizeof(void *) (an undefined value).
@@ -105,7 +105,7 @@ public:
/// resulted from [x ...] with 'x' possibly being nil and the result's size
// was larger than sizeof(void *) (an undefined value).
ErrorNodes NilReceiverLargerThanVoidPtrRetImplicit;
-
+
/// RetsStackAddr - Nodes in the ExplodedGraph that result from returning
/// the address of a stack variable.
ErrorNodes RetsStackAddr;
@@ -113,65 +113,65 @@ public:
/// RetsUndef - Nodes in the ExplodedGraph that result from returning
/// an undefined value.
ErrorNodes RetsUndef;
-
+
/// UndefBranches - Nodes in the ExplodedGraph that result from
/// taking a branch based on an undefined value.
ErrorNodes UndefBranches;
-
+
/// UndefStores - Sinks in the ExplodedGraph that result from
/// making a store to an undefined lvalue.
ErrorNodes UndefStores;
-
+
/// NoReturnCalls - Sinks in the ExplodedGraph that result from
// calling a function with the attribute "noreturn".
ErrorNodes NoReturnCalls;
-
+
/// ImplicitNullDeref - Nodes in the ExplodedGraph that result from
/// taking a dereference on a symbolic pointer that MAY be NULL.
ErrorNodes ImplicitNullDeref;
-
+
/// ExplicitNullDeref - Nodes in the ExplodedGraph that result from
/// taking a dereference on a symbolic pointer that MUST be NULL.
ErrorNodes ExplicitNullDeref;
-
+
/// UnitDeref - Nodes in the ExplodedGraph that result from
/// taking a dereference on an undefined value.
ErrorNodes UndefDeref;
- /// ImplicitBadDivides - Nodes in the ExplodedGraph that result from
+ /// ImplicitBadDivides - Nodes in the ExplodedGraph that result from
/// evaluating a divide or modulo operation where the denominator
/// MAY be zero.
ErrorNodes ImplicitBadDivides;
-
- /// ExplicitBadDivides - Nodes in the ExplodedGraph that result from
+
+ /// ExplicitBadDivides - Nodes in the ExplodedGraph that result from
/// evaluating a divide or modulo operation where the denominator
/// MUST be zero or undefined.
ErrorNodes ExplicitBadDivides;
-
- /// ImplicitBadSizedVLA - Nodes in the ExplodedGraph that result from
+
+ /// ImplicitBadSizedVLA - Nodes in the ExplodedGraph that result from
/// constructing a zero-sized VLA where the size may be zero.
ErrorNodes ImplicitBadSizedVLA;
-
- /// ExplicitBadSizedVLA - Nodes in the ExplodedGraph that result from
+
+ /// ExplicitBadSizedVLA - Nodes in the ExplodedGraph that result from
/// constructing a zero-sized VLA where the size must be zero.
ErrorNodes ExplicitBadSizedVLA;
-
+
/// UndefResults - Nodes in the ExplodedGraph where the operands are defined
/// by the result is not. Excludes divide-by-zero errors.
ErrorNodes UndefResults;
-
+
/// BadCalls - Nodes in the ExplodedGraph resulting from calls to function
/// pointers that are NULL (or other constants) or Undefined.
ErrorNodes BadCalls;
-
+
/// UndefReceiver - Nodes in the ExplodedGraph resulting from message
/// ObjC message expressions where the receiver is undefined (uninitialized).
ErrorNodes UndefReceivers;
-
+
/// UndefArg - Nodes in the ExplodedGraph resulting from calls to functions
/// where a pass-by-value argument has an undefined value.
UndefArgsTy UndefArgs;
-
+
/// MsgExprUndefArgs - Nodes in the ExplodedGraph resulting from
/// message expressions where a pass-by-value argument has an undefined
/// value.
@@ -184,132 +184,132 @@ public:
/// OutOfBoundMemAccesses - Nodes in the ExplodedGraph resulting from
/// out-of-bound memory accesses where the index MUST be out-of-bound.
ErrorNodes ExplicitOOBMemAccesses;
-
+
public:
GRExprEngine(AnalysisManager &mgr);
~GRExprEngine();
-
+
void ExecuteWorkList(const LocationContext *L, unsigned Steps = 150000) {
CoreEngine.ExecuteWorkList(L, Steps);
}
-
+
/// getContext - Return the ASTContext associated with this analysis.
ASTContext& getContext() const { return G.getContext(); }
AnalysisManager &getAnalysisManager() const { return AMgr; }
-
+
SValuator &getSValuator() { return SVator; }
-
+
GRTransferFuncs& getTF() { return *StateMgr.TF; }
-
+
BugReporter& getBugReporter() { return BR; }
-
+
/// setTransferFunctions
void setTransferFunctions(GRTransferFuncs* tf);
void setTransferFunctions(GRTransferFuncs& tf) {
setTransferFunctions(&tf);
}
-
+
/// ViewGraph - Visualize the ExplodedGraph created by executing the
/// simulation.
void ViewGraph(bool trim = false);
-
+
void ViewGraph(ExplodedNode** Beg, ExplodedNode** End);
-
+
/// getInitialState - Return the initial state used for the root vertex
/// in the ExplodedGraph.
const GRState* getInitialState(const LocationContext *InitLoc);
-
+
ExplodedGraph& getGraph() { return G; }
const ExplodedGraph& getGraph() const { return G; }
void RegisterInternalChecks();
-
+
void registerCheck(Checker *check) {
Checkers.push_back(check);
}
-
+
bool isRetStackAddr(const ExplodedNode* N) const {
return N->isSink() && RetsStackAddr.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isUndefControlFlow(const ExplodedNode* N) const {
return N->isSink() && UndefBranches.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isUndefStore(const ExplodedNode* N) const {
return N->isSink() && UndefStores.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isImplicitNullDeref(const ExplodedNode* N) const {
return N->isSink() && ImplicitNullDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isExplicitNullDeref(const ExplodedNode* N) const {
return N->isSink() && ExplicitNullDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isUndefDeref(const ExplodedNode* N) const {
return N->isSink() && UndefDeref.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isImplicitBadDivide(const ExplodedNode* N) const {
return N->isSink() && ImplicitBadDivides.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isExplicitBadDivide(const ExplodedNode* N) const {
return N->isSink() && ExplicitBadDivides.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isNoReturnCall(const ExplodedNode* N) const {
return N->isSink() && NoReturnCalls.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isUndefResult(const ExplodedNode* N) const {
return N->isSink() && UndefResults.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isBadCall(const ExplodedNode* N) const {
return N->isSink() && BadCalls.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
bool isUndefArg(const ExplodedNode* N) const {
return N->isSink() &&
(UndefArgs.find(const_cast<ExplodedNode*>(N)) != UndefArgs.end() ||
MsgExprUndefArgs.find(const_cast<ExplodedNode*>(N)) != MsgExprUndefArgs.end());
}
-
+
bool isUndefReceiver(const ExplodedNode* N) const {
return N->isSink() && UndefReceivers.count(const_cast<ExplodedNode*>(N)) != 0;
}
-
+
typedef ErrorNodes::iterator ret_stackaddr_iterator;
ret_stackaddr_iterator ret_stackaddr_begin() { return RetsStackAddr.begin(); }
- ret_stackaddr_iterator ret_stackaddr_end() { return RetsStackAddr.end(); }
-
+ ret_stackaddr_iterator ret_stackaddr_end() { return RetsStackAddr.end(); }
+
typedef ErrorNodes::iterator ret_undef_iterator;
ret_undef_iterator ret_undef_begin() { return RetsUndef.begin(); }
ret_undef_iterator ret_undef_end() { return RetsUndef.end(); }
-
+
typedef ErrorNodes::iterator undef_branch_iterator;
undef_branch_iterator undef_branches_begin() { return UndefBranches.begin(); }
- undef_branch_iterator undef_branches_end() { return UndefBranches.end(); }
-
+ undef_branch_iterator undef_branches_end() { return UndefBranches.end(); }
+
typedef ErrorNodes::iterator null_deref_iterator;
null_deref_iterator null_derefs_begin() { return ExplicitNullDeref.begin(); }
null_deref_iterator null_derefs_end() { return ExplicitNullDeref.end(); }
-
+
null_deref_iterator implicit_null_derefs_begin() {
return ImplicitNullDeref.begin();
}
null_deref_iterator implicit_null_derefs_end() {
return ImplicitNullDeref.end();
}
-
+
typedef ErrorNodes::iterator nil_receiver_struct_ret_iterator;
-
+
nil_receiver_struct_ret_iterator nil_receiver_struct_ret_begin() {
return NilReceiverStructRetExplicit.begin();
}
@@ -317,9 +317,9 @@ public:
nil_receiver_struct_ret_iterator nil_receiver_struct_ret_end() {
return NilReceiverStructRetExplicit.end();
}
-
+
typedef ErrorNodes::iterator nil_receiver_larger_than_voidptr_ret_iterator;
-
+
nil_receiver_larger_than_voidptr_ret_iterator
nil_receiver_larger_than_voidptr_ret_begin() {
return NilReceiverLargerThanVoidPtrRetExplicit.begin();
@@ -329,60 +329,60 @@ public:
nil_receiver_larger_than_voidptr_ret_end() {
return NilReceiverLargerThanVoidPtrRetExplicit.end();
}
-
+
typedef ErrorNodes::iterator undef_deref_iterator;
undef_deref_iterator undef_derefs_begin() { return UndefDeref.begin(); }
undef_deref_iterator undef_derefs_end() { return UndefDeref.end(); }
-
+
typedef ErrorNodes::iterator bad_divide_iterator;
bad_divide_iterator explicit_bad_divides_begin() {
return ExplicitBadDivides.begin();
}
-
+
bad_divide_iterator explicit_bad_divides_end() {
return ExplicitBadDivides.end();
}
-
+
bad_divide_iterator implicit_bad_divides_begin() {
return ImplicitBadDivides.begin();
}
-
+
bad_divide_iterator implicit_bad_divides_end() {
return ImplicitBadDivides.end();
}
-
+
typedef ErrorNodes::iterator undef_result_iterator;
undef_result_iterator undef_results_begin() { return UndefResults.begin(); }
undef_result_iterator undef_results_end() { return UndefResults.end(); }
typedef ErrorNodes::iterator bad_calls_iterator;
bad_calls_iterator bad_calls_begin() { return BadCalls.begin(); }
- bad_calls_iterator bad_calls_end() { return BadCalls.end(); }
-
+ bad_calls_iterator bad_calls_end() { return BadCalls.end(); }
+
typedef UndefArgsTy::iterator undef_arg_iterator;
undef_arg_iterator undef_arg_begin() { return UndefArgs.begin(); }
- undef_arg_iterator undef_arg_end() { return UndefArgs.end(); }
-
+ undef_arg_iterator undef_arg_end() { return UndefArgs.end(); }
+
undef_arg_iterator msg_expr_undef_arg_begin() {
return MsgExprUndefArgs.begin();
}
undef_arg_iterator msg_expr_undef_arg_end() {
return MsgExprUndefArgs.end();
- }
-
+ }
+
typedef ErrorNodes::iterator undef_receivers_iterator;
undef_receivers_iterator undef_receivers_begin() {
return UndefReceivers.begin();
}
-
+
undef_receivers_iterator undef_receivers_end() {
return UndefReceivers.end();
}
typedef ErrorNodes::iterator oob_memacc_iterator;
- oob_memacc_iterator implicit_oob_memacc_begin() {
+ oob_memacc_iterator implicit_oob_memacc_begin() {
return ImplicitOOBMemAccesses.begin();
}
oob_memacc_iterator implicit_oob_memacc_end() {
@@ -397,45 +397,45 @@ public:
void AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C);
void AddCheck(GRSimpleAPICheck* A);
-
+
/// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
- /// nodes by processing the 'effects' of a block-level statement.
- void ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder);
-
+ /// nodes by processing the 'effects' of a block-level statement.
+ void ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder);
+
/// ProcessBlockEntrance - Called by GRCoreEngine when start processing
/// a CFGBlock. This method returns true if the analysis should continue
/// exploring the given path, and false otherwise.
bool ProcessBlockEntrance(CFGBlock* B, const GRState* St,
GRBlockCounter BC);
-
+
/// ProcessBranch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a branch condition.
void ProcessBranch(Stmt* Condition, Stmt* Term, GRBranchNodeBuilder& builder);
-
+
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a computed goto jump.
void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder);
-
+
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
void ProcessSwitch(GRSwitchNodeBuilder& builder);
-
+
/// ProcessEndPath - Called by GRCoreEngine. Used to generate end-of-path
/// nodes when the control reaches the end of a function.
void ProcessEndPath(GREndPathNodeBuilder& builder) {
getTF().EvalEndPath(*this, builder);
StateMgr.EndPath(builder.getState());
}
-
+
GRStateManager& getStateManager() { return StateMgr; }
const GRStateManager& getStateManager() const { return StateMgr; }
StoreManager& getStoreManager() { return StateMgr.getStoreManager(); }
-
+
ConstraintManager& getConstraintManager() {
return StateMgr.getConstraintManager();
}
-
+
// FIXME: Remove when we migrate over to just using ValueManager.
BasicValueFactory& getBasicVals() {
return StateMgr.getBasicVals();
@@ -443,19 +443,19 @@ public:
const BasicValueFactory& getBasicVals() const {
return StateMgr.getBasicVals();
}
-
- ValueManager &getValueManager() { return ValMgr; }
+
+ ValueManager &getValueManager() { return ValMgr; }
const ValueManager &getValueManager() const { return ValMgr; }
-
+
// FIXME: Remove when we migrate over to just using ValueManager.
SymbolManager& getSymbolManager() { return SymMgr; }
const SymbolManager& getSymbolManager() const { return SymMgr; }
-
+
protected:
const GRState* GetState(ExplodedNode* N) {
return N == EntryNode ? CleanedState : N->getState();
}
-
+
public:
ExplodedNode* MakeNode(ExplodedNodeSet& Dst, Stmt* S, ExplodedNode* Pred, const GRState* St,
ProgramPoint::Kind K = ProgramPoint::PostStmtKind,
@@ -464,60 +464,60 @@ protected:
/// CheckerVisit - Dispatcher for performing checker-specific logic
/// at specific statements.
void CheckerVisit(Stmt *S, ExplodedNodeSet &Dst, ExplodedNodeSet &Src, bool isPrevisit);
-
+
/// Visit - Transfer function logic for all statements. Dispatches to
/// other functions that handle specific kinds of statements.
void Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitLValue - Evaluate the lvalue of the expression. For example, if Ex is
/// a DeclRefExpr, it evaluates to the MemRegionVal which represents its
/// storage location. Note that not all kinds of expressions has lvalue.
void VisitLValue(Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitArraySubscriptExpr - Transfer function for array accesses.
void VisitArraySubscriptExpr(ArraySubscriptExpr* Ex, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue);
-
+
/// VisitAsmStmt - Transfer function logic for inline asm.
void VisitAsmStmt(AsmStmt* A, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
void VisitAsmStmtHelperOutputs(AsmStmt* A,
AsmStmt::outputs_iterator I,
AsmStmt::outputs_iterator E,
ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
void VisitAsmStmtHelperInputs(AsmStmt* A,
AsmStmt::inputs_iterator I,
AsmStmt::inputs_iterator E,
ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitBinaryOperator - Transfer function logic for binary operators.
void VisitBinaryOperator(BinaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitCall - Transfer function for function calls.
void VisitCall(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI, CallExpr::arg_iterator AE,
ExplodedNodeSet& Dst);
void VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI, CallExpr::arg_iterator AE,
- ExplodedNodeSet& Dst, const FunctionProtoType *,
+ ExplodedNodeSet& Dst, const FunctionProtoType *,
unsigned ParamIdx = 0);
-
+
/// VisitCast - Transfer function logic for all casts (implicit and explicit).
void VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst);
/// VisitCompoundLiteralExpr - Transfer function logic for compound literals.
void VisitCompoundLiteralExpr(CompoundLiteralExpr* CL, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue);
-
+
/// VisitDeclRefExpr - Transfer function logic for DeclRefExprs.
void VisitDeclRefExpr(DeclRefExpr* DR, ExplodedNode* Pred, ExplodedNodeSet& Dst,
- bool asLValue);
-
+ bool asLValue);
+
/// VisitDeclStmt - Transfer function logic for DeclStmts.
- void VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+ void VisitDeclStmt(DeclStmt* DS, ExplodedNode* Pred, ExplodedNodeSet& Dst);
+
/// VisitGuardedExpr - Transfer function logic for ?, __builtin_choose
void VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, ExplodedNode* Pred, ExplodedNodeSet& Dst);
@@ -525,65 +525,65 @@ protected:
/// VisitLogicalExpr - Transfer function logic for '&&', '||'
void VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitMemberExpr - Transfer function for member expressions.
void VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred, ExplodedNodeSet& Dst,bool asLValue);
-
+
/// VisitObjCIvarRefExpr - Transfer function logic for ObjCIvarRefExprs.
void VisitObjCIvarRefExpr(ObjCIvarRefExpr* DR, ExplodedNode* Pred, ExplodedNodeSet& Dst,
- bool asLValue);
+ bool asLValue);
/// VisitObjCForCollectionStmt - Transfer function logic for
/// ObjCForCollectionStmt.
void VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, ExplodedNode* Pred,
ExplodedNodeSet& Dst);
-
+
void VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S, ExplodedNode* Pred,
ExplodedNodeSet& Dst, SVal ElementV);
-
+
/// VisitObjCMessageExpr - Transfer function for ObjC message expressions.
void VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
void VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator I,
ObjCMessageExpr::arg_iterator E,
ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
void VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, ExplodedNode* Pred,
ExplodedNodeSet& Dst);
-
+
/// VisitReturnStmt - Transfer function logic for return statements.
void VisitReturnStmt(ReturnStmt* R, ExplodedNode* Pred, ExplodedNodeSet& Dst);
-
+
/// VisitSizeOfAlignOfExpr - Transfer function for sizeof.
void VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex, ExplodedNode* Pred,
ExplodedNodeSet& Dst);
-
+
/// VisitUnaryOperator - Transfer function logic for unary operators.
void VisitUnaryOperator(UnaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue);
-
+
const GRState* CheckDivideZero(Expr* Ex, const GRState* St, ExplodedNode* Pred,
- SVal Denom);
-
+ SVal Denom);
+
/// EvalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic
/// expressions of the form 'x != 0' and generate new nodes (stored in Dst)
/// with those assumptions.
void EvalEagerlyAssume(ExplodedNodeSet& Dst, ExplodedNodeSet& Src, Expr *Ex);
-
+
SVal EvalMinus(SVal X) {
return X.isValid() ? SVator.EvalMinus(cast<NonLoc>(X)) : X;
}
-
+
SVal EvalComplement(SVal X) {
return X.isValid() ? SVator.EvalComplement(cast<NonLoc>(X)) : X;
}
bool EvalBuiltinFunction(const FunctionDecl *FD, CallExpr *CE,
ExplodedNode *Pred, ExplodedNodeSet &Dst);
-
+
public:
-
+
SVal EvalBinOp(BinaryOperator::Opcode op, NonLoc L, NonLoc R, QualType T) {
return SVator.EvalBinOpNN(op, L, R, T);
}
@@ -591,49 +591,49 @@ public:
SVal EvalBinOp(BinaryOperator::Opcode op, NonLoc L, SVal R, QualType T) {
return R.isValid() ? SVator.EvalBinOpNN(op, L, cast<NonLoc>(R), T) : R;
}
-
+
SVal EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
SVal LHS, SVal RHS, QualType T) {
return SVator.EvalBinOp(ST, Op, LHS, RHS, T);
}
protected:
-
+
void EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L, ExplodedNode* Pred);
-
+
void EvalObjCMessageExpr(ExplodedNodeSet& Dst, ObjCMessageExpr* ME, ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
getTF().EvalObjCMessageExpr(Dst, *this, *Builder, ME, Pred);
}
void EvalReturn(ExplodedNodeSet& Dst, ReturnStmt* s, ExplodedNode* Pred);
-
- const GRState* MarkBranch(const GRState* St, Stmt* Terminator,
+
+ const GRState* MarkBranch(const GRState* St, Stmt* Terminator,
bool branchTaken);
-
+
/// EvalBind - Handle the semantics of binding a value to a specific location.
/// This method is used by EvalStore, VisitDeclStmt, and others.
void EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* St, SVal location, SVal Val);
-
+
public:
void EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* St, SVal location, const void *tag = 0);
-
+
ExplodedNode* EvalLocation(Stmt* Ex, ExplodedNode* Pred,
const GRState* St, SVal location,
const void *tag = 0);
-
+
void EvalStore(ExplodedNodeSet& Dst, Expr* E, ExplodedNode* Pred, const GRState* St,
SVal TargetLV, SVal Val, const void *tag = 0);
-
+
void EvalStore(ExplodedNodeSet& Dst, Expr* E, Expr* StoreE, ExplodedNode* Pred,
const GRState* St, SVal TargetLV, SVal Val,
const void *tag = 0);
-
+
};
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
index 0c31818857..60db406cd1 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
@@ -34,10 +34,10 @@ class GRStmtNodeBuilderRef {
private:
friend class GRExprEngine;
-
+
GRStmtNodeBuilderRef(); // do not implement
void operator=(const GRStmtNodeBuilderRef&); // do not implement
-
+
GRStmtNodeBuilderRef(ExplodedNodeSet &dst,
GRStmtNodeBuilder &builder,
GRExprEngine& eng,
@@ -47,12 +47,12 @@ private:
: Dst(dst), B(builder), Eng(eng), Pred(pred),
state(st), stmt(s), OldSize(Dst.size()), AutoCreateNode(auto_create_node),
OldSink(B.BuildSinks), OldTag(B.Tag), OldHasGen(B.HasGeneratedNode) {}
-
+
public:
~GRStmtNodeBuilderRef() {
// Handle the case where no nodes where generated. Auto-generate that
- // contains the updated state if we aren't generating sinks.
+ // contains the updated state if we aren't generating sinks.
if (!B.BuildSinks && Dst.size() == OldSize && !B.HasGeneratedNode) {
if (AutoCreateNode)
B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
@@ -62,14 +62,14 @@ public:
}
const GRState *getState() { return state; }
-
+
GRStateManager& getStateManager() {
return Eng.getStateManager();
}
-
+
ExplodedNode* MakeNode(const GRState* state) {
- return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
- }
+ return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
+ }
};
} // end clang namespace
diff --git a/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
index c0593a375c..978ff0889e 100644
--- a/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
+++ b/include/clang/Analysis/PathSensitive/GRSimpleAPICheck.h
@@ -20,15 +20,15 @@
#include "clang/Analysis/PathSensitive/GRState.h"
namespace clang {
-
+
class Diagnostic;
class BugReporter;
class ASTContext;
class GRExprEngine;
class PathDiagnosticClient;
class ExplodedGraph;
-
-
+
+
class GRSimpleAPICheck : public GRAuditor {
public:
GRSimpleAPICheck() {}
diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h
index 54a86af1f7..3924084015 100644
--- a/include/clang/Analysis/PathSensitive/GRState.h
+++ b/include/clang/Analysis/PathSensitive/GRState.h
@@ -49,12 +49,12 @@ typedef StoreManager* (*StoreManagerCreator)(GRStateManager&);
//===----------------------------------------------------------------------===//
// GRStateTrait - Traits used by the Generic Data Map of a GRState.
//===----------------------------------------------------------------------===//
-
+
template <typename T> struct GRStatePartialTrait;
template <typename T> struct GRStateTrait {
typedef typename T::data_type data_type;
- static inline void* GDMIndex() { return &T::TagInt; }
+ static inline void* GDMIndex() { return &T::TagInt; }
static inline void* MakeVoidPtr(data_type D) { return (void*) D; }
static inline data_type MakeData(void* const* P) {
return P ? (data_type) *P : (data_type) 0;
@@ -66,19 +66,19 @@ template <typename T> struct GRStateTrait {
//===----------------------------------------------------------------------===//
class GRStateManager;
-
+
/// GRState - This class encapsulates the actual data values for
/// for a "state" in our symbolic value tracking. It is intended to be
/// used as a functional object; that is once it is created and made
/// "persistent" in a FoldingSet its values will never change.
class GRState : public llvm::FoldingSetNode {
-public:
+public:
typedef llvm::ImmutableSet<llvm::APSInt*> IntSetTy;
- typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
-
+ typedef llvm::ImmutableMap<void*, void*> GenericDataMap;
+
private:
void operator=(const GRState& R) const;
-
+
friend class GRStateManager;
GRStateManager *StateMgr;
@@ -88,9 +88,9 @@ private:
// FIXME: Make these private.
public:
GenericDataMap GDM;
-
+
public:
-
+
/// This ctor is used when creating the first GRState object.
GRState(GRStateManager *mgr, const Environment& env,
Store st, GenericDataMap gdm)
@@ -98,7 +98,7 @@ public:
Env(env),
St(st),
GDM(gdm) {}
-
+
/// Copy ctor - We must explicitly define this or else the "Next" ptr
/// in FoldingSetNode will also get copied.
GRState(const GRState& RHS)
@@ -107,33 +107,33 @@ public:
Env(RHS.Env),
St(RHS.St),
GDM(RHS.GDM) {}
-
+
/// getStateManager - Return the GRStateManager associated with this state.
GRStateManager &getStateManager() const {
return *StateMgr;
}
-
+
/// getAnalysisContext - Return the AnalysisContext associated with this
/// state.
AnalysisContext &getAnalysisContext() const {
return Env.getAnalysisContext();
}
-
+
/// getEnvironment - Return the environment associated with this state.
/// The environment is the mapping from expressions to values.
const Environment& getEnvironment() const { return Env; }
-
+
/// getStore - Return the store associated with this state. The store
/// is a mapping from locations to values.
Store getStore() const { return St; }
-
+
void setStore(Store s) { St = s; }
-
+
/// getGDM - Return the generic data map associated with this state.
GenericDataMap getGDM() const { return GDM; }
-
+
void setGDM(GenericDataMap gdm) { GDM = gdm; }
-
+
/// Profile - Profile the contents of a GRState object for use
/// in a FoldingSet.
static void Profile(llvm::FoldingSetNodeID& ID, const GRState* V) {
@@ -148,19 +148,19 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) const {
Profile(ID, this);
}
-
+
SVal LookupExpr(Expr* E) const {
return Env.LookupExpr(E);
}
-
+
/// makeWithStore - Return a GRState with the same values as the current
/// state with the exception of using the specified Store.
const GRState *makeWithStore(Store store) const;
-
+
BasicValueFactory &getBasicVals() const;
SymbolManager &getSymbolManager() const;
GRTransferFuncs &getTransferFuncs() const;
-
+
//==---------------------------------------------------------------------==//
// Constraints on values.
//==---------------------------------------------------------------------==//
@@ -193,12 +193,12 @@ public:
// FIXME: (a) should probably disappear since it is redundant with (b).
// (i.e., (b) could just be set to NULL).
//
-
+
const GRState *assume(SVal condition, bool assumption) const;
-
- const GRState *assumeInBound(SVal idx, SVal upperBound,
+
+ const GRState *assumeInBound(SVal idx, SVal upperBound,
bool assumption) const;
-
+
//==---------------------------------------------------------------------==//
// Utility methods for getting regions.
//==---------------------------------------------------------------------==//
@@ -208,67 +208,67 @@ public:
//==---------------------------------------------------------------------==//
// Binding and retrieving values to/from the environment and symbolic store.
//==---------------------------------------------------------------------==//
-
+
/// BindCompoundLiteral - Return the state that has the bindings currently
/// in 'state' plus the bindings for the CompoundLiteral. 'R' is the region
/// for the compound literal and 'BegInit' and 'EndInit' represent an
/// array of initializer values.
const GRState* bindCompoundLiteral(const CompoundLiteralExpr* CL,
SVal V) const;
-
+
const GRState *BindExpr(const Stmt *S, SVal V, bool Invalidate = true) const;
-
+
const GRState *bindDecl(const VarDecl *VD, const LocationContext *LC,
SVal V) const;
-
+
const GRState *bindDeclWithNoInit(const VarDecl *VD,
- const LocationContext *LC) const;
-
+ const LocationContext *LC) const;
+
const GRState *bindLoc(Loc location, SVal V) const;
-
+
const GRState *bindLoc(SVal location, SVal V) const;
-
+
const GRState *unbindLoc(Loc LV) const;
/// Get the lvalue for a variable reference.
SVal getLValue(const VarDecl *D, const LocationContext *LC) const;
-
+
/// Get the lvalue for a StringLiteral.
SVal getLValue(const StringLiteral *literal) const;
-
+
SVal getLValue(const CompoundLiteralExpr *literal) const;
-
+
/// Get the lvalue for an ivar reference.
SVal getLValue(const ObjCIvarDecl *decl, SVal base) const;
-
+
/// Get the lvalue for a field reference.
SVal getLValue(SVal Base, const FieldDecl *decl) const;
-
+
/// Get the lvalue for an array index.
SVal getLValue(QualType ElementType, SVal Base, SVal Idx) const;
-
+
const llvm::APSInt *getSymVal(SymbolRef sym) const;
SVal getSVal(const Stmt* Ex) const;
-
+
SVal getSValAsScalarOrLoc(const Stmt *Ex) const;
-
+
SVal getSVal(Loc LV, QualType T = QualType()) const;
-
+
SVal getSVal(const MemRegion* R) const;
-
+
SVal getSValAsScalarOrLoc(const MemRegion *R) const;
-
+
bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const;
template <typename CB> CB scanReachableSymbols(SVal val) const;
-
+
//==---------------------------------------------------------------------==//
// Accessing the Generic Data Map (GDM).
//==---------------------------------------------------------------------==//
void* const* FindGDM(void* K) const;
-
+
template<typename T>
const GRState *add(typename GRStateTrait<T>::key_type K) const;
@@ -277,31 +277,31 @@ public:
get() const {
return GRStateTrait<T>::MakeData(FindGDM(GRStateTrait<T>::GDMIndex()));
}
-
+
template<typename T>
typename GRStateTrait<T>::lookup_type
get(typename GRStateTrait<T>::key_type key) const {
void* const* d = FindGDM(GRStateTrait<T>::GDMIndex());
return GRStateTrait<T>::Lookup(GRStateTrait<T>::MakeData(d), key);
}
-
+
template <typename T>
typename GRStateTrait<T>::context_type get_context() const;
-
-
+
+
template<typename T>
const GRState *remove(typename GRStateTrait<T>::key_type K) const;
template<typename T>
const GRState *remove(typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::context_type C) const;
-
+
template<typename T>
const GRState *set(typename GRStateTrait<T>::data_type D) const;
-
+
template<typename T>
const GRState *set(typename GRStateTrait<T>::key_type K,
- typename GRStateTrait<T>::value_type E) const;
+ typename GRStateTrait<T>::value_type E) const;
template<typename T>
const GRState *set(typename GRStateTrait<T>::key_type K,
@@ -313,7 +313,7 @@ public:
void* const* d = FindGDM(GRStateTrait<T>::GDMIndex());
return GRStateTrait<T>::Contains(GRStateTrait<T>::MakeData(d), key);
}
-
+
// State pretty-printing.
class Printer {
public:
@@ -321,55 +321,55 @@ public:
virtual void Print(llvm::raw_ostream& Out, const GRState* state,
const char* nl, const char* sep) = 0;
};
-
+
// Pretty-printing.
void print(llvm::raw_ostream& Out, const char *nl = "\n",
- const char *sep = "") const;
+ const char *sep = "") const;
+
+ void printStdErr() const;
+
+ void printDOT(llvm::raw_ostream& Out) const;
- void printStdErr() const;
-
- void printDOT(llvm::raw_ostream& Out) const;
-
// Tags used for the Generic Data Map.
struct NullDerefTag {
static int TagInt;
typedef const SVal* data_type;
};
};
-
+
class GRStateSet {
typedef llvm::SmallPtrSet<const GRState*,5> ImplTy;
- ImplTy Impl;
+ ImplTy Impl;
public:
GRStateSet() {}
inline void Add(const GRState* St) {
Impl.insert(St);
}
-
+
typedef ImplTy::const_iterator iterator;
-
+
inline unsigned size() const { return Impl.size(); }
inline bool empty() const { return Impl.empty(); }
-
+
inline iterator begin() const { return Impl.begin(); }
inline iterator end() const { return Impl.end(); }
-
+
class AutoPopulate {
GRStateSet& S;
unsigned StartSize;
const GRState* St;
public:
- AutoPopulate(GRStateSet& s, const GRState* st)
+ AutoPopulate(GRStateSet& s, const GRState* st)
: S(s), StartSize(S.size()), St(st) {}
-
+
~AutoPopulate() {
if (StartSize == S.size())
S.Add(St);
}
};
-};
-
+};
+
//===----------------------------------------------------------------------===//
// GRStateManager - Factory object for GRStates.
//===----------------------------------------------------------------------===//
@@ -377,21 +377,21 @@ public:
class GRStateManager {
friend class GRExprEngine;
friend class GRState;
-
+
private:
EnvironmentManager EnvMgr;
llvm::OwningPtr<StoreManager> StoreMgr;
llvm::OwningPtr<ConstraintManager> ConstraintMgr;
-
+
GRState::GenericDataMap::Factory GDMFactory;
-
+
typedef llvm::DenseMap<void*,std::pair<void*,void (*)(void*)> > GDMContextsTy;
GDMContextsTy GDMContexts;
-
+
/// Printers - A set of printer objects used for pretty-printing a GRState.
/// GRStateManager owns these objects.
std::vector<GRState::Printer*> Printers;
-
+
/// StateSet - FoldingSet containing all the states created for analyzing
/// a particular function. This is used to unique states.
llvm::FoldingSet<GRState> StateSet;
@@ -401,36 +401,36 @@ private:
/// Alloc - A BumpPtrAllocator to allocate states.
llvm::BumpPtrAllocator& Alloc;
-
+
/// CurrentStmt - The block-level statement currently being visited. This
/// is set by GRExprEngine.
Stmt* CurrentStmt;
-
+
/// TF - Object that represents a bundle of transfer functions
/// for manipulating and creating SVals.
GRTransferFuncs* TF;
public:
-
+
GRStateManager(ASTContext& Ctx,
StoreManagerCreator CreateStoreManager,
ConstraintManagerCreator CreateConstraintManager,
llvm::BumpPtrAllocator& alloc)
- : EnvMgr(alloc),
- GDMFactory(alloc),
- ValueMgr(alloc, Ctx, *this),
+ : EnvMgr(alloc),
+ GDMFactory(alloc),
+ ValueMgr(alloc, Ctx, *this),
Alloc(alloc) {
StoreMgr.reset((*CreateStoreManager)(*this));
ConstraintMgr.reset((*CreateConstraintManager)(*this));
}
-
+
~GRStateManager();
const GRState *getInitialState(const LocationContext *InitLoc);
-
+
ASTContext &getContext() { return ValueMgr.getContext(); }
const ASTContext &getContext() const { return ValueMgr.getContext(); }
-
+
GRTransferFuncs& getTransferFuncs() { return *TF; }
BasicValueFactory &getBasicVals() {
@@ -439,17 +439,17 @@ public:
const BasicValueFactory& getBasicVals() const {
return ValueMgr.getBasicValueFactory();
}
-
+
SymbolManager &getSymbolManager() {
return ValueMgr.getSymbolManager();
}
const SymbolManager &getSymbolManager() const {
return ValueMgr.getSymbolManager();
}
-
+
ValueManager &getValueManager() { return ValueMgr; }
const ValueManager &getValueManager() const { return ValueMgr; }
-
+
llvm::BumpPtrAllocator& getAllocator() { return Alloc; }
MemRegionManager& getRegionManager() {
@@ -458,11 +458,11 @@ public:
const MemRegionManager& getRegionManager() const {
return ValueMgr.getRegionManager();
}
-
+
StoreManager& getStoreManager() { return *StoreMgr; }
ConstraintManager& getConstraintManager() { return *ConstraintMgr; }
- const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc,
+ const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc,
SymbolReaper& SymReaper);
public:
@@ -470,10 +470,10 @@ public:
SVal ArrayToPointer(Loc Array) {
return StoreMgr->ArrayToPointer(Array);
}
-
+
// Methods that manipulate the GDM.
const GRState* addGDM(const GRState* St, void* Key, void* Data);
-
+
// Methods that query & manipulate the Store.
void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {
@@ -484,7 +484,7 @@ public:
bool isEqual(const GRState* state, const Expr* Ex, const llvm::APSInt& V);
bool isEqual(const GRState* state, const Expr* Ex, uint64_t);
-
+
//==---------------------------------------------------------------------==//
// Generic Data Map methods.
//==---------------------------------------------------------------------==//
@@ -502,21 +502,21 @@ public:
// The templated methods below use the GRStateTrait<T> class
// to resolve keys into the GDM and to return data values to clients.
//
-
- // Trait based GDM dispatch.
+
+ // Trait based GDM dispatch.
template <typename T>
const GRState* set(const GRState* st, typename GRStateTrait<T>::data_type D) {
return addGDM(st, GRStateTrait<T>::GDMIndex(),
GRStateTrait<T>::MakeVoidPtr(D));
}
-
+
template<typename T>
const GRState* set(const GRState* st,
typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::value_type V,
typename GRStateTrait<T>::context_type C) {
-
- return addGDM(st, GRStateTrait<T>::GDMIndex(),
+
+ return addGDM(st, GRStateTrait<T>::GDMIndex(),
GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Set(st->get<T>(), K, V, C)));
}
@@ -532,22 +532,22 @@ public:
const GRState* remove(const GRState* st,
typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::context_type C) {
-
- return addGDM(st, GRStateTrait<T>::GDMIndex(),
+
+ return addGDM(st, GRStateTrait<T>::GDMIndex(),
GRStateTrait<T>::MakeVoidPtr(GRStateTrait<T>::Remove(st->get<T>(), K, C)));
}
-
+
void* FindGDMContext(void* index,
void* (*CreateContext)(llvm::BumpPtrAllocator&),
void (*DeleteContext)(void*));
-
+
template <typename T>
typename GRStateTrait<T>::context_type get_context() {
void* p = FindGDMContext(GRStateTrait<T>::GDMIndex(),
GRStateTrait<T>::CreateContext,
GRStateTrait<T>::DeleteContext);
-
+
return GRStateTrait<T>::MakeContext(p);
}
@@ -559,7 +559,7 @@ public:
ConstraintMgr->EndPath(St);
}
};
-
+
//===----------------------------------------------------------------------===//
// Out-of-line method definitions for GRState.
@@ -577,13 +577,13 @@ inline const GRState *GRState::assume(SVal Cond, bool Assumption) const {
inline const GRState *GRState::assumeInBound(SVal Idx, SVal UpperBound,
bool Assumption) const {
return getStateManager().ConstraintMgr->AssumeInBound(this, Idx, UpperBound, Assumption);
-}
+}
inline const GRState *GRState::bindCompoundLiteral(const CompoundLiteralExpr* CL,
SVal V) const {
return getStateManager().StoreMgr->BindCompoundLiteral(this, CL, V);
}
-
+
inline const GRState *GRState::bindDecl(const VarDecl* VD,
const LocationContext *LC,
SVal IVal) const {
@@ -594,7 +594,7 @@ inline const GRState *GRState::bindDeclWithNoInit(const VarDecl* VD,
const LocationContext *LC) const {
return getStateManager().StoreMgr->BindDeclWithNoInit(this, VD, LC);
}
-
+
inline const GRState *GRState::bindLoc(Loc LV, SVal V) const {
return getStateManager().StoreMgr->Bind(this, LV, V);
}
@@ -602,7 +602,7 @@ inline const GRState *GRState::bindLoc(Loc LV, SVal V) const {
inline const GRState *GRState::bindLoc(SVal LV, SVal V) const {
return !isa<Loc>(LV) ? this : bindLoc(cast<Loc>(LV), V);
}
-
+
inline SVal GRState::getLValue(const VarDecl* VD,
const LocationContext *LC) const {
return getStateManager().StoreMgr->getLValueVar(this, VD, LC);
@@ -611,7 +611,7 @@ inline SVal GRState::getLValue(const VarDecl* VD,
inline SVal GRState::getLValue(const StringLiteral *literal) const {
return getStateManager().StoreMgr->getLValueString(this, literal);
}
-
+
inline SVal GRState::getLValue(const CompoundLiteralExpr *literal) const {
return getStateManager().StoreMgr->getLValueCompoundLiteral(this, literal);
}
@@ -619,19 +619,19 @@ inline SVal GRState::getLValue(const CompoundLiteralExpr *literal) const {
inline SVal GRState::getLValue(const ObjCIvarDecl *D, SVal Base) const {
return getStateManager().StoreMgr->getLValueIvar(this, D, Base);
}
-
+
inline SVal GRState::getLValue(SVal Base, const FieldDecl* D) const {
return getStateManager().StoreMgr->getLValueField(this, Base, D);
}
-
+
inline SVal GRState::getLValue(QualType ElementType, SVal Base, SVal Idx) const{
return getStateManager().StoreMgr->getLValueElement(this, ElementType, Base, Idx);
}
-
+
inline const llvm::APSInt *GRState::getSymVal(SymbolRef sym) const {
return getStateManager().getSymVal(this, sym);
}
-
+
inline SVal GRState::getSVal(const Stmt* Ex) const {
return Env.GetSVal(Ex, getStateManager().ValueMgr);
}
@@ -642,7 +642,7 @@ inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
if (Loc::IsLocType(T) || T->isIntegerType())
return getSVal(S);
}
-
+
return UnknownVal();
}
@@ -653,7 +653,7 @@ inline SVal GRState::getSVal(Loc LV, QualType T) const {
inline SVal GRState::getSVal(const MemRegion* R) const {
return getStateManager().StoreMgr->Retrieve(this, loc::MemRegionVal(R)).getSVal();
}
-
+
inline BasicValueFactory &GRState::getBasicVals() const {
return getStateManager().getBasicVals();
}
@@ -661,7 +661,7 @@ inline BasicValueFactory &GRState::getBasicVals() const {
inline SymbolManager &GRState::getSymbolManager() const {
return getStateManager().getSymbolManager();
}
-
+
inline GRTransferFuncs &GRState::getTransferFuncs() const {
return getStateManager().getTransferFuncs();
}
@@ -670,12 +670,12 @@ template<typename T>
const GRState *GRState::add(typename GRStateTrait<T>::key_type K) const {
return getStateManager().add<T>(this, K, get_context<T>());
}
-
+
template <typename T>
typename GRStateTrait<T>::context_type GRState::get_context() const {
return getStateManager().get_context<T>();
}
-
+
template<typename T>
const GRState *GRState::remove(typename GRStateTrait<T>::key_type K) const {
return getStateManager().remove<T>(this, K, get_context<T>());
@@ -686,25 +686,25 @@ const GRState *GRState::remove(typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::context_type C) const {
return getStateManager().remove<T>(this, K, C);
}
-
+
template<typename T>
const GRState *GRState::set(typename GRStateTrait<T>::data_type D) const {
return getStateManager().set<T>(this, D);
}
-
+
template<typename T>
const GRState *GRState::set(typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::value_type E) const {
return getStateManager().set<T>(this, K, E, get_context<T>());
}
-
+
template<typename T>
const GRState *GRState::set(typename GRStateTrait<T>::key_type K,
typename GRStateTrait<T>::value_type E,
typename GRStateTrait<T>::context_type C) const {
return getStateManager().set<T>(this, K, E, C);
}
-
+
template <typename CB>
CB GRState::scanReachableSymbols(SVal val) const {
CB cb(this);
diff --git a/include/clang/Analysis/PathSensitive/GRStateTrait.h b/include/clang/Analysis/PathSensitive/GRStateTrait.h
index ce43cda31e..5189a1f5aa 100644
--- a/include/clang/Analysis/PathSensitive/GRStateTrait.h
+++ b/include/clang/Analysis/PathSensitive/GRStateTrait.h
@@ -1,5 +1,5 @@
//==- GRStateTrait.h - Partial implementations of GRStateTrait -----*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -27,59 +27,59 @@ namespace llvm {
namespace clang {
template <typename T> struct GRStatePartialTrait;
-
+
// Partial-specialization for ImmutableMap.
-
+
template <typename Key, typename Data, typename Info>
struct GRStatePartialTrait< llvm::ImmutableMap<Key,Data,Info> > {
typedef llvm::ImmutableMap<Key,Data,Info> data_type;
- typedef typename data_type::Factory& context_type;
+ typedef typename data_type::Factory& context_type;
typedef Key key_type;
typedef Data value_type;
typedef const value_type* lookup_type;
-
+
static inline data_type MakeData(void* const* p) {
return p ? data_type((typename data_type::TreeTy*) *p) : data_type(0);
- }
+ }
static inline void* MakeVoidPtr(data_type B) {
return B.getRoot();
- }
+ }
static lookup_type Lookup(data_type B, key_type K) {
return B.lookup(K);
- }
+ }
static data_type Set(data_type B, key_type K, value_type E,context_type F){
return F.Add(B, K, E);
}
-
+
static data_type Remove(data_type B, key_type K, context_type F) {
return F.Remove(B, K);
}
-
+
static inline context_type MakeContext(void* p) {
return *((typename data_type::Factory*) p);
}
-
+
static void* CreateContext(llvm::BumpPtrAllocator& Alloc) {
- return new typename data_type::Factory(Alloc);
+ return new typename data_type::Factory(Alloc);
}
-
+
static void DeleteContext(void* Ctx) {
delete (typename data_type::Factory*) Ctx;
- }
+ }
};
-
-
+
+
// Partial-specialization for ImmutableSet.
-
+
template <typename Key, typename Info>
struct GRStatePartialTrait< llvm::ImmutableSet<Key,Info> > {
typedef llvm::ImmutableSet<Key,Info> data_type;
- typedef typename data_type::Factory& context_type;
+ typedef typename data_type::Factory& context_type;
typedef Key key_type;
-
+
static inline data_type MakeData(void* const* p) {
return p ? data_type((typename data_type::TreeTy*) *p) : data_type(0);
- }
+ }
static inline void* MakeVoidPtr(data_type B) {
return B.getRoot();
@@ -88,60 +88,60 @@ namespace clang {
static data_type Add(data_type B, key_type K, context_type F) {
return F.Add(B, K);
}
-
+
static data_type Remove(data_type B, key_type K, context_type F) {
return F.Remove(B, K);
}
-
+
static bool Contains(data_type B, key_type K) {
return B.contains(K);
}
-
+
static inline context_type MakeContext(void* p) {
return *((typename data_type::Factory*) p);
}
-
+
static void* CreateContext(llvm::BumpPtrAllocator& Alloc) {
- return new typename data_type::Factory(Alloc);
+ return new typename data_type::Factory(Alloc);
}
-
+
static void DeleteContext(void* Ctx) {
delete (typename data_type::Factory*) Ctx;
- }
+ }
};
-
+
// Partial-specialization for ImmutableList.
-
+
template <typename T>
struct GRStatePartialTrait< llvm::ImmutableList<T> > {
typedef llvm::ImmutableList<T> data_type;
typedef T key_type;
- typedef typename data_type::Factory& context_type;
-
+ typedef typename data_type::Factory& context_type;
+
static data_type Add(data_type L, key_type K, context_type F) {
return F.Add(K, L);
}
-
+
static inline data_type MakeData(void* const* p) {
- return p ? data_type((const llvm::ImmutableListImpl<T>*) *p)
+ return p ? data_type((const llvm::ImmutableListImpl<T>*) *p)
: data_type(0);
- }
-
+ }
+
static inline void* MakeVoidPtr(data_type D) {
return (void*) D.getInternalPointer();
- }
-
+ }
+
static inline context_type MakeContext(void* p) {
return *((typename data_type::Factory*) p);
}
-
+
static void* CreateContext(llvm::BumpPtrAllocator& Alloc) {
- return new typename data_type::Factory(Alloc);
+ return new typename data_type::Factory(Alloc);
}
-
+
static void DeleteContext(void* Ctx) {
delete (typename data_type::Factory*) Ctx;
- }
+ }
};
} // end clang namespace
diff --git a/include/clang/Analysis/PathSensitive/GRSubEngine.h b/include/clang/Analysis/PathSensitive/GRSubEngine.h
index f4636095ad..62e36f9e64 100644
--- a/include/clang/Analysis/PathSensitive/GRSubEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRSubEngine.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the interface of a subengine of the GRCoreEngine.
+// This file defines the interface of a subengine of the GRCoreEngine.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_GRSUBENGINE_H
@@ -36,28 +36,28 @@ public:
virtual GRStateManager& getStateManager() = 0;
/// ProcessStmt - Called by GRCoreEngine. Used to generate new successor
- /// nodes by processing the 'effects' of a block-level statement.
- virtual void ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) = 0;
-
+ /// nodes by processing the 'effects' of a block-level statement.
+ virtual void ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) = 0;
+
/// ProcessBlockEntrance - Called by GRCoreEngine when start processing
/// a CFGBlock. This method returns true if the analysis should continue
/// exploring the given path, and false otherwise.
virtual bool ProcessBlockEntrance(CFGBlock* B, const GRState* St,
GRBlockCounter BC) = 0;
-
+
/// ProcessBranch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a branch condition.
- virtual void ProcessBranch(Stmt* Condition, Stmt* Term,
+ virtual void ProcessBranch(Stmt* Condition, Stmt* Term,
GRBranchNodeBuilder& builder) = 0;
-
+
/// ProcessIndirectGoto - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a computed goto jump.
virtual void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) = 0;
-
+
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
virtual void ProcessSwitch(GRSwitchNodeBuilder& builder) = 0;
-
+
/// ProcessEndPath - Called by GRCoreEngine. Used to generate end-of-path
/// nodes when the control reaches the end of a function.
virtual void ProcessEndPath(GREndPathNodeBuilder& builder) = 0;
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index 87caf8e054..a3bb8bad84 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -21,66 +21,66 @@
#include <vector>
namespace clang {
-
+
class GRExprEngine;
class BugReporter;
class ObjCMessageExpr;
class GRStmtNodeBuilderRef;
-
+
class GRTransferFuncs {
public:
GRTransferFuncs() {}
virtual ~GRTransferFuncs() {}
-
+
virtual void RegisterPrinters(std::vector<GRState::Printer*>& Printers) {}
virtual void RegisterChecks(BugReporter& BR) {}
-
+
// Calls.
-
+
virtual void EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {}
-
+
virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred) {}
-
+
// Stores.
-
+
virtual void EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {}
-
+
// End-of-path and dead symbol notification.
-
+
virtual void EvalEndPath(GRExprEngine& Engine,
GREndPathNodeBuilder& Builder) {}
-
-
+
+
virtual void EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper) {}
-
- // Return statements.
+
+ // Return statements.
virtual void EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred) {}
- // Assumptions.
+ // Assumptions.
virtual const GRState* EvalAssume(const GRState *state,
SVal Cond, bool Assumption) {
return state;
}
};
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/GRWorkList.h b/include/clang/Analysis/PathSensitive/GRWorkList.h
index b423e88072..17b83fdf9f 100644
--- a/include/clang/Analysis/PathSensitive/GRWorkList.h
+++ b/include/clang/Analysis/PathSensitive/GRWorkList.h
@@ -1,5 +1,5 @@
//==- GRWorkList.h - Worklist class used by GRCoreEngine -----------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -17,16 +17,16 @@
#include "clang/Analysis/PathSensitive/GRBlockCounter.h"
-namespace clang {
+namespace clang {
class ExplodedNodeImpl;
-
+
class GRWorkListUnit {
ExplodedNode* Node;
GRBlockCounter Counter;
CFGBlock* Block;
unsigned BlockIdx;
-
+
public:
GRWorkListUnit(ExplodedNode* N, GRBlockCounter C,
CFGBlock* B, unsigned idx)
@@ -34,13 +34,13 @@ public:
Counter(C),
Block(B),
BlockIdx(idx) {}
-
+
explicit GRWorkListUnit(ExplodedNode* N, GRBlockCounter C)
: Node(N),
Counter(C),
Block(NULL),
BlockIdx(0) {}
-
+
ExplodedNode* getNode() const { return Node; }
GRBlockCounter getBlockCounter() const { return Counter; }
CFGBlock* getBlock() const { return Block; }
@@ -52,25 +52,25 @@ class GRWorkList {
public:
virtual ~GRWorkList();
virtual bool hasWork() const = 0;
-
+
virtual void Enqueue(const GRWorkListUnit& U) = 0;
- void Enqueue(ExplodedNode* N, CFGBlock& B, unsigned idx) {
+ void Enqueue(ExplodedNode* N, CFGBlock& B, unsigned idx) {
Enqueue(GRWorkListUnit(N, CurrentCounter, &B, idx));
}
-
+
void Enqueue(ExplodedNode* N) {
Enqueue(GRWorkListUnit(N, CurrentCounter));
}
-
+
virtual GRWorkListUnit Dequeue() = 0;
-
+
void setBlockCounter(GRBlockCounter C) { CurrentCounter = C; }
GRBlockCounter getBlockCounter() const { return CurrentCounter; }
-
+
static GRWorkList *MakeDFS();
static GRWorkList *MakeBFS();
static GRWorkList *MakeBFSBlockDFSContents();
};
-} // end clang namespace
+} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index 54cb872368..ae0580afa4 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/include/clang/Analysis/PathSensitive/MemRegion.h
@@ -31,15 +31,15 @@
namespace llvm { class raw_ostream; }
namespace clang {
-
+
class MemRegionManager;
class MemSpaceRegion;
class LocationContext;
-
+
//===----------------------------------------------------------------------===//
// Base region classes.
//===----------------------------------------------------------------------===//
-
+
/// MemRegion - The root abstract class for all memory regions.
class MemRegion : public llvm::FoldingSetNode {
public:
@@ -56,52 +56,52 @@ public:
VarRegionKind, FieldRegionKind,
ObjCIvarRegionKind, ObjCObjectRegionKind,
END_DECL_REGIONS,
- END_TYPED_REGIONS };
+ END_TYPED_REGIONS };
private:
const Kind kind;
-
+
protected:
MemRegion(Kind k) : kind(k) {}
virtual ~MemRegion();
public:
ASTContext &getContext() const;
-
+
virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0;
virtual MemRegionManager* getMemRegionManager() const = 0;
std::string getString() const;
-
+
const MemSpaceRegion *getMemorySpace() const;
-
+
const MemRegion *getBaseRegion() const;
-
+
bool hasStackStorage() const;
-
+
bool hasParametersStorage() const;
-
+
bool hasGlobalsStorage() const;
-
+
bool hasGlobalsOrParametersStorage() const;
-
+
bool hasHeapStorage() const;
-
+
bool hasHeapOrStackStorage() const;
virtual void dumpToStream(llvm::raw_ostream& os) const;
void dump() const;
-
- Kind getKind() const { return kind; }
-
+
+ Kind getKind() const { return kind; }
+
template<typename RegionTy> const RegionTy* getAs() const;
-
+
virtual bool isBoundable() const { return false; }
static bool classof(const MemRegion*) { return true; }
};
-
+
/// MemSpaceRegion - A memory region that represents and "memory space";
/// for example, the set of global variables, the stack frame, etc.
class MemSpaceRegion : public MemRegion {
@@ -112,7 +112,7 @@ protected:
MemSpaceRegion(MemRegionManager *mgr) : MemRegion(MemSpaceRegionKind),
Mgr(mgr) {}
-
+
MemRegionManager* getMemRegionManager() const {
return Mgr;
}
@@ -131,28 +131,28 @@ public:
/// are subclasses of SubRegion.
class SubRegion : public MemRegion {
protected:
- const MemRegion* superRegion;
+ const MemRegion* superRegion;
SubRegion(const MemRegion* sReg, Kind k) : MemRegion(k), superRegion(sReg) {}
public:
const MemRegion* getSuperRegion() const {
return superRegion;
}
-
+
MemRegionManager* getMemRegionManager() const;
-
+
bool isSubRegionOf(const MemRegion* R) const;
-
+
static bool classof(const MemRegion* R) {
return R->getKind() > MemSpaceRegionKind;
}
};
-
+
//===----------------------------------------------------------------------===//
// Auxillary data classes for use with MemRegions.
//===----------------------------------------------------------------------===//
class ElementRegion;
-
+
class RegionRawOffset : public std::pair<const MemRegion*, int64_t> {
private:
friend class ElementRegion;
@@ -160,7 +160,7 @@ private:
RegionRawOffset(const MemRegion* reg, int64_t offset = 0)
: std::pair<const MemRegion*, int64_t>(reg, offset) {}
-public:
+public:
// FIXME: Eventually support symbolic offsets.
int64_t getByteOffset() const { return second; }
const MemRegion *getRegion() const { return first; }
@@ -171,7 +171,7 @@ public:
//===----------------------------------------------------------------------===//
// MemRegion subclasses.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
/// AllocaRegion - A region that represents an untyped blob of bytes created
/// by a call to 'alloca'.
@@ -184,9 +184,9 @@ protected:
AllocaRegion(const Expr* ex, unsigned cnt, const MemRegion *superRegion)
: SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {}
-
+
public:
-
+
const Expr* getExpr() const { return Ex; }
bool isBoundable() const { return true; }
@@ -195,32 +195,32 @@ public:
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr* Ex,
unsigned Cnt, const MemRegion *superRegion);
-
+
void dumpToStream(llvm::raw_ostream& os) const;
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == AllocaRegionKind;
}
-};
-
+};
+
/// TypedRegion - An abstract class representing regions that are typed.
class TypedRegion : public SubRegion {
protected:
TypedRegion(const MemRegion* sReg, Kind k) : SubRegion(sReg, k) {}
-
+
public:
virtual QualType getValueType(ASTContext &C) const = 0;
-
+
virtual QualType getLocationType(ASTContext& C) const {
// FIXME: We can possibly optimize this later to cache this value.
return C.getPointerType(getValueType(C));
}
-
+
QualType getDesugaredValueType(ASTContext& C) const {
QualType T = getValueType(C);
return T.getTypePtr() ? T->getDesugaredType() : T;
}
-
+
QualType getDesugaredLocationType(ASTContext& C) const {
return getLocationType(C)->getDesugaredType();
}
@@ -260,9 +260,9 @@ public:
const FunctionDecl *getDecl() const {
return FD;
}
-
+
bool isBoundable() const { return false; }
-
+
virtual void dumpToStream(llvm::raw_ostream& os) const;
void Profile(llvm::FoldingSetNodeID& ID) const;
@@ -285,9 +285,9 @@ protected:
const SymbolRef sym;
public:
- SymbolicRegion(const SymbolRef s, const MemRegion* sreg)
+ SymbolicRegion(const SymbolRef s, const MemRegion* sreg)
: SubRegion(sreg, SymbolicRegionKind), sym(s) {}
-
+
SymbolRef getSymbol() const {
return sym;
}
@@ -299,13 +299,13 @@ public:
static void ProfileRegion(llvm::FoldingSetNodeID& ID,
SymbolRef sym,
const MemRegion* superRegion);
-
+
void dumpToStream(llvm::raw_ostream& os) const;
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == SymbolicRegionKind;
}
-};
+};
/// StringRegion - Region associated with a StringLiteral.
class StringRegion : public TypedRegion {
@@ -323,7 +323,7 @@ protected:
public:
const StringLiteral* getStringLiteral() const { return Str; }
-
+
QualType getValueType(ASTContext& C) const {
return Str->getType();
}
@@ -351,7 +351,7 @@ private:
CompoundLiteralRegion(const CompoundLiteralExpr* cl, const MemRegion* sReg)
: TypedRegion(sReg, CompoundLiteralRegionKind), CL(cl) {}
-
+
static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const CompoundLiteralExpr* CL,
const MemRegion* superRegion);
@@ -363,11 +363,11 @@ public:
bool isBoundable() const { return !CL->isFileScope(); }
void Profile(llvm::FoldingSetNodeID& ID) const;
-
+
void dumpToStream(llvm::raw_ostream& os) const;
const CompoundLiteralExpr* getLiteralExpr() const { return CL; }
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == CompoundLiteralRegionKind;
}
@@ -382,23 +382,23 @@ protected:
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Decl* D,
const MemRegion* superRegion, Kind k);
-
+
public:
const Decl* getDecl() const { return D; }
void Profile(llvm::FoldingSetNodeID& ID) const;
-
+
static bool classof(const MemRegion* R) {
unsigned k = R->getKind();
return k > BEG_DECL_REGIONS && k < END_DECL_REGIONS;
}
};
-
+
class VarRegion : public DeclRegion {
friend class MemRegionManager;
// Data.
const LocationContext *LC;
-
+
// Constructors and private methods.
VarRegion(const VarDecl* vd, const LocationContext *lC, const MemRegion* sReg)
: DeclRegion(vd, sReg, VarRegionKind), LC(lC) {}
@@ -409,24 +409,24 @@ class VarRegion : public DeclRegion {
DeclRegion::ProfileRegion(ID, VD, superRegion, VarRegionKind);
ID.AddPointer(LC);
}
-
+
void Profile(llvm::FoldingSetNodeID& ID) const;
-
-public:
+
+public:
const VarDecl *getDecl() const { return cast<VarDecl>(D); }
-
+
const LocationContext *getLocationContext() const { return LC; }
-
- QualType getValueType(ASTContext& C) const {
+
+ QualType getValueType(ASTContext& C) const {
// FIXME: We can cache this if needed.
return C.getCanonicalType(getDecl()->getType());
- }
-
+ }
+
void dumpToStream(llvm::raw_ostream& os) const;
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == VarRegionKind;
- }
+ }
};
class FieldRegion : public DeclRegion {
@@ -436,57 +436,57 @@ class FieldRegion : public DeclRegion {
: DeclRegion(fd, sReg, FieldRegionKind) {}
public:
-
+
void dumpToStream(llvm::raw_ostream& os) const;
-
+
const FieldDecl* getDecl() const { return cast<FieldDecl>(D); }
-
- QualType getValueType(ASTContext& C) const {
+
+ QualType getValueType(ASTContext& C) const {
// FIXME: We can cache this if needed.
return C.getCanonicalType(getDecl()->getType());
- }
+ }
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const FieldDecl* FD,
const MemRegion* superRegion) {
DeclRegion::ProfileRegion(ID, FD, superRegion, FieldRegionKind);
}
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == FieldRegionKind;
}
};
-
+
class ObjCObjectRegion : public DeclRegion {
-
+
friend class MemRegionManager;
-
+
ObjCObjectRegion(const ObjCInterfaceDecl* ivd, const MemRegion* sReg)
: DeclRegion(ivd, sReg, ObjCObjectRegionKind) {}
-
+
static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const ObjCInterfaceDecl* ivd,
const MemRegion* superRegion) {
DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCObjectRegionKind);
}
-
+
public:
const ObjCInterfaceDecl* getInterface() const {
return cast<ObjCInterfaceDecl>(D);
}
-
+
QualType getValueType(ASTContext& C) const {
return C.getObjCInterfaceType(getInterface());
}
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == ObjCObjectRegionKind;
}
-};
-
+};
+
class ObjCIvarRegion : public DeclRegion {
-
+
friend class MemRegionManager;
-
+
ObjCIvarRegion(const ObjCIvarDecl* ivd, const MemRegion* sReg)
: DeclRegion(ivd, sReg, ObjCIvarRegionKind) {}
@@ -494,13 +494,13 @@ class ObjCIvarRegion : public DeclRegion {
const MemRegion* superRegion) {
DeclRegion::ProfileRegion(ID, ivd, superRegion, ObjCIvarRegionKind);
}
-
+
public:
const ObjCIvarDecl* getDecl() const { return cast<ObjCIvarDecl>(D); }
QualType getValueType(ASTContext&) const { return getDecl()->getType(); }
-
+
void dumpToStream(llvm::raw_ostream& os) const;
-
+
static bool classof(const MemRegion* R) {
return R->getKind() == ObjCIvarRegionKind;
}
@@ -519,7 +519,7 @@ class ElementRegion : public TypedRegion {
cast<nonloc::ConcreteInt>(&Idx)->getValue().isSigned()) &&
"The index must be signed");
}
-
+
static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType elementType,
SVal Idx, const MemRegion* superRegion);
@@ -530,13 +530,13 @@ public:
QualType getValueType(ASTContext&) const {
return ElementType;
}
-
+
QualType getElementType() const {
return ElementType;
}
-
+
RegionRawOffset getAsRawOffset() const;
-
+
void dumpToStream(llvm::raw_ostream& os) const;
void Profile(llvm::FoldingSetNodeID& ID) const;
@@ -550,7 +550,7 @@ template<typename RegionTy>
const RegionTy* MemRegion::getAs() const {
if (const RegionTy* RT = dyn_cast<RegionTy>(this))
return RT;
-
+
return NULL;
}
@@ -562,7 +562,7 @@ class MemRegionManager {
ASTContext &C;
llvm::BumpPtrAllocator& A;
llvm::FoldingSet<MemRegion> Regions;
-
+
MemSpaceRegion *globals;
MemSpaceRegion *stack;
MemSpaceRegion *stackArguments;
@@ -574,11 +574,11 @@ public:
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator& a)
: C(c), A(a), globals(0), stack(0), stackArguments(0), heap(0),
unknown(0), code(0) {}
-
+
~MemRegionManager() {}
-
+
ASTContext &getContext() { return C; }
-
+
/// getStackRegion - Retrieve the memory region associated with the
/// current stack frame.
MemSpaceRegion *getStackRegion();
@@ -586,11 +586,11 @@ public:
/// getStackArgumentsRegion - Retrieve the memory region associated with
/// function/method arguments of the current stack frame.
MemSpaceRegion *getStackArgumentsRegion();
-
+
/// getGlobalsRegion - Retrieve the memory region associated with
/// all global variables.
MemSpaceRegion *getGlobalsRegion();
-
+
/// getHeapRegion - Retrieve the memory region associated with the
/// generic "heap".
MemSpaceRegion *getHeapRegion();
@@ -603,12 +603,12 @@ public:
/// getAllocaRegion - Retrieve a region associated with a call to alloca().
AllocaRegion *getAllocaRegion(const Expr* Ex, unsigned Cnt);
-
+
/// getCompoundLiteralRegion - Retrieve the region associated with a
/// given CompoundLiteral.
CompoundLiteralRegion*
- getCompoundLiteralRegion(const CompoundLiteralExpr* CL);
-
+ getCompoundLiteralRegion(const CompoundLiteralExpr* CL);
+
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
SymbolicRegion* getSymbolicRegion(SymbolRef sym);
@@ -617,13 +617,13 @@ public:
/// getVarRegion - Retrieve or create the memory region associated with
/// a specified VarDecl and LocationContext.
VarRegion* getVarRegion(const VarDecl *D, const LocationContext *LC);
-
+
/// getElementRegion - Retrieve the memory region associated with the
/// associated element type, index, and super region.
ElementRegion *getElementRegion(QualType elementType, SVal Idx,
const MemRegion *superRegion,
ASTContext &Ctx);
-
+
ElementRegion *getElementRegionWithSuper(const ElementRegion *ER,
const MemRegion *superRegion) {
return getElementRegion(ER->getElementType(), ER->getIndex(),
@@ -636,44 +636,44 @@ public:
/// a structure or class).
FieldRegion *getFieldRegion(const FieldDecl* fd,
const MemRegion* superRegion);
-
+
FieldRegion *getFieldRegionWithSuper(const FieldRegion *FR,
const MemRegion *superRegion) {
return getFieldRegion(FR->getDecl(), superRegion);
}
-
+
/// getObjCObjectRegion - Retrieve or create the memory region associated with
/// the instance of a specified Objective-C class.
ObjCObjectRegion* getObjCObjectRegion(const ObjCInterfaceDecl* ID,
const MemRegion* superRegion);
-
+
/// getObjCIvarRegion - Retrieve or create the memory region associated with
/// a specified Objective-c instance variable. 'superRegion' corresponds
/// to the containing region (which typically represents the Objective-C
/// object).
ObjCIvarRegion *getObjCIvarRegion(const ObjCIvarDecl* ivd,
const MemRegion* superRegion);
-
+
CodeTextRegion *getCodeTextRegion(const FunctionDecl *FD);
-
+
template <typename RegionTy, typename A1>
RegionTy* getRegion(const A1 a1);
-
+
template <typename RegionTy, typename A1>
RegionTy* getSubRegion(const A1 a1, const MemRegion* superRegion);
-
+
template <typename RegionTy, typename A1, typename A2>
RegionTy* getRegion(const A1 a1, const A2 a2);
- bool isGlobalsRegion(const MemRegion* R) {
+ bool isGlobalsRegion(const MemRegion* R) {
assert(R);
- return R == globals;
+ return R == globals;
}
-
+
private:
MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
};
-
+
//===----------------------------------------------------------------------===//
// Out-of-line member definitions.
//===----------------------------------------------------------------------===//
@@ -681,69 +681,69 @@ private:
inline ASTContext& MemRegion::getContext() const {
return getMemRegionManager()->getContext();
}
-
+
template<typename RegionTy> struct MemRegionManagerTrait;
-
+
template <typename RegionTy, typename A1>
RegionTy* MemRegionManager::getRegion(const A1 a1) {
const typename MemRegionManagerTrait<RegionTy>::SuperRegionTy *superRegion =
MemRegionManagerTrait<RegionTy>::getSuperRegion(*this, a1);
-
- llvm::FoldingSetNodeID ID;
- RegionTy::ProfileRegion(ID, a1, superRegion);
+
+ llvm::FoldingSetNodeID ID;
+ RegionTy::ProfileRegion(ID, a1, superRegion);
void* InsertPos;
RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
InsertPos));
-
+
if (!R) {
R = (RegionTy*) A.Allocate<RegionTy>();
new (R) RegionTy(a1, superRegion);
Regions.InsertNode(R, InsertPos);
}
-
+
return R;
}
template <typename RegionTy, typename A1>
RegionTy* MemRegionManager::getSubRegion(const A1 a1,
const MemRegion *superRegion) {
- llvm::FoldingSetNodeID ID;
- RegionTy::ProfileRegion(ID, a1, superRegion);
+ llvm::FoldingSetNodeID ID;
+ RegionTy::ProfileRegion(ID, a1, superRegion);
void* InsertPos;
RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
InsertPos));
-
+
if (!R) {
R = (RegionTy*) A.Allocate<RegionTy>();
new (R) RegionTy(a1, superRegion);
Regions.InsertNode(R, InsertPos);
}
-
+
return R;
}
-
+
template <typename RegionTy, typename A1, typename A2>
RegionTy* MemRegionManager::getRegion(const A1 a1, const A2 a2) {
-
+
const typename MemRegionManagerTrait<RegionTy>::SuperRegionTy *superRegion =
MemRegionManagerTrait<RegionTy>::getSuperRegion(*this, a1, a2);
-
- llvm::FoldingSetNodeID ID;
- RegionTy::ProfileRegion(ID, a1, a2, superRegion);
+
+ llvm::FoldingSetNodeID ID;
+ RegionTy::ProfileRegion(ID, a1, a2, superRegion);
void* InsertPos;
RegionTy* R = cast_or_null<RegionTy>(Regions.FindNodeOrInsertPos(ID,
InsertPos));
-
+
if (!R) {
R = (RegionTy*) A.Allocate<RegionTy>();
new (R) RegionTy(a1, a2, superRegion);
Regions.InsertNode(R, InsertPos);
}
-
+
return R;
}
-
+
//===----------------------------------------------------------------------===//
// Traits for constructing regions.
//===----------------------------------------------------------------------===//
@@ -754,18 +754,18 @@ template <> struct MemRegionManagerTrait<AllocaRegion> {
const Expr *, unsigned) {
return MRMgr.getStackRegion();
}
-};
-
+};
+
template <> struct MemRegionManagerTrait<CompoundLiteralRegion> {
typedef MemRegion SuperRegionTy;
static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr,
const CompoundLiteralExpr *CL) {
-
- return CL->isFileScope() ? MRMgr.getGlobalsRegion()
+
+ return CL->isFileScope() ? MRMgr.getGlobalsRegion()
: MRMgr.getStackRegion();
}
};
-
+
template <> struct MemRegionManagerTrait<StringRegion> {
typedef MemSpaceRegion SuperRegionTy;
static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr,
@@ -773,24 +773,24 @@ template <> struct MemRegionManagerTrait<StringRegion> {
return MRMgr.getGlobalsRegion();
}
};
-
+
template <> struct MemRegionManagerTrait<VarRegion> {
typedef MemRegion SuperRegionTy;
static const SuperRegionTy* getSuperRegion(MemRegionManager &MRMgr,
const VarDecl *D,
const LocationContext *LC) {
-
+
// FIXME: Make stack regions have a location context?
-
+
if (D->hasLocalStorage()) {
return isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)
? MRMgr.getStackArgumentsRegion() : MRMgr.getStackRegion();
}
-
+
return MRMgr.getGlobalsRegion();
}
};
-
+
template <> struct MemRegionManagerTrait<SymbolicRegion> {
typedef MemRegion SuperRegionTy;
static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr,
@@ -810,7 +810,7 @@ template<> struct MemRegionManagerTrait<CodeTextRegion> {
return MRMgr.getCodeRegion();
}
};
-
+
} // end clang namespace
//===----------------------------------------------------------------------===//
@@ -819,7 +819,7 @@ template<> struct MemRegionManagerTrait<CodeTextRegion> {
namespace llvm {
static inline raw_ostream& operator<<(raw_ostream& os,
- const clang::MemRegion* R) {
+ const clang::MemRegion* R) {
R->dumpToStream(os);
return os;
}
diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h
index 1dd690695e..608364af5e 100644
--- a/include/clang/Analysis/PathSensitive/SVals.h
+++ b/include/clang/Analysis/PathSensitive/SVals.h
@@ -38,35 +38,35 @@ class TypedRegion;
class MemRegionManager;
class GRStateManager;
class ValueManager;
-
+
class SVal {
public:
enum BaseKind { UndefinedKind, UnknownKind, LocKind, NonLocKind };
enum { BaseBits = 2, BaseMask = 0x3 };
-
+
protected:
void* Data;
unsigned Kind;
-
+
protected:
SVal(const void* d, bool isLoc, unsigned ValKind)
: Data(const_cast<void*>(d)),
Kind((isLoc ? LocKind : NonLocKind) | (ValKind << BaseBits)) {}
-
+
explicit SVal(BaseKind k, void* D = NULL)
: Data(D), Kind(k) {}
-
+
public:
SVal() : Data(0), Kind(0) {}
~SVal() {};
-
+
/// BufferTy - A temporary buffer to hold a set of SVals.
typedef llvm::SmallVector<SVal,5> BufferTy;
-
+
inline unsigned getRawKind() const { return Kind; }
inline BaseKind getBaseKind() const { return (BaseKind) (Kind & BaseMask); }
inline unsigned getSubKind() const { return (Kind & ~BaseMask) >> BaseBits; }
-
+
inline void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned) getRawKind());
ID.AddPointer(reinterpret_cast<void*>(Data));
@@ -75,7 +75,7 @@ public:
inline bool operator==(const SVal& R) const {
return getRawKind() == R.getRawKind() && Data == R.Data;
}
-
+
inline bool operator!=(const SVal& R) const {
return !(*this == R);
}
@@ -91,25 +91,25 @@ public:
inline bool isUnknownOrUndef() const {
return getRawKind() <= UnknownKind;
}
-
+
inline bool isValid() const {
return getRawKind() > UnknownKind;
}
-
+
bool isZeroConstant() const;
/// hasConjuredSymbol - If this SVal wraps a conjured symbol, return true;
bool hasConjuredSymbol() const;
/// getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a
- /// CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl.
+ /// CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl.
/// Otherwise return 0.
const FunctionDecl* getAsFunctionDecl() const;
-
- /// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
+
+ /// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
/// wraps a symbol, return that SymbolRef. Otherwise return a SymbolData*
SymbolRef getAsLocSymbol() const;
-
+
/// getAsSymbol - If this Sval wraps a symbol return that SymbolRef.
/// Otherwise return a SymbolRef where 'isValid()' returns false.
SymbolRef getAsSymbol() const;
@@ -119,7 +119,7 @@ public:
const SymExpr *getAsSymbolicExpression() const;
const MemRegion *getAsRegion() const;
-
+
void dumpToStream(llvm::raw_ostream& OS) const;
void dump() const;
@@ -130,14 +130,14 @@ public:
public:
symbol_iterator() {}
symbol_iterator(const SymExpr* SE);
-
+
symbol_iterator& operator++();
SymbolRef operator*();
-
+
bool operator==(const symbol_iterator& X) const;
bool operator!=(const symbol_iterator& X) const;
};
-
+
symbol_iterator symbol_begin() const {
const SymExpr *SE = getAsSymbolicExpression();
if (SE)
@@ -145,9 +145,9 @@ public:
else
return symbol_iterator();
}
-
+
symbol_iterator symbol_end() const { return symbol_iterator(); }
-
+
// Implement isa<T> support.
static inline bool classof(const SVal*) { return true; }
};
@@ -155,24 +155,24 @@ public:
class UnknownVal : public SVal {
public:
UnknownVal() : SVal(UnknownKind) {}
-
+
static inline bool classof(const SVal* V) {
return V->getBaseKind() == UnknownKind;
- }
+ }
};
class UndefinedVal : public SVal {
public:
UndefinedVal() : SVal(UndefinedKind) {}
UndefinedVal(void* D) : SVal(UndefinedKind, D) {}
-
+
static inline bool classof(const SVal* V) {
return V->getBaseKind() == UndefinedKind;
}
-
- void* getData() const { return Data; }
+
+ void* getData() const { return Data; }
};
-
+
class DefinedSVal : public SVal {
protected:
DefinedSVal(const void* d, bool isLoc, unsigned ValKind)
@@ -181,16 +181,16 @@ public:
// Implement isa<T> support.
static inline bool classof(const SVal *V) {
return !V->isUnknownOrUndef();
- }
+ }
};
class NonLoc : public DefinedSVal {
protected:
NonLoc(unsigned SubKind, const void* d) : DefinedSVal(d, false, SubKind) {}
-
+
public:
void dumpToStream(llvm::raw_ostream& Out) const;
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind;
@@ -207,45 +207,45 @@ public:
Loc(const Loc& X) : DefinedSVal(X.Data, true, X.getSubKind()) {}
Loc& operator=(const Loc& X) { memcpy(this, &X, sizeof(Loc)); return *this; }
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == LocKind;
}
-
+
static inline bool IsLocType(QualType T) {
return T->isAnyPointerType() || T->isBlockPointerType();
}
};
-
+
//==------------------------------------------------------------------------==//
// Subclasses of NonLoc.
//==------------------------------------------------------------------------==//
namespace nonloc {
-
+
enum Kind { ConcreteIntKind, SymbolValKind, SymExprValKind,
LocAsIntegerKind, CompoundValKind, LazyCompoundValKind };
class SymbolVal : public NonLoc {
public:
SymbolVal(SymbolRef sym) : NonLoc(SymbolValKind, sym) {}
-
+
SymbolRef getSymbol() const {
return (const SymbolData*) Data;
}
-
+
static inline bool classof(const SVal* V) {
- return V->getBaseKind() == NonLocKind &&
+ return V->getBaseKind() == NonLocKind &&
V->getSubKind() == SymbolValKind;
}
-
+
static inline bool classof(const NonLoc* V) {
return V->getSubKind() == SymbolValKind;
}
};
-class SymExprVal : public NonLoc {
+class SymExprVal : public NonLoc {
public:
SymExprVal(const SymExpr *SE)
: NonLoc(SymExprValKind, reinterpret_cast<const void*>(SE)) {}
@@ -253,12 +253,12 @@ public:
const SymExpr *getSymbolicExpression() const {
return reinterpret_cast<SymExpr*>(Data);
}
-
+
static inline bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind &&
V->getSubKind() == SymExprValKind;
}
-
+
static inline bool classof(const NonLoc* V) {
return V->getSubKind() == SymExprValKind;
}
@@ -267,30 +267,30 @@ public:
class ConcreteInt : public NonLoc {
public:
ConcreteInt(const llvm::APSInt& V) : NonLoc(ConcreteIntKind, &V) {}
-
+
const llvm::APSInt& getValue() const {
return *static_cast<llvm::APSInt*>(Data);
}
-
+
// Transfer functions for binary/unary operations on ConcreteInts.
SVal evalBinOp(ValueManager &ValMgr, BinaryOperator::Opcode Op,
const ConcreteInt& R) const;
-
+
ConcreteInt evalComplement(ValueManager &ValMgr) const;
-
+
ConcreteInt evalMinus(ValueManager &ValMgr) const;
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind &&
V->getSubKind() == ConcreteIntKind;
}
-
+
static inline bool classof(const NonLoc* V) {
return V->getSubKind() == ConcreteIntKind;
}
};
-
+
class LocAsInteger : public NonLoc {
friend class clang::ValueManager;
@@ -298,28 +298,28 @@ class LocAsInteger : public NonLoc {
NonLoc(LocAsIntegerKind, &data) {
assert (isa<Loc>(data.first));
}
-
+
public:
-
+
Loc getLoc() const {
return cast<Loc>(((std::pair<SVal, uintptr_t>*) Data)->first);
}
-
+
const Loc& getPersistentLoc() const {
const SVal& V = ((std::pair<SVal, uintptr_t>*) Data)->first;
return cast<Loc>(V);
- }
-
+ }
+
unsigned getNumBits() const {
return ((std::pair<SVal, unsigned>*) Data)->second;
}
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind &&
V->getSubKind() == LocAsIntegerKind;
}
-
+
static inline bool classof(const NonLoc* V) {
return V->getSubKind() == LocAsIntegerKind;
}
@@ -334,10 +334,10 @@ public:
const CompoundValData* getValue() const {
return static_cast<CompoundValData*>(Data);
}
-
+
typedef llvm::ImmutableList<SVal>::iterator iterator;
iterator begin() const;
- iterator end() const;
+ iterator end() const;
static bool classof(const SVal* V) {
return V->getBaseKind() == NonLocKind && V->getSubKind() == CompoundValKind;
@@ -347,7 +347,7 @@ public:
return V->getSubKind() == CompoundValKind;
}
};
-
+
class LazyCompoundVal : public NonLoc {
friend class clang::ValueManager;
@@ -359,16 +359,16 @@ public:
}
const GRState *getState() const;
const TypedRegion *getRegion() const;
-
+
static bool classof(const SVal *V) {
- return V->getBaseKind() == NonLocKind &&
+ return V->getBaseKind() == NonLocKind &&
V->getSubKind() == LazyCompoundValKind;
}
static bool classof(const NonLoc *V) {
return V->getSubKind() == LazyCompoundValKind;
}
};
-
+
} // end namespace clang::nonloc
//==------------------------------------------------------------------------==//
@@ -376,27 +376,27 @@ public:
//==------------------------------------------------------------------------==//
namespace loc {
-
+
enum Kind { GotoLabelKind, MemRegionKind, ConcreteIntKind };
class GotoLabel : public Loc {
public:
GotoLabel(LabelStmt* Label) : Loc(GotoLabelKind, Label) {}
-
+
LabelStmt* getLabel() const {
return static_cast<LabelStmt*>(Data);
}
-
+
static inline bool classof(const SVal* V) {
return V->getBaseKind() == LocKind &&
V->getSubKind() == GotoLabelKind;
}
-
+
static inline bool classof(const Loc* V) {
return V->getSubKind() == GotoLabelKind;
- }
+ }
};
-
+
class MemRegionVal : public Loc {
public:
@@ -405,37 +405,37 @@ public:
const MemRegion* getRegion() const {
return static_cast<MemRegion*>(Data);
}
-
+
const MemRegion* getBaseRegion() const;
-
+
template <typename REGION>
const REGION* getRegionAs() const {
return llvm::dyn_cast<REGION>(getRegion());
- }
-
+ }
+
inline bool operator==(const MemRegionVal& R) const {
return getRegion() == R.getRegion();
}
-
+
inline bool operator!=(const MemRegionVal& R) const {
return getRegion() != R.getRegion();
}
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == LocKind &&
V->getSubKind() == MemRegionKind;
}
-
+
static inline bool classof(const Loc* V) {
return V->getSubKind() == MemRegionKind;
- }
+ }
};
class ConcreteInt : public Loc {
public:
ConcreteInt(const llvm::APSInt& V) : Loc(ConcreteIntKind, &V) {}
-
+
const llvm::APSInt& getValue() const {
return *static_cast<llvm::APSInt*>(Data);
}
@@ -443,20 +443,20 @@ public:
// Transfer functions for binary/unary operations on ConcreteInts.
SVal EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op,
const ConcreteInt& R) const;
-
+
// Implement isa<T> support.
static inline bool classof(const SVal* V) {
return V->getBaseKind() == LocKind &&
V->getSubKind() == ConcreteIntKind;
}
-
+
static inline bool classof(const Loc* V) {
return V->getSubKind() == ConcreteIntKind;
}
};
-
+
} // end clang::loc namespace
-} // end clang namespace
+} // end clang namespace
namespace llvm {
static inline llvm::raw_ostream& operator<<(llvm::raw_ostream& os,
diff --git a/include/clang/Analysis/PathSensitive/SValuator.h b/include/clang/Analysis/PathSensitive/SValuator.h
index 4635a9cd2a..b08d7ca642 100644
--- a/include/clang/Analysis/PathSensitive/SValuator.h
+++ b/include/clang/Analysis/PathSensitive/SValuator.h
@@ -9,7 +9,7 @@
//
// This file defines SValuator, a class that defines the interface for
// "symbolical evaluators" which construct an SVal from an expression.
-//
+//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_SVALUATOR
@@ -28,14 +28,14 @@ class SValuator {
protected:
ValueManager &ValMgr;
- virtual SVal EvalCastNL(NonLoc val, QualType castTy) = 0;
-
+ virtual SVal EvalCastNL(NonLoc val, QualType castTy) = 0;
+
virtual SVal EvalCastL(Loc val, QualType castTy) = 0;
public:
SValuator(ValueManager &valMgr) : ValMgr(valMgr) {}
virtual ~SValuator() {}
-
+
class CastResult : public std::pair<const GRState *, SVal> {
public:
const GRState *getState() const { return first; }
@@ -43,12 +43,12 @@ public:
CastResult(const GRState *s, SVal v)
: std::pair<const GRState*, SVal>(s, v) {}
};
-
+
CastResult EvalCast(SVal val, const GRState *state,
QualType castTy, QualType originalType);
-
+
virtual SVal EvalMinus(NonLoc val) = 0;
-
+
virtual SVal EvalComplement(NonLoc val) = 0;
virtual SVal EvalBinOpNN(BinaryOperator::Opcode Op, NonLoc lhs,
@@ -58,13 +58,13 @@ public:
QualType resultTy) = 0;
virtual SVal EvalBinOpLN(const GRState *state, BinaryOperator::Opcode Op,
- Loc lhs, NonLoc rhs, QualType resultTy) = 0;
-
+ Loc lhs, NonLoc rhs, QualType resultTy) = 0;
+
SVal EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
SVal L, SVal R, QualType T);
};
-
+
SValuator* CreateSimpleSValuator(ValueManager &valMgr);
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h
index 51143ec84b..047bc6c680 100644
--- a/include/clang/Analysis/PathSensitive/Store.h
+++ b/include/clang/Analysis/PathSensitive/Store.h
@@ -23,16 +23,16 @@
#include "llvm/ADT/SmallVector.h"
namespace clang {
-
+
typedef const void* Store;
-class GRState;
+class GRState;
class GRStateManager;
class Stmt;
class Expr;
class ObjCIvarDecl;
class SubRegionMap;
-
+
class StoreManager {
protected:
ValueManager &ValMgr;
@@ -43,13 +43,13 @@ protected:
StoreManager(GRStateManager &stateMgr);
-public:
+public:
virtual ~StoreManager() {}
-
+
/// Return the value bound to specified location in a given state.
/// \param[in] state The analysis state.
/// \param[in] loc The symbolic memory location.
- /// \param[in] T An optional type that provides a hint indicating the
+ /// \param[in] T An optional type that provides a hint indicating the
/// expected type of the returned value. This is used if the value is
/// lazily computed.
/// \return The value bound to the location \c loc.
@@ -60,13 +60,13 @@ public:
/// \param[in] state The analysis state.
/// \param[in] loc The symbolic memory location.
/// \param[in] val The value to bind to location \c loc.
- /// \return A pointer to a GRState object that contains the same bindings as
+ /// \return A pointer to a GRState object that contains the same bindings as
/// \c state with the addition of having the value specified by \c val bound
/// to the location given for \c loc.
virtual const GRState *Bind(const GRState *state, Loc loc, SVal val) = 0;
virtual Store Remove(Store St, Loc L) = 0;
-
+
/// BindCompoundLiteral - Return the store that has the bindings currently
/// in 'store' plus the bindings for the CompoundLiteral. 'R' is the region
/// for the compound literal and 'BegInit' and 'EndInit' represent an
@@ -74,15 +74,15 @@ public:
virtual const GRState *BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* cl,
SVal v) = 0;
-
+
/// getInitialStore - Returns the initial "empty" store representing the
/// value bindings upon entry to an analyzed function.
virtual Store getInitialStore(const LocationContext *InitLoc) = 0;
-
+
/// getRegionManager - Returns the internal RegionManager object that is
/// used to query and manipulate MemRegion objects.
MemRegionManager& getRegionManager() { return MRMgr; }
-
+
/// getSubRegionMap - Returns an opaque map object that clients can query
/// to get the subregions of a given MemRegion object. It is the
// caller's responsibility to 'delete' the returned map.
@@ -96,13 +96,13 @@ public:
virtual SVal getLValueCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* cl) = 0;
-
+
virtual SVal getLValueIvar(const GRState *state, const ObjCIvarDecl* decl,
SVal base) = 0;
-
+
virtual SVal getLValueField(const GRState *state, SVal base,
const FieldDecl* D) = 0;
-
+
virtual SVal getLValueElement(const GRState *state, QualType elementType,
SVal base, SVal offset) = 0;
@@ -114,7 +114,7 @@ public:
/// ArrayToPointer - Used by GRExprEngine::VistCast to handle implicit
/// conversions between arrays and pointers.
virtual SVal ArrayToPointer(Loc Array) = 0;
-
+
class CastResult {
const GRState *state;
const MemRegion *region;
@@ -123,19 +123,19 @@ public:
const MemRegion* getRegion() const { return region; }
CastResult(const GRState *s, const MemRegion* r = 0) : state(s), region(r){}
};
-
+
/// CastRegion - Used by GRExprEngine::VisitCast to handle casts from
/// a MemRegion* to a specific location type. 'R' is the region being
/// casted and 'CastToTy' the result type of the cast.
CastResult CastRegion(const GRState *state, const MemRegion *region,
- QualType CastToTy);
+ QualType CastToTy);
/// EvalBinOp - Perform pointer arithmetic.
virtual SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,
Loc lhs, NonLoc rhs, QualType resultTy) {
return UnknownVal();
}
-
+
virtual void RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
@@ -166,14 +166,14 @@ public:
virtual void print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) = 0;
-
+
class BindingsHandler {
- public:
+ public:
virtual ~BindingsHandler();
virtual bool HandleBinding(StoreManager& SMgr, Store store,
const MemRegion *region, SVal val) = 0;
};
-
+
/// iterBindings - Iterate over the bindings in the Store.
virtual void iterBindings(Store store, BindingsHandler& f) = 0;
@@ -181,12 +181,12 @@ protected:
CastResult MakeElementRegion(const GRState *state, const MemRegion *region,
QualType pointeeTy, QualType castToTy,
uint64_t index = 0);
-
+
/// CastRetrievedVal - Used by subclasses of StoreManager to implement
/// implicit casts that arise from loads from regions that are reinterpreted
/// as another region.
SValuator::CastResult CastRetrievedVal(SVal val, const GRState *state,
- const TypedRegion *R, QualType castTy);
+ const TypedRegion *R, QualType castTy);
};
// FIXME: Do we still need this?
@@ -195,14 +195,14 @@ protected:
class SubRegionMap {
public:
virtual ~SubRegionMap() {}
-
+
class Visitor {
public:
virtual ~Visitor() {};
virtual bool Visit(const MemRegion* Parent, const MemRegion* SubRegion) = 0;
};
-
- virtual bool iterSubRegions(const MemRegion *region, Visitor& V) const = 0;
+
+ virtual bool iterSubRegions(const MemRegion *region, Visitor& V) const = 0;
};
// FIXME: Do we need to pass GRStateManager anymore?
diff --git a/include/clang/Analysis/PathSensitive/SymbolManager.h b/include/clang/Analysis/PathSensitive/SymbolManager.h
index 1a46e90b41..d3996c6330 100644
--- a/include/clang/Analysis/PathSensitive/SymbolManager.h
+++ b/include/clang/Analysis/PathSensitive/SymbolManager.h
@@ -27,7 +27,7 @@ namespace llvm {
class raw_ostream;
}
-namespace clang {
+namespace clang {
class MemRegion;
class TypedRegion;
class ASTContext;
@@ -35,7 +35,7 @@ namespace clang {
}
namespace clang {
-
+
class SymExpr : public llvm::FoldingSetNode {
public:
enum Kind { BEGIN_SYMBOLS,
@@ -46,47 +46,47 @@ private:
Kind K;
protected:
- SymExpr(Kind k) : K(k) {}
-
+ SymExpr(Kind k) : K(k) {}
+
public:
virtual ~SymExpr() {}
-
- Kind getKind() const { return K; }
-
+
+ Kind getKind() const { return K; }
+
void dump() const;
-
+
virtual void dumpToStream(llvm::raw_ostream &os) const = 0;
-
- virtual QualType getType(ASTContext&) const = 0;
+
+ virtual QualType getType(ASTContext&) const = 0;
virtual void Profile(llvm::FoldingSetNodeID& profile) = 0;
-
+
// Implement isa<T> support.
static inline bool classof(const SymExpr*) { return true; }
};
-
+
typedef unsigned SymbolID;
-
+
class SymbolData : public SymExpr {
private:
const SymbolID Sym;
-
+
protected:
- SymbolData(Kind k, SymbolID sym) : SymExpr(k), Sym(sym) {}
+ SymbolData(Kind k, SymbolID sym) : SymExpr(k), Sym(sym) {}
public:
virtual ~SymbolData() {}
-
+
SymbolID getSymbolID() const { return Sym; }
// Implement isa<T> support.
- static inline bool classof(const SymExpr* SE) {
+ static inline bool classof(const SymExpr* SE) {
Kind k = SE->getKind();
return k > BEGIN_SYMBOLS && k < END_SYMBOLS;
}
};
typedef const SymbolData* SymbolRef;
-
+
class SymbolRegionValue : public SymbolData {
const MemRegion *R;
// We may cast the region to another type, so the expected type of the symbol
@@ -96,7 +96,7 @@ class SymbolRegionValue : public SymbolData {
public:
SymbolRegionValue(SymbolID sym, const MemRegion *r, QualType t = QualType())
: SymbolData(RegionValueKind, sym), R(r), T(t) {}
-
+
const MemRegion* getRegion() const { return R; }
static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,
@@ -105,13 +105,13 @@ public:
profile.AddPointer(R);
T.Profile(profile);
}
-
+
virtual void Profile(llvm::FoldingSetNodeID& profile) {
Profile(profile, R, T);
}
-
+
void dumpToStream(llvm::raw_ostream &os) const;
-
+
QualType getType(ASTContext&) const;
// Implement isa<T> support.
@@ -131,17 +131,17 @@ public:
const void* symbolTag)
: SymbolData(ConjuredKind, sym), S(s), T(t), Count(count),
SymbolTag(symbolTag) {}
-
+
const Stmt* getStmt() const { return S; }
unsigned getCount() const { return Count; }
const void* getTag() const { return SymbolTag; }
-
+
QualType getType(ASTContext&) const;
-
+
void dumpToStream(llvm::raw_ostream &os) const;
-
+
static void Profile(llvm::FoldingSetNodeID& profile, const Stmt* S,
- QualType T, unsigned Count, const void* SymbolTag) {
+ QualType T, unsigned Count, const void* SymbolTag) {
profile.AddInteger((unsigned) ConjuredKind);
profile.AddPointer(S);
profile.Add(T);
@@ -156,39 +156,39 @@ public:
// Implement isa<T> support.
static inline bool classof(const SymExpr* SE) {
return SE->getKind() == ConjuredKind;
- }
+ }
};
-
+
class SymbolDerived : public SymbolData {
SymbolRef parentSymbol;
const TypedRegion *R;
-
+
public:
SymbolDerived(SymbolID sym, SymbolRef parent, const TypedRegion *r)
: SymbolData(DerivedKind, sym), parentSymbol(parent), R(r) {}
SymbolRef getParentSymbol() const { return parentSymbol; }
const TypedRegion *getRegion() const { return R; }
-
+
QualType getType(ASTContext&) const;
-
+
void dumpToStream(llvm::raw_ostream &os) const;
-
+
static void Profile(llvm::FoldingSetNodeID& profile, SymbolRef parent,
const TypedRegion *r) {
profile.AddInteger((unsigned) DerivedKind);
profile.AddPointer(r);
profile.AddPointer(parent);
}
-
+
virtual void Profile(llvm::FoldingSetNodeID& profile) {
Profile(profile, parentSymbol, R);
}
-
+
// Implement isa<T> support.
static inline bool classof(const SymExpr* SE) {
return SE->getKind() == DerivedKind;
- }
+ }
};
// SymIntExpr - Represents symbolic expression like 'x' + 3.
@@ -205,16 +205,16 @@ public:
// FIXME: We probably need to make this out-of-line to avoid redundant
// generation of virtual functions.
- QualType getType(ASTContext& C) const { return T; }
-
+ QualType getType(ASTContext& C) const { return T; }
+
BinaryOperator::Opcode getOpcode() const { return Op; }
-
- void dumpToStream(llvm::raw_ostream &os) const;
-
+
+ void dumpToStream(llvm::raw_ostream &os) const;
+
const SymExpr *getLHS() const { return LHS; }
const llvm::APSInt &getRHS() const { return RHS; }
- static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
+ static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
BinaryOperator::Opcode op, const llvm::APSInt& rhs,
QualType t) {
ID.AddInteger((unsigned) SymIntKind);
@@ -227,11 +227,11 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) {
Profile(ID, LHS, Op, RHS, T);
}
-
+
// Implement isa<T> support.
static inline bool classof(const SymExpr* SE) {
return SE->getKind() == SymIntKind;
- }
+ }
};
// SymSymExpr - Represents symbolic expression like 'x' + 'y'.
@@ -248,13 +248,13 @@ public:
const SymExpr *getLHS() const { return LHS; }
const SymExpr *getRHS() const { return RHS; }
-
+
// FIXME: We probably need to make this out-of-line to avoid redundant
// generation of virtual functions.
QualType getType(ASTContext& C) const { return T; }
-
+
void dumpToStream(llvm::raw_ostream &os) const;
-
+
static void Profile(llvm::FoldingSetNodeID& ID, const SymExpr *lhs,
BinaryOperator::Opcode op, const SymExpr *rhs, QualType t) {
ID.AddInteger((unsigned) SymSymKind);
@@ -267,48 +267,48 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) {
Profile(ID, LHS, Op, RHS, T);
}
-
+
// Implement isa<T> support.
static inline bool classof(const SymExpr* SE) {
return SE->getKind() == SymSymKind;
- }
+ }
};
class SymbolManager {
typedef llvm::FoldingSet<SymExpr> DataSetTy;
- DataSetTy DataSet;
+ DataSetTy DataSet;
unsigned SymbolCounter;
llvm::BumpPtrAllocator& BPAlloc;
BasicValueFactory &BV;
ASTContext& Ctx;
-
+
public:
- SymbolManager(ASTContext& ctx, BasicValueFactory &bv,
+ SymbolManager(ASTContext& ctx, BasicValueFactory &bv,
llvm::BumpPtrAllocator& bpalloc)
: SymbolCounter(0), BPAlloc(bpalloc), BV(bv), Ctx(ctx) {}
-
+
~SymbolManager();
-
+
static bool canSymbolicate(QualType T);
/// Make a unique symbol for MemRegion R according to its kind.
- const SymbolRegionValue* getRegionValueSymbol(const MemRegion* R,
+ const SymbolRegionValue* getRegionValueSymbol(const MemRegion* R,
QualType T = QualType());
const SymbolConjured* getConjuredSymbol(const Stmt* E, QualType T,
unsigned VisitCount,
const void* SymbolTag = 0);
const SymbolConjured* getConjuredSymbol(const Expr* E, unsigned VisitCount,
- const void* SymbolTag = 0) {
+ const void* SymbolTag = 0) {
return getConjuredSymbol(E, E->getType(), VisitCount, SymbolTag);
}
-
+
const SymbolDerived *getDerivedSymbol(SymbolRef parentSymbol,
const TypedRegion *R);
const SymIntExpr *getSymIntExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
const llvm::APSInt& rhs, QualType t);
-
+
const SymIntExpr *getSymIntExpr(const SymExpr &lhs, BinaryOperator::Opcode op,
const llvm::APSInt& rhs, QualType t) {
return getSymIntExpr(&lhs, op, rhs, t);
@@ -316,27 +316,27 @@ public:
const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType t);
-
+
QualType getType(const SymExpr *SE) const {
return SE->getType(Ctx);
}
-
+
ASTContext &getContext() { return Ctx; }
BasicValueFactory &getBasicVals() { return BV; }
};
-
+
class SymbolReaper {
typedef llvm::DenseSet<SymbolRef> SetTy;
-
+
SetTy TheLiving;
SetTy TheDead;
LiveVariables& Liveness;
SymbolManager& SymMgr;
-
+
public:
SymbolReaper(LiveVariables& liveness, SymbolManager& symmgr)
: Liveness(liveness), SymMgr(symmgr) {}
-
+
~SymbolReaper() {}
bool isLive(SymbolRef sym);
@@ -348,19 +348,19 @@ public:
bool isLive(const Stmt* Loc, const VarDecl* VD) const {
return Liveness.isLive(Loc, VD);
}
-
+
void markLive(SymbolRef sym);
bool maybeDead(SymbolRef sym);
-
+
typedef SetTy::const_iterator dead_iterator;
dead_iterator dead_begin() const { return TheDead.begin(); }
dead_iterator dead_end() const { return TheDead.end(); }
-
+
bool hasDeadSymbols() const {
return !TheDead.empty();
}
};
-
+
class SymbolVisitor {
public:
// VisitSymbol - A visitor method invoked by
@@ -369,7 +369,7 @@ public:
virtual bool VisitSymbol(SymbolRef sym) = 0;
virtual ~SymbolVisitor();
};
-
+
} // end clang namespace
namespace llvm {
diff --git a/include/clang/Analysis/PathSensitive/ValueManager.h b/include/clang/Analysis/PathSensitive/ValueManager.h
index 8aa7a7711b..0d9c5f7811 100644
--- a/include/clang/Analysis/PathSensitive/ValueManager.h
+++ b/include/clang/Analysis/PathSensitive/ValueManager.h
@@ -25,15 +25,15 @@
namespace llvm { class BumpPtrAllocator; }
-namespace clang {
+namespace clang {
class GRStateManager;
-
+
class ValueManager {
- ASTContext &Context;
+ ASTContext &Context;
BasicValueFactory BasicVals;
-
+
/// SymMgr - Object that manages the symbol information.
SymbolManager SymMgr;
@@ -41,12 +41,12 @@ class ValueManager {
llvm::OwningPtr<SValuator> SVator;
MemRegionManager MemMgr;
-
+
GRStateManager &StateMgr;
-
+
const QualType ArrayIndexTy;
const unsigned ArrayIndexWidth;
-
+
public:
ValueManager(llvm::BumpPtrAllocator &alloc, ASTContext &context,
GRStateManager &stateMgr)
@@ -54,40 +54,39 @@ public:
SymMgr(context, BasicVals, alloc),
MemMgr(context, alloc), StateMgr(stateMgr),
ArrayIndexTy(context.IntTy),
- ArrayIndexWidth(context.getTypeSize(ArrayIndexTy))
- {
+ ArrayIndexWidth(context.getTypeSize(ArrayIndexTy)) {
// FIXME: Generalize later.
SVator.reset(clang::CreateSimpleSValuator(*this));
}
// Accessors to submanagers.
-
+
ASTContext &getContext() { return Context; }
const ASTContext &getContext() const { return Context; }
-
+
GRStateManager &getStateManager() { return StateMgr; }
-
+
BasicValueFactory &getBasicValueFactory() { return BasicVals; }
const BasicValueFactory &getBasicValueFactory() const { return BasicVals; }
-
+
SymbolManager &getSymbolManager() { return SymMgr; }
const SymbolManager &getSymbolManager() const { return SymMgr; }
-
+
SValuator &getSValuator() { return *SVator.get(); }
MemRegionManager &getRegionManager() { return MemMgr; }
const MemRegionManager &getRegionManager() const { return MemMgr; }
-
+
// Forwarding methods to SymbolManager.
-
+
const SymbolConjured* getConjuredSymbol(const Stmt* E, QualType T,
unsigned VisitCount,
const void* SymbolTag = 0) {
return SymMgr.getConjuredSymbol(E, T, VisitCount, SymbolTag);
}
-
+
const SymbolConjured* getConjuredSymbol(const Expr* E, unsigned VisitCount,
- const void* SymbolTag = 0) {
+ const void* SymbolTag = 0) {
return SymMgr.getConjuredSymbol(E, VisitCount, SymbolTag);
}
@@ -96,24 +95,24 @@ public:
/// getRegionValueSymbolVal - make a unique symbol for value of R.
SVal getRegionValueSymbolVal(const MemRegion *R, QualType T = QualType());
-
+
SVal getRegionValueSymbolValOrUnknown(const MemRegion *R, QualType T) {
- return SymMgr.canSymbolicate(T) ? getRegionValueSymbolVal(R, T)
- : UnknownVal();
+ return SymMgr.canSymbolicate(T) ? getRegionValueSymbolVal(R, T)
+ : UnknownVal();
}
-
- SVal getConjuredSymbolVal(const Expr *E, unsigned Count);
+
+ SVal getConjuredSymbolVal(const Expr *E, unsigned Count);
SVal getConjuredSymbolVal(const Expr* E, QualType T, unsigned Count);
SVal getDerivedRegionValueSymbolVal(SymbolRef parentSymbol,
const TypedRegion *R);
-
+
SVal getFunctionPointer(const FunctionDecl* FD);
NonLoc makeCompoundVal(QualType T, llvm::ImmutableList<SVal> Vals) {
return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals));
}
-
+
NonLoc makeLazyCompoundVal(const GRState *state, const TypedRegion *R) {
return nonloc::LazyCompoundVal(BasicVals.getLazyCompoundValData(state, R));
}
@@ -121,11 +120,11 @@ public:
NonLoc makeZeroArrayIndex() {
return nonloc::ConcreteInt(BasicVals.getValue(0, ArrayIndexTy));
}
-
+
NonLoc makeArrayIndex(uint64_t idx) {
return nonloc::ConcreteInt(BasicVals.getValue(idx, ArrayIndexTy));
}
-
+
SVal convertToArrayIndex(SVal V);
nonloc::ConcreteInt makeIntVal(const IntegerLiteral* I) {
@@ -136,7 +135,7 @@ public:
nonloc::ConcreteInt makeIntVal(const llvm::APSInt& V) {
return nonloc::ConcreteInt(BasicVals.getValue(V));
}
-
+
loc::ConcreteInt makeIntLocVal(const llvm::APSInt &v) {
return loc::ConcreteInt(BasicVals.getValue(v));
}
@@ -170,10 +169,10 @@ public:
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
const llvm::APSInt& rhs, QualType T);
-
+
NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
const SymExpr *rhs, QualType T);
-
+
NonLoc makeTruthVal(bool b, QualType T) {
return nonloc::ConcreteInt(BasicVals.getTruthValue(b, T));
}
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h
index f2ff998fd8..666e45b847 100644
--- a/include/clang/Analysis/ProgramPoint.h
+++ b/include/clang/Analysis/ProgramPoint.h
@@ -26,7 +26,7 @@
namespace clang {
class LocationContext;
-
+
class ProgramPoint {
public:
enum Kind { BlockEdgeKind,
@@ -55,12 +55,12 @@ private:
// context insensitive analysis.
const LocationContext *L;
const void *Tag;
-
+
protected:
- ProgramPoint(const void* P, Kind k, const LocationContext *l,
+ ProgramPoint(const void* P, Kind k, const LocationContext *l,
const void *tag = 0)
: Data(P, NULL), K(k), L(l), Tag(tag) {}
-
+
ProgramPoint(const void* P1, const void* P2, Kind k, const LocationContext *l,
const void *tag = 0)
: Data(P1, P2), K(k), L(l), Tag(tag) {}
@@ -69,8 +69,8 @@ protected:
const void* getData1() const { return Data.first; }
const void* getData2() const { return Data.second; }
const void *getTag() const { return Tag; }
-
-public:
+
+public:
Kind getKind() const { return K; }
const LocationContext *getLocationContext() const { return L; }
@@ -81,7 +81,7 @@ public:
Profile(ID);
return ID.ComputeHash();
}
-
+
static bool classof(const ProgramPoint*) { return true; }
bool operator==(const ProgramPoint & RHS) const {
@@ -91,7 +91,7 @@ public:
bool operator!=(const ProgramPoint& RHS) const {
return K != RHS.K || Data != RHS.Data || L != RHS.L || Tag != RHS.Tag;
}
-
+
void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned) K);
ID.AddPointer(Data.first);
@@ -100,17 +100,17 @@ public:
ID.AddPointer(Tag);
}
};
-
+
class BlockEntrance : public ProgramPoint {
public:
- BlockEntrance(const CFGBlock* B, const LocationContext *L,
+ BlockEntrance(const CFGBlock* B, const LocationContext *L,
const void *tag = 0)
: ProgramPoint(B, BlockEntranceKind, L, tag) {}
-
+
CFGBlock* getBlock() const {
return const_cast<CFGBlock*>(reinterpret_cast<const CFGBlock*>(getData1()));
}
-
+
Stmt* getFirstStmt() const {
const CFGBlock* B = getBlock();
return B->empty() ? NULL : B->front();
@@ -123,9 +123,9 @@ public:
class BlockExit : public ProgramPoint {
public:
- BlockExit(const CFGBlock* B, const LocationContext *L)
+ BlockExit(const CFGBlock* B, const LocationContext *L)
: ProgramPoint(B, BlockExitKind, L) {}
-
+
CFGBlock* getBlock() const {
return const_cast<CFGBlock*>(reinterpret_cast<const CFGBlock*>(getData1()));
}
@@ -134,41 +134,41 @@ public:
const CFGBlock* B = getBlock();
return B->empty() ? NULL : B->back();
}
-
+
Stmt* getTerminator() const {
return getBlock()->getTerminator();
}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == BlockExitKind;
}
};
-
+
class StmtPoint : public ProgramPoint {
public:
- StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L,
+ StmtPoint(const Stmt *S, const void *p2, Kind k, const LocationContext *L,
const void *tag)
: ProgramPoint(S, p2, k, L, tag) {}
-
+
const Stmt *getStmt() const { return (const Stmt*) getData1(); }
-
+
template <typename T>
const T* getStmtAs() const { return llvm::dyn_cast<T>(getStmt()); }
-
+
static bool classof(const ProgramPoint* Location) {
unsigned k = Location->getKind();
return k >= PreStmtKind && k <= MaxPostStmtKind;
}
-};
+};
+
-
class PreStmt : public StmtPoint {
public:
- PreStmt(const Stmt *S, const LocationContext *L, const void *tag,
+ PreStmt(const Stmt *S, const LocationContext *L, const void *tag,
const Stmt *SubStmt = 0)
: StmtPoint(S, SubStmt, PreStmtKind, L, tag) {}
- const Stmt *getSubStmt() const { return (const Stmt*) getData2(); }
+ const Stmt *getSubStmt() const { return (const Stmt*) getData2(); }
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PreStmtKind;
@@ -183,7 +183,7 @@ protected:
PostStmt(const Stmt* S, const void* data, Kind k, const LocationContext *L,
const void *tag =0)
: StmtPoint(S, data, k, L, tag) {}
-
+
public:
explicit PostStmt(const Stmt* S, const LocationContext *L,const void *tag = 0)
: StmtPoint(S, NULL, PostStmtKind, L, tag) {}
@@ -196,15 +196,15 @@ public:
class PostLocationChecksSucceed : public PostStmt {
public:
- PostLocationChecksSucceed(const Stmt* S, const LocationContext *L,
+ PostLocationChecksSucceed(const Stmt* S, const LocationContext *L,
const void *tag = 0)
: PostStmt(S, PostLocationChecksSucceedKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostLocationChecksSucceedKind;
}
};
-
+
class PostStmtCustom : public PostStmt {
public:
PostStmtCustom(const Stmt* S,
@@ -216,22 +216,22 @@ public:
return
*reinterpret_cast<const std::pair<const void*, const void*>*>(getData2());
}
-
+
const void* getTag() const { return getTaggedPair().first; }
-
+
const void* getTaggedData() const { return getTaggedPair().second; }
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostStmtCustomKind;
}
};
-
+
class PostOutOfBoundsCheckFailed : public PostStmt {
public:
- PostOutOfBoundsCheckFailed(const Stmt* S, const LocationContext *L,
+ PostOutOfBoundsCheckFailed(const Stmt* S, const LocationContext *L,
const void *tag = 0)
: PostStmt(S, PostOutOfBoundsCheckFailedKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostOutOfBoundsCheckFailedKind;
}
@@ -242,38 +242,38 @@ public:
PostUndefLocationCheckFailed(const Stmt* S, const LocationContext *L,
const void *tag = 0)
: PostStmt(S, PostUndefLocationCheckFailedKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostUndefLocationCheckFailedKind;
}
};
-
+
class PostNullCheckFailed : public PostStmt {
public:
PostNullCheckFailed(const Stmt* S, const LocationContext *L,
const void *tag = 0)
: PostStmt(S, PostNullCheckFailedKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostNullCheckFailedKind;
}
};
-
+
class PostLoad : public PostStmt {
public:
PostLoad(const Stmt* S, const LocationContext *L, const void *tag = 0)
: PostStmt(S, PostLoadKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostLoadKind;
}
};
-
+
class PostStore : public PostStmt {
public:
PostStore(const Stmt* S, const LocationContext *L, const void *tag = 0)
: PostStmt(S, PostStoreKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostStoreKind;
}
@@ -283,52 +283,52 @@ class PostLValue : public PostStmt {
public:
PostLValue(const Stmt* S, const LocationContext *L, const void *tag = 0)
: PostStmt(S, PostLValueKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostLValueKind;
}
-};
-
+};
+
class PostPurgeDeadSymbols : public PostStmt {
public:
- PostPurgeDeadSymbols(const Stmt* S, const LocationContext *L,
+ PostPurgeDeadSymbols(const Stmt* S, const LocationContext *L,
const void *tag = 0)
: PostStmt(S, PostPurgeDeadSymbolsKind, L, tag) {}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PostPurgeDeadSymbolsKind;
}
};
-
+
class BlockEdge : public ProgramPoint {
public:
BlockEdge(const CFGBlock* B1, const CFGBlock* B2, const LocationContext *L)
: ProgramPoint(B1, B2, BlockEdgeKind, L) {}
-
+
CFGBlock* getSrc() const {
return const_cast<CFGBlock*>(static_cast<const CFGBlock*>(getData1()));
}
-
+
CFGBlock* getDst() const {
return const_cast<CFGBlock*>(static_cast<const CFGBlock*>(getData2()));
}
-
+
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == BlockEdgeKind;
}
};
-
+
} // end namespace clang
-namespace llvm { // Traits specialization for DenseMap
-
+namespace llvm { // Traits specialization for DenseMap
+
template <> struct DenseMapInfo<clang::ProgramPoint> {
static inline clang::ProgramPoint getEmptyKey() {
uintptr_t x =
- reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
+ reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
return clang::BlockEntrance(reinterpret_cast<clang::CFGBlock*>(x), 0);
}
diff --git a/include/clang/Analysis/Support/BlkExprDeclBitVector.h b/include/clang/Analysis/Support/BlkExprDeclBitVector.h
index 7944c8e682..27ecc66e66 100644
--- a/include/clang/Analysis/Support/BlkExprDeclBitVector.h
+++ b/include/clang/Analysis/Support/BlkExprDeclBitVector.h
@@ -23,18 +23,18 @@
#include "llvm/ADT/DenseMap.h"
namespace clang {
-
+
class Stmt;
class ASTContext;
struct DeclBitVector_Types {
-
+
class Idx {
unsigned I;
public:
explicit Idx(unsigned i) : I(i) {}
Idx() : I(~0U) {}
-
+
bool isValid() const {
return I != ~0U;
}
@@ -42,35 +42,35 @@ struct DeclBitVector_Types {
assert (isValid());
return I;
}
- };
-
+ };
+
//===--------------------------------------------------------------------===//
// AnalysisDataTy - Whole-function meta data.
//===--------------------------------------------------------------------===//
-
+
class AnalysisDataTy {
public:
typedef llvm::DenseMap<const NamedDecl*, unsigned > DMapTy;
typedef DMapTy::const_iterator decl_iterator;
-
+
protected:
- DMapTy DMap;
+ DMapTy DMap;
unsigned NDecls;
-
+
public:
-
+
AnalysisDataTy() : NDecls(0) {}
virtual ~AnalysisDataTy() {}
-
+
bool isTracked(const NamedDecl* SD) { return DMap.find(SD) != DMap.end(); }
-
+
Idx getIdx(const NamedDecl* SD) const {
DMapTy::const_iterator I = DMap.find(SD);
return I == DMap.end() ? Idx() : Idx(I->second);
}
unsigned getNumDecls() const { return NDecls; }
-
+
void Register(const NamedDecl* SD) {
if (!isTracked(SD)) DMap[SD] = NDecls++;
}
@@ -78,44 +78,44 @@ struct DeclBitVector_Types {
decl_iterator begin_decl() const { return DMap.begin(); }
decl_iterator end_decl() const { return DMap.end(); }
};
-
+
//===--------------------------------------------------------------------===//
// ValTy - Dataflow value.
//===--------------------------------------------------------------------===//
-
+
class ValTy {
llvm::BitVector DeclBV;
public:
-
+
void resetDeclValues(AnalysisDataTy& AD) {
- DeclBV.resize(AD.getNumDecls());
+ DeclBV.resize(AD.getNumDecls());
DeclBV.reset();
}
void setDeclValues(AnalysisDataTy& AD) {
- DeclBV.resize(AD.getNumDecls());
+ DeclBV.resize(AD.getNumDecls());
DeclBV.set();
}
-
+
void resetValues(AnalysisDataTy& AD) {
resetDeclValues(AD);
- }
-
- bool operator==(const ValTy& RHS) const {
+ }
+
+ bool operator==(const ValTy& RHS) const {
assert (sizesEqual(RHS));
return DeclBV == RHS.DeclBV;
}
-
+
void copyValues(const ValTy& RHS) { DeclBV = RHS.DeclBV; }
-
+
llvm::BitVector::reference getBit(unsigned i) {
return DeclBV[i];
}
-
+
bool getBit(unsigned i) const {
return DeclBV[i];
}
-
+
llvm::BitVector::reference
operator()(const NamedDecl* ND, const AnalysisDataTy& AD) {
return getBit(AD.getIdx(ND));
@@ -124,48 +124,48 @@ struct DeclBitVector_Types {
bool operator()(const NamedDecl* ND, const AnalysisDataTy& AD) const {
return getBit(AD.getIdx(ND));
}
-
- llvm::BitVector::reference getDeclBit(unsigned i) { return DeclBV[i]; }
+
+ llvm::BitVector::reference getDeclBit(unsigned i) { return DeclBV[i]; }
const llvm::BitVector::reference getDeclBit(unsigned i) const {
return const_cast<llvm::BitVector&>(DeclBV)[i];
}
-
+
ValTy& operator|=(const ValTy& RHS) {
assert (sizesEqual(RHS));
DeclBV |= RHS.DeclBV;
return *this;
}
-
+
ValTy& operator&=(const ValTy& RHS) {
assert (sizesEqual(RHS));
DeclBV &= RHS.DeclBV;
return *this;
}
-
+
ValTy& OrDeclBits(const ValTy& RHS) {
return operator|=(RHS);
}
-
+
ValTy& AndDeclBits(const ValTy& RHS) {
return operator&=(RHS);
}
-
+
bool sizesEqual(const ValTy& RHS) const {
return DeclBV.size() == RHS.DeclBV.size();
}
};
-
+
//===--------------------------------------------------------------------===//
// Some useful merge operations.
//===--------------------------------------------------------------------===//
-
+
struct Union { void operator()(ValTy& Dst, ValTy& Src) { Dst |= Src; } };
struct Intersect { void operator()(ValTy& Dst, ValTy& Src) { Dst &= Src; } };
};
struct StmtDeclBitVector_Types {
-
+
//===--------------------------------------------------------------------===//
// AnalysisDataTy - Whole-function meta data.
//===--------------------------------------------------------------------===//
@@ -179,13 +179,13 @@ struct StmtDeclBitVector_Types {
void setContext(ASTContext& c) { ctx = &c; }
ASTContext& getContext() {
- assert(ctx && "ASTContext should not be NULL.");
+ assert(ctx && "ASTContext should not be NULL.");
return *ctx;
}
void setCFG(CFG& c) { cfg = &c; }
CFG& getCFG() { assert(cfg && "CFG should not be NULL."); return *cfg; }
-
+
bool isTracked(const Stmt* S) { return cfg->isBlkExpr(S); }
using DeclBitVector_Types::AnalysisDataTy::isTracked;
@@ -195,7 +195,7 @@ struct StmtDeclBitVector_Types {
return I;
}
using DeclBitVector_Types::AnalysisDataTy::getIdx;
-
+
unsigned getNumBlkExprs() const { return cfg->getNumBlkExprs(); }
};
@@ -206,101 +206,101 @@ struct StmtDeclBitVector_Types {
class ValTy : public DeclBitVector_Types::ValTy {
llvm::BitVector BlkExprBV;
typedef DeclBitVector_Types::ValTy ParentTy;
-
+
static inline ParentTy& ParentRef(ValTy& X) {
return static_cast<ParentTy&>(X);
}
-
+
static inline const ParentTy& ParentRef(const ValTy& X) {
return static_cast<const ParentTy&>(X);
}
-
+
public:
void resetBlkExprValues(AnalysisDataTy& AD) {
BlkExprBV.resize(AD.getNumBlkExprs());
BlkExprBV.reset();
}
-
+
void setBlkExprValues(AnalysisDataTy& AD) {
BlkExprBV.resize(AD.getNumBlkExprs());
BlkExprBV.set();
}
-
+
void resetValues(AnalysisDataTy& AD) {
resetDeclValues(AD);
resetBlkExprValues(AD);
}
-
+
void setValues(AnalysisDataTy& AD) {
setDeclValues(AD);
setBlkExprValues(AD);
}
-
- bool operator==(const ValTy& RHS) const {
- return ParentRef(*this) == ParentRef(RHS)
+
+ bool operator==(const ValTy& RHS) const {
+ return ParentRef(*this) == ParentRef(RHS)
&& BlkExprBV == RHS.BlkExprBV;
}
-
+
void copyValues(const ValTy& RHS) {
ParentRef(*this).copyValues(ParentRef(RHS));
BlkExprBV = RHS.BlkExprBV;
}
-
+
llvm::BitVector::reference
operator()(const Stmt* S, const AnalysisDataTy& AD) {
- return BlkExprBV[AD.getIdx(S)];
- }
+ return BlkExprBV[AD.getIdx(S)];
+ }
const llvm::BitVector::reference
operator()(const Stmt* S, const AnalysisDataTy& AD) const {
return const_cast<ValTy&>(*this)(S,AD);
}
-
+
using DeclBitVector_Types::ValTy::operator();
-
- llvm::BitVector::reference getStmtBit(unsigned i) { return BlkExprBV[i]; }
+
+ llvm::BitVector::reference getStmtBit(unsigned i) { return BlkExprBV[i]; }
const llvm::BitVector::reference getStmtBit(unsigned i) const {
return const_cast<llvm::BitVector&>(BlkExprBV)[i];
}
-
+
ValTy& OrBlkExprBits(const ValTy& RHS) {
BlkExprBV |= RHS.BlkExprBV;
return *this;
}
-
+
ValTy& AndBlkExprBits(const ValTy& RHS) {
BlkExprBV &= RHS.BlkExprBV;
return *this;
}
-
+
ValTy& operator|=(const ValTy& RHS) {
assert (sizesEqual(RHS));
ParentRef(*this) |= ParentRef(RHS);
BlkExprBV |= RHS.BlkExprBV;
return *this;
}
-
+
ValTy& operator&=(const ValTy& RHS) {
assert (sizesEqual(RHS));
ParentRef(*this) &= ParentRef(RHS);
BlkExprBV &= RHS.BlkExprBV;
return *this;
}
-
+
bool sizesEqual(const ValTy& RHS) const {
return ParentRef(*this).sizesEqual(ParentRef(RHS))
&& BlkExprBV.size() == RHS.BlkExprBV.size();
}
};
-
+
//===--------------------------------------------------------------------===//
// Some useful merge operations.
//===--------------------------------------------------------------------===//
-
+
struct Union { void operator()(ValTy& Dst, ValTy& Src) { Dst |= Src; } };
struct Intersect { void operator()(ValTy& Dst, ValTy& Src) { Dst &= Src; } };
-
+
};
} // end namespace clang
diff --git a/include/clang/Analysis/Support/Optional.h b/include/clang/Analysis/Support/Optional.h
index 5fb5078f76..3940007bb5 100644
--- a/include/clang/Analysis/Support/Optional.h
+++ b/include/clang/Analysis/Support/Optional.h
@@ -17,7 +17,7 @@
#define LLVM_CLANG_ANALYSIS_OPTIONAL
namespace clang {
-
+
template<typename T>
class Optional {
const T x;
@@ -25,15 +25,15 @@ class Optional {
public:
explicit Optional() : hasVal(false) {}
Optional(const T &y) : x(y), hasVal(true) {}
-
+
static inline Optional create(const T* y) {
return y ? Optional(*y) : Optional();
}
-
+
const T* getPointer() const { assert(hasVal); return &x; }
-
+
operator bool() const { return hasVal; }
- const T* operator->() const { return getPointer(); }
+ const T* operator->() const { return getPointer(); }
const T& operator*() const { assert(hasVal); return x; }
};
} //end clang namespace
@@ -46,7 +46,7 @@ struct simplify_type<const ::clang::Optional<T> > {
return Val.getPointer();
}
};
-
+
template <typename T>
struct simplify_type< ::clang::Optional<T> >
: public simplify_type<const ::clang::Optional<T> > {};
diff --git a/include/clang/Analysis/Support/SaveAndRestore.h b/include/clang/Analysis/Support/SaveAndRestore.h
index f597fcba57..4720c22d99 100644
--- a/include/clang/Analysis/Support/SaveAndRestore.h
+++ b/include/clang/Analysis/Support/SaveAndRestore.h
@@ -16,7 +16,7 @@
#define LLVM_CLANG_ANALYSIS_SAVERESTORE
namespace clang {
-
+
// SaveAndRestore - A utility class that uses RAII to save and restore
// the value of a variable.
template<typename T>
@@ -24,7 +24,7 @@ struct SaveAndRestore {
SaveAndRestore(T& x) : X(x), old_value(x) {}
~SaveAndRestore() { X = old_value; }
T get() { return old_value; }
-private:
+private:
T& X;
T old_value;
};
@@ -39,6 +39,6 @@ private:
bool& X;
const bool old_value;
};
-
+
}
#endif
diff --git a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
index ee79c51703..3826d3a3ac 100644
--- a/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
@@ -30,28 +30,28 @@ break;
#define DEFAULT_DISPATCH_VARDECL(CLASS) void Visit##CLASS(CLASS* D)\
{ static_cast<ImplClass*>(this)->VisitVarDecl(D); }
-
+
namespace clang {
template <typename ImplClass>
class CFGRecStmtDeclVisitor : public CFGRecStmtVisitor<ImplClass> {
-public:
+public:
void VisitDeclRefExpr(DeclRefExpr* DR) {
- static_cast<ImplClass*>(this)->VisitDecl(DR->getDecl());
+ static_cast<ImplClass*>(this)->VisitDecl(DR->getDecl());
}
-
+
void VisitDeclStmt(DeclStmt* DS) {
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
Decl* D = *DI;
- static_cast<ImplClass*>(this)->VisitDecl(D);
+ static_cast<ImplClass*>(this)->VisitDecl(D);
// Visit the initializer.
if (VarDecl* VD = dyn_cast<VarDecl>(D))
if (Expr* I = VD->getInit())
static_cast<ImplClass*>(this)->Visit(I);
}
}
-
+
void VisitDecl(Decl* D) {
switch (D->getKind()) {
DISPATCH_CASE(Function,FunctionDecl)
@@ -67,7 +67,7 @@ public:
assert(false && "Subtype of ScopedDecl not handled.");
}
}
-
+
DEFAULT_DISPATCH(VarDecl)
DEFAULT_DISPATCH(FunctionDecl)
DEFAULT_DISPATCH_VARDECL(OriginalParmVarDecl)
diff --git a/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h b/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
index 4d32019622..83700a3a34 100644
--- a/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
@@ -20,12 +20,12 @@
namespace clang {
template <typename ImplClass>
class CFGRecStmtVisitor : public CFGStmtVisitor<ImplClass,void> {
-public:
+public:
void VisitStmt(Stmt* S) {
static_cast< ImplClass* >(this)->VisitChildren(S);
}
-
+
// Defining operator() allows the visitor to be used as a C++ style functor.
void operator()(Stmt* S) { static_cast<ImplClass*>(this)->BlockStmt_Visit(S);}
};
diff --git a/include/clang/Analysis/Visitors/CFGStmtVisitor.h b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
index 7456831a6a..426b9ccd8a 100644
--- a/include/clang/Analysis/Visitors/CFGStmtVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the CFGStmtVisitor interface, which extends
+// This file defines the CFGStmtVisitor interface, which extends
// StmtVisitor. This interface is useful for visiting statements in a CFG
// where some statements have implicit control-flow and thus should
// be treated specially.
@@ -24,7 +24,7 @@ namespace clang {
#define DISPATCH_CASE(CLASS) \
case Stmt::CLASS ## Class: return \
-static_cast<ImplClass*>(this)->BlockStmt_Visit ## CLASS(static_cast<CLASS*>(S));
+static_cast<ImplClass*>(this)->BlockStmt_Visit ## CLASS(static_cast<CLASS*>(S));
#define DEFAULT_BLOCKSTMT_VISIT(CLASS) RetTy BlockStmt_Visit ## CLASS(CLASS *S)\
{ return\
@@ -36,40 +36,40 @@ class CFGStmtVisitor : public StmtVisitor<ImplClass,RetTy> {
Stmt* CurrentBlkStmt;
struct NullifyStmt {
- Stmt*& S;
-
+ Stmt*& S;
+
NullifyStmt(Stmt*& s) : S(s) {}
~NullifyStmt() { S = NULL; }
};
-
+
public:
- CFGStmtVisitor() : CurrentBlkStmt(NULL) {}
-
+ CFGStmtVisitor() : CurrentBlkStmt(NULL) {}
+
Stmt* getCurrentBlkStmt() const { return CurrentBlkStmt; }
-
+
RetTy Visit(Stmt* S) {
- if (S == CurrentBlkStmt ||
+ if (S == CurrentBlkStmt ||
!static_cast<ImplClass*>(this)->getCFG().isBlkExpr(S))
return StmtVisitor<ImplClass,RetTy>::Visit(S);
else
return RetTy();
}
-
+
/// BlockVisit_XXX - Visitor methods for visiting the "root" statements in
- /// CFGBlocks. Root statements are the statements that appear explicitly in
+ /// CFGBlocks. Root statements are the statements that appear explicitly in
/// the list of statements in a CFGBlock. For substatements, or when there
/// is no implementation provided for a BlockStmt_XXX method, we default
/// to using StmtVisitor's Visit method.
RetTy BlockStmt_Visit(Stmt* S) {
CurrentBlkStmt = S;
NullifyStmt cleanup(CurrentBlkStmt);
-
+
switch (S->getStmtClass()) {
DISPATCH_CASE(StmtExpr)
DISPATCH_CASE(ConditionalOperator)
DISPATCH_CASE(ObjCForCollectionStmt)
-
+
case Stmt::BinaryOperatorClass: {
BinaryOperator* B = cast<BinaryOperator>(S);
if (B->isLogicalOp())
@@ -78,40 +78,40 @@ public:
return static_cast<ImplClass*>(this)->BlockStmt_VisitComma(B);
// Fall through.
}
-
+
default:
if (isa<Expr>(S))
- return
+ return
static_cast<ImplClass*>(this)->BlockStmt_VisitExpr(cast<Expr>(S));
else
- return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(S);
+ return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(S);
}
}
DEFAULT_BLOCKSTMT_VISIT(StmtExpr)
DEFAULT_BLOCKSTMT_VISIT(ConditionalOperator)
-
+
RetTy BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(S);
}
-
+
RetTy BlockStmt_VisitImplicitControlFlowExpr(Expr* E) {
return static_cast<ImplClass*>(this)->BlockStmt_VisitExpr(E);
}
-
+
RetTy BlockStmt_VisitExpr(Expr* E) {
return static_cast<ImplClass*>(this)->BlockStmt_VisitStmt(E);
}
-
+
RetTy BlockStmt_VisitStmt(Stmt* S) {
return static_cast<ImplClass*>(this)->Visit(S);
}
RetTy BlockStmt_VisitLogicalOp(BinaryOperator* B) {
- return
+ return
static_cast<ImplClass*>(this)->BlockStmt_VisitImplicitControlFlowExpr(B);
}
-
+
RetTy BlockStmt_VisitComma(BinaryOperator* B) {
return
static_cast<ImplClass*>(this)->BlockStmt_VisitImplicitControlFlowExpr(B);
@@ -120,21 +120,21 @@ public:
//===--------------------------------------------------------------------===//
// Utility methods. Not called by default (but subclasses may use them).
//===--------------------------------------------------------------------===//
-
+
/// VisitChildren: Call "Visit" on each child of S.
void VisitChildren(Stmt* S) {
-
+
switch (S->getStmtClass()) {
default:
break;
-
+
case Stmt::StmtExprClass: {
CompoundStmt* CS = cast<StmtExpr>(S)->getSubStmt();
if (CS->body_empty()) return;
static_cast<ImplClass*>(this)->Visit(CS->body_back());
return;
}
-
+
case Stmt::BinaryOperatorClass: {
BinaryOperator* B = cast<BinaryOperator>(S);
if (B->getOpcode() != BinaryOperator::Comma) break;
@@ -142,12 +142,12 @@ public:
return;
}
}
-
+
for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I)
- if (*I) static_cast<ImplClass*>(this)->Visit(*I);
+ if (*I) static_cast<ImplClass*>(this)->Visit(*I);
}
-};
-
+};
+
#undef DEFAULT_BLOCKSTMT_VISIT
#undef DISPATCH_CASE
diff --git a/include/clang/Analysis/Visitors/CFGVarDeclVisitor.h b/include/clang/Analysis/Visitors/CFGVarDeclVisitor.h
index 8c5cf0b0b6..1bc798f4e7 100644
--- a/include/clang/Analysis/Visitors/CFGVarDeclVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGVarDeclVisitor.h
@@ -24,37 +24,37 @@ namespace clang {
template <typename ImplClass>
class CFGVarDeclVisitor : public CFGStmtVisitor<ImplClass> {
const CFG& cfg;
-public:
+public:
CFGVarDeclVisitor(const CFG& c) : cfg(c) {}
-
+
void VisitStmt(Stmt* S) {
static_cast<ImplClass*>(this)->VisitChildren(S);
}
-
+
void VisitDeclRefExpr(DeclRefExpr* DR) {
static_cast<ImplClass*>(this)->VisitDeclChain(DR->getDecl());
}
-
+
void VisitDeclStmt(DeclStmt* DS) {
static_cast<ImplClass*>(this)->VisitDeclChain(DS->getDecl());
}
-
- void VisitDeclChain(ScopedDecl* D) {
+
+ void VisitDeclChain(ScopedDecl* D) {
for (; D != NULL ; D = D->getNextDeclarator())
static_cast<ImplClass*>(this)->VisitScopedDecl(D);
}
-
+
void VisitScopedDecl(ScopedDecl* D) {
if (VarDecl* V = dyn_cast<VarDecl>(D))
static_cast<ImplClass*>(this)->VisitVarDecl(V);
}
-
+
void VisitVarDecl(VarDecl* D) {}
-
+
void VisitAllDecls() {
for (CFG::const_iterator BI = cfg.begin(), BE = cfg.end(); BI != BE; ++BI)
for (CFGBlock::const_iterator SI=BI->begin(),SE = BI->end();SI != SE;++SI)
- static_cast<ImplClass*>(this)->BlockStmt_Visit(const_cast<Stmt*>(*SI));
+ static_cast<ImplClass*>(this)->BlockStmt_Visit(const_cast<Stmt*>(*SI));
}
};
diff --git a/include/clang/Basic/Builtins.h b/include/clang/Basic/Builtins.h
index cd05bccfb4..07f091a58a 100644
--- a/include/clang/Basic/Builtins.h
+++ b/include/clang/Basic/Builtins.h
@@ -67,40 +67,40 @@ public:
/// \brief Popular the vector with the names of all of the builtins.
void GetBuiltinNames(llvm::SmallVectorImpl<const char *> &Names,
bool NoBuiltins);
-
+
/// Builtin::GetName - Return the identifier name for the specified builtin,
/// e.g. "__builtin_abs".
const char *GetName(unsigned ID) const {
return GetRecord(ID).Name;
}
-
+
/// GetTypeString - Get the type descriptor string for the specified builtin.
const char *GetTypeString(unsigned ID) const {
return GetRecord(ID).Type;
}
-
+
/// isConst - Return true if this function has no side effects and doesn't
/// read memory.
bool isConst(unsigned ID) const {
return strchr(GetRecord(ID).Attributes, 'c') != 0;
}
-
+
/// isNoThrow - Return true if we know this builtin never throws an exception.
bool isNoThrow(unsigned ID) const {
return strchr(GetRecord(ID).Attributes, 'n') != 0;
}
-
+
/// isNoReturn - Return true if we know this builtin never returns.
bool isNoReturn(unsigned ID) const {
return strchr(GetRecord(ID).Attributes, 'r') != 0;
}
-
+
/// isLibFunction - Return true if this is a builtin for a libc/libm function,
/// with a "__builtin_" prefix (e.g. __builtin_abs).
bool isLibFunction(unsigned ID) const {
return strchr(GetRecord(ID).Attributes, 'F') != 0;
}
-
+
/// \brief Determines whether this builtin is a predefined libc/libm
/// function, such as "malloc", where we know the signature a
/// priori.
@@ -124,7 +124,7 @@ public:
bool hasVAListUse(unsigned ID) const {
return strpbrk(GetRecord(ID).Type, "Aa") != 0;
}
-
+
/// isConstWithoutErrno - Return true if this function has no side
/// effects and doesn't read memory, except for possibly errno. Such
/// functions can be const when the MathErrno lang option is
diff --git a/include/clang/Basic/ConvertUTF.h b/include/clang/Basic/ConvertUTF.h
index 823a7030c2..4da2ad7572 100644
--- a/include/clang/Basic/ConvertUTF.h
+++ b/include/clang/Basic/ConvertUTF.h
@@ -8,9 +8,9 @@
*==------------------------------------------------------------------------==*/
/*
* Copyright 2001-2004 Unicode, Inc.
- *
+ *
* Disclaimer
- *
+ *
* This source code is provided as is by Unicode, Inc. No claims are
* made as to fitness for any particular purpose. No warranties of any
* kind are expressed or implied. The recipient agrees to determine
@@ -18,9 +18,9 @@
* purchased on magnetic or optical media from Unicode, Inc., the
* sole remedy for any claim will be exchange of defective media
* within 90 days of receipt.
- *
+ *
* Limitations on Rights to Redistribute This Code
- *
+ *
* Unicode, Inc. hereby grants the right to freely use the information
* supplied in this file in the creation of products supporting the
* Unicode Standard, and to make copies of this file in any form
@@ -41,7 +41,7 @@
Each routine converts the text between *sourceStart and sourceEnd,
putting the result into the buffer between *targetStart and
- targetEnd. Note: the end pointers are *after* the last item: e.g.
+ targetEnd. Note: the end pointers are *after* the last item: e.g.
*(sourceEnd - 1) is the last item.
The return result indicates whether the conversion was successful,
@@ -79,7 +79,7 @@
sequence is malformed. When "sourceIllegal" is returned, the source
value will point to the illegal value that caused the problem. E.g.,
in UTF-8 when a sequence is malformed, it points to the start of the
- malformed sequence.
+ malformed sequence.
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
@@ -125,28 +125,28 @@ extern "C" {
#endif
ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
+ const UTF8** sourceStart, const UTF8* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
#ifdef CLANG_NEEDS_THESE_ONE_DAY
ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
+ const UTF16** sourceStart, const UTF16* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF8toUTF32 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
+ const UTF8** sourceStart, const UTF8* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF8 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
+ const UTF32** sourceStart, const UTF32* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF16toUTF32 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
+ const UTF16** sourceStart, const UTF16* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
ConversionResult ConvertUTF32toUTF16 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
+ const UTF32** sourceStart, const UTF32* sourceEnd,
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
#endif
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index be52939c18..dc854b1830 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -30,7 +30,7 @@ namespace clang {
class LangOptions;
class PartialDiagnostic;
class SourceRange;
-
+
// Import the diagnostic enums themselves.
namespace diag {
// Start position for diagnostics.
@@ -46,7 +46,7 @@ namespace clang {
};
class CustomDiagInfo;
-
+
/// diag::kind - All of the diagnostics that can be emitted by the frontend.
typedef unsigned kind;
@@ -57,7 +57,7 @@ namespace clang {
NUM_BUILTIN_COMMON_DIAGNOSTICS
#undef DIAG
};
-
+
/// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
/// to either MAP_IGNORE (nothing), MAP_WARNING (emit a warning), MAP_ERROR
/// (emit as an error). It allows clients to map errors to
@@ -69,13 +69,13 @@ namespace clang {
MAP_WARNING = 2, //< Map this diagnostic to a warning.
MAP_ERROR = 3, //< Map this diagnostic to an error.
MAP_FATAL = 4, //< Map this diagnostic to a fatal error.
-
+
/// Map this diagnostic to "warning", but make it immune to -Werror. This
/// happens when you specify -Wno-error=foo.
MAP_WARNING_NO_WERROR = 5
};
}
-
+
/// \brief Annotates a diagnostic with some code that should be
/// inserted, removed, or replaced to fix the problem.
///
@@ -104,7 +104,7 @@ public:
/// \brief Create a code modification hint that inserts the given
/// code string at a specific location.
- static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc,
+ static CodeModificationHint CreateInsertion(SourceLocation InsertionLoc,
const std::string &Code) {
CodeModificationHint Hint;
Hint.InsertionLoc = InsertionLoc;
@@ -122,7 +122,7 @@ public:
/// \brief Create a code modification hint that replaces the given
/// source range with the given code string.
- static CodeModificationHint CreateReplacement(SourceRange RemoveRange,
+ static CodeModificationHint CreateReplacement(SourceRange RemoveRange,
const std::string &Code) {
CodeModificationHint Hint;
Hint.RemoveRange = RemoveRange;
@@ -142,13 +142,13 @@ public:
enum Level {
Ignored, Note, Warning, Error, Fatal
};
-
+
/// ExtensionHandling - How do we handle otherwise-unmapped extension? This
/// is controlled by -pedantic and -pedantic-errors.
enum ExtensionHandling {
Ext_Ignore, Ext_Warn, Ext_Error
};
-
+
enum ArgumentKind {
ak_std_string, // std::string
ak_c_string, // const char *
@@ -161,10 +161,10 @@ public:
ak_nestednamespec // NestedNameSpecifier *
};
-private:
+private:
unsigned char AllExtensionsSilenced; // Used by __extension__
bool IgnoreAllWarnings; // Ignore all warnings: -w
- bool WarningsAsErrors; // Treat warnings like errors:
+ bool WarningsAsErrors; // Treat warnings like errors:
bool SuppressSystemWarnings; // Suppress warnings in system headers.
ExtensionHandling ExtBehavior; // Map extensions onto warnings or errors?
DiagnosticClient *Client;
@@ -183,7 +183,7 @@ private:
/// fatal error is emitted, and is sticky.
bool ErrorOccurred;
bool FatalErrorOccurred;
-
+
/// LastDiagLevel - This is the level of the last diagnostic emitted. This is
/// used to emit continuation diagnostics with the same level as the
/// diagnostic that they follow.
@@ -209,16 +209,16 @@ private:
public:
explicit Diagnostic(DiagnosticClient *client = 0);
~Diagnostic();
-
+
//===--------------------------------------------------------------------===//
// Diagnostic characterization methods, used by a client to customize how
//
-
+
DiagnosticClient *getClient() { return Client; };
const DiagnosticClient *getClient() const { return Client; };
-
- /// pushMappings - Copies the current DiagMappings and pushes the new copy
+
+ /// pushMappings - Copies the current DiagMappings and pushes the new copy
/// onto the top of the stack.
void pushMappings();
@@ -234,12 +234,12 @@ public:
/// ignored. If this and WarningsAsErrors are both set, then this one wins.
void setIgnoreAllWarnings(bool Val) { IgnoreAllWarnings = Val; }
bool getIgnoreAllWarnings() const { return IgnoreAllWarnings; }
-
+
/// setWarningsAsErrors - When set to true, any warnings reported are issued
/// as errors.
void setWarningsAsErrors(bool Val) { WarningsAsErrors = Val; }
bool getWarningsAsErrors() const { return WarningsAsErrors; }
-
+
/// setSuppressSystemWarnings - When set to true mask warnings that
/// come from system headers.
void setSuppressSystemWarnings(bool Val) { SuppressSystemWarnings = Val; }
@@ -251,14 +251,14 @@ public:
void setExtensionHandlingBehavior(ExtensionHandling H) {
ExtBehavior = H;
}
-
+
/// AllExtensionsSilenced - This is a counter bumped when an __extension__
/// block is encountered. When non-zero, all extension diagnostics are
/// entirely silenced, no matter how they are mapped.
void IncrementAllExtensionsSilenced() { ++AllExtensionsSilenced; }
void DecrementAllExtensionsSilenced() { --AllExtensionsSilenced; }
bool hasAllExtensionsSilenced() { return AllExtensionsSilenced != 0; }
-
+
/// setDiagnosticMapping - This allows the client to specify that certain
/// warnings are ignored. Notes can never be mapped, errors can only be
/// mapped to fatal, and WARNINGs and EXTENSIONs can be mapped arbitrarily.
@@ -269,7 +269,7 @@ public:
"Cannot map errors!");
setDiagnosticMappingInternal(Diag, Map, true);
}
-
+
/// setDiagnosticGroupMapping - Change an entire diagnostic group (e.g.
/// "unknown-pragmas" to have the specified mapping. This returns true and
/// ignores the request if "Group" was unknown, false otherwise.
@@ -280,13 +280,13 @@ public:
unsigned getNumErrors() const { return NumErrors; }
unsigned getNumDiagnostics() const { return NumDiagnostics; }
-
+
/// getCustomDiagID - Return an ID for a diagnostic with the specified message
/// and level. If this is the first request for this diagnosic, it is
/// registered and created, otherwise the existing ID is returned.
unsigned getCustomDiagID(Level L, const char *Message);
-
-
+
+
/// ConvertArgToString - This method converts a diagnostic argument (as an
/// intptr_t) into the string that represents it.
void ConvertArgToString(ArgumentKind Kind, intptr_t Val,
@@ -296,12 +296,12 @@ public:
ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, Output,
ArgToStringCookie);
}
-
+
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie) {
ArgToStringFn = Fn;
ArgToStringCookie = Cookie;
}
-
+
//===--------------------------------------------------------------------===//
// Diagnostic classification and reporting interfaces.
//
@@ -309,7 +309,7 @@ public:
/// getDescription - Given a diagnostic ID, return a description of the
/// issue.
const char *getDescription(unsigned DiagID) const;
-
+
/// isNoteWarningOrExtension - Return true if the unmapped diagnostic
/// level of the specified diagnostic ID is a Warning or Extension.
/// This only works on builtin diagnostics, not custom ones, and is not legal to
@@ -319,12 +319,12 @@ public:
/// \brief Determine whether the given built-in diagnostic ID is a
/// Note.
static bool isBuiltinNote(unsigned DiagID);
-
+
/// isBuiltinExtensionDiag - Determine whether the given built-in diagnostic
/// ID is for an extension of some sort.
///
static bool isBuiltinExtensionDiag(unsigned DiagID);
-
+
/// getWarningOptionForDiag - Return the lowest-level warning option that
/// enables the specified diagnostic. If there is no -Wfoo flag that controls
/// the diagnostic, this returns null.
@@ -343,8 +343,8 @@ public:
/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
/// object, classify the specified diagnostic ID into a Level, consumable by
/// the DiagnosticClient.
- Level getDiagnosticLevel(unsigned DiagID) const;
-
+ Level getDiagnosticLevel(unsigned DiagID) const;
+
/// Report - Issue the message to the client. @c DiagID is a member of the
/// @c diag::kind enum. This actually returns aninstance of DiagnosticBuilder
/// which emits the diagnostics (through @c ProcessDiag) when it is destroyed.
@@ -354,7 +354,7 @@ public:
/// \brief Clear out the current diagnostic.
void Clear() { CurDiagID = ~0U; }
-
+
private:
/// getDiagnosticMappingInfo - Return the mapping info currently set for the
/// specified builtin diagnostic. This returns the high bit encoding, or zero
@@ -363,7 +363,7 @@ private:
const DiagMappings &currentMappings = DiagMappingsStack.back();
return (diag::Mapping)((currentMappings[Diag/2] >> (Diag & 1)*4) & 15);
}
-
+
void setDiagnosticMappingInternal(unsigned DiagId, unsigned Map,
bool isUser) const {
if (isUser) Map |= 8; // Set the high bit for user mappings.
@@ -372,7 +372,7 @@ private:
Slot &= ~(15 << Shift);
Slot |= Map << Shift;
}
-
+
/// getDiagnosticLevel - This is an internal implementation helper used when
/// DiagClass is already known.
Level getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const;
@@ -389,7 +389,7 @@ private:
/// CurDiagLoc - This is the location of the current diagnostic that is in
/// flight.
FullSourceLoc CurDiagLoc;
-
+
/// CurDiagID - This is the ID of the current diagnostic that is in flight.
/// This is set to ~0U when there is no diagnostic in flight.
unsigned CurDiagID;
@@ -400,7 +400,7 @@ private:
/// than that almost certainly has to be simplified anyway.
MaxArguments = 10
};
-
+
/// NumDiagArgs - This contains the number of entries in Arguments.
signed char NumDiagArgs;
/// NumRanges - This is the number of ranges in the DiagRanges array.
@@ -413,7 +413,7 @@ private:
/// values, with one for each argument. This specifies whether the argument
/// is in DiagArgumentsStr or in DiagArguments.
unsigned char DiagArgumentsKind[MaxArguments];
-
+
/// DiagArgumentsStr - This holds the values of each string argument for the
/// current diagnostic. This value is only used when the corresponding
/// ArgumentKind is ak_std_string.
@@ -424,11 +424,11 @@ private:
/// mangled into an intptr_t and the intepretation depends on exactly what
/// sort of argument kind it is.
intptr_t DiagArgumentsVal[MaxArguments];
-
+
/// DiagRanges - The list of ranges added to this diagnostic. It currently
/// only support 10 ranges, could easily be extended if needed.
const SourceRange *DiagRanges[10];
-
+
enum { MaxCodeModificationHints = 3 };
/// CodeModificationHints - If valid, provides a hint with some code
@@ -461,14 +461,14 @@ private:
class DiagnosticBuilder {
mutable Diagnostic *DiagObj;
mutable unsigned NumArgs, NumRanges, NumCodeModificationHints;
-
+
void operator=(const DiagnosticBuilder&); // DO NOT IMPLEMENT
friend class Diagnostic;
explicit DiagnosticBuilder(Diagnostic *diagObj)
- : DiagObj(diagObj), NumArgs(0), NumRanges(0),
+ : DiagObj(diagObj), NumArgs(0), NumRanges(0),
NumCodeModificationHints(0) {}
-public:
+public:
/// Copy constructor. When copied, this "takes" the diagnostic info from the
/// input and neuters it.
DiagnosticBuilder(const DiagnosticBuilder &D) {
@@ -485,7 +485,7 @@ public:
/// \brief Create an empty DiagnosticBuilder object that represents
/// no actual diagnostic.
- explicit DiagnosticBuilder(SuppressKind)
+ explicit DiagnosticBuilder(SuppressKind)
: DiagObj(0), NumArgs(0), NumRanges(0), NumCodeModificationHints(0) { }
/// \brief Force the diagnostic builder to emit the diagnostic now.
@@ -522,7 +522,7 @@ public:
/// Destructor - The dtor emits the diagnostic if it hasn't already
/// been emitted.
~DiagnosticBuilder() { Emit(); }
-
+
/// Operator bool: conversion of DiagnosticBuilder to bool always returns
/// true. This allows is to be used in boolean error contexts like:
/// return Diag(...);
@@ -536,7 +536,7 @@ public:
DiagObj->DiagArgumentsStr[NumArgs++] = S;
}
}
-
+
void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const {
assert(NumArgs < Diagnostic::MaxArguments &&
"Too many arguments to diagnostic!");
@@ -545,14 +545,14 @@ public:
DiagObj->DiagArgumentsVal[NumArgs++] = V;
}
}
-
+
void AddSourceRange(const SourceRange &R) const {
- assert(NumRanges <
+ assert(NumRanges <
sizeof(DiagObj->DiagRanges)/sizeof(DiagObj->DiagRanges[0]) &&
"Too many arguments to diagnostic!");
if (DiagObj)
DiagObj->DiagRanges[NumRanges++] = &R;
- }
+ }
void AddCodeModificationHint(const CodeModificationHint &Hint) const {
assert(NumCodeModificationHints < Diagnostic::MaxCodeModificationHints &&
@@ -597,7 +597,7 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
Diagnostic::ak_identifierinfo);
return DB;
}
-
+
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const SourceRange &R) {
DB.AddSourceRange(R);
@@ -623,7 +623,7 @@ inline DiagnosticBuilder Diagnostic::Report(FullSourceLoc Loc, unsigned DiagID){
//===----------------------------------------------------------------------===//
// DiagnosticInfo
//===----------------------------------------------------------------------===//
-
+
/// DiagnosticInfo - This is a little helper class (which is basically a smart
/// pointer that forward info from Diagnostic) that allows clients to enquire
/// about the currently in-flight diagnostic.
@@ -631,74 +631,74 @@ class DiagnosticInfo {
const Diagnostic *DiagObj;
public:
explicit DiagnosticInfo(const Diagnostic *DO) : DiagObj(DO) {}
-
+
const Diagnostic *getDiags() const { return DiagObj; }
unsigned getID() const { return DiagObj->CurDiagID; }
const FullSourceLoc &getLocation() const { return DiagObj->CurDiagLoc; }
-
+
unsigned getNumArgs() const { return DiagObj->NumDiagArgs; }
-
+
/// getArgKind - Return the kind of the specified index. Based on the kind
/// of argument, the accessors below can be used to get the value.
Diagnostic::ArgumentKind getArgKind(unsigned Idx) const {
assert(Idx < getNumArgs() && "Argument index out of range!");
return (Diagnostic::ArgumentKind)DiagObj->DiagArgumentsKind[Idx];
}
-
+
/// getArgStdStr - Return the provided argument string specified by Idx.
const std::string &getArgStdStr(unsigned Idx) const {
assert(getArgKind(Idx) == Diagnostic::ak_std_string &&
"invalid argument accessor!");
return DiagObj->DiagArgumentsStr[Idx];
}
-
+
/// getArgCStr - Return the specified C string argument.
const char *getArgCStr(unsigned Idx) const {
assert(getArgKind(Idx) == Diagnostic::ak_c_string &&
"invalid argument accessor!");
return reinterpret_cast<const char*>(DiagObj->DiagArgumentsVal[Idx]);
}
-
+
/// getArgSInt - Return the specified signed integer argument.
int getArgSInt(unsigned Idx) const {
assert(getArgKind(Idx) == Diagnostic::ak_sint &&
"invalid argument accessor!");
return (int)DiagObj->DiagArgumentsVal[Idx];
}
-
+
/// getArgUInt - Return the specified unsigned integer argument.
unsigned getArgUInt(unsigned Idx) const {
assert(getArgKind(Idx) == Diagnostic::ak_uint &&
"invalid argument accessor!");
return (unsigned)DiagObj->DiagArgumentsVal[Idx];
}
-
+
/// getArgIdentifier - Return the specified IdentifierInfo argument.
const IdentifierInfo *getArgIdentifier(unsigned Idx) const {
assert(getArgKind(Idx) == Diagnostic::ak_identifierinfo &&
"invalid argument accessor!");
return reinterpret_cast<IdentifierInfo*>(DiagObj->DiagArgumentsVal[Idx]);
}
-
+
/// getRawArg - Return the specified non-string argument in an opaque form.
intptr_t getRawArg(unsigned Idx) const {
assert(getArgKind(Idx) != Diagnostic::ak_std_string &&
"invalid argument accessor!");
return DiagObj->DiagArgumentsVal[Idx];
}
-
-
+
+
/// getNumRanges - Return the number of source ranges associated with this
/// diagnostic.
unsigned getNumRanges() const {
return DiagObj->NumDiagRanges;
}
-
+
const SourceRange &getRange(unsigned Idx) const {
assert(Idx < DiagObj->NumDiagRanges && "Invalid diagnostic range index!");
return *DiagObj->DiagRanges[Idx];
}
-
+
unsigned getNumCodeModificationHints() const {
return DiagObj->NumCodeModificationHints;
}
@@ -708,7 +708,7 @@ public:
}
const CodeModificationHint *getCodeModificationHints() const {
- return DiagObj->NumCodeModificationHints?
+ return DiagObj->NumCodeModificationHints?
&DiagObj->CodeModificationHints[0] : 0;
}
@@ -717,20 +717,20 @@ public:
/// array.
void FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const;
};
-
+
/// DiagnosticClient - This is an abstract interface implemented by clients of
/// the front-end, which formats and prints fully processed diagnostics.
class DiagnosticClient {
public:
virtual ~DiagnosticClient();
-
+
/// setLangOptions - This is set by clients of diagnostics when they know the
/// language parameters of the diagnostics that may be sent through. Note
/// that this can change over time if a DiagClient has multiple languages sent
/// through it. It may also be set to null (e.g. when processing command line
/// options).
virtual void setLangOptions(const LangOptions *LO) {}
-
+
/// IncludeInDiagnosticCounts - This method (whose default implementation
/// returns true) indicates whether the diagnostics handled by this
/// DiagnosticClient should be included in the number of diagnostics
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index d684449c85..7c9113c497 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -25,7 +25,7 @@
namespace clang {
class FileManager;
-
+
/// DirectoryEntry - Cached information about one directory on the disk.
///
class DirectoryEntry {
@@ -33,7 +33,7 @@ class DirectoryEntry {
friend class FileManager;
public:
DirectoryEntry() : Name(0) {}
- const char *getName() const { return Name; }
+ const char *getName() const { return Name; }
};
/// FileEntry - Cached information about one file on the disk.
@@ -53,7 +53,7 @@ public:
: Name(0), Device(device), Inode(inode), FileMode(m) {}
// Add a default constructor for use with llvm::StringMap
FileEntry() : Name(0), Device(0), Inode(0), FileMode(0) {}
-
+
const char *getName() const { return Name; }
off_t getSize() const { return Size; }
unsigned getUID() const { return UID; }
@@ -61,11 +61,11 @@ public:
dev_t getDevice() const { return Device; }
time_t getModificationTime() const { return ModTime; }
mode_t getFileMode() const { return FileMode; }
-
+
/// getDir - Return the directory the file lives in.
///
const DirectoryEntry *getDir() const { return Dir; }
-
+
bool operator<(const FileEntry& RHS) const {
return Device < RHS.Device || (Device == RHS.Device && Inode < RHS.Inode);
}
@@ -85,19 +85,19 @@ public:
/// execution of the front end.
class MemorizeStatCalls : public StatSysCallCache {
public:
- /// \brief The result of a stat() call.
+ /// \brief The result of a stat() call.
///
/// The first member is the result of calling stat(). If stat()
/// found something, the second member is a copy of the stat
/// structure.
typedef std::pair<int, struct stat> StatResult;
- /// \brief The set of stat() calls that have been
+ /// \brief The set of stat() calls that have been
llvm::StringMap<StatResult, llvm::BumpPtrAllocator> StatCalls;
typedef llvm::StringMap<StatResult, llvm::BumpPtrAllocator>::const_iterator
iterator;
-
+
iterator begin() const { return StatCalls.begin(); }
iterator end() const { return StatCalls.end(); }
@@ -124,22 +124,22 @@ class FileManager {
///
llvm::StringMap<DirectoryEntry*, llvm::BumpPtrAllocator> DirEntries;
llvm::StringMap<FileEntry*, llvm::BumpPtrAllocator> FileEntries;
-
+
/// NextFileUID - Each FileEntry we create is assigned a unique ID #.
///
unsigned NextFileUID;
-
+
// Statistics.
unsigned NumDirLookups, NumFileLookups;
unsigned NumDirCacheMisses, NumFileCacheMisses;
-
+
// Caching.
llvm::OwningPtr<StatSysCallCache> StatCache;
int stat_cached(const char* path, struct stat* buf) {
return StatCache.get() ? StatCache->stat(path, buf) : stat(path, buf);
}
-
+
public:
FileManager();
~FileManager();
@@ -150,24 +150,24 @@ public:
void setStatCache(StatSysCallCache *statCache) {
StatCache.reset(statCache);
}
-
+
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
- ///
+ ///
const DirectoryEntry *getDirectory(const llvm::StringRef &Filename) {
return getDirectory(Filename.begin(), Filename.end());
}
const DirectoryEntry *getDirectory(const char *FileStart,const char *FileEnd);
-
+
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
- ///
+ ///
const FileEntry *getFile(const llvm::StringRef &Filename) {
return getFile(Filename.begin(), Filename.end());
}
const FileEntry *getFile(const char *FilenameStart,
const char *FilenameEnd);
-
+
void PrintStats() const;
};
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h
index 57cd311631..8512538e45 100644
--- a/include/clang/Basic/IdentifierTable.h
+++ b/include/clang/Basic/IdentifierTable.h
@@ -21,8 +21,8 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/PointerLikeTypeTraits.h"
-#include <string>
-#include <cassert>
+#include <string>
+#include <cassert>
namespace llvm {
template <typename T> struct DenseMapInfo;
@@ -38,21 +38,21 @@ namespace clang {
/// IdentifierLocPair - A simple pair of identifier info and location.
typedef std::pair<IdentifierInfo*, SourceLocation> IdentifierLocPair;
-
-
+
+
/// IdentifierInfo - One of these records is kept for each identifier that
/// is lexed. This contains information about whether the token was #define'd,
/// is a language keyword, or if it is a front-end token of some sort (e.g. a
/// variable or function name). The preprocessor keeps this information in a
-/// set, and all tok::identifier tokens have a pointer to one of these.
+/// set, and all tok::identifier tokens have a pointer to one of these.
class IdentifierInfo {
// Note: DON'T make TokenID a 'tok::TokenKind'; MSVC will treat it as a
// signed char and TokenKinds > 127 won't be handled correctly.
- unsigned TokenID : 8; // Front-end token ID or tok::identifier.
+ unsigned TokenID : 8; // Front-end token ID or tok::identifier.
// Objective-C keyword ('protocol' in '@protocol') or builtin (__builtin_inf).
// First NUM_OBJC_KEYWORDS values are for Objective-C, the remaining values
// are for builtins.
- unsigned ObjCOrBuiltinID :10;
+ unsigned ObjCOrBuiltinID :10;
bool HasMacro : 1; // True if there is a #define for this.
bool IsExtension : 1; // True if identifier is a lang extension.
bool IsPoisoned : 1; // True if identifier is poisoned.
@@ -61,50 +61,50 @@ class IdentifierInfo {
// 9 bits left in 32-bit word.
void *FETokenInfo; // Managed by the language front-end.
llvm::StringMapEntry<IdentifierInfo*> *Entry;
-
+
IdentifierInfo(const IdentifierInfo&); // NONCOPYABLE.
void operator=(const IdentifierInfo&); // NONASSIGNABLE.
- friend class IdentifierTable;
+ friend class IdentifierTable;
public:
IdentifierInfo();
-
+
/// isStr - Return true if this is the identifier for the specified string.
/// This is intended to be used for string literals only: II->isStr("foo").
template <std::size_t StrLen>
bool isStr(const char (&Str)[StrLen]) const {
return getLength() == StrLen-1 && !memcmp(getName(), Str, StrLen-1);
}
-
- /// getName - Return the actual string for this identifier. The returned
+
+ /// getName - Return the actual string for this identifier. The returned
/// string is properly null terminated.
///
- const char *getName() const {
+ const char *getName() const {
if (Entry) return Entry->getKeyData();
// FIXME: This is gross. It would be best not to embed specific details
// of the PTH file format here.
- // The 'this' pointer really points to a
+ // The 'this' pointer really points to a
// std::pair<IdentifierInfo, const char*>, where internal pointer
// points to the external string data.
return ((std::pair<IdentifierInfo, const char*>*) this)->second;
}
-
+
/// getLength - Efficiently return the length of this identifier info.
///
unsigned getLength() const {
if (Entry) return Entry->getKeyLength();
// FIXME: This is gross. It would be best not to embed specific details
// of the PTH file format here.
- // The 'this' pointer really points to a
+ // The 'this' pointer really points to a
// std::pair<IdentifierInfo, const char*>, where internal pointer
// points to the external string data.
const char* p = ((std::pair<IdentifierInfo, const char*>*) this)->second-2;
return (((unsigned) p[0])
| (((unsigned) p[1]) << 8)) - 1;
}
-
+
/// hasMacroDefinition - Return true if this identifier is #defined to some
/// other value.
bool hasMacroDefinition() const {
@@ -112,29 +112,29 @@ public:
}
void setHasMacroDefinition(bool Val) {
if (HasMacro == Val) return;
-
+
HasMacro = Val;
if (Val)
NeedsHandleIdentifier = 1;
else
RecomputeNeedsHandleIdentifier();
}
-
+
/// get/setTokenID - If this is a source-language token (e.g. 'for'), this API
/// can be used to cause the lexer to map identifiers to source-language
/// tokens.
tok::TokenKind getTokenID() const { return (tok::TokenKind)TokenID; }
void setTokenID(tok::TokenKind ID) { TokenID = ID; }
-
+
/// getPPKeywordID - Return the preprocessor keyword ID for this identifier.
/// For example, "define" will return tok::pp_define.
tok::PPKeywordKind getPPKeywordID() const;
-
+
/// getObjCKeywordID - Return the Objective-C keyword ID for the this
/// identifier. For example, 'class' will return tok::objc_class if ObjC is
/// enabled.
tok::ObjCKeywordKind getObjCKeywordID() const {
- if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
+ if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
return tok::ObjCKeywordKind(ObjCOrBuiltinID);
else
return tok::objc_not_keyword;
@@ -144,15 +144,15 @@ public:
/// getBuiltinID - Return a value indicating whether this is a builtin
/// function. 0 is not-built-in. 1 is builtin-for-some-nonprimary-target.
/// 2+ are specific builtin functions.
- unsigned getBuiltinID() const {
+ unsigned getBuiltinID() const {
if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
- return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
+ return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
else
return 0;
}
void setBuiltinID(unsigned ID) {
ObjCOrBuiltinID = ID + tok::NUM_OBJC_KEYWORDS;
- assert(ObjCOrBuiltinID - unsigned(tok::NUM_OBJC_KEYWORDS) == ID
+ assert(ObjCOrBuiltinID - unsigned(tok::NUM_OBJC_KEYWORDS) == ID
&& "ID too large for field!");
}
@@ -170,7 +170,7 @@ public:
else
RecomputeNeedsHandleIdentifier();
}
-
+
/// setIsPoisoned - Mark this identifier as poisoned. After poisoning, the
/// Preprocessor will emit an error every time this token is used.
void setIsPoisoned(bool Value = true) {
@@ -180,10 +180,10 @@ public:
else
RecomputeNeedsHandleIdentifier();
}
-
+
/// isPoisoned - Return true if this token has been poisoned.
bool isPoisoned() const { return IsPoisoned; }
-
+
/// isCPlusPlusOperatorKeyword/setIsCPlusPlusOperatorKeyword controls whether
/// this identifier is a C++ alternate representation of an operator.
void setIsCPlusPlusOperatorKeyword(bool Val = true) {
@@ -205,7 +205,7 @@ public:
/// must be called on a token of this identifier. If this returns false, we
/// know that HandleIdentifier will not affect the token.
bool isHandleIdentifierCase() const { return NeedsHandleIdentifier; }
-
+
private:
/// RecomputeNeedsHandleIdentifier - The Preprocessor::HandleIdentifier does
/// several special (but rare) things to identifiers of various sorts. For
@@ -227,13 +227,13 @@ private:
class IdentifierInfoLookup {
public:
virtual ~IdentifierInfoLookup();
-
+
/// get - Return the identifier token info for the specified named identifier.
/// Unlike the version in IdentifierTable, this returns a pointer instead
/// of a reference. If the pointer is NULL then the IdentifierInfo cannot
/// be found.
virtual IdentifierInfo* get(const char *NameStart, const char *NameEnd) = 0;
-};
+};
/// \brief An abstract class used to resolve numerical identifier
/// references (meaningful only to some external source) into
@@ -257,7 +257,7 @@ class IdentifierTable {
// BumpPtrAllocator!
typedef llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator> HashTableTy;
HashTableTy HashTable;
-
+
IdentifierInfoLookup* ExternalLookup;
public:
@@ -265,7 +265,7 @@ public:
/// info about the language keywords for the language specified by LangOpts.
IdentifierTable(const LangOptions &LangOpts,
IdentifierInfoLookup* externalLookup = 0);
-
+
/// \brief Set the external identifier lookup mechanism.
void setExternalIdentifierLookup(IdentifierInfoLookup *IILookup) {
ExternalLookup = IILookup;
@@ -274,16 +274,16 @@ public:
llvm::BumpPtrAllocator& getAllocator() {
return HashTable.getAllocator();
}
-
+
/// get - Return the identifier token info for the specified named identifier.
///
IdentifierInfo &get(const char *NameStart, const char *NameEnd) {
llvm::StringMapEntry<IdentifierInfo*> &Entry =
HashTable.GetOrCreateValue(NameStart, NameEnd);
-
+
IdentifierInfo *II = Entry.getValue();
if (II) return *II;
-
+
// No entry; if we have an external lookup, look there first.
if (ExternalLookup) {
II = ExternalLookup->get(NameStart, NameEnd);
@@ -305,7 +305,7 @@ public:
return *II;
}
-
+
/// \brief Creates a new IdentifierInfo from the given string.
///
/// This is a lower-level version of get() that requires that this
@@ -314,14 +314,14 @@ public:
/// identifier sources can use this routine to build IdentifierInfo
/// nodes and then introduce additional information about those
/// identifiers.
- IdentifierInfo &CreateIdentifierInfo(const char *NameStart,
+ IdentifierInfo &CreateIdentifierInfo(const char *NameStart,
const char *NameEnd) {
llvm::StringMapEntry<IdentifierInfo*> &Entry =
HashTable.GetOrCreateValue(NameStart, NameEnd);
-
+
IdentifierInfo *II = Entry.getValue();
assert(!II && "IdentifierInfo already exists");
-
+
// Lookups failed, make a new IdentifierInfo.
void *Mem = getAllocator().Allocate<IdentifierInfo>();
II = new (Mem) IdentifierInfo();
@@ -345,26 +345,26 @@ public:
typedef HashTableTy::const_iterator iterator;
typedef HashTableTy::const_iterator const_iterator;
-
+
iterator begin() const { return HashTable.begin(); }
iterator end() const { return HashTable.end(); }
unsigned size() const { return HashTable.size(); }
-
+
/// PrintStats - Print some statistics to stderr that indicate how well the
/// hashing is doing.
void PrintStats() const;
-
+
void AddKeywords(const LangOptions &LangOpts);
};
/// Selector - This smart pointer class efficiently represents Objective-C
/// method names. This class will either point to an IdentifierInfo or a
/// MultiKeywordSelector (which is private). This enables us to optimize
-/// selectors that take no arguments and selectors that take 1 argument, which
+/// selectors that take no arguments and selectors that take 1 argument, which
/// accounts for 78% of all selectors in Cocoa.h.
class Selector {
friend class DiagnosticInfo;
-
+
enum IdentifierInfoFlag {
// MultiKeywordSelector = 0.
ZeroArg = 0x1,
@@ -372,7 +372,7 @@ class Selector {
ArgFlags = ZeroArg|OneArg
};
uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo.
-
+
Selector(IdentifierInfo *II, unsigned nArgs) {
InfoPtr = reinterpret_cast<uintptr_t>(II);
assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
@@ -383,7 +383,7 @@ class Selector {
InfoPtr = reinterpret_cast<uintptr_t>(SI);
assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
}
-
+
IdentifierInfo *getAsIdentifierInfo() const {
if (getIdentifierInfoFlag())
return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags);
@@ -417,19 +417,19 @@ public:
bool isNull() const { return InfoPtr == 0; }
// Predicates to identify the selector type.
- bool isKeywordSelector() const {
- return getIdentifierInfoFlag() != ZeroArg;
+ bool isKeywordSelector() const {
+ return getIdentifierInfoFlag() != ZeroArg;
}
- bool isUnarySelector() const {
+ bool isUnarySelector() const {
return getIdentifierInfoFlag() == ZeroArg;
}
unsigned getNumArgs() const;
IdentifierInfo *getIdentifierInfoForSlot(unsigned argIndex) const;
-
+
/// getAsString - Derive the full selector name (e.g. "foo:bar:") and return
/// it as an std::string.
std::string getAsString() const;
-
+
static Selector getEmptyMarker() {
return Selector(uintptr_t(-1));
}
@@ -452,7 +452,7 @@ public:
/// whether this is a no argument selector "foo", a single argument selector
/// "foo:" or multi-argument "foo:bar:".
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV);
-
+
Selector getUnarySelector(IdentifierInfo *ID) {
return Selector(ID, 1);
}
@@ -519,15 +519,15 @@ struct DenseMapInfo<clang::Selector> {
return clang::Selector::getEmptyMarker();
}
static inline clang::Selector getTombstoneKey() {
- return clang::Selector::getTombstoneMarker();
+ return clang::Selector::getTombstoneMarker();
}
-
+
static unsigned getHashValue(clang::Selector S);
-
+
static bool isEqual(clang::Selector LHS, clang::Selector RHS) {
return LHS == RHS;
}
-
+
static bool isPod() { return true; }
};
@@ -537,7 +537,7 @@ template<>
class PointerLikeTypeTraits<clang::IdentifierInfo*> {
public:
static inline void *getAsVoidPointer(clang::IdentifierInfo* P) {
- return P;
+ return P;
}
static inline clang::IdentifierInfo *getFromVoidPointer(void *P) {
return static_cast<clang::IdentifierInfo*>(P);
@@ -549,7 +549,7 @@ template<>
class PointerLikeTypeTraits<const clang::IdentifierInfo*> {
public:
static inline const void *getAsVoidPointer(const clang::IdentifierInfo* P) {
- return P;
+ return P;
}
static inline const clang::IdentifierInfo *getFromVoidPointer(const void *P) {
return static_cast<const clang::IdentifierInfo*>(P);
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index da702a8ab3..b5c813dc3c 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -34,13 +34,13 @@ public:
unsigned CPlusPlus : 1; // C++ Support
unsigned CPlusPlus0x : 1; // C++0x Support
unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords.
-
+
unsigned ObjC1 : 1; // Objective-C 1 support enabled.
unsigned ObjC2 : 1; // Objective-C 2 support enabled.
unsigned ObjCSenderDispatch: 1; // Objective-C 2 three-dimensional dispatch
// enabled.
unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled
-
+
unsigned PascalStrings : 1; // Allow Pascal strings
unsigned WritableStrings : 1; // Allow writable strings
unsigned LaxVectorConversions : 1;
@@ -69,7 +69,7 @@ public:
// may be ripped out at any time.
unsigned Optimize : 1; // Whether __OPTIMIZE__ should be defined.
- unsigned OptimizeSize : 1; // Whether __OPTIMIZE_SIZE__ should be
+ unsigned OptimizeSize : 1; // Whether __OPTIMIZE_SIZE__ should be
// defined.
unsigned Static : 1; // Should __STATIC__ be defined (as
// opposed to __DYNAMIC__).
@@ -82,7 +82,7 @@ public:
unsigned ObjCGCBitmapPrint : 1; // Enable printing of gc's bitmap layout
// for __weak/__strong ivars.
- unsigned AccessControl : 1; // Whether C++ access control should
+ unsigned AccessControl : 1; // Whether C++ access control should
// be enabled.
unsigned CharIsSigned : 1; // Whether char is a signed or unsigned type
@@ -106,19 +106,19 @@ private:
/// the original input file, for example with -save-temps.
const char *MainFileName;
-public:
+public:
unsigned InstantiationDepth; // Maximum template instantiation depth.
const char *ObjCConstantStringClass;
enum GCMode { NonGC, GCOnly, HybridGC };
enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
- enum VisibilityMode {
- Default,
- Protected,
+ enum VisibilityMode {
+ Default,
+ Protected,
Hidden
};
-
+
LangOptions() {
Trigraphs = BCPLComment = Bool = DollarIdents = AsmPreprocessor = 0;
GNUMode = ImplicitInt = Digraphs = 0;
@@ -134,7 +134,7 @@ public:
AltiVec = OpenCL = StackProtector = 0;
SymbolVisibility = (unsigned) Default;
-
+
// FIXME: The default should be 1.
ThreadsafeStatics = 0;
POSIXThreads = 0;
@@ -145,13 +145,13 @@ public:
// FIXME: The default should be 1.
AccessControl = 0;
ElideConstructors = 1;
-
+
OverflowChecking = 0;
ObjCGCBitmapPrint = 0;
ObjCSenderDispatch = 0;
InstantiationDepth = 99;
-
+
Optimize = 0;
OptimizeSize = 0;
@@ -165,7 +165,7 @@ public:
MainFileName = 0;
}
-
+
GCMode getGCMode() const { return (GCMode) GC; }
void setGCMode(GCMode m) { GC = (unsigned) m; }
@@ -179,8 +179,8 @@ public:
const char *getMainFileName() const { return MainFileName; }
void setMainFileName(const char *Name) { MainFileName = Name; }
- VisibilityMode getVisibilityMode() const {
- return (VisibilityMode) SymbolVisibility;
+ VisibilityMode getVisibilityMode() const {
+ return (VisibilityMode) SymbolVisibility;
}
void setVisibilityMode(VisibilityMode v) { SymbolVisibility = (unsigned) v; }
};
diff --git a/include/clang/Basic/OnDiskHashTable.h b/include/clang/Basic/OnDiskHashTable.h
index f54d67042c..65245167d8 100644
--- a/include/clang/Basic/OnDiskHashTable.h
+++ b/include/clang/Basic/OnDiskHashTable.h
@@ -29,7 +29,7 @@ namespace clang {
// This is basically copy-and-paste from StringMap. This likely won't
// stay here, which is why I didn't both to expose this function from
// String Map.
-inline unsigned BernsteinHash(const char* x) {
+inline unsigned BernsteinHash(const char* x) {
unsigned int R = 0;
for ( ; *x != '\0' ; ++x) R = R * 33 + *x;
return R + (R >> 5);
@@ -131,29 +131,29 @@ class OnDiskChainedHashTableGenerator {
unsigned NumBuckets;
unsigned NumEntries;
llvm::BumpPtrAllocator BA;
-
+
class Item {
public:
typename Info::key_type key;
typename Info::data_type data;
Item *next;
const uint32_t hash;
-
+
Item(typename Info::key_type_ref k, typename Info::data_type_ref d)
: key(k), data(d), next(0), hash(Info::ComputeHash(k)) {}
};
-
- class Bucket {
+
+ class Bucket {
public:
io::Offset off;
Item* head;
unsigned length;
-
+
Bucket() {}
};
-
+
Bucket* Buckets;
-
+
private:
void insert(Bucket* b, size_t size, Item* E) {
unsigned idx = E->hash & (size - 1);
@@ -162,7 +162,7 @@ private:
++B.length;
B.head = E;
}
-
+
void resize(size_t newsize) {
Bucket* newBuckets = (Bucket*) std::calloc(newsize, sizeof(Bucket));
// Populate newBuckets with the old entries.
@@ -173,14 +173,14 @@ private:
insert(newBuckets, newsize, E);
E = N;
}
-
+
free(Buckets);
NumBuckets = newsize;
Buckets = newBuckets;
- }
-
+ }
+
public:
-
+
void insert(typename Info::key_type_ref key,
typename Info::data_type_ref data) {
@@ -188,7 +188,7 @@ public:
if (4*NumEntries >= 3*NumBuckets) resize(NumBuckets*2);
insert(Buckets, NumBuckets, new (BA.Allocate<Item>()) Item(key, data));
}
-
+
io::Offset Emit(llvm::raw_ostream &out) {
Info InfoObj;
return Emit(out, InfoObj);
@@ -201,42 +201,42 @@ public:
for (unsigned i = 0; i < NumBuckets; ++i) {
Bucket& B = Buckets[i];
if (!B.head) continue;
-
+
// Store the offset for the data of this bucket.
B.off = out.tell();
assert(B.off && "Cannot write a bucket at offset 0. Please add padding.");
// Write out the number of items in the bucket.
Emit16(out, B.length);
-
+
// Write out the entries in the bucket.
for (Item *I = B.head; I ; I = I->next) {
Emit32(out, I->hash);
- const std::pair<unsigned, unsigned>& Len =
+ const std::pair<unsigned, unsigned>& Len =
InfoObj.EmitKeyDataLength(out, I->key, I->data);
InfoObj.EmitKey(out, I->key, Len.first);
InfoObj.EmitData(out, I->key, I->data, Len.second);
}
}
-
+
// Emit the hashtable itself.
Pad(out, 4);
io::Offset TableOff = out.tell();
Emit32(out, NumBuckets);
Emit32(out, NumEntries);
for (unsigned i = 0; i < NumBuckets; ++i) Emit32(out, Buckets[i].off);
-
+
return TableOff;
}
-
+
OnDiskChainedHashTableGenerator() {
NumEntries = 0;
- NumBuckets = 64;
+ NumBuckets = 64;
// Note that we do not need to run the constructors of the individual
// Bucket objects since 'calloc' returns bytes that are all 0.
Buckets = (Bucket*) std::calloc(NumBuckets, sizeof(Bucket));
}
-
+
~OnDiskChainedHashTableGenerator() {
std::free(Buckets);
}
@@ -254,7 +254,7 @@ public:
typedef typename Info::internal_key_type internal_key_type;
typedef typename Info::external_key_type external_key_type;
typedef typename Info::data_type data_type;
-
+
OnDiskChainedHashTable(unsigned numBuckets, unsigned numEntries,
const unsigned char* buckets,
const unsigned char* base,
@@ -271,7 +271,7 @@ public:
const unsigned char* getBuckets() const { return Buckets; }
bool isEmpty() const { return NumEntries == 0; }
-
+
class iterator {
internal_key_type key;
const unsigned char* const data;
@@ -282,12 +282,12 @@ public:
iterator(const internal_key_type k, const unsigned char* d, unsigned l,
Info *InfoObj)
: key(k), data(d), len(l), InfoObj(InfoObj) {}
-
- data_type operator*() const { return InfoObj->ReadData(key, data, len); }
- bool operator==(const iterator& X) const { return X.data == data; }
+
+ data_type operator*() const { return InfoObj->ReadData(key, data, len); }
+ bool operator==(const iterator& X) const { return X.data == data; }
bool operator!=(const iterator& X) const { return X.data != data; }
- };
-
+ };
+
iterator find(const external_key_type& eKey, Info *InfoPtr = 0) {
if (!InfoPtr)
InfoPtr = &InfoObj;
@@ -295,25 +295,25 @@ public:
using namespace io;
const internal_key_type& iKey = Info::GetInternalKey(eKey);
unsigned key_hash = Info::ComputeHash(iKey);
-
+
// Each bucket is just a 32-bit offset into the hash table file.
unsigned idx = key_hash & (NumBuckets - 1);
const unsigned char* Bucket = Buckets + sizeof(uint32_t)*idx;
-
+
unsigned offset = ReadLE32(Bucket);
if (offset == 0) return iterator(); // Empty bucket.
const unsigned char* Items = Base + offset;
-
+
// 'Items' starts with a 16-bit unsigned integer representing the
// number of items in this bucket.
unsigned len = ReadUnalignedLE16(Items);
-
+
for (unsigned i = 0; i < len; ++i) {
// Read the hash.
uint32_t item_hash = ReadUnalignedLE32(Items);
-
+
// Determine the length of the key and the data.
- const std::pair<unsigned, unsigned>& L = Info::ReadKeyDataLength(Items);
+ const std::pair<unsigned, unsigned>& L = Info::ReadKeyDataLength(Items);
unsigned item_len = L.first + L.second;
// Compare the hashes. If they are not the same, skip the entry entirely.
@@ -321,7 +321,7 @@ public:
Items += item_len;
continue;
}
-
+
// Read the key.
const internal_key_type& X =
InfoPtr->ReadKey((const unsigned char* const) Items, L.first);
@@ -331,17 +331,17 @@ public:
Items += item_len;
continue;
}
-
+
// The key matches!
return iterator(X, Items + L.first, L.second, InfoPtr);
}
-
+
return iterator();
}
-
+
iterator end() const { return iterator(); }
-
-
+
+
static OnDiskChainedHashTable* Create(const unsigned char* buckets,
const unsigned char* const base,
const Info &InfoObj = Info()) {
@@ -349,14 +349,14 @@ public:
assert(buckets > base);
assert((reinterpret_cast<uintptr_t>(buckets) & 0x3) == 0 &&
"buckets should be 4-byte aligned.");
-
+
unsigned numBuckets = ReadLE32(buckets);
unsigned numEntries = ReadLE32(buckets);
return new OnDiskChainedHashTable<Info>(numBuckets, numEntries, buckets,
base, InfoObj);
- }
+ }
};
} // end namespace clang
-#endif
+#endif
diff --git a/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h
index 2405c2fe7d..28cf2db9bc 100644
--- a/include/clang/Basic/SourceLocation.h
+++ b/include/clang/Basic/SourceLocation.h
@@ -24,10 +24,10 @@ namespace llvm {
}
namespace clang {
-
+
class SourceManager;
class FileEntry;
-
+
/// FileID - This is an opaque identifier used by SourceManager which refers to
/// a source file (MemoryBuffer) along with its #include path and #line data.
///
@@ -36,19 +36,19 @@ class FileID {
unsigned ID;
public:
FileID() : ID(0) {}
-
+
bool isInvalid() const { return ID == 0; }
-
+
bool operator==(const FileID &RHS) const { return ID == RHS.ID; }
bool operator<(const FileID &RHS) const { return ID < RHS.ID; }
bool operator<=(const FileID &RHS) const { return ID <= RHS.ID; }
bool operator!=(const FileID &RHS) const { return !(*this == RHS); }
bool operator>(const FileID &RHS) const { return RHS < *this; }
bool operator>=(const FileID &RHS) const { return RHS <= *this; }
-
+
static FileID getSentinel() { return get(~0U); }
unsigned getHashValue() const { return ID; }
-
+
private:
friend class SourceManager;
static FileID get(unsigned V) {
@@ -58,8 +58,8 @@ private:
}
unsigned getOpaqueValue() const { return ID; }
};
-
-
+
+
/// SourceLocation - This is a carefully crafted 32-bit identifier that encodes
/// a full include stack, line and column number information for a position in
/// an input translation unit.
@@ -72,17 +72,17 @@ class SourceLocation {
public:
SourceLocation() : ID(0) {} // 0 is an invalid FileID.
-
+
bool isFileID() const { return (ID & MacroIDBit) == 0; }
bool isMacroID() const { return (ID & MacroIDBit) != 0; }
-
+
/// isValid - Return true if this is a valid SourceLocation object. Invalid
/// SourceLocations are often used when events have no corresponding location
/// in the source (e.g. a diagnostic is required for a command line option).
///
bool isValid() const { return ID != 0; }
bool isInvalid() const { return ID == 0; }
-
+
private:
/// getOffset - Return the index for SourceManager's SLocEntryTable table,
/// note that this is not an index *into* it though.
@@ -96,7 +96,7 @@ private:
L.ID = ID;
return L;
}
-
+
static SourceLocation getMacroLoc(unsigned ID) {
assert((ID & MacroIDBit) == 0 && "Ran out of source locations!");
SourceLocation L;
@@ -104,7 +104,7 @@ private:
return L;
}
public:
-
+
/// getFileLocWithOffset - Return a source location with the specified offset
/// from this file SourceLocation.
SourceLocation getFileLocWithOffset(int Offset) const {
@@ -113,14 +113,14 @@ public:
L.ID = ID+Offset;
return L;
}
-
+
/// getRawEncoding - When a SourceLocation itself cannot be used, this returns
/// an (opaque) 32-bit integer encoding for it. This should only be passed
/// to SourceLocation::getFromRawEncoding, it should not be inspected
/// directly.
unsigned getRawEncoding() const { return ID; }
-
-
+
+
/// getFromRawEncoding - Turn a raw encoding of a SourceLocation object into
/// a real SourceLocation.
static SourceLocation getFromRawEncoding(unsigned Encoding) {
@@ -128,7 +128,7 @@ public:
X.ID = Encoding;
return X;
}
-
+
void print(llvm::raw_ostream &OS, const SourceManager &SM) const;
void dump(const SourceManager &SM) const;
};
@@ -140,7 +140,7 @@ inline bool operator==(const SourceLocation &LHS, const SourceLocation &RHS) {
inline bool operator!=(const SourceLocation &LHS, const SourceLocation &RHS) {
return !(LHS == RHS);
}
-
+
inline bool operator<(const SourceLocation &LHS, const SourceLocation &RHS) {
return LHS.getRawEncoding() < RHS.getRawEncoding();
}
@@ -153,24 +153,24 @@ public:
SourceRange(): B(SourceLocation()), E(SourceLocation()) {}
SourceRange(SourceLocation loc) : B(loc), E(loc) {}
SourceRange(SourceLocation begin, SourceLocation end) : B(begin), E(end) {}
-
+
SourceLocation getBegin() const { return B; }
SourceLocation getEnd() const { return E; }
-
+
void setBegin(SourceLocation b) { B = b; }
void setEnd(SourceLocation e) { E = e; }
-
+
bool isValid() const { return B.isValid() && E.isValid(); }
-
+
bool operator==(const SourceRange &X) const {
return B == X.B && E == X.E;
}
-
+
bool operator!=(const SourceRange &X) const {
return B != X.B || E != X.E;
}
};
-
+
/// FullSourceLoc - A SourceLocation and its associated SourceManager. Useful
/// for argument passing to functions that expect both objects.
class FullSourceLoc : public SourceLocation {
@@ -179,21 +179,21 @@ public:
/// Creates a FullSourceLoc where isValid() returns false.
explicit FullSourceLoc() : SrcMgr((SourceManager*) 0) {}
- explicit FullSourceLoc(SourceLocation Loc, SourceManager &SM)
+ explicit FullSourceLoc(SourceLocation Loc, SourceManager &SM)
: SourceLocation(Loc), SrcMgr(&SM) {}
-
+
SourceManager &getManager() {
assert(SrcMgr && "SourceManager is NULL.");
return *SrcMgr;
}
-
+
const SourceManager &getManager() const {
assert(SrcMgr && "SourceManager is NULL.");
return *SrcMgr;
}
-
+
FileID getFileID() const;
-
+
FullSourceLoc getInstantiationLoc() const;
FullSourceLoc getSpellingLoc() const;
@@ -204,37 +204,37 @@ public:
unsigned getSpellingColumnNumber() const;
const char *getCharacterData() const;
-
+
const llvm::MemoryBuffer* getBuffer() const;
-
+
/// getBufferData - Return a pointer to the start and end of the source buffer
/// data for the specified FileID.
std::pair<const char*, const char*> getBufferData() const;
-
+
/// getDecomposedLoc - Decompose the specified location into a raw FileID +
/// Offset pair. The first element is the FileID, the second is the
/// offset from the start of the buffer of the location.
std::pair<FileID, unsigned> getDecomposedLoc() const;
bool isInSystemHeader() const;
-
+
/// Prints information about this FullSourceLoc to stderr. Useful for
/// debugging.
void dump() const { SourceLocation::dump(*SrcMgr); }
- friend inline bool
+ friend inline bool
operator==(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
return LHS.getRawEncoding() == RHS.getRawEncoding() &&
LHS.SrcMgr == RHS.SrcMgr;
}
- friend inline bool
+ friend inline bool
operator!=(const FullSourceLoc &LHS, const FullSourceLoc &RHS) {
return !(LHS == RHS);
}
};
-
+
/// PresumedLoc - This class represents an unpacked "presumed" location which
/// can be presented to the user. A 'presumed' location can be modified by
/// #line and GNU line marker directives and is always the instantiation point
@@ -250,13 +250,13 @@ public:
PresumedLoc(const char *FN, unsigned Ln, unsigned Co, SourceLocation IL)
: Filename(FN), Line(Ln), Col(Co), IncludeLoc(IL) {
}
-
+
/// isInvalid - Return true if this object is invalid or uninitialized. This
/// occurs when created with invalid source locations or when walking off
/// the top of a #include stack.
bool isInvalid() const { return Filename == 0; }
bool isValid() const { return Filename != 0; }
-
+
/// getFilename - Return the presumed filename of this location. This can be
/// affected by #line etc.
const char *getFilename() const { return Filename; }
@@ -264,7 +264,7 @@ public:
/// getLine - Return the presumed line number of this location. This can be
/// affected by #line etc.
unsigned getLine() const { return Line; }
-
+
/// getColumn - Return the presumed column number of this location. This can
/// not be affected by #line, but is packaged here for convenience.
unsigned getColumn() const { return Col; }
@@ -274,7 +274,7 @@ public:
SourceLocation getIncludeLoc() const { return IncludeLoc; }
};
-
+
} // end namespace clang
namespace llvm {
@@ -286,20 +286,20 @@ namespace llvm {
return clang::FileID();
}
static inline clang::FileID getTombstoneKey() {
- return clang::FileID::getSentinel();
+ return clang::FileID::getSentinel();
}
-
+
static unsigned getHashValue(clang::FileID S) {
return S.getHashValue();
}
-
+
static bool isEqual(clang::FileID LHS, clang::FileID RHS) {
return LHS == RHS;
}
-
+
static bool isPod() { return true; }
};
-
+
} // end namespace llvm
#endif
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 249ca89f71..e0eb2197ce 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -24,9 +24,9 @@
namespace llvm {
class MemoryBuffer;
}
-
+
namespace clang {
-
+
class SourceManager;
class FileManager;
class FileEntry;
@@ -46,7 +46,7 @@ namespace SrcMgr {
enum CharacteristicKind {
C_User, C_System, C_ExternCSystem
};
-
+
/// ContentCache - Once instance of this struct is kept for every file
/// loaded or used. This object owns the MemoryBuffer object.
class ContentCache {
@@ -59,12 +59,12 @@ namespace SrcMgr {
/// the FileEntry object. It is possible for this to be NULL if
/// the ContentCache encapsulates an imaginary text buffer.
const FileEntry *Entry;
-
+
/// SourceLineCache - A bump pointer allocated array of offsets for each
/// source line. This is lazily computed. This is owned by the
/// SourceManager BumpPointerAllocator object.
unsigned *SourceLineCache;
-
+
/// NumLines - The number of lines in this ContentCache. This is only valid
/// if SourceLineCache is non-null.
unsigned NumLines;
@@ -76,28 +76,28 @@ namespace SrcMgr {
/// getBuffer - Returns the memory buffer for the associated content.
const llvm::MemoryBuffer *getBuffer() const;
-
+
/// getSize - Returns the size of the content encapsulated by this
/// ContentCache. This can be the size of the source file or the size of an
/// arbitrary scratch buffer. If the ContentCache encapsulates a source
/// file this size is retrieved from the file's FileEntry.
unsigned getSize() const;
-
+
/// getSizeBytesMapped - Returns the number of bytes actually mapped for
/// this ContentCache. This can be 0 if the MemBuffer was not actually
/// instantiated.
unsigned getSizeBytesMapped() const;
-
+
void setBuffer(const llvm::MemoryBuffer *B) {
assert(!Buffer && "MemoryBuffer already set.");
Buffer = B;
}
-
+
ContentCache(const FileEntry *Ent = 0)
: Buffer(0), Entry(Ent), SourceLineCache(0), NumLines(0) {}
~ContentCache();
-
+
/// The copy ctor does not allow copies where source object has either
/// a non-NULL Buffer or SourceLineCache. Ownership of allocated memory
/// is not transfered, so this is a logical error.
@@ -106,14 +106,14 @@ namespace SrcMgr {
assert (RHS.Buffer == 0 && RHS.SourceLineCache == 0
&& "Passed ContentCache object cannot own a buffer.");
-
- NumLines = RHS.NumLines;
+
+ NumLines = RHS.NumLines;
}
-
+
private:
// Disable assignments.
- ContentCache &operator=(const ContentCache& RHS);
- };
+ ContentCache &operator=(const ContentCache& RHS);
+ };
/// FileInfo - Information about a FileID, basically just the logical file
/// that it represents and include stack information.
@@ -128,7 +128,7 @@ namespace SrcMgr {
/// IncludeLoc - The location of the #include that brought in this file.
/// This is an invalid SLOC for the main file (top of the #include chain).
unsigned IncludeLoc; // Really a SourceLocation
-
+
/// Data - This contains the ContentCache* and the bits indicating the
/// characteristic of the file and whether it has #line info, all bitmangled
/// together.
@@ -145,39 +145,39 @@ namespace SrcMgr {
X.Data |= (unsigned)FileCharacter;
return X;
}
-
+
SourceLocation getIncludeLoc() const {
return SourceLocation::getFromRawEncoding(IncludeLoc);
}
const ContentCache* getContentCache() const {
return reinterpret_cast<const ContentCache*>(Data & ~7UL);
}
-
+
/// getCharacteristic - Return whether this is a system header or not.
- CharacteristicKind getFileCharacteristic() const {
+ CharacteristicKind getFileCharacteristic() const {
return (CharacteristicKind)(Data & 3);
}
/// hasLineDirectives - Return true if this FileID has #line directives in
/// it.
bool hasLineDirectives() const { return (Data & 4) != 0; }
-
+
/// setHasLineDirectives - Set the flag that indicates that this FileID has
/// line table entries associated with it.
void setHasLineDirectives() {
Data |= 4;
}
};
-
+
/// InstantiationInfo - Each InstantiationInfo encodes the Instantiation
/// location - where the token was ultimately instantiated, and the
/// SpellingLoc - where the actual character data for the token came from.
class InstantiationInfo {
// Really these are all SourceLocations.
-
+
/// SpellingLoc - Where the spelling for the token can be found.
unsigned SpellingLoc;
-
+
/// InstantiationLocStart/InstantiationLocEnd - In a macro expansion, these
/// indicate the start and end of the instantiation. In object-like macros,
/// these will be the same. In a function-like macro instantiation, the
@@ -193,12 +193,12 @@ namespace SrcMgr {
SourceLocation getInstantiationLocEnd() const {
return SourceLocation::getFromRawEncoding(InstantiationLocEnd);
}
-
+
std::pair<SourceLocation,SourceLocation> getInstantiationLocRange() const {
return std::make_pair(getInstantiationLocStart(),
getInstantiationLocEnd());
}
-
+
/// get - Return a InstantiationInfo for an expansion. IL specifies
/// the instantiation location (where the macro is expanded), and SL
/// specifies the spelling location (where the characters from the token
@@ -213,7 +213,7 @@ namespace SrcMgr {
return X;
}
};
-
+
/// SLocEntry - This is a discriminated union of FileInfo and
/// InstantiationInfo. SourceManager keeps an array of these objects, and
/// they are uniquely identified by the FileID datatype.
@@ -225,10 +225,10 @@ namespace SrcMgr {
};
public:
unsigned getOffset() const { return Offset >> 1; }
-
+
bool isInstantiation() const { return Offset & 1; }
bool isFile() const { return !isInstantiation(); }
-
+
const FileInfo &getFile() const {
assert(isFile() && "Not a file SLocEntry!");
return File;
@@ -238,7 +238,7 @@ namespace SrcMgr {
assert(isInstantiation() && "Not an instantiation SLocEntry!");
return Instantiation;
}
-
+
static SLocEntry get(unsigned Offset, const FileInfo &FI) {
SLocEntry E;
E.Offset = Offset << 1;
@@ -277,18 +277,18 @@ public:
/// location specifies where it was expanded.
class SourceManager {
mutable llvm::BumpPtrAllocator ContentCacheAlloc;
-
+
/// FileInfos - Memoized information about all of the files tracked by this
/// SourceManager. This set allows us to merge ContentCache entries based
/// on their FileEntry*. All ContentCache objects will thus have unique,
- /// non-null, FileEntry pointers.
+ /// non-null, FileEntry pointers.
llvm::DenseMap<const FileEntry*, SrcMgr::ContentCache*> FileInfos;
-
+
/// MemBufferInfos - Information about various memory buffers that we have
/// read in. All FileEntry* within the stored ContentCache objects are NULL,
/// as they do not refer to a file.
std::vector<SrcMgr::ContentCache*> MemBufferInfos;
-
+
/// SLocEntryTable - This is an array of SLocEntry's that we have created.
/// FileID is an index into this vector. This array is sorted by the offset.
std::vector<SrcMgr::SLocEntry> SLocEntryTable;
@@ -308,49 +308,49 @@ class SourceManager {
/// LastFileIDLookup records the last FileID looked up or created, because it
/// is very common to look up many tokens from the same file.
mutable FileID LastFileIDLookup;
-
+
/// LineTable - This holds information for #line directives. It is referenced
/// by indices from SLocEntryTable.
LineTableInfo *LineTable;
-
+
/// LastLineNo - These ivars serve as a cache used in the getLineNumber
/// method which is used to speedup getLineNumber calls to nearby locations.
mutable FileID LastLineNoFileIDQuery;
mutable SrcMgr::ContentCache *LastLineNoContentCache;
mutable unsigned LastLineNoFilePos;
mutable unsigned LastLineNoResult;
-
+
/// MainFileID - The file ID for the main source file of the translation unit.
FileID MainFileID;
// Statistics for -print-stats.
mutable unsigned NumLinearScans, NumBinaryProbes;
-
+
// Cache results for the isBeforeInTranslationUnit method.
mutable FileID LastLFIDForBeforeTUCheck;
mutable FileID LastRFIDForBeforeTUCheck;
mutable bool LastResForBeforeTUCheck;
-
+
// SourceManager doesn't support copy construction.
explicit SourceManager(const SourceManager&);
- void operator=(const SourceManager&);
+ void operator=(const SourceManager&);
public:
- SourceManager()
- : ExternalSLocEntries(0), LineTable(0), NumLinearScans(0),
+ SourceManager()
+ : ExternalSLocEntries(0), LineTable(0), NumLinearScans(0),
NumBinaryProbes(0) {
clearIDTables();
}
~SourceManager();
-
+
void clearIDTables();
-
+
//===--------------------------------------------------------------------===//
// MainFileID creation and querying methods.
//===--------------------------------------------------------------------===//
/// getMainFileID - Returns the FileID of the main source file.
FileID getMainFileID() const { return MainFileID; }
-
+
/// createMainFileID - Create the FileID for the main source file.
FileID createMainFileID(const FileEntry *SourceFile,
SourceLocation IncludePos) {
@@ -358,15 +358,15 @@ public:
MainFileID = createFileID(SourceFile, IncludePos, SrcMgr::C_User);
return MainFileID;
}
-
+
//===--------------------------------------------------------------------===//
// Methods to create new FileID's and instantiations.
//===--------------------------------------------------------------------===//
-
+
/// createFileID - Create a new FileID that represents the specified file
/// being #included from the specified IncludePosition. This returns 0 on
/// error and translates NULL into standard input.
- /// PreallocateID should be non-zero to specify which a pre-allocated,
+ /// PreallocateID should be non-zero to specify which a pre-allocated,
/// lazily computed source location is being filled in by this operation.
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos,
SrcMgr::CharacteristicKind FileCharacter,
@@ -376,7 +376,7 @@ public:
if (IR == 0) return FileID(); // Error opening file?
return createFileID(IR, IncludePos, FileCharacter, PreallocatedID, Offset);
}
-
+
/// createFileIDForMemBuffer - Create a new FileID that represents the
/// specified memory buffer. This does no caching of the buffer and takes
/// ownership of the MemoryBuffer, so only pass a MemoryBuffer to this once.
@@ -386,7 +386,7 @@ public:
return createFileID(createMemBufferContentCache(Buffer), SourceLocation(),
SrcMgr::C_User, PreallocatedID, Offset);
}
-
+
/// createMainFileIDForMembuffer - Create the FileID for a memory buffer
/// that will represent the FileID for the main source. One example
/// of when this would be used is when the main source is read from STDIN.
@@ -405,31 +405,31 @@ public:
unsigned TokLength,
unsigned PreallocatedID = 0,
unsigned Offset = 0);
-
+
//===--------------------------------------------------------------------===//
// FileID manipulation methods.
//===--------------------------------------------------------------------===//
-
+
/// getBuffer - Return the buffer for the specified FileID.
///
const llvm::MemoryBuffer *getBuffer(FileID FID) const {
return getSLocEntry(FID).getFile().getContentCache()->getBuffer();
}
-
+
/// getFileEntryForID - Returns the FileEntry record for the provided FileID.
const FileEntry *getFileEntryForID(FileID FID) const {
return getSLocEntry(FID).getFile().getContentCache()->Entry;
}
-
+
/// getBufferData - Return a pointer to the start and end of the source buffer
/// data for the specified FileID.
std::pair<const char*, const char*> getBufferData(FileID FID) const;
-
-
+
+
//===--------------------------------------------------------------------===//
// SourceLocation manipulation methods.
//===--------------------------------------------------------------------===//
-
+
/// getFileID - Return the FileID for a SourceLocation. This is a very
/// hot method that is used for all SourceManager queries that start with a
/// SourceLocation object. It is responsible for finding the entry in
@@ -437,14 +437,14 @@ public:
///
FileID getFileID(SourceLocation SpellingLoc) const {
unsigned SLocOffset = SpellingLoc.getOffset();
-
+
// If our one-entry cache covers this offset, just return it.
if (isOffsetInFileID(LastFileIDLookup, SLocOffset))
return LastFileIDLookup;
return getFileIDSlow(SLocOffset);
}
-
+
/// getLocForStartOfFile - Return the source location corresponding to the
/// first byte of the specified file.
SourceLocation getLocForStartOfFile(FileID FID) const {
@@ -453,7 +453,7 @@ public:
unsigned FileOffset = getSLocEntry(FID).getOffset();
return SourceLocation::getFileLoc(FileOffset);
}
-
+
/// getInstantiationLoc - Given a SourceLocation object, return the
/// instantiation location referenced by the ID.
SourceLocation getInstantiationLoc(SourceLocation Loc) const {
@@ -462,18 +462,18 @@ public:
if (Loc.isFileID()) return Loc;
return getInstantiationLocSlowCase(Loc);
}
-
+
/// getImmediateInstantiationRange - Loc is required to be an instantiation
/// location. Return the start/end of the instantiation information.
std::pair<SourceLocation,SourceLocation>
getImmediateInstantiationRange(SourceLocation Loc) const;
-
+
/// getInstantiationRange - Given a SourceLocation object, return the
/// range of tokens covered by the instantiation in the ultimate file.
std::pair<SourceLocation,SourceLocation>
getInstantiationRange(SourceLocation Loc) const;
-
-
+
+
/// getSpellingLoc - Given a SourceLocation object, return the spelling
/// location referenced by the ID. This is the place where the characters
/// that make up the lexed token can be found.
@@ -483,12 +483,12 @@ public:
if (Loc.isFileID()) return Loc;
return getSpellingLocSlowCase(Loc);
}
-
+
/// getImmediateSpellingLoc - Given a SourceLocation object, return the
/// spelling location referenced by the ID. This is the first level down
/// towards the place where the characters that make up the lexed token can be
/// found. This should not generally be used by clients.
- SourceLocation getImmediateSpellingLoc(SourceLocation Loc) const;
+ SourceLocation getImmediateSpellingLoc(SourceLocation Loc) const;
/// getDecomposedLoc - Decompose the specified location into a raw FileID +
/// Offset pair. The first element is the FileID, the second is the
@@ -497,7 +497,7 @@ public:
FileID FID = getFileID(Loc);
return std::make_pair(FID, Loc.getOffset()-getSLocEntry(FID).getOffset());
}
-
+
/// getDecomposedInstantiationLoc - Decompose the specified location into a
/// raw FileID + Offset pair. If the location is an instantiation record,
/// walk through it until we find the final location instantiated.
@@ -505,11 +505,11 @@ public:
getDecomposedInstantiationLoc(SourceLocation Loc) const {
FileID FID = getFileID(Loc);
const SrcMgr::SLocEntry *E = &getSLocEntry(FID);
-
+
unsigned Offset = Loc.getOffset()-E->getOffset();
if (Loc.isFileID())
return std::make_pair(FID, Offset);
-
+
return getDecomposedInstantiationLocSlowCase(E, Offset);
}
@@ -520,29 +520,29 @@ public:
getDecomposedSpellingLoc(SourceLocation Loc) const {
FileID FID = getFileID(Loc);
const SrcMgr::SLocEntry *E = &getSLocEntry(FID);
-
+
unsigned Offset = Loc.getOffset()-E->getOffset();
if (Loc.isFileID())
return std::make_pair(FID, Offset);
return getDecomposedSpellingLocSlowCase(E, Offset);
- }
-
+ }
+
/// getFileOffset - This method returns the offset from the start
/// of the file that the specified SourceLocation represents. This is not very
/// meaningful for a macro ID.
unsigned getFileOffset(SourceLocation SpellingLoc) const {
return getDecomposedLoc(SpellingLoc).second;
}
-
-
+
+
//===--------------------------------------------------------------------===//
// Queries about the code at a SourceLocation.
//===--------------------------------------------------------------------===//
-
+
/// getCharacterData - Return a pointer to the start of the specified location
/// in the appropriate spelling MemoryBuffer.
const char *getCharacterData(SourceLocation SL) const;
-
+
/// getColumnNumber - Return the column # for the specified file position.
/// This is significantly cheaper to compute than the line number. This
/// returns zero if the column number isn't known. This may only be called on
@@ -551,24 +551,24 @@ public:
unsigned getColumnNumber(FileID FID, unsigned FilePos) const;
unsigned getSpellingColumnNumber(SourceLocation Loc) const;
unsigned getInstantiationColumnNumber(SourceLocation Loc) const;
-
-
+
+
/// getLineNumber - Given a SourceLocation, return the spelling line number
/// for the position indicated. This requires building and caching a table of
/// line offsets for the MemoryBuffer, so this is not cheap: use only when
/// about to emit a diagnostic.
unsigned getLineNumber(FileID FID, unsigned FilePos) const;
-
+
unsigned getInstantiationLineNumber(SourceLocation Loc) const;
unsigned getSpellingLineNumber(SourceLocation Loc) const;
-
+
/// Return the filename or buffer identifier of the buffer the location is in.
/// Note that this name does not respect #line directives. Use getPresumedLoc
/// for normal clients.
const char *getBufferName(SourceLocation Loc) const;
-
+
/// getFileCharacteristic - return the file characteristic of the specified
- /// source location, indicating whether this is a normal file, a system
+ /// source location, indicating whether this is a normal file, a system
/// header, or an "implicit extern C" system header.
///
/// This state can be modified with flags on GNU linemarker directives like:
@@ -576,7 +576,7 @@ public:
/// which changes all source locations in the current file after that to be
/// considered to be from a system header.
SrcMgr::CharacteristicKind getFileCharacteristic(SourceLocation Loc) const;
-
+
/// getPresumedLoc - This method returns the "presumed" location of a
/// SourceLocation specifies. A "presumed location" can be modified by #line
/// or GNU line marker directives. This provides a view on the data that a
@@ -585,44 +585,44 @@ public:
/// Note that a presumed location is always given as the instantiation point
/// of an instantiation location, not at the spelling location.
PresumedLoc getPresumedLoc(SourceLocation Loc) const;
-
+
/// isFromSameFile - Returns true if both SourceLocations correspond to
/// the same file.
bool isFromSameFile(SourceLocation Loc1, SourceLocation Loc2) const {
return getFileID(Loc1) == getFileID(Loc2);
}
-
+
/// isFromMainFile - Returns true if the file of provided SourceLocation is
/// the main file.
bool isFromMainFile(SourceLocation Loc) const {
return getFileID(Loc) == getMainFileID();
- }
-
+ }
+
/// isInSystemHeader - Returns if a SourceLocation is in a system header.
bool isInSystemHeader(SourceLocation Loc) const {
return getFileCharacteristic(Loc) != SrcMgr::C_User;
}
-
+
/// isInExternCSystemHeader - Returns if a SourceLocation is in an "extern C"
/// system header.
bool isInExternCSystemHeader(SourceLocation Loc) const {
return getFileCharacteristic(Loc) == SrcMgr::C_ExternCSystem;
}
-
+
//===--------------------------------------------------------------------===//
// Line Table Manipulation Routines
//===--------------------------------------------------------------------===//
-
+
/// getLineTableFilenameID - Return the uniqued ID for the specified filename.
- ///
+ ///
unsigned getLineTableFilenameID(const char *Ptr, unsigned Len);
-
+
/// AddLineNote - Add a line note to the line table for the FileID and offset
/// specified by Loc. If FilenameID is -1, it is considered to be
/// unspecified.
void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID);
void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID,
- bool IsFileEntry, bool IsFileExit,
+ bool IsFileEntry, bool IsFileExit,
bool IsSystemHeader, bool IsExternCHeader);
/// \brief Determine if the source manager has a line table.
@@ -641,7 +641,7 @@ public:
/// be based upon the first inclusion.
SourceLocation getLocation(const FileEntry *SourceFile,
unsigned Line, unsigned Col) const;
-
+
/// \brief Determines the order of 2 source locations in the translation unit.
///
/// \returns true if LHS source location comes before RHS, false otherwise.
@@ -657,22 +657,22 @@ public:
///
void PrintStats() const;
- // Iteration over the source location entry table.
+ // Iteration over the source location entry table.
typedef std::vector<SrcMgr::SLocEntry>::const_iterator sloc_entry_iterator;
- sloc_entry_iterator sloc_entry_begin() const {
- return SLocEntryTable.begin();
+ sloc_entry_iterator sloc_entry_begin() const {
+ return SLocEntryTable.begin();
}
- sloc_entry_iterator sloc_entry_end() const {
- return SLocEntryTable.end();
+ sloc_entry_iterator sloc_entry_end() const {
+ return SLocEntryTable.end();
}
unsigned sloc_entry_size() const { return SLocEntryTable.size(); }
const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const {
assert(FID.ID < SLocEntryTable.size() && "Invalid id");
- if (ExternalSLocEntries &&
+ if (ExternalSLocEntries &&
FID.ID < SLocEntryLoaded.size() &&
!SLocEntryLoaded[FID.ID])
ExternalSLocEntries->ReadSLocEntry(FID.ID);
@@ -698,14 +698,14 @@ private:
const SrcMgr::SLocEntry &Entry = getSLocEntry(FID);
// If the entry is after the offset, it can't contain it.
if (SLocOffset < Entry.getOffset()) return false;
-
+
// If this is the last entry than it does. Otherwise, the entry after it
// has to not include it.
if (FID.ID+1 == SLocEntryTable.size()) return true;
return SLocOffset < getSLocEntry(FileID::get(FID.ID+1)).getOffset();
}
-
+
/// createFileID - Create a new fileID for the specified ContentCache and
/// include position. This works regardless of whether the ContentCache
/// corresponds to a file or some other input source.
@@ -714,15 +714,15 @@ private:
SrcMgr::CharacteristicKind DirCharacter,
unsigned PreallocatedID = 0,
unsigned Offset = 0);
-
+
const SrcMgr::ContentCache *
getOrCreateContentCache(const FileEntry *SourceFile);
/// createMemBufferContentCache - Create a new ContentCache for the specified
/// memory buffer.
- const SrcMgr::ContentCache*
+ const SrcMgr::ContentCache*
createMemBufferContentCache(const llvm::MemoryBuffer *Buf);
-
+
FileID getFileIDSlow(unsigned SLocOffset) const;
SourceLocation getInstantiationLocSlowCase(SourceLocation Loc) const;
@@ -730,7 +730,7 @@ private:
std::pair<FileID, unsigned>
getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
- unsigned Offset) const;
+ unsigned Offset) const;
std::pair<FileID, unsigned>
getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
unsigned Offset) const;
diff --git a/include/clang/Basic/SourceManagerInternals.h b/include/clang/Basic/SourceManagerInternals.h
index 0bcb68e460..258989cb77 100644
--- a/include/clang/Basic/SourceManagerInternals.h
+++ b/include/clang/Basic/SourceManagerInternals.h
@@ -28,22 +28,22 @@ namespace clang {
struct LineEntry {
/// FileOffset - The offset in this file that the line entry occurs at.
unsigned FileOffset;
-
+
/// LineNo - The presumed line number of this line entry: #line 4.
unsigned LineNo;
-
+
/// FilenameID - The ID of the filename identified by this line entry:
/// #line 4 "foo.c". This is -1 if not specified.
int FilenameID;
-
- /// Flags - Set the 0 if no flags, 1 if a system header,
+
+ /// Flags - Set the 0 if no flags, 1 if a system header,
SrcMgr::CharacteristicKind FileKind;
-
+
/// IncludeOffset - This is the offset of the virtual include stack location,
/// which is manipulated by GNU linemarker directives. If this is 0 then
/// there is no virtual #includer.
unsigned IncludeOffset;
-
+
static LineEntry get(unsigned Offs, unsigned Line, int Filename,
SrcMgr::CharacteristicKind FileKind,
unsigned IncludeOffset) {
@@ -70,7 +70,7 @@ inline bool operator<(const LineEntry &E, unsigned Offset) {
inline bool operator<(unsigned Offset, const LineEntry &E) {
return Offset < E.FileOffset;
}
-
+
/// LineTableInfo - This class is used to hold and unique data used to
/// represent #line information.
class LineTableInfo {
@@ -81,22 +81,22 @@ class LineTableInfo {
/// to string.
llvm::StringMap<unsigned, llvm::BumpPtrAllocator> FilenameIDs;
std::vector<llvm::StringMapEntry<unsigned>*> FilenamesByID;
-
+
/// LineEntries - This is a map from FileIDs to a list of line entries (sorted
/// by the offset they occur in the file.
std::map<unsigned, std::vector<LineEntry> > LineEntries;
public:
LineTableInfo() {
}
-
+
void clear() {
FilenameIDs.clear();
FilenamesByID.clear();
LineEntries.clear();
}
-
+
~LineTableInfo() {}
-
+
unsigned getLineTableFilenameID(const char *Ptr, unsigned Len);
const char *getFilename(unsigned ID) const {
assert(ID < FilenamesByID.size() && "Invalid FilenameID");
@@ -110,7 +110,7 @@ public:
unsigned LineNo, int FilenameID,
unsigned EntryExit, SrcMgr::CharacteristicKind FileKind);
-
+
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
const LineEntry *FindNearestLineEntry(unsigned FID, unsigned Offset);
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index f48d1a3a60..f8dca87a26 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -34,7 +34,7 @@ class SourceLocation;
class SourceManager;
class LangOptions;
namespace Builtin { struct Info; }
-
+
/// TargetInfo - This class exposes information about the current target.
///
class TargetInfo {
@@ -61,8 +61,8 @@ protected:
// TargetInfo Constructor. Default initializes all fields.
TargetInfo(const std::string &T);
-
-public:
+
+public:
/// CreateTargetInfo - Return the target info object for the specified target
/// triple.
static TargetInfo* CreateTargetInfo(const std::string &Triple);
@@ -105,35 +105,35 @@ public:
uint64_t getPointerAlign(unsigned AddrSpace) const {
return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
}
-
+
/// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
/// target, in bits.
unsigned getBoolWidth(bool isWide = false) const { return 8; } // FIXME
unsigned getBoolAlign(bool isWide = false) const { return 8; } // FIXME
-
+
unsigned getCharWidth() const { return 8; } // FIXME
unsigned getCharAlign() const { return 8; } // FIXME
-
+
/// getShortWidth/Align - Return the size of 'signed short' and
- /// 'unsigned short' for this target, in bits.
+ /// 'unsigned short' for this target, in bits.
unsigned getShortWidth() const { return 16; } // FIXME
unsigned getShortAlign() const { return 16; } // FIXME
-
+
/// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
/// this target, in bits.
unsigned getIntWidth() const { return IntWidth; }
unsigned getIntAlign() const { return IntAlign; }
-
+
/// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
/// for this target, in bits.
unsigned getLongWidth() const { return LongWidth; }
unsigned getLongAlign() const { return LongAlign; }
-
+
/// getLongLongWidth/Align - Return the size of 'signed long long' and
/// 'unsigned long long' for this target, in bits.
unsigned getLongLongWidth() const { return LongLongWidth; }
unsigned getLongLongAlign() const { return LongLongAlign; }
-
+
/// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
/// bits.
unsigned getWCharWidth() const { return WCharWidth; }
@@ -166,13 +166,13 @@ public:
const llvm::fltSemantics &getLongDoubleFormat() const {
return *LongDoubleFormat;
}
-
+
/// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
- /// target, in bits.
+ /// target, in bits.
unsigned getIntMaxTWidth() const {
return IntMaxTWidth;
}
-
+
/// getUserLabelPrefix - This returns the default value of the
/// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
/// default. On most platforms this is "_", but it is "" on some, and "." on
@@ -180,22 +180,22 @@ public:
const char *getUserLabelPrefix() const {
return UserLabelPrefix;
}
-
+
/// getTypeName - Return the user string for the specified integer type enum.
/// For example, SignedShort -> "short".
static const char *getTypeName(IntType T);
-
+
///===---- Other target property query methods --------------------------===//
-
+
/// getTargetDefines - Appends the target-specific #define values for this
/// target set to the specified buffer.
virtual void getTargetDefines(const LangOptions &Opts,
std::vector<char> &DefineBuffer) const = 0;
-
+
/// getTargetBuiltins - Return information about target-specific builtins for
/// the current primary target, and info about which builtins are non-portable
/// across the current set of primary and secondary targets.
- virtual void getTargetBuiltins(const Builtin::Info *&Records,
+ virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const = 0;
/// getVAListDeclaration - Return the declaration to use for
@@ -210,7 +210,7 @@ public:
// getNormalizedGCCRegisterName - Returns the "normalized" GCC register name.
// For example, on x86 it will return "ax" when "eax" is passed in.
const char *getNormalizedGCCRegisterName(const char *Name) const;
-
+
struct ConstraintInfo {
enum {
CI_None = 0x00,
@@ -221,7 +221,7 @@ public:
};
unsigned Flags;
int TiedOperand;
-
+
std::string ConstraintStr; // constraint: "=rm"
std::string Name; // Operand name: [foo] with no []'s.
public:
@@ -235,11 +235,11 @@ public:
bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
-
+
/// hasMatchingInput - Return true if this output operand has a matching
/// (tied) input operand.
bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
-
+
/// hasTiedOperand() - Return true if this input operand is a matching
/// constraint that ties it to an output operand. If this returns true,
/// then getTiedOperand will indicate which output operand this is tied to.
@@ -248,12 +248,12 @@ public:
assert(hasTiedOperand() && "Has no tied operand!");
return (unsigned)TiedOperand;
}
-
+
void setIsReadWrite() { Flags |= CI_ReadWrite; }
void setAllowsMemory() { Flags |= CI_AllowsMemory; }
void setAllowsRegister() { Flags |= CI_AllowsRegister; }
void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
-
+
/// setTiedOperand - Indicate that this is an input operand that is tied to
/// the specified output operand. Copy over the various constraint
/// information from the output.
@@ -275,20 +275,20 @@ public:
bool resolveSymbolicName(const char *&Name,
ConstraintInfo *OutputConstraints,
unsigned NumOutputs, unsigned &Index) const;
-
+
virtual std::string convertConstraint(const char Constraint) const {
return std::string(1, Constraint);
}
-
+
// Returns a string of target-specific clobbers, in LLVM format.
virtual const char *getClobbers() const = 0;
-
+
/// getTriple - Return the target triple of the primary target.
const llvm::Triple &getTriple() const {
return Triple;
}
-
+
const char *getTargetDescription() const {
return DescriptionString;
}
@@ -302,30 +302,30 @@ public:
/// getUnicodeStringSymbolPrefix - Get the default symbol prefix to
/// use for string literals.
- virtual const char *getUnicodeStringSymbolPrefix() const {
+ virtual const char *getUnicodeStringSymbolPrefix() const {
return ".str";
}
/// getUnicodeStringSection - Return the section to use for unicode
/// string literals, or 0 if no special section is used.
- virtual const char *getUnicodeStringSection() const {
+ virtual const char *getUnicodeStringSection() const {
return 0;
}
/// getCFStringSection - Return the section to use for CFString
/// literals, or 0 if no special section is used.
- virtual const char *getCFStringSection() const {
+ virtual const char *getCFStringSection() const {
return "__DATA,__cfstring";
}
/// getCFStringDataSection - Return the section to use for the
/// constant string data associated with a CFString literal, or 0 if
/// no special section is used.
- virtual const char *getCFStringDataSection() const {
+ virtual const char *getCFStringDataSection() const {
return "__TEXT,__cstring,cstring_literals";
}
-
-
+
+
/// isValidSectionSpecifier - This is an optional hook that targets can
/// implement to perform semantic checking on attribute((section("foo")))
/// specifiers. In this case, "foo" is passed in to be checked. If the
@@ -342,13 +342,13 @@ public:
/// getDefaultLangOptions - Allow the target to specify default settings for
/// various language options. These may be overridden by command line
- /// options.
+ /// options.
virtual void getDefaultLangOptions(LangOptions &Opts) {}
/// getDefaultFeatures - Get the default set of target features for
/// the \args CPU; this should include all legal feature strings on
/// the target.
- virtual void getDefaultFeatures(const std::string &CPU,
+ virtual void getDefaultFeatures(const std::string &CPU,
llvm::StringMap<bool> &Features) const {
}
@@ -387,11 +387,11 @@ protected:
virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
return PtrDiffType;
}
- virtual void getGCCRegNames(const char * const *&Names,
+ virtual void getGCCRegNames(const char * const *&Names,
unsigned &NumNames) const = 0;
- virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
+ virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
unsigned &NumAliases) const = 0;
- virtual bool validateAsmConstraint(const char *&Name,
+ virtual bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const= 0;
};
diff --git a/include/clang/Basic/TokenKinds.h b/include/clang/Basic/TokenKinds.h
index 62a9e428bf..85dc0671de 100644
--- a/include/clang/Basic/TokenKinds.h
+++ b/include/clang/Basic/TokenKinds.h
@@ -29,7 +29,7 @@ enum TokenKind {
/// PPKeywordKind - This provides a namespace for preprocessor keywords which
/// start with a '#' at the beginning of the line.
enum PPKeywordKind {
-#define PPKEYWORD(X) pp_##X,
+#define PPKEYWORD(X) pp_##X,
#include "clang/Basic/TokenKinds.def"
NUM_PP_KEYWORDS
};
diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h
index 12b74d5147..1871c8f206 100644
--- a/include/clang/CodeGen/ModuleBuilder.h
+++ b/include/clang/CodeGen/ModuleBuilder.h
@@ -26,13 +26,13 @@ namespace clang {
class Diagnostic;
class LangOptions;
class CompileOptions;
-
+
class CodeGenerator : public ASTConsumer {
public:
virtual llvm::Module* GetModule() = 0;
- virtual llvm::Module* ReleaseModule() = 0;
+ virtual llvm::Module* ReleaseModule() = 0;
};
-
+
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
const std::string &ModuleName,
const CompileOptions &CO,
diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h
index ceef189f7b..679704c395 100644
--- a/include/clang/Driver/Action.h
+++ b/include/clang/Driver/Action.h
@@ -26,7 +26,7 @@ namespace clang {
namespace driver {
class Arg;
-/// Action - Represent an abstract compilation step to perform.
+/// Action - Represent an abstract compilation step to perform.
///
/// An action represents an edge in the compilation graph; typically
/// it is a job to transform an input using some tool.
@@ -63,15 +63,15 @@ private:
/// The output type of this action.
types::ID Type;
-
+
ActionList Inputs;
protected:
Action(ActionClass _Kind, types::ID _Type) : Kind(_Kind), Type(_Type) {}
- Action(ActionClass _Kind, Action *Input, types::ID _Type)
+ Action(ActionClass _Kind, Action *Input, types::ID _Type)
: Kind(_Kind), Type(_Type), Inputs(&Input, &Input + 1) {}
- Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
- : Kind(_Kind), Type(_Type), Inputs(_Inputs) {}
+ Action(ActionClass _Kind, const ActionList &_Inputs, types::ID _Type)
+ : Kind(_Kind), Type(_Type), Inputs(_Inputs) {}
public:
virtual ~Action();
@@ -90,7 +90,7 @@ public:
const_iterator begin() const { return Inputs.begin(); }
const_iterator end() const { return Inputs.end(); }
- static bool classof(const Action *) { return true; }
+ static bool classof(const Action *) { return true; }
};
class InputAction : public Action {
@@ -100,8 +100,8 @@ public:
const Arg &getInputArg() const { return Input; }
- static bool classof(const Action *A) {
- return A->getKind() == InputClass;
+ static bool classof(const Action *A) {
+ return A->getKind() == InputClass;
}
static bool classof(const InputAction *) { return true; }
};
@@ -116,8 +116,8 @@ public:
const char *getArchName() const { return ArchName; }
- static bool classof(const Action *A) {
- return A->getKind() == BindArchClass;
+ static bool classof(const Action *A) {
+ return A->getKind() == BindArchClass;
}
static bool classof(const BindArchAction *) { return true; }
};
@@ -128,9 +128,9 @@ protected:
JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type);
public:
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return (A->getKind() >= JobClassFirst &&
- A->getKind() <= JobClassLast);
+ A->getKind() <= JobClassLast);
}
static bool classof(const JobAction *) { return true; }
};
@@ -139,7 +139,7 @@ class PreprocessJobAction : public JobAction {
public:
PreprocessJobAction(Action *Input, types::ID OutputType);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == PreprocessJobClass;
}
static bool classof(const PreprocessJobAction *) { return true; }
@@ -149,7 +149,7 @@ class PrecompileJobAction : public JobAction {
public:
PrecompileJobAction(Action *Input, types::ID OutputType);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == PrecompileJobClass;
}
static bool classof(const PrecompileJobAction *) { return true; }
@@ -159,7 +159,7 @@ class AnalyzeJobAction : public JobAction {
public:
AnalyzeJobAction(Action *Input, types::ID OutputType);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == AnalyzeJobClass;
}
static bool classof(const AnalyzeJobAction *) { return true; }
@@ -169,7 +169,7 @@ class CompileJobAction : public JobAction {
public:
CompileJobAction(Action *Input, types::ID OutputType);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == CompileJobClass;
}
static bool classof(const CompileJobAction *) { return true; }
@@ -179,7 +179,7 @@ class AssembleJobAction : public JobAction {
public:
AssembleJobAction(Action *Input, types::ID OutputType);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == AssembleJobClass;
}
static bool classof(const AssembleJobAction *) { return true; }
@@ -189,7 +189,7 @@ class LinkJobAction : public JobAction {
public:
LinkJobAction(ActionList &Inputs, types::ID Type);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == LinkJobClass;
}
static bool classof(const LinkJobAction *) { return true; }
@@ -199,7 +199,7 @@ class LipoJobAction : public JobAction {
public:
LipoJobAction(ActionList &Inputs, types::ID Type);
- static bool classof(const Action *A) {
+ static bool classof(const Action *A) {
return A->getKind() == LipoJobClass;
}
static bool classof(const LipoJobAction *) { return true; }
diff --git a/include/clang/Driver/Arg.h b/include/clang/Driver/Arg.h
index 6bed2b8cbd..ebf40d45de 100644
--- a/include/clang/Driver/Arg.h
+++ b/include/clang/Driver/Arg.h
@@ -49,7 +49,7 @@ namespace driver {
/// The option this argument is an instance of.
const Option *Opt;
-
+
/// The argument this argument was derived from (during tool chain
/// argument translation), if any.
const Arg *BaseArg;
@@ -66,7 +66,7 @@ namespace driver {
protected:
Arg(ArgClass Kind, const Option *Opt, unsigned Index,
const Arg *BaseArg = 0);
-
+
public:
Arg(const Arg &);
virtual ~Arg();
@@ -74,12 +74,12 @@ namespace driver {
ArgClass getKind() const { return Kind; }
const Option &getOption() const { return *Opt; }
unsigned getIndex() const { return Index; }
-
+
/// getBaseArg - Return the base argument which generated this
/// arg; this is either the argument itself or the argument it was
/// derived from during tool chain specific argument translation.
- const Arg &getBaseArg() const {
- return BaseArg ? *BaseArg : *this;
+ const Arg &getBaseArg() const {
+ return BaseArg ? *BaseArg : *this;
}
void setBaseArg(const Arg *_BaseArg) {
BaseArg = _BaseArg;
@@ -88,14 +88,14 @@ namespace driver {
bool isClaimed() const { return getBaseArg().Claimed; }
/// claim - Set the Arg claimed bit.
-
+
// FIXME: We need to deal with derived arguments and set the bit
// in the original argument; not the derived one.
void claim() const { getBaseArg().Claimed = true; }
virtual unsigned getNumValues() const = 0;
virtual const char *getValue(const ArgList &Args, unsigned N=0) const = 0;
-
+
/// render - Append the argument onto the given array as strings.
virtual void render(const ArgList &Args, ArgStringList &Output) const = 0;
@@ -105,7 +105,7 @@ namespace driver {
/// (e.g., Xlinker).
void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
- static bool classof(const Arg *) { return true; }
+ static bool classof(const Arg *) { return true; }
void dump() const;
@@ -124,8 +124,8 @@ namespace driver {
virtual unsigned getNumValues() const { return 0; }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::FlagClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::FlagClass;
}
static bool classof(const FlagArg *) { return true; }
};
@@ -140,8 +140,8 @@ namespace driver {
virtual unsigned getNumValues() const { return 1; }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::PositionalClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::PositionalClass;
}
static bool classof(const PositionalArg *) { return true; }
};
@@ -157,8 +157,8 @@ namespace driver {
virtual unsigned getNumValues() const { return 1; }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::JoinedClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::JoinedClass;
}
static bool classof(const JoinedArg *) { return true; }
};
@@ -169,7 +169,7 @@ namespace driver {
unsigned NumValues;
public:
- SeparateArg(const Option *Opt, unsigned Index, unsigned NumValues,
+ SeparateArg(const Option *Opt, unsigned Index, unsigned NumValues,
const Arg *BaseArg = 0);
virtual void render(const ArgList &Args, ArgStringList &Output) const;
@@ -177,8 +177,8 @@ namespace driver {
virtual unsigned getNumValues() const { return NumValues; }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::SeparateClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::SeparateClass;
}
static bool classof(const SeparateArg *) { return true; }
};
@@ -193,7 +193,7 @@ namespace driver {
std::vector<std::string> Values;
public:
- CommaJoinedArg(const Option *Opt, unsigned Index, const char *Str,
+ CommaJoinedArg(const Option *Opt, unsigned Index, const char *Str,
const Arg *BaseArg = 0);
virtual void render(const ArgList &Args, ArgStringList &Output) const;
@@ -201,8 +201,8 @@ namespace driver {
virtual unsigned getNumValues() const { return Values.size(); }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::CommaJoinedClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::CommaJoinedClass;
}
static bool classof(const CommaJoinedArg *) { return true; }
};
@@ -211,7 +211,7 @@ namespace driver {
/// values.
class JoinedAndSeparateArg : public Arg {
public:
- JoinedAndSeparateArg(const Option *Opt, unsigned Index,
+ JoinedAndSeparateArg(const Option *Opt, unsigned Index,
const Arg *BaseArg = 0);
virtual void render(const ArgList &Args, ArgStringList &Output) const;
@@ -219,8 +219,8 @@ namespace driver {
virtual unsigned getNumValues() const { return 2; }
virtual const char *getValue(const ArgList &Args, unsigned N=0) const;
- static bool classof(const Arg *A) {
- return A->getKind() == Arg::JoinedAndSeparateClass;
+ static bool classof(const Arg *A) {
+ return A->getKind() == Arg::JoinedAndSeparateClass;
}
static bool classof(const JoinedAndSeparateArg *) { return true; }
};
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
index ea8846a6e9..81588a5994 100644
--- a/include/clang/Driver/ArgList.h
+++ b/include/clang/Driver/ArgList.h
@@ -65,17 +65,17 @@ namespace driver {
const_iterator begin() const { return Args.begin(); }
const_iterator end() const { return Args.end(); }
-
+
const_reverse_iterator rbegin() const { return Args.rbegin(); }
const_reverse_iterator rend() const { return Args.rend(); }
/// hasArg - Does the arg list contain any option matching \arg Id.
///
/// \arg Claim Whether the argument should be claimed, if it exists.
- bool hasArg(options::ID Id, bool Claim=true) const {
+ bool hasArg(options::ID Id, bool Claim=true) const {
return getLastArg(Id, Claim) != 0;
}
- bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const {
+ bool hasArg(options::ID Id0, options::ID Id1, bool Claim=true) const {
return getLastArg(Id0, Id1, Claim) != 0;
}
@@ -105,15 +105,15 @@ namespace driver {
/// AddAllArgs - Render all arguments matching the given ids.
void AddAllArgs(ArgStringList &Output, options::ID Id0) const;
- void AddAllArgs(ArgStringList &Output, options::ID Id0,
+ void AddAllArgs(ArgStringList &Output, options::ID Id0,
options::ID Id1) const;
- void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1,
+ void AddAllArgs(ArgStringList &Output, options::ID Id0, options::ID Id1,
options::ID Id2) const;
/// AddAllArgValues - Render the argument values of all arguments
/// matching the given ids.
void AddAllArgValues(ArgStringList &Output, options::ID Id0) const;
- void AddAllArgValues(ArgStringList &Output, options::ID Id0,
+ void AddAllArgValues(ArgStringList &Output, options::ID Id0,
options::ID Id1) const;
/// AddAllArgsTranslated - Render all the arguments matching the
@@ -123,7 +123,7 @@ namespace driver {
/// \param Joined - If true, render the argument as joined with
/// the option specifier.
void AddAllArgsTranslated(ArgStringList &Output, options::ID Id0,
- const char *Translation,
+ const char *Translation,
bool Joined = false) const;
/// ClaimAllArgs - Claim all arguments which match the given
@@ -168,8 +168,8 @@ namespace driver {
InputArgList(const ArgList &);
~InputArgList();
- virtual const char *getArgString(unsigned Index) const {
- return ArgStrings[Index];
+ virtual const char *getArgString(unsigned Index) const {
+ return ArgStrings[Index];
}
/// getNumInputArgStrings - Return the number of original input
@@ -212,7 +212,7 @@ namespace driver {
~DerivedArgList();
virtual const char *getArgString(unsigned Index) const {
- return BaseArgs.getArgString(Index);
+ return BaseArgs.getArgString(Index);
}
/// @name Arg Synthesis
@@ -226,17 +226,17 @@ namespace driver {
/// MakePositionalArg - Construct a new Positional arg for the
/// given option \arg Id, with the provided \arg Value.
- Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt,
+ Arg *MakePositionalArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const;
/// MakeSeparateArg - Construct a new Positional arg for the
/// given option \arg Id, with the provided \arg Value.
- Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
+ Arg *MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const;
/// MakeJoinedArg - Construct a new Positional arg for the
/// given option \arg Id, with the provided \arg Value.
- Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
+ Arg *MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const;
/// @}
diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h
index 6414ef1369..9e026b91ef 100644
--- a/include/clang/Driver/Compilation.h
+++ b/include/clang/Driver/Compilation.h
@@ -56,7 +56,7 @@ class Compilation {
ArgStringList ResultFiles;
public:
- Compilation(const Driver &D, const ToolChain &DefaultToolChain,
+ Compilation(const Driver &D, const ToolChain &DefaultToolChain,
InputArgList *Args);
~Compilation();
@@ -83,8 +83,8 @@ public:
/// addTempFile - Add a file to remove on exit, and returns its
/// argument.
- const char *addTempFile(const char *Name) {
- TempFiles.push_back(Name);
+ const char *addTempFile(const char *Name) {
+ TempFiles.push_back(Name);
return Name;
}
@@ -99,7 +99,7 @@ public:
///
/// \param IssueErrors - Report failures as errors.
/// \return Whether all files were removed successfully.
- bool CleanupFileList(const ArgStringList &Files,
+ bool CleanupFileList(const ArgStringList &Files,
bool IssueErrors=false) const;
/// PrintJob - Print one job in -### format.
@@ -108,7 +108,7 @@ public:
/// \param J - The job to print.
/// \param Terminator - A string to print at the end of the line.
/// \param Quote - Should separate arguments be quoted.
- void PrintJob(llvm::raw_ostream &OS, const Job &J,
+ void PrintJob(llvm::raw_ostream &OS, const Job &J,
const char *Terminator, bool Quote) const;
/// ExecuteCommand - Execute an actual command.
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index bdc6f3b18a..c18d9e0c46 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -55,11 +55,11 @@ public:
public:
/// The name the driver was invoked as.
std::string Name;
-
+
/// The path the driver executable was in, as invoked from the
/// command line.
std::string Dir;
-
+
/// Default host triple.
std::string DefaultHostTriple;
@@ -75,7 +75,7 @@ public:
/// Whether the driver should follow g++ like behavior.
bool CCCIsCXX : 1;
-
+
/// Echo commands while executing (in -v style).
bool CCCEcho : 1;
@@ -107,7 +107,7 @@ private:
/// Certain options suppress the 'no input files' warning.
bool SuppressMissingInputWarning : 1;
-
+
std::list<std::string> TempFiles;
std::list<std::string> ResultFiles;
@@ -243,7 +243,7 @@ public:
/// \param BaseInput - The original input file that this action was
/// triggered by.
/// \param AtTopLevel - Whether this is a "top-level" action.
- const char *GetNamedOutputPath(Compilation &C,
+ const char *GetNamedOutputPath(Compilation &C,
const JobAction &JA,
const char *BaseInput,
bool AtTopLevel) const;
@@ -253,14 +253,14 @@ public:
///
/// GCC goes to extra lengths here to be a bit more robust.
std::string GetTemporaryPath(const char *Suffix) const;
-
+
/// GetHostInfo - Construct a new host info object for the given
/// host triple.
const HostInfo *GetHostInfo(const char *HostTriple) const;
/// ShouldUseClangCompilar - Should the clang compiler be used to
/// handle this action.
- bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
+ bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
const llvm::Triple &ArchName) const;
/// @}
@@ -272,7 +272,7 @@ public:
/// \return True if the entire string was parsed (9.2), or all
/// groups were parsed (10.3.5extrastuff). HadExtra is true if all
/// groups were parsed but extra characters remain at the end.
- static bool GetReleaseVersion(const char *Str, unsigned &Major,
+ static bool GetReleaseVersion(const char *Str, unsigned &Major,
unsigned &Minor, unsigned &Micro,
bool &HadExtra);
};
diff --git a/include/clang/Driver/DriverDiagnostic.h b/include/clang/Driver/DriverDiagnostic.h
index 705c3422cd..d4a9da7b6d 100644
--- a/include/clang/Driver/DriverDiagnostic.h
+++ b/include/clang/Driver/DriverDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define DRIVERSTART
diff --git a/include/clang/Driver/HostInfo.h b/include/clang/Driver/HostInfo.h
index caffaeca36..bf67c343f3 100644
--- a/include/clang/Driver/HostInfo.h
+++ b/include/clang/Driver/HostInfo.h
@@ -22,7 +22,7 @@ namespace driver {
/// HostInfo - Config information about a particular host which may interact
/// with driver behavior.
-///
+///
/// The host information is used for controlling the parts of the driver which
/// interact with the platform the driver is ostensibly being run from. For
/// testing purposes, the HostInfo used by the driver may differ from the actual
@@ -38,7 +38,7 @@ public:
virtual ~HostInfo();
const Driver &getDriver() const { return TheDriver; }
-
+
const llvm::Triple& getTriple() const { return Triple; }
std::string getArchName() const { return Triple.getArchName(); }
std::string getPlatformName() const { return Triple.getVendorName(); }
@@ -64,23 +64,23 @@ public:
// FIXME: Pin down exactly what the HostInfo is allowed to use Args
// for here. Currently this is for -m32 / -m64 defaulting.
- virtual ToolChain *CreateToolChain(const ArgList &Args,
+ virtual ToolChain *CreateToolChain(const ArgList &Args,
const char *ArchName=0) const = 0;
};
const HostInfo *createAuroraUXHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createDarwinHostInfo(const Driver &D,
+const HostInfo *createDarwinHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createOpenBSDHostInfo(const Driver &D,
+const HostInfo *createOpenBSDHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createFreeBSDHostInfo(const Driver &D,
+const HostInfo *createFreeBSDHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createDragonFlyHostInfo(const Driver &D,
+const HostInfo *createDragonFlyHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createLinuxHostInfo(const Driver &D,
+const HostInfo *createLinuxHostInfo(const Driver &D,
const llvm::Triple& Triple);
-const HostInfo *createUnknownHostInfo(const Driver &D,
+const HostInfo *createUnknownHostInfo(const Driver &D,
const llvm::Triple& Triple);
} // end namespace driver
diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h
index a23babdbb3..906d73128b 100644
--- a/include/clang/Driver/Job.h
+++ b/include/clang/Driver/Job.h
@@ -46,7 +46,7 @@ public:
/// either a piped job or a job list.
void addCommand(Command *C);
- static bool classof(const Job *) { return true; }
+ static bool classof(const Job *) { return true; }
};
/// Command - An executable path/name and argument vector to
@@ -63,7 +63,7 @@ class Command : public Job {
ArgStringList Arguments;
public:
- Command(const Action &_Source, const char *_Executable,
+ Command(const Action &_Source, const char *_Executable,
const ArgStringList &_Arguments);
/// getSource - Return the Action which caused the creation of this job.
@@ -73,8 +73,8 @@ public:
const ArgStringList &getArguments() const { return Arguments; }
- static bool classof(const Job *J) {
- return J->getKind() == CommandClass;
+ static bool classof(const Job *J) {
+ return J->getKind() == CommandClass;
}
static bool classof(const Command *) { return true; }
};
@@ -97,15 +97,15 @@ public:
void addCommand(Command *C) { Commands.push_back(C); }
const list_type &getCommands() const { return Commands; }
-
+
size_type size() const { return Commands.size(); }
iterator begin() { return Commands.begin(); }
const_iterator begin() const { return Commands.begin(); }
iterator end() { return Commands.end(); }
const_iterator end() const { return Commands.end(); }
- static bool classof(const Job *J) {
- return J->getKind() == PipedJobClass;
+ static bool classof(const Job *J) {
+ return J->getKind() == PipedJobClass;
}
static bool classof(const PipedJob *) { return true; }
};
@@ -133,13 +133,13 @@ public:
const_iterator begin() const { return Jobs.begin(); }
iterator end() { return Jobs.end(); }
const_iterator end() const { return Jobs.end(); }
-
- static bool classof(const Job *J) {
- return J->getKind() == JobListClass;
+
+ static bool classof(const Job *J) {
+ return J->getKind() == JobListClass;
}
static bool classof(const JobList *) { return true; }
};
-
+
} // end namespace driver
} // end namespace clang
diff --git a/include/clang/Driver/Option.h b/include/clang/Driver/Option.h
index c59faef897..c70b648216 100644
--- a/include/clang/Driver/Option.h
+++ b/include/clang/Driver/Option.h
@@ -24,7 +24,7 @@ namespace driver {
class Arg;
class InputArgList;
class OptionGroup;
-
+
/// Option - Abstract representation for a single form of driver
/// argument.
///
@@ -57,10 +57,10 @@ namespace driver {
options::ID ID;
/// The option name.
- const char *Name;
+ const char *Name;
/// Group this option is a member of, if any.
- const OptionGroup *Group;
+ const OptionGroup *Group;
/// Option that this is an alias for, if any.
const Option *Alias;
@@ -70,7 +70,7 @@ namespace driver {
/// Treat this option like a linker input?
bool LinkerInput : 1;
-
+
/// When rendering as an input, don't render the option.
// FIXME: We should ditch the render/renderAsInput distinction.
@@ -78,18 +78,18 @@ namespace driver {
/// Always render this option as separate form its value.
bool ForceSeparateRender : 1;
-
+
/// Always render this option joined with its value.
- bool ForceJoinedRender : 1;
+ bool ForceJoinedRender : 1;
/// This option is only consumed by the driver.
- bool DriverOption : 1;
+ bool DriverOption : 1;
/// This option should not report argument unused errors.
- bool NoArgumentUnused : 1;
+ bool NoArgumentUnused : 1;
protected:
- Option(OptionClass Kind, options::ID ID, const char *Name,
+ Option(OptionClass Kind, options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
public:
virtual ~Option();
@@ -108,13 +108,13 @@ namespace driver {
bool hasNoOptAsInput() const { return NoOptAsInput; }
void setNoOptAsInput(bool Value) { NoOptAsInput = Value; }
-
+
bool hasForceSeparateRender() const { return ForceSeparateRender; }
void setForceSeparateRender(bool Value) { ForceSeparateRender = Value; }
-
+
bool hasForceJoinedRender() const { return ForceJoinedRender; }
void setForceJoinedRender(bool Value) { ForceJoinedRender = Value; }
-
+
bool isDriverOption() const { return DriverOption; }
void setDriverOption(bool Value) { DriverOption = Value; }
@@ -125,7 +125,7 @@ namespace driver {
/// getUnaliasedOption - Return the final option this option
/// aliases (itself, if the option has no alias).
- const Option *getUnaliasedOption() const {
+ const Option *getUnaliasedOption() const {
if (Alias) return Alias->getUnaliasedOption();
return this;
}
@@ -149,12 +149,12 @@ namespace driver {
/// Index to the position where argument parsing should resume
/// (even if the argument is missing values).
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const = 0;
-
+
void dump() const;
static bool classof(const Option *) { return true; }
};
-
+
/// OptionGroup - A set of options which are can be handled uniformly
/// by the driver.
class OptionGroup : public Option {
@@ -163,14 +163,14 @@ namespace driver {
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::GroupClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::GroupClass;
}
static bool classof(const OptionGroup *) { return true; }
};
-
+
// Dummy option classes.
-
+
/// InputOption - Dummy option class for representing driver inputs.
class InputOption : public Option {
public:
@@ -178,8 +178,8 @@ namespace driver {
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::InputClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::InputClass;
}
static bool classof(const InputOption *) { return true; }
};
@@ -191,8 +191,8 @@ namespace driver {
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::UnknownClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::UnknownClass;
}
static bool classof(const UnknownOption *) { return true; }
};
@@ -201,52 +201,52 @@ namespace driver {
class FlagOption : public Option {
public:
- FlagOption(options::ID ID, const char *Name, const OptionGroup *Group,
+ FlagOption(options::ID ID, const char *Name, const OptionGroup *Group,
const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::FlagClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::FlagClass;
}
static bool classof(const FlagOption *) { return true; }
};
class JoinedOption : public Option {
public:
- JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group,
+ JoinedOption(options::ID ID, const char *Name, const OptionGroup *Group,
const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::JoinedClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::JoinedClass;
}
static bool classof(const JoinedOption *) { return true; }
};
class SeparateOption : public Option {
public:
- SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group,
+ SeparateOption(options::ID ID, const char *Name, const OptionGroup *Group,
const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::SeparateClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::SeparateClass;
}
static bool classof(const SeparateOption *) { return true; }
};
class CommaJoinedOption : public Option {
public:
- CommaJoinedOption(options::ID ID, const char *Name,
+ CommaJoinedOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::CommaJoinedClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::CommaJoinedClass;
}
static bool classof(const CommaJoinedOption *) { return true; }
};
@@ -259,15 +259,15 @@ namespace driver {
unsigned NumArgs;
public:
- MultiArgOption(options::ID ID, const char *Name, const OptionGroup *Group,
+ MultiArgOption(options::ID ID, const char *Name, const OptionGroup *Group,
const Option *Alias, unsigned NumArgs);
unsigned getNumArgs() const { return NumArgs; }
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::MultiArgClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::MultiArgClass;
}
static bool classof(const MultiArgOption *) { return true; }
};
@@ -276,13 +276,13 @@ namespace driver {
/// prefixes its (non-empty) value, or is follwed by a value.
class JoinedOrSeparateOption : public Option {
public:
- JoinedOrSeparateOption(options::ID ID, const char *Name,
+ JoinedOrSeparateOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::JoinedOrSeparateClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::JoinedOrSeparateClass;
}
static bool classof(const JoinedOrSeparateOption *) { return true; }
};
@@ -291,13 +291,13 @@ namespace driver {
/// value and is followed by another value.
class JoinedAndSeparateOption : public Option {
public:
- JoinedAndSeparateOption(options::ID ID, const char *Name,
+ JoinedAndSeparateOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
- static bool classof(const Option *O) {
- return O->getKind() == Option::JoinedAndSeparateClass;
+ static bool classof(const Option *O) {
+ return O->getKind() == Option::JoinedAndSeparateClass;
}
static bool classof(const JoinedAndSeparateOption *) { return true; }
};
diff --git a/include/clang/Driver/Options.h b/include/clang/Driver/Options.h
index 8b959d369c..7fcaf3f497 100644
--- a/include/clang/Driver/Options.h
+++ b/include/clang/Driver/Options.h
@@ -24,7 +24,7 @@ namespace options {
#undef OPTION
};
}
-
+
class Arg;
class InputArgList;
class Option;
@@ -36,7 +36,7 @@ namespace options {
/// few options will be needed at runtime; the OptTable class
/// maintains enough information to parse command lines without
/// instantiating Options, while letting other parts of the driver
- /// still use Option instances where convient.
+ /// still use Option instances where convient.
class OptTable {
/// The table of options which have been constructed, indexed by
/// option::ID - 1.
diff --git a/include/clang/Driver/Tool.h b/include/clang/Driver/Tool.h
index d8b37e9ead..8a89f01e0f 100644
--- a/include/clang/Driver/Tool.h
+++ b/include/clang/Driver/Tool.h
@@ -22,7 +22,7 @@ namespace driver {
class Job;
class JobAction;
class ToolChain;
-
+
typedef llvm::SmallVector<InputInfo, 4> InputInfoList;
/// Tool - Information on a specific compilation tool.
@@ -57,9 +57,9 @@ public:
/// linker, then this is the final output name of the linked image.
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const = 0;
};
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index d3d43c2588..fc89e95cd7 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -38,9 +38,9 @@ class LangOptions;
// implementation is still incomplete.
ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS);
-// AST XML-printer: prints out the AST in a XML format
+// AST XML-printer: prints out the AST in a XML format
// The output is intended to be in a format such that
-// clang or any other tool could re-parse the output back into the same AST,
+// clang or any other tool could re-parse the output back into the same AST,
// but the implementation is still incomplete.
ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS);
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index d41549ec3e..3b72c37bcd 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -43,7 +43,7 @@ class ASTUnit {
ASTUnit(const ASTUnit&); // do not implement
ASTUnit &operator=(const ASTUnit &); // do not implement
ASTUnit();
-
+
public:
~ASTUnit();
@@ -52,13 +52,13 @@ public:
const Preprocessor &getPreprocessor() const { return *PP.get(); }
Preprocessor &getPreprocessor() { return *PP.get(); }
-
+
const ASTContext &getASTContext() const { return *Ctx.get(); }
ASTContext &getASTContext() { return *Ctx.get(); }
const Diagnostic &getDiagnostic() const { return *Diags.get(); }
Diagnostic &getDiagnostic() { return *Diags.get(); }
-
+
FileManager &getFileManager();
const std::string &getOriginalSourceFileName();
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h
index 1eaa958995..4092724372 100644
--- a/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/include/clang/Frontend/CommandLineSourceLoc.h
@@ -34,21 +34,21 @@ namespace llvm {
///
/// Source locations are of the form filename:line:column.
template<>
- class parser<clang::ParsedSourceLocation>
+ class parser<clang::ParsedSourceLocation>
: public basic_parser<clang::ParsedSourceLocation> {
public:
- bool parse(Option &O, const char *ArgName,
+ bool parse(Option &O, const char *ArgName,
const std::string &ArgValue,
clang::ParsedSourceLocation &Val);
};
- bool
+ bool
parser<clang::ParsedSourceLocation>::
- parse(Option &O, const char *ArgName, const std::string &ArgValue,
+ parse(Option &O, const char *ArgName, const std::string &ArgValue,
clang::ParsedSourceLocation &Val) {
using namespace clang;
- const char *ExpectedFormat
+ const char *ExpectedFormat
= "source location must be of the form filename:line:column";
std::string::size_type SecondColon = ArgValue.rfind(':');
if (SecondColon == std::string::npos) {
@@ -56,7 +56,7 @@ namespace llvm {
return true;
}
char *EndPtr;
- long Column
+ long Column
= std::strtol(ArgValue.c_str() + SecondColon + 1, &EndPtr, 10);
if (EndPtr != ArgValue.c_str() + ArgValue.size()) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
@@ -73,7 +73,7 @@ namespace llvm {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
-
+
Val.FileName = ArgValue.substr(0, FirstColon);
Val.Line = Line;
Val.Column = Column;
diff --git a/include/clang/Frontend/CompileOptions.h b/include/clang/Frontend/CompileOptions.h
index 75dec00f74..508af537b1 100644
--- a/include/clang/Frontend/CompileOptions.h
+++ b/include/clang/Frontend/CompileOptions.h
@@ -67,7 +67,7 @@ public:
Inlining = NoInlining;
DisableRedZone = 0;
NoImplicitFloat = 0;
- }
+ }
};
} // end namespace clang
diff --git a/include/clang/Frontend/DocumentXML.h b/include/clang/Frontend/DocumentXML.h
index 4ed11e153c..31cffd0be9 100644
--- a/include/clang/Frontend/DocumentXML.h
+++ b/include/clang/Frontend/DocumentXML.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the XML document class, which provides the means to
+// This file implements the XML document class, which provides the means to
// dump out the AST in a XML form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
@@ -32,10 +32,9 @@ class NamedDecl;
class FunctionDecl;
class ASTContext;
class LabelStmt;
-
-//---------------------------------------------------------
-namespace XML
-{
+
+//---------------------------------------------------------
+namespace XML {
// id maps:
template<class T>
struct IdMap : llvm::DenseMap<T, unsigned> {};
@@ -47,9 +46,8 @@ namespace XML
struct IdMap<std::string> : std::map<std::string, unsigned> {};
}
-//---------------------------------------------------------
-class DocumentXML
-{
+//---------------------------------------------------------
+class DocumentXML {
public:
DocumentXML(const std::string& rootName, llvm::raw_ostream& out);
@@ -62,24 +60,22 @@ public:
DocumentXML& addSubNode(const std::string& name); // also enters the sub node, returns *this
DocumentXML& toParent(); // returns *this
- void addAttribute(const char* pName, const QualType& pType);
+ void addAttribute(const char* pName, const QualType& pType);
void addAttribute(const char* pName, bool value);
template<class T>
- void addAttribute(const char* pName, const T* value)
- {
+ void addAttribute(const char* pName, const T* value) {
addPtrAttribute(pName, value);
}
template<class T>
- void addAttribute(const char* pName, T* value)
- {
+ void addAttribute(const char* pName, T* value) {
addPtrAttribute(pName, value);
}
template<class T>
void addAttribute(const char* pName, const T& value);
-
+
template<class T>
void addAttributeOptional(const char* pName, const T& value);
@@ -114,7 +110,7 @@ private:
void Indent();
// forced pointer dispatch:
- void addPtrAttribute(const char* pName, const Type* pType);
+ void addPtrAttribute(const char* pName, const Type* pType);
void addPtrAttribute(const char* pName, const NamedDecl* D);
void addPtrAttribute(const char* pName, const DeclContext* D);
void addPtrAttribute(const char* pName, const NamespaceDecl* D); // disambiguation
@@ -141,42 +137,37 @@ private:
//--------------------------------------------------------- inlines
-inline void DocumentXML::initialize(ASTContext &Context)
-{
- Ctx = &Context;
+inline void DocumentXML::initialize(ASTContext &Context) {
+ Ctx = &Context;
}
-//---------------------------------------------------------
+//---------------------------------------------------------
template<class T>
-inline void DocumentXML::addAttribute(const char* pName, const T& value)
-{
+inline void DocumentXML::addAttribute(const char* pName, const T& value) {
Out << ' ' << pName << "=\"" << value << "\"";
}
-//---------------------------------------------------------
-inline void DocumentXML::addPtrAttribute(const char* pName, const char* text)
-{
+//---------------------------------------------------------
+inline void DocumentXML::addPtrAttribute(const char* pName, const char* text) {
Out << ' ' << pName << "=\"" << text << "\"";
}
-//---------------------------------------------------------
-inline void DocumentXML::addAttribute(const char* pName, bool value)
-{
+//---------------------------------------------------------
+inline void DocumentXML::addAttribute(const char* pName, bool value) {
addPtrAttribute(pName, value ? "1" : "0");
}
-//---------------------------------------------------------
+//---------------------------------------------------------
template<class T>
-inline void DocumentXML::addAttributeOptional(const char* pName, const T& value)
-{
- if (!isDefault(value))
- {
+inline void DocumentXML::addAttributeOptional(const char* pName,
+ const T& value) {
+ if (!isDefault(value)) {
addAttribute(pName, value);
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
-} //namespace clang
+} //namespace clang
#endif //LLVM_CLANG_DOCUMENTXML_H
diff --git a/include/clang/Frontend/FixItRewriter.h b/include/clang/Frontend/FixItRewriter.h
index 7fcd682bf6..fac87afade 100644
--- a/include/clang/Frontend/FixItRewriter.h
+++ b/include/clang/Frontend/FixItRewriter.h
@@ -51,7 +51,7 @@ class FixItRewriter : public DiagnosticClient {
unsigned NumFailures;
/// \brief Locations at which we should perform fix-its.
- ///
+ ///
/// When empty, perform fix-it modifications everywhere.
llvm::SmallVector<RequestedSourceLocation, 4> FixItLocations;
@@ -72,7 +72,7 @@ public:
/// \brief Write the modified source file.
///
/// \returns true if there was an error, false otherwise.
- bool WriteFixedFile(const std::string &InFileName,
+ bool WriteFixedFile(const std::string &InFileName,
const std::string &OutFileName = std::string());
/// IncludeInDiagnosticCounts - This method (whose default implementation
diff --git a/include/clang/Frontend/FrontendDiagnostic.h b/include/clang/Frontend/FrontendDiagnostic.h
index 079abae3ee..a044586a8c 100644
--- a/include/clang/Frontend/FrontendDiagnostic.h
+++ b/include/clang/Frontend/FrontendDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define FRONTENDSTART
diff --git a/include/clang/Frontend/ManagerRegistry.h b/include/clang/Frontend/ManagerRegistry.h
index ecab67a3b6..f05cfe6df6 100644
--- a/include/clang/Frontend/ManagerRegistry.h
+++ b/include/clang/Frontend/ManagerRegistry.h
@@ -43,7 +43,7 @@ public:
class RegisterConstraintManager {
public:
RegisterConstraintManager(ConstraintManagerCreator CMC) {
- assert(ManagerRegistry::ConstraintMgrCreator == 0
+ assert(ManagerRegistry::ConstraintMgrCreator == 0
&& "ConstraintMgrCreator already set!");
ManagerRegistry::ConstraintMgrCreator = CMC;
}
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index 92a541ea19..f6efccfe07 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -65,7 +65,7 @@ namespace clang {
typedef uint32_t IdentID;
typedef uint32_t SelectorID;
-
+
/// \brief Describes the various kinds of blocks that occur within
/// a PCH file.
enum BlockIDs {
@@ -106,7 +106,7 @@ namespace clang {
/// TYPE_OFFSET block to determine the offset of that type's
/// corresponding record within the TYPES_BLOCK_ID block.
TYPE_OFFSET = 1,
-
+
/// \brief Record code for the offsets of each decl.
///
/// The DECL_OFFSET constant describes the record that occurs
@@ -182,7 +182,7 @@ namespace clang {
/// \brief Record code for the array of locally-scoped external
/// declarations.
LOCALLY_SCOPED_EXTERNAL_DECLS = 11,
-
+
/// \brief Record code for the table of offsets into the
/// Objective-C method pool.
SELECTOR_OFFSETS = 12,
@@ -215,7 +215,7 @@ namespace clang {
/// \brief Record code for the original file that was used to
/// generate the precompiled header.
ORIGINAL_FILE_NAME = 19,
-
+
/// \brief Record code for the sorted array of source ranges where
/// comments were encountered in the source code.
COMMENT_RANGES = 20
@@ -243,7 +243,7 @@ namespace clang {
/// ControllingMacro is optional.
SM_HEADER_FILE_INFO = 6
};
-
+
/// \brief Record types used within a preprocessor block.
enum PreprocessorRecordTypes {
// The macros in the PP section are a PP_MACRO_* instance followed by a
@@ -257,7 +257,7 @@ namespace clang {
/// [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars,
/// NumArgs, ArgIdentInfoID* ]
PP_MACRO_FUNCTION_LIKE = 2,
-
+
/// \brief Describes one token.
/// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags]
PP_TOKEN = 3
@@ -333,7 +333,7 @@ namespace clang {
/// \brief The ObjC 'id' type.
PREDEF_TYPE_OBJC_ID = 26,
/// \brief The ObjC 'Class' type.
- PREDEF_TYPE_OBJC_CLASS = 27
+ PREDEF_TYPE_OBJC_CLASS = 27
};
/// \brief The number of predefined type IDs that are reserved for
@@ -627,9 +627,9 @@ namespace clang {
EXPR_BLOCK,
/// \brief A BlockDeclRef record.
EXPR_BLOCK_DECL_REF,
-
+
// Objective-C
-
+
/// \brief An ObjCStringLiteral record.
EXPR_OBJC_STRING_LITERAL,
/// \brief An ObjCEncodeExpr record.
@@ -650,23 +650,23 @@ namespace clang {
EXPR_OBJC_SUPER_EXPR,
/// \brief An ObjCIsa Expr record.
EXPR_OBJC_ISA,
-
- /// \brief An ObjCForCollectionStmt record.
+
+ /// \brief An ObjCForCollectionStmt record.
STMT_OBJC_FOR_COLLECTION,
- /// \brief An ObjCAtCatchStmt record.
+ /// \brief An ObjCAtCatchStmt record.
STMT_OBJC_CATCH,
- /// \brief An ObjCAtFinallyStmt record.
+ /// \brief An ObjCAtFinallyStmt record.
STMT_OBJC_FINALLY,
- /// \brief An ObjCAtTryStmt record.
+ /// \brief An ObjCAtTryStmt record.
STMT_OBJC_AT_TRY,
- /// \brief An ObjCAtSynchronizedStmt record.
+ /// \brief An ObjCAtSynchronizedStmt record.
STMT_OBJC_AT_SYNCHRONIZED,
- /// \brief An ObjCAtThrowStmt record.
+ /// \brief An ObjCAtThrowStmt record.
STMT_OBJC_AT_THROW,
// C++
- /// \brief An CXXOperatorCallExpr record.
+ /// \brief An CXXOperatorCallExpr record.
EXPR_CXX_OPERATOR_CALL
};
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 2ddf13fcf1..6f28a25722 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -66,21 +66,21 @@ struct HeaderFileInfo;
class PCHReaderListener {
public:
virtual ~PCHReaderListener();
-
+
/// \brief Receives the language options.
///
/// \returns true to indicate the options are invalid or false otherwise.
virtual bool ReadLanguageOptions(const LangOptions &LangOpts) {
return false;
}
-
+
/// \brief Receives the target triple.
///
/// \returns true to indicate the target triple is invalid or false otherwise.
virtual bool ReadTargetTriple(const std::string &Triple) {
return false;
}
-
+
/// \brief Receives the contents of the predefines buffer.
///
/// \param PCHPredef The start of the predefines buffer in the PCH
@@ -95,16 +95,16 @@ public:
/// here.
///
/// \returns true to indicate the predefines are invalid or false otherwise.
- virtual bool ReadPredefinesBuffer(const char *PCHPredef,
+ virtual bool ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines) {
return false;
}
-
+
/// \brief Receives a HeaderFileInfo entry.
virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI) {}
-
+
/// \brief Receives __COUNTER__ value.
virtual void ReadCounter(unsigned Value) {}
};
@@ -114,16 +114,16 @@ public:
class PCHValidator : public PCHReaderListener {
Preprocessor &PP;
PCHReader &Reader;
-
+
unsigned NumHeaderInfos;
-
+
public:
PCHValidator(Preprocessor &PP, PCHReader &Reader)
: PP(PP), Reader(Reader), NumHeaderInfos(0) {}
-
+
virtual bool ReadLanguageOptions(const LangOptions &LangOpts);
virtual bool ReadTargetTriple(const std::string &Triple);
- virtual bool ReadPredefinesBuffer(const char *PCHPredef,
+ virtual bool ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines);
@@ -143,8 +143,8 @@ public:
/// The PCH reader provides lazy de-serialization of declarations, as
/// required when traversing the AST. Only those AST nodes that are
/// actually required will be de-serialized.
-class PCHReader
- : public ExternalSemaSource,
+class PCHReader
+ : public ExternalSemaSource,
public IdentifierInfoLookup,
public ExternalIdentifierLookup,
public ExternalSLocEntrySource {
@@ -154,11 +154,11 @@ public:
private:
/// \ brief The receiver of some callbacks invoked by PCHReader.
llvm::OwningPtr<PCHReaderListener> Listener;
-
+
SourceManager &SourceMgr;
FileManager &FileMgr;
Diagnostic &Diags;
-
+
/// \brief The semantic analysis object that will be processing the
/// PCH file and the translation unit that uses it.
Sema *SemaObj;
@@ -203,8 +203,8 @@ private:
const uint32_t *TypeOffsets;
/// \brief Types that have already been loaded from the PCH file.
- ///
- /// When the pointer at index I is non-NULL, the type with
+ ///
+ /// When the pointer at index I is non-NULL, the type with
/// ID = (I + 1) << 3 has already been loaded from the PCH file.
std::vector<Type *> TypesLoaded;
@@ -273,7 +273,7 @@ private:
/// \brief The total number of selectors stored in the PCH file.
unsigned TotalNumSelectors;
- /// \brief A vector containing selectors that have already been loaded.
+ /// \brief A vector containing selectors that have already been loaded.
///
/// This vector is indexed by the Selector ID (-1). NULL selector
/// entries indicate that the particular selector ID has not yet
@@ -282,10 +282,10 @@ private:
/// \brief A sorted array of source ranges containing comments.
SourceRange *Comments;
-
+
/// \brief The number of source ranges in the Comments array.
unsigned NumComments;
-
+
/// \brief The set of external definitions stored in the the PCH
/// file.
llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
@@ -312,11 +312,11 @@ private:
/// \brief Whether this precompiled header is a relocatable PCH file.
bool RelocatablePCH;
-
- /// \brief The system include root to be used when loading the
+
+ /// \brief The system include root to be used when loading the
/// precompiled header.
const char *isysroot;
-
+
/// \brief Mapping from switch-case IDs in the PCH file to
/// switch-case statements.
std::map<unsigned, SwitchCase *> SwitchCaseStmts;
@@ -369,41 +369,41 @@ private:
/// Number of visible decl contexts read/total.
unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
-
- /// \brief When a type or declaration is being loaded from the PCH file, an
- /// instantance of this RAII object will be available on the stack to
+
+ /// \brief When a type or declaration is being loaded from the PCH file, an
+ /// instantance of this RAII object will be available on the stack to
/// indicate when we are in a recursive-loading situation.
class LoadingTypeOrDecl {
PCHReader &Reader;
LoadingTypeOrDecl *Parent;
-
+
LoadingTypeOrDecl(const LoadingTypeOrDecl&); // do not implement
LoadingTypeOrDecl &operator=(const LoadingTypeOrDecl&); // do not implement
-
+
public:
explicit LoadingTypeOrDecl(PCHReader &Reader);
~LoadingTypeOrDecl();
};
friend class LoadingTypeOrDecl;
-
+
/// \brief If we are currently loading a type or declaration, points to the
/// most recent LoadingTypeOrDecl object on the stack.
LoadingTypeOrDecl *CurrentlyLoadingTypeOrDecl;
-
- /// \brief An IdentifierInfo that has been loaded but whose top-level
+
+ /// \brief An IdentifierInfo that has been loaded but whose top-level
/// declarations of the same name have not (yet) been loaded.
struct PendingIdentifierInfo {
IdentifierInfo *II;
llvm::SmallVector<uint32_t, 4> DeclIDs;
};
-
+
/// \brief The set of identifiers that were read while the PCH reader was
- /// (recursively) loading declarations.
- ///
+ /// (recursively) loading declarations.
+ ///
/// The declarations on the identifier chain for these identifiers will be
/// loaded once the recursive loading has completed.
std::deque<PendingIdentifierInfo> PendingIdentifierInfos;
-
+
/// \brief FIXME: document!
llvm::SmallVector<uint64_t, 4> SpecialTypes;
@@ -434,17 +434,17 @@ private:
/// there are differences that the PCH reader can work around, this
/// predefines buffer may contain additional definitions.
std::string SuggestedPredefines;
-
+
void MaybeAddSystemRootToFilename(std::string &Filename);
-
+
PCHReadResult ReadPCHBlock();
- bool CheckPredefinesBuffer(const char *PCHPredef,
+ bool CheckPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID);
bool ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record);
PCHReadResult ReadSourceManagerBlock();
PCHReadResult ReadSLocEntryRecord(unsigned ID);
-
+
bool ParseLanguageOptions(const llvm::SmallVectorImpl<uint64_t> &Record);
QualType ReadTypeRecord(uint64_t Offset);
void LoadedDecl(unsigned Index, Decl *D);
@@ -474,7 +474,7 @@ public:
/// user. This is only used with relocatable PCH files. If non-NULL,
/// a relocatable PCH file will use the default path "/".
PCHReader(Preprocessor &PP, ASTContext *Context, const char *isysroot = 0);
-
+
/// \brief Load the PCH file without using any pre-initialized Preprocessor.
///
/// The necessary information to initialize a Preprocessor later can be
@@ -492,28 +492,28 @@ public:
/// \param isysroot If non-NULL, the system include path specified by the
/// user. This is only used with relocatable PCH files. If non-NULL,
/// a relocatable PCH file will use the default path "/".
- PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
+ PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
Diagnostic &Diags, const char *isysroot = 0);
~PCHReader();
/// \brief Load the precompiled header designated by the given file
/// name.
PCHReadResult ReadPCH(const std::string &FileName);
-
+
/// \brief Set the PCH callbacks listener.
void setListener(PCHReaderListener *listener) {
Listener.reset(listener);
}
-
+
/// \brief Set the Preprocessor to use.
void setPreprocessor(Preprocessor &pp) {
PP = &pp;
}
-
+
/// \brief Sets and initializes the given Context.
void InitializeContext(ASTContext &Context);
- /// \brief Retrieve the name of the original source file name
+ /// \brief Retrieve the name of the original source file name
const std::string &getOriginalSourceFile() { return OriginalFileName; }
/// \brief Retrieve the name of the original source file name
@@ -533,7 +533,7 @@ public:
/// replaced with the sorted set of source ranges corresponding to
/// comments in the source code.
virtual void ReadComments(std::vector<SourceRange> &Comments);
-
+
/// \brief Resolve a type ID into a type, potentially building a new
/// type.
virtual QualType GetType(pch::TypeID ID);
@@ -619,14 +619,14 @@ public:
///
/// \returns a pair of Objective-C methods lists containing the
/// instance and factory methods, respectively, with this selector.
- virtual std::pair<ObjCMethodList, ObjCMethodList>
+ virtual std::pair<ObjCMethodList, ObjCMethodList>
ReadMethodPool(Selector Sel);
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
- void SetGloballyVisibleDecls(IdentifierInfo *II,
+ void SetGloballyVisibleDecls(IdentifierInfo *II,
const llvm::SmallVectorImpl<uint32_t> &DeclIDs,
bool Nonrecursive = false);
-
+
/// \brief Report a diagnostic.
DiagnosticBuilder Diag(unsigned DiagID);
@@ -634,11 +634,11 @@ public:
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
IdentifierInfo *DecodeIdentifierInfo(unsigned Idx);
-
+
IdentifierInfo *GetIdentifierInfo(const RecordData &Record, unsigned &Idx) {
return DecodeIdentifierInfo(Record[Idx++]);
}
-
+
virtual IdentifierInfo *GetIdentifier(unsigned ID) {
return DecodeIdentifierInfo(ID);
}
@@ -647,7 +647,7 @@ public:
virtual void ReadSLocEntry(unsigned ID);
Selector DecodeSelector(unsigned Idx);
-
+
Selector GetSelector(const RecordData &Record, unsigned &Idx) {
return DecodeSelector(Record[Idx++]);
}
@@ -670,13 +670,13 @@ public:
/// \brief ReadDeclExpr - Reads an expression from the current decl cursor.
Expr *ReadDeclExpr();
-
+
/// \brief ReadTypeExpr - Reads an expression from the current type cursor.
Expr *ReadTypeExpr();
/// \brief Reads a statement from the specified cursor.
Stmt *ReadStmt(llvm::BitstreamCursor &Cursor);
-
+
/// \brief Read a statement from the current DeclCursor.
Stmt *ReadDeclStmt() {
return ReadStmt(DeclsCursor);
@@ -741,16 +741,16 @@ public:
struct SavedStreamPosition {
explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
: Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
-
+
~SavedStreamPosition() {
Cursor.JumpToBit(Offset);
}
-
+
private:
llvm::BitstreamCursor &Cursor;
uint64_t Offset;
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
index 3bab9b998b..22341fb9c5 100644
--- a/include/clang/Frontend/PCHWriter.h
+++ b/include/clang/Frontend/PCHWriter.h
@@ -98,21 +98,21 @@ private:
/// discovery), starting at 1. An ID of zero refers to a NULL
/// IdentifierInfo.
llvm::DenseMap<const IdentifierInfo *, pch::IdentID> IdentifierIDs;
-
+
/// \brief Offsets of each of the identifier IDs into the identifier
/// table.
std::vector<uint32_t> IdentifierOffsets;
/// \brief Map that provides the ID numbers of each Selector.
llvm::DenseMap<Selector, pch::SelectorID> SelectorIDs;
-
+
/// \brief Offset of each selector within the method pool/selector
/// table, indexed by the Selector ID (-1).
std::vector<uint32_t> SelectorOffsets;
/// \brief A vector of all Selectors (ordered by ID).
std::vector<Selector> SelVector;
-
+
/// \brief Offsets of each of the macro identifiers into the
/// bitstream.
///
@@ -141,7 +141,7 @@ private:
/// \brief Mapping from SwitchCase statements to IDs.
std::map<SwitchCase *, unsigned> SwitchCaseIDs;
-
+
/// \brief Mapping from LabelStmt statements to IDs.
std::map<LabelStmt *, unsigned> LabelIDs;
@@ -163,7 +163,7 @@ private:
void WriteMetadata(ASTContext &Context, const char *isysroot);
void WriteLanguageOptions(const LangOptions &LangOpts);
void WriteStatCache(MemorizeStatCalls &StatCalls, const char* isysroot);
- void WriteSourceManagerBlock(SourceManager &SourceMgr,
+ void WriteSourceManagerBlock(SourceManager &SourceMgr,
const Preprocessor &PP,
const char* isysroot);
void WritePreprocessor(const Preprocessor &PP);
@@ -172,7 +172,7 @@ private:
void WriteTypesBlock(ASTContext &Context);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
-
+
void WriteDeclsBlock(ASTContext &Context);
void WriteMethodPool(Sema &SemaRef);
void WriteIdentifierTable(Preprocessor &PP);
@@ -180,12 +180,12 @@ private:
unsigned ParmVarDeclAbbrev;
void WriteDeclsBlockAbbrevs();
-
+
public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
PCHWriter(llvm::BitstreamWriter &Stream);
-
+
/// \brief Write a precompiled header for the given semantic analysis.
///
/// \param SemaRef a reference to the semantic analysis object that processed
@@ -194,9 +194,9 @@ public:
/// \param StatCalls the object that cached all of the stat() calls made while
/// searching for source files and headers.
///
- /// \param isysroot if non-NULL, write a relocatable PCH file whose headers
+ /// \param isysroot if non-NULL, write a relocatable PCH file whose headers
/// are relative to the given system root.
- void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
+ void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char* isysroot);
/// \brief Emit a source location.
@@ -216,7 +216,7 @@ public:
/// \brief Emit a Selector (which is a smart pointer reference)
void AddSelectorRef(const Selector, RecordData &Record);
-
+
/// \brief Get the unique number used to refer to the given
/// identifier.
pch::IdentID getIdentifierRef(const IdentifierInfo *II);
@@ -226,7 +226,7 @@ public:
///
/// The identifier must refer to a macro.
uint64_t getMacroOffset(const IdentifierInfo *II) {
- assert(MacroOffsets.find(II) != MacroOffsets.end() &&
+ assert(MacroOffsets.find(II) != MacroOffsets.end() &&
"Identifier does not name a macro");
return MacroOffsets[II];
}
diff --git a/include/clang/Frontend/PathDiagnosticClients.h b/include/clang/Frontend/PathDiagnosticClients.h
index 53dd32e93b..8cb6898d75 100644
--- a/include/clang/Frontend/PathDiagnosticClients.h
+++ b/include/clang/Frontend/PathDiagnosticClients.h
@@ -23,12 +23,12 @@ namespace clang {
class PathDiagnosticClient;
class Preprocessor;
class PreprocessorFactory;
-
+
class PathDiagnosticClientFactory {
public:
PathDiagnosticClientFactory() {}
virtual ~PathDiagnosticClientFactory() {}
-
+
virtual const char *getName() const = 0;
virtual PathDiagnosticClient*
@@ -39,12 +39,12 @@ PathDiagnosticClient*
CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP = 0,
PreprocessorFactory* PPF = 0,
llvm::SmallVectorImpl<std::string>* FilesMade = 0);
-
+
PathDiagnosticClientFactory*
CreateHTMLDiagnosticClientFactory(const std::string& prefix,
Preprocessor* PP = 0,
PreprocessorFactory* PPF = 0);
-
+
PathDiagnosticClient*
CreatePlistDiagnosticClient(const std::string& prefix, Preprocessor* PP,
PreprocessorFactory* PPF,
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index f8408bdbd7..0fd8d44f72 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -52,7 +52,7 @@ public:
unsigned messageLength = 0,
bool useColors = false)
: OS(os), LangOpts(0),
- LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
+ LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
PrintRangeInfo(printRangeInfo),
PrintDiagnosticOption(printDiagnosticOption),
@@ -63,7 +63,7 @@ public:
void setLangOptions(const LangOptions *LO) {
LangOpts = LO;
}
-
+
void PrintIncludeStack(SourceLocation Loc, const SourceManager &SM);
void HighlightRange(const SourceRange &R,
@@ -72,13 +72,13 @@ public:
std::string &CaretLine,
const std::string &SourceLine);
- void EmitCaretDiagnostic(SourceLocation Loc,
+ void EmitCaretDiagnostic(SourceLocation Loc,
SourceRange *Ranges, unsigned NumRanges,
SourceManager &SM,
const CodeModificationHint *Hints,
unsigned NumHints,
unsigned Columns);
-
+
virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info);
};
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 2ad44da999..9cbcf8e3e9 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -57,7 +57,7 @@ void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
/// RewriteMacrosInInput - A simple test for the TokenRewriter class.
void DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS);
-
+
/// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option.
MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP,
diff --git a/include/clang/Index/ASTLocation.h b/include/clang/Index/ASTLocation.h
index 954792d0f9..60af9e672c 100644
--- a/include/clang/Index/ASTLocation.h
+++ b/include/clang/Index/ASTLocation.h
@@ -75,13 +75,13 @@ public:
static bool isImmediateParent(Decl *D, Stmt *Node);
static Decl *FindImmediateParent(Decl *D, Stmt *Node);
- friend bool operator==(const ASTLocation &L, const ASTLocation &R) {
+ friend bool operator==(const ASTLocation &L, const ASTLocation &R) {
return L.D == R.D && L.Stm == R.Stm;
}
- friend bool operator!=(const ASTLocation &L, const ASTLocation &R) {
+ friend bool operator!=(const ASTLocation &L, const ASTLocation &R) {
return !(L == R);
}
-
+
void print(llvm::raw_ostream &OS) const;
};
@@ -89,13 +89,13 @@ public:
/// ASTLocation originated from.
class TULocation : public ASTLocation {
TranslationUnit *TU;
-
+
public:
TULocation(TranslationUnit *tu, ASTLocation astLoc)
: ASTLocation(astLoc), TU(tu) {
assert(tu && "Passed null translation unit");
}
-
+
TranslationUnit *getTU() const { return TU; }
};
diff --git a/include/clang/Index/DeclReferenceMap.h b/include/clang/Index/DeclReferenceMap.h
index 1ed64369fc..73f2fe50b3 100644
--- a/include/clang/Index/DeclReferenceMap.h
+++ b/include/clang/Index/DeclReferenceMap.h
@@ -24,27 +24,27 @@ namespace clang {
class NamedDecl;
namespace idx {
-
+
/// \brief Maps NamedDecls with the ASTLocations that reference them.
///
/// References are mapped and retrieved using the canonical decls.
class DeclReferenceMap {
public:
explicit DeclReferenceMap(ASTContext &Ctx);
-
+
typedef std::multimap<NamedDecl*, ASTLocation> MapTy;
typedef pair_value_iterator<MapTy::iterator> astlocation_iterator;
astlocation_iterator refs_begin(NamedDecl *D) const;
astlocation_iterator refs_end(NamedDecl *D) const;
bool refs_empty(NamedDecl *D) const;
-
+
private:
mutable MapTy Map;
};
} // end idx namespace
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Index/Entity.h b/include/clang/Index/Entity.h
index edbb329723..4533a1a0ac 100644
--- a/include/clang/Index/Entity.h
+++ b/include/clang/Index/Entity.h
@@ -50,7 +50,7 @@ class Entity {
explicit Entity(Decl *D);
explicit Entity(EntityImpl *impl) : Val(impl) { }
friend class EntityGetter;
-
+
public:
Entity() { }
@@ -79,7 +79,7 @@ public:
bool isValid() const { return !Val.isNull(); }
bool isInvalid() const { return !isValid(); }
-
+
void *getAsOpaquePtr() const { return Val.getOpaqueValue(); }
static Entity getFromOpaquePtr(void *Ptr) {
Entity Ent;
@@ -87,12 +87,12 @@ public:
return Ent;
}
- friend bool operator==(const Entity &LHS, const Entity &RHS) {
+ friend bool operator==(const Entity &LHS, const Entity &RHS) {
return LHS.getAsOpaquePtr() == RHS.getAsOpaquePtr();
}
-
+
// For use in a std::map.
- friend bool operator < (const Entity &LHS, const Entity &RHS) {
+ friend bool operator < (const Entity &LHS, const Entity &RHS) {
return LHS.getAsOpaquePtr() < RHS.getAsOpaquePtr();
}
@@ -110,7 +110,7 @@ public:
return Ent;
}
};
-
+
} // namespace idx
} // namespace clang
@@ -130,7 +130,7 @@ struct DenseMapInfo<clang::idx::Entity> {
static unsigned getHashValue(clang::idx::Entity);
- static inline bool
+ static inline bool
isEqual(clang::idx::Entity LHS, clang::idx::Entity RHS) {
return LHS == RHS;
}
diff --git a/include/clang/Index/GlobalSelector.h b/include/clang/Index/GlobalSelector.h
index e24c419d1e..51f98267f3 100644
--- a/include/clang/Index/GlobalSelector.h
+++ b/include/clang/Index/GlobalSelector.h
@@ -44,19 +44,19 @@ public:
/// \brief Get a GlobalSelector for the ASTContext-specific selector.
static GlobalSelector get(Selector Sel, Program &Prog);
-
+
void *getAsOpaquePtr() const { return Val; }
-
+
static GlobalSelector getFromOpaquePtr(void *Ptr) {
return GlobalSelector(Ptr);
}
- friend bool operator==(const GlobalSelector &LHS, const GlobalSelector &RHS) {
+ friend bool operator==(const GlobalSelector &LHS, const GlobalSelector &RHS) {
return LHS.getAsOpaquePtr() == RHS.getAsOpaquePtr();
}
-
+
// For use in a std::map.
- friend bool operator< (const GlobalSelector &LHS, const GlobalSelector &RHS) {
+ friend bool operator< (const GlobalSelector &LHS, const GlobalSelector &RHS) {
return LHS.getAsOpaquePtr() < RHS.getAsOpaquePtr();
}
@@ -66,7 +66,7 @@ public:
return GlobalSelector((void*)-2);
}
};
-
+
} // namespace idx
} // namespace clang
@@ -86,7 +86,7 @@ struct DenseMapInfo<clang::idx::GlobalSelector> {
static unsigned getHashValue(clang::idx::GlobalSelector);
- static inline bool
+ static inline bool
isEqual(clang::idx::GlobalSelector LHS, clang::idx::GlobalSelector RHS) {
return LHS == RHS;
}
diff --git a/include/clang/Index/Handlers.h b/include/clang/Index/Handlers.h
index 2fe83c7f8b..655aef901c 100644
--- a/include/clang/Index/Handlers.h
+++ b/include/clang/Index/Handlers.h
@@ -63,7 +63,7 @@ class Storing : public handler_type {
typedef typename handler_type::receiving_type receiving_type;
typedef llvm::SmallVector<receiving_type, 8> StoreTy;
StoreTy Store;
-
+
public:
virtual void Handle(receiving_type Obj) {
Store.push_back(Obj);
diff --git a/include/clang/Index/Indexer.h b/include/clang/Index/Indexer.h
index 0fcf31c644..7bb48f2b75 100644
--- a/include/clang/Index/Indexer.h
+++ b/include/clang/Index/Indexer.h
@@ -37,13 +37,13 @@ public:
typedef std::map<Entity, TUSetTy> MapTy;
typedef std::map<GlobalSelector, TUSetTy> SelMapTy;
- explicit Indexer(Program &prog, FileManager &FM) :
+ explicit Indexer(Program &prog, FileManager &FM) :
Prog(prog), FileMgr(FM) { }
Program &getProgram() const { return Prog; }
FileManager &getFileManager() const { return FileMgr; }
-
+
/// \brief Find all Entities and map them to the given translation unit.
void IndexAST(TranslationUnit *TU);
@@ -55,7 +55,7 @@ public:
private:
Program &Prog;
FileManager &FileMgr;
-
+
MapTy Map;
CtxTUMapTy CtxTUMap;
SelMapTy SelMap;
diff --git a/include/clang/Index/Program.h b/include/clang/Index/Program.h
index a9e0b878d7..8039192512 100644
--- a/include/clang/Index/Program.h
+++ b/include/clang/Index/Program.h
@@ -29,7 +29,7 @@ class Program {
Program &operator=(const Program &); // do not implement
friend class Entity;
friend class GlobalSelector;
-
+
public:
Program();
~Program();
diff --git a/include/clang/Index/STLExtras.h b/include/clang/Index/STLExtras.h
index a9707204c5..a3693c6c79 100644
--- a/include/clang/Index/STLExtras.h
+++ b/include/clang/Index/STLExtras.h
@@ -48,16 +48,16 @@ public:
return tmp;
}
- friend bool operator==(pair_value_iterator L, pair_value_iterator R) {
+ friend bool operator==(pair_value_iterator L, pair_value_iterator R) {
return L.I == R.I;
}
- friend bool operator!=(pair_value_iterator L, pair_value_iterator R) {
+ friend bool operator!=(pair_value_iterator L, pair_value_iterator R) {
return L.I != R.I;
}
};
} // end idx namespace
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Index/SelectorMap.h b/include/clang/Index/SelectorMap.h
index 0fb6afb741..be01702fcb 100644
--- a/include/clang/Index/SelectorMap.h
+++ b/include/clang/Index/SelectorMap.h
@@ -25,14 +25,14 @@ namespace clang {
class ObjCMethodDecl;
namespace idx {
-
+
/// \brief Maps NamedDecls with the ASTLocations that reference them.
///
/// References are mapped and retrieved using the canonical decls.
class SelectorMap {
public:
explicit SelectorMap(ASTContext &Ctx);
-
+
typedef std::multimap<Selector, ObjCMethodDecl *> SelMethMapTy;
typedef std::multimap<Selector, ASTLocation> SelRefMapTy;
@@ -44,14 +44,14 @@ public:
astlocation_iterator refs_begin(Selector Sel) const;
astlocation_iterator refs_end(Selector Sel) const;
-
+
private:
mutable SelMethMapTy SelMethMap;
mutable SelRefMapTy SelRefMap;
};
} // end idx namespace
-
+
} // end clang namespace
#endif
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h
index 618de39233..c94a990224 100644
--- a/include/clang/Lex/DirectoryLookup.h
+++ b/include/clang/Lex/DirectoryLookup.h
@@ -38,20 +38,20 @@ private:
/// Dir - This is the actual directory that we're referring to for a normal
/// directory or a framework.
const DirectoryEntry *Dir;
-
+
/// Map - This is the HeaderMap if this is a headermap lookup.
///
const HeaderMap *Map;
} u;
-
+
/// DirCharacteristic - The type of directory this is: this is an instance of
/// SrcMgr::CharacteristicKind.
unsigned DirCharacteristic : 2;
-
+
/// UserSupplied - True if this is a user-supplied directory.
///
bool UserSupplied : 1;
-
+
/// LookupType - This indicates whether this DirectoryLookup object is a
/// normal directory, a framework, or a headermap.
unsigned LookupType : 2;
@@ -62,25 +62,25 @@ public:
bool isUser, bool isFramework)
: DirCharacteristic(DT), UserSupplied(isUser),
LookupType(isFramework ? LT_Framework : LT_NormalDir) {
- u.Dir = dir;
+ u.Dir = dir;
}
-
+
/// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
/// 'map'.
DirectoryLookup(const HeaderMap *map, SrcMgr::CharacteristicKind DT,
bool isUser)
: DirCharacteristic(DT), UserSupplied(isUser), LookupType(LT_HeaderMap) {
- u.Map = map;
+ u.Map = map;
}
-
+
/// getLookupType - Return the kind of directory lookup that this is: either a
/// normal directory, a framework path, or a HeaderMap.
LookupType_t getLookupType() const { return (LookupType_t)LookupType; }
-
+
/// getName - Return the directory or filename corresponding to this lookup
/// object.
const char *getName() const;
-
+
/// getDir - Return the directory that this entry refers to.
///
const DirectoryEntry *getDir() const { return isNormalDir() ? u.Dir : 0; }
@@ -90,42 +90,42 @@ public:
const DirectoryEntry *getFrameworkDir() const {
return isFramework() ? u.Dir : 0;
}
-
+
/// getHeaderMap - Return the directory that this entry refers to.
///
const HeaderMap *getHeaderMap() const { return isHeaderMap() ? u.Map : 0; }
/// isNormalDir - Return true if this is a normal directory, not a header map.
bool isNormalDir() const { return getLookupType() == LT_NormalDir; }
-
+
/// isFramework - True if this is a framework directory.
///
bool isFramework() const { return getLookupType() == LT_Framework; }
-
+
/// isHeaderMap - Return true if this is a header map, not a normal directory.
bool isHeaderMap() const { return getLookupType() == LT_HeaderMap; }
-
+
/// DirCharacteristic - The type of directory this is, one of the DirType enum
/// values.
SrcMgr::CharacteristicKind getDirCharacteristic() const {
return (SrcMgr::CharacteristicKind)DirCharacteristic;
}
-
+
/// isUserSupplied - True if this is a user-supplied directory.
///
bool isUserSupplied() const { return UserSupplied; }
-
-
+
+
/// LookupFile - Lookup the specified file in this search path, returning it
/// if it exists or returning null if not.
const FileEntry *LookupFile(const char *FilenameStart,
const char *FilenameEnd, HeaderSearch &HS) const;
-
+
private:
const FileEntry *DoFrameworkLookup(const char *FilenameStart,
- const char *FilenameEnd,
+ const char *FilenameEnd,
HeaderSearch &HS) const;
-
+
};
} // end namespace clang
diff --git a/include/clang/Lex/HeaderMap.h b/include/clang/Lex/HeaderMap.h
index d8033093bd..6bb7c25947 100644
--- a/include/clang/Lex/HeaderMap.h
+++ b/include/clang/Lex/HeaderMap.h
@@ -30,31 +30,31 @@ namespace clang {
class HeaderMap {
HeaderMap(const HeaderMap&); // DO NOT IMPLEMENT
void operator=(const HeaderMap&); // DO NOT IMPLEMENT
-
+
const llvm::MemoryBuffer *FileBuffer;
bool NeedsBSwap;
-
+
HeaderMap(const llvm::MemoryBuffer *File, bool BSwap)
: FileBuffer(File), NeedsBSwap(BSwap) {
}
public:
~HeaderMap();
-
+
/// HeaderMap::Create - This attempts to load the specified file as a header
/// map. If it doesn't look like a HeaderMap, it gives up and returns null.
static const HeaderMap *Create(const FileEntry *FE);
-
+
/// LookupFile - Check to see if the specified relative filename is located in
/// this HeaderMap. If so, open it and return its FileEntry.
const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd,
FileManager &FM) const;
-
+
/// getFileName - Return the filename of the headermap.
const char *getFileName() const;
-
+
/// dump - Print the contents of this headermap to stderr.
void dump() const;
-
+
private:
unsigned getEndianAdjustedWord(unsigned X) const;
const HMapHeader &getHeader() const;
diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h
index f21aab1b40..7517440983 100644
--- a/include/clang/Lex/HeaderSearch.h
+++ b/include/clang/Lex/HeaderSearch.h
@@ -30,17 +30,17 @@ class IdentifierInfo;
struct HeaderFileInfo {
/// isImport - True if this is a #import'd or #pragma once file.
bool isImport : 1;
-
+
/// DirInfo - Keep track of whether this is a system header, and if so,
/// whether it is C++ clean or not. This can be set by the include paths or
/// by #pragma gcc system_header. This is an instance of
/// SrcMgr::CharacteristicKind.
unsigned DirInfo : 2;
-
+
/// NumIncludes - This is the number of times the file has been included
/// already.
unsigned short NumIncludes;
-
+
/// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard
/// that protects the entire contents of the file, this is the identifier
/// for the macro that controls whether or not it has any effect.
@@ -51,14 +51,14 @@ struct HeaderFileInfo {
/// external storage.
const IdentifierInfo *ControllingMacro;
- /// \brief The ID number of the controlling macro.
+ /// \brief The ID number of the controlling macro.
///
/// This ID number will be non-zero when there is a controlling
/// macro whose IdentifierInfo may not yet have been loaded from
/// external storage.
unsigned ControllingMacroID;
- HeaderFileInfo()
+ HeaderFileInfo()
: isImport(false), DirInfo(SrcMgr::C_User),
NumIncludes(0), ControllingMacro(0), ControllingMacroID(0) {}
@@ -71,7 +71,7 @@ struct HeaderFileInfo {
/// file referenced by a #include or #include_next, (sub-)framework lookup, etc.
class HeaderSearch {
FileManager &FileMgr;
-
+
/// #include search path information. Requests for #include "x" search the
/// directory of the #including file first, then each directory in SearchDirs
/// consequtively. Requests for <x> search the current dir first, then each
@@ -81,7 +81,7 @@ class HeaderSearch {
std::vector<DirectoryLookup> SearchDirs;
unsigned SystemDirIdx;
bool NoCurDirSearch;
-
+
/// FileInfo - This contains all of the preprocessor-specific data about files
/// that are included. The vector is indexed by the FileEntry's UID.
///
@@ -94,13 +94,13 @@ class HeaderSearch {
/// ignored. The second value is the entry in SearchDirs that satisfied the
/// query.
llvm::StringMap<std::pair<unsigned, unsigned> > LookupFileCache;
-
-
+
+
/// FrameworkMap - This is a collection mapping a framework or subframework
/// name like "Carbon" to the Carbon.framework directory.
llvm::StringMap<const DirectoryEntry *> FrameworkMap;
- /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing
+ /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing
/// headermaps. This vector owns the headermap.
std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps;
@@ -114,7 +114,7 @@ class HeaderSearch {
unsigned NumFrameworkLookups, NumSubFrameworkLookups;
// HeaderSearch doesn't support default or copy construction.
- explicit HeaderSearch();
+ explicit HeaderSearch();
explicit HeaderSearch(const HeaderSearch&);
void operator=(const HeaderSearch&);
public:
@@ -132,12 +132,12 @@ public:
NoCurDirSearch = noCurDirSearch;
//LookupFileCache.clear();
}
-
+
/// ClearFileInfo - Forget everything we know about headers so far.
void ClearFileInfo() {
FileInfo.clear();
}
-
+
void SetExternalLookup(ExternalIdentifierLookup *EIL) {
ExternalLookup = EIL;
}
@@ -155,7 +155,7 @@ public:
const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir,
const FileEntry *CurFileEnt);
-
+
/// LookupSubframeworkHeader - Look up a subframework for the specified
/// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from
/// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox
@@ -164,7 +164,7 @@ public:
const FileEntry *LookupSubframeworkHeader(const char *FilenameStart,
const char *FilenameEnd,
const FileEntry *RelativeFileEnt);
-
+
/// LookupFrameworkCache - Look up the specified framework name in our
/// framework cache, returning the DirectoryEntry it is in if we know,
/// otherwise, return null.
@@ -172,19 +172,19 @@ public:
const char *FWNameEnd) {
return FrameworkMap.GetOrCreateValue(FWNameStart, FWNameEnd).getValue();
}
-
+
/// ShouldEnterIncludeFile - Mark the specified file as a target of of a
/// #include, #include_next, or #import directive. Return false if #including
/// the file will have no effect or true if we should include it.
bool ShouldEnterIncludeFile(const FileEntry *File, bool isImport);
-
-
+
+
/// getFileDirFlavor - Return whether the specified file is a normal header,
/// a system header, or a C++ friendly system header.
SrcMgr::CharacteristicKind getFileDirFlavor(const FileEntry *File) {
return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo;
}
-
+
/// MarkFileIncludeOnce - Mark the specified file as a "once only" file, e.g.
/// due to #pragma once.
void MarkFileIncludeOnce(const FileEntry *File) {
@@ -196,13 +196,13 @@ public:
void MarkFileSystemHeader(const FileEntry *File) {
getFileInfo(File).DirInfo = SrcMgr::C_System;
}
-
+
/// IncrementIncludeCount - Increment the count for the number of times the
/// specified FileEntry has been entered.
void IncrementIncludeCount(const FileEntry *File) {
++getFileInfo(File).NumIncludes;
}
-
+
/// SetFileControllingMacro - Mark the specified file as having a controlling
/// macro. This is used by the multiple-include optimization to eliminate
/// no-op #includes.
@@ -210,11 +210,11 @@ public:
const IdentifierInfo *ControllingMacro) {
getFileInfo(File).ControllingMacro = ControllingMacro;
}
-
+
/// CreateHeaderMap - This method returns a HeaderMap for the specified
/// FileEntry, uniquing them through the the 'HeaderMaps' datastructure.
const HeaderMap *CreateHeaderMap(const FileEntry *FE);
-
+
void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; }
typedef std::vector<HeaderFileInfo>::iterator header_file_iterator;
@@ -223,10 +223,10 @@ public:
// Used by PCHReader.
void setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID);
-
+
void PrintStats();
private:
-
+
/// getFileInfo - Return the HeaderFileInfo structure for the specified
/// FileEntry.
HeaderFileInfo &getFileInfo(const FileEntry *FE);
diff --git a/include/clang/Lex/LexDiagnostic.h b/include/clang/Lex/LexDiagnostic.h
index 03d9b7b3bb..a470aa0924 100644
--- a/include/clang/Lex/LexDiagnostic.h
+++ b/include/clang/Lex/LexDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define LEXSTART
diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h
index 3a73147152..1443ef1184 100644
--- a/include/clang/Lex/Lexer.h
+++ b/include/clang/Lex/Lexer.h
@@ -39,11 +39,11 @@ class Lexer : public PreprocessorLexer {
SourceLocation FileLoc; // Location for start of file.
LangOptions Features; // Features enabled by this language (cache).
bool Is_PragmaLexer; // True if lexer for _Pragma handling.
-
+
//===--------------------------------------------------------------------===//
// Context-specific lexing flags set by the preprocessor.
//
-
+
/// ExtendedTokenMode - The lexer can optionally keep comments and whitespace
/// and return them as tokens. This is used for -C and -CC modes, and
/// whitespace preservation can be useful for some clients that want to lex
@@ -52,7 +52,7 @@ class Lexer : public PreprocessorLexer {
/// When this is set to 2 it returns comments and whitespace. When set to 1
/// it returns comments, when it is set to 0 it returns normal tokens only.
unsigned char ExtendedTokenMode;
-
+
//===--------------------------------------------------------------------===//
// Context that changes as the file is lexed.
// NOTE: any state that mutates when in raw mode must have save/restore code
@@ -65,14 +65,14 @@ class Lexer : public PreprocessorLexer {
// IsAtStartOfLine - True if the next lexed token should get the "start of
// line" flag set on it.
bool IsAtStartOfLine;
-
+
Lexer(const Lexer&); // DO NOT IMPLEMENT
void operator=(const Lexer&); // DO NOT IMPLEMENT
friend class Preprocessor;
-
+
void InitLexer(const char *BufStart, const char *BufPtr, const char *BufEnd);
public:
-
+
/// Lexer constructor - Create a new lexer object for the specified buffer
/// with the specified preprocessor managing the lexing process. This lexer
/// assumes that the associated file buffer and Preprocessor objects will
@@ -84,21 +84,21 @@ public:
/// range will outlive it, so it doesn't take ownership of it.
Lexer(SourceLocation FileLoc, const LangOptions &Features,
const char *BufStart, const char *BufPtr, const char *BufEnd);
-
+
/// Lexer constructor - Create a new raw lexer object. This object is only
/// suitable for calls to 'LexRawToken'. This lexer assumes that the text
/// range will outlive it, so it doesn't take ownership of it.
Lexer(FileID FID, const SourceManager &SM, const LangOptions &Features);
-
+
/// Create_PragmaLexer: Lexer constructor - Create a new lexer object for
/// _Pragma expansion. This has a variety of magic semantics that this method
/// sets up. It returns a new'd Lexer that must be delete'd when done.
- static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc,
+ static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc,
SourceLocation InstantiationLocStart,
SourceLocation InstantiationLocEnd,
unsigned TokLen, Preprocessor &PP);
-
-
+
+
/// getFeatures - Return the language features currently enabled. NOTE: this
/// lexer modifies features as a file is parsed!
const LangOptions &getFeatures() const { return Features; }
@@ -108,7 +108,7 @@ public:
/// the virtual location encodes where we should *claim* the characters came
/// from. Currently this is only used by _Pragma handling.
SourceLocation getFileLoc() const { return FileLoc; }
-
+
/// Lex - Return the next token in the file. If this is the end of file, it
/// return the tok::eof token. Return true if an error occurred and
/// compilation should terminate, false if normal. This implicitly involves
@@ -116,14 +116,14 @@ public:
void Lex(Token &Result) {
// Start a new token.
Result.startToken();
-
- // NOTE, any changes here should also change code after calls to
+
+ // NOTE, any changes here should also change code after calls to
// Preprocessor::HandleDirective
if (IsAtStartOfLine) {
Result.setFlag(Token::StartOfLine);
IsAtStartOfLine = false;
}
-
+
// Get a token. Note that this may delete the current lexer if the end of
// file is reached.
LexTokenInternal(Result);
@@ -131,11 +131,11 @@ public:
/// isPragmaLexer - Returns true if this Lexer is being used to lex a pragma.
bool isPragmaLexer() const { return Is_PragmaLexer; }
-
+
/// IndirectLex - An indirect call to 'Lex' that can be invoked via
/// the PreprocessorLexer interface.
void IndirectLex(Token &Result) { Lex(Result); }
-
+
/// LexFromRawLexer - Lex a token from a designated raw lexer (one with no
/// associated preprocessor object. Return true if the 'next character to
/// read' pointer points at the end of the lexer buffer, false otherwise.
@@ -144,7 +144,7 @@ public:
Lex(Result);
// Note that lexing to the end of the buffer doesn't implicitly delete the
// lexer when in raw mode.
- return BufferPtr == BufferEnd;
+ return BufferPtr == BufferEnd;
}
/// isKeepWhitespaceMode - Return true if the lexer should return tokens for
@@ -168,23 +168,23 @@ public:
bool inKeepCommentMode() const {
return ExtendedTokenMode > 0;
}
-
+
/// SetCommentRetentionMode - Change the comment retention mode of the lexer
/// to the specified mode. This is really only useful when lexing in raw
/// mode, because otherwise the lexer needs to manage this.
- void SetCommentRetentionState(bool Mode) {
+ void SetCommentRetentionState(bool Mode) {
assert(!isKeepWhitespaceMode() &&
"Can't play with comment retention state when retaining whitespace");
ExtendedTokenMode = Mode ? 1 : 0;
}
-
+
const char *getBufferStart() const { return BufferStart; }
-
+
/// ReadToEndOfLine - Read the rest of the current preprocessor line as an
/// uninterpreted string. This switches the lexer out of directive mode.
std::string ReadToEndOfLine();
-
-
+
+
/// Diag - Forwarding function for diagnostics. This translate a source
/// position in the current buffer into a SourceLocation object for rendering.
DiagnosticBuilder Diag(const char *Loc, unsigned DiagID) const;
@@ -192,20 +192,20 @@ public:
/// getSourceLocation - Return a source location identifier for the specified
/// offset in the current file.
SourceLocation getSourceLocation(const char *Loc, unsigned TokLen = 1) const;
-
+
/// getSourceLocation - Return a source location for the next character in
/// the current file.
SourceLocation getSourceLocation() { return getSourceLocation(BufferPtr); }
-
+
/// Stringify - Convert the specified string into a C string by escaping '\'
/// and " characters. This does not add surrounding ""'s to the string.
/// If Charify is true, this escapes the ' character instead of ".
static std::string Stringify(const std::string &Str, bool Charify = false);
-
+
/// Stringify - Convert the specified string into a C string by escaping '\'
/// and " characters. This does not add surrounding ""'s to the string.
static void Stringify(llvm::SmallVectorImpl<char> &Str);
-
+
/// MeasureTokenLength - Relex the token at the specified location and return
/// its length in bytes in the input file. If the token needs cleaning (e.g.
/// includes a trigraph or an escaped newline) then this count includes bytes
@@ -213,7 +213,7 @@ public:
static unsigned MeasureTokenLength(SourceLocation Loc,
const SourceManager &SM,
const LangOptions &LangOpts);
-
+
//===--------------------------------------------------------------------===//
// Internal implementation interfaces.
private:
@@ -228,7 +228,7 @@ private:
/// takes that range and assigns it to the token as its location and size. In
/// addition, since tokens cannot overlap, this also updates BufferPtr to be
/// TokEnd.
- void FormTokenWithChars(Token &Result, const char *TokEnd,
+ void FormTokenWithChars(Token &Result, const char *TokEnd,
tok::TokenKind Kind) {
unsigned TokLen = TokEnd-BufferPtr;
Result.setLength(TokLen);
@@ -236,7 +236,7 @@ private:
Result.setKind(Kind);
BufferPtr = TokEnd;
}
-
+
/// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a
/// tok::l_paren token, 0 if it is something else and 2 if there are no more
/// tokens in the buffer controlled by this lexer.
@@ -245,7 +245,7 @@ private:
//===--------------------------------------------------------------------===//
// Lexer character reading interfaces.
public:
-
+
// This lexer is built on two interfaces for reading characters, both of which
// automatically provide phase 1/2 translation. getAndAdvanceChar is used
// when we know that we will be reading a character from the input buffer and
@@ -260,7 +260,7 @@ public:
// approach allows us to emit diagnostics for characters (e.g. warnings about
// trigraphs), knowing that they only are emitted if the character is
// consumed.
-
+
/// isObviouslySimpleCharacter - Return true if the specified character is
/// obviously the same in translation phase 1 and translation phase 3. This
/// can return false for characters that end up being the same, but it will
@@ -268,7 +268,7 @@ public:
static bool isObviouslySimpleCharacter(char C) {
return C != '?' && C != '\\';
}
-
+
/// getAndAdvanceChar - Read a single 'character' from the specified buffer,
/// advance over it, and return it. This is tricky in several cases. Here we
/// just handle the trivial case and fall-back to the non-inlined
@@ -277,13 +277,13 @@ public:
// If this is not a trigraph and not a UCN or escaped newline, return
// quickly.
if (isObviouslySimpleCharacter(Ptr[0])) return *Ptr++;
-
+
unsigned Size = 0;
char C = getCharAndSizeSlow(Ptr, Size, &Tok);
Ptr += Size;
return C;
}
-
+
private:
/// ConsumeChar - When a character (identified by PeekCharAndSize) is consumed
/// and added to a given token, check to see if there are diagnostics that
@@ -300,7 +300,7 @@ private:
getCharAndSizeSlow(Ptr, Size, &Tok);
return Ptr+Size;
}
-
+
/// getCharAndSize - Peek a single 'character' from the specified buffer,
/// get its size, and return it. This is tricky in several cases. Here we
/// just handle the trivial case and fall-back to the non-inlined
@@ -312,16 +312,16 @@ private:
Size = 1;
return *Ptr;
}
-
+
Size = 0;
return getCharAndSizeSlow(Ptr, Size);
}
-
+
/// getCharAndSizeSlow - Handle the slow/uncommon case of the getCharAndSize
/// method.
char getCharAndSizeSlow(const char *Ptr, unsigned &Size, Token *Tok = 0);
public:
-
+
/// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever
/// emit a warning.
static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size,
@@ -332,30 +332,30 @@ public:
Size = 1;
return *Ptr;
}
-
+
Size = 0;
return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
}
-
+
/// getEscapedNewLineSize - Return the size of the specified escaped newline,
/// or 0 if it is not an escaped newline. P[-1] is known to be a "\" on entry
/// to this function.
static unsigned getEscapedNewLineSize(const char *P);
-
+
/// SkipEscapedNewLines - If P points to an escaped newline (or a series of
/// them), skip over them and return the first non-escaped-newline found,
/// otherwise return P.
static const char *SkipEscapedNewLines(const char *P);
private:
-
+
/// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a
/// diagnostic.
static char getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size,
const LangOptions &Features);
-
+
//===--------------------------------------------------------------------===//
// Other lexer functions.
-
+
// Helper functions to lex the remainder of a token of the specific type.
void LexIdentifier (Token &Result, const char *CurPtr);
void LexNumericConstant (Token &Result, const char *CurPtr);
@@ -363,7 +363,7 @@ private:
void LexAngledStringLiteral(Token &Result, const char *CurPtr);
void LexCharConstant (Token &Result, const char *CurPtr);
bool LexEndOfFile (Token &Result, const char *CurPtr);
-
+
bool SkipWhitespace (Token &Result, const char *CurPtr);
bool SkipBCPLComment (Token &Result, const char *CurPtr);
bool SkipBlockComment (Token &Result, const char *CurPtr);
diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h
index 29b82c1807..1c1cc8031f 100644
--- a/include/clang/Lex/LiteralSupport.h
+++ b/include/clang/Lex/LiteralSupport.h
@@ -32,22 +32,22 @@ class Preprocessor;
class Token;
class SourceLocation;
class TargetInfo;
-
+
/// NumericLiteralParser - This performs strict semantic analysis of the content
/// of a ppnumber, classifying it as either integer, floating, or erroneous,
/// determines the radix of the value and can convert it to a useful value.
class NumericLiteralParser {
Preprocessor &PP; // needed for diagnostics
-
+
const char *const ThisTokBegin;
const char *const ThisTokEnd;
const char *DigitsBegin, *SuffixBegin; // markers
const char *s; // cursor
-
+
unsigned radix;
-
+
bool saw_exponent, saw_period;
-
+
public:
NumericLiteralParser(const char *begin, const char *end,
SourceLocation Loc, Preprocessor &PP);
@@ -57,8 +57,8 @@ public:
bool isLongLong;
bool isFloat; // 1.0f
bool isImaginary; // 1.0i
-
- bool isIntegerLiteral() const {
+
+ bool isIntegerLiteral() const {
return !saw_period && !saw_exponent;
}
bool isFloatingLiteral() const {
@@ -67,27 +67,27 @@ public:
bool hasSuffix() const {
return SuffixBegin != ThisTokEnd;
}
-
+
unsigned getRadix() const { return radix; }
-
+
/// GetIntegerValue - Convert this numeric literal value to an APInt that
/// matches Val's input width. If there is an overflow (i.e., if the unsigned
/// value read is larger than the APInt's bits will hold), set Val to the low
/// bits of the result and return true. Otherwise, return false.
bool GetIntegerValue(llvm::APInt &Val);
-
+
/// GetFloatValue - Convert this numeric literal to a floating value, using
/// the specified APFloat fltSemantics (specifying float, double, etc).
/// The optional bool isExact (passed-by-reference) has its value
/// set to true if the returned APFloat can represent the number in the
/// literal exactly, and false otherwise.
- llvm::APFloat GetFloatValue(const llvm::fltSemantics &Format,
+ llvm::APFloat GetFloatValue(const llvm::fltSemantics &Format,
bool* isExact = NULL);
-private:
-
+private:
+
void ParseNumberStartingWithZero(SourceLocation TokLoc);
-
+
/// SkipHexDigits - Read and skip over any hex digits, up to End.
/// Return a pointer to the first non-hex digit or End.
const char *SkipHexDigits(const char *ptr) {
@@ -95,7 +95,7 @@ private:
ptr++;
return ptr;
}
-
+
/// SkipOctalDigits - Read and skip over any octal digits, up to End.
/// Return a pointer to the first non-hex digit or End.
const char *SkipOctalDigits(const char *ptr) {
@@ -103,7 +103,7 @@ private:
ptr++;
return ptr;
}
-
+
/// SkipDigits - Read and skip over any digits, up to End.
/// Return a pointer to the first non-hex digit or End.
const char *SkipDigits(const char *ptr) {
@@ -111,7 +111,7 @@ private:
ptr++;
return ptr;
}
-
+
/// SkipBinaryDigits - Read and skip over any binary digits, up to End.
/// Return a pointer to the first non-binary digit or End.
const char *SkipBinaryDigits(const char *ptr) {
@@ -119,7 +119,7 @@ private:
ptr++;
return ptr;
}
-
+
};
/// CharLiteralParser - Perform interpretation and semantic analysis of a
@@ -144,7 +144,7 @@ public:
/// literals) (C99 5.1.1.2p1).
class StringLiteralParser {
Preprocessor &PP;
-
+
unsigned MaxTokenLength;
unsigned SizeBound;
unsigned wchar_tByteWidth;
@@ -156,7 +156,7 @@ public:
bool hadError;
bool AnyWide;
bool Pascal;
-
+
const char *GetString() { return &ResultBuf[0]; }
unsigned GetStringLength() const { return ResultPtr-&ResultBuf[0]; }
@@ -164,14 +164,14 @@ public:
if (AnyWide)
return GetStringLength() / wchar_tByteWidth;
return GetStringLength();
- }
+ }
/// getOffsetOfStringByte - This function returns the offset of the
/// specified byte of the string data represented by Token. This handles
/// advancing over escape sequences in the string.
static unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo,
Preprocessor &PP);
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h
index ccd13c80d3..5887041c46 100644
--- a/include/clang/Lex/MacroInfo.h
+++ b/include/clang/Lex/MacroInfo.h
@@ -22,7 +22,7 @@
namespace clang {
class Preprocessor;
-
+
/// MacroInfo - Each identifier that is #define'd has an instance of this class
/// associated with it, used to implement macro expansion.
class MacroInfo {
@@ -39,7 +39,7 @@ class MacroInfo {
/// includes the __VA_ARGS__ identifier on the list.
IdentifierInfo **ArgumentList;
unsigned NumArguments;
-
+
/// ReplacementTokens - This is the list of tokens that the macro is defined
/// to.
llvm::SmallVector<Token, 8> ReplacementTokens;
@@ -47,21 +47,21 @@ class MacroInfo {
/// IsFunctionLike - True if this macro is a function-like macro, false if it
/// is an object-like macro.
bool IsFunctionLike : 1;
-
+
/// IsC99Varargs - True if this macro is of the form "#define X(...)" or
/// "#define X(Y,Z,...)". The __VA_ARGS__ token should be replaced with the
/// contents of "..." in an invocation.
bool IsC99Varargs : 1;
-
+
/// IsGNUVarargs - True if this macro is of the form "#define X(a...)". The
/// "a" identifier in the replacement list will be replaced with all arguments
/// of the macro starting with the specified one.
bool IsGNUVarargs : 1;
-
+
/// IsBuiltinMacro - True if this is a builtin macro, such as __LINE__, and if
/// it has not yet been redefined or undefined.
bool IsBuiltinMacro : 1;
-
+
private:
//===--------------------------------------------------------------------===//
// State that changes as the macro is used.
@@ -70,19 +70,19 @@ private:
/// This disbles recursive expansion, which would be quite bad for things like
/// #define A A.
bool IsDisabled : 1;
-
+
/// IsUsed - True if this macro is either defined in the main file and has
- /// been used, or if it is not defined in the main file. This is used to
+ /// been used, or if it is not defined in the main file. This is used to
/// emit -Wunused-macros diagnostics.
bool IsUsed : 1;
-
+
~MacroInfo() {
assert(ArgumentList == 0 && "Didn't call destroy before dtor!");
}
-
+
public:
MacroInfo(SourceLocation DefLoc);
-
+
/// FreeArgumentList - Free the argument list of the macro, restoring it to a
/// state where it can be reused for other devious purposes.
void FreeArgumentList(llvm::BumpPtrAllocator &PPAllocator) {
@@ -90,13 +90,13 @@ public:
ArgumentList = 0;
NumArguments = 0;
}
-
+
/// Destroy - destroy this MacroInfo object.
void Destroy(llvm::BumpPtrAllocator &PPAllocator) {
FreeArgumentList(PPAllocator);
this->~MacroInfo();
}
-
+
/// getDefinitionLoc - Return the location that the macro was defined at.
///
SourceLocation getDefinitionLoc() const { return Location; }
@@ -112,13 +112,13 @@ public:
/// this macro in spelling, arguments, and whitespace. This is used to emit
/// duplicate definition warnings. This implements the rules in C99 6.10.3.
bool isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const;
-
+
/// setIsBuiltinMacro - Set or clear the isBuiltinMacro flag.
///
void setIsBuiltinMacro(bool Val = true) {
IsBuiltinMacro = Val;
}
-
+
/// setIsUsed - Set the value of the IsUsed flag.
///
void setIsUsed(bool Val) {
@@ -132,13 +132,13 @@ public:
assert(ArgumentList == 0 && NumArguments == 0 &&
"Argument list already set!");
if (NumArgs == 0) return;
-
+
NumArguments = NumArgs;
ArgumentList = PPAllocator.Allocate<IdentifierInfo*>(NumArgs);
for (unsigned i = 0; i != NumArgs; ++i)
ArgumentList[i] = List[i];
}
-
+
/// Arguments - The list of arguments for a function-like macro. This can be
/// empty, for, e.g. "#define X()".
typedef IdentifierInfo* const *arg_iterator;
@@ -146,7 +146,7 @@ public:
arg_iterator arg_begin() const { return ArgumentList; }
arg_iterator arg_end() const { return ArgumentList+NumArguments; }
unsigned getNumArgs() const { return NumArguments; }
-
+
/// getArgumentNum - Return the argument number of the specified identifier,
/// or -1 if the identifier is not a formal argument identifier.
int getArgumentNum(IdentifierInfo *Arg) const {
@@ -154,20 +154,20 @@ public:
if (*I == Arg) return I-arg_begin();
return -1;
}
-
+
/// Function/Object-likeness. Keep track of whether this macro has formal
/// parameters.
void setIsFunctionLike() { IsFunctionLike = true; }
bool isFunctionLike() const { return IsFunctionLike; }
bool isObjectLike() const { return !IsFunctionLike; }
-
+
/// Varargs querying methods. This can only be set for function-like macros.
void setIsC99Varargs() { IsC99Varargs = true; }
void setIsGNUVarargs() { IsGNUVarargs = true; }
bool isC99Varargs() const { return IsC99Varargs; }
bool isGNUVarargs() const { return IsGNUVarargs; }
bool isVariadic() const { return IsC99Varargs | IsGNUVarargs; }
-
+
/// isBuiltinMacro - Return true if this macro is a builtin macro, such as
/// __LINE__, which requires processing before expansion.
bool isBuiltinMacro() const { return IsBuiltinMacro; }
@@ -175,7 +175,7 @@ public:
/// isUsed - Return false if this macro is defined in the main file and has
/// not yet been used.
bool isUsed() const { return IsUsed; }
-
+
/// getNumTokens - Return the number of tokens that this macro expands to.
///
unsigned getNumTokens() const {
@@ -186,22 +186,22 @@ public:
assert(Tok < ReplacementTokens.size() && "Invalid token #");
return ReplacementTokens[Tok];
}
-
+
typedef llvm::SmallVector<Token, 8>::const_iterator tokens_iterator;
tokens_iterator tokens_begin() const { return ReplacementTokens.begin(); }
tokens_iterator tokens_end() const { return ReplacementTokens.end(); }
bool tokens_empty() const { return ReplacementTokens.empty(); }
-
+
/// AddTokenToBody - Add the specified token to the replacement text for the
/// macro.
void AddTokenToBody(const Token &Tok) {
ReplacementTokens.push_back(Tok);
}
-
+
/// isEnabled - Return true if this macro is enabled: in other words, that we
/// are not currently in an expansion of this macro.
bool isEnabled() const { return !IsDisabled; }
-
+
void EnableMacro() {
assert(IsDisabled && "Cannot enable an already-enabled macro!");
IsDisabled = false;
@@ -212,7 +212,7 @@ public:
IsDisabled = true;
}
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Lex/MultipleIncludeOpt.h b/include/clang/Lex/MultipleIncludeOpt.h
index 94d4677f9d..5d5d673290 100644
--- a/include/clang/Lex/MultipleIncludeOpt.h
+++ b/include/clang/Lex/MultipleIncludeOpt.h
@@ -36,7 +36,7 @@ class MultipleIncludeOpt {
/// to false, that way any tokens before the first #ifdef or after the last
/// #endif can be easily detected.
bool DidMacroExpansion;
-
+
/// TheMacro - The controlling macro for a file, if valid.
///
const IdentifierInfo *TheMacro;
@@ -46,7 +46,7 @@ public:
DidMacroExpansion = false;
TheMacro = 0;
}
-
+
/// Invalidate - Permenantly mark this file as not being suitable for the
/// include-file optimization.
void Invalidate() {
@@ -55,19 +55,19 @@ public:
ReadAnyTokens = true;
TheMacro = 0;
}
-
+
/// getHasReadAnyTokensVal - This is used for the #ifndef hande-shake at the
/// top of the file when reading preprocessor directives. Otherwise, reading
/// the "ifndef x" would count as reading tokens.
bool getHasReadAnyTokensVal() const { return ReadAnyTokens; }
-
+
// If a token is read, remember that we have seen a side-effect in this file.
void ReadToken() { ReadAnyTokens = true; }
-
+
/// ExpandedMacro - When a macro is expanded with this lexer as the current
/// buffer, this method is called to disable the MIOpt if needed.
void ExpandedMacro() { DidMacroExpansion = true; }
-
+
/// EnterTopLevelIFNDEF - When entering a top-level #ifndef directive (or the
/// "#if !defined" equivalent) without any preceding tokens, this method is
/// called.
@@ -80,14 +80,14 @@ public:
// If the macro is already set, this is after the top-level #endif.
if (TheMacro)
return Invalidate();
-
+
// If we have already expanded a macro by the end of the #ifndef line, then
// there is a macro expansion *in* the #ifndef line. This means that the
// condition could evaluate differently when subsequently #included. Reject
// this.
if (DidMacroExpansion)
return Invalidate();
-
+
// Remember that we're in the #if and that we have the macro.
ReadAnyTokens = true;
TheMacro = M;
@@ -100,7 +100,7 @@ public:
/// there is a chunk of the file not guarded by the controlling macro.
Invalidate();
}
-
+
/// ExitTopLevelConditional - This method is called when the lexer exits the
/// top-level conditional.
void ExitTopLevelConditional() {
@@ -108,12 +108,12 @@ public:
// back to "not having read any tokens" so we can detect anything after the
// #endif.
if (!TheMacro) return Invalidate();
-
+
// At this point, we haven't "read any tokens" but we do have a controlling
// macro.
ReadAnyTokens = false;
}
-
+
/// GetControllingMacroAtEndOfFile - Once the entire file has been lexed, if
/// there is a controlling macro, return it.
const IdentifierInfo *GetControllingMacroAtEndOfFile() const {
diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h
index e5cbeebd22..dd24fb7d7b 100644
--- a/include/clang/Lex/PPCallbacks.h
+++ b/include/clang/Lex/PPCallbacks.h
@@ -23,18 +23,18 @@ namespace clang {
class Token;
class IdentifierInfo;
class MacroInfo;
-
+
/// PPCallbacks - This interface provides a way to observe the actions of the
/// preprocessor as it does its thing. Clients can define their hooks here to
/// implement preprocessor level tools.
class PPCallbacks {
public:
virtual ~PPCallbacks();
-
+
enum FileChangeReason {
EnterFile, ExitFile, SystemHeaderPragma, RenameFile
};
-
+
/// FileChanged - This callback is invoked whenever a source file is
/// entered or exited. The SourceLocation indicates the new location, and
/// EnteringFile indicates whether this is because we are entering a new
@@ -43,25 +43,25 @@ public:
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType) {
}
-
+
/// Ident - This callback is invoked when a #ident or #sccs directive is read.
///
virtual void Ident(SourceLocation Loc, const std::string &str) {
}
-
+
/// PragmaComment - This callback is invoked when a #pragma comment directive
/// is read.
///
- virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
+ virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str) {
}
-
+
/// MacroExpands - This is called by
/// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is
/// found.
virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
}
-
+
/// MacroDefined - This hook is called whenever a macro definition is seen.
virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
}
@@ -76,7 +76,7 @@ public:
class PPChainedCallbacks : public PPCallbacks {
PPCallbacks *First, *Second;
-public:
+public:
PPChainedCallbacks(PPCallbacks *_First, PPCallbacks *_Second)
: First(_First), Second(_Second) {}
~PPChainedCallbacks() {
@@ -89,23 +89,23 @@ public:
First->FileChanged(Loc, Reason, FileType);
Second->FileChanged(Loc, Reason, FileType);
}
-
+
virtual void Ident(SourceLocation Loc, const std::string &str) {
First->Ident(Loc, str);
Second->Ident(Loc, str);
}
-
- virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
+
+ virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str) {
First->PragmaComment(Loc, Kind, Str);
Second->PragmaComment(Loc, Kind, Str);
}
-
+
virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
First->MacroExpands(Id, MI);
Second->MacroExpands(Id, MI);
}
-
+
virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
First->MacroDefined(II, MI);
Second->MacroDefined(II, MI);
diff --git a/include/clang/Lex/PTHLexer.h b/include/clang/Lex/PTHLexer.h
index 369b818a1f..e96a8c514e 100644
--- a/include/clang/Lex/PTHLexer.h
+++ b/include/clang/Lex/PTHLexer.h
@@ -18,42 +18,42 @@
#include <vector>
namespace clang {
-
+
class PTHManager;
class PTHSpellingSearch;
-
+
class PTHLexer : public PreprocessorLexer {
SourceLocation FileStartLoc;
-
+
/// TokBuf - Buffer from PTH file containing raw token data.
const unsigned char* TokBuf;
-
+
/// CurPtr - Pointer into current offset of the token buffer where
/// the next token will be read.
const unsigned char* CurPtr;
-
+
/// LastHashTokPtr - Pointer into TokBuf of the last processed '#'
/// token that appears at the start of a line.
const unsigned char* LastHashTokPtr;
-
+
/// PPCond - Pointer to a side table in the PTH file that provides a
/// a consise summary of the preproccessor conditional block structure.
/// This is used to perform quick skipping of conditional blocks.
const unsigned char* PPCond;
-
+
/// CurPPCondPtr - Pointer inside PPCond that refers to the next entry
/// to process when doing quick skipping of preprocessor blocks.
const unsigned char* CurPPCondPtr;
PTHLexer(const PTHLexer&); // DO NOT IMPLEMENT
void operator=(const PTHLexer&); // DO NOT IMPLEMENT
-
+
/// ReadToken - Used by PTHLexer to read tokens TokBuf.
void ReadToken(Token& T);
/// PTHMgr - The PTHManager object that created this PTHLexer.
PTHManager& PTHMgr;
-
+
Token EofToken;
protected:
@@ -62,19 +62,19 @@ protected:
/// Create a PTHLexer for the specified token stream.
PTHLexer(Preprocessor& pp, FileID FID, const unsigned char *D,
const unsigned char* ppcond, PTHManager &PM);
-public:
+public:
~PTHLexer() {}
-
+
/// Lex - Return the next token.
void Lex(Token &Tok);
-
+
void getEOF(Token &Tok);
-
+
/// DiscardToEndOfLine - Read the rest of the current preprocessor line as an
/// uninterpreted string. This switches the lexer out of directive mode.
void DiscardToEndOfLine();
-
+
/// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a
/// tok::l_paren token, 0 if it is something else and 2 if there are no more
/// tokens controlled by this lexer.
@@ -85,12 +85,12 @@ public:
// its kind.
tok::TokenKind x = (tok::TokenKind)*CurPtr;
return x == tok::eof ? 2 : x == tok::l_paren;
- }
+ }
/// IndirectLex - An indirect call to 'Lex' that can be invoked via
/// the PreprocessorLexer interface.
void IndirectLex(Token &Result) { Lex(Result); }
-
+
/// getSourceLocation - Return a source location for the token in
/// the current file.
SourceLocation getSourceLocation();
diff --git a/include/clang/Lex/PTHManager.h b/include/clang/Lex/PTHManager.h
index 507576473f..ff1a17259e 100644
--- a/include/clang/Lex/PTHManager.h
+++ b/include/clang/Lex/PTHManager.h
@@ -32,29 +32,29 @@ class FileEntry;
class PTHLexer;
class Diagnostic;
class StatSysCallCache;
-
+
class PTHManager : public IdentifierInfoLookup {
friend class PTHLexer;
-
+
/// The memory mapped PTH file.
const llvm::MemoryBuffer* Buf;
/// Alloc - Allocator used for IdentifierInfo objects.
llvm::BumpPtrAllocator Alloc;
-
+
/// IdMap - A lazily generated cache mapping from persistent identifiers to
/// IdentifierInfo*.
IdentifierInfo** PerIDCache;
-
+
/// FileLookup - Abstract data structure used for mapping between files
/// and token data in the PTH file.
void* FileLookup;
-
+
/// IdDataTable - Array representing the mapping from persistent IDs to the
/// data offset within the PTH file containing the information to
/// reconsitute an IdentifierInfo.
const unsigned char* const IdDataTable;
-
+
/// SortedIdTable - Abstract data structure mapping from strings to
/// persistent IDs. This is used by get().
void* StringIdLookup;
@@ -65,15 +65,15 @@ class PTHManager : public IdentifierInfoLookup {
/// PP - The Preprocessor object that will use this PTHManager to create
/// PTHLexer objects.
Preprocessor* PP;
-
- /// SpellingBase - The base offset within the PTH memory buffer that
+
+ /// SpellingBase - The base offset within the PTH memory buffer that
/// contains the cached spellings for literals.
const unsigned char* const SpellingBase;
-
+
/// OriginalSourceFile - A null-terminated C-string that specifies the name
/// if the file (if any) that was to used to generate the PTH cache.
const char* OriginalSourceFile;
-
+
/// This constructor is intended to only be called by the static 'Create'
/// method.
PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup,
@@ -84,11 +84,11 @@ class PTHManager : public IdentifierInfoLookup {
// Do not implement.
PTHManager();
void operator=(const PTHManager&);
-
- /// getSpellingAtPTHOffset - Used by PTHLexer classes to get the cached
+
+ /// getSpellingAtPTHOffset - Used by PTHLexer classes to get the cached
/// spelling for a token.
unsigned getSpellingAtPTHOffset(unsigned PTHOffset, const char*& Buffer);
-
+
/// GetIdentifierInfo - Used to reconstruct IdentifierInfo objects from the
/// PTH file.
inline IdentifierInfo* GetIdentifierInfo(unsigned PersistentID) {
@@ -98,44 +98,44 @@ class PTHManager : public IdentifierInfoLookup {
return LazilyCreateIdentifierInfo(PersistentID);
}
IdentifierInfo* LazilyCreateIdentifierInfo(unsigned PersistentID);
-
+
public:
// The current PTH version.
enum { Version = 9 };
~PTHManager();
-
+
/// getOriginalSourceFile - Return the full path to the original header
/// file name that was used to generate the PTH cache.
const char* getOriginalSourceFile() const {
return OriginalSourceFile;
}
-
+
/// get - Return the identifier token info for the specified named identifier.
/// Unlike the version in IdentifierTable, this returns a pointer instead
/// of a reference. If the pointer is NULL then the IdentifierInfo cannot
/// be found.
IdentifierInfo *get(const char *NameStart, const char *NameEnd);
-
+
/// Create - This method creates PTHManager objects. The 'file' argument
/// is the name of the PTH file. This method returns NULL upon failure.
static PTHManager *Create(const std::string& file, Diagnostic* Diags = 0,
Diagnostic::Level failureLevel=Diagnostic::Warning);
- void setPreprocessor(Preprocessor *pp) { PP = pp; }
-
+ void setPreprocessor(Preprocessor *pp) { PP = pp; }
+
/// CreateLexer - Return a PTHLexer that "lexes" the cached tokens for the
/// specified file. This method returns NULL if no cached tokens exist.
/// It is the responsibility of the caller to 'delete' the returned object.
- PTHLexer *CreateLexer(FileID FID);
-
+ PTHLexer *CreateLexer(FileID FID);
+
/// createStatCache - Returns a StatSysCallCache object for use with
/// FileManager objects. These objects use the PTH data to speed up
/// calls to stat by memoizing their results from when the PTH file
/// was generated.
StatSysCallCache *createStatCache();
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Lex/Pragma.h b/include/clang/Lex/Pragma.h
index 136dc6fabf..ef367feb84 100644
--- a/include/clang/Lex/Pragma.h
+++ b/include/clang/Lex/Pragma.h
@@ -37,10 +37,10 @@ class PragmaHandler {
public:
PragmaHandler(const IdentifierInfo *name) : Name(name) {}
virtual ~PragmaHandler();
-
+
const IdentifierInfo *getName() const { return Name; }
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken) = 0;
-
+
/// getIfNamespace - If this is a namespace, return it. This is equivalent to
/// using a dynamic_cast, but doesn't require RTTI.
virtual PragmaNamespace *getIfNamespace() { return 0; }
@@ -57,14 +57,14 @@ class PragmaNamespace : public PragmaHandler {
public:
PragmaNamespace(const IdentifierInfo *Name) : PragmaHandler(Name) {}
virtual ~PragmaNamespace();
-
+
/// FindHandler - Check to see if there is already a handler for the
/// specified name. If not, return the handler for the null identifier if it
/// exists, otherwise return null. If IgnoreNull is true (the default) then
/// the null handler isn't returned on failure to match.
PragmaHandler *FindHandler(const IdentifierInfo *Name,
bool IgnoreNull = true) const;
-
+
/// AddPragma - Add a pragma to this namespace.
///
void AddPragma(PragmaHandler *Handler) {
@@ -75,12 +75,12 @@ public:
/// namespace.
void RemovePragmaHandler(PragmaHandler *Handler);
- bool IsEmpty() {
- return Handlers.empty();
+ bool IsEmpty() {
+ return Handlers.empty();
}
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
-
+
virtual PragmaNamespace *getIfNamespace() { return this; }
};
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index f1647afaa3..d1c508a542 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -29,7 +29,7 @@
#include <vector>
namespace clang {
-
+
class SourceManager;
class FileManager;
class FileEntry;
@@ -41,7 +41,7 @@ class ScratchBuffer;
class TargetInfo;
class PPCallbacks;
class DirectoryLookup;
-
+
/// Preprocessor - This object engages in a tight little dance with the lexer to
/// efficiently preprocess tokens. Lexers know only about tokens within a
/// single source file, and don't know anything about preprocessor-level issues
@@ -55,15 +55,15 @@ class Preprocessor {
SourceManager &SourceMgr;
ScratchBuffer *ScratchBuf;
HeaderSearch &HeaderInfo;
-
+
/// PTH - An optional PTHManager object used for getting tokens from
/// a token cache rather than lexing the original source file.
llvm::OwningPtr<PTHManager> PTH;
-
+
/// BP - A BumpPtrAllocator object used to quickly allocate and release
/// objects internal to the Preprocessor.
llvm::BumpPtrAllocator BP;
-
+
/// Identifiers for builtin macros and other builtins.
IdentifierInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__
IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__
@@ -74,7 +74,7 @@ class Preprocessor {
IdentifierInfo *Ident_Pragma, *Ident__VA_ARGS__; // _Pragma, __VA_ARGS__
IdentifierInfo *Ident__has_feature; // __has_feature
IdentifierInfo *Ident__has_builtin; // __has_builtin
-
+
SourceLocation DATELoc, TIMELoc;
unsigned CounterValue; // Next __COUNTER__ value.
@@ -86,7 +86,7 @@ class Preprocessor {
// State that is set before the preprocessor begins.
bool KeepComments : 1;
bool KeepMacroComments : 1;
-
+
// State that changes while the preprocessor runs:
bool DisableMacroExpansion : 1; // True if macro expansion is disabled.
bool InMacroArgs : 1; // True if parsing fn macro invocation args.
@@ -94,42 +94,42 @@ class Preprocessor {
/// Identifiers - This is mapping/lookup information for all identifiers in
/// the program, including program keywords.
IdentifierTable Identifiers;
-
+
/// Selectors - This table contains all the selectors in the program. Unlike
/// IdentifierTable above, this table *isn't* populated by the preprocessor.
- /// It is declared/instantiated here because it's role/lifetime is
+ /// It is declared/instantiated here because it's role/lifetime is
/// conceptually similar the IdentifierTable. In addition, the current control
- /// flow (in clang::ParseAST()), make it convenient to put here.
+ /// flow (in clang::ParseAST()), make it convenient to put here.
/// FIXME: Make sure the lifetime of Identifiers/Selectors *isn't* tied to
/// the lifetime fo the preprocessor.
SelectorTable Selectors;
/// BuiltinInfo - Information about builtins.
Builtin::Context BuiltinInfo;
-
+
/// PragmaHandlers - This tracks all of the pragmas that the client registered
/// with this preprocessor.
PragmaNamespace *PragmaHandlers;
-
- /// \brief Tracks all of the comment handlers that the client registered
+
+ /// \brief Tracks all of the comment handlers that the client registered
/// with this preprocessor.
std::vector<CommentHandler *> CommentHandlers;
-
+
/// CurLexer - This is the current top of the stack that we're lexing from if
/// not expanding a macro and we are lexing directly from source code.
/// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null.
llvm::OwningPtr<Lexer> CurLexer;
-
+
/// CurPTHLexer - This is the current top of stack that we're lexing from if
/// not expanding from a macro and we are lexing from a PTH cache.
/// Only one of CurLexer, CurPTHLexer, or CurTokenLexer will be non-null.
llvm::OwningPtr<PTHLexer> CurPTHLexer;
-
+
/// CurPPLexer - This is the current top of the stack what we're lexing from
/// if not expanding a macro. This is an alias for either CurLexer or
/// CurPTHLexer.
PreprocessorLexer* CurPPLexer;
-
+
/// CurLookup - The DirectoryLookup structure used to find the current
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to
/// implement #include_next and find directory-specific properties.
@@ -138,7 +138,7 @@ class Preprocessor {
/// CurTokenLexer - This is the current macro we are expanding, if we are
/// expanding a macro. One of CurLexer and CurTokenLexer must be null.
llvm::OwningPtr<TokenLexer> CurTokenLexer;
-
+
/// IncludeMacroStack - This keeps track of the stack of files currently
/// #included, and macros currently being expanded from, not counting
/// CurLexer/CurTokenLexer.
@@ -146,7 +146,7 @@ class Preprocessor {
Lexer *TheLexer;
PTHLexer *ThePTHLexer;
PreprocessorLexer *ThePPLexer;
- TokenLexer *TheTokenLexer;
+ TokenLexer *TheTokenLexer;
const DirectoryLookup *TheDirLookup;
IncludeStackInfo(Lexer *L, PTHLexer* P, PreprocessorLexer* PPL,
@@ -155,19 +155,19 @@ class Preprocessor {
TheDirLookup(D) {}
};
std::vector<IncludeStackInfo> IncludeMacroStack;
-
+
/// Callbacks - These are actions invoked when some preprocessor activity is
/// encountered (e.g. a file is #included, etc).
PPCallbacks *Callbacks;
-
+
/// Macros - For each IdentifierInfo with 'HasMacro' set, we keep a mapping
/// to the actual definition of the macro.
llvm::DenseMap<IdentifierInfo*, MacroInfo*> Macros;
-
+
/// MICache - A "freelist" of MacroInfo objects that can be reused for quick
/// allocation.
std::vector<MacroInfo*> MICache;
-
+
// Various statistics we track for performance analysis.
unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma;
unsigned NumIf, NumElse, NumEndif;
@@ -175,11 +175,11 @@ class Preprocessor {
unsigned NumMacroExpanded, NumFnMacroExpanded, NumBuiltinMacroExpanded;
unsigned NumFastMacroExpanded, NumTokenPaste, NumFastTokenPaste;
unsigned NumSkipped;
-
+
/// Predefines - This string is the predefined macros that preprocessor
/// should use from the command line etc.
std::string Predefines;
-
+
/// TokenLexerCache - Cache macro expanders to reduce malloc traffic.
enum { TokenLexerCacheSize = 8 };
unsigned NumCachedTokenLexers;
@@ -223,9 +223,9 @@ public:
SelectorTable &getSelectorTable() { return Selectors; }
Builtin::Context &getBuiltinInfo() { return BuiltinInfo; }
llvm::BumpPtrAllocator &getPreprocessorAllocator() { return BP; }
-
+
void setPTHManager(PTHManager* pm);
-
+
PTHManager *getPTHManager() { return PTH.get(); }
/// SetCommentRetentionState - Control whether or not the preprocessor retains
@@ -234,20 +234,20 @@ public:
this->KeepComments = KeepComments | KeepMacroComments;
this->KeepMacroComments = KeepMacroComments;
}
-
+
bool getCommentRetentionState() const { return KeepComments; }
-
+
/// isCurrentLexer - Return true if we are lexing directly from the specified
/// lexer.
bool isCurrentLexer(const PreprocessorLexer *L) const {
return CurPPLexer == L;
}
-
+
/// getCurrentLexer - Return the current file lexer being lexed from. Note
/// that this ignores any potentially active macro expansions and _Pragma
/// expansions going on at the time.
PreprocessorLexer *getCurrentFileLexer() const;
-
+
/// getPPCallbacks/setPPCallbacks - Accessors for preprocessor callbacks.
/// Note that this class takes ownership of any PPCallbacks object given to
/// it.
@@ -257,32 +257,32 @@ public:
C = new PPChainedCallbacks(C, Callbacks);
Callbacks = C;
}
-
+
/// getMacroInfo - Given an identifier, return the MacroInfo it is #defined to
/// or null if it isn't #define'd.
MacroInfo *getMacroInfo(IdentifierInfo *II) const {
return II->hasMacroDefinition() ? Macros.find(II)->second : 0;
}
-
+
/// setMacroInfo - Specify a macro for this identifier.
///
void setMacroInfo(IdentifierInfo *II, MacroInfo *MI);
-
+
/// macro_iterator/macro_begin/macro_end - This allows you to walk the current
/// state of the macro table. This visits every currently-defined macro.
- typedef llvm::DenseMap<IdentifierInfo*,
+ typedef llvm::DenseMap<IdentifierInfo*,
MacroInfo*>::const_iterator macro_iterator;
macro_iterator macro_begin() const { return Macros.begin(); }
macro_iterator macro_end() const { return Macros.end(); }
-
-
-
+
+
+
const std::string &getPredefines() const { return Predefines; }
/// setPredefines - Set the predefines for this Preprocessor. These
/// predefines are automatically injected when parsing the main file.
void setPredefines(const char *P) { Predefines = P; }
void setPredefines(const std::string &P) { Predefines = P; }
-
+
/// getIdentifierInfo - Return information about the specified preprocessor
/// identifier token. The version of this method that takes two character
/// pointers is preferred unless the identifier is already available as a
@@ -295,7 +295,7 @@ public:
IdentifierInfo *getIdentifierInfo(const char *NameStr) {
return getIdentifierInfo(NameStr, NameStr+strlen(NameStr));
}
-
+
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
@@ -309,16 +309,16 @@ public:
/// \brief Add the specified comment handler to the preprocessor.
void AddCommentHandler(CommentHandler *Handler);
-
+
/// \brief Remove the specified comment handler.
///
/// It is an error to remove a handler that has not been registered.
void RemoveCommentHandler(CommentHandler *Handler);
-
+
/// EnterMainSourceFile - Enter the specified FileID as the main source file,
/// which implicitly adds the builtin defines etc.
- void EnterMainSourceFile();
-
+ void EnterMainSourceFile();
+
/// EnterSourceFile - Add a source file to the top of the include stack and
/// start lexing tokens from it instead of the current buffer. If isMainFile
/// is true, this is the main file for the translation unit.
@@ -331,7 +331,7 @@ public:
/// ILEnd specifies the location of the ')' for a function-like macro or the
/// identifier for an object-like macro.
void EnterMacro(Token &Identifier, SourceLocation ILEnd, MacroArgs *Args);
-
+
/// EnterTokenStream - Add a "macro" context to the top of the include stack,
/// which will cause the lexer to start returning the specified tokens.
///
@@ -346,7 +346,7 @@ public:
///
void EnterTokenStream(const Token *Toks, unsigned NumToks,
bool DisableMacroExpansion, bool OwnsTokens);
-
+
/// RemoveTopOfLexerStack - Pop the current lexer/macro exp off the top of the
/// lexer stack. This should only be used in situations where the current
/// state of the top-of-stack lexer is known.
@@ -371,7 +371,7 @@ public:
void CommitBacktrackedTokens();
/// Backtrack - Make Preprocessor re-lex the tokens that were lexed since
- /// EnableBacktrackAtThisPos() was previously called.
+ /// EnableBacktrackAtThisPos() was previously called.
void Backtrack();
/// isBacktrackEnabled - True if EnableBacktrackAtThisPos() was called and
@@ -390,7 +390,7 @@ public:
else
CachingLex(Result);
}
-
+
/// LexNonComment - Lex a token. If it's a comment, keep lexing until we get
/// something not a comment. This is useful in -E -C mode where comments
/// would foul up preprocessor directive handling.
@@ -408,11 +408,11 @@ public:
DisableMacroExpansion = true;
// Lex the token.
Lex(Result);
-
+
// Reenable it.
DisableMacroExpansion = OldVal;
}
-
+
/// LookAhead - This peeks ahead N tokens and returns that token without
/// consuming any tokens. LookAhead(0) returns the next token that would be
/// returned by Lex(), LookAhead(1) returns the token after it, etc. This
@@ -461,7 +461,7 @@ public:
AnnotatePreviousCachedTokens(Tok);
}
- /// \brief Replace the last token with an annotation token.
+ /// \brief Replace the last token with an annotation token.
///
/// Like AnnotateCachedTokens(), this routine replaces an
/// already-parsed (and resolved) token with an annotation
@@ -481,19 +481,19 @@ public:
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) {
return Diags->Report(FullSourceLoc(Loc, getSourceManager()), DiagID);
}
-
+
DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID) {
return Diags->Report(FullSourceLoc(Tok.getLocation(), getSourceManager()),
DiagID);
}
-
+
/// getSpelling() - Return the 'spelling' of the Tok token. The spelling of a
/// token is the characters used to represent the token in the source file
/// after trigraph expansion and escaped-newline folding. In particular, this
/// wants to get the true, uncanonicalized, spelling of things like digraphs
/// UCNs, etc.
std::string getSpelling(const Token &Tok) const;
-
+
/// getSpelling - This method is used to get the spelling of a token into a
/// preallocated buffer, instead of as an std::string. The caller is required
/// to allocate enough space for the token, which is guaranteed to be at least
@@ -521,7 +521,7 @@ public:
// works.
return *SourceMgr.getCharacterData(Tok.getLocation());
}
-
+
/// CreateString - Plop the specified string into a scratch buffer and set the
/// specified token's location and length to it. If specified, the source
/// location provides a location of the instantiation point of the token.
@@ -539,35 +539,35 @@ public:
/// it points into a macro), this routine returns an invalid
/// source location.
SourceLocation getLocForEndOfToken(SourceLocation Loc);
-
+
/// DumpToken - Print the token to stderr, used for debugging.
///
void DumpToken(const Token &Tok, bool DumpFlags = false) const;
void DumpLocation(SourceLocation Loc) const;
void DumpMacro(const MacroInfo &MI) const;
-
+
/// AdvanceToTokenCharacter - Given a location that specifies the start of a
/// token, return a new location that specifies a character within the token.
SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart,unsigned Char);
-
+
/// IncrementPasteCounter - Increment the counters for the number of token
/// paste operations performed. If fast was specified, this is a 'fast paste'
/// case we handled.
- ///
+ ///
void IncrementPasteCounter(bool isFast) {
if (isFast)
++NumFastTokenPaste;
else
++NumTokenPaste;
}
-
+
void PrintStats();
/// HandleMicrosoftCommentPaste - When the macro expander pastes together a
/// comment (/##/) in microsoft mode, this method handles updating the current
/// state, returning the token on the next source line.
void HandleMicrosoftCommentPaste(Token &Tok);
-
+
//===--------------------------------------------------------------------===//
// Preprocessor callback methods. These are invoked by a lexer as various
// directives and events are found.
@@ -576,26 +576,26 @@ public:
/// identifier information for the token and install it into the token.
IdentifierInfo *LookUpIdentifierInfo(Token &Identifier,
const char *BufPtr = 0);
-
+
/// HandleIdentifier - This callback is invoked when the lexer reads an
/// identifier and has filled in the tokens IdentifierInfo member. This
/// callback potentially macro expands it or turns it into a named token (like
/// 'for').
void HandleIdentifier(Token &Identifier);
-
+
/// HandleEndOfFile - This callback is invoked when the lexer hits the end of
/// the current file. This either returns the EOF token and returns true, or
/// pops a level off the include stack and returns false, at which point the
/// client should call lex again.
bool HandleEndOfFile(Token &Result, bool isEndOfMacro = false);
-
+
/// HandleEndOfTokenLexer - This callback is invoked when the current
/// TokenLexer hits the end of its token stream.
bool HandleEndOfTokenLexer(Token &Result);
-
+
/// HandleDirective - This callback is invoked when the lexer sees a # token
- /// at the start of a line. This consumes the directive, modifies the
+ /// at the start of a line. This consumes the directive, modifies the
/// lexer/preprocessor state, and advances the lexer(s) so that the next token
/// read is the correct one.
void HandleDirective(Token &Result);
@@ -604,11 +604,11 @@ public:
/// not, emit a diagnostic and consume up until the eom. If EnableMacros is
/// true, then we consider macros that expand to zero tokens as being ok.
void CheckEndOfDirective(const char *Directive, bool EnableMacros = false);
-
+
/// DiscardUntilEndOfDirective - Read and discard all tokens remaining on the
/// current line until the tok::eom token is found.
void DiscardUntilEndOfDirective();
-
+
/// SawDateOrTime - This returns true if the preprocessor has seen a use of
/// __DATE__ or __TIME__ in the file so far.
bool SawDateOrTime() const {
@@ -616,13 +616,13 @@ public:
}
unsigned getCounterValue() const { return CounterValue; }
void setCounterValue(unsigned V) { CounterValue = V; }
-
+
/// AllocateMacroInfo - Allocate a new MacroInfo object with the provide
/// SourceLocation.
MacroInfo* AllocateMacroInfo(SourceLocation L);
-
+
private:
-
+
void PushIncludeMacroStack() {
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer.take(),
CurPTHLexer.take(),
@@ -631,7 +631,7 @@ private:
CurDirLookup));
CurPPLexer = 0;
}
-
+
void PopIncludeMacroStack() {
CurLexer.reset(IncludeMacroStack.back().TheLexer);
CurPTHLexer.reset(IncludeMacroStack.back().ThePTHLexer);
@@ -640,11 +640,11 @@ private:
CurDirLookup = IncludeMacroStack.back().TheDirLookup;
IncludeMacroStack.pop_back();
}
-
+
/// ReleaseMacroInfo - Release the specified MacroInfo. This memory will
/// be reused for allocating new MacroInfo objects.
void ReleaseMacroInfo(MacroInfo* MI);
-
+
/// isInPrimaryFile - Return true if we're in the top-level file, not in a
/// #include.
bool isInPrimaryFile() const;
@@ -653,13 +653,13 @@ private:
/// #define or #undef. This emits a diagnostic, sets the token kind to eom,
/// and discards the rest of the macro line if the macro name is invalid.
void ReadMacroName(Token &MacroNameTok, char isDefineUndef = 0);
-
+
/// ReadMacroDefinitionArgList - The ( starting an argument list of a macro
/// definition has just been read. Lex the rest of the arguments and the
/// closing ), updating MI with what we learn. Return true if an error occurs
/// parsing the arg list.
bool ReadMacroDefinitionArgList(MacroInfo *MI);
-
+
/// SkipExcludedConditionalBlock - We just read a #if or related directive and
/// decided that the subsequent tokens are in the #if'd out portion of the
/// file. Lex the rest of the file, until we see an #endif. If
@@ -670,34 +670,34 @@ private:
/// the caller can lex the first valid token.
void SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
bool FoundNonSkipPortion, bool FoundElse);
-
+
/// PTHSkipExcludedConditionalBlock - A fast PTH version of
/// SkipExcludedConditionalBlock.
void PTHSkipExcludedConditionalBlock();
-
+
/// EvaluateDirectiveExpression - Evaluate an integer constant expression that
/// may occur after a #if or #elif directive and return it as a bool. If the
/// expression is equivalent to "!defined(X)" return X in IfNDefMacro.
bool EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro);
-
+
/// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
/// #pragma GCC poison/system_header/dependency and #pragma once.
void RegisterBuiltinPragmas();
-
+
/// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the
/// identifier table.
void RegisterBuiltinMacros();
-
+
/// HandleMacroExpandedIdentifier - If an identifier token is read that is to
/// be expanded as a macro, handle it and return the next token as 'Tok'. If
/// the macro should not be expanded return true, otherwise return false.
bool HandleMacroExpandedIdentifier(Token &Tok, MacroInfo *MI);
-
+
/// isNextPPTokenLParen - Determine whether the next preprocessor token to be
/// lexed is a '('. If so, consume the token and return true, if not, this
/// method should have no observable side-effect on the lexed tokens.
bool isNextPPTokenLParen();
-
+
/// ReadFunctionLikeMacroArgs - After reading "MACRO(", this method is
/// invoked to read all of the formal arguments specified for the macro
/// invocation. This returns null on error.
@@ -707,12 +707,12 @@ private:
/// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
/// as a builtin macro, handle it and return the next token as 'Tok'.
void ExpandBuiltinMacro(Token &Tok);
-
+
/// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then
/// return the first token after the directive. The _Pragma token has just
/// been read into 'Tok'.
void Handle_Pragma(Token &Tok);
-
+
/// EnterSourceFileWithLexer - Add a lexer to the top of the include stack and
/// start lexing tokens from it instead of the current buffer.
void EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *Dir);
@@ -720,7 +720,7 @@ private:
/// EnterSourceFileWithPTH - Add a lexer to the top of the include stack and
/// start getting tokens from it using the PTH cache.
void EnterSourceFileWithPTH(PTHLexer *PL, const DirectoryLookup *Dir);
-
+
/// GetIncludeFilenameSpelling - Turn the specified lexer token into a fully
/// checked and spelled filename, e.g. as an operand of #include. This returns
/// true if the input filename was in <>'s or false if it were in ""'s. The
@@ -729,7 +729,7 @@ private:
/// this method decides to use a different buffer.
bool GetIncludeFilenameSpelling(SourceLocation Loc,
const char *&BufStart, const char *&BufEnd);
-
+
/// LookupFile - Given a "foo" or <foo> reference, look up the indicated file,
/// return null on failure. isAngled indicates whether the file reference is
/// for system #include's or not (i.e. using <> instead of "").
@@ -737,7 +737,7 @@ private:
bool isAngled, const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir);
-
+
/// IsFileLexer - Returns true if we are lexing from a file and not a
/// pragma or a macro.
@@ -752,7 +752,7 @@ private:
bool IsFileLexer() const {
return IsFileLexer(CurLexer.get(), CurPPLexer);
}
-
+
//===--------------------------------------------------------------------===//
// Caching stuff.
void CachingLex(Token &Result);
@@ -773,7 +773,7 @@ private:
void HandleDigitDirective(Token &Tok);
void HandleUserDiagnosticDirective(Token &Tok, bool isWarning);
void HandleIdentSCCSDirective(Token &Tok);
-
+
// File inclusion.
void HandleIncludeDirective(Token &Tok,
const DirectoryLookup *LookupFrom = 0,
@@ -781,13 +781,13 @@ private:
void HandleIncludeNextDirective(Token &Tok);
void HandleIncludeMacrosDirective(Token &Tok);
void HandleImportDirective(Token &Tok);
-
+
// Macro handling.
void HandleDefineDirective(Token &Tok);
void HandleUndefDirective(Token &Tok);
// HandleAssertDirective(Token &Tok);
// HandleUnassertDirective(Token &Tok);
-
+
// Conditional Inclusion.
void HandleIfdefDirective(Token &Tok, bool isIfndef,
bool ReadAnyTokensBeforeDirective);
@@ -795,7 +795,7 @@ private:
void HandleEndifDirective(Token &Tok);
void HandleElseDirective(Token &Tok);
void HandleElifDirective(Token &Tok);
-
+
// Pragmas.
void HandlePragmaDirective();
public:
@@ -813,18 +813,18 @@ public:
class PreprocessorFactory {
public:
virtual ~PreprocessorFactory();
- virtual Preprocessor* CreatePreprocessor() = 0;
+ virtual Preprocessor* CreatePreprocessor() = 0;
};
-
-/// \brief Abstract base class that describes a handler that will receive
+
+/// \brief Abstract base class that describes a handler that will receive
/// source ranges for each of the comments encountered in the source file.
class CommentHandler {
public:
virtual ~CommentHandler();
-
+
virtual void HandleComment(Preprocessor &PP, SourceRange Comment) = 0;
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Lex/PreprocessorLexer.h b/include/clang/Lex/PreprocessorLexer.h
index 6a3c2bd43f..85c44c5a0b 100644
--- a/include/clang/Lex/PreprocessorLexer.h
+++ b/include/clang/Lex/PreprocessorLexer.h
@@ -29,19 +29,19 @@ protected:
/// The SourceManager FileID corresponding to the file being lexed.
const FileID FID;
-
+
//===--------------------------------------------------------------------===//
// Context-specific lexing flags set by the preprocessor.
//===--------------------------------------------------------------------===//
-
+
/// ParsingPreprocessorDirective - This is true when parsing #XXX. This turns
/// '\n' into a tok::eom token.
bool ParsingPreprocessorDirective;
-
+
/// ParsingFilename - True after #include: this turns <xx> into a
/// tok::angle_string_literal token.
bool ParsingFilename;
-
+
/// LexingRawMode - True if in raw mode: This flag disables interpretation of
/// tokens and is a far faster mode to lex in than non-raw-mode. This flag:
/// 1. If EOF of the current lexer is found, the include stack isn't popped.
@@ -54,40 +54,40 @@ protected:
///
/// Note that in raw mode that the PP pointer may be null.
bool LexingRawMode;
-
- /// MIOpt - This is a state machine that detects the #ifndef-wrapping a file
+
+ /// MIOpt - This is a state machine that detects the #ifndef-wrapping a file
/// idiom for the multiple-include optimization.
MultipleIncludeOpt MIOpt;
-
+
/// ConditionalStack - Information about the set of #if/#ifdef/#ifndef blocks
/// we are currently in.
llvm::SmallVector<PPConditionalInfo, 4> ConditionalStack;
-
+
PreprocessorLexer(const PreprocessorLexer&); // DO NOT IMPLEMENT
void operator=(const PreprocessorLexer&); // DO NOT IMPLEMENT
friend class Preprocessor;
-
+
PreprocessorLexer(Preprocessor *pp, FileID fid)
: PP(pp), FID(fid), ParsingPreprocessorDirective(false),
ParsingFilename(false), LexingRawMode(false) {}
-
+
PreprocessorLexer()
- : PP(0),
+ : PP(0),
ParsingPreprocessorDirective(false),
ParsingFilename(false),
LexingRawMode(false) {}
-
+
virtual ~PreprocessorLexer() {}
-
+
virtual void IndirectLex(Token& Result) = 0;
-
+
/// getSourceLocation - Return the source location for the next observable
/// location.
virtual SourceLocation getSourceLocation() = 0;
-
+
//===--------------------------------------------------------------------===//
// #if directive handling.
-
+
/// pushConditionalLevel - When we enter a #if directive, this keeps track of
/// what we are currently in for diagnostic emission (e.g. #if with missing
/// #endif).
@@ -102,8 +102,8 @@ protected:
}
void pushConditionalLevel(const PPConditionalInfo &CI) {
ConditionalStack.push_back(CI);
- }
-
+ }
+
/// popConditionalLevel - Remove an entry off the top of the conditional
/// stack, returning information about it. If the conditional stack is empty,
/// this returns true and does not fill in the arguments.
@@ -113,44 +113,44 @@ protected:
ConditionalStack.pop_back();
return false;
}
-
+
/// peekConditionalLevel - Return the top of the conditional stack. This
/// requires that there be a conditional active.
PPConditionalInfo &peekConditionalLevel() {
assert(!ConditionalStack.empty() && "No conditionals active!");
return ConditionalStack.back();
}
-
- unsigned getConditionalStackDepth() const { return ConditionalStack.size(); }
+
+ unsigned getConditionalStackDepth() const { return ConditionalStack.size(); }
public:
-
+
//===--------------------------------------------------------------------===//
// Misc. lexing methods.
-
+
/// LexIncludeFilename - After the preprocessor has parsed a #include, lex and
/// (potentially) macro expand the filename. If the sequence parsed is not
/// lexically legal, emit a diagnostic and return a result EOM token.
void LexIncludeFilename(Token &Result);
-
+
/// setParsingPreprocessorDirective - Inform the lexer whether or not
/// we are currently lexing a preprocessor directive.
void setParsingPreprocessorDirective(bool f) {
ParsingPreprocessorDirective = f;
}
-
+
/// isLexingRawMode - Return true if this lexer is in raw mode or not.
bool isLexingRawMode() const { return LexingRawMode; }
/// getPP - Return the preprocessor object for this lexer.
Preprocessor *getPP() const { return PP; }
-
- FileID getFileID() const {
+
+ FileID getFileID() const {
assert(PP &&
"PreprocessorLexer::getFileID() should only be used with a Preprocessor");
return FID;
}
-
+
/// getFileEntry - Return the FileEntry corresponding to this FileID. Like
/// getFileID(), this only works for lexers with attached preprocessors.
const FileEntry *getFileEntry() const;
diff --git a/include/clang/Lex/ScratchBuffer.h b/include/clang/Lex/ScratchBuffer.h
index 6506f92629..f03515ffc1 100644
--- a/include/clang/Lex/ScratchBuffer.h
+++ b/include/clang/Lex/ScratchBuffer.h
@@ -29,13 +29,13 @@ class ScratchBuffer {
unsigned BytesUsed;
public:
ScratchBuffer(SourceManager &SM);
-
+
/// getToken - Splat the specified text into a temporary MemoryBuffer and
/// return a SourceLocation that refers to the token. This is just like the
/// previous method, but returns a location that indicates the physloc of the
/// token.
SourceLocation getToken(const char *Buf, unsigned Len, const char *&DestPtr);
-
+
private:
void AllocScratchBuffer(unsigned RequestLen);
};
diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h
index 2c8f2ad3f2..8acdb30cc7 100644
--- a/include/clang/Lex/Token.h
+++ b/include/clang/Lex/Token.h
@@ -62,14 +62,14 @@ class Token {
/// Kind - The actual flavor of token this is.
///
- unsigned Kind : 8; // DON'T make Kind a 'tok::TokenKind';
+ unsigned Kind : 8; // DON'T make Kind a 'tok::TokenKind';
// MSVC will treat it as a signed char and
// TokenKinds > 127 won't be handled correctly.
-
+
/// Flags - Bits we track about this token, members of the TokenFlags enum.
unsigned Flags : 8;
public:
-
+
// Various flags set per token:
enum TokenFlags {
StartOfLine = 0x01, // At start of line or only after whitespace.
@@ -80,7 +80,7 @@ public:
tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }
void setKind(tok::TokenKind K) { Kind = K; }
-
+
/// is/isNot - Predicates to check if this token is a specific kind, as in
/// "if (Tok.is(tok::l_brace)) {...}".
bool is(tok::TokenKind K) const { return Kind == (unsigned) K; }
@@ -94,12 +94,12 @@ public:
is(tok::angle_string_literal);
}
- bool isAnnotation() const {
- return is(tok::annot_typename) ||
+ bool isAnnotation() const {
+ return is(tok::annot_typename) ||
is(tok::annot_cxxscope) ||
is(tok::annot_template_id);
}
-
+
/// getLocation - Return a source location identifier for the specified
/// offset in the current file.
SourceLocation getLocation() const { return Loc; }
@@ -132,11 +132,11 @@ public:
setLocation(R.getBegin());
setAnnotationEndLoc(R.getEnd());
}
-
+
const char *getName() const {
return tok::getTokenName( (tok::TokenKind) Kind);
}
-
+
/// startToken - Reset all flags to cleared.
///
void startToken() {
@@ -145,7 +145,7 @@ public:
PtrData = 0;
Loc = SourceLocation();
}
-
+
IdentifierInfo *getIdentifierInfo() const {
assert(!isAnnotation() && "Used IdentInfo on annotation token!");
if (isLiteral()) return 0;
@@ -154,7 +154,7 @@ public:
void setIdentifierInfo(IdentifierInfo *II) {
PtrData = (void*) II;
}
-
+
/// getLiteralData - For a literal token (numeric constant, string, etc), this
/// returns a pointer to the start of it in the text buffer if known, null
/// otherwise.
@@ -166,7 +166,7 @@ public:
assert(isLiteral() && "Cannot set literal data of non-literal");
PtrData = (void*)Ptr;
}
-
+
void *getAnnotationValue() const {
assert(isAnnotation() && "Used AnnotVal on non-annotation token");
return PtrData;
@@ -175,17 +175,17 @@ public:
assert(isAnnotation() && "Used AnnotVal on non-annotation token");
PtrData = val;
}
-
+
/// setFlag - Set the specified flag.
void setFlag(TokenFlags Flag) {
Flags |= Flag;
}
-
+
/// clearFlag - Unset the specified flag.
void clearFlag(TokenFlags Flag) {
Flags &= ~Flag;
}
-
+
/// getFlags - Return the internal represtation of the flags.
/// Only intended for low-level operations such as writing tokens to
// disk.
@@ -195,32 +195,32 @@ public:
/// setFlagValue - Set a flag to either true or false.
void setFlagValue(TokenFlags Flag, bool Val) {
- if (Val)
+ if (Val)
setFlag(Flag);
else
clearFlag(Flag);
}
-
+
/// isAtStartOfLine - Return true if this token is at the start of a line.
///
bool isAtStartOfLine() const { return (Flags & StartOfLine) ? true : false; }
-
+
/// hasLeadingSpace - Return true if this token has whitespace before it.
///
bool hasLeadingSpace() const { return (Flags & LeadingSpace) ? true : false; }
-
+
/// isExpandDisabled - Return true if this identifier token should never
/// be expanded in the future, due to C99 6.10.3.4p2.
bool isExpandDisabled() const {
return (Flags & DisableExpand) ? true : false;
}
-
- /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
+
+ /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;
-
+
/// getObjCKeywordID - Return the ObjC keyword kind.
tok::ObjCKeywordKind getObjCKeywordID() const;
-
+
/// needsCleaning - Return true if this token has trigraphs or escaped
/// newlines in it.
///
@@ -233,15 +233,15 @@ struct PPConditionalInfo {
/// IfLoc - Location where the conditional started.
///
SourceLocation IfLoc;
-
+
/// WasSkipping - True if this was contained in a skipping directive, e.g.
/// in a "#if 0" block.
bool WasSkipping;
-
+
/// FoundNonSkip - True if we have emitted tokens already, and now we're in
/// an #else block or something. Only useful in Skipping blocks.
bool FoundNonSkip;
-
+
/// FoundElse - True if we've seen a #else in this block. If so,
/// #elif/#else directives are not allowed.
bool FoundElse;
@@ -263,41 +263,41 @@ struct TemplateIdAnnotation {
/// The declaration of the template corresponding to the
/// template-name. This is an Action::DeclTy*.
- void *Template;
+ void *Template;
/// The kind of template that Template refers to.
TemplateNameKind Kind;
/// The location of the '<' before the template argument
- /// list.
+ /// list.
SourceLocation LAngleLoc;
/// The location of the '>' after the template argument
- /// list.
+ /// list.
SourceLocation RAngleLoc;
/// NumArgs - The number of template arguments.
- unsigned NumArgs;
+ unsigned NumArgs;
/// \brief Retrieves a pointer to the template arguments
void **getTemplateArgs() { return (void **)(this + 1); }
/// \brief Retrieves a pointer to the array of template argument
/// locations.
- SourceLocation *getTemplateArgLocations() {
+ SourceLocation *getTemplateArgLocations() {
return (SourceLocation *)(getTemplateArgs() + NumArgs);
}
/// \brief Retrieves a pointer to the array of flags that states
/// whether the template arguments are types.
- bool *getTemplateArgIsType() {
+ bool *getTemplateArgIsType() {
return (bool *)(getTemplateArgLocations() + NumArgs);
}
static TemplateIdAnnotation* Allocate(unsigned NumArgs) {
- TemplateIdAnnotation *TemplateId
- = (TemplateIdAnnotation *)std::malloc(sizeof(TemplateIdAnnotation) +
- sizeof(void*) * NumArgs +
+ TemplateIdAnnotation *TemplateId
+ = (TemplateIdAnnotation *)std::malloc(sizeof(TemplateIdAnnotation) +
+ sizeof(void*) * NumArgs +
sizeof(SourceLocation) * NumArgs +
sizeof(bool) * NumArgs);
TemplateId->NumArgs = NumArgs;
diff --git a/include/clang/Lex/TokenConcatenation.h b/include/clang/Lex/TokenConcatenation.h
index dfc05f4074..d759e47e57 100644
--- a/include/clang/Lex/TokenConcatenation.h
+++ b/include/clang/Lex/TokenConcatenation.h
@@ -19,7 +19,7 @@
namespace clang {
class Preprocessor;
class Token;
-
+
/// TokenConcatenation class, which answers the question of
/// "Is it safe to emit two tokens without a whitespace between them, or
/// would that cause implicit concatenation of the tokens?"
@@ -30,40 +30,40 @@ namespace clang {
///
class TokenConcatenation {
Preprocessor &PP;
-
+
enum AvoidConcatInfo {
/// By default, a token never needs to avoid concatenation. Most tokens
/// (e.g. ',', ')', etc) don't cause a problem when concatenated.
aci_never_avoid_concat = 0,
-
+
/// aci_custom_firstchar - AvoidConcat contains custom code to handle this
/// token's requirements, and it needs to know the first character of the
/// token.
aci_custom_firstchar = 1,
-
+
/// aci_custom - AvoidConcat contains custom code to handle this token's
/// requirements, but it doesn't need to know the first character of the
/// token.
aci_custom = 2,
-
+
/// aci_avoid_equal - Many tokens cannot be safely followed by an '='
/// character. For example, "<<" turns into "<<=" when followed by an =.
aci_avoid_equal = 4
};
-
+
/// TokenInfo - This array contains information for each token on what
/// action to take when avoiding concatenation of tokens in the AvoidConcat
/// method.
char TokenInfo[tok::NUM_TOKENS];
public:
TokenConcatenation(Preprocessor &PP);
-
+
bool AvoidConcat(const Token &PrevTok, const Token &Tok) const;
private:
/// StartsWithL - Return true if the spelling of this token starts with 'L'.
bool StartsWithL(const Token &Tok) const;
-
+
/// IsIdentifierL - Return true if the spelling of this token is literally
/// 'L'.
bool IsIdentifierL(const Token &Tok) const;
diff --git a/include/clang/Lex/TokenLexer.h b/include/clang/Lex/TokenLexer.h
index c0a61cf93e..3f13e9cc12 100644
--- a/include/clang/Lex/TokenLexer.h
+++ b/include/clang/Lex/TokenLexer.h
@@ -21,7 +21,7 @@ namespace clang {
class Preprocessor;
class Token;
class MacroArgs;
-
+
/// TokenLexer - This implements a lexer that returns token from a macro body
/// or token stream instead of lexing from a character buffer. This is used for
/// macro expansion and _Pragma handling, for example.
@@ -47,34 +47,34 @@ class TokenLexer {
/// the preprocessor's bump pointer allocator, or some other buffer that we
/// may or may not own (depending on OwnsTokens).
const Token *Tokens;
-
+
/// NumTokens - This is the length of the Tokens array.
///
unsigned NumTokens;
-
+
/// CurToken - This is the next token that Lex will return.
///
unsigned CurToken;
-
+
/// InstantiateLocStart/End - The source location range where this macro was
/// instantiated.
SourceLocation InstantiateLocStart, InstantiateLocEnd;
-
+
/// Lexical information about the expansion point of the macro: the identifier
/// that the macro expanded from had these properties.
bool AtStartOfLine : 1;
bool HasLeadingSpace : 1;
-
+
/// OwnsTokens - This is true if this TokenLexer allocated the Tokens
/// array, and thus needs to free it when destroyed. For simple object-like
/// macros (for example) we just point into the token buffer of the macro
/// definition, we don't make a copy of it.
bool OwnsTokens : 1;
-
+
/// DisableMacroExpansion - This is true when tokens lexed from the TokenLexer
/// should not be subject to further macro expansion.
bool DisableMacroExpansion : 1;
-
+
TokenLexer(const TokenLexer&); // DO NOT IMPLEMENT
void operator=(const TokenLexer&); // DO NOT IMPLEMENT
public:
@@ -87,13 +87,13 @@ public:
: Macro(0), ActualArgs(0), PP(pp), OwnsTokens(false) {
Init(Tok, ILEnd, ActualArgs);
}
-
+
/// Init - Initialize this TokenLexer to expand from the specified macro
/// with the specified argument information. Note that this ctor takes
/// ownership of the ActualArgs pointer. ILEnd specifies the location of the
/// ')' for a function-like macro or the identifier for an object-like macro.
void Init(Token &Tok, SourceLocation ILEnd, MacroArgs *ActualArgs);
-
+
/// Create a TokenLexer for the specified token stream. If 'OwnsTokens' is
/// specified, this takes ownership of the tokens and delete[]'s them when
/// the token lexer is empty.
@@ -102,45 +102,45 @@ public:
: Macro(0), ActualArgs(0), PP(pp), OwnsTokens(false) {
Init(TokArray, NumToks, DisableExpansion, ownsTokens);
}
-
+
/// Init - Initialize this TokenLexer with the specified token stream.
/// This does not take ownership of the specified token vector.
///
- /// DisableExpansion is true when macro expansion of tokens lexed from this
+ /// DisableExpansion is true when macro expansion of tokens lexed from this
/// stream should be disabled.
void Init(const Token *TokArray, unsigned NumToks,
bool DisableMacroExpansion, bool OwnsTokens);
-
+
~TokenLexer() { destroy(); }
-
+
/// isNextTokenLParen - If the next token lexed will pop this macro off the
/// expansion stack, return 2. If the next unexpanded token is a '(', return
/// 1, otherwise return 0.
unsigned isNextTokenLParen() const;
-
+
/// Lex - Lex and return a token from this macro stream.
void Lex(Token &Tok);
-
+
private:
void destroy();
-
+
/// isAtEnd - Return true if the next lex call will pop this macro off the
/// include stack.
bool isAtEnd() const {
return CurToken == NumTokens;
}
-
+
/// PasteTokens - Tok is the LHS of a ## operator, and CurToken is the ##
/// operator. Read the ## and RHS, and paste the LHS/RHS together. If there
/// are is another ## after it, chomp it iteratively. Return the result as
/// Tok. If this returns true, the caller should immediately return the
/// token.
bool PasteTokens(Token &Tok);
-
+
/// Expand the arguments of a function-like macro so that we can quickly
/// return preexpanded tokens from Tokens.
void ExpandFunctionArguments();
-
+
/// HandleMicrosoftCommentPaste - In microsoft compatibility mode, /##/ pastes
/// together to form a comment that comments out everything in the current
/// macro, other active macros, and anything left on the current physical
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index feecfdfbc7..27f690b6b3 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -50,7 +50,7 @@ namespace clang {
template<> struct IsResultPtrLowBitFree<3> { static const bool value = true;};
template<> struct IsResultPtrLowBitFree<4> { static const bool value = true;};
template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;};
-
+
/// Action - As the parser reads the input file and recognizes the productions
/// of the grammar, it invokes methods on this class to turn the parsed input
/// into something useful: e.g. a parse tree.
@@ -103,22 +103,22 @@ public:
typedef ASTMultiPtr<&ActionBase::DeleteStmt> MultiStmtArg;
typedef ASTMultiPtr<&ActionBase::DeleteTemplateParams> MultiTemplateParamsArg;
- class FullExprArg {
+ class FullExprArg {
public:
// FIXME: The const_cast here is ugly. RValue references would make this
- // much nicer (or we could duplicate a bunch of the move semantics
+ // much nicer (or we could duplicate a bunch of the move semantics
// emulation code from Ownership.h).
FullExprArg(const FullExprArg& Other)
: Expr(move(const_cast<FullExprArg&>(Other).Expr)) {}
-
+
OwningExprResult release() {
return move(Expr);
}
-
+
ExprArg* operator->() {
return &Expr;
}
-
+
private:
// FIXME: No need to make the entire Action class a friend when it's just
// Action::FullExpr that needs access to the constructor below.
@@ -129,7 +129,7 @@ public:
ExprArg Expr;
};
-
+
template<typename T>
FullExprArg FullExpr(T &Arg) {
return FullExprArg(ActOnFinishFullExpr(move(Arg)));
@@ -150,24 +150,24 @@ public:
virtual void PrintStats() const {}
/// getDeclName - Return a pretty name for the specified decl if possible, or
- /// an empty string if not. This is used for pretty crash reporting.
+ /// an empty string if not. This is used for pretty crash reporting.
virtual std::string getDeclName(DeclPtrTy D) { return ""; }
-
+
/// \brief Invoked for each comment in the source code, providing the source
/// range that contains the comment.
virtual void ActOnComment(SourceRange Comment) { }
-
+
//===--------------------------------------------------------------------===//
// Declaration Tracking Callbacks.
//===--------------------------------------------------------------------===//
-
+
/// ConvertDeclToDeclGroup - If the parser has one decl in a context where it
/// needs a decl group, it calls this to convert between the two
/// representations.
virtual DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr) {
return DeclGroupPtrTy();
}
-
+
/// getTypeName - Return non-null if the specified identifier is a type name
/// in the current scope.
///
@@ -177,13 +177,13 @@ public:
///
/// \param S the scope in which this name lookup occurs
///
- /// \param SS if non-NULL, the C++ scope specifier that precedes the
+ /// \param SS if non-NULL, the C++ scope specifier that precedes the
/// identifier
///
- /// \param isClassName whether this is a C++ class-name production, in
- /// which we can end up referring to a member of an unknown specialization
+ /// \param isClassName whether this is a C++ class-name production, in
+ /// which we can end up referring to a member of an unknown specialization
/// that we know (from the grammar) is supposed to be a type. For example,
- /// this occurs when deriving from "std::vector<T>::allocator_type", where T
+ /// this occurs when deriving from "std::vector<T>::allocator_type", where T
/// is a template parameter.
///
/// \returns the type referred to by this identifier, or NULL if the type
@@ -200,7 +200,7 @@ public:
virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S) {
return DeclSpec::TST_unspecified;
}
-
+
/// isCurrentClassName - Return true if the specified name is the
/// name of the innermost C++ class type currently being defined.
virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
@@ -227,7 +227,7 @@ public:
///
/// \returns the kind of template that this name refers to.
virtual TemplateNameKind isTemplateName(Scope *S,
- const IdentifierInfo &II,
+ const IdentifierInfo &II,
SourceLocation IdLoc,
const CXXScopeSpec *SS,
TypeTy *ObjectType,
@@ -253,18 +253,18 @@ public:
/// \param IdLoc the location of the identifier we have just parsed (e.g.,
/// the "bar" in "foo::bar::".
///
- /// \param CCLoc the location of the '::' at the end of the
+ /// \param CCLoc the location of the '::' at the end of the
/// nested-name-specifier.
///
- /// \param II the identifier that represents the scope that this
+ /// \param II the identifier that represents the scope that this
/// nested-name-specifier refers to, e.g., the "bar" in "foo::bar::".
///
- /// \param ObjectType if this nested-name-specifier occurs as part of a
+ /// \param ObjectType if this nested-name-specifier occurs as part of a
/// C++ member access expression such as "x->Base::f", the type of the base
/// object (e.g., *x in the example, if "x" were a pointer).
- ///
+ ///
/// \param EnteringContext if true, then we intend to immediately enter the
- /// context of this nested-name-specifier, e.g., for an out-of-line
+ /// context of this nested-name-specifier, e.g., for an out-of-line
/// definition of a class member.
///
/// \returns a CXXScopeTy* object representing the C++ scope.
@@ -291,7 +291,7 @@ public:
TypeTy *Type,
SourceRange TypeRange,
SourceLocation CCLoc) {
- return 0;
+ return 0;
}
/// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
@@ -340,12 +340,12 @@ public:
return DeclPtrTy();
}
- /// AddInitializerToDecl - This action is called immediately after
- /// ActOnDeclarator (when an initializer is present). The code is factored
+ /// AddInitializerToDecl - This action is called immediately after
+ /// ActOnDeclarator (when an initializer is present). The code is factored
/// this way to make sure we are able to handle the following:
/// void func() { int xx = xx; }
/// This allows ActOnDeclarator to register "xx" prior to parsing the
- /// initializer. The declaration above should still result in a warning,
+ /// initializer. The declaration above should still result in a warning,
/// since the reference to "xx" is uninitialized.
virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) {
return;
@@ -363,7 +363,7 @@ public:
/// ActOnDeclarator (when an initializer is *not* present).
/// If TypeContainsUndeducedAuto is true, then the type of the declarator
/// has an undeduced 'auto' type somewhere.
- virtual void ActOnUninitializedDecl(DeclPtrTy Dcl,
+ virtual void ActOnUninitializedDecl(DeclPtrTy Dcl,
bool TypeContainsUndeducedAuto) {
return;
}
@@ -376,7 +376,7 @@ public:
return DeclGroupPtrTy();
}
-
+
/// @brief Indicates that all K&R-style parameter declarations have
/// been parsed prior to a function definition.
/// @param S The function prototype scope.
@@ -414,7 +414,7 @@ public:
ExprArg AsmString) {
return DeclPtrTy();
}
-
+
/// ActOnPopScope - This callback is called immediately before the specified
/// scope is popped and deleted.
virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
@@ -422,7 +422,7 @@ public:
/// ActOnTranslationUnitScope - This callback is called once, immediately
/// after creating the translation unit scope (in Parser::Initialize).
virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {}
-
+
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
@@ -459,7 +459,7 @@ public:
/// translation unit when EOF is reached and all but the top-level scope is
/// popped.
virtual void ActOnEndOfTranslationUnit() {}
-
+
//===--------------------------------------------------------------------===//
// Type Parsing Callbacks.
//===--------------------------------------------------------------------===//
@@ -468,7 +468,7 @@ public:
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
return TypeResult();
}
-
+
enum TagUseKind {
TUK_Reference, // Reference to a tag: 'struct foo *X;'
TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
@@ -481,7 +481,7 @@ public:
///
/// \param S the scope in which this tag occurs.
///
- /// \param TagSpec an instance of DeclSpec::TST, indicating what kind of tag
+ /// \param TagSpec an instance of DeclSpec::TST, indicating what kind of tag
/// this is (struct/union/enum/class).
///
/// \param TUK how the tag we have encountered is being used, which
@@ -489,7 +489,7 @@ public:
/// declaration of that tag, or the beginning of a definition of
/// that tag.
///
- /// \param KWLoc the location of the "struct", "class", "union", or "enum"
+ /// \param KWLoc the location of the "struct", "class", "union", or "enum"
/// keyword.
///
/// \param SS C++ scope specifier that precedes the name of the tag, e.g.,
@@ -502,12 +502,12 @@ public:
///
/// \param Attr the set of attributes that appertain to the tag.
///
- /// \param AS when this tag occurs within a C++ class, provides the
- /// current access specifier (AS_public, AS_private, AS_protected).
+ /// \param AS when this tag occurs within a C++ class, provides the
+ /// current access specifier (AS_public, AS_private, AS_protected).
/// Otherwise, it will be AS_none.
///
- /// \param TemplateParameterLists the set of C++ template parameter lists
- /// that apply to this tag, if the tag is a declaration or definition (see
+ /// \param TemplateParameterLists the set of C++ template parameter lists
+ /// that apply to this tag, if the tag is a declaration or definition (see
/// the \p TK parameter). The action module is responsible for determining,
/// based on the template parameter lists and the scope specifier, whether
/// the declared tag is a class template or not.
@@ -525,9 +525,9 @@ public:
bool &OwnedDecl) {
return DeclPtrTy();
}
-
+
/// Act on @defs() element found when parsing a structure. ClassName is the
- /// name of the referenced class.
+ /// name of the referenced class.
virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
IdentifierInfo *ClassName,
llvm::SmallVectorImpl<DeclPtrTy> &Decls) {}
@@ -536,19 +536,19 @@ public:
Declarator &D, ExprTy *BitfieldWidth) {
return DeclPtrTy();
}
-
+
virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
DeclPtrTy IntfDecl,
Declarator &D, ExprTy *BitfieldWidth,
tok::ObjCKeywordKind visibility) {
return DeclPtrTy();
}
-
+
virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl,
- DeclPtrTy *Fields, unsigned NumFields,
+ DeclPtrTy *Fields, unsigned NumFields,
SourceLocation LBrac, SourceLocation RBrac,
AttributeList *AttrList) {}
-
+
/// ActOnTagStartDefinition - Invoked when we have entered the
/// scope of a tag's definition (e.g., for an enumeration, class,
/// struct, or union).
@@ -602,10 +602,10 @@ public:
SourceLocation ColonLoc) {
return StmtEmpty();
}
-
+
/// ActOnCaseStmtBody - This installs a statement as the body of a case.
virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt) {}
-
+
virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
SourceLocation ColonLoc,
StmtArg SubStmt, Scope *CurScope){
@@ -619,8 +619,8 @@ public:
return StmtEmpty();
}
- virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
- FullExprArg CondVal, StmtArg ThenVal,
+ virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
+ FullExprArg CondVal, StmtArg ThenVal,
SourceLocation ElseLoc,
StmtArg ElseVal) {
return StmtEmpty();
@@ -635,12 +635,12 @@ public:
return StmtEmpty();
}
- virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
+ virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
FullExprArg Cond, StmtArg Body) {
return StmtEmpty();
}
virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
- SourceLocation WhileLoc,
+ SourceLocation WhileLoc,
SourceLocation CondLParen,
ExprArg Cond,
SourceLocation CondRParen) {
@@ -682,7 +682,7 @@ public:
return StmtEmpty();
}
virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
+ bool IsSimple,
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
@@ -753,15 +753,15 @@ public:
/// \brief The current expression and its subexpressions occur within an
/// unevaluated operand (C++0x [expr]p8), such as a constant expression
/// or the subexpression of \c sizeof, where the type or the value of the
- /// expression may be significant but no code will be generated to evaluate
+ /// expression may be significant but no code will be generated to evaluate
/// the value of the expression at run time.
Unevaluated,
-
- /// \brief The current expression is potentially evaluated at run time,
- /// which means that code may be generated to evaluate the value of the
+
+ /// \brief The current expression is potentially evaluated at run time,
+ /// which means that code may be generated to evaluate the value of the
/// expression at run time.
PotentiallyEvaluated,
-
+
/// \brief The current expression may be potentially evaluated or it may
/// be unevaluated, but it is impossible to tell from the lexical context.
/// This evaluation context is used primary for the operand of the C++
@@ -769,17 +769,17 @@ public:
/// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2).
PotentiallyPotentiallyEvaluated
};
-
+
/// \brief The parser is entering a new expression evaluation context.
///
/// \param NewContext is the new expression evaluation context.
///
/// \returns the previous expression evaluation context.
- virtual ExpressionEvaluationContext
+ virtual ExpressionEvaluationContext
PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext) {
return PotentiallyEvaluated;
}
-
+
/// \brief The parser is existing an expression evaluation context.
///
/// \param OldContext the expression evaluation context that the parser is
@@ -787,10 +787,10 @@ public:
///
/// \param NewContext the expression evaluation context that the parser is
/// returning to.
- virtual void
+ virtual void
PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
ExpressionEvaluationContext NewContext) { }
-
+
// Primary Expressions.
/// \brief Retrieve the source range that corresponds to the given
@@ -862,12 +862,12 @@ public:
return move(Val); // Default impl returns operand.
}
- virtual OwningExprResult ActOnParenListExpr(SourceLocation L,
- SourceLocation R,
+ virtual OwningExprResult ActOnParenListExpr(SourceLocation L,
+ SourceLocation R,
MultiExprArg Val) {
return ExprEmpty();
}
-
+
// Postfix Expressions.
virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
tok::TokenKind Kind,
@@ -924,8 +924,8 @@ public:
SourceLocation RParenLoc) {
return ExprEmpty();
}
- /// @brief Parsed a C99 designated initializer.
- ///
+ /// @brief Parsed a C99 designated initializer.
+ ///
/// @param Desig Contains the designation with one or more designators.
///
/// @param Loc The location of the '=' or ':' prior to the
@@ -945,11 +945,11 @@ public:
}
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
- TypeTy *Ty, SourceLocation RParenLoc,
+ TypeTy *Ty, SourceLocation RParenLoc,
ExprArg Op) {
return ExprEmpty();
}
-
+
virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
tok::TokenKind Kind,
ExprArg LHS, ExprArg RHS) {
@@ -999,13 +999,13 @@ public:
}
// __builtin_types_compatible_p(type1, type2)
- virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
+ virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
TypeTy *arg1, TypeTy *arg2,
SourceLocation RPLoc) {
return ExprEmpty();
}
// __builtin_choose_expr(constExpr, expr1, expr2)
- virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
+ virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
ExprArg cond, ExprArg expr1,
ExprArg expr2, SourceLocation RPLoc){
return ExprEmpty();
@@ -1093,7 +1093,7 @@ public:
OverloadedOperatorKind Op,
AttributeList *AttrList,
bool IsTypeName);
-
+
/// ActOnParamDefaultArgument - Parse default argument for function parameter
virtual void ActOnParamDefaultArgument(DeclPtrTy param,
SourceLocation EqualLoc,
@@ -1104,7 +1104,7 @@ public:
/// argument for a function parameter, but we can't parse it yet
/// because we're inside a class definition. Note that this default
/// argument will be parsed later.
- virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
+ virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
SourceLocation EqualLoc,
SourceLocation ArgLoc) { }
@@ -1112,7 +1112,7 @@ public:
/// the default argument for the parameter param failed.
virtual void ActOnParamDefaultArgumentError(DeclPtrTy param) { }
- /// AddCXXDirectInitializerToDecl - This action is called immediately after
+ /// AddCXXDirectInitializerToDecl - This action is called immediately after
/// ActOnDeclarator, when a C++ direct initializer is present.
/// e.g: "int x(1);"
virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
@@ -1286,7 +1286,7 @@ public:
return ExprEmpty();
}
- /// \brief Invoked when the parser is starting to parse a C++ member access
+ /// \brief Invoked when the parser is starting to parse a C++ member access
/// expression such as x.f or x->f.
///
/// \param S the scope in which the member access expression occurs.
@@ -1299,7 +1299,7 @@ public:
/// \param OpKind the kind of member access operator ("." or "->")
///
/// \param ObjectType originally NULL. The action should fill in this type
- /// with the type into which name lookup should look to find the member in
+ /// with the type into which name lookup should look to find the member in
/// the member access expression.
///
/// \returns the (possibly modified) \p Base expression
@@ -1310,7 +1310,7 @@ public:
TypeTy *&ObjectType) {
return ExprEmpty();
}
-
+
/// ActOnDestructorReferenceExpr - Parsed a destructor reference, for example:
///
/// t->~T();
@@ -1352,10 +1352,10 @@ public:
const CXXScopeSpec *SS = 0) {
return ExprEmpty();
}
-
+
/// \brief Parsed a reference to a member template-id.
///
- /// This callback will occur instead of ActOnMemberReferenceExpr() when the
+ /// This callback will occur instead of ActOnMemberReferenceExpr() when the
/// member in question is a template for which the code provides an
/// explicitly-specified template argument list, e.g.,
///
@@ -1371,7 +1371,7 @@ public:
///
/// \param OpKind the kind of operator, which will be "." or "->".
///
- /// \param SS the scope specifier that precedes the template-id in, e.g.,
+ /// \param SS the scope specifier that precedes the template-id in, e.g.,
/// \c x.Base::f<int>().
///
/// \param Template the declaration of the template that is being referenced.
@@ -1399,7 +1399,7 @@ public:
SourceLocation RAngleLoc) {
return ExprEmpty();
}
-
+
/// ActOnFinishFullExpr - Called whenever a full expression has been parsed.
/// (C++ [intro.execution]p12).
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr) {
@@ -1408,18 +1408,18 @@ public:
//===---------------------------- C++ Classes ---------------------------===//
/// ActOnBaseSpecifier - Parsed a base specifier
- virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
+ virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
SourceRange SpecifierRange,
bool Virtual, AccessSpecifier Access,
- TypeTy *basetype,
+ TypeTy *basetype,
SourceLocation BaseLoc) {
return BaseResult();
}
- virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
+ virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
unsigned NumBases) {
}
-
+
/// ActOnCXXMemberDeclarator - This is invoked when a C++ class member
/// declarator is parsed. 'AS' is the access specifier, 'BitfieldWidth'
/// specifies the bitfield width if there is one and 'Init' specifies the
@@ -1452,12 +1452,12 @@ public:
/// is the function declaration (which will be a C++ constructor in
/// a well-formed program), ColonLoc is the location of the ':' that
/// starts the constructor initializer, and MemInit/NumMemInits
- /// contains the individual member (and base) initializers.
- virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
+ /// contains the individual member (and base) initializers.
+ virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
SourceLocation ColonLoc,
MemInitTy **MemInits, unsigned NumMemInits){
}
-
+
virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl) {}
/// ActOnFinishCXXMemberSpecification - Invoked after all member declarators
@@ -1473,17 +1473,17 @@ public:
/// ActOnTypeParameter - Called when a C++ template type parameter
/// (e.g., "typename T") has been parsed. Typename specifies whether
/// the keyword "typename" was used to declare the type parameter
- /// (otherwise, "class" was used), ellipsis specifies whether this is a
+ /// (otherwise, "class" was used), ellipsis specifies whether this is a
/// C++0x parameter pack, EllipsisLoc specifies the start of the ellipsis,
- /// and KeyLoc is the location of the "class" or "typename" keyword.
- // ParamName is the name of the parameter (NULL indicates an unnamed template
+ /// and KeyLoc is the location of the "class" or "typename" keyword.
+ // ParamName is the name of the parameter (NULL indicates an unnamed template
// parameter) and ParamNameLoc is the location of the parameter name (if any)
/// If the type parameter has a default argument, it will be added
/// later via ActOnTypeParameterDefault. Depth and Position provide
/// the number of enclosing templates (see
/// ActOnTemplateParameterList) and the number of previous
/// parameters within this template parameter list.
- virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
+ virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
SourceLocation EllipsisLoc,
SourceLocation KeyLoc,
IdentifierInfo *ParamName,
@@ -1493,8 +1493,8 @@ public:
}
/// ActOnTypeParameterDefault - Adds a default argument (the type
- /// Default) to the given template type parameter (TypeParam).
- virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam,
+ /// Default) to the given template type parameter (TypeParam).
+ virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam,
SourceLocation EqualLoc,
SourceLocation DefaultLoc,
TypeTy *Default) {
@@ -1508,7 +1508,7 @@ public:
/// ActOnTemplateParameterList) and the number of previous
/// parameters within this template parameter list.
virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
- unsigned Depth,
+ unsigned Depth,
unsigned Position) {
return DeclPtrTy();
}
@@ -1566,7 +1566,7 @@ public:
/// @endcode
///
/// ExportLoc, if valid, is the position of the "export"
- /// keyword. Otherwise, "export" was not specified.
+ /// keyword. Otherwise, "export" was not specified.
/// TemplateLoc is the position of the template keyword, LAngleLoc
/// is the position of the left angle bracket, and RAngleLoc is the
/// position of the corresponding right angle bracket.
@@ -1575,7 +1575,7 @@ public:
virtual TemplateParamsTy *
ActOnTemplateParameterList(unsigned Depth,
SourceLocation ExportLoc,
- SourceLocation TemplateLoc,
+ SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
DeclPtrTy *Params, unsigned NumParams,
SourceLocation RAngleLoc) {
@@ -1607,7 +1607,7 @@ public:
/// \param TUK Either TUK_Reference or TUK_Friend. Declarations and
/// definitions are interpreted as explicit instantiations or
/// specializations.
- ///
+ ///
/// \param TagSpec The tag keyword that was provided as part of the
/// elaborated-type-specifier; either class, struct, union, or enum.
///
@@ -1636,7 +1636,7 @@ public:
SourceLocation RAngleLoc) {
return ExprError();
}
-
+
/// \brief Form a dependent template name.
///
/// This action forms a dependent template name given the template
@@ -1653,10 +1653,10 @@ public:
///
/// \param SS the nested-name-specifier that precedes the "template" keyword
/// or the template name. FIXME: If the dependent template name occurs in
- /// a member access expression, e.g., "x.template f<T>", this
+ /// a member access expression, e.g., "x.template f<T>", this
/// nested-name-specifier will be empty.
///
- /// \param ObjectType if this dependent template name occurs in the
+ /// \param ObjectType if this dependent template name occurs in the
/// context of a member access expression, the type of the object being
/// accessed.
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
@@ -1695,7 +1695,7 @@ public:
/// (template)
///
/// \param TUK whether this is a declaration or a definition
- ///
+ ///
/// \param KWLoc the location of the 'class', 'struct', or 'union'
/// keyword.
///
@@ -1715,7 +1715,7 @@ public:
/// specialization); the parser does not check this condition.
virtual DeclResult
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
- SourceLocation KWLoc,
+ SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
SourceLocation TemplateNameLoc,
@@ -1732,22 +1732,22 @@ public:
/// lists has been parsed.
///
/// This action is similar to ActOnDeclarator(), except that the declaration
- /// being created somehow involves a template, e.g., it is a template
+ /// being created somehow involves a template, e.g., it is a template
/// declaration or specialization.
- virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
+ virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D) {
return DeclPtrTy();
}
-
+
/// \brief Invoked when the parser is beginning to parse a function template
/// or function template specialization definition.
- virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
+ virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D) {
return DeclPtrTy();
}
-
+
/// \brief Process the explicit instantiation of a class template
/// specialization.
///
@@ -1791,10 +1791,10 @@ public:
///
/// \param Attr attributes that apply to this instantiation.
virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
+ ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
@@ -1806,7 +1806,7 @@ public:
AttributeList *Attr) {
return DeclResult();
}
-
+
/// \brief Process the explicit instantiation of a member class of a
/// class template specialization.
///
@@ -1851,10 +1851,10 @@ public:
///
/// \param Attr attributes that apply to this instantiation.
virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
+ ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
IdentifierInfo *Name,
@@ -1877,7 +1877,7 @@ public:
}
/// \brief Called when the parser has parsed a C++ typename
- /// specifier that ends in a template-id, e.g.,
+ /// specifier that ends in a template-id, e.g.,
/// "typename MetaFun::template apply<T1, T2>".
///
/// \param TypenameLoc the location of the 'typename' keyword
@@ -1891,22 +1891,22 @@ public:
}
//===----------------------- Obj-C Declarations -------------------------===//
-
+
// ActOnStartClassInterface - this action is called immediately after parsing
- // the prologue for a class interface (before parsing the instance
+ // the prologue for a class interface (before parsing the instance
// variables). Instance variables are processed by ActOnFields().
virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
- IdentifierInfo *ClassName,
+ IdentifierInfo *ClassName,
SourceLocation ClassLoc,
- IdentifierInfo *SuperName,
+ IdentifierInfo *SuperName,
SourceLocation SuperLoc,
- const DeclPtrTy *ProtoRefs,
+ const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
SourceLocation EndProtoLoc,
AttributeList *AttrList) {
return DeclPtrTy();
}
-
+
/// ActOnCompatiblityAlias - this action is called after complete parsing of
/// @compaatibility_alias declaration. It sets up the alias relationships.
virtual DeclPtrTy ActOnCompatiblityAlias(
@@ -1915,11 +1915,11 @@ public:
IdentifierInfo *ClassName, SourceLocation ClassLocation) {
return DeclPtrTy();
}
-
+
// ActOnStartProtocolInterface - this action is called immdiately after
// parsing the prologue for a protocol interface.
virtual DeclPtrTy ActOnStartProtocolInterface(SourceLocation AtProtoLoc,
- IdentifierInfo *ProtocolName,
+ IdentifierInfo *ProtocolName,
SourceLocation ProtocolLoc,
const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
@@ -1930,9 +1930,9 @@ public:
// ActOnStartCategoryInterface - this action is called immdiately after
// parsing the prologue for a category interface.
virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
- IdentifierInfo *ClassName,
+ IdentifierInfo *ClassName,
SourceLocation ClassLoc,
- IdentifierInfo *CategoryName,
+ IdentifierInfo *CategoryName,
SourceLocation CategoryLoc,
const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
@@ -1940,13 +1940,13 @@ public:
return DeclPtrTy();
}
// ActOnStartClassImplementation - this action is called immdiately after
- // parsing the prologue for a class implementation. Instance variables are
+ // parsing the prologue for a class implementation. Instance variables are
// processed by ActOnFields().
virtual DeclPtrTy ActOnStartClassImplementation(
SourceLocation AtClassImplLoc,
- IdentifierInfo *ClassName,
+ IdentifierInfo *ClassName,
SourceLocation ClassLoc,
- IdentifierInfo *SuperClassname,
+ IdentifierInfo *SuperClassname,
SourceLocation SuperClassLoc) {
return DeclPtrTy();
}
@@ -1954,12 +1954,12 @@ public:
// parsing the prologue for a category implementation.
virtual DeclPtrTy ActOnStartCategoryImplementation(
SourceLocation AtCatImplLoc,
- IdentifierInfo *ClassName,
+ IdentifierInfo *ClassName,
SourceLocation ClassLoc,
IdentifierInfo *CatName,
SourceLocation CatLoc) {
return DeclPtrTy();
- }
+ }
// ActOnPropertyImplDecl - called for every property implementation
virtual DeclPtrTy ActOnPropertyImplDecl(
SourceLocation AtLoc, // location of the @synthesize/@dynamic
@@ -1971,7 +1971,7 @@ public:
IdentifierInfo *propertyIvar) { // name of the ivar
return DeclPtrTy();
}
-
+
struct ObjCArgInfo {
IdentifierInfo *Name;
SourceLocation NameLoc;
@@ -1979,12 +1979,12 @@ public:
// in this case.
TypeTy *Type;
ObjCDeclSpec DeclSpec;
-
+
/// ArgAttrs - Attribute list for this argument.
AttributeList *ArgAttrs;
};
- // ActOnMethodDeclaration - called for all method declarations.
+ // ActOnMethodDeclaration - called for all method declarations.
virtual DeclPtrTy ActOnMethodDeclaration(
SourceLocation BeginLoc, // location of the + or -.
SourceLocation EndLoc, // location of the ; or {.
@@ -1996,20 +1996,20 @@ public:
ObjCArgInfo *ArgInfo, // ArgInfo: Has 'Sel.getNumArgs()' entries.
llvm::SmallVectorImpl<Declarator> &Cdecls, // c-style args
AttributeList *MethodAttrList, // optional
- // tok::objc_not_keyword, tok::objc_optional, tok::objc_required
+ // tok::objc_not_keyword, tok::objc_optional, tok::objc_required
tok::ObjCKeywordKind impKind,
bool isVariadic = false) {
return DeclPtrTy();
}
// ActOnAtEnd - called to mark the @end. For declarations (interfaces,
- // protocols, categories), the parser passes all methods/properties.
+ // protocols, categories), the parser passes all methods/properties.
// For class implementations, these values default to 0. For implementations,
// methods are processed incrementally (by ActOnMethodDeclaration above).
- virtual void ActOnAtEnd(SourceLocation AtEndLoc,
+ virtual void ActOnAtEnd(SourceLocation AtEndLoc,
DeclPtrTy classDecl,
- DeclPtrTy *allMethods = 0,
+ DeclPtrTy *allMethods = 0,
unsigned allNum = 0,
- DeclPtrTy *allProperties = 0,
+ DeclPtrTy *allProperties = 0,
unsigned pNum = 0,
DeclGroupPtrTy *allTUVars = 0,
unsigned tuvNum = 0) {
@@ -2023,7 +2023,7 @@ public:
tok::ObjCKeywordKind MethodImplKind) {
return DeclPtrTy();
}
-
+
virtual OwningExprResult ActOnClassPropertyRefExpr(
IdentifierInfo &receiverName,
IdentifierInfo &propertyName,
@@ -2031,17 +2031,17 @@ public:
SourceLocation &propertyNameLoc) {
return ExprEmpty();
}
-
+
// ActOnClassMessage - used for both unary and keyword messages.
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from NumArgs.
virtual ExprResult ActOnClassMessage(
Scope *S,
- IdentifierInfo *receivingClassName,
+ IdentifierInfo *receivingClassName,
Selector Sel,
SourceLocation lbrac, SourceLocation receiverLoc,
SourceLocation selectorLoc,
- SourceLocation rbrac,
+ SourceLocation rbrac,
ExprTy **ArgExprs, unsigned NumArgs) {
return ExprResult();
}
@@ -2050,7 +2050,7 @@ public:
// is obtained from NumArgs.
virtual ExprResult ActOnInstanceMessage(
ExprTy *receiver, Selector Sel,
- SourceLocation lbrac, SourceLocation selectorLoc, SourceLocation rbrac,
+ SourceLocation lbrac, SourceLocation selectorLoc, SourceLocation rbrac,
ExprTy **ArgExprs, unsigned NumArgs) {
return ExprResult();
}
@@ -2067,7 +2067,7 @@ public:
AttributeList *AttrList) {
return DeclPtrTy();
}
-
+
/// FindProtocolDeclaration - This routine looks up protocols and
/// issues error if they are not declared. It returns list of valid
/// protocols found.
@@ -2079,7 +2079,7 @@ public:
//===----------------------- Obj-C Expressions --------------------------===//
- virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
+ virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
ExprTy **Strings,
unsigned NumStrings) {
return ExprResult();
@@ -2092,7 +2092,7 @@ public:
SourceLocation RParenLoc) {
return ExprResult();
}
-
+
virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
SourceLocation AtLoc,
SourceLocation SelLoc,
@@ -2100,38 +2100,38 @@ public:
SourceLocation RParenLoc) {
return ExprResult();
}
-
+
virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
SourceLocation AtLoc,
SourceLocation ProtoLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
return ExprResult();
- }
+ }
//===---------------------------- Pragmas -------------------------------===//
enum PragmaPackKind {
- PPK_Default, // #pragma pack([n])
+ PPK_Default, // #pragma pack([n])
PPK_Show, // #pragma pack(show), only supported by MSVC.
PPK_Push, // #pragma pack(push, [identifier], [n])
PPK_Pop // #pragma pack(pop, [identifier], [n])
};
-
+
/// ActOnPragmaPack - Called on well formed #pragma pack(...).
virtual void ActOnPragmaPack(PragmaPackKind Kind,
IdentifierInfo *Name,
ExprTy *Alignment,
- SourceLocation PragmaLoc,
+ SourceLocation PragmaLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
return;
}
-
+
/// ActOnPragmaUnused - Called on well formed #pragma unused(...).
virtual void ActOnPragmaUnused(const Token *Identifiers,
unsigned NumIdentifiers, Scope *CurScope,
- SourceLocation PragmaLoc,
+ SourceLocation PragmaLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
return;
@@ -2181,13 +2181,13 @@ public:
///
/// \param S the scope in which this name lookup occurs
///
- /// \param SS if non-NULL, the C++ scope specifier that precedes the
+ /// \param SS if non-NULL, the C++ scope specifier that precedes the
/// identifier
///
- /// \param isClassName whether this is a C++ class-name production, in
- /// which we can end up referring to a member of an unknown specialization
+ /// \param isClassName whether this is a C++ class-name production, in
+ /// which we can end up referring to a member of an unknown specialization
/// that we know (from the grammar) is supposed to be a type. For example,
- /// this occurs when deriving from "std::vector<T>::allocator_type", where T
+ /// this occurs when deriving from "std::vector<T>::allocator_type", where T
/// is a template parameter.
///
/// \returns the type referred to by this identifier, or NULL if the type
@@ -2202,10 +2202,10 @@ public:
const CXXScopeSpec *SS);
virtual TemplateNameKind isTemplateName(Scope *S,
- const IdentifierInfo &II,
+ const IdentifierInfo &II,
SourceLocation IdLoc,
const CXXScopeSpec *SS,
- TypeTy *ObjectType,
+ TypeTy *ObjectType,
bool EnteringContext,
TemplateTy &Template);
@@ -2213,22 +2213,22 @@ public:
/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
/// popped.
virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D);
-
- /// ActOnPopScope - When a scope is popped, if any typedefs are now
+
+ /// ActOnPopScope - When a scope is popped, if any typedefs are now
/// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.
virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
-
+
virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentifierInfo **IdentList,
unsigned NumElts);
-
+
virtual DeclPtrTy ActOnStartClassInterface(SourceLocation interLoc,
IdentifierInfo *ClassName,
SourceLocation ClassLoc,
IdentifierInfo *SuperName,
SourceLocation SuperLoc,
- const DeclPtrTy *ProtoRefs,
+ const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
SourceLocation EndProtoLoc,
AttributeList *AttrList);
@@ -2248,15 +2248,15 @@ public:
Action &actions, SourceManager &sm,
const char *Msg)
: TheDecl(Decl), Loc(L), Actions(actions), SM(sm), Message(Msg) {}
-
+
virtual void print(llvm::raw_ostream &OS) const;
-};
-
+};
+
/// \brief RAII object that enters a new expression evaluation context.
-class EnterExpressionEvaluationContext {
+class EnterExpressionEvaluationContext {
/// \brief The action object.
Action &Actions;
-
+
/// \brief The previous expression evaluation context.
Action::ExpressionEvaluationContext PrevContext;
@@ -2265,16 +2265,16 @@ class EnterExpressionEvaluationContext {
public:
EnterExpressionEvaluationContext(Action &Actions,
- Action::ExpressionEvaluationContext NewContext)
- : Actions(Actions), CurContext(NewContext) {
+ Action::ExpressionEvaluationContext NewContext)
+ : Actions(Actions), CurContext(NewContext) {
PrevContext = Actions.PushExpressionEvaluationContext(NewContext);
}
-
+
~EnterExpressionEvaluationContext() {
Actions.PopExpressionEvaluationContext(CurContext, PrevContext);
}
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h
index 6f987eefd0..9fcc845cb0 100644
--- a/include/clang/Parse/AttributeList.h
+++ b/include/clang/Parse/AttributeList.h
@@ -21,7 +21,7 @@
namespace clang {
class IdentifierInfo;
class Action;
-
+
/// AttributeList - Represents GCC's __attribute__ declaration. There are
/// 4 forms of this construct...they are:
///
@@ -47,7 +47,7 @@ public:
ActionBase::ExprTy **args, unsigned numargs,
AttributeList *Next, bool declspec = false);
~AttributeList();
-
+
enum Kind { // Please keep this list alphabetized.
AT_IBOutlet, // Clang-specific.
AT_address_space,
@@ -102,57 +102,57 @@ public:
IgnoredAttribute,
UnknownAttribute
};
-
+
IdentifierInfo *getName() const { return AttrName; }
SourceLocation getLoc() const { return AttrLoc; }
IdentifierInfo *getParameterName() const { return ParmName; }
bool isDeclspecAttribute() const { return DeclspecAttribute; }
-
+
Kind getKind() const { return getKind(getName()); }
static Kind getKind(const IdentifierInfo *Name);
-
+
AttributeList *getNext() const { return Next; }
void setNext(AttributeList *N) { Next = N; }
/// getNumArgs - Return the number of actual arguments to this attribute.
unsigned getNumArgs() const { return NumArgs; }
-
+
/// getArg - Return the specified argument.
ActionBase::ExprTy *getArg(unsigned Arg) const {
assert(Arg < NumArgs && "Arg access out of range!");
return Args[Arg];
}
-
+
class arg_iterator {
ActionBase::ExprTy** X;
unsigned Idx;
public:
- arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
+ arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
arg_iterator& operator++() {
++Idx;
return *this;
}
-
+
bool operator==(const arg_iterator& I) const {
assert (X == I.X &&
"compared arg_iterators are for different argument lists");
return Idx == I.Idx;
}
-
+
bool operator!=(const arg_iterator& I) const {
return !operator==(I);
}
-
+
ActionBase::ExprTy* operator*() const {
return X[Idx];
}
-
+
unsigned getArgNum() const {
return Idx+1;
}
};
-
+
arg_iterator arg_begin() const {
return arg_iterator(Args, 0);
}
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h
index 3bedec4e4d..8f0441a8fe 100644
--- a/include/clang/Parse/DeclSpec.h
+++ b/include/clang/Parse/DeclSpec.h
@@ -25,7 +25,7 @@ namespace clang {
class IdentifierInfo;
class Preprocessor;
class Declarator;
-
+
/// DeclSpec - This class captures information about "declaration specifiers",
/// which encompasses storage-class-specifiers, type-specifiers,
/// type-qualifiers, and function-specifiers.
@@ -42,7 +42,7 @@ public:
SCS_private_extern,
SCS_mutable
};
-
+
// type-specifier
enum TSW {
TSW_unspecified,
@@ -50,19 +50,19 @@ public:
TSW_long,
TSW_longlong
};
-
+
enum TSC {
TSC_unspecified,
TSC_imaginary,
TSC_complex
};
-
+
enum TSS {
TSS_unspecified,
TSS_signed,
TSS_unsigned
};
-
+
enum TST {
TST_unspecified,
TST_void,
@@ -88,7 +88,7 @@ public:
TST_auto, // C++0x auto
TST_error // erroneous type
};
-
+
// type-qualifiers
enum TQ { // NOTE: These flags must be kept in sync with QualType::TQ.
TQ_unspecified = 0,
@@ -106,9 +106,9 @@ public:
PQ_TypeQualifier = 4,
PQ_FunctionSpecifier = 8
};
-
+
private:
-
+
// storage-class-specifier
/*SCS*/unsigned StorageClassSpec : 3;
bool SCS_thread_specified : 1;
@@ -122,43 +122,43 @@ private:
// type-qualifiers
unsigned TypeQualifiers : 3; // Bitwise OR of TQ.
-
+
// function-specifier
bool FS_inline_specified : 1;
bool FS_virtual_specified : 1;
bool FS_explicit_specified : 1;
-
+
// friend-specifier
bool Friend_specified : 1;
-
+
/// TypeRep - This contains action-specific information about a specific TST.
/// For example, for a typedef or struct, it might contain the declaration for
/// these.
- void *TypeRep;
-
+ void *TypeRep;
+
// attributes.
AttributeList *AttrList;
-
- // List of protocol qualifiers for objective-c classes. Used for
+
+ // List of protocol qualifiers for objective-c classes. Used for
// protocol-qualified interfaces "NString<foo>" and protocol-qualified id
// "id<foo>".
const ActionBase::DeclPtrTy *ProtocolQualifiers;
unsigned NumProtocolQualifiers;
-
+
// SourceLocation info. These are null if the item wasn't specified or if
// the setting was synthesized.
SourceRange Range;
-
+
SourceLocation StorageClassSpecLoc, SCS_threadLoc;
SourceLocation TSWLoc, TSCLoc, TSSLoc, TSTLoc;
SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc;
SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc;
SourceLocation FriendLoc;
-
+
DeclSpec(const DeclSpec&); // DO NOT IMPLEMENT
void operator=(const DeclSpec&); // DO NOT IMPLEMENT
-public:
-
+public:
+
DeclSpec()
: StorageClassSpec(SCS_unspecified),
SCS_thread_specified(false),
@@ -184,17 +184,17 @@ public:
// storage-class-specifier
SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
bool isThreadSpecified() const { return SCS_thread_specified; }
-
+
SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
SourceLocation getThreadSpecLoc() const { return SCS_threadLoc; }
-
+
void ClearStorageClassSpecs() {
StorageClassSpec = DeclSpec::SCS_unspecified;
SCS_thread_specified = false;
StorageClassSpecLoc = SourceLocation();
SCS_threadLoc = SourceLocation();
}
-
+
// type-specifier
TSW getTypeSpecWidth() const { return (TSW)TypeSpecWidth; }
TSC getTypeSpecComplex() const { return (TSC)TypeSpecComplex; }
@@ -202,13 +202,13 @@ public:
TST getTypeSpecType() const { return (TST)TypeSpecType; }
bool isTypeSpecOwned() const { return TypeSpecOwned; }
void *getTypeRep() const { return TypeRep; }
-
+
const SourceRange &getSourceRange() const { return Range; }
SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; }
SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
SourceLocation getTypeSpecSignLoc() const { return TSSLoc; }
SourceLocation getTypeSpecTypeLoc() const { return TSTLoc; }
-
+
/// getSpecifierName - Turn a type-specifier-type into a string like "_Bool"
/// or "union".
static const char *getSpecifierName(DeclSpec::TST T);
@@ -217,7 +217,7 @@ public:
static const char *getSpecifierName(DeclSpec::TSC C);
static const char *getSpecifierName(DeclSpec::TSW W);
static const char *getSpecifierName(DeclSpec::SCS S);
-
+
// type-qualifiers
/// getTypeQualifiers - Return a set of TQs.
@@ -225,7 +225,7 @@ public:
SourceLocation getConstSpecLoc() const { return TQ_constLoc; }
SourceLocation getRestrictSpecLoc() const { return TQ_restrictLoc; }
SourceLocation getVolatileSpecLoc() const { return TQ_volatileLoc; }
-
+
// function-specifier
bool isInlineSpecified() const { return FS_inline_specified; }
SourceLocation getInlineSpecLoc() const { return FS_inlineLoc; }
@@ -244,7 +244,7 @@ public:
FS_explicit_specified = false;
FS_explicitLoc = SourceLocation();
}
-
+
/// hasTypeSpecifier - Return true if any type-specifier has been found.
bool hasTypeSpecifier() const {
return getTypeSpecType() != DeclSpec::TST_unspecified ||
@@ -252,21 +252,21 @@ public:
getTypeSpecComplex() != DeclSpec::TSC_unspecified ||
getTypeSpecSign() != DeclSpec::TSS_unspecified;
}
-
+
/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
/// DeclSpec includes.
///
unsigned getParsedSpecifiers() const;
-
+
/// isEmpty - Return true if this declaration specifier is completely empty:
/// no tokens were parsed in the production of it.
bool isEmpty() const {
return getParsedSpecifiers() == DeclSpec::PQ_None;
}
-
+
void SetRangeStart(SourceLocation Loc) { Range.setBegin(Loc); }
void SetRangeEnd(SourceLocation Loc) { Range.setEnd(Loc); }
-
+
/// These methods set the specified attribute of the DeclSpec and
/// return false if there was no error. If an error occurs (for
/// example, if we tried to set "auto" on a spec with "extern"
@@ -291,42 +291,42 @@ public:
unsigned &DiagID, void *Rep = 0, bool Owned = false);
bool SetTypeSpecError();
void UpdateTypeRep(void *Rep) { TypeRep = Rep; }
-
+
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID, const LangOptions &Lang);
-
+
bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID);
bool SetFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID);
bool SetFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID);
-
+
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
unsigned &DiagID);
bool isFriendSpecified() const { return Friend_specified; }
SourceLocation getFriendSpecLoc() const { return FriendLoc; }
- /// AddAttributes - contatenates two attribute lists.
+ /// AddAttributes - contatenates two attribute lists.
/// The GCC attribute syntax allows for the following:
///
- /// short __attribute__(( unused, deprecated ))
+ /// short __attribute__(( unused, deprecated ))
/// int __attribute__(( may_alias, aligned(16) )) var;
///
/// This declares 4 attributes using 2 lists. The following syntax is
/// also allowed and equivalent to the previous declaration.
///
- /// short __attribute__((unused)) __attribute__((deprecated))
+ /// short __attribute__((unused)) __attribute__((deprecated))
/// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
- ///
+ ///
void AddAttributes(AttributeList *alist) {
AttrList = addAttributeLists(AttrList, alist);
}
void SetAttributes(AttributeList *AL) { AttrList = AL; }
const AttributeList *getAttributes() const { return AttrList; }
AttributeList *getAttributes() { return AttrList; }
-
+
/// TakeAttributes - Return the current attribute list and remove them from
/// the DeclSpec so that it doesn't own them.
AttributeList *TakeAttributes() {
@@ -334,7 +334,7 @@ public:
AttrList = 0;
return AL;
}
-
+
typedef const ActionBase::DeclPtrTy *ProtocolQualifierListTy;
ProtocolQualifierListTy getProtocolQualifiers() const {
return ProtocolQualifiers;
@@ -348,7 +348,7 @@ public:
memcpy((void*)ProtocolQualifiers, Protos, sizeof(ActionBase::DeclPtrTy)*NP);
NumProtocolQualifiers = NP;
}
-
+
/// Finish - This does final analysis of the declspec, issuing diagnostics for
/// things like "_Imaginary" (lacking an FP type). After calling this method,
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
@@ -359,7 +359,7 @@ public:
bool isMissingDeclaratorOk();
};
-/// ObjCDeclSpec - This class captures information about
+/// ObjCDeclSpec - This class captures information about
/// "declaration specifiers" specific to objective-c
class ObjCDeclSpec {
public:
@@ -373,47 +373,46 @@ public:
DQ_Byref = 0x10,
DQ_Oneway = 0x20
};
-
+
/// PropertyAttributeKind - list of property attributes.
- enum ObjCPropertyAttributeKind { DQ_PR_noattr = 0x0,
- DQ_PR_readonly = 0x01,
- DQ_PR_getter = 0x02,
- DQ_PR_assign = 0x04,
- DQ_PR_readwrite = 0x08,
+ enum ObjCPropertyAttributeKind { DQ_PR_noattr = 0x0,
+ DQ_PR_readonly = 0x01,
+ DQ_PR_getter = 0x02,
+ DQ_PR_assign = 0x04,
+ DQ_PR_readwrite = 0x08,
DQ_PR_retain = 0x10,
- DQ_PR_copy = 0x20,
+ DQ_PR_copy = 0x20,
DQ_PR_nonatomic = 0x40,
DQ_PR_setter = 0x80
};
-
-
+
+
ObjCDeclSpec() : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
- GetterName(0), SetterName(0)
- {}
+ GetterName(0), SetterName(0) { }
ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }
- void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
+ void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
{ objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal); }
-
- ObjCPropertyAttributeKind getPropertyAttributes() const
+
+ ObjCPropertyAttributeKind getPropertyAttributes() const
{ return ObjCPropertyAttributeKind(PropertyAttributes); }
- void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
- PropertyAttributes =
+ void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
+ PropertyAttributes =
(ObjCPropertyAttributeKind) (PropertyAttributes | PRVal);
}
-
+
const IdentifierInfo *getGetterName() const { return GetterName; }
IdentifierInfo *getGetterName() { return GetterName; }
void setGetterName(IdentifierInfo *name) { GetterName = name; }
-
+
const IdentifierInfo *getSetterName() const { return SetterName; }
IdentifierInfo *getSetterName() { return SetterName; }
void setSetterName(IdentifierInfo *name) { SetterName = name; }
private:
- // FIXME: These two are unrelated and mutially exclusive. So perhaps
+ // FIXME: These two are unrelated and mutially exclusive. So perhaps
// we can put them in a union to reflect their mutual exclusiveness
// (space saving is negligible).
ObjCDeclQualifier objcDeclQualifier : 6;
-
+
// NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind
unsigned PropertyAttributes : 8;
IdentifierInfo *GetterName; // getter name of NULL if no getter
@@ -453,7 +452,7 @@ public:
ScopeRep = 0;
}
};
-
+
/// CachedTokens - A set of tokens that has been cached for later
/// parsing.
typedef llvm::SmallVector<Token, 4> CachedTokens;
@@ -471,7 +470,7 @@ struct DeclaratorChunk {
SourceLocation Loc;
/// EndLoc - If valid, the place where this chunck ends.
SourceLocation EndLoc;
-
+
struct PointerTypeInfo {
/// The type qualifiers: const/volatile/restrict.
unsigned TypeQuals : 3;
@@ -495,20 +494,20 @@ struct DeclaratorChunk {
struct ArrayTypeInfo {
/// The type qualifiers for the array: const/volatile/restrict.
unsigned TypeQuals : 3;
-
+
/// True if this dimension included the 'static' keyword.
bool hasStatic : 1;
-
+
/// True if this dimension was [*]. In this case, NumElts is null.
bool isStar : 1;
-
+
/// This is the size of the array, or null if [] or [*] was specified.
/// Since the parser is multi-purpose, and we don't want to impose a root
/// expression class on all clients, NumElts is untyped.
ActionBase::ExprTy *NumElts;
void destroy() {}
};
-
+
/// ParamInfo - An array of paraminfo objects is allocated whenever a function
/// declarator is parsed. There are two interesting styles of arguments here:
/// K&R-style identifier lists and parameter type lists. K&R-style identifier
@@ -531,7 +530,7 @@ struct DeclaratorChunk {
ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
ActionBase::DeclPtrTy param,
CachedTokens *DefArgTokens = 0)
- : Ident(ident), IdentLoc(iloc), Param(param),
+ : Ident(ident), IdentLoc(iloc), Param(param),
DefaultArgTokens(DefArgTokens) {}
};
@@ -552,7 +551,7 @@ struct DeclaratorChunk {
bool isVariadic : 1;
/// The type qualifiers: const/volatile/restrict.
- /// The qualifier bitmask values are the same as in QualType.
+ /// The qualifier bitmask values are the same as in QualType.
unsigned TypeQuals : 3;
/// hasExceptionSpec - True if the function has an exception specification.
@@ -692,7 +691,7 @@ struct DeclaratorChunk {
I.Ptr.AttrList = AL;
return I;
}
-
+
/// getReference - Return a DeclaratorChunk for a reference.
///
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc,
@@ -705,7 +704,7 @@ struct DeclaratorChunk {
I.Ref.AttrList = AL;
return I;
}
-
+
/// getArray - Return a DeclaratorChunk for an array.
///
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic,
@@ -721,7 +720,7 @@ struct DeclaratorChunk {
I.Arr.NumElts = NumElts;
return I;
}
-
+
/// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
/// "TheDeclarator" is the declarator that this will be added to.
static DeclaratorChunk getFunction(bool hasProto, bool isVariadic,
@@ -735,7 +734,7 @@ struct DeclaratorChunk {
unsigned NumExceptions,
SourceLocation LPLoc, SourceLocation RPLoc,
Declarator &TheDeclarator);
-
+
/// getBlockPointer - Return a DeclaratorChunk for a block.
///
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc,
@@ -791,11 +790,11 @@ public:
/// DeclaratorKind - The kind of declarator this represents.
enum DeclaratorKind {
DK_Abstract, // An abstract declarator (has no identifier)
- DK_Normal, // A normal declarator (has an identifier).
+ DK_Normal, // A normal declarator (has an identifier).
DK_Constructor, // A C++ constructor (identifier is the class name)
DK_Destructor, // A C++ destructor (identifier is ~class name)
DK_Operator, // A C++ overloaded operator name
- DK_Conversion // A C++ conversion function (identifier is
+ DK_Conversion // A C++ conversion function (identifier is
// "operator " then the type name)
};
@@ -810,7 +809,7 @@ private:
///
TheContext Context;
- /// Kind - What kind of declarator this is.
+ /// Kind - What kind of declarator this is.
DeclaratorKind Kind;
/// DeclTypeInfo - This holds each type that the declarator includes as it is
@@ -827,7 +826,7 @@ private:
/// AttrList - Attributes.
AttributeList *AttrList;
-
+
/// AsmLabel - The asm label, if specified.
ActionBase::ExprTy *AsmLabel;
@@ -861,7 +860,7 @@ public:
GroupingParens(false), AttrList(0), AsmLabel(0), Type(0),
InlineParamsUsed(false), Extension(false) {
}
-
+
~Declarator() {
clear();
}
@@ -869,7 +868,7 @@ public:
/// getDeclSpec - Return the declaration-specifier that this declarator was
/// declared with.
const DeclSpec &getDeclSpec() const { return DS; }
-
+
/// getMutableDeclSpec - Return a non-const version of the DeclSpec. This
/// should be used with extreme care: declspecs can often be shared between
/// multiple declarators, so mutating the DeclSpec affects all of the
@@ -928,9 +927,9 @@ public:
Type = 0;
InlineParamsUsed = false;
}
-
+
/// mayOmitIdentifier - Return true if the identifier is either optional or
- /// not allowed. This is true for typenames, prototypes, and template
+ /// not allowed. This is true for typenames, prototypes, and template
/// parameter lists.
bool mayOmitIdentifier() const {
return Context == TypeNameContext || Context == PrototypeContext ||
@@ -953,7 +952,7 @@ public:
Context == BlockContext ||
Context == ForContext);
}
-
+
/// isPastIdentifier - Return true if we have parsed beyond the point where
/// the
bool isPastIdentifier() const { return IdentifierLoc.isValid(); }
@@ -965,7 +964,7 @@ public:
IdentifierInfo *getIdentifier() const { return Identifier; }
SourceLocation getIdentifierLoc() const { return IdentifierLoc; }
-
+
void SetIdentifier(IdentifierInfo *ID, SourceLocation Loc) {
Identifier = ID;
IdentifierLoc = Loc;
@@ -975,7 +974,7 @@ public:
Kind = DK_Abstract;
SetRangeEnd(Loc);
}
-
+
/// setConstructor - Set this declarator to be a C++ constructor
/// declarator. Also extends the range.
void setConstructor(ActionBase::TypeTy *Ty, SourceLocation Loc) {
@@ -1035,7 +1034,7 @@ public:
/// getNumTypeObjects() - Return the number of types applied to this
/// declarator.
unsigned getNumTypeObjects() const { return DeclTypeInfo.size(); }
-
+
/// Return the specified TypeInfo from this declarator. TypeInfo #0 is
/// closest to the identifier.
const DeclaratorChunk &getTypeObject(unsigned i) const {
@@ -1046,14 +1045,14 @@ public:
assert(i < DeclTypeInfo.size() && "Invalid type chunk");
return DeclTypeInfo[i];
}
-
+
/// isFunctionDeclarator - Once this declarator is fully parsed and formed,
/// this method returns true if the identifier is a function declarator.
bool isFunctionDeclarator() const {
return !DeclTypeInfo.empty() &&
DeclTypeInfo[0].Kind == DeclaratorChunk::Function;
}
-
+
/// AddAttributes - simply adds the attribute list to the Declarator.
/// These examples both add 3 attributes to "var":
/// short int var __attribute__((aligned(16),common,deprecated));
@@ -1061,13 +1060,13 @@ public:
/// __attribute__((common,deprecated));
///
/// Also extends the range of the declarator.
- void AddAttributes(AttributeList *alist, SourceLocation LastLoc) {
+ void AddAttributes(AttributeList *alist, SourceLocation LastLoc) {
AttrList = addAttributeLists(AttrList, alist);
if (!LastLoc.isInvalid())
SetRangeEnd(LastLoc);
}
-
+
const AttributeList *getAttributes() const { return AttrList; }
AttributeList *getAttributes() { return AttrList; }
@@ -1091,8 +1090,8 @@ public:
OverloadedOperatorKind getOverloadedOperator() const { return OperatorKind; }
void setInvalidType(bool Val = true) { InvalidType = Val; }
- bool isInvalidType() const {
- return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
+ bool isInvalidType() const {
+ return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
}
void setGroupingParens(bool flag) { GroupingParens = flag; }
diff --git a/include/clang/Parse/Designator.h b/include/clang/Parse/Designator.h
index 026286d318..255af59018 100644
--- a/include/clang/Parse/Designator.h
+++ b/include/clang/Parse/Designator.h
@@ -18,7 +18,7 @@
#include "clang/Parse/Action.h"
namespace clang {
-
+
/// Designator - This class is a discriminated union which holds the various
/// different sorts of designators possible. A Designation is an array of
/// these. An example of a designator are things like this:
@@ -34,7 +34,7 @@ public:
};
private:
DesignatorKind Kind;
-
+
struct FieldDesignatorInfo {
const IdentifierInfo *II;
unsigned DotLoc;
@@ -50,15 +50,15 @@ private:
unsigned LBracketLoc, EllipsisLoc;
mutable unsigned RBracketLoc;
};
-
+
union {
FieldDesignatorInfo FieldInfo;
ArrayDesignatorInfo ArrayInfo;
ArrayRangeDesignatorInfo ArrayRangeInfo;
};
-
+
public:
-
+
DesignatorKind getKind() const { return Kind; }
bool isFieldDesignator() const { return Kind == FieldDesignator; }
bool isArrayDesignator() const { return Kind == ArrayDesignator; }
@@ -78,7 +78,7 @@ public:
assert(isFieldDesignator() && "Invalid accessor");
return SourceLocation::getFromRawEncoding(FieldInfo.NameLoc);
}
-
+
ActionBase::ExprTy *getArrayIndex() const {
assert(isArrayDesignator() && "Invalid accessor");
return ArrayInfo.Index;
@@ -92,22 +92,22 @@ public:
assert(isArrayRangeDesignator() && "Invalid accessor");
return ArrayRangeInfo.End;
}
-
+
SourceLocation getLBracketLoc() const {
- assert((isArrayDesignator() || isArrayRangeDesignator()) &&
+ assert((isArrayDesignator() || isArrayRangeDesignator()) &&
"Invalid accessor");
if (isArrayDesignator())
return SourceLocation::getFromRawEncoding(ArrayInfo.LBracketLoc);
- else
+ else
return SourceLocation::getFromRawEncoding(ArrayRangeInfo.LBracketLoc);
}
SourceLocation getRBracketLoc() const {
- assert((isArrayDesignator() || isArrayRangeDesignator()) &&
+ assert((isArrayDesignator() || isArrayRangeDesignator()) &&
"Invalid accessor");
if (isArrayDesignator())
return SourceLocation::getFromRawEncoding(ArrayInfo.RBracketLoc);
- else
+ else
return SourceLocation::getFromRawEncoding(ArrayRangeInfo.RBracketLoc);
}
@@ -135,10 +135,10 @@ public:
D.ArrayInfo.RBracketLoc = 0;
return D;
}
-
+
static Designator getArrayRange(ActionBase::ExprTy *Start,
ActionBase::ExprTy *End,
- SourceLocation LBracketLoc,
+ SourceLocation LBracketLoc,
SourceLocation EllipsisLoc) {
Designator D;
D.Kind = ArrayRangeDesignator;
@@ -151,14 +151,14 @@ public:
}
void setRBracketLoc(SourceLocation RBracketLoc) const {
- assert((isArrayDesignator() || isArrayRangeDesignator()) &&
+ assert((isArrayDesignator() || isArrayRangeDesignator()) &&
"Invalid accessor");
if (isArrayDesignator())
ArrayInfo.RBracketLoc = RBracketLoc.getRawEncoding();
else
ArrayRangeInfo.RBracketLoc = RBracketLoc.getRawEncoding();
}
-
+
/// ClearExprs - Null out any expression references, which prevents them from
/// being 'delete'd later.
void ClearExprs(Action &Actions) {
@@ -173,7 +173,7 @@ public:
return;
}
}
-
+
/// FreeExprs - Release any unclaimed memory for the expressions in this
/// designator.
void FreeExprs(Action &Actions) {
@@ -190,7 +190,7 @@ public:
}
};
-
+
/// Designation - Represent a full designation, which is a sequence of
/// designators. This class is mostly a helper for InitListDesignations.
class Designation {
@@ -198,10 +198,10 @@ class Designation {
/// example, if the initializer were "{ A, .foo=B, C }" a Designation would
/// exist with InitIndex=1, because element #1 has a designation.
unsigned InitIndex;
-
+
/// Designators - The actual designators for this initializer.
llvm::SmallVector<Designator, 2> Designators;
-
+
Designation(unsigned Idx) : InitIndex(Idx) {}
public:
Designation() : InitIndex(4000) {}
@@ -218,14 +218,14 @@ public:
assert(Idx < Designators.size());
return Designators[Idx];
}
-
+
/// ClearExprs - Null out any expression references, which prevents them from
/// being 'delete'd later.
void ClearExprs(Action &Actions) {
for (unsigned i = 0, e = Designators.size(); i != e; ++i)
Designators[i].ClearExprs(Actions);
}
-
+
/// FreeExprs - Release any unclaimed memory for the expressions in this
/// designation.
void FreeExprs(Action &Actions) {
@@ -233,7 +233,7 @@ public:
Designators[i].FreeExprs(Actions);
}
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Parse/Ownership.h b/include/clang/Parse/Ownership.h
index 8840adb25f..9bd69c5fdb 100644
--- a/include/clang/Parse/Ownership.h
+++ b/include/clang/Parse/Ownership.h
@@ -23,7 +23,7 @@
namespace clang {
class ActionBase;
-
+
/// OpaquePtr - This is a very simple POD type that wraps a pointer that the
/// Parser doesn't know about but that Sema or another client does. The UID
/// template argument is used to make sure that "Decl" pointers are not
@@ -33,29 +33,29 @@ namespace clang {
void *Ptr;
public:
OpaquePtr() : Ptr(0) {}
-
+
template <typename T>
T* getAs() const {
return llvm::PointerLikeTypeTraits<T*>::getFromVoidPointer(Ptr);
}
-
+
template <typename T>
T getAsVal() const {
return llvm::PointerLikeTypeTraits<T>::getFromVoidPointer(Ptr);
}
-
+
void *get() const { return Ptr; }
-
+
template<typename T>
static OpaquePtr make(T P) {
OpaquePtr R; R.set(P); return R;
}
-
+
template<typename T>
void set(T P) {
Ptr = llvm::PointerLikeTypeTraits<T>::getAsVoidPointer(P);
}
-
+
operator bool() const { return Ptr != 0; }
};
}
@@ -218,7 +218,7 @@ namespace clang {
/// expressions, stmts, etc. It encapsulates both the object returned by
/// the action, plus a sense of whether or not it is valid.
/// When CompressInvalid is true, the "invalid" flag will be
- /// stored in the low bit of the Val pointer.
+ /// stored in the low bit of the Val pointer.
template<unsigned UID,
typename PtrTy = void*,
bool CompressInvalid = IsResultPtrLowBitFree<UID>::value>
@@ -252,7 +252,7 @@ namespace clang {
uintptr_t PtrWithInvalid;
typedef llvm::PointerLikeTypeTraits<PtrTy> PtrTraits;
public:
- ActionResult(bool Invalid = false)
+ ActionResult(bool Invalid = false)
: PtrWithInvalid(static_cast<uintptr_t>(Invalid)) { }
template<typename ActualExprTy>
@@ -262,17 +262,17 @@ namespace clang {
PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
}
-
+
ActionResult(PtrTy V) {
void *VP = PtrTraits::getAsVoidPointer(V);
PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
}
-
+
ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { }
PtrTy get() const {
- void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01);
+ void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01);
return PtrTraits::getFromVoidPointer(VP);
}
@@ -326,8 +326,7 @@ namespace clang {
/// Move emulation helper for ASTOwningResult. NEVER EVER use this class
/// directly if you don't know what you're doing.
template <ASTDestroyer Destroyer>
- class ASTResultMover
- {
+ class ASTResultMover {
ASTOwningResult<Destroyer> &Moved;
public:
@@ -339,8 +338,7 @@ namespace clang {
/// Move emulation helper for ASTMultiPtr. NEVER EVER use this class
/// directly if you don't know what you're doing.
template <ASTDestroyer Destroyer>
- class ASTMultiMover
- {
+ class ASTMultiMover {
ASTMultiPtr<Destroyer> &Moved;
public:
@@ -357,8 +355,7 @@ namespace clang {
/// Kept only as a type-safe wrapper for a void pointer, when smart pointers
/// are disabled. When they are enabled, ASTOwningResult takes over.
template <ASTDestroyer Destroyer>
- class ASTOwningPtr
- {
+ class ASTOwningPtr {
void *Node;
public:
@@ -400,8 +397,7 @@ namespace clang {
#if !defined(DISABLE_SMART_POINTERS)
template <ASTDestroyer Destroyer>
- class ASTOwningResult
- {
+ class ASTOwningResult {
llvm::PointerIntPair<ActionBase*, 1, bool> ActionInv;
void *Ptr;
@@ -505,8 +501,7 @@ namespace clang {
};
#else
template <ASTDestroyer Destroyer>
- class ASTOwningResult
- {
+ class ASTOwningResult {
public:
typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult;
@@ -522,8 +517,7 @@ namespace clang {
ASTOwningResult(const ASTOwningPtr<Destroyer> &o) : Result(o.get()) { }
/// Assignment from a raw pointer. Takes ownership - beware!
- ASTOwningResult & operator =(void *raw)
- {
+ ASTOwningResult & operator =(void *raw) {
Result = raw;
return *this;
}
@@ -563,8 +557,7 @@ namespace clang {
#endif
template <ASTDestroyer Destroyer>
- class ASTMultiPtr
- {
+ class ASTMultiPtr {
#if !defined(DISABLE_SMART_POINTERS)
ActionBase &Actions;
#endif
@@ -608,7 +601,7 @@ namespace clang {
/// Move constructor
ASTMultiPtr(moving::ASTMultiMover<Destroyer> mover)
#if defined(_MSC_VER)
- // Apply the visual C++ hack supplied above.
+ // Apply the visual C++ hack supplied above.
// Last tested with Visual Studio 2008.
: Actions(hack(mover)->Actions), Nodes(hack(mover)->Nodes), Count(hack(mover)->Count) {
#else
@@ -660,7 +653,7 @@ namespace clang {
}
#endif
};
-
+
class ASTTemplateArgsPtr {
#if !defined(DISABLE_SMART_POINTERS)
ActionBase &Actions;
@@ -668,7 +661,7 @@ namespace clang {
void **Args;
bool *ArgIsType;
mutable unsigned Count;
-
+
#if !defined(DISABLE_SMART_POINTERS)
void destroy() {
if (!Count)
@@ -684,16 +677,16 @@ namespace clang {
public:
ASTTemplateArgsPtr(ActionBase &actions, void **args, bool *argIsType,
- unsigned count) :
+ unsigned count) :
#if !defined(DISABLE_SMART_POINTERS)
- Actions(actions),
+ Actions(actions),
#endif
Args(args), ArgIsType(argIsType), Count(count) { }
// FIXME: Lame, not-fully-type-safe emulation of 'move semantics'.
- ASTTemplateArgsPtr(ASTTemplateArgsPtr &Other) :
+ ASTTemplateArgsPtr(ASTTemplateArgsPtr &Other) :
#if !defined(DISABLE_SMART_POINTERS)
- Actions(Other.Actions),
+ Actions(Other.Actions),
#endif
Args(Other.Args), ArgIsType(Other.ArgIsType), Count(Other.Count) {
#if !defined(DISABLE_SMART_POINTERS)
@@ -734,7 +727,7 @@ namespace clang {
void *operator[](unsigned Arg) const { return Args[Arg]; }
- void **release() const {
+ void **release() const {
#if !defined(DISABLE_SMART_POINTERS)
Count = 0;
#endif
@@ -754,7 +747,7 @@ namespace clang {
ASTOwningVector &operator=(ASTOwningVector &); // do not implement
public:
- explicit ASTOwningVector(ActionBase &Actions)
+ explicit ASTOwningVector(ActionBase &Actions)
#if !defined(DISABLE_SMART_POINTERS)
: Actions(Actions), Owned(true)
#endif
@@ -825,8 +818,7 @@ namespace clang {
template <ASTDestroyer Destroyer> inline
ASTOwningPtr<Destroyer>::ASTOwningPtr(const ASTOwningResult<Destroyer> &o)
- : Node(o.get())
- {}
+ : Node(o.get()) { }
// These versions are hopefully no-ops.
template <ASTDestroyer Destroyer> inline
diff --git a/include/clang/Parse/ParseDiagnostic.h b/include/clang/Parse/ParseDiagnostic.h
index fa600ddadf..c702e2fe65 100644
--- a/include/clang/Parse/ParseDiagnostic.h
+++ b/include/clang/Parse/ParseDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define PARSESTART
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index dd1036e861..e1a6e7ad39 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -38,8 +38,8 @@ public:
PrettyStackTraceParserEntry(const Parser &p) : P(p) {}
virtual void print(llvm::raw_ostream &OS) const;
};
-
-
+
+
/// Parser - This implements a parser for the C family of languages. After
/// parsing units of the grammar, productions are invoked to handle whatever has
/// been read.
@@ -47,13 +47,13 @@ public:
class Parser {
friend class PragmaUnusedHandler;
PrettyStackTraceParserEntry CrashInfo;
-
+
Preprocessor &PP;
-
+
/// Tok - The current token we are peeking ahead. All parsing methods assume
/// that this is valid.
Token Tok;
-
+
// PrevTokLocation - The location of the token we previously
// consumed. This token is used for diagnostics where we expected to
// see a token following another token (e.g., the ';' at the end of
@@ -66,10 +66,10 @@ class Parser {
/// in the file. This refers to the common base class between MinimalActions
/// and SemaActions for those uses that don't matter.
Action &Actions;
-
+
Scope *CurScope;
Diagnostic &Diags;
-
+
/// ScopeCache - Cache scopes to reduce malloc traffic.
enum { ScopeCacheSize = 16 };
unsigned NumCachedScopes;
@@ -83,7 +83,7 @@ class Parser {
llvm::OwningPtr<PragmaHandler> UnusedHandler;
llvm::OwningPtr<PragmaHandler> WeakHandler;
llvm::OwningPtr<clang::CommentHandler> CommentHandler;
-
+
/// Whether the '>' token acts as an operator or not. This will be
/// true except when we are parsing an expression within a C++
/// template argument list, where the '>' closes the template
@@ -92,15 +92,15 @@ class Parser {
/// The "depth" of the template parameters currently being parsed.
unsigned TemplateParameterDepth;
-
+
/// \brief RAII object that makes '>' behave either as an operator
/// or as the closing angle bracket for a template argument list.
struct GreaterThanIsOperatorScope {
bool &GreaterThanIsOperator;
bool OldGreaterThanIsOperator;
-
+
GreaterThanIsOperatorScope(bool &GTIO, bool Val)
- : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) {
+ : GreaterThanIsOperator(GTIO), OldGreaterThanIsOperator(GTIO) {
GreaterThanIsOperator = Val;
}
@@ -108,7 +108,7 @@ class Parser {
GreaterThanIsOperator = OldGreaterThanIsOperator;
}
};
-
+
public:
Parser(Preprocessor &PP, Action &Actions);
~Parser();
@@ -117,9 +117,9 @@ public:
TargetInfo &getTargetInfo() const { return PP.getTargetInfo(); }
Preprocessor &getPreprocessor() const { return PP; }
Action &getActions() const { return Actions; }
-
+
const Token &getCurToken() const { return Tok; }
-
+
// Type forwarding. All of these are statically 'void*', but they may all be
// different actual classes based on the actions in place.
typedef Action::ExprTy ExprTy;
@@ -166,24 +166,24 @@ public:
OwningExprResult ExprEmpty() { return OwningExprResult(Actions, false); }
// Parsing methods.
-
+
/// ParseTranslationUnit - All in one method that initializes parses, and
/// shuts down the parser.
void ParseTranslationUnit();
-
+
/// Initialize - Warm up the parser.
///
void Initialize();
-
- /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if
+
+ /// ParseTopLevelDecl - Parse one top-level declaration. Returns true if
/// the EOF was encountered.
bool ParseTopLevelDecl(DeclGroupPtrTy &Result);
-
+
private:
//===--------------------------------------------------------------------===//
// Low-Level token peeking and consumption methods.
//
-
+
/// isTokenParen - Return true if the cur token is '(' or ')'.
bool isTokenParen() const {
return Tok.getKind() == tok::l_paren || Tok.getKind() == tok::r_paren;
@@ -196,7 +196,7 @@ private:
bool isTokenBrace() const {
return Tok.getKind() == tok::l_brace || Tok.getKind() == tok::r_brace;
}
-
+
/// isTokenStringLiteral - True if this token is a string-literal.
///
bool isTokenStringLiteral() const {
@@ -216,7 +216,7 @@ private:
PP.Lex(Tok);
return PrevTokLocation;
}
-
+
/// ConsumeAnyToken - Dispatch to the right Consume* method based on the
/// current token type. This should only be used in cases where the type of
/// the token really isn't known, e.g. in error recovery.
@@ -232,7 +232,7 @@ private:
else
return ConsumeToken();
}
-
+
/// ConsumeParen - This consume method keeps the paren count up-to-date.
///
SourceLocation ConsumeParen() {
@@ -245,7 +245,7 @@ private:
PP.Lex(Tok);
return PrevTokLocation;
}
-
+
/// ConsumeBracket - This consume method keeps the bracket count up-to-date.
///
SourceLocation ConsumeBracket() {
@@ -254,12 +254,12 @@ private:
++BracketCount;
else if (BracketCount)
--BracketCount; // Don't let unbalanced ]'s drive the count negative.
-
+
PrevTokLocation = Tok.getLocation();
PP.Lex(Tok);
return PrevTokLocation;
}
-
+
/// ConsumeBrace - This consume method keeps the brace count up-to-date.
///
SourceLocation ConsumeBrace() {
@@ -268,12 +268,12 @@ private:
++BraceCount;
else if (BraceCount)
--BraceCount; // Don't let unbalanced }'s drive the count negative.
-
+
PrevTokLocation = Tok.getLocation();
PP.Lex(Tok);
return PrevTokLocation;
}
-
+
/// ConsumeStringToken - Consume the current 'peek token', lexing a new one
/// and returning the token kind. This method is specific to strings, as it
/// handles string literal concatenation, as per C99 5.1.1.2, translation
@@ -285,7 +285,7 @@ private:
PP.Lex(Tok);
return PrevTokLocation;
}
-
+
/// GetLookAheadToken - This peeks ahead N tokens and returns that token
/// without consuming any tokens. LookAhead(0) returns 'Tok', LookAhead(1)
/// returns the token after Tok, etc.
@@ -362,8 +362,8 @@ private:
assert(!isActive && "Forgot to call Commit or Revert!");
}
};
-
-
+
+
/// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'),
/// this helper function matches and consumes the specified RHS token if
/// present. If not present, it emits the specified diagnostic indicating
@@ -372,7 +372,7 @@ private:
/// of the consumed token.
SourceLocation MatchRHSPunctuation(tok::TokenKind RHSTok,
SourceLocation LHSLoc);
-
+
/// ExpectAndConsume - The parser expects that 'ExpectedTok' is next in the
/// input. If so, it is consumed and false is returned.
///
@@ -385,7 +385,7 @@ private:
//===--------------------------------------------------------------------===//
// Scope manipulation
-
+
/// ParseScope - Introduces a new scope for parsing. The kind of
/// scope is determined by ScopeFlags. Objects of this type should
/// be created on the stack to coincide with the position where the
@@ -402,7 +402,7 @@ private:
// parser Self where the new Scope is created with the flags
// ScopeFlags, but only when ManageScope is true (the default). If
// ManageScope is false, this object does nothing.
- ParseScope(Parser *Self, unsigned ScopeFlags, bool ManageScope = true)
+ ParseScope(Parser *Self, unsigned ScopeFlags, bool ManageScope = true)
: Self(Self) {
if (ManageScope)
Self->EnterScope(ScopeFlags);
@@ -426,7 +426,7 @@ private:
/// EnterScope - Start a new scope.
void EnterScope(unsigned ScopeFlags);
-
+
/// ExitScope - Pop a scope off the scope stack.
void ExitScope();
@@ -436,7 +436,7 @@ private:
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
DiagnosticBuilder Diag(const Token &Tok, unsigned DiagID);
- void SuggestParentheses(SourceLocation Loc, unsigned DK,
+ void SuggestParentheses(SourceLocation Loc, unsigned DK,
SourceRange ParenRange);
/// SkipUntil - Read tokens until we get to the specified token, then consume
@@ -444,9 +444,9 @@ private:
/// token will ever occur, this skips to the next token, or to some likely
/// good stopping point. If StopAtSemi is true, skipping will stop at a ';'
/// character.
- ///
+ ///
/// If SkipUntil finds the specified token, it returns true, otherwise it
- /// returns false.
+ /// returns false.
bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true,
bool DontConsume = false) {
return SkipUntil(&T, 1, StopAtSemi, DontConsume);
@@ -479,7 +479,7 @@ private:
/// occurs within a member function declaration inside the class
/// (C++ [class.mem]p2).
struct LateParsedDefaultArgument {
- explicit LateParsedDefaultArgument(Action::DeclPtrTy P,
+ explicit LateParsedDefaultArgument(Action::DeclPtrTy P,
CachedTokens *Toks = 0)
: Param(P), Toks(Toks) { }
@@ -492,13 +492,13 @@ private:
/// default argument.
CachedTokens *Toks;
};
-
+
/// LateParsedMethodDeclaration - A method declaration inside a class that
/// contains at least one entity whose parsing needs to be delayed
/// until the class itself is completely-defined, such as a default
/// argument (C++ [class.mem]p2).
struct LateParsedMethodDeclaration {
- explicit LateParsedMethodDeclaration(Action::DeclPtrTy M)
+ explicit LateParsedMethodDeclaration(Action::DeclPtrTy M)
: Method(M), TemplateScope(false) { }
/// Method - The method declaration.
@@ -508,12 +508,12 @@ private:
/// scope. When true, D is a template declaration.
/// othewise, it is a member function declaration.
bool TemplateScope;
-
+
/// DefaultArgs - Contains the parameters of the function and
/// their default arguments. At least one of the parameters will
/// have a default argument, but all of the parameters of the
/// method will be stored so that they can be reintroduced into
- /// scope at the appropriate times.
+ /// scope at the appropriate times.
llvm::SmallVector<LateParsedDefaultArgument, 8> DefaultArgs;
};
@@ -533,8 +533,8 @@ private:
/// any member function declarations or definitions that need to be
/// parsed after the corresponding top-level class is complete.
struct ParsingClass {
- ParsingClass(DeclPtrTy TagOrTemplate, bool TopLevelClass)
- : TopLevelClass(TopLevelClass), TemplateScope(false),
+ ParsingClass(DeclPtrTy TagOrTemplate, bool TopLevelClass)
+ : TopLevelClass(TopLevelClass), TemplateScope(false),
TagOrTemplate(TagOrTemplate) { }
/// \brief Whether this is a "top-level" class, meaning that it is
@@ -571,27 +571,27 @@ private:
return *ClassStack.top();
}
- /// \brief RAII object used to
+ /// \brief RAII object used to
class ParsingClassDefinition {
Parser &P;
bool Popped;
public:
- ParsingClassDefinition(Parser &P, DeclPtrTy TagOrTemplate, bool TopLevelClass)
- : P(P), Popped(false) {
+ ParsingClassDefinition(Parser &P, DeclPtrTy TagOrTemplate, bool TopLevelClass)
+ : P(P), Popped(false) {
P.PushParsingClass(TagOrTemplate, TopLevelClass);
}
/// \brief Pop this class of the stack.
- void Pop() {
+ void Pop() {
assert(!Popped && "Nested class has already been popped");
Popped = true;
P.PopParsingClass();
}
- ~ParsingClassDefinition() {
+ ~ParsingClassDefinition() {
if (!Popped)
- P.PopParsingClass();
+ P.PopParsingClass();
}
};
@@ -599,7 +599,7 @@ private:
/// information that has been parsed prior to parsing declaration
/// specifiers.
struct ParsedTemplateInfo {
- ParsedTemplateInfo()
+ ParsedTemplateInfo()
: Kind(NonTemplate), TemplateParams(0), TemplateLoc() { }
ParsedTemplateInfo(TemplateParameterLists *TemplateParams,
@@ -609,7 +609,7 @@ private:
explicit ParsedTemplateInfo(SourceLocation ExternLoc,
SourceLocation TemplateLoc)
- : Kind(ExplicitInstantiation), TemplateParams(0),
+ : Kind(ExplicitInstantiation), TemplateParams(0),
ExternLoc(ExternLoc), TemplateLoc(TemplateLoc) { }
/// \brief The kind of template we are parsing.
@@ -631,12 +631,12 @@ private:
/// \brief The location of the 'extern' keyword, if any, for an explicit
/// instantiation
SourceLocation ExternLoc;
-
+
/// \brief The location of the 'template' keyword, for an explicit
/// instantiation.
SourceLocation TemplateLoc;
};
-
+
void PushParsingClass(DeclPtrTy TagOrTemplate, bool TopLevelClass);
void DeallocateParsedClasses(ParsingClass *Class);
void PopParsingClass();
@@ -645,7 +645,7 @@ private:
const ParsedTemplateInfo &TemplateInfo);
void ParseLexedMethodDeclarations(ParsingClass &Class);
void ParseLexedMethodDefs(ParsingClass &Class);
- bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
+ bool ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
CachedTokens &Toks,
tok::TokenKind EarlyAbortIf = tok::unknown,
bool ConsumeFinalToken = true);
@@ -657,7 +657,7 @@ private:
bool isStartOfFunctionDefinition();
DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
AccessSpecifier AS = AS_none);
-
+
DeclPtrTy ParseFunctionDefinition(Declarator &D,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
void ParseKNRParamDeclarations(Declarator &D);
@@ -667,20 +667,20 @@ private:
OwningExprResult ParseAsmStringLiteral();
// Objective-C External Declarations
- DeclPtrTy ParseObjCAtDirectives();
+ DeclPtrTy ParseObjCAtDirectives();
DeclPtrTy ParseObjCAtClassDeclaration(SourceLocation atLoc);
- DeclPtrTy ParseObjCAtInterfaceDeclaration(SourceLocation atLoc,
+ DeclPtrTy ParseObjCAtInterfaceDeclaration(SourceLocation atLoc,
AttributeList *prefixAttrs = 0);
- void ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
+ void ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
SourceLocation atLoc);
bool ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &P,
- bool WarnOnDeclarations,
+ bool WarnOnDeclarations,
SourceLocation &EndProtoLoc);
void ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
tok::ObjCKeywordKind contextKey);
DeclPtrTy ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
AttributeList *prefixAttrs = 0);
-
+
DeclPtrTy ObjCImpDecl;
DeclPtrTy ParseObjCAtImplementationDeclaration(SourceLocation atLoc);
@@ -688,7 +688,7 @@ private:
DeclPtrTy ParseObjCAtAliasDeclaration(SourceLocation atLoc);
DeclPtrTy ParseObjCPropertySynthesize(SourceLocation atLoc);
DeclPtrTy ParseObjCPropertyDynamic(SourceLocation atLoc);
-
+
IdentifierInfo *ParseObjCSelectorPiece(SourceLocation &MethodLocation);
// Definitions for Objective-c context sensitive keywords recognition.
enum ObjCTypeQual {
@@ -696,7 +696,7 @@ private:
objc_NumQuals
};
IdentifierInfo *ObjCTypeQuals[objc_NumQuals];
-
+
bool isTokIdentifier_in() const;
TypeTy *ParseObjCTypeName(ObjCDeclSpec &DS);
@@ -707,9 +707,9 @@ private:
DeclPtrTy classDecl,
tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword);
void ParseObjCPropertyAttribute(ObjCDeclSpec &DS);
-
+
DeclPtrTy ParseObjCMethodDefinition();
-
+
//===--------------------------------------------------------------------===//
// C99 6.5: Expressions.
@@ -734,7 +734,7 @@ private:
OwningExprResult ParsePostfixExpressionSuffix(OwningExprResult LHS);
OwningExprResult ParseSizeofAlignofExpression();
OwningExprResult ParseBuiltinPrimaryExpression();
-
+
OwningExprResult ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
bool &isCastExpr,
TypeTy *&CastTy,
@@ -759,26 +759,26 @@ private:
bool parseAsExprList,
TypeTy *&CastTy,
SourceLocation &RParenLoc);
-
+
OwningExprResult ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
TypeTy *&CastTy,
SourceLocation LParenLoc,
SourceLocation &RParenLoc);
-
+
OwningExprResult ParseCompoundLiteralExpression(TypeTy *Ty,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
-
+
OwningExprResult ParseStringLiteralExpression();
//===--------------------------------------------------------------------===//
// C++ Expressions
OwningExprResult ParseCXXIdExpression(bool isAddressOfOperand = false);
- bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
+ bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
TypeTy *ObjectType,
bool EnteringContext);
-
+
//===--------------------------------------------------------------------===//
// C++ 5.2p1: C++ Casts
OwningExprResult ParseCXXCasts();
@@ -832,7 +832,7 @@ private:
//===--------------------------------------------------------------------===//
// C99 6.7.8: Initialization.
-
+
/// ParseInitializer
/// initializer: [C99 6.7.8]
/// assignment-expression
@@ -852,15 +852,15 @@ private:
//===--------------------------------------------------------------------===//
// Objective-C Expressions
-
+
bool isTokObjCMessageIdentifierReceiver() const {
if (!Tok.is(tok::identifier))
return false;
-
+
IdentifierInfo *II = Tok.getIdentifierInfo();
if (Actions.getTypeName(*II, Tok.getLocation(), CurScope))
return true;
-
+
return II == Ident_super;
}
@@ -935,7 +935,7 @@ private:
DSC_normal, // normal context
DSC_class // class context, enables 'friend'
};
-
+
DeclGroupPtrTy ParseDeclaration(unsigned Context, SourceLocation &DeclEnd);
DeclGroupPtrTy ParseSimpleDeclaration(unsigned Context,
SourceLocation &DeclEnd,
@@ -949,17 +949,17 @@ private:
bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS);
- void ParseDeclarationSpecifiers(DeclSpec &DS,
+ void ParseDeclarationSpecifiers(DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
AccessSpecifier AS = AS_none,
DeclSpecContext DSC = DSC_normal);
- bool ParseOptionalTypeSpecifier(DeclSpec &DS, bool &isInvalid,
+ bool ParseOptionalTypeSpecifier(DeclSpec &DS, bool &isInvalid,
const char *&PrevSpec,
unsigned &DiagID,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
void ParseSpecifierQualifierList(DeclSpec &DS);
-
+
void ParseObjCTypeQualifierList(ObjCDeclSpec &DS);
void ParseEnumSpecifier(SourceLocation TagLoc, DeclSpec &DS,
@@ -969,7 +969,7 @@ private:
DeclPtrTy TagDecl);
void ParseStructDeclaration(DeclSpec &DS,
llvm::SmallVectorImpl<FieldDeclarator> &Fields);
-
+
bool isDeclarationSpecifier();
bool isTypeSpecifierQualifier();
bool isTypeQualifier() const;
@@ -1131,7 +1131,7 @@ private:
}
}
};
-
+
/// ParseDeclarator - Parse and verify a newly-initialized declarator.
void ParseDeclarator(Declarator &D);
/// A function that parses a variant of direct-declarator.
@@ -1147,10 +1147,10 @@ private:
void ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
Declarator &D);
void ParseBracketDeclarator(Declarator &D);
-
+
//===--------------------------------------------------------------------===//
// C++ 7: Declarations [dcl.dcl]
-
+
DeclPtrTy ParseNamespace(unsigned Context, SourceLocation &DeclEnd);
DeclPtrTy ParseLinkage(unsigned Context);
DeclPtrTy ParseUsingDirectiveOrDeclaration(unsigned Context,
@@ -1164,14 +1164,14 @@ private:
DeclPtrTy ParseNamespaceAlias(SourceLocation NamespaceLoc,
SourceLocation AliasLoc, IdentifierInfo *Alias,
SourceLocation &DeclEnd);
-
+
//===--------------------------------------------------------------------===//
// C++ 9: classes [class] and C structs/unions.
- TypeResult ParseClassName(SourceLocation &EndLocation,
+ TypeResult ParseClassName(SourceLocation &EndLocation,
const CXXScopeSpec *SS = 0,
bool DestrExpected = false);
void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc,
- DeclSpec &DS,
+ DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),
AccessSpecifier AS = AS_none);
void ParseCXXMemberSpecification(SourceLocation StartLoc, unsigned TagType,
@@ -1212,9 +1212,9 @@ private:
const ParsedTemplateInfo &TemplateInfo,
SourceLocation &DeclEnd,
AccessSpecifier AS=AS_none);
- bool ParseTemplateParameters(unsigned Depth,
+ bool ParseTemplateParameters(unsigned Depth,
TemplateParameterList &TemplateParams,
- SourceLocation &LAngleLoc,
+ SourceLocation &LAngleLoc,
SourceLocation &RAngleLoc);
bool ParseTemplateParameterList(unsigned Depth,
TemplateParameterList &TemplateParams);
@@ -1228,7 +1228,7 @@ private:
typedef llvm::SmallVector<SourceLocation, 16> TemplateArgLocationList;
bool ParseTemplateIdAfterTemplateName(TemplateTy Template,
- SourceLocation TemplateNameLoc,
+ SourceLocation TemplateNameLoc,
const CXXScopeSpec *SS,
bool ConsumeLastToken,
SourceLocation &LAngleLoc,
@@ -1247,7 +1247,7 @@ private:
TemplateArgLocationList &TemplateArgLocations);
void *ParseTemplateArgument(bool &ArgIsType);
DeclPtrTy ParseExplicitInstantiation(SourceLocation ExternLoc,
- SourceLocation TemplateLoc,
+ SourceLocation TemplateLoc,
SourceLocation &DeclEnd);
//===--------------------------------------------------------------------===//
diff --git a/include/clang/Parse/Scope.h b/include/clang/Parse/Scope.h
index 84cc5d5c34..480b94f73f 100644
--- a/include/clang/Parse/Scope.h
+++ b/include/clang/Parse/Scope.h
@@ -31,15 +31,15 @@ public:
/// FnScope - This indicates that the scope corresponds to a function, which
/// means that labels are set here.
FnScope = 0x01,
-
+
/// BreakScope - This is a while,do,switch,for, etc that can have break
/// stmts embedded into it.
BreakScope = 0x02,
-
+
/// ContinueScope - This is a while,do,for, which can have continue
/// stmt embedded into it.
ContinueScope = 0x04,
-
+
/// DeclScope - This is a scope that can contain a declaration. Some scopes
/// just contain loop constructs but don't contain decls.
DeclScope = 0x08,
@@ -49,7 +49,7 @@ public:
/// ClassScope - The scope of a struct/union/class definition.
ClassScope = 0x20,
-
+
/// BlockScope - This is a scope that corresponds to a block object.
/// Blocks serve as top-level scopes for some objects like labels, they
/// also prevent things like break and continue. BlockScopes have the
@@ -65,7 +65,7 @@ public:
/// FunctionPrototypeScope - This is a scope that corresponds to the
/// parameters within a function prototype.
FunctionPrototypeScope = 0x100,
-
+
/// AtCatchScope - This is a scope that corresponds to the Objective-C
/// @catch statement.
AtCatchScope = 0x200
@@ -74,15 +74,15 @@ private:
/// The parent scope for this scope. This is null for the translation-unit
/// scope.
Scope *AnyParent;
-
+
/// Depth - This is the depth of this scope. The translation-unit scope has
/// depth 0.
unsigned Depth : 16;
-
+
/// Flags - This contains a set of ScopeFlags, which indicates how the scope
/// interrelates with other control flow statements.
unsigned Flags : 10;
-
+
/// WithinElse - Whether this scope is part of the "else" branch in
/// its parent ControlScope.
bool WithinElse : 1;
@@ -90,7 +90,7 @@ private:
/// FnParent - If this scope has a parent scope that is a function body, this
/// pointer is non-null and points to it. This is used for label processing.
Scope *FnParent;
-
+
/// BreakParent/ContinueParent - This is a direct link to the immediately
/// preceeding BreakParent/ContinueParent if this scope is not one, or null if
/// there is no containing break/continue scope.
@@ -119,7 +119,7 @@ private:
/// implement these semantics.
typedef llvm::SmallPtrSet<Action::DeclPtrTy, 32> DeclSetTy;
DeclSetTy DeclsInScope;
-
+
/// Entity - The entity with which this scope is associated. For
/// example, the entity of a class scope is the class itself, the
/// entity of a function scope is a function, etc. This field is
@@ -151,9 +151,9 @@ public:
///
const Scope *getFnParent() const { return FnParent; }
Scope *getFnParent() { return FnParent; }
-
+
/// getContinueParent - Return the closest scope that a continue statement
- /// would be affected by. If the closest scope is a closure scope, we know
+ /// would be affected by. If the closest scope is a closure scope, we know
/// that there is no loop *inside* the closure.
Scope *getContinueParent() {
if (ContinueParent && !ContinueParent->isBlockScope())
@@ -164,9 +164,9 @@ public:
const Scope *getContinueParent() const {
return const_cast<Scope*>(this)->getContinueParent();
}
-
+
/// getBreakParent - Return the closest scope that a break statement
- /// would be affected by. If the closest scope is a block scope, we know
+ /// would be affected by. If the closest scope is a block scope, we know
/// that there is no loop *inside* the block.
Scope *getBreakParent() {
if (BreakParent && !BreakParent->isBlockScope())
@@ -176,16 +176,16 @@ public:
const Scope *getBreakParent() const {
return const_cast<Scope*>(this)->getBreakParent();
}
-
+
Scope *getControlParent() { return ControlParent; }
const Scope *getControlParent() const { return ControlParent; }
-
+
Scope *getBlockParent() { return BlockParent; }
- const Scope *getBlockParent() const { return BlockParent; }
+ const Scope *getBlockParent() const { return BlockParent; }
Scope *getTemplateParamParent() { return TemplateParamParent; }
- const Scope *getTemplateParamParent() const { return TemplateParamParent; }
-
+ const Scope *getTemplateParamParent() const { return TemplateParamParent; }
+
typedef DeclSetTy::iterator decl_iterator;
decl_iterator decl_begin() const { return DeclsInScope.begin(); }
decl_iterator decl_end() const { return DeclsInScope.end(); }
@@ -222,7 +222,7 @@ public:
}
return false;
}
-
+
/// isTemplateParamScope - Return true if this scope is a C++
/// template parameter scope.
bool isTemplateParamScope() const {
@@ -275,7 +275,7 @@ public:
AnyParent = Parent;
Depth = AnyParent ? AnyParent->Depth+1 : 0;
Flags = ScopeFlags;
-
+
if (AnyParent) {
FnParent = AnyParent->FnParent;
BreakParent = AnyParent->BreakParent;
@@ -291,7 +291,7 @@ public:
TemplateParamParent = 0;
WithinElse = false;
}
-
+
// If this scope is a function or contains breaks/continues, remember it.
if (Flags & FnScope) FnParent = this;
if (Flags & BreakScope) BreakParent = this;
@@ -304,7 +304,7 @@ public:
Entity = 0;
}
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Rewrite/DeltaTree.h b/include/clang/Rewrite/DeltaTree.h
index 7bf9305e28..7e0796524c 100644
--- a/include/clang/Rewrite/DeltaTree.h
+++ b/include/clang/Rewrite/DeltaTree.h
@@ -15,7 +15,7 @@
#define CLANG_REWRITE_DELTATREE_H
namespace clang {
-
+
/// DeltaTree - a multiway search tree (BTree) structure with some fancy
/// features. B-Trees are are generally more memory and cache efficient than
/// binary trees, because they store multiple keys/values in each node. This
@@ -32,16 +32,16 @@ namespace clang {
// Note: Currently we only support copying when the RHS is empty.
DeltaTree(const DeltaTree &RHS);
~DeltaTree();
-
+
/// getDeltaAt - Return the accumulated delta at the specified file offset.
/// This includes all insertions or delections that occurred *before* the
/// specified file index.
- int getDeltaAt(unsigned FileIndex) const;
+ int getDeltaAt(unsigned FileIndex) const;
/// AddDelta - When a change is made that shifts around the text buffer,
/// this method is used to record that info. It inserts a delta of 'Delta'
/// into the current DeltaTree at offset FileIndex.
- void AddDelta(unsigned FileIndex, int Delta);
+ void AddDelta(unsigned FileIndex, int Delta);
};
} // end namespace clang
diff --git a/include/clang/Rewrite/HTMLRewrite.h b/include/clang/Rewrite/HTMLRewrite.h
index f49d49e710..f77e0c61c5 100644
--- a/include/clang/Rewrite/HTMLRewrite.h
+++ b/include/clang/Rewrite/HTMLRewrite.h
@@ -19,36 +19,36 @@
#include <string>
namespace clang {
-
+
class Rewriter;
class RewriteBuffer;
class Preprocessor;
class PreprocessorFactory;
-
+
namespace html {
-
+
/// HighlightRange - Highlight a range in the source code with the specified
/// start/end tags. B/E must be in the same file. This ensures that
/// start/end tags are placed at the start/end of each line if the range is
/// multiline.
void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
const char *StartTag, const char *EndTag);
-
+
/// HighlightRange - Highlight a range in the source code with the specified
- /// start/end tags. The Start/end of the range must be in the same file.
+ /// start/end tags. The Start/end of the range must be in the same file.
/// This ensures that start/end tags are placed at the start/end of each line
/// if the range is multiline.
inline void HighlightRange(Rewriter &R, SourceRange Range,
const char *StartTag, const char *EndTag) {
HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag);
}
-
+
/// HighlightRange - This is the same as the above method, but takes
/// decomposed file locations.
void HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
const char *BufferStart,
const char *StartTag, const char *EndTag);
-
+
/// EscapeText - HTMLize a specified file so that special characters are
/// are translated so that they are not interpreted as HTML tags.
void EscapeText(Rewriter& R, FileID FID,
@@ -61,9 +61,9 @@ namespace html {
std::string EscapeText(const std::string& s,
bool EscapeSpaces = false, bool ReplaceTabs = false);
- void AddLineNumbers(Rewriter& R, FileID FID);
-
- void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
+ void AddLineNumbers(Rewriter& R, FileID FID);
+
+ void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
const char *title = NULL);
/// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
diff --git a/include/clang/Rewrite/RewriteRope.h b/include/clang/Rewrite/RewriteRope.h
index 3b8eeb2b6b..c0bd741d55 100644
--- a/include/clang/Rewrite/RewriteRope.h
+++ b/include/clang/Rewrite/RewriteRope.h
@@ -22,7 +22,7 @@ namespace clang {
//===--------------------------------------------------------------------===//
// RopeRefCountString Class
//===--------------------------------------------------------------------===//
-
+
/// RopeRefCountString - This struct is allocated with 'new char[]' from the
/// heap, and represents a reference counted chunk of string data. When its
/// ref count drops to zero, it is delete[]'d. This is primarily managed
@@ -30,21 +30,21 @@ namespace clang {
struct RopeRefCountString {
unsigned RefCount;
char Data[1]; // Variable sized.
-
+
void addRef() {
if (this) ++RefCount;
}
-
+
void dropRef() {
if (this && --RefCount == 0)
delete [] (char*)this;
}
};
-
+
//===--------------------------------------------------------------------===//
// RopePiece Class
//===--------------------------------------------------------------------===//
-
+
/// RopePiece - This class represents a view into a RopeRefCountString object.
/// This allows references to string data to be efficiently chopped up and
/// moved around without having to push around the string data itself.
@@ -57,9 +57,9 @@ namespace clang {
RopeRefCountString *StrData;
unsigned StartOffs;
unsigned EndOffs;
-
+
RopePiece() : StrData(0), StartOffs(0), EndOffs(0) {}
-
+
RopePiece(RopeRefCountString *Str, unsigned Start, unsigned End)
: StrData(Str), StartOffs(Start), EndOffs(End) {
StrData->addRef();
@@ -68,11 +68,11 @@ namespace clang {
: StrData(RP.StrData), StartOffs(RP.StartOffs), EndOffs(RP.EndOffs) {
StrData->addRef();
}
-
+
~RopePiece() {
StrData->dropRef();
}
-
+
void operator=(const RopePiece &RHS) {
if (StrData != RHS.StrData) {
StrData->dropRef();
@@ -82,21 +82,21 @@ namespace clang {
StartOffs = RHS.StartOffs;
EndOffs = RHS.EndOffs;
}
-
+
const char &operator[](unsigned Offset) const {
return StrData->Data[Offset+StartOffs];
}
char &operator[](unsigned Offset) {
return StrData->Data[Offset+StartOffs];
}
-
+
unsigned size() const { return EndOffs-StartOffs; }
};
-
+
//===--------------------------------------------------------------------===//
// RopePieceBTreeIterator Class
//===--------------------------------------------------------------------===//
-
+
/// RopePieceBTreeIterator - This class provides read-only forward iteration
/// over bytes that are in a RopePieceBTree. This first iterates over bytes
/// in a RopePiece, then iterates over RopePiece's in a RopePieceBTreeLeaf,
@@ -115,18 +115,18 @@ namespace clang {
RopePieceBTreeIterator(const void /*RopePieceBTreeNode*/ *N);
// end iterator
RopePieceBTreeIterator() : CurNode(0), CurPiece(0), CurChar(0) {}
-
+
char operator*() const {
return (*CurPiece)[CurChar];
}
-
+
bool operator==(const RopePieceBTreeIterator &RHS) const {
return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar;
}
bool operator!=(const RopePieceBTreeIterator &RHS) const {
return !operator==(RHS);
}
-
+
RopePieceBTreeIterator& operator++() { // Preincrement
if (CurChar+1 < CurPiece->size())
++CurChar;
@@ -140,11 +140,11 @@ namespace clang {
private:
void MoveToNextPiece();
};
-
+
//===--------------------------------------------------------------------===//
// RopePieceBTree Class
//===--------------------------------------------------------------------===//
-
+
class RopePieceBTree {
void /*RopePieceBTreeNode*/ *Root;
void operator=(const RopePieceBTree &); // DO NOT IMPLEMENT
@@ -152,15 +152,15 @@ namespace clang {
RopePieceBTree();
RopePieceBTree(const RopePieceBTree &RHS);
~RopePieceBTree();
-
+
typedef RopePieceBTreeIterator iterator;
iterator begin() const { return iterator(Root); }
iterator end() const { return iterator(); }
unsigned size() const;
unsigned empty() const { return size() == 0; }
-
+
void clear();
-
+
void insert(unsigned Offset, const RopePiece &R);
void erase(unsigned Offset, unsigned NumBytes);
@@ -169,13 +169,13 @@ namespace clang {
//===--------------------------------------------------------------------===//
// RewriteRope Class
//===--------------------------------------------------------------------===//
-
+
/// RewriteRope - A powerful string class. This class supports extremely
/// efficient insertions and deletions into the middle of it, even for
/// ridiculously long strings.
class RewriteRope {
RopePieceBTree Chunks;
-
+
/// We allocate space for string data out of a buffer of size AllocChunkSize.
/// This keeps track of how much space is left.
RopeRefCountString *AllocBuffer;
@@ -184,7 +184,7 @@ class RewriteRope {
public:
RewriteRope() : AllocBuffer(0), AllocOffs(AllocChunkSize) {}
- RewriteRope(const RewriteRope &RHS)
+ RewriteRope(const RewriteRope &RHS)
: Chunks(RHS.Chunks), AllocBuffer(0), AllocOffs(AllocChunkSize) {
}
@@ -192,23 +192,23 @@ public:
// If we had an allocation buffer, drop our reference to it.
AllocBuffer->dropRef();
}
-
+
typedef RopePieceBTree::iterator iterator;
typedef RopePieceBTree::iterator const_iterator;
iterator begin() const { return Chunks.begin(); }
iterator end() const { return Chunks.end(); }
unsigned size() const { return Chunks.size(); }
-
+
void clear() {
Chunks.clear();
}
-
+
void assign(const char *Start, const char *End) {
clear();
if (Start != End)
Chunks.insert(0, MakeRopeString(Start, End));
}
-
+
void insert(unsigned Offset, const char *Start, const char *End) {
assert(Offset <= size() && "Invalid position to insert!");
if (Start == End) return;
@@ -224,7 +224,7 @@ public:
private:
RopePiece MakeRopeString(const char *Start, const char *End);
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Rewrite/Rewriter.h b/include/clang/Rewrite/Rewriter.h
index ea4b08e71b..29e78fa279 100644
--- a/include/clang/Rewrite/Rewriter.h
+++ b/include/clang/Rewrite/Rewriter.h
@@ -29,7 +29,7 @@ namespace clang {
class LangOptions;
class Rewriter;
class Stmt;
-
+
/// RewriteBuffer - As code is rewritten, SourceBuffer's from the original
/// input with modifications get a new RewriteBuffer associated with them. The
/// RewriteBuffer captures the modified text itself as well as information used
@@ -41,7 +41,7 @@ class RewriteBuffer {
/// Deltas - Keep track of all the deltas in the source code due to insertions
/// and deletions.
DeltaTree Deltas;
-
+
/// Buffer - This is the actual buffer itself. Note that using a vector or
/// string is a horribly inefficient way to do this, we should use a rope
/// instead.
@@ -52,17 +52,17 @@ public:
iterator begin() const { return Buffer.begin(); }
iterator end() const { return Buffer.end(); }
unsigned size() const { return Buffer.size(); }
-
+
/// RemoveText - Remove the specified text.
void RemoveText(unsigned OrigOffset, unsigned Size);
-
+
/// InsertText - Insert some text at the specified point, where the offset in
/// the buffer is specified relative to the original SourceBuffer. The
/// text is inserted after the specified location.
///
void InsertText(unsigned OrigOffset, const llvm::StringRef &Str,
bool InsertAfter = true);
-
+
/// InsertTextBefore - Insert some text before the specified point, where the
/// offset in the buffer is specified relative to the original
@@ -71,28 +71,28 @@ public:
void InsertTextBefore(unsigned OrigOffset, const llvm::StringRef &Str) {
InsertText(OrigOffset, Str, false);
}
-
+
/// InsertTextAfter - Insert some text at the specified point, where the
/// offset in the buffer is specified relative to the original SourceBuffer.
/// The text is inserted after the specified location.
void InsertTextAfter(unsigned OrigOffset, const llvm::StringRef &Str) {
InsertText(OrigOffset, Str);
}
-
+
/// ReplaceText - This method replaces a range of characters in the input
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
void ReplaceText(unsigned OrigOffset, unsigned OrigLength,
const llvm::StringRef &NewStr);
-
+
private: // Methods only usable by Rewriter.
-
+
/// Initialize - Start this rewrite buffer out with a copy of the unmodified
/// input buffer.
void Initialize(const char *BufStart, const char *BufEnd) {
Buffer.assign(BufStart, BufEnd);
}
-
+
/// getMappedOffset - Given an offset into the original SourceBuffer that this
/// RewriteBuffer is based on, map it into the offset space of the
/// RewriteBuffer. If AfterInserts is true and if the OrigOffset indicates a
@@ -102,7 +102,7 @@ private: // Methods only usable by Rewriter.
bool AfterInserts = false) const{
return Deltas.getDeltaAt(2*OrigOffset+AfterInserts)+OrigOffset;
}
-
+
/// AddInsertDelta - When an insertion is made at a position, this
/// method is used to record that information.
void AddInsertDelta(unsigned OrigOffset, int Change) {
@@ -115,7 +115,7 @@ private: // Methods only usable by Rewriter.
return Deltas.AddDelta(2*OrigOffset+1, Change);
}
};
-
+
/// Rewriter - This is the main interface to the rewrite buffers. Its primary
/// job is to dispatch high-level requests to the low-level RewriteBuffers that
@@ -128,14 +128,14 @@ public:
explicit Rewriter(SourceManager &SM, const LangOptions &LO)
: SourceMgr(&SM), LangOpts(&LO) {}
explicit Rewriter() : SourceMgr(0), LangOpts(0) {}
-
+
void setSourceMgr(SourceManager &SM, const LangOptions &LO) {
SourceMgr = &SM;
LangOpts = &LO;
}
SourceManager &getSourceMgr() { return *SourceMgr; }
const LangOptions &getLangOpts() { return *LangOpts; }
-
+
/// isRewritable - Return true if this location is a raw file location, which
/// is rewritable. Locations from macros, etc are not rewritable.
static bool isRewritable(SourceLocation Loc) {
@@ -145,7 +145,7 @@ public:
/// getRangeSize - Return the size in bytes of the specified range if they
/// are in the same file. If not, this returns -1.
int getRangeSize(SourceRange Range) const;
-
+
/// getRewritenText - Return the rewritten form of the text in the specified
/// range. If the start or end of the range was unrewritable or if they are
/// in different buffers, this returns an empty string.
@@ -153,22 +153,22 @@ public:
/// Note that this method is not particularly efficient.
///
std::string getRewritenText(SourceRange Range) const;
-
+
/// InsertText - Insert the specified string at the specified location in the
/// original buffer. This method returns true (and does nothing) if the input
/// location was not rewritable, false otherwise.
bool InsertText(SourceLocation Loc, const llvm::StringRef &Str,
bool InsertAfter = true);
-
+
/// InsertTextAfter - Insert the specified string at the specified location in
- /// the original buffer. This method returns true (and does nothing) if
+ /// the original buffer. This method returns true (and does nothing) if
/// the input location was not rewritable, false otherwise. Text is
/// inserted after any other text that has been previously inserted
/// at the some point (the default behavior for InsertText).
bool InsertTextAfter(SourceLocation Loc, const llvm::StringRef &Str) {
return InsertText(Loc, Str);
- }
-
+ }
+
/// InsertText - Insert the specified string at the specified location in the
/// original buffer. This method returns true (and does nothing) if the input
/// location was not rewritable, false otherwise. Text is
@@ -177,21 +177,21 @@ public:
bool InsertTextBefore(SourceLocation Loc, const llvm::StringRef &Str) {
return InsertText(Loc, Str, false);
}
-
+
/// RemoveText - Remove the specified text region.
bool RemoveText(SourceLocation Start, unsigned Length);
-
+
/// ReplaceText - This method replaces a range of characters in the input
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
bool ReplaceText(SourceLocation Start, unsigned OrigLength,
const llvm::StringRef &NewStr);
-
+
/// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty
/// printer to generate the replacement code. This returns true if the input
/// could not be rewritten, or false if successful.
bool ReplaceStmt(Stmt *From, Stmt *To);
-
+
/// getRewriteBufferFor - Return the rewrite buffer for the specified FileID.
/// If no modification has been made to it, return null.
const RewriteBuffer *getRewriteBufferFor(FileID FID) const {
@@ -209,7 +209,7 @@ public:
private:
unsigned getLocationOffsetAndFileID(SourceLocation Loc, FileID &FID) const;
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Rewrite/TokenRewriter.h b/include/clang/Rewrite/TokenRewriter.h
index c8fd0f532c..62ea12af1f 100644
--- a/include/clang/Rewrite/TokenRewriter.h
+++ b/include/clang/Rewrite/TokenRewriter.h
@@ -24,7 +24,7 @@ namespace clang {
class Token;
class LangOptions;
class ScratchBuffer;
-
+
class TokenRewriter {
/// TokenList - This is the list of raw tokens that make up this file. Each
/// of these tokens has a unique SourceLocation, which is a FileID.
@@ -32,17 +32,17 @@ namespace clang {
/// TokenRefTy - This is the type used to refer to a token in the TokenList.
typedef std::list<Token>::iterator TokenRefTy;
-
+
/// TokenAtLoc - This map indicates which token exists at a specific
/// SourceLocation. Since each token has a unique SourceLocation, this is a
/// one to one map. The token can return its own location directly, to map
/// backwards.
std::map<SourceLocation, TokenRefTy> TokenAtLoc;
-
+
/// ScratchBuf - This is the buffer that we create scratch tokens from.
///
llvm::OwningPtr<ScratchBuffer> ScratchBuf;
-
+
TokenRewriter(const TokenRewriter&); // DO NOT IMPLEMENT
void operator=(const TokenRewriter&); // DO NOT IMPLEMENT.
public:
@@ -50,30 +50,30 @@ namespace clang {
/// specified FileID.
TokenRewriter(FileID FID, SourceManager &SM, const LangOptions &LO);
~TokenRewriter();
-
+
typedef std::list<Token>::const_iterator token_iterator;
token_iterator token_begin() const { return TokenList.begin(); }
token_iterator token_end() const { return TokenList.end(); }
-
-
+
+
token_iterator AddTokenBefore(token_iterator I, const char *Val);
token_iterator AddTokenAfter(token_iterator I, const char *Val) {
assert(I != token_end() && "Cannot insert after token_end()!");
return AddTokenBefore(++I, Val);
}
-
+
private:
/// RemapIterator - Convert from token_iterator (a const iterator) to
/// TokenRefTy (a non-const iterator).
TokenRefTy RemapIterator(token_iterator I);
-
+
/// AddToken - Add the specified token into the Rewriter before the other
/// position.
TokenRefTy AddToken(const Token &T, TokenRefTy Where);
};
-
-
-
+
+
+
} // end namespace clang
#endif
diff --git a/include/clang/Sema/ExternalSemaSource.h b/include/clang/Sema/ExternalSemaSource.h
index 0f0d375e9c..05c56451b2 100644
--- a/include/clang/Sema/ExternalSemaSource.h
+++ b/include/clang/Sema/ExternalSemaSource.h
@@ -39,13 +39,13 @@ public:
///
/// \returns a pair of Objective-C methods lists containing the
/// instance and factory methods, respectively, with this selector.
- virtual std::pair<ObjCMethodList, ObjCMethodList>
- ReadMethodPool(Selector Sel) {
+ virtual std::pair<ObjCMethodList, ObjCMethodList>
+ ReadMethodPool(Selector Sel) {
return std::pair<ObjCMethodList, ObjCMethodList>();
}
-
+
// isa/cast/dyn_cast support
- static bool classof(const ExternalASTSource *Source) {
+ static bool classof(const ExternalASTSource *Source) {
return Source->SemaSource;
}
static bool classof(const ExternalSemaSource *) { return true; }
diff --git a/include/clang/Sema/ParseAST.h b/include/clang/Sema/ParseAST.h
index bdce5e95ef..debe75bb85 100644
--- a/include/clang/Sema/ParseAST.h
+++ b/include/clang/Sema/ParseAST.h
@@ -28,7 +28,7 @@ namespace clang {
/// \param CompleteTranslationUnit When true, the parsed file is
/// considered to be a complete translation unit, and any
/// end-of-translation-unit wrapup will be performed.
- void ParseAST(Preprocessor &pp, ASTConsumer *C,
+ void ParseAST(Preprocessor &pp, ASTConsumer *C,
ASTContext &Ctx, bool PrintStats = false,
bool CompleteTranslationUnit = true);
diff --git a/include/clang/Sema/SemaConsumer.h b/include/clang/Sema/SemaConsumer.h
index e821947035..b213daf8a3 100644
--- a/include/clang/Sema/SemaConsumer.h
+++ b/include/clang/Sema/SemaConsumer.h
@@ -35,8 +35,8 @@ namespace clang {
virtual void InitializeSema(Sema &S) {}
// isa/cast/dyn_cast support
- static bool classof(const ASTConsumer *Consumer) {
- return Consumer->SemaConsumer;
+ static bool classof(const ASTConsumer *Consumer) {
+ return Consumer->SemaConsumer;
}
static bool classof(const SemaConsumer *) { return true; }
};
diff --git a/include/clang/Sema/SemaDiagnostic.h b/include/clang/Sema/SemaDiagnostic.h
index de92844f4d..d026339b5c 100644
--- a/include/clang/Sema/SemaDiagnostic.h
+++ b/include/clang/Sema/SemaDiagnostic.h
@@ -13,7 +13,7 @@
#include "clang/Basic/Diagnostic.h"
namespace clang {
- namespace diag {
+ namespace diag {
enum {
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM,
#define SEMASTART
diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp
index 489dac7970..772a884c90 100644
--- a/lib/AST/APValue.cpp
+++ b/lib/AST/APValue.cpp
@@ -91,7 +91,7 @@ void APValue::print(llvm::raw_ostream &OS) const {
return;
case Vector:
OS << "Vector: " << getVectorElt(0);
- for (unsigned i = 1; i != getVectorLength(); ++i)
+ for (unsigned i = 1; i != getVectorLength(); ++i)
OS << ", " << getVectorElt(i);
return;
case ComplexInt:
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 30e4234956..bf1fac9eec 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -37,16 +37,16 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins,
- bool FreeMem, unsigned size_reserve) :
- GlobalNestedNameSpecifier(0), CFConstantStringTypeDecl(0),
+ bool FreeMem, unsigned size_reserve) :
+ GlobalNestedNameSpecifier(0), CFConstantStringTypeDecl(0),
ObjCFastEnumerationStateTypeDecl(0), FILEDecl(0), jmp_bufDecl(0),
- sigjmp_bufDecl(0), SourceMgr(SM), LangOpts(LOpts),
- LoadedExternalComments(false), FreeMemory(FreeMem), Target(t),
+ sigjmp_bufDecl(0), SourceMgr(SM), LangOpts(LOpts),
+ LoadedExternalComments(false), FreeMemory(FreeMem), Target(t),
Idents(idents), Selectors(sels),
- BuiltinInfo(builtins), ExternalSource(0), PrintingPolicy(LOpts) {
+ BuiltinInfo(builtins), ExternalSource(0), PrintingPolicy(LOpts) {
ObjCIdRedefinitionType = QualType();
ObjCClassRedefinitionType = QualType();
- if (size_reserve > 0) Types.reserve(size_reserve);
+ if (size_reserve > 0) Types.reserve(size_reserve);
TUDecl = TranslationUnitDecl::Create(*this);
InitBuiltinTypes();
}
@@ -79,8 +79,8 @@ ASTContext::~ASTContext() {
// Destroy nested-name-specifiers.
for (llvm::FoldingSet<NestedNameSpecifier>::iterator
NNS = NestedNameSpecifiers.begin(),
- NNSEnd = NestedNameSpecifiers.end();
- NNS != NNSEnd;
+ NNSEnd = NestedNameSpecifiers.end();
+ NNS != NNSEnd;
/* Increment in loop */)
(*NNS++).Destroy(*this);
@@ -90,7 +90,7 @@ ASTContext::~ASTContext() {
TUDecl->Destroy(*this);
}
-void
+void
ASTContext::setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source) {
ExternalSource.reset(Source.take());
}
@@ -100,7 +100,7 @@ void ASTContext::PrintStats() const {
fprintf(stderr, " %d types total.\n", (int)Types.size());
unsigned counts[] = {
-#define TYPE(Name, Parent) 0,
+#define TYPE(Name, Parent) 0,
#define ABSTRACT_TYPE(Name, Parent)
#include "clang/AST/TypeNodes.def"
0 // Extra
@@ -120,7 +120,7 @@ void ASTContext::PrintStats() const {
++Idx;
#define ABSTRACT_TYPE(Name, Parent)
#include "clang/AST/TypeNodes.def"
-
+
fprintf(stderr, "Total bytes = %d\n", int(TotalBytes));
if (ExternalSource.get()) {
@@ -136,10 +136,10 @@ void ASTContext::InitBuiltinType(QualType &R, BuiltinType::Kind K) {
void ASTContext::InitBuiltinTypes() {
assert(VoidTy.isNull() && "Context reinitialized?");
-
+
// C99 6.2.5p19.
InitBuiltinType(VoidTy, BuiltinType::Void);
-
+
// C99 6.2.5p2.
InitBuiltinType(BoolTy, BuiltinType::Bool);
// C99 6.2.5p3.
@@ -153,14 +153,14 @@ void ASTContext::InitBuiltinTypes() {
InitBuiltinType(IntTy, BuiltinType::Int);
InitBuiltinType(LongTy, BuiltinType::Long);
InitBuiltinType(LongLongTy, BuiltinType::LongLong);
-
+
// C99 6.2.5p6.
InitBuiltinType(UnsignedCharTy, BuiltinType::UChar);
InitBuiltinType(UnsignedShortTy, BuiltinType::UShort);
InitBuiltinType(UnsignedIntTy, BuiltinType::UInt);
InitBuiltinType(UnsignedLongTy, BuiltinType::ULong);
InitBuiltinType(UnsignedLongLongTy, BuiltinType::ULongLong);
-
+
// C99 6.2.5p10.
InitBuiltinType(FloatTy, BuiltinType::Float);
InitBuiltinType(DoubleTy, BuiltinType::Double);
@@ -195,27 +195,27 @@ void ASTContext::InitBuiltinTypes() {
// expressions.
InitBuiltinType(DependentTy, BuiltinType::Dependent);
- // Placeholder type for C++0x auto declarations whose real type has
+ // Placeholder type for C++0x auto declarations whose real type has
// not yet been deduced.
InitBuiltinType(UndeducedAutoTy, BuiltinType::UndeducedAuto);
-
+
// C99 6.2.5p11.
FloatComplexTy = getComplexType(FloatTy);
DoubleComplexTy = getComplexType(DoubleTy);
LongDoubleComplexTy = getComplexType(LongDoubleTy);
BuiltinVaListType = QualType();
-
+
// "Builtin" typedefs set by Sema::ActOnTranslationUnitScope().
ObjCIdTypedefType = QualType();
ObjCClassTypedefType = QualType();
-
+
// Builtin types for 'id' and 'Class'.
InitBuiltinType(ObjCBuiltinIdTy, BuiltinType::ObjCId);
InitBuiltinType(ObjCBuiltinClassTy, BuiltinType::ObjCClass);
ObjCConstantStringType = QualType();
-
+
// void * type
VoidPtrTy = getPointerType(VoidTy);
@@ -229,11 +229,11 @@ VarDecl *ASTContext::getInstantiatedFromStaticDataMember(VarDecl *Var) {
= InstantiatedFromStaticDataMember.find(Var);
if (Pos == InstantiatedFromStaticDataMember.end())
return 0;
-
+
return Pos->second;
}
-void
+void
ASTContext::setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl) {
assert(Inst->isStaticDataMember() && "Not a static data member");
assert(Tmpl->isStaticDataMember() && "Not a static data member");
@@ -244,11 +244,11 @@ ASTContext::setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl) {
UnresolvedUsingDecl *
ASTContext::getInstantiatedFromUnresolvedUsingDecl(UsingDecl *UUD) {
- llvm::DenseMap<UsingDecl *, UnresolvedUsingDecl *>::iterator Pos
+ llvm::DenseMap<UsingDecl *, UnresolvedUsingDecl *>::iterator Pos
= InstantiatedFromUnresolvedUsingDecl.find(UUD);
if (Pos == InstantiatedFromUnresolvedUsingDecl.end())
return 0;
-
+
return Pos->second;
}
@@ -265,7 +265,7 @@ FieldDecl *ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) {
= InstantiatedFromUnnamedFieldDecl.find(Field);
if (Pos == InstantiatedFromUnnamedFieldDecl.end())
return 0;
-
+
return Pos->second;
}
@@ -275,18 +275,18 @@ void ASTContext::setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst,
assert(!Tmpl->getDeclName() && "Template field decl is not unnamed");
assert(!InstantiatedFromUnnamedFieldDecl[Inst] &&
"Already noted what unnamed field was instantiated from");
-
+
InstantiatedFromUnnamedFieldDecl[Inst] = Tmpl;
}
namespace {
- class BeforeInTranslationUnit
+ class BeforeInTranslationUnit
: std::binary_function<SourceRange, SourceRange, bool> {
SourceManager *SourceMgr;
-
+
public:
explicit BeforeInTranslationUnit(SourceManager *SM) : SourceMgr(SM) { }
-
+
bool operator()(SourceRange X, SourceRange Y) {
return SourceMgr->isBeforeInTranslationUnit(X.getBegin(), Y.getBegin());
}
@@ -302,14 +302,14 @@ namespace {
/// \param Member whether we want to check whether this is a member comment
/// (which requires a < after the Doxygen-comment delimiter). Otherwise,
/// we only return true when we find a non-member comment.
-static bool
-isDoxygenComment(SourceManager &SourceMgr, SourceRange Comment,
+static bool
+isDoxygenComment(SourceManager &SourceMgr, SourceRange Comment,
bool Member = false) {
- const char *BufferStart
+ const char *BufferStart
= SourceMgr.getBufferData(SourceMgr.getFileID(Comment.getBegin())).first;
const char *Start = BufferStart + SourceMgr.getFileOffset(Comment.getBegin());
const char* End = BufferStart + SourceMgr.getFileOffset(Comment.getEnd());
-
+
if (End - Start < 4)
return false;
@@ -323,32 +323,32 @@ isDoxygenComment(SourceManager &SourceMgr, SourceRange Comment,
}
/// \brief Retrieve the comment associated with the given declaration, if
-/// it has one.
+/// it has one.
const char *ASTContext::getCommentForDecl(const Decl *D) {
if (!D)
return 0;
-
+
// Check whether we have cached a comment string for this declaration
// already.
- llvm::DenseMap<const Decl *, std::string>::iterator Pos
+ llvm::DenseMap<const Decl *, std::string>::iterator Pos
= DeclComments.find(D);
if (Pos != DeclComments.end())
return Pos->second.c_str();
- // If we have an external AST source and have not yet loaded comments from
+ // If we have an external AST source and have not yet loaded comments from
// that source, do so now.
if (ExternalSource && !LoadedExternalComments) {
std::vector<SourceRange> LoadedComments;
ExternalSource->ReadComments(LoadedComments);
-
+
if (!LoadedComments.empty())
Comments.insert(Comments.begin(), LoadedComments.begin(),
LoadedComments.end());
-
+
LoadedExternalComments = true;
}
-
- // If there are no comments anywhere, we won't find anything.
+
+ // If there are no comments anywhere, we won't find anything.
if (Comments.empty())
return 0;
@@ -360,17 +360,17 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
// Find the comment that occurs just before this declaration.
std::vector<SourceRange>::iterator LastComment
- = std::lower_bound(Comments.begin(), Comments.end(),
+ = std::lower_bound(Comments.begin(), Comments.end(),
SourceRange(DeclStartLoc),
BeforeInTranslationUnit(&SourceMgr));
-
+
// Decompose the location for the start of the declaration and find the
// beginning of the file buffer.
- std::pair<FileID, unsigned> DeclStartDecomp
+ std::pair<FileID, unsigned> DeclStartDecomp
= SourceMgr.getDecomposedLoc(DeclStartLoc);
- const char *FileBufferStart
+ const char *FileBufferStart
= SourceMgr.getBufferData(DeclStartDecomp.first).first;
-
+
// First check whether we have a comment for a member.
if (LastComment != Comments.end() &&
!isa<TagDecl>(D) && !isa<NamespaceDecl>(D) &&
@@ -379,19 +379,19 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
= SourceMgr.getDecomposedLoc(LastComment->getEnd());
if (DeclStartDecomp.first == LastCommentEndDecomp.first &&
SourceMgr.getLineNumber(DeclStartDecomp.first, DeclStartDecomp.second)
- == SourceMgr.getLineNumber(LastCommentEndDecomp.first,
+ == SourceMgr.getLineNumber(LastCommentEndDecomp.first,
LastCommentEndDecomp.second)) {
// The Doxygen member comment comes after the declaration starts and
// is on the same line and in the same file as the declaration. This
// is the comment we want.
std::string &Result = DeclComments[D];
- Result.append(FileBufferStart +
- SourceMgr.getFileOffset(LastComment->getBegin()),
+ Result.append(FileBufferStart +
+ SourceMgr.getFileOffset(LastComment->getBegin()),
FileBufferStart + LastCommentEndDecomp.second + 1);
return Result.c_str();
}
}
-
+
if (LastComment == Comments.begin())
return 0;
--LastComment;
@@ -399,33 +399,33 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
// Decompose the end of the comment.
std::pair<FileID, unsigned> LastCommentEndDecomp
= SourceMgr.getDecomposedLoc(LastComment->getEnd());
-
+
// If the comment and the declaration aren't in the same file, then they
// aren't related.
if (DeclStartDecomp.first != LastCommentEndDecomp.first)
return 0;
-
+
// Check that we actually have a Doxygen comment.
if (!isDoxygenComment(SourceMgr, *LastComment))
return 0;
-
+
// Compute the starting line for the declaration and for the end of the
// comment (this is expensive).
- unsigned DeclStartLine
+ unsigned DeclStartLine
= SourceMgr.getLineNumber(DeclStartDecomp.first, DeclStartDecomp.second);
unsigned CommentEndLine
- = SourceMgr.getLineNumber(LastCommentEndDecomp.first,
+ = SourceMgr.getLineNumber(LastCommentEndDecomp.first,
LastCommentEndDecomp.second);
-
+
// If the comment does not end on the line prior to the declaration, then
// the comment is not associated with the declaration at all.
if (CommentEndLine + 1 != DeclStartLine)
return 0;
-
+
// We have a comment, but there may be more comments on the previous lines.
// Keep looking so long as the comments are still Doxygen comments and are
// still adjacent.
- unsigned ExpectedLine
+ unsigned ExpectedLine
= SourceMgr.getSpellingLineNumber(LastComment->getBegin()) - 1;
std::vector<SourceRange>::iterator FirstComment = LastComment;
while (FirstComment != Comments.begin()) {
@@ -433,31 +433,31 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
--FirstComment;
std::pair<FileID, unsigned> Decomp
= SourceMgr.getDecomposedLoc(FirstComment->getEnd());
-
+
// If this previous comment is in a different file, we're done.
if (Decomp.first != DeclStartDecomp.first) {
++FirstComment;
break;
}
-
+
// If this comment is not a Doxygen comment, we're done.
if (!isDoxygenComment(SourceMgr, *FirstComment)) {
++FirstComment;
break;
}
-
+
// If the line number is not what we expected, we're done.
unsigned Line = SourceMgr.getLineNumber(Decomp.first, Decomp.second);
if (Line != ExpectedLine) {
++FirstComment;
break;
}
-
+
// Set the next expected line number.
- ExpectedLine
+ ExpectedLine
= SourceMgr.getSpellingLineNumber(FirstComment->getBegin()) - 1;
}
-
+
// The iterator range [FirstComment, LastComment] contains all of the
// BCPL comments that, together, are associated with this declaration.
// Form a single comment block string for this declaration that concatenates
@@ -472,10 +472,10 @@ const char *ASTContext::getCommentForDecl(const Decl *D) {
FileBufferStart + DecompEnd.second + 1);
++FirstComment;
}
-
+
// Append the last comment line.
- Result.append(FileBufferStart +
- SourceMgr.getFileOffset(LastComment->getBegin()),
+ Result.append(FileBufferStart +
+ SourceMgr.getFileOffset(LastComment->getBegin()),
FileBufferStart + LastCommentEndDecomp.second + 1);
return Result.c_str();
}
@@ -555,7 +555,7 @@ ASTContext::getTypeInfo(const Type *T) {
case Type::ConstantArrayWithoutExpr:
case Type::ConstantArray: {
const ConstantArrayType *CAT = cast<ConstantArrayType>(T);
-
+
std::pair<uint64_t, unsigned> EltInfo = getTypeInfo(CAT->getElementType());
Width = EltInfo.first*CAT->getSize().getZExtValue();
Align = EltInfo.second;
@@ -563,7 +563,7 @@ ASTContext::getTypeInfo(const Type *T) {
}
case Type::ExtVector:
case Type::Vector: {
- std::pair<uint64_t, unsigned> EltInfo =
+ std::pair<uint64_t, unsigned> EltInfo =
getTypeInfo(cast<VectorType>(T)->getElementType());
Width = EltInfo.first*cast<VectorType>(T)->getNumElements();
Align = Width;
@@ -689,7 +689,7 @@ ASTContext::getTypeInfo(const Type *T) {
// If we ever want to support other ABIs this needs to be abstracted.
QualType Pointee = cast<MemberPointerType>(T)->getPointeeType();
- std::pair<uint64_t, unsigned> PtrDiffInfo =
+ std::pair<uint64_t, unsigned> PtrDiffInfo =
getTypeInfo(getPointerDiffType());
Width = PtrDiffInfo.first;
if (Pointee->isFunctionType())
@@ -700,7 +700,7 @@ ASTContext::getTypeInfo(const Type *T) {
case Type::Complex: {
// Complex types have the same alignment as their elements, but twice the
// size.
- std::pair<uint64_t, unsigned> EltInfo =
+ std::pair<uint64_t, unsigned> EltInfo =
getTypeInfo(cast<ComplexType>(T)->getElementType());
Width = EltInfo.first*2;
Align = EltInfo.second;
@@ -722,7 +722,7 @@ ASTContext::getTypeInfo(const Type *T) {
Align = 1;
break;
}
-
+
if (const EnumType *ET = dyn_cast<EnumType>(TT))
return getTypeInfo(ET->getDecl()->getIntegerType());
@@ -760,16 +760,16 @@ ASTContext::getTypeInfo(const Type *T) {
case Type::QualifiedName:
return getTypeInfo(cast<QualifiedNameType>(T)->getNamedType().getTypePtr());
-
+
case Type::TemplateSpecialization:
- assert(getCanonicalType(T) != T &&
+ assert(getCanonicalType(T) != T &&
"Cannot request the size of a dependent type");
// FIXME: this is likely to be wrong once we support template
// aliases, since a template alias could refer to a typedef that
// has an __aligned__ attribute on it.
return getTypeInfo(getCanonicalType(T));
}
-
+
assert(Align && (Align & (Align-1)) == 0 && "Alignment must be power of 2");
return std::make_pair(Width, Align);
}
@@ -829,7 +829,7 @@ void ASTContext::CollectProtocolSynthesizedIvars(const ObjCProtocolDecl *PD,
E = PD->prop_end(); I != E; ++I)
if (ObjCIvarDecl *Ivar = (*I)->getPropertyIvarDecl())
Ivars.push_back(Ivar);
-
+
// Also look into nested protocols.
for (ObjCProtocolDecl::protocol_iterator P = PD->protocol_begin(),
E = PD->protocol_end(); P != E; ++P)
@@ -869,8 +869,7 @@ unsigned ASTContext::CountProtocolSynthesizedIvars(const ObjCProtocolDecl *PD) {
return count;
}
-unsigned ASTContext::CountSynthesizedIvars(const ObjCInterfaceDecl *OI)
-{
+unsigned ASTContext::CountSynthesizedIvars(const ObjCInterfaceDecl *OI) {
unsigned count = 0;
for (ObjCInterfaceDecl::prop_iterator I = OI->prop_begin(),
E = OI->prop_end(); I != E; ++I) {
@@ -944,7 +943,7 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
assert(!D->isForwardDecl() && "Invalid interface decl!");
// Look up this layout, if already laid out, return what we have.
- ObjCContainerDecl *Key =
+ ObjCContainerDecl *Key =
Impl ? (ObjCContainerDecl*) Impl : (ObjCContainerDecl*) D;
if (const ASTRecordLayout *Entry = ObjCLayouts[Key])
return *Entry;
@@ -962,10 +961,10 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
return getObjCLayout(D, 0);
}
- const ASTRecordLayout *NewEntry =
+ const ASTRecordLayout *NewEntry =
ASTRecordLayoutBuilder::ComputeLayout(*this, D, Impl);
ObjCLayouts[Key] = NewEntry;
-
+
return *NewEntry;
}
@@ -992,10 +991,10 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
const ASTRecordLayout *Entry = ASTRecordLayouts[D];
if (Entry) return *Entry;
- const ASTRecordLayout *NewEntry =
+ const ASTRecordLayout *NewEntry =
ASTRecordLayoutBuilder::ComputeLayout(*this, D);
ASTRecordLayouts[D] = NewEntry;
-
+
return *NewEntry;
}
@@ -1013,7 +1012,7 @@ QualType ASTContext::getAddrSpaceQualType(QualType T, unsigned AddressSpace) {
unsigned CVRQuals = T.getCVRQualifiers();
QualType::GCAttrTypes GCAttr = QualType::GCNone;
Type *TypeNode = T.getTypePtr();
-
+
if (ExtQualType *EQT = dyn_cast<ExtQualType>(TypeNode)) {
// If this type already has an address space specified, it cannot get
// another one.
@@ -1022,7 +1021,7 @@ QualType ASTContext::getAddrSpaceQualType(QualType T, unsigned AddressSpace) {
GCAttr = EQT->getObjCGCAttr();
TypeNode = EQT->getBaseType();
}
-
+
// Check if we've already instantiated this type.
llvm::FoldingSetNodeID ID;
ExtQualType::Profile(ID, TypeNode, AddressSpace, GCAttr);
@@ -1035,7 +1034,7 @@ QualType ASTContext::getAddrSpaceQualType(QualType T, unsigned AddressSpace) {
QualType Canonical;
if (!TypeNode->isCanonical()) {
Canonical = getAddrSpaceQualType(CanT, AddressSpace);
-
+
// Update InsertPos, the previous call could have invalidated it.
ExtQualType *NewIP = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1052,7 +1051,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
QualType CanT = getCanonicalType(T);
if (CanT.getObjCGCAttr() == GCAttr)
return T;
-
+
if (T->isPointerType()) {
QualType Pointee = T->getAs<PointerType>()->getPointeeType();
if (Pointee->isAnyPointerType()) {
@@ -1065,7 +1064,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
unsigned CVRQuals = T.getCVRQualifiers();
Type *TypeNode = T.getTypePtr();
unsigned AddressSpace = 0;
-
+
if (ExtQualType *EQT = dyn_cast<ExtQualType>(TypeNode)) {
// If this type already has an ObjCGC specified, it cannot get
// another one.
@@ -1074,14 +1073,14 @@ QualType ASTContext::getObjCGCQualType(QualType T,
AddressSpace = EQT->getAddressSpace();
TypeNode = EQT->getBaseType();
}
-
+
// Check if we've already instantiated an gc qual'd type of this type.
llvm::FoldingSetNodeID ID;
ExtQualType::Profile(ID, TypeNode, AddressSpace, GCAttr);
void *InsertPos = 0;
if (ExtQualType *EXTQy = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(EXTQy, CVRQuals);
-
+
// If the base type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
// FIXME: Isn't this also not canonical if the base type is a array
@@ -1089,7 +1088,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getObjCGCQualType(CanT, GCAttr);
-
+
// Update InsertPos, the previous call could have invalidated it.
ExtQualType *NewIP = ExtQualTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1117,10 +1116,10 @@ QualType ASTContext::getNoReturnType(QualType T) {
ResultType = getBlockPointerType(ResultType);
ResultType.setCVRQualifiers(T.getCVRQualifiers());
return qs.apply(ResultType, *this);
- }
+ }
if (!T->isFunctionType())
assert(0 && "can't noreturn qualify non-pointer to function or block type");
-
+
if (const FunctionNoProtoType *F = T->getAsFunctionNoProtoType()) {
return getFunctionNoProtoType(F->getResultType(), true);
}
@@ -1138,17 +1137,17 @@ QualType ASTContext::getComplexType(QualType T) {
// structure.
llvm::FoldingSetNodeID ID;
ComplexType::Profile(ID, T);
-
+
void *InsertPos = 0;
if (ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(CT, 0);
-
+
// If the pointee type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getComplexType(getCanonicalType(T));
-
+
// Get the new insert position for the node we care about.
ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1175,17 +1174,17 @@ QualType ASTContext::getPointerType(QualType T) {
// structure.
llvm::FoldingSetNodeID ID;
PointerType::Profile(ID, T);
-
+
void *InsertPos = 0;
if (PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(PT, 0);
-
+
// If the pointee type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getPointerType(getCanonicalType(T));
-
+
// Get the new insert position for the node we care about.
PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1196,7 +1195,7 @@ QualType ASTContext::getPointerType(QualType T) {
return QualType(New, 0);
}
-/// getBlockPointerType - Return the uniqued reference to the type for
+/// getBlockPointerType - Return the uniqued reference to the type for
/// a pointer to the specified block.
QualType ASTContext::getBlockPointerType(QualType T) {
assert(T->isFunctionType() && "block of function types only");
@@ -1204,18 +1203,18 @@ QualType ASTContext::getBlockPointerType(QualType T) {
// structure.
llvm::FoldingSetNodeID ID;
BlockPointerType::Profile(ID, T);
-
+
void *InsertPos = 0;
if (BlockPointerType *PT =
BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(PT, 0);
-
- // If the block pointee type isn't canonical, this won't be a canonical
+
+ // If the block pointee type isn't canonical, this won't be a canonical
// type either so fill in the canonical type field.
QualType Canonical;
if (!T->isCanonical()) {
Canonical = getBlockPointerType(getCanonicalType(T));
-
+
// Get the new insert position for the node we care about.
BlockPointerType *NewIP =
BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -1291,8 +1290,7 @@ QualType ASTContext::getRValueReferenceType(QualType T) {
/// getMemberPointerType - Return the uniqued reference to the type for a
/// member pointer to the specified type, in the specified class.
-QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls)
-{
+QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls) {
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
llvm::FoldingSetNodeID ID;
@@ -1320,9 +1318,9 @@ QualType ASTContext::getMemberPointerType(QualType T, const Type *Cls)
return QualType(New, 0);
}
-/// getConstantArrayType - Return the unique reference to the type for an
+/// getConstantArrayType - Return the unique reference to the type for an
/// array of the specified element type.
-QualType ASTContext::getConstantArrayType(QualType EltTy,
+QualType ASTContext::getConstantArrayType(QualType EltTy,
const llvm::APInt &ArySizeIn,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
@@ -1333,27 +1331,27 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
// the target.
llvm::APInt ArySize(ArySizeIn);
ArySize.zextOrTrunc(Target.getPointerWidth(EltTy.getAddressSpace()));
-
+
llvm::FoldingSetNodeID ID;
ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, EltTypeQuals);
-
+
void *InsertPos = 0;
- if (ConstantArrayType *ATP =
+ if (ConstantArrayType *ATP =
ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(ATP, 0);
-
+
// If the element type isn't canonical, this won't be a canonical type either,
// so fill in the canonical type field.
QualType Canonical;
if (!EltTy->isCanonical()) {
- Canonical = getConstantArrayType(getCanonicalType(EltTy), ArySize,
+ Canonical = getConstantArrayType(getCanonicalType(EltTy), ArySize,
ASM, EltTypeQuals);
// Get the new insert position for the node we care about.
- ConstantArrayType *NewIP =
+ ConstantArrayType *NewIP =
ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
}
-
+
ConstantArrayType *New =
new(*this,8)ConstantArrayType(EltTy, Canonical, ArySize, ASM, EltTypeQuals);
ConstantArrayTypes.InsertNode(New, InsertPos);
@@ -1437,11 +1435,11 @@ QualType ASTContext::getDependentSizedArrayType(QualType EltTy,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals,
SourceRange Brackets) {
- assert((NumElts->isTypeDependent() || NumElts->isValueDependent()) &&
+ assert((NumElts->isTypeDependent() || NumElts->isValueDependent()) &&
"Size must be type- or value-dependent!");
llvm::FoldingSetNodeID ID;
- DependentSizedArrayType::Profile(ID, *this, getCanonicalType(EltTy), ASM,
+ DependentSizedArrayType::Profile(ID, *this, getCanonicalType(EltTy), ASM,
EltTypeQuals, NumElts);
void *InsertPos = 0;
@@ -1451,7 +1449,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType EltTy,
if (Canon) {
// We already have a canonical version of this array type; use it as
// the canonical type for a newly-built type.
- New = new (*this,8) DependentSizedArrayType(*this, EltTy,
+ New = new (*this,8) DependentSizedArrayType(*this, EltTy,
QualType(Canon, 0),
NumElts, ASM, EltTypeQuals,
Brackets);
@@ -1468,10 +1466,10 @@ QualType ASTContext::getDependentSizedArrayType(QualType EltTy,
SourceRange());
New = new (*this,8) DependentSizedArrayType(*this, EltTy, Canon,
NumElts, ASM, EltTypeQuals,
- Brackets);
+ Brackets);
}
}
-
+
Types.push_back(New);
return QualType(New, 0);
}
@@ -1483,7 +1481,7 @@ QualType ASTContext::getIncompleteArrayType(QualType EltTy,
IncompleteArrayType::Profile(ID, EltTy, ASM, EltTypeQuals);
void *InsertPos = 0;
- if (IncompleteArrayType *ATP =
+ if (IncompleteArrayType *ATP =
IncompleteArrayTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(ATP, 0);
@@ -1514,13 +1512,13 @@ QualType ASTContext::getIncompleteArrayType(QualType EltTy,
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts) {
BuiltinType *baseType;
-
+
baseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
assert(baseType != 0 && "getVectorType(): Expecting a built-in type");
-
+
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
- VectorType::Profile(ID, vecType, NumElts, Type::Vector);
+ VectorType::Profile(ID, vecType, NumElts, Type::Vector);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
@@ -1530,7 +1528,7 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts) {
QualType Canonical;
if (!vecType->isCanonical()) {
Canonical = getVectorType(getCanonicalType(vecType), NumElts);
-
+
// Get the new insert position for the node we care about.
VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1545,13 +1543,13 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts) {
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
BuiltinType *baseType;
-
+
baseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
assert(baseType != 0 && "getExtVectorType(): Expecting a built-in type");
-
+
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
- VectorType::Profile(ID, vecType, NumElts, Type::ExtVector);
+ VectorType::Profile(ID, vecType, NumElts, Type::ExtVector);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
@@ -1561,7 +1559,7 @@ QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
QualType Canonical;
if (!vecType->isCanonical()) {
Canonical = getExtVectorType(getCanonicalType(vecType), NumElts);
-
+
// Get the new insert position for the node we care about.
VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
@@ -1572,13 +1570,13 @@ QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
return QualType(New, 0);
}
-QualType ASTContext::getDependentSizedExtVectorType(QualType vecType,
+QualType ASTContext::getDependentSizedExtVectorType(QualType vecType,
Expr *SizeExpr,
SourceLocation AttrLoc) {
llvm::FoldingSetNodeID ID;
- DependentSizedExtVectorType::Profile(ID, *this, getCanonicalType(vecType),
+ DependentSizedExtVectorType::Profile(ID, *this, getCanonicalType(vecType),
SizeExpr);
-
+
void *InsertPos = 0;
DependentSizedExtVectorType *Canon
= DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -1592,8 +1590,8 @@ QualType ASTContext::getDependentSizedExtVectorType(QualType vecType,
} else {
QualType CanonVecTy = getCanonicalType(vecType);
if (CanonVecTy == vecType) {
- New = new (*this,8) DependentSizedExtVectorType(*this, vecType,
- QualType(), SizeExpr,
+ New = new (*this,8) DependentSizedExtVectorType(*this, vecType,
+ QualType(), SizeExpr,
AttrLoc);
DependentSizedExtVectorTypes.InsertNode(New, InsertPos);
} else {
@@ -1603,7 +1601,7 @@ QualType ASTContext::getDependentSizedExtVectorType(QualType vecType,
SizeExpr, AttrLoc);
}
}
-
+
Types.push_back(New);
return QualType(New, 0);
}
@@ -1615,22 +1613,22 @@ QualType ASTContext::getFunctionNoProtoType(QualType ResultTy, bool NoReturn) {
// structure.
llvm::FoldingSetNodeID ID;
FunctionNoProtoType::Profile(ID, ResultTy, NoReturn);
-
+
void *InsertPos = 0;
- if (FunctionNoProtoType *FT =
+ if (FunctionNoProtoType *FT =
FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FT, 0);
-
+
QualType Canonical;
if (!ResultTy->isCanonical()) {
Canonical = getFunctionNoProtoType(getCanonicalType(ResultTy), NoReturn);
-
+
// Get the new insert position for the node we care about.
FunctionNoProtoType *NewIP =
FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
}
-
+
FunctionNoProtoType *New
= new (*this,8) FunctionNoProtoType(ResultTy, Canonical, NoReturn);
Types.push_back(New);
@@ -1653,7 +1651,7 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
NumExs, ExArray, NoReturn);
void *InsertPos = 0;
- if (FunctionProtoType *FTP =
+ if (FunctionProtoType *FTP =
FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FTP, 0);
@@ -1688,7 +1686,7 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
// FunctionProtoType objects are allocated with extra bytes after them
// for two variable size arrays (for parameter and exception types) at the
// end of them.
- FunctionProtoType *FTP =
+ FunctionProtoType *FTP =
(FunctionProtoType*)Allocate(sizeof(FunctionProtoType) +
NumArgs*sizeof(QualType) +
NumExs*sizeof(QualType), 8);
@@ -1705,7 +1703,7 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
QualType ASTContext::getTypeDeclType(TypeDecl *Decl, TypeDecl* PrevDecl) {
assert(Decl && "Passed null for Decl param");
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
-
+
if (TypedefDecl *Typedef = dyn_cast<TypedefDecl>(Decl))
return getTypedefType(Typedef);
else if (isa<TemplateTypeParmDecl>(Decl)) {
@@ -1735,7 +1733,7 @@ QualType ASTContext::getTypeDeclType(TypeDecl *Decl, TypeDecl* PrevDecl) {
/// specified typename decl.
QualType ASTContext::getTypedefType(TypedefDecl *Decl) {
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
-
+
QualType Canonical = getCanonicalType(Decl->getUnderlyingType());
Decl->TypeForDecl = new(*this,8) TypedefType(Type::Typedef, Decl, Canonical);
Types.push_back(Decl->TypeForDecl);
@@ -1743,20 +1741,20 @@ QualType ASTContext::getTypedefType(TypedefDecl *Decl) {
}
/// \brief Retrieve the template type parameter type for a template
-/// parameter or parameter pack with the given depth, index, and (optionally)
+/// parameter or parameter pack with the given depth, index, and (optionally)
/// name.
-QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
+QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
bool ParameterPack,
IdentifierInfo *Name) {
llvm::FoldingSetNodeID ID;
TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, Name);
void *InsertPos = 0;
- TemplateTypeParmType *TypeParm
+ TemplateTypeParmType *TypeParm
= TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
if (TypeParm)
return QualType(TypeParm, 0);
-
+
if (Name) {
QualType Canon = getTemplateTypeParmType(Depth, Index, ParameterPack);
TypeParm = new (*this, 8) TemplateTypeParmType(Depth, Index, ParameterPack,
@@ -1770,7 +1768,7 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
return QualType(TypeParm, 0);
}
-QualType
+QualType
ASTContext::getTemplateSpecializationType(TemplateName Template,
const TemplateArgument *Args,
unsigned NumArgs,
@@ -1788,65 +1786,65 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
// Determine whether this canonical template specialization type already
// exists.
llvm::FoldingSetNodeID ID;
- TemplateSpecializationType::Profile(ID, CanonTemplate,
+ TemplateSpecializationType::Profile(ID, CanonTemplate,
CanonArgs.data(), NumArgs, *this);
void *InsertPos = 0;
TemplateSpecializationType *Spec
= TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
-
+
if (!Spec) {
// Allocate a new canonical template specialization type.
- void *Mem = Allocate((sizeof(TemplateSpecializationType) +
+ void *Mem = Allocate((sizeof(TemplateSpecializationType) +
sizeof(TemplateArgument) * NumArgs),
8);
- Spec = new (Mem) TemplateSpecializationType(*this, CanonTemplate,
+ Spec = new (Mem) TemplateSpecializationType(*this, CanonTemplate,
CanonArgs.data(), NumArgs,
Canon);
Types.push_back(Spec);
- TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
+ TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
}
-
+
if (Canon.isNull())
Canon = QualType(Spec, 0);
- assert(Canon->isDependentType() &&
+ assert(Canon->isDependentType() &&
"Non-dependent template-id type must have a canonical type");
}
// Allocate the (non-canonical) template specialization type, but don't
// try to unique it: these types typically have location information that
// we don't unique and don't want to lose.
- void *Mem = Allocate((sizeof(TemplateSpecializationType) +
+ void *Mem = Allocate((sizeof(TemplateSpecializationType) +
sizeof(TemplateArgument) * NumArgs),
8);
- TemplateSpecializationType *Spec
- = new (Mem) TemplateSpecializationType(*this, Template, Args, NumArgs,
+ TemplateSpecializationType *Spec
+ = new (Mem) TemplateSpecializationType(*this, Template, Args, NumArgs,
Canon);
-
+
Types.push_back(Spec);
- return QualType(Spec, 0);
+ return QualType(Spec, 0);
}
-QualType
+QualType
ASTContext::getQualifiedNameType(NestedNameSpecifier *NNS,
QualType NamedType) {
llvm::FoldingSetNodeID ID;
QualifiedNameType::Profile(ID, NNS, NamedType);
void *InsertPos = 0;
- QualifiedNameType *T
+ QualifiedNameType *T
= QualifiedNameTypes.FindNodeOrInsertPos(ID, InsertPos);
if (T)
return QualType(T, 0);
- T = new (*this) QualifiedNameType(NNS, NamedType,
+ T = new (*this) QualifiedNameType(NNS, NamedType,
getCanonicalType(NamedType));
Types.push_back(T);
QualifiedNameTypes.InsertNode(T, InsertPos);
return QualType(T, 0);
}
-QualType ASTContext::getTypenameType(NestedNameSpecifier *NNS,
+QualType ASTContext::getTypenameType(NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
QualType Canon) {
assert(NNS->isDependent() && "nested-name-specifier must be dependent");
@@ -1861,7 +1859,7 @@ QualType ASTContext::getTypenameType(NestedNameSpecifier *NNS,
TypenameType::Profile(ID, NNS, Name);
void *InsertPos = 0;
- TypenameType *T
+ TypenameType *T
= TypenameTypes.FindNodeOrInsertPos(ID, InsertPos);
if (T)
return QualType(T, 0);
@@ -1869,11 +1867,11 @@ QualType ASTContext::getTypenameType(NestedNameSpecifier *NNS,
T = new (*this) TypenameType(NNS, Name, Canon);
Types.push_back(T);
TypenameTypes.InsertNode(T, InsertPos);
- return QualType(T, 0);
+ return QualType(T, 0);
}
-QualType
-ASTContext::getTypenameType(NestedNameSpecifier *NNS,
+QualType
+ASTContext::getTypenameType(NestedNameSpecifier *NNS,
const TemplateSpecializationType *TemplateId,
QualType Canon) {
assert(NNS->isDependent() && "nested-name-specifier must be dependent");
@@ -1894,7 +1892,7 @@ ASTContext::getTypenameType(NestedNameSpecifier *NNS,
TypenameType::Profile(ID, NNS, TemplateId);
void *InsertPos = 0;
- TypenameType *T
+ TypenameType *T
= TypenameTypes.FindNodeOrInsertPos(ID, InsertPos);
if (T)
return QualType(T, 0);
@@ -1902,7 +1900,7 @@ ASTContext::getTypenameType(NestedNameSpecifier *NNS,
T = new (*this) TypenameType(NNS, TemplateId, Canon);
Types.push_back(T);
TypenameTypes.InsertNode(T, InsertPos);
- return QualType(T, 0);
+ return QualType(T, 0);
}
QualType
@@ -1910,7 +1908,7 @@ ASTContext::getElaboratedType(QualType UnderlyingType,
ElaboratedType::TagKind Tag) {
llvm::FoldingSetNodeID ID;
ElaboratedType::Profile(ID, UnderlyingType, Tag);
-
+
void *InsertPos = 0;
ElaboratedType *T = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos);
if (T)
@@ -1934,7 +1932,7 @@ static bool CmpProtocolNames(const ObjCProtocolDecl *LHS,
static void SortAndUniqueProtocols(ObjCProtocolDecl **&Protocols,
unsigned &NumProtocols) {
ObjCProtocolDecl **ProtocolsEnd = Protocols+NumProtocols;
-
+
// Sort protocols, keyed by name.
std::sort(Protocols, Protocols+NumProtocols, CmpProtocolNames);
@@ -1946,7 +1944,7 @@ static void SortAndUniqueProtocols(ObjCProtocolDecl **&Protocols,
/// getObjCObjectPointerType - Return a ObjCObjectPointerType type for
/// the given interface decl and the conforming protocol list.
QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
- ObjCProtocolDecl **Protocols,
+ ObjCProtocolDecl **Protocols,
unsigned NumProtocols) {
// Sort the protocol list alphabetically to canonicalize it.
if (NumProtocols)
@@ -1963,7 +1961,7 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
// No Match;
ObjCObjectPointerType *QType =
new (*this,8) ObjCObjectPointerType(InterfaceT, Protocols, NumProtocols);
-
+
Types.push_back(QType);
ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
return QualType(QType, 0);
@@ -1973,21 +1971,21 @@ QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
/// specified ObjC interface decl. The list of protocols is optional.
QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
ObjCProtocolDecl **Protocols, unsigned NumProtocols) {
- if (NumProtocols)
+ if (NumProtocols)
// Sort the protocol list alphabetically to canonicalize it.
SortAndUniqueProtocols(Protocols, NumProtocols);
-
+
llvm::FoldingSetNodeID ID;
ObjCInterfaceType::Profile(ID, Decl, Protocols, NumProtocols);
-
+
void *InsertPos = 0;
if (ObjCInterfaceType *QT =
ObjCInterfaceTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(QT, 0);
-
+
// No Match;
ObjCInterfaceType *QType =
- new (*this,8) ObjCInterfaceType(const_cast<ObjCInterfaceDecl*>(Decl),
+ new (*this,8) ObjCInterfaceType(const_cast<ObjCInterfaceDecl*>(Decl),
Protocols, NumProtocols);
Types.push_back(QType);
ObjCInterfaceTypes.InsertNode(QType, InsertPos);
@@ -1997,21 +1995,21 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
/// getTypeOfExprType - Unlike many "get<Type>" functions, we can't unique
/// TypeOfExprType AST's (since expression's are never shared). For example,
/// multiple declarations that refer to "typeof(x)" all contain different
-/// DeclRefExpr's. This doesn't effect the type checker, since it operates
+/// DeclRefExpr's. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfExprType(Expr *tofExpr) {
TypeOfExprType *toe;
if (tofExpr->isTypeDependent()) {
llvm::FoldingSetNodeID ID;
DependentTypeOfExprType::Profile(ID, *this, tofExpr);
-
+
void *InsertPos = 0;
DependentTypeOfExprType *Canon
= DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
if (Canon) {
// We already have a "canonical" version of an identical, dependent
// typeof(expr) type. Use that as our canonical type.
- toe = new (*this, 8) TypeOfExprType(tofExpr,
+ toe = new (*this, 8) TypeOfExprType(tofExpr,
QualType((TypeOfExprType*)Canon, 0));
}
else {
@@ -2031,7 +2029,7 @@ QualType ASTContext::getTypeOfExprType(Expr *tofExpr) {
/// getTypeOfType - Unlike many "get<Type>" functions, we don't unique
/// TypeOfType AST's. The only motivation to unique these nodes would be
/// memory savings. Since typeof(t) is fairly uncommon, space shouldn't be
-/// an issue. This doesn't effect the type checker, since it operates
+/// an issue. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getTypeOfType(QualType tofType) {
QualType Canonical = getCanonicalType(tofType);
@@ -2045,7 +2043,7 @@ QualType ASTContext::getTypeOfType(QualType tofType) {
static QualType getDecltypeForExpr(const Expr *e, ASTContext &Context) {
if (e->isTypeDependent())
return Context.DependentTy;
-
+
// If e is an id expression or a class member access, decltype(e) is defined
// as the type of the entity named by e.
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(e)) {
@@ -2061,28 +2059,28 @@ static QualType getDecltypeForExpr(const Expr *e, ASTContext &Context) {
// return type of that function.
if (const CallExpr *CE = dyn_cast<CallExpr>(e->IgnoreParens()))
return CE->getCallReturnType();
-
+
QualType T = e->getType();
-
- // Otherwise, where T is the type of e, if e is an lvalue, decltype(e) is
+
+ // Otherwise, where T is the type of e, if e is an lvalue, decltype(e) is
// defined as T&, otherwise decltype(e) is defined as T.
if (e->isLvalue(Context) == Expr::LV_Valid)
T = Context.getLValueReferenceType(T);
-
+
return T;
}
/// getDecltypeType - Unlike many "get<Type>" functions, we don't unique
/// DecltypeType AST's. The only motivation to unique these nodes would be
/// memory savings. Since decltype(t) is fairly uncommon, space shouldn't be
-/// an issue. This doesn't effect the type checker, since it operates
+/// an issue. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
QualType ASTContext::getDecltypeType(Expr *e) {
DecltypeType *dt;
if (e->isTypeDependent()) {
llvm::FoldingSetNodeID ID;
DependentDecltypeType::Profile(ID, *this, e);
-
+
void *InsertPos = 0;
DependentDecltypeType *Canon
= DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos);
@@ -2100,7 +2098,7 @@ QualType ASTContext::getDecltypeType(Expr *e) {
}
} else {
QualType T = getDecltypeForExpr(e, *this);
- dt = new (*this, 8) DecltypeType(e, T, getCanonicalType(T));
+ dt = new (*this, 8) DecltypeType(e, T, getCanonicalType(T));
}
Types.push_back(dt);
return QualType(dt, 0);
@@ -2115,9 +2113,9 @@ QualType ASTContext::getTagDeclType(const TagDecl *Decl) {
return getTypeDeclType(const_cast<TagDecl*>(Decl));
}
-/// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
-/// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and
-/// needs to agree with the definition in <stddef.h>.
+/// getSizeType - Return the unique type for "size_t" (C99 7.17), the result
+/// of the sizeof operator (C99 6.5.3.4p4). The value is target dependent and
+/// needs to agree with the definition in <stddef.h>.
QualType ASTContext::getSizeType() const {
return getFromTargetType(Target.getSizeType());
}
@@ -2154,10 +2152,10 @@ QualType ASTContext::getPointerDiffType() const {
/// for exact equality with a simple pointer comparison.
CanQualType ASTContext::getCanonicalType(QualType T) {
QualType CanType = T.getTypePtr()->getCanonicalTypeInternal();
-
+
// If the result has type qualifiers, make sure to canonicalize them as well.
unsigned TypeQuals = T.getCVRQualifiers() | CanType.getCVRQualifiers();
- if (TypeQuals == 0)
+ if (TypeQuals == 0)
return CanQualType::CreateUnsafe(CanType);
// If the type qualifiers are on an array type, get the canonical type of the
@@ -2165,12 +2163,12 @@ CanQualType ASTContext::getCanonicalType(QualType T) {
ArrayType *AT = dyn_cast<ArrayType>(CanType);
if (!AT)
return CanQualType::CreateUnsafe(CanType.getQualifiedType(TypeQuals));
-
+
// Get the canonical version of the element with the extra qualifiers on it.
// This can recursively sink qualifiers through multiple levels of arrays.
QualType NewEltTy=AT->getElementType().getWithAdditionalQualifiers(TypeQuals);
NewEltTy = getCanonicalType(NewEltTy);
-
+
if (ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
return CanQualType::CreateUnsafe(
getConstantArrayType(NewEltTy, CAT->getSize(),
@@ -2180,7 +2178,7 @@ CanQualType ASTContext::getCanonicalType(QualType T) {
return CanQualType::CreateUnsafe(
getIncompleteArrayType(NewEltTy, IAT->getSizeModifier(),
IAT->getIndexTypeQualifier()));
-
+
if (DependentSizedArrayType *DSAT = dyn_cast<DependentSizedArrayType>(AT))
return CanQualType::CreateUnsafe(
getDependentSizedArrayType(NewEltTy,
@@ -2205,7 +2203,7 @@ TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) {
if (TemplateDecl *Template = Name.getAsTemplateDecl())
return TemplateName(cast<TemplateDecl>(Template->getCanonicalDecl()));
- // If this template name refers to a set of overloaded function templates,
+ // If this template name refers to a set of overloaded function templates,
/// the canonical template name merely stores the set of function templates.
if (OverloadedFunctionDecl *Ovl = Name.getAsOverloadedFunctionDecl()) {
OverloadedFunctionDecl *CanonOvl = 0;
@@ -2215,55 +2213,55 @@ TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) {
Decl *Canon = F->get()->getCanonicalDecl();
if (CanonOvl || Canon != F->get()) {
if (!CanonOvl)
- CanonOvl = OverloadedFunctionDecl::Create(*this,
- Ovl->getDeclContext(),
+ CanonOvl = OverloadedFunctionDecl::Create(*this,
+ Ovl->getDeclContext(),
Ovl->getDeclName());
-
+
CanonOvl->addOverload(
AnyFunctionDecl::getFromNamedDecl(cast<NamedDecl>(Canon)));
}
}
-
+
return TemplateName(CanonOvl? CanonOvl : Ovl);
}
-
+
DependentTemplateName *DTN = Name.getAsDependentTemplateName();
assert(DTN && "Non-dependent template names must refer to template decls.");
return DTN->CanonicalTemplateName;
}
-TemplateArgument
+TemplateArgument
ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
return Arg;
-
+
case TemplateArgument::Expression:
// FIXME: Build canonical expression?
return Arg;
-
+
case TemplateArgument::Declaration:
return TemplateArgument(SourceLocation(),
Arg.getAsDecl()->getCanonicalDecl());
-
+
case TemplateArgument::Integral:
return TemplateArgument(SourceLocation(),
*Arg.getAsIntegral(),
getCanonicalType(Arg.getIntegralType()));
-
+
case TemplateArgument::Type:
return TemplateArgument(SourceLocation(),
getCanonicalType(Arg.getAsType()));
-
+
case TemplateArgument::Pack: {
// FIXME: Allocate in ASTContext
TemplateArgument *CanonArgs = new TemplateArgument[Arg.pack_size()];
unsigned Idx = 0;
- for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
+ for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
AEnd = Arg.pack_end();
A != AEnd; (void)++A, ++Idx)
CanonArgs[Idx] = getCanonicalTemplateArgument(*A);
-
+
TemplateArgument Result;
Result.setArgumentPack(CanonArgs, Arg.pack_size(), false);
return Result;
@@ -2277,13 +2275,13 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) {
NestedNameSpecifier *
ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) {
- if (!NNS)
+ if (!NNS)
return 0;
switch (NNS->getKind()) {
case NestedNameSpecifier::Identifier:
// Canonicalize the prefix but keep the identifier the same.
- return NestedNameSpecifier::Create(*this,
+ return NestedNameSpecifier::Create(*this,
getCanonicalNestedNameSpecifier(NNS->getPrefix()),
NNS->getAsIdentifier());
@@ -2295,8 +2293,8 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) {
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
QualType T = getCanonicalType(QualType(NNS->getAsType(), 0));
- return NestedNameSpecifier::Create(*this, 0,
- NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
+ return NestedNameSpecifier::Create(*this, 0,
+ NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
T.getTypePtr());
}
@@ -2317,27 +2315,27 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
if (const ArrayType *AT = dyn_cast<ArrayType>(T))
return AT;
}
-
+
// Handle the common negative case fast, ignoring CVR qualifiers.
QualType CType = T->getCanonicalTypeInternal();
-
+
// Make sure to look through type qualifiers (like ExtQuals) for the negative
// test.
if (!isa<ArrayType>(CType) &&
!isa<ArrayType>(CType.getUnqualifiedType()))
return 0;
-
+
// Apply any CVR qualifiers from the array type to the element type. This
// implements C99 6.7.3p8: "If the specification of an array type includes
// any type qualifiers, the element type is so qualified, not the array type."
-
+
// If we get here, we either have type qualifiers on the type, or we have
// sugar such as a typedef in the way. If we have type qualifiers on the type
// we must propagate them down into the element type.
unsigned CVRQuals = T.getCVRQualifiers();
unsigned AddrSpace = 0;
Type *Ty = T.getTypePtr();
-
+
// Rip through ExtQualType's and typedefs to get to a concrete type.
while (1) {
if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(Ty)) {
@@ -2351,12 +2349,12 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
Ty = T.getTypePtr();
}
}
-
+
// If we have a simple case, just return now.
const ArrayType *ATy = dyn_cast<ArrayType>(Ty);
if (ATy == 0 || (AddrSpace == 0 && CVRQuals == 0))
return ATy;
-
+
// Otherwise, we have an array and we have qualifiers on it. Push the
// qualifiers into the array element type and return a new array type.
// Get the canonical version of the element with the extra qualifiers on it.
@@ -2365,7 +2363,7 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
if (AddrSpace)
NewEltTy = getAddrSpaceQualType(NewEltTy, AddrSpace);
NewEltTy = NewEltTy.getWithAdditionalQualifiers(CVRQuals);
-
+
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(ATy))
return cast<ArrayType>(getConstantArrayType(NewEltTy, CAT->getSize(),
CAT->getSizeModifier(),
@@ -2375,16 +2373,16 @@ const ArrayType *ASTContext::getAsArrayType(QualType T) {
IAT->getSizeModifier(),
IAT->getIndexTypeQualifier()));
- if (const DependentSizedArrayType *DSAT
+ if (const DependentSizedArrayType *DSAT
= dyn_cast<DependentSizedArrayType>(ATy))
return cast<ArrayType>(
- getDependentSizedArrayType(NewEltTy,
+ getDependentSizedArrayType(NewEltTy,
DSAT->getSizeExpr() ?
DSAT->getSizeExpr()->Retain() : 0,
DSAT->getSizeModifier(),
DSAT->getIndexTypeQualifier(),
DSAT->getBracketsRange()));
-
+
const VariableArrayType *VAT = cast<VariableArrayType>(ATy);
return cast<ArrayType>(getVariableArrayType(NewEltTy,
VAT->getSizeExpr() ?
@@ -2408,7 +2406,7 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) {
// (C99 6.7.3p8).
const ArrayType *PrettyArrayType = getAsArrayType(Ty);
assert(PrettyArrayType && "Not an array type!");
-
+
QualType PtrTy = getPointerType(PrettyArrayType->getElementType());
// int x[restrict 4] -> int *restrict
@@ -2429,15 +2427,15 @@ QualType ASTContext::getBaseElementType(QualType QT) {
QualType ASTContext::getBaseElementType(const VariableArrayType *VAT) {
QualType ElemTy = VAT->getElementType();
-
+
if (const VariableArrayType *VAT = getAsVariableArrayType(ElemTy))
return getBaseElementType(VAT);
-
+
return ElemTy;
}
/// getConstantArrayElementCount - Returns number of constant array elements.
-uint64_t
+uint64_t
ASTContext::getConstantArrayElementCount(const ConstantArrayType *CA) const {
uint64_t ElementCount = 1;
do {
@@ -2462,8 +2460,8 @@ static FloatingRank getFloatingRank(QualType T) {
}
}
-/// getFloatingTypeOfSizeWithinDomain - Returns a real floating
-/// point or a complex type (based on typeDomain/typeSize).
+/// getFloatingTypeOfSizeWithinDomain - Returns a real floating
+/// point or a complex type (based on typeDomain/typeSize).
/// 'typeDomain' is a real floating point or complex type.
/// 'typeSize' is a real floating point or complex type.
QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size,
@@ -2490,11 +2488,11 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size,
/// getFloatingTypeOrder - Compare the rank of the two specified floating
/// point types, ignoring the domain of the type (i.e. 'double' ==
/// '_Complex double'). If LHS > RHS, return 1. If LHS == RHS, return 0. If
-/// LHS < RHS, return -1.
+/// LHS < RHS, return -1.
int ASTContext::getFloatingTypeOrder(QualType LHS, QualType RHS) {
FloatingRank LHSR = getFloatingRank(LHS);
FloatingRank RHSR = getFloatingRank(RHS);
-
+
if (LHSR == RHSR)
return 0;
if (LHSR > RHSR)
@@ -2597,77 +2595,77 @@ QualType ASTContext::getPromotedIntegerType(QualType Promotable) {
return (PromotableSize != IntSize) ? IntTy : UnsignedIntTy;
}
-/// getIntegerTypeOrder - Returns the highest ranked integer type:
+/// getIntegerTypeOrder - Returns the highest ranked integer type:
/// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If
-/// LHS < RHS, return -1.
+/// LHS < RHS, return -1.
int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) {
Type *LHSC = getCanonicalType(LHS).getTypePtr();
Type *RHSC = getCanonicalType(RHS).getTypePtr();
if (LHSC == RHSC) return 0;
-
+
bool LHSUnsigned = LHSC->isUnsignedIntegerType();
bool RHSUnsigned = RHSC->isUnsignedIntegerType();
-
+
unsigned LHSRank = getIntegerRank(LHSC);
unsigned RHSRank = getIntegerRank(RHSC);
-
+
if (LHSUnsigned == RHSUnsigned) { // Both signed or both unsigned.
if (LHSRank == RHSRank) return 0;
return LHSRank > RHSRank ? 1 : -1;
}
-
+
// Otherwise, the LHS is signed and the RHS is unsigned or visa versa.
if (LHSUnsigned) {
// If the unsigned [LHS] type is larger, return it.
if (LHSRank >= RHSRank)
return 1;
-
+
// If the signed type can represent all values of the unsigned type, it
// wins. Because we are dealing with 2's complement and types that are
- // powers of two larger than each other, this is always safe.
+ // powers of two larger than each other, this is always safe.
return -1;
}
// If the unsigned [RHS] type is larger, return it.
if (RHSRank >= LHSRank)
return -1;
-
+
// If the signed type can represent all values of the unsigned type, it
// wins. Because we are dealing with 2's complement and types that are
- // powers of two larger than each other, this is always safe.
+ // powers of two larger than each other, this is always safe.
return 1;
}
-// getCFConstantStringType - Return the type used for constant CFStrings.
+// getCFConstantStringType - Return the type used for constant CFStrings.
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
- CFConstantStringTypeDecl =
- RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ CFConstantStringTypeDecl =
+ RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
&Idents.get("NSConstantString"));
QualType FieldTypes[4];
-
+
// const int *isa;
- FieldTypes[0] = getPointerType(IntTy.getQualifiedType(QualType::Const));
+ FieldTypes[0] = getPointerType(IntTy.getQualifiedType(QualType::Const));
// int flags;
FieldTypes[1] = IntTy;
// const char *str;
- FieldTypes[2] = getPointerType(CharTy.getQualifiedType(QualType::Const));
+ FieldTypes[2] = getPointerType(CharTy.getQualifiedType(QualType::Const));
// long length;
- FieldTypes[3] = LongTy;
-
+ FieldTypes[3] = LongTy;
+
// Create fields
for (unsigned i = 0; i < 4; ++i) {
- FieldDecl *Field = FieldDecl::Create(*this, CFConstantStringTypeDecl,
+ FieldDecl *Field = FieldDecl::Create(*this, CFConstantStringTypeDecl,
SourceLocation(), 0,
FieldTypes[i], /*DInfo=*/0,
- /*BitWidth=*/0,
+ /*BitWidth=*/0,
/*Mutable=*/false);
CFConstantStringTypeDecl->addDecl(Field);
}
CFConstantStringTypeDecl->completeDefinition(*this);
}
-
+
return getTagDeclType(CFConstantStringTypeDecl);
}
@@ -2677,13 +2675,12 @@ void ASTContext::setCFConstantStringType(QualType T) {
CFConstantStringTypeDecl = Rec->getDecl();
}
-QualType ASTContext::getObjCFastEnumerationStateType()
-{
+QualType ASTContext::getObjCFastEnumerationStateType() {
if (!ObjCFastEnumerationStateTypeDecl) {
ObjCFastEnumerationStateTypeDecl =
RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
&Idents.get("__objcFastEnumerationState"));
-
+
QualType FieldTypes[] = {
UnsignedLongTy,
getPointerType(ObjCIdTypedefType),
@@ -2691,20 +2688,20 @@ QualType ASTContext::getObjCFastEnumerationStateType()
getConstantArrayType(UnsignedLongTy,
llvm::APInt(32, 5), ArrayType::Normal, 0)
};
-
+
for (size_t i = 0; i < 4; ++i) {
- FieldDecl *Field = FieldDecl::Create(*this,
- ObjCFastEnumerationStateTypeDecl,
- SourceLocation(), 0,
+ FieldDecl *Field = FieldDecl::Create(*this,
+ ObjCFastEnumerationStateTypeDecl,
+ SourceLocation(), 0,
FieldTypes[i], /*DInfo=*/0,
- /*BitWidth=*/0,
+ /*BitWidth=*/0,
/*Mutable=*/false);
ObjCFastEnumerationStateTypeDecl->addDecl(Field);
}
-
+
ObjCFastEnumerationStateTypeDecl->completeDefinition(*this);
}
-
+
return getTagDeclType(ObjCFastEnumerationStateTypeDecl);
}
@@ -2720,7 +2717,7 @@ static bool isTypeTypedefedAsBOOL(QualType T) {
if (const TypedefType *TT = dyn_cast<TypedefType>(T))
if (IdentifierInfo *II = TT->getDecl()->getIdentifier())
return II->isStr("BOOL");
-
+
return false;
}
@@ -2728,7 +2725,7 @@ static bool isTypeTypedefedAsBOOL(QualType T) {
/// purpose.
int ASTContext::getObjCEncodingTypeSize(QualType type) {
uint64_t sz = getTypeSize(type);
-
+
// Make all integer and enum types at least as large as an int
if (sz > 0 && type->isIntegralType())
sz = std::max(sz, getTypeSize(IntTy));
@@ -2740,7 +2737,7 @@ int ASTContext::getObjCEncodingTypeSize(QualType type) {
/// getObjCEncodingForMethodDecl - Return the encoded type for this method
/// declaration.
-void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
+void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
std::string& S) {
// FIXME: This is not very efficient.
// Encode type qualifer, 'in', 'inout', etc. for the return type.
@@ -2765,13 +2762,13 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
S += llvm::utostr(ParmOffset);
S += "@0:";
S += llvm::utostr(PtrSize);
-
+
// Argument types.
ParmOffset = 2 * PtrSize;
for (ObjCMethodDecl::param_iterator PI = Decl->param_begin(),
E = Decl->param_end(); PI != E; ++PI) {
ParmVarDecl *PVDecl = *PI;
- QualType PType = PVDecl->getOriginalType();
+ QualType PType = PVDecl->getOriginalType();
if (const ArrayType *AT =
dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
// Use array's original type only if it has known number of
@@ -2793,11 +2790,11 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
/// property declaration. If non-NULL, Container must be either an
/// ObjCCategoryImplDecl or ObjCImplementationDecl; it should only be
/// NULL when getting encodings for protocol properties.
-/// Property attributes are stored as a comma-delimited C string. The simple
-/// attributes readonly and bycopy are encoded as single characters. The
-/// parametrized attributes, getter=name, setter=name, and ivar=name, are
-/// encoded as single characters, followed by an identifier. Property types
-/// are also encoded as a parametrized attribute. The characters used to encode
+/// Property attributes are stored as a comma-delimited C string. The simple
+/// attributes readonly and bycopy are encoded as single characters. The
+/// parametrized attributes, getter=name, setter=name, and ivar=name, are
+/// encoded as single characters, followed by an identifier. Property types
+/// are also encoded as a parametrized attribute. The characters used to encode
/// these attributes are defined by the following enumeration:
/// @code
/// enum PropertyAttributes {
@@ -2814,7 +2811,7 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
/// kPropertyNonAtomic = 'N' // property non-atomic
/// };
/// @endcode
-void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
+void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
const Decl *Container,
std::string& S) {
// Collect information from the property implementation decl(s).
@@ -2823,7 +2820,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
// FIXME: Duplicated code due to poor abstraction.
if (Container) {
- if (const ObjCCategoryImplDecl *CID =
+ if (const ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(Container)) {
for (ObjCCategoryImplDecl::propimpl_iterator
i = CID->propimpl_begin(), e = CID->propimpl_end();
@@ -2850,7 +2847,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
SynthesizePID = PID;
}
}
- }
+ }
}
}
@@ -2860,7 +2857,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
// Encode result type.
// GCC has some special rules regarding encoding of properties which
// closely resembles encoding of ivars.
- getObjCEncodingForTypeImpl(PD->getType(), S, true, true, 0,
+ getObjCEncodingForTypeImpl(PD->getType(), S, true, true, 0,
true /* outermost type */,
true /* encoding for property */);
@@ -2870,7 +2867,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
switch (PD->getSetterKind()) {
case ObjCPropertyDecl::Assign: break;
case ObjCPropertyDecl::Copy: S += ",C"; break;
- case ObjCPropertyDecl::Retain: S += ",&"; break;
+ case ObjCPropertyDecl::Retain: S += ",&"; break;
}
}
@@ -2881,7 +2878,7 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic)
S += ",N";
-
+
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
S += ",G";
S += PD->getGetterName().getAsString();
@@ -2902,8 +2899,8 @@ void ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
}
/// getLegacyIntegralTypeEncoding -
-/// Another legacy compatibility encoding: 32-bit longs are encoded as
-/// 'l' or 'L' , but not always. For typedefs, we need to use
+/// Another legacy compatibility encoding: 32-bit longs are encoded as
+/// 'l' or 'L' , but not always. For typedefs, we need to use
/// 'i' or 'I' instead if encoding a struct field, or a pointer!
///
void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const {
@@ -2912,7 +2909,7 @@ void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const {
if (BT->getKind() == BuiltinType::ULong &&
((const_cast<ASTContext *>(this))->getIntWidth(PointeeTy) == 32))
PointeeTy = UnsignedIntTy;
- else
+ else
if (BT->getKind() == BuiltinType::Long &&
((const_cast<ASTContext *>(this))->getIntWidth(PointeeTy) == 32))
PointeeTy = IntTy;
@@ -2926,11 +2923,11 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
// directly pointed to, and expanding embedded structures. Note that
// these rules are sufficient to prevent recursive encoding of the
// same type.
- getObjCEncodingForTypeImpl(T, S, true, true, Field,
+ getObjCEncodingForTypeImpl(T, S, true, true, Field,
true /* outermost type */);
}
-static void EncodeBitField(const ASTContext *Context, std::string& S,
+static void EncodeBitField(const ASTContext *Context, std::string& S,
const FieldDecl *FD) {
const Expr *E = FD->getBitWidth();
assert(E && "bitfield width not there - getObjCEncodingForTypeImpl");
@@ -2951,16 +2948,16 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
return EncodeBitField(this, S, FD);
char encoding;
switch (BT->getKind()) {
- default: assert(0 && "Unhandled builtin type kind");
+ default: assert(0 && "Unhandled builtin type kind");
case BuiltinType::Void: encoding = 'v'; break;
case BuiltinType::Bool: encoding = 'B'; break;
case BuiltinType::Char_U:
case BuiltinType::UChar: encoding = 'C'; break;
case BuiltinType::UShort: encoding = 'S'; break;
case BuiltinType::UInt: encoding = 'I'; break;
- case BuiltinType::ULong:
- encoding =
- (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'L' : 'Q';
+ case BuiltinType::ULong:
+ encoding =
+ (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'L' : 'Q';
break;
case BuiltinType::UInt128: encoding = 'T'; break;
case BuiltinType::ULongLong: encoding = 'Q'; break;
@@ -2968,9 +2965,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
case BuiltinType::SChar: encoding = 'c'; break;
case BuiltinType::Short: encoding = 's'; break;
case BuiltinType::Int: encoding = 'i'; break;
- case BuiltinType::Long:
- encoding =
- (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'l' : 'q';
+ case BuiltinType::Long:
+ encoding =
+ (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'l' : 'q';
break;
case BuiltinType::LongLong: encoding = 'q'; break;
case BuiltinType::Int128: encoding = 't'; break;
@@ -2978,25 +2975,25 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
case BuiltinType::Double: encoding = 'd'; break;
case BuiltinType::LongDouble: encoding = 'd'; break;
}
-
+
S += encoding;
return;
}
-
+
if (const ComplexType *CT = T->getAsComplexType()) {
S += 'j';
- getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false,
+ getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, 0, false,
false);
return;
}
-
+
if (const PointerType *PT = T->getAs<PointerType>()) {
QualType PointeeTy = PT->getPointeeType();
bool isReadOnly = false;
// For historical/compatibility reasons, the read-only qualifier of the
// pointee gets emitted _before_ the '^'. The read-only qualifier of
// the pointer itself gets ignored, _unless_ we are looking at a typedef!
- // Also, do not emit the 'r' for anything but the outermost type!
+ // Also, do not emit the 'r' for anything but the outermost type!
if (isa<TypedefType>(T.getTypePtr())) {
if (OutermostType && T.isConstQualified()) {
isReadOnly = true;
@@ -3026,7 +3023,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += ':';
return;
}
-
+
if (PointeeTy->isCharType()) {
// char pointer types should be encoded as '*' unless it is a
// type that has been typedef'd to 'BOOL'.
@@ -3050,11 +3047,11 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += '^';
getLegacyIntegralTypeEncoding(PointeeTy);
- getObjCEncodingForTypeImpl(PointeeTy, S, false, ExpandPointedToStructures,
+ getObjCEncodingForTypeImpl(PointeeTy, S, false, ExpandPointedToStructures,
NULL);
return;
}
-
+
if (const ArrayType *AT =
// Ignore type qualifiers etc.
dyn_cast<ArrayType>(T->getCanonicalTypeInternal())) {
@@ -3062,11 +3059,11 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// Incomplete arrays are encoded as a pointer to the array element.
S += '^';
- getObjCEncodingForTypeImpl(AT->getElementType(), S,
+ getObjCEncodingForTypeImpl(AT->getElementType(), S,
false, ExpandStructures, FD);
} else {
S += '[';
-
+
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
S += llvm::utostr(CAT->getSize().getZExtValue());
else {
@@ -3074,19 +3071,19 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
assert(isa<VariableArrayType>(AT) && "Unknown array type!");
S += '0';
}
-
- getObjCEncodingForTypeImpl(AT->getElementType(), S,
+
+ getObjCEncodingForTypeImpl(AT->getElementType(), S,
false, ExpandStructures, FD);
S += ']';
}
return;
}
-
+
if (T->getAsFunctionType()) {
S += '?';
return;
}
-
+
if (const RecordType *RTy = T->getAs<RecordType>()) {
RecordDecl *RDecl = RTy->getDecl();
S += RDecl->isUnion() ? '(' : '{';
@@ -3106,15 +3103,15 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += Field->getNameAsString();
S += '"';
}
-
+
// Special case bit-fields.
if (Field->isBitField()) {
- getObjCEncodingForTypeImpl(Field->getType(), S, false, true,
+ getObjCEncodingForTypeImpl(Field->getType(), S, false, true,
(*Field));
} else {
QualType qt = Field->getType();
getLegacyIntegralTypeEncoding(qt);
- getObjCEncodingForTypeImpl(qt, S, false, true,
+ getObjCEncodingForTypeImpl(qt, S, false, true,
FD);
}
}
@@ -3122,7 +3119,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += RDecl->isUnion() ? ')' : '}';
return;
}
-
+
if (T->isEnumeralType()) {
if (FD && FD->isBitField())
EncodeBitField(this, S, FD);
@@ -3130,12 +3127,12 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += 'i';
return;
}
-
+
if (T->isBlockPointerType()) {
S += "@?"; // Unlike a pointer-to-function, which is "^?".
return;
}
-
+
if (T->isObjCInterfaceType()) {
// @encode(class_name)
ObjCInterfaceDecl *OI = T->getAsObjCInterfaceType()->getDecl();
@@ -3147,29 +3144,29 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
CollectObjCIvars(OI, RecFields);
for (unsigned i = 0, e = RecFields.size(); i != e; ++i) {
if (RecFields[i]->isBitField())
- getObjCEncodingForTypeImpl(RecFields[i]->getType(), S, false, true,
+ getObjCEncodingForTypeImpl(RecFields[i]->getType(), S, false, true,
RecFields[i]);
else
- getObjCEncodingForTypeImpl(RecFields[i]->getType(), S, false, true,
+ getObjCEncodingForTypeImpl(RecFields[i]->getType(), S, false, true,
FD);
}
S += '}';
return;
}
-
+
if (const ObjCObjectPointerType *OPT = T->getAsObjCObjectPointerType()) {
if (OPT->isObjCIdType()) {
S += '@';
return;
}
-
+
if (OPT->isObjCClassType()) {
S += '#';
return;
}
-
+
if (OPT->isObjCQualifiedIdType()) {
- getObjCEncodingForTypeImpl(getObjCIdType(), S,
+ getObjCEncodingForTypeImpl(getObjCIdType(), S,
ExpandPointedToStructures,
ExpandStructures, FD);
if (FD || EncodingProperty) {
@@ -3186,16 +3183,16 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
}
return;
}
-
+
QualType PointeeTy = OPT->getPointeeType();
if (!EncodingProperty &&
isa<TypedefType>(PointeeTy.getTypePtr())) {
// Another historical/compatibility reason.
- // We encode the underlying type which comes out as
+ // We encode the underlying type which comes out as
// {...};
S += '^';
- getObjCEncodingForTypeImpl(PointeeTy, S,
- false, ExpandPointedToStructures,
+ getObjCEncodingForTypeImpl(PointeeTy, S,
+ false, ExpandPointedToStructures,
NULL);
return;
}
@@ -3209,16 +3206,16 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += '<';
S += (*I)->getNameAsString();
S += '>';
- }
+ }
S += '"';
}
return;
}
-
+
assert(0 && "@encode for type not implemented!");
}
-void ASTContext::getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
+void ASTContext::getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
std::string& S) const {
if (QT & Decl::OBJC_TQ_In)
S += 'n';
@@ -3236,7 +3233,7 @@ void ASTContext::getObjCEncodingForTypeQualifier(Decl::ObjCDeclQualifier QT,
void ASTContext::setBuiltinVaListType(QualType T) {
assert(BuiltinVaListType.isNull() && "__builtin_va_list type already set!");
-
+
BuiltinVaListType = T;
}
@@ -3271,15 +3268,15 @@ void ASTContext::setObjCClassType(QualType T) {
}
void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) {
- assert(ObjCConstantStringType.isNull() &&
+ assert(ObjCConstantStringType.isNull() &&
"'NSConstantString' type already set!");
-
+
ObjCConstantStringType = getObjCInterfaceType(Decl);
}
/// \brief Retrieve the template name that represents a qualified
/// template name such as \c std::vector.
-TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
+TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
TemplateDecl *Template) {
llvm::FoldingSetNodeID ID;
@@ -3298,12 +3295,12 @@ TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
/// \brief Retrieve the template name that represents a qualified
/// template name such as \c std::vector.
-TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
+TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
OverloadedFunctionDecl *Template) {
llvm::FoldingSetNodeID ID;
QualifiedTemplateName::Profile(ID, NNS, TemplateKeyword, Template);
-
+
void *InsertPos = 0;
QualifiedTemplateName *QTN =
QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
@@ -3311,15 +3308,15 @@ TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
QTN = new (*this,4) QualifiedTemplateName(NNS, TemplateKeyword, Template);
QualifiedTemplateNames.InsertNode(QTN, InsertPos);
}
-
+
return TemplateName(QTN);
}
/// \brief Retrieve the template name that represents a dependent
/// template name such as \c MetaFun::template apply.
-TemplateName ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
+TemplateName ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
const IdentifierInfo *Name) {
- assert((!NNS || NNS->isDependent()) &&
+ assert((!NNS || NNS->isDependent()) &&
"Nested name specifier must be dependent");
llvm::FoldingSetNodeID ID;
@@ -3349,7 +3346,7 @@ TemplateName ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
/// is actually a value of type @c TargetInfo::IntType.
QualType ASTContext::getFromTargetType(unsigned Type) const {
switch (Type) {
- case TargetInfo::NoInt: return QualType();
+ case TargetInfo::NoInt: return QualType();
case TargetInfo::SignedShort: return ShortTy;
case TargetInfo::UnsignedShort: return UnsignedShortTy;
case TargetInfo::SignedInt: return IntTy;
@@ -3379,7 +3376,7 @@ bool ASTContext::isObjCNSObjectType(QualType Ty) const {
if (TD->getAttr<ObjCNSObjectAttr>())
return true;
}
- return false;
+ return false;
}
/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
@@ -3391,7 +3388,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
getLangOptions().getGCMode() != LangOptions::NonGC) {
GCAttrs = Ty.getObjCGCAttr();
// Default behavious under objective-c's gc is for objective-c pointers
- // (or pointers to them) be treated as though they were declared
+ // (or pointers to them) be treated as though they were declared
// as __strong.
if (GCAttrs == QualType::GCNone) {
if (Ty->isObjCObjectPointerType())
@@ -3411,7 +3408,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
// Type Compatibility Testing
//===----------------------------------------------------------------------===//
-/// areCompatVectorTypes - Return true if the two specified vector types are
+/// areCompatVectorTypes - Return true if the two specified vector types are
/// compatible.
static bool areCompatVectorTypes(const VectorType *LHS,
const VectorType *RHS) {
@@ -3451,20 +3448,20 @@ bool ASTContext::QualifiedIdConformsQualifiedId(QualType lhs, QualType rhs) {
bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
bool compare) {
// Allow id<P..> and an 'id' or void* type in all cases.
- if (lhs->isVoidPointerType() ||
+ if (lhs->isVoidPointerType() ||
lhs->isObjCIdType() || lhs->isObjCClassType())
return true;
- else if (rhs->isVoidPointerType() ||
+ else if (rhs->isVoidPointerType() ||
rhs->isObjCIdType() || rhs->isObjCClassType())
return true;
if (const ObjCObjectPointerType *lhsQID = lhs->getAsObjCQualifiedIdType()) {
const ObjCObjectPointerType *rhsOPT = rhs->getAsObjCObjectPointerType();
-
+
if (!rhsOPT) return false;
-
+
if (rhsOPT->qual_empty()) {
- // If the RHS is a unqualified interface pointer "NSString*",
+ // If the RHS is a unqualified interface pointer "NSString*",
// make sure we check the class hierarchy.
if (ObjCInterfaceDecl *rhsID = rhsOPT->getInterfaceDecl()) {
for (ObjCObjectPointerType::qual_iterator I = lhsQID->qual_begin(),
@@ -3479,7 +3476,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
// If there are no qualifiers and no interface, we have an 'id'.
return true;
}
- // Both the right and left sides have qualifiers.
+ // Both the right and left sides have qualifiers.
for (ObjCObjectPointerType::qual_iterator I = lhsQID->qual_begin(),
E = lhsQID->qual_end(); I != E; ++I) {
ObjCProtocolDecl *lhsProto = *I;
@@ -3497,7 +3494,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
break;
}
}
- // If the RHS is a qualified interface pointer "NSString<P>*",
+ // If the RHS is a qualified interface pointer "NSString<P>*",
// make sure we check the class hierarchy.
if (ObjCInterfaceDecl *rhsID = rhsOPT->getInterfaceDecl()) {
for (ObjCObjectPointerType::qual_iterator I = lhsQID->qual_begin(),
@@ -3514,14 +3511,14 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
if (!match)
return false;
}
-
+
return true;
}
-
+
const ObjCObjectPointerType *rhsQID = rhs->getAsObjCQualifiedIdType();
assert(rhsQID && "One of the LHS/RHS should be id<x>");
- if (const ObjCObjectPointerType *lhsOPT =
+ if (const ObjCObjectPointerType *lhsOPT =
lhs->getAsObjCInterfacePointerType()) {
if (lhsOPT->qual_empty()) {
bool match = false;
@@ -3541,7 +3538,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
}
return true;
}
- // Both the right and left sides have qualifiers.
+ // Both the right and left sides have qualifiers.
for (ObjCObjectPointerType::qual_iterator I = lhsOPT->qual_begin(),
E = lhsOPT->qual_end(); I != E; ++I) {
ObjCProtocolDecl *lhsProto = *I;
@@ -3578,15 +3575,15 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
return true;
if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType())
- return ObjCQualifiedIdTypesAreCompatible(QualType(LHSOPT,0),
- QualType(RHSOPT,0),
+ return ObjCQualifiedIdTypesAreCompatible(QualType(LHSOPT,0),
+ QualType(RHSOPT,0),
false);
const ObjCInterfaceType* LHS = LHSOPT->getInterfaceType();
const ObjCInterfaceType* RHS = RHSOPT->getInterfaceType();
if (LHS && RHS) // We have 2 user-defined types.
return canAssignObjCInterfaces(LHS, RHS);
-
+
return false;
}
@@ -3596,17 +3593,17 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCInterfaceType *LHS,
// the LHS.
if (!LHS->getDecl()->isSuperClassOf(RHS->getDecl()))
return false;
-
+
// RHS must have a superset of the protocols in the LHS. If the LHS is not
// protocol qualified at all, then we are good.
if (LHS->getNumProtocols() == 0)
return true;
-
+
// Okay, we know the LHS has protocol qualifiers. If the RHS doesn't, then it
// isn't a superset.
if (RHS->getNumProtocols() == 0)
return true; // FIXME: should return false!
-
+
for (ObjCInterfaceType::qual_iterator LHSPI = LHS->qual_begin(),
LHSPE = LHS->qual_end();
LHSPI != LHSPE; LHSPI++) {
@@ -3634,7 +3631,7 @@ bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) {
// get the "pointed to" types
const ObjCObjectPointerType *LHSOPT = LHS->getAsObjCObjectPointerType();
const ObjCObjectPointerType *RHSOPT = RHS->getAsObjCObjectPointerType();
-
+
if (!LHSOPT || !RHSOPT)
return false;
@@ -3642,9 +3639,9 @@ bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) {
canAssignObjCInterfaces(RHSOPT, LHSOPT);
}
-/// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,
+/// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,
/// both shall have the identically qualified version of a compatible type.
-/// C99 6.2.7p1: Two types have compatible types if their types are the
+/// C99 6.2.7p1: Two types have compatible types if their types are the
/// same. See 6.7.[2,3,5] for additional rules.
bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS) {
return !mergeTypes(LHS, RHS).isNull();
@@ -3671,7 +3668,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
allLTypes = false;
if (NoReturn != rbase->getNoReturnAttr())
allRTypes = false;
-
+
if (lproto && rproto) { // two C99 style function prototypes
assert(!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec() &&
"C++ shouldn't be here");
@@ -3783,15 +3780,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
QualType::GCAttrTypes GCAttr = RHSCan.getObjCGCAttr();
if (GCAttr != QualType::GCNone) {
QualType::GCAttrTypes GCLHSAttr = LHSCan.getObjCGCAttr();
- // __weak attribute must appear on both declarations.
- // __strong attribue is redundant if other decl is an objective-c
+ // __weak attribute must appear on both declarations.
+ // __strong attribue is redundant if other decl is an objective-c
// object pointer (or decorated with __strong attribute); otherwise
// issue error.
if ((GCAttr == QualType::Weak && GCLHSAttr != GCAttr) ||
(GCAttr == QualType::Strong && GCLHSAttr != GCAttr &&
!LHSCan->isObjCObjectPointerType()))
return QualType();
-
+
RHS = QualType(cast<ExtQualType>(RHS.getDesugaredType())->getBaseType(),
RHS.getCVRQualifiers());
QualType Result = mergeTypes(LHS, RHS);
@@ -3809,14 +3806,14 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
if (GCAttr != QualType::GCNone) {
QualType::GCAttrTypes GCRHSAttr = RHSCan.getObjCGCAttr();
// __weak attribute must appear on both declarations. __strong
- // __strong attribue is redundant if other decl is an objective-c
+ // __strong attribue is redundant if other decl is an objective-c
// object pointer (or decorated with __strong attribute); otherwise
// issue error.
if ((GCAttr == QualType::Weak && GCRHSAttr != GCAttr) ||
(GCAttr == QualType::Strong && GCRHSAttr != GCAttr &&
!RHSCan->isObjCObjectPointerType()))
return QualType();
-
+
LHS = QualType(cast<ExtQualType>(LHS.getDesugaredType())->getBaseType(),
LHS.getCVRQualifiers());
QualType Result = mergeTypes(LHS, RHS);
@@ -3835,15 +3832,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
LHSClass = Type::ConstantArray;
if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray)
RHSClass = Type::ConstantArray;
-
+
// Canonicalize ExtVector -> Vector.
if (LHSClass == Type::ExtVector) LHSClass = Type::Vector;
if (RHSClass == Type::ExtVector) RHSClass = Type::Vector;
-
+
// If the canonical type classes don't match.
if (LHSClass != RHSClass) {
// C99 6.7.2.2p4: Each enumerated type shall be compatible with char,
- // a signed integer type, or an unsigned integer type.
+ // a signed integer type, or an unsigned integer type.
if (const EnumType* ETy = LHS->getAsEnumType()) {
if (ETy->getDecl()->getIntegerType() == RHSCan.getUnqualifiedType())
return RHS;
@@ -3976,7 +3973,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
return QualType();
}
case Type::ObjCObjectPointer: {
- if (canAssignObjCInterfaces(LHS->getAsObjCObjectPointerType(),
+ if (canAssignObjCInterfaces(LHS->getAsObjCObjectPointerType(),
RHS->getAsObjCObjectPointerType()))
return LHS;
@@ -4072,18 +4069,18 @@ void ExternalASTSource::PrintStats() { }
/// DecodeTypeFromStr - This decodes one type descriptor from Str, advancing the
/// pointer over the consumed characters. This returns the resultant type.
-static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
+static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
ASTContext::GetBuiltinTypeError &Error,
bool AllowTypeModifiers = true) {
// Modifiers.
int HowLong = 0;
bool Signed = false, Unsigned = false;
-
+
// Read the modifiers first.
bool Done = false;
while (!Done) {
switch (*Str++) {
- default: Done = true; --Str; break;
+ default: Done = true; --Str; break;
case 'S':
assert(!Unsigned && "Can't use both 'S' and 'U' modifiers!");
assert(!Signed && "Can't use 'S' modifier multiple times!");
@@ -4102,7 +4099,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
}
QualType Type;
-
+
// Read the base type.
switch (*Str++) {
default: assert(0 && "Unknown builtin type letter!");
@@ -4186,9 +4183,9 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
char *End;
unsigned NumElements = strtoul(Str, &End, 10);
assert(End != Str && "Missing vector size");
-
+
Str = End;
-
+
QualType ElementType = DecodeTypeFromStr(Str, Context, Error, false);
Type = Context.getVectorType(ElementType, NumElements);
break;
@@ -4212,10 +4209,10 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
}
break;
}
-
+
if (!AllowTypeModifiers)
return Type;
-
+
Done = false;
while (!Done) {
switch (*Str++) {
@@ -4232,7 +4229,7 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
break;
}
}
-
+
return Type;
}
@@ -4240,9 +4237,9 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context,
QualType ASTContext::GetBuiltinType(unsigned id,
GetBuiltinTypeError &Error) {
const char *TypeStr = BuiltinInfo.GetTypeString(id);
-
+
llvm::SmallVector<QualType, 8> ArgTypes;
-
+
Error = GE_None;
QualType ResType = DecodeTypeFromStr(TypeStr, *this, Error);
if (Error != GE_None)
@@ -4255,7 +4252,7 @@ QualType ASTContext::GetBuiltinType(unsigned id,
// Do array -> pointer decay. The builtin should use the decayed type.
if (Ty->isArrayType())
Ty = getArrayDecayedType(Ty);
-
+
ArgTypes.push_back(Ty);
}
@@ -4288,42 +4285,42 @@ ASTContext::UsualArithmeticConversionsType(QualType lhs, QualType rhs) {
// If both types are identical, no conversion is needed.
if (lhs == rhs)
return lhs;
-
+
// If either side is a non-arithmetic type (e.g. a pointer), we are done.
// The caller can deal with this (e.g. pointer + int).
if (!lhs->isArithmeticType() || !rhs->isArithmeticType())
return lhs;
-
- // At this point, we have two different arithmetic types.
-
+
+ // At this point, we have two different arithmetic types.
+
// Handle complex types first (C99 6.3.1.8p1).
if (lhs->isComplexType() || rhs->isComplexType()) {
// if we have an integer operand, the result is the complex type.
- if (rhs->isIntegerType() || rhs->isComplexIntegerType()) {
+ if (rhs->isIntegerType() || rhs->isComplexIntegerType()) {
// convert the rhs to the lhs complex type.
return lhs;
}
- if (lhs->isIntegerType() || lhs->isComplexIntegerType()) {
+ if (lhs->isIntegerType() || lhs->isComplexIntegerType()) {
// convert the lhs to the rhs complex type.
return rhs;
}
// This handles complex/complex, complex/float, or float/complex.
- // When both operands are complex, the shorter operand is converted to the
- // type of the longer, and that is the type of the result. This corresponds
- // to what is done when combining two real floating-point operands.
- // The fun begins when size promotion occur across type domains.
+ // When both operands are complex, the shorter operand is converted to the
+ // type of the longer, and that is the type of the result. This corresponds
+ // to what is done when combining two real floating-point operands.
+ // The fun begins when size promotion occur across type domains.
// From H&S 6.3.4: When one operand is complex and the other is a real
- // floating-point type, the less precise type is converted, within it's
+ // floating-point type, the less precise type is converted, within it's
// real or complex domain, to the precision of the other type. For example,
- // when combining a "long double" with a "double _Complex", the
+ // when combining a "long double" with a "double _Complex", the
// "double _Complex" is promoted to "long double _Complex".
int result = getFloatingTypeOrder(lhs, rhs);
-
- if (result > 0) { // The left side is bigger, convert rhs.
+
+ if (result > 0) { // The left side is bigger, convert rhs.
rhs = getFloatingTypeOfSizeWithinDomain(lhs, rhs);
- } else if (result < 0) { // The right side is bigger, convert lhs.
+ } else if (result < 0) { // The right side is bigger, convert lhs.
lhs = getFloatingTypeOfSizeWithinDomain(rhs, lhs);
- }
+ }
// At this point, lhs and rhs have the same rank/size. Now, make sure the
// domains match. This is a requirement for our implementation, C99
// does not require this promotion.
@@ -4351,7 +4348,7 @@ ASTContext::UsualArithmeticConversionsType(QualType lhs, QualType rhs) {
// convert lhs to the rhs floating point type.
return rhs;
}
- if (lhs->isComplexIntegerType()) {
+ if (lhs->isComplexIntegerType()) {
// convert lhs to the complex floating point type.
return getComplexType(rhs);
}
@@ -4369,7 +4366,7 @@ ASTContext::UsualArithmeticConversionsType(QualType lhs, QualType rhs) {
const ComplexType *rhsComplexInt = rhs->getAsComplexIntegerType();
if (lhsComplexInt && rhsComplexInt) {
- if (getIntegerTypeOrder(lhsComplexInt->getElementType(),
+ if (getIntegerTypeOrder(lhsComplexInt->getElementType(),
rhsComplexInt->getElementType()) >= 0)
return lhs; // convert the rhs
return rhs;
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 4e07b957a7..776a26595b 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -45,7 +45,7 @@ TypeLoc DeclaratorInfo::getTypeLoc() const {
//===----------------------------------------------------------------------===//
// Decl Allocation/Deallocation Method Implementations
//===----------------------------------------------------------------------===//
-
+
TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) {
return new (C) TranslationUnitDecl(C);
@@ -59,7 +59,7 @@ NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC,
void NamespaceDecl::Destroy(ASTContext& C) {
// NamespaceDecl uses "NextDeclarator" to chain namespace declarations
// together. They are all top-level Decls.
-
+
this->~NamespaceDecl();
C.Deallocate((void *)this);
}
@@ -75,9 +75,9 @@ const char *VarDecl::getStorageClassSpecifierString(StorageClass SC) {
case VarDecl::None: break;
case VarDecl::Auto: return "auto"; break;
case VarDecl::Extern: return "extern"; break;
- case VarDecl::PrivateExtern: return "__private_extern__"; break;
+ case VarDecl::PrivateExtern: return "__private_extern__"; break;
case VarDecl::Register: return "register"; break;
- case VarDecl::Static: return "static"; break;
+ case VarDecl::Static: return "static"; break;
}
assert(0 && "Invalid storage class");
@@ -92,13 +92,13 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
}
QualType ParmVarDecl::getOriginalType() const {
- if (const OriginalParmVarDecl *PVD =
+ if (const OriginalParmVarDecl *PVD =
dyn_cast<OriginalParmVarDecl>(this))
return PVD->OriginalType;
return getType();
}
-void VarDecl::setInit(ASTContext &C, Expr *I) {
+void VarDecl::setInit(ASTContext &C, Expr *I) {
if (EvaluatedStmt *Eval = Init.dyn_cast<EvaluatedStmt *>()) {
Eval->~EvaluatedStmt();
C.Deallocate(Eval);
@@ -109,11 +109,11 @@ void VarDecl::setInit(ASTContext &C, Expr *I) {
bool VarDecl::isExternC(ASTContext &Context) const {
if (!Context.getLangOptions().CPlusPlus)
- return (getDeclContext()->isTranslationUnit() &&
+ return (getDeclContext()->isTranslationUnit() &&
getStorageClass() != Static) ||
(getDeclContext()->isFunctionOrMethod() && hasExternalStorage());
- for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
+ for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
DC = DC->getParent()) {
if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC)) {
if (Linkage->getLanguage() == LinkageSpecDecl::lang_c)
@@ -138,12 +138,12 @@ OriginalParmVarDecl *OriginalParmVarDecl::Create(
}
FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+ SourceLocation L,
DeclarationName N, QualType T,
DeclaratorInfo *DInfo,
- StorageClass S, bool isInline,
+ StorageClass S, bool isInline,
bool hasWrittenPrototype) {
- FunctionDecl *New
+ FunctionDecl *New
= new (C) FunctionDecl(Function, DC, L, N, T, DInfo, S, isInline);
New->HasWrittenPrototype = hasWrittenPrototype;
return New;
@@ -162,7 +162,7 @@ FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
bool FieldDecl::isAnonymousStructOrUnion() const {
if (!isImplicit() || getDeclName())
return false;
-
+
if (const RecordType *Record = getType()->getAs<RecordType>())
return Record->getDecl()->isAnonymousStructOrUnion();
@@ -233,7 +233,7 @@ std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const {
// scope class/struct/union. How do we handle this case?
break;
- if (const ClassTemplateSpecializationDecl *Spec
+ if (const ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) {
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
std::string TemplateArgsStr
@@ -271,7 +271,7 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
return cast<UsingDirectiveDecl>(this)->getNominatedNamespace() ==
cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace();
}
-
+
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
// For function declarations, we keep track of redeclarations.
return FD->getPreviousDeclaration() == OldD;
@@ -283,11 +283,11 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
= dyn_cast<FunctionTemplateDecl>(OldD))
return FunctionTemplate->getTemplatedDecl()
->declarationReplaces(OldFunctionTemplate->getTemplatedDecl());
-
+
// For method declarations, we keep track of redeclarations.
if (isa<ObjCMethodDecl>(this))
return false;
-
+
// For non-function declarations, if the declarations are of the
// same kind then this must be a redeclaration, or semantic analysis
// would not have given us the new declaration.
@@ -444,11 +444,11 @@ bool FunctionDecl::isExternC(ASTContext &Context) const {
if (!Context.getLangOptions().CPlusPlus)
return getStorageClass() != Static && !getAttr<OverloadableAttr>();
- for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
+ for (const DeclContext *DC = getDeclContext(); !DC->isTranslationUnit();
DC = DC->getParent()) {
if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC)) {
if (Linkage->getLanguage() == LinkageSpecDecl::lang_c)
- return getStorageClass() != Static &&
+ return getStorageClass() != Static &&
!getAttr<OverloadableAttr>();
break;
@@ -465,7 +465,7 @@ bool FunctionDecl::isGlobal() const {
if (getStorageClass() == Static)
return false;
- for (const DeclContext *DC = getDeclContext();
+ for (const DeclContext *DC = getDeclContext();
DC->isNamespace();
DC = DC->getParent()) {
if (const NamespaceDecl *Namespace = cast<NamespaceDecl>(DC)) {
@@ -485,7 +485,7 @@ bool FunctionDecl::isGlobal() const {
/// declared at translation scope or within an extern "C" block and
/// its name matches with the name of a builtin. The returned value
/// will be 0 for functions that do not correspond to a builtin, a
-/// value of type \c Builtin::ID if in the target-independent range
+/// value of type \c Builtin::ID if in the target-independent range
/// \c [1,Builtin::First), or a target-specific builtin value.
unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const {
if (!getIdentifier() || !getIdentifier()->getBuiltinID())
@@ -512,7 +512,7 @@ unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const {
// If the function is in an extern "C" linkage specification and is
// not marked "overloadable", it's the real function.
if (isa<LinkageSpecDecl>(getDeclContext()) &&
- cast<LinkageSpecDecl>(getDeclContext())->getLanguage()
+ cast<LinkageSpecDecl>(getDeclContext())->getLanguage()
== LinkageSpecDecl::lang_c &&
!getAttr<OverloadableAttr>())
return BuiltinID;
@@ -530,14 +530,14 @@ unsigned FunctionDecl::getNumParams() const {
if (isa<FunctionNoProtoType>(FT))
return 0;
return cast<FunctionProtoType>(FT)->getNumArgs();
-
+
}
void FunctionDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
unsigned NumParams) {
assert(ParamInfo == 0 && "Already has param info!");
assert(NumParams == getNumParams() && "Parameter count mismatch!");
-
+
// Zero params -> null pointer.
if (NumParams) {
void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
@@ -586,12 +586,12 @@ bool FunctionDecl::isExternGNUInline(ASTContext &Context) const {
return false;
}
-void
+void
FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
redeclarable_base::setPreviousDeclaration(PrevDecl);
if (FunctionTemplateDecl *FunTmpl = getDescribedFunctionTemplate()) {
- FunctionTemplateDecl *PrevFunTmpl
+ FunctionTemplateDecl *PrevFunTmpl
= PrevDecl? PrevDecl->getDescribedFunctionTemplate() : 0;
assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch");
FunTmpl->setPreviousDeclaration(PrevFunTmpl);
@@ -612,7 +612,7 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
}
FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
- if (FunctionTemplateSpecializationInfo *Info
+ if (FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization
.dyn_cast<FunctionTemplateSpecializationInfo*>()) {
return Info->Template.getPointer();
@@ -622,7 +622,7 @@ FunctionTemplateDecl *FunctionDecl::getPrimaryTemplate() const {
const TemplateArgumentList *
FunctionDecl::getTemplateSpecializationArgs() const {
- if (FunctionTemplateSpecializationInfo *Info
+ if (FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization
.dyn_cast<FunctionTemplateSpecializationInfo*>()) {
return Info->TemplateArguments;
@@ -630,53 +630,53 @@ FunctionDecl::getTemplateSpecializationArgs() const {
return 0;
}
-void
+void
FunctionDecl::setFunctionTemplateSpecialization(ASTContext &Context,
FunctionTemplateDecl *Template,
const TemplateArgumentList *TemplateArgs,
void *InsertPos) {
- FunctionTemplateSpecializationInfo *Info
+ FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
if (!Info)
Info = new (Context) FunctionTemplateSpecializationInfo;
-
+
Info->Function = this;
Info->Template.setPointer(Template);
Info->Template.setInt(TSK_ImplicitInstantiation - 1);
Info->TemplateArguments = TemplateArgs;
TemplateOrSpecialization = Info;
-
+
// Insert this function template specialization into the set of known
// function template specialiations.
Template->getSpecializations().InsertNode(Info, InsertPos);
}
TemplateSpecializationKind FunctionDecl::getTemplateSpecializationKind() const {
- // For a function template specialization, query the specialization
+ // For a function template specialization, query the specialization
// information object.
- FunctionTemplateSpecializationInfo *Info
+ FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
if (Info)
return Info->getTemplateSpecializationKind();
-
+
if (!getInstantiatedFromMemberFunction())
return TSK_Undeclared;
-
+
// Find the class template specialization corresponding to this instantiation
// of a member function.
const DeclContext *Parent = getDeclContext();
while (Parent && !isa<ClassTemplateSpecializationDecl>(Parent))
Parent = Parent->getParent();
-
+
if (!Parent)
return TSK_Undeclared;
return cast<ClassTemplateSpecializationDecl>(Parent)->getSpecializationKind();
}
-void
+void
FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
- FunctionTemplateSpecializationInfo *Info
+ FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
assert(Info && "Not a function template specialization");
Info->setTemplateSpecializationKind(TSK);
@@ -714,12 +714,12 @@ void TagDecl::completeDefinition() {
TagDecl* TagDecl::getDefinition(ASTContext& C) const {
if (isDefinition())
return const_cast<TagDecl *>(this);
-
- for (redecl_iterator R = redecls_begin(), REnd = redecls_end();
+
+ for (redecl_iterator R = redecls_begin(), REnd = redecls_end();
R != REnd; ++R)
if (R->isDefinition())
return *R;
-
+
return 0;
}
@@ -750,7 +750,7 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
SourceLocation TKL, RecordDecl* PrevDecl) {
-
+
RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id, PrevDecl, TKL);
C.getTypeDeclType(R, PrevDecl);
return R;
@@ -764,7 +764,7 @@ void RecordDecl::Destroy(ASTContext& C) {
}
bool RecordDecl::isInjectedClassName() const {
- return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
+ return isImplicit() && getDeclName() && getDeclContext()->isRecord() &&
cast<RecordDecl>(getDeclContext())->getDeclName() == getDeclName();
}
@@ -788,15 +788,15 @@ void BlockDecl::Destroy(ASTContext& C) {
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
(*I)->Destroy(C);
-
- C.Deallocate(ParamInfo);
+
+ C.Deallocate(ParamInfo);
Decl::Destroy(C);
}
void BlockDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
unsigned NParms) {
assert(ParamInfo == 0 && "Already has param info!");
-
+
// Zero params -> null pointer.
if (NParms) {
NumParams = NParms;
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index acdbdbe422..34bc2b97e3 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -62,12 +62,12 @@ bool Decl::CollectingStats(bool Enable) {
void Decl::PrintStats() {
fprintf(stderr, "*** Decl Stats:\n");
-
+
int totalDecls = 0;
#define DECL(Derived, Base) totalDecls += n##Derived##s;
#include "clang/AST/DeclNodes.def"
fprintf(stderr, " %d decls total.\n", totalDecls);
-
+
int totalBytes = 0;
#define DECL(Derived, Base) \
if (n##Derived##s > 0) { \
@@ -77,7 +77,7 @@ void Decl::PrintStats() {
(int)(n##Derived##s * sizeof(Derived##Decl))); \
}
#include "clang/AST/DeclNodes.def"
-
+
fprintf(stderr, "Total bytes = %d\n", totalBytes);
}
@@ -92,26 +92,26 @@ void Decl::addDeclKind(Kind k) {
bool Decl::isTemplateParameterPack() const {
if (const TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(this))
return TTP->isParameterPack();
-
+
return false;
}
bool Decl::isFunctionOrFunctionTemplate() const {
if (const UsingDecl *UD = dyn_cast<UsingDecl>(this))
return UD->getTargetDecl()->isFunctionOrFunctionTemplate();
-
+
return isa<FunctionDecl>(this) || isa<FunctionTemplateDecl>(this);
}
//===----------------------------------------------------------------------===//
// PrettyStackTraceDecl Implementation
//===----------------------------------------------------------------------===//
-
+
void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const {
SourceLocation TheLoc = Loc;
if (TheLoc.isInvalid() && TheDecl)
TheLoc = TheDecl->getLocation();
-
+
if (TheLoc.isValid()) {
TheLoc.print(OS, SM);
OS << ": ";
@@ -123,7 +123,7 @@ void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const {
OS << " '" << DN->getQualifiedNameAsString() << '\'';
OS << '\n';
}
-
+
//===----------------------------------------------------------------------===//
// Decl Implementation
//===----------------------------------------------------------------------===//
@@ -132,14 +132,14 @@ void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const {
Decl::~Decl() {
if (isOutOfSemaDC())
delete getMultipleDC();
-
+
assert(!HasAttrs && "attributes should have been freed by Destroy");
}
void Decl::setDeclContext(DeclContext *DC) {
if (isOutOfSemaDC())
delete getMultipleDC();
-
+
DeclCtx = DC;
}
@@ -163,22 +163,22 @@ TranslationUnitDecl *Decl::getTranslationUnitDecl() {
DeclContext *DC = getDeclContext();
assert(DC && "This decl is not contained in a translation unit!");
-
+
while (!DC->isTranslationUnit()) {
DC = DC->getParent();
assert(DC && "This decl is not contained in a translation unit!");
}
-
+
return cast<TranslationUnitDecl>(DC);
}
ASTContext &Decl::getASTContext() const {
- return getTranslationUnitDecl()->getASTContext();
+ return getTranslationUnitDecl()->getASTContext();
}
unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
switch (DeclKind) {
- default:
+ default:
if (DeclKind >= FunctionFirst && DeclKind <= FunctionLast)
return IDNS_Ordinary;
assert(0 && "Unknown decl kind!");
@@ -202,7 +202,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
case ObjCProtocol:
return IDNS_ObjCProtocol;
-
+
case ObjCImplementation:
return IDNS_ObjCImplementation;
@@ -213,13 +213,13 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
case ObjCAtDefsField:
case ObjCIvar:
return IDNS_Member;
-
+
case Record:
case CXXRecord:
case Enum:
case TemplateTypeParm:
return IDNS_Tag;
-
+
case Namespace:
case Template:
case FunctionTemplate:
@@ -227,7 +227,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) {
case TemplateTemplateParm:
case NamespaceAlias:
return IDNS_Tag | IDNS_Ordinary;
-
+
// Never have names.
case Friend:
case LinkageSpec:
@@ -252,41 +252,41 @@ void Decl::addAttr(Attr *NewAttr) {
NewAttr->setNext(ExistingAttr);
ExistingAttr = NewAttr;
-
+
HasAttrs = true;
}
void Decl::invalidateAttrs() {
if (!HasAttrs) return;
-
+
HasAttrs = false;
getASTContext().eraseDeclAttrs(this);
}
const Attr *Decl::getAttrsImpl() const {
- assert(HasAttrs && "getAttrs() should verify this!");
+ assert(HasAttrs && "getAttrs() should verify this!");
return getASTContext().getDeclAttrs(this);
}
void Decl::swapAttrs(Decl *RHS) {
bool HasLHSAttr = this->HasAttrs;
bool HasRHSAttr = RHS->HasAttrs;
-
+
// Usually, neither decl has attrs, nothing to do.
if (!HasLHSAttr && !HasRHSAttr) return;
-
+
// If 'this' has no attrs, swap the other way.
if (!HasLHSAttr)
return RHS->swapAttrs(this);
-
+
ASTContext &Context = getASTContext();
-
+
// Handle the case when both decls have attrs.
if (HasRHSAttr) {
std::swap(Context.getDeclAttrs(this), Context.getDeclAttrs(RHS));
return;
}
-
+
// Otherwise, LHS has an attr and RHS doesn't.
Context.getDeclAttrs(RHS) = Context.getDeclAttrs(this);
Context.eraseDeclAttrs(this);
@@ -302,7 +302,7 @@ void Decl::Destroy(ASTContext &C) {
invalidateAttrs();
HasAttrs = false;
}
-
+
#if 0
// FIXME: Once ownership is fully understood, we can enable this code
if (DeclContext *DC = dyn_cast<DeclContext>(this))
@@ -311,15 +311,15 @@ void Decl::Destroy(ASTContext &C) {
// Observe the unrolled recursion. By setting N->NextDeclInContext = 0x0
// within the loop, only the Destroy method for the first Decl
// will deallocate all of the Decls in a chain.
-
+
Decl* N = getNextDeclInContext();
-
+
while (N) {
Decl* Tmp = N->getNextDeclInContext();
N->NextDeclInContext = 0;
N->Destroy(C);
N = Tmp;
- }
+ }
this->~Decl();
C.Deallocate((void *)this);
@@ -384,8 +384,8 @@ void Decl::CheckAccessDeclContext() const {
if (isa<TranslationUnitDecl>(this) ||
!isa<CXXRecordDecl>(getDeclContext()))
return;
-
- assert(Access != AS_none &&
+
+ assert(Access != AS_none &&
"Access specifier is AS_none inside a record decl");
}
@@ -434,7 +434,7 @@ bool DeclContext::isDependentContext() const {
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(this))
if (Function->getDescribedFunctionTemplate())
return true;
-
+
return getParent() && getParent()->isDependentContext();
}
@@ -454,18 +454,18 @@ bool DeclContext::isTransparentContext() const {
bool DeclContext::Encloses(DeclContext *DC) {
if (getPrimaryContext() != this)
return getPrimaryContext()->Encloses(DC);
-
+
for (; DC; DC = DC->getParent())
if (DC->getPrimaryContext() == this)
return true;
- return false;
+ return false;
}
DeclContext *DeclContext::getPrimaryContext() {
switch (DeclKind) {
case Decl::TranslationUnit:
case Decl::LinkageSpec:
- case Decl::Block:
+ case Decl::Block:
// There is only one DeclContext for these entities.
return this;
@@ -491,7 +491,7 @@ DeclContext *DeclContext::getPrimaryContext() {
// If this is a tag type that has a definition or is currently
// being defined, that definition is our primary context.
if (const TagType *TagT =cast<TagDecl>(this)->TypeForDecl->getAs<TagType>())
- if (TagT->isBeingDefined() ||
+ if (TagT->isBeingDefined() ||
(TagT->getDecl() && TagT->getDecl()->isDefinition()))
return TagT->getDecl();
return this;
@@ -516,13 +516,13 @@ DeclContext *DeclContext::getNextContext() {
/// \brief Load the declarations within this lexical storage from an
/// external source.
-void
+void
DeclContext::LoadLexicalDeclsFromExternalStorage() const {
ExternalASTSource *Source = getParentASTContext().getExternalSource();
assert(hasExternalLexicalStorage() && Source && "No external storage?");
llvm::SmallVector<uint32_t, 64> Decls;
- if (Source->ReadDeclsLexicallyInContext(const_cast<DeclContext *>(this),
+ if (Source->ReadDeclsLexicallyInContext(const_cast<DeclContext *>(this),
Decls))
return;
@@ -554,7 +554,7 @@ DeclContext::LoadLexicalDeclsFromExternalStorage() const {
LastDecl = PrevDecl;
}
-void
+void
DeclContext::LoadVisibleDeclsFromExternalStorage() const {
DeclContext *This = const_cast<DeclContext *>(this);
ExternalASTSource *Source = getParentASTContext().getExternalSource();
@@ -583,14 +583,14 @@ DeclContext::decl_iterator DeclContext::decls_begin() const {
// FIXME: Check whether we need to load some declarations from
// external storage.
- return decl_iterator(FirstDecl);
+ return decl_iterator(FirstDecl);
}
DeclContext::decl_iterator DeclContext::decls_end() const {
if (hasExternalLexicalStorage())
LoadLexicalDeclsFromExternalStorage();
- return decl_iterator();
+ return decl_iterator();
}
bool DeclContext::decls_empty() const {
@@ -603,7 +603,7 @@ bool DeclContext::decls_empty() const {
void DeclContext::addHiddenDecl(Decl *D) {
assert(D->getLexicalDeclContext() == this &&
"Decl inserted into wrong lexical context");
- assert(!D->getNextDeclInContext() && D != LastDecl &&
+ assert(!D->getNextDeclInContext() && D != LastDecl &&
"Decl already inserted into a DeclContext");
if (FirstDecl) {
@@ -626,8 +626,8 @@ void DeclContext::addDecl(Decl *D) {
/// transparent contexts nested within it).
void DeclContext::buildLookup(DeclContext *DCtx) {
for (; DCtx; DCtx = DCtx->getNextContext()) {
- for (decl_iterator D = DCtx->decls_begin(),
- DEnd = DCtx->decls_end();
+ for (decl_iterator D = DCtx->decls_begin(),
+ DEnd = DCtx->decls_end();
D != DEnd; ++D) {
// Insert this declaration into the lookup structure, but only
// if it's semantically in its decl context. During non-lazy
@@ -645,7 +645,7 @@ void DeclContext::buildLookup(DeclContext *DCtx) {
}
}
-DeclContext::lookup_result
+DeclContext::lookup_result
DeclContext::lookup(DeclarationName Name) {
DeclContext *PrimaryContext = getPrimaryContext();
if (PrimaryContext != this)
@@ -671,7 +671,7 @@ DeclContext::lookup(DeclarationName Name) {
return Pos->second.getLookupResult(getParentASTContext());
}
-DeclContext::lookup_const_result
+DeclContext::lookup_const_result
DeclContext::lookup(DeclarationName Name) const {
return const_cast<DeclContext*>(this)->lookup(Name);
}
@@ -744,14 +744,14 @@ void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D) {
// one, just replace it and return.
if (DeclNameEntries.HandleRedeclaration(getParentASTContext(), D))
return;
-
+
// Put this declaration into the appropriate slot.
DeclNameEntries.AddSubsequentDecl(D);
}
/// Returns iterator range [First, Last) of UsingDirectiveDecls stored within
/// this context.
-DeclContext::udir_iterator_range
+DeclContext::udir_iterator_range
DeclContext::getUsingDirectives() const {
lookup_const_result Result = lookup(UsingDirectiveDecl::getName());
return udir_iterator_range(reinterpret_cast<udir_iterator>(Result.first),
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 155005a100..e8f97a383d 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -26,7 +26,7 @@ using namespace clang;
CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
CXXRecordDecl *PrevDecl,
- SourceLocation TKL)
+ SourceLocation TKL)
: RecordDecl(K, TK, DC, L, Id, PrevDecl, TKL),
UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false),
UserDeclaredCopyAssignment(false), UserDeclaredDestructor(false),
@@ -42,12 +42,12 @@ CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation TKL,
CXXRecordDecl* PrevDecl,
bool DelayTypeCreation) {
- CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id,
+ CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id,
PrevDecl, TKL);
-
+
// FIXME: DelayTypeCreation seems like such a hack
if (!DelayTypeCreation)
- C.getTypeDeclType(R, PrevDecl);
+ C.getTypeDeclType(R, PrevDecl);
return R;
}
@@ -60,22 +60,22 @@ void CXXRecordDecl::Destroy(ASTContext &C) {
this->RecordDecl::Destroy(C);
}
-void
+void
CXXRecordDecl::setBases(ASTContext &C,
- CXXBaseSpecifier const * const *Bases,
+ CXXBaseSpecifier const * const *Bases,
unsigned NumBases) {
- // C++ [dcl.init.aggr]p1:
+ // C++ [dcl.init.aggr]p1:
// An aggregate is an array or a class (clause 9) with [...]
// no base classes [...].
Aggregate = false;
if (this->Bases)
C.Deallocate(this->Bases);
-
+
int vbaseCount = 0;
llvm::SmallVector<const CXXBaseSpecifier*, 8> UniqueVbases;
bool hasDirectVirtualBase = false;
-
+
this->Bases = new(C) CXXBaseSpecifier [NumBases];
this->NumBases = NumBases;
for (unsigned i = 0; i < NumBases; ++i) {
@@ -83,7 +83,7 @@ CXXRecordDecl::setBases(ASTContext &C,
// Keep track of inherited vbases for this base class.
const CXXBaseSpecifier *Base = Bases[i];
QualType BaseType = Base->getType();
- // Skip template types.
+ // Skip template types.
// FIXME. This means that this list must be rebuilt during template
// instantiation.
if (BaseType->isDependentType())
@@ -92,10 +92,10 @@ CXXRecordDecl::setBases(ASTContext &C,
= cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
if (Base->isVirtual())
hasDirectVirtualBase = true;
- for (CXXRecordDecl::base_class_iterator VBase =
+ for (CXXRecordDecl::base_class_iterator VBase =
BaseClassDecl->vbases_begin(),
E = BaseClassDecl->vbases_end(); VBase != E; ++VBase) {
- // Add this vbase to the array of vbases for current class if it is
+ // Add this vbase to the array of vbases for current class if it is
// not already in the list.
// FIXME. Note that we do a linear search as number of such classes are
// very few.
@@ -134,7 +134,7 @@ CXXRecordDecl::setBases(ASTContext &C,
QualType QT = UniqueVbases[i]->getType();
CXXRecordDecl *VBaseClassDecl
= cast<CXXRecordDecl>(QT->getAs<RecordType>()->getDecl());
- this->VBases[i] =
+ this->VBases[i] =
CXXBaseSpecifier(VBaseClassDecl->getSourceRange(), true,
VBaseClassDecl->getTagKind() == RecordDecl::TK_class,
UniqueVbases[i]->getAccessSpecifier(), QT);
@@ -146,11 +146,11 @@ bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const {
return getCopyConstructor(Context, QualType::Const) != 0;
}
-CXXConstructorDecl *CXXRecordDecl::getCopyConstructor(ASTContext &Context,
+CXXConstructorDecl *CXXRecordDecl::getCopyConstructor(ASTContext &Context,
unsigned TypeQuals) const{
QualType ClassType
= Context.getTypeDeclType(const_cast<CXXRecordDecl*>(this));
- DeclarationName ConstructorName
+ DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType));
unsigned FoundTQs;
@@ -162,12 +162,12 @@ CXXConstructorDecl *CXXRecordDecl::getCopyConstructor(ASTContext &Context,
if (isa<FunctionTemplateDecl>(*Con))
continue;
- if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context,
+ if (cast<CXXConstructorDecl>(*Con)->isCopyConstructor(Context,
FoundTQs)) {
if (((TypeQuals & QualType::Const) == (FoundTQs & QualType::Const)) ||
(!(TypeQuals & QualType::Const) && (FoundTQs & QualType::Const)))
return cast<CXXConstructorDecl>(*Con);
-
+
}
}
return 0;
@@ -217,13 +217,13 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context,
}
void
-CXXRecordDecl::addedConstructor(ASTContext &Context,
+CXXRecordDecl::addedConstructor(ASTContext &Context,
CXXConstructorDecl *ConDecl) {
assert(!ConDecl->isImplicit() && "addedConstructor - not for implicit decl");
// Note that we have a user-declared constructor.
UserDeclaredConstructor = true;
- // C++ [dcl.init.aggr]p1:
+ // C++ [dcl.init.aggr]p1:
// An aggregate is an array or a class (clause 9) with no
// user-declared constructors (12.1) [...].
Aggregate = false;
@@ -237,7 +237,7 @@ CXXRecordDecl::addedConstructor(ASTContext &Context,
// constructor.
// FIXME: C++0x: don't do this for "= default" default constructors.
HasTrivialConstructor = false;
-
+
// Note when we have a user-declared copy constructor, which will
// suppress the implicit declaration of a copy constructor.
if (ConDecl->isCopyConstructor(Context)) {
@@ -282,14 +282,14 @@ void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
PlainOldData = false;
}
-void CXXRecordDecl::addConversionFunction(ASTContext &Context,
+void CXXRecordDecl::addConversionFunction(ASTContext &Context,
CXXConversionDecl *ConvDecl) {
assert(!ConvDecl->getDescribedFunctionTemplate() &&
"Conversion function templates should cast to FunctionTemplateDecl.");
Conversions.addOverload(ConvDecl);
}
-void CXXRecordDecl::addConversionFunction(ASTContext &Context,
+void CXXRecordDecl::addConversionFunction(ASTContext &Context,
FunctionTemplateDecl *ConvDecl) {
assert(isa<CXXConversionDecl>(ConvDecl->getTemplatedDecl()) &&
"Function template is not a conversion function template");
@@ -302,7 +302,7 @@ CXXRecordDecl::getDefaultConstructor(ASTContext &Context) {
DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType.getUnqualifiedType()));
-
+
DeclContext::lookup_const_iterator Con, ConEnd;
for (llvm::tie(Con, ConEnd) = lookup(ConstructorName);
Con != ConEnd; ++Con) {
@@ -320,18 +320,18 @@ CXXRecordDecl::getDefaultConstructor(ASTContext &Context) {
const CXXDestructorDecl *
CXXRecordDecl::getDestructor(ASTContext &Context) {
QualType ClassType = Context.getTypeDeclType(this);
-
- DeclarationName Name
+
+ DeclarationName Name
= Context.DeclarationNames.getCXXDestructorName(
Context.getCanonicalType(ClassType));
DeclContext::lookup_iterator I, E;
- llvm::tie(I, E) = lookup(Name);
+ llvm::tie(I, E) = lookup(Name);
assert(I != E && "Did not find a destructor!");
-
+
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(*I);
assert(++I == E && "Found more than one destructor!");
-
+
return Dtor;
}
@@ -345,8 +345,8 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
}
-typedef llvm::DenseMap<const CXXMethodDecl*,
- std::vector<const CXXMethodDecl *> *>
+typedef llvm::DenseMap<const CXXMethodDecl*,
+ std::vector<const CXXMethodDecl *> *>
OverriddenMethodsMapTy;
// FIXME: We hate static data. This doesn't survive PCH saving/loading, and
@@ -355,21 +355,21 @@ static OverriddenMethodsMapTy *OverriddenMethods = 0;
void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) {
// FIXME: The CXXMethodDecl dtor needs to remove and free the entry.
-
+
if (!OverriddenMethods)
OverriddenMethods = new OverriddenMethodsMapTy();
-
+
std::vector<const CXXMethodDecl *> *&Methods = (*OverriddenMethods)[this];
if (!Methods)
Methods = new std::vector<const CXXMethodDecl *>;
-
+
Methods->push_back(MD);
}
CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const {
if (!OverriddenMethods)
return 0;
-
+
OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
if (it == OverriddenMethods->end() || it->second->empty())
return 0;
@@ -380,7 +380,7 @@ CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const {
CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {
if (!OverriddenMethods)
return 0;
-
+
OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this);
if (it == OverriddenMethods->end() || it->second->empty())
return 0;
@@ -409,12 +409,12 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const {
CXXBaseOrMemberInitializer::
CXXBaseOrMemberInitializer(QualType BaseType, Expr **Args, unsigned NumArgs,
CXXConstructorDecl *C,
- SourceLocation L, SourceLocation R)
+ SourceLocation L, SourceLocation R)
: Args(0), NumArgs(0), CtorOrAnonUnion(), IdLoc(L), RParenLoc(R) {
BaseOrMember = reinterpret_cast<uintptr_t>(BaseType.getTypePtr());
assert((BaseOrMember & 0x01) == 0 && "Invalid base class type pointer");
BaseOrMember |= 0x01;
-
+
if (NumArgs > 0) {
this->NumArgs = NumArgs;
// FIXME. Allocation via Context
@@ -431,7 +431,7 @@ CXXBaseOrMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs,
SourceLocation L, SourceLocation R)
: Args(0), NumArgs(0), CtorOrAnonUnion(), IdLoc(L), RParenLoc(R) {
BaseOrMember = reinterpret_cast<uintptr_t>(Member);
- assert((BaseOrMember & 0x01) == 0 && "Invalid member pointer");
+ assert((BaseOrMember & 0x01) == 0 && "Invalid member pointer");
if (NumArgs > 0) {
this->NumArgs = NumArgs;
@@ -466,8 +466,8 @@ bool CXXConstructorDecl::isDefaultConstructor() const {
(getNumParams() > 0 && getParamDecl(0)->hasDefaultArg());
}
-bool
-CXXConstructorDecl::isCopyConstructor(ASTContext &Context,
+bool
+CXXConstructorDecl::isCopyConstructor(ASTContext &Context,
unsigned &TypeQuals) const {
// C++ [class.copy]p2:
// A non-template constructor for class X is a copy constructor
@@ -508,7 +508,7 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
if (isExplicit() && !AllowExplicit)
return false;
- return (getNumParams() == 0 &&
+ return (getNumParams() == 0 &&
getType()->getAsFunctionProtoType()->isVariadic()) ||
(getNumParams() == 1) ||
(getNumParams() > 1 && getParamDecl(1)->hasDefaultArg());
@@ -517,11 +517,11 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
CXXDestructorDecl *
CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, DeclarationName N,
- QualType T, bool isInline,
+ QualType T, bool isInline,
bool isImplicitlyDeclared) {
assert(N.getNameKind() == DeclarationName::CXXDestructorName &&
"Name must refer to a destructor");
- return new (C) CXXDestructorDecl(RD, L, N, T, isInline,
+ return new (C) CXXDestructorDecl(RD, L, N, T, isInline,
isImplicitlyDeclared);
}
@@ -556,7 +556,7 @@ OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
OverloadIterator::OverloadIterator(NamedDecl *ND) : D(0) {
if (!ND)
return;
-
+
if (isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND))
D = ND;
else if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(ND)) {
@@ -575,10 +575,10 @@ void OverloadedFunctionDecl::addOverload(AnyFunctionDecl F) {
OverloadIterator::reference OverloadIterator::operator*() const {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
return FD;
-
+
if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D))
return FTD;
-
+
assert(isa<OverloadedFunctionDecl>(D));
return *Iter;
}
@@ -588,20 +588,20 @@ OverloadIterator &OverloadIterator::operator++() {
D = 0;
return *this;
}
-
+
if (++Iter == cast<OverloadedFunctionDecl>(D)->function_end())
D = 0;
-
+
return *this;
}
bool OverloadIterator::Equals(const OverloadIterator &Other) const {
if (!D || !Other.D)
return D == Other.D;
-
+
if (D != Other.D)
return false;
-
+
return !isa<OverloadedFunctionDecl>(D) || Iter == Other.Iter;
}
@@ -621,10 +621,10 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
#endif
return new (C) FriendDecl(DC, L, Friend, FriendL);
-}
+}
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
- DeclContext *DC,
+ DeclContext *DC,
SourceLocation L,
LanguageIDs Lang, bool Braces) {
return new (C) LinkageSpecDecl(DC, L, Lang, Braces);
@@ -638,19 +638,19 @@ UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation IdentLoc,
NamespaceDecl *Used,
DeclContext *CommonAncestor) {
- return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierRange,
+ return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierRange,
Qualifier, IdentLoc, Used, CommonAncestor);
}
-NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
- SourceLocation AliasLoc,
- IdentifierInfo *Alias,
+NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L,
+ SourceLocation AliasLoc,
+ IdentifierInfo *Alias,
SourceRange QualifierRange,
NestedNameSpecifier *Qualifier,
- SourceLocation IdentLoc,
+ SourceLocation IdentLoc,
NamedDecl *Namespace) {
- return new (C) NamespaceAliasDecl(DC, L, AliasLoc, Alias, QualifierRange,
+ return new (C) NamespaceAliasDecl(DC, L, AliasLoc, Alias, QualifierRange,
Qualifier, IdentLoc, Namespace);
}
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index ee2b81560d..d6e4b2c44b 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -30,8 +30,8 @@ void ObjCListBase::Destroy(ASTContext &Ctx) {
void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
assert(List == 0 && "Elements already set!");
if (Elts == 0) return; // Setting to an empty list is a noop.
-
-
+
+
List = new (Ctx) void*[Elts];
NumElts = Elts;
memcpy(List, InList, sizeof(void*)*Elts);
@@ -83,15 +83,15 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
for (prop_iterator I = prop_begin(), E = prop_end(); I != E; ++I)
if ((*I)->getIdentifier() == PropertyId)
return *I;
-
+
const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this);
if (PID) {
- for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
+ for (ObjCProtocolDecl::protocol_iterator I = PID->protocol_begin(),
E = PID->protocol_end(); I != E; ++I)
if (ObjCPropertyDecl *P = (*I)->FindPropertyDeclaration(PropertyId))
return P;
}
-
+
if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this)) {
// Look through categories.
for (ObjCCategoryDecl *Category = OID->getCategoryList();
@@ -151,11 +151,11 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
bool isInstance) const {
const ObjCInterfaceDecl* ClassDecl = this;
ObjCMethodDecl *MethodDecl = 0;
-
+
while (ClassDecl != NULL) {
if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
return MethodDecl;
-
+
// Didn't find one yet - look through protocols.
const ObjCList<ObjCProtocolDecl> &Protocols =
ClassDecl->getReferencedProtocols();
@@ -163,13 +163,13 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
E = Protocols.end(); I != E; ++I)
if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
return MethodDecl;
-
+
// Didn't find one yet - now look through categories.
ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
while (CatDecl) {
if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
return MethodDecl;
-
+
// Didn't find one yet - look through protocols.
const ObjCList<ObjCProtocolDecl> &Protocols =
CatDecl->getReferencedProtocols();
@@ -191,7 +191,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
//===----------------------------------------------------------------------===//
ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
- SourceLocation beginLoc,
+ SourceLocation beginLoc,
SourceLocation endLoc,
Selector SelInfo, QualType T,
DeclContext *contextDecl,
@@ -201,14 +201,14 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
ImplementationControl impControl) {
return new (C) ObjCMethodDecl(beginLoc, endLoc,
SelInfo, T, contextDecl,
- isInstance,
+ isInstance,
isVariadic, isSynthesized, impControl);
}
void ObjCMethodDecl::Destroy(ASTContext &C) {
if (Body) Body->Destroy(C);
if (SelfDecl) SelfDecl->Destroy(C);
-
+
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
if (*I) (*I)->Destroy(C);
@@ -267,7 +267,7 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
return this;
}
-void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
+void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
const ObjCInterfaceDecl *OID) {
QualType selfTy;
if (isInstanceMethod()) {
@@ -282,11 +282,11 @@ void ObjCMethodDecl::createImplicitParams(ASTContext &Context,
} else // we have a factory method.
selfTy = Context.getObjCClassType();
- setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
+ setSelfDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
&Context.Idents.get("self"), selfTy));
- setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
- &Context.Idents.get("_cmd"),
+ setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
+ &Context.Idents.get("_cmd"),
Context.getObjCSelType()));
}
@@ -310,7 +310,7 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
DeclContext *DC,
SourceLocation atLoc,
- IdentifierInfo *Id,
+ IdentifierInfo *Id,
SourceLocation ClassLoc,
bool ForwardDecl, bool isInternal){
return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
@@ -326,13 +326,13 @@ ObjCInterfaceDecl(DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id,
ClassLoc(CLoc) {
}
-void ObjCInterfaceDecl::Destroy(ASTContext &C) {
+void ObjCInterfaceDecl::Destroy(ASTContext &C) {
for (ivar_iterator I = ivar_begin(), E = ivar_end(); I != E; ++I)
if (*I) (*I)->Destroy(C);
-
+
IVars.Destroy(C);
// FIXME: CategoryList?
-
+
// FIXME: Because there is no clear ownership
// role between ObjCInterfaceDecls and the ObjCPropertyDecls that they
// reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
@@ -391,7 +391,7 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
// 1st, look up the class.
const ObjCList<ObjCProtocolDecl> &Protocols =
IDecl->getReferencedProtocols();
-
+
for (ObjCList<ObjCProtocolDecl>::iterator PI = Protocols.begin(),
E = Protocols.end(); PI != E; ++PI) {
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
@@ -402,11 +402,11 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
// object. This IMO, should be a bug.
// FIXME: Treat this as an extension, and flag this as an error when GCC
// extensions are not enabled.
- if (RHSIsQualifiedID &&
+ if (RHSIsQualifiedID &&
getASTContext().ProtocolCompatibleWithProtocol(*PI, lProto))
return true;
}
-
+
// 2nd, look up the category.
if (lookupCategory)
for (ObjCCategoryDecl *CDecl = IDecl->getCategoryList(); CDecl;
@@ -416,13 +416,13 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
if (getASTContext().ProtocolCompatibleWithProtocol(lProto, *PI))
return true;
}
-
+
// 3rd, look up the super class(s)
if (IDecl->getSuperClass())
return
IDecl->getSuperClass()->ClassImplementsProtocol(lProto, lookupCategory,
RHSIsQualifiedID);
-
+
return false;
}
@@ -451,7 +451,7 @@ ObjCAtDefsFieldDecl
void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
this->~ObjCAtDefsFieldDecl();
- C.Deallocate((void *)this);
+ C.Deallocate((void *)this);
}
//===----------------------------------------------------------------------===//
@@ -459,7 +459,7 @@ void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
//===----------------------------------------------------------------------===//
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+ SourceLocation L,
IdentifierInfo *Id) {
return new (C) ObjCProtocolDecl(DC, L, Id);
}
@@ -478,7 +478,7 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
if ((PDecl = (*I)->lookupProtocolNamed(Name)))
return PDecl;
-
+
return NULL;
}
@@ -487,10 +487,10 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
bool isInstance) const {
ObjCMethodDecl *MethodDecl = NULL;
-
+
if ((MethodDecl = getMethod(Sel, isInstance)))
return MethodDecl;
-
+
for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
return MethodDecl;
@@ -501,7 +501,7 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
// ObjCClassDecl
//===----------------------------------------------------------------------===//
-ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L,
+ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L,
ObjCInterfaceDecl *const *Elts, unsigned nElts,
ASTContext &C)
: Decl(ObjCClass, DC, L) {
@@ -517,7 +517,7 @@ ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
}
void ObjCClassDecl::Destroy(ASTContext &C) {
-
+
// FIXME: There is no clear ownership policy now for referenced
// ObjCInterfaceDecls. Some of them can be forward declarations that
// are never later defined (in which case the ObjCClassDecl owns them)
@@ -525,7 +525,7 @@ void ObjCClassDecl::Destroy(ASTContext &C) {
// we should have separate objects for forward declarations and definitions,
// obviating this problem. Because of this situation, referenced
// ObjCInterfaceDecls are destroyed in ~TranslationUnit.
-
+
ForwardDecls.Destroy(C);
Decl::Destroy(C);
}
@@ -538,14 +538,14 @@ ObjCForwardProtocolDecl::
ObjCForwardProtocolDecl(DeclContext *DC, SourceLocation L,
ObjCProtocolDecl *const *Elts, unsigned nElts,
ASTContext &C)
-: Decl(ObjCForwardProtocol, DC, L) {
+: Decl(ObjCForwardProtocol, DC, L) {
ReferencedProtocols.set(Elts, nElts, C);
}
ObjCForwardProtocolDecl *
ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC,
- SourceLocation L,
+ SourceLocation L,
ObjCProtocolDecl *const *Elts,
unsigned NumElts) {
return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts, C);
@@ -649,7 +649,7 @@ FindPropertyImplDecl(IdentifierInfo *Id) const {
//===----------------------------------------------------------------------===//
ObjCImplementationDecl *
-ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
+ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
ObjCInterfaceDecl *ClassInterface,
ObjCInterfaceDecl *SuperDecl) {
@@ -663,7 +663,7 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
ObjCCompatibleAliasDecl *
ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
- IdentifierInfo *Id,
+ IdentifierInfo *Id,
ObjCInterfaceDecl* AliasedClass) {
return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
}
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index 275fa69723..8aae742ef1 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -34,9 +34,9 @@ namespace {
void ProcessDeclGroup(llvm::SmallVectorImpl<Decl*>& Decls);
void Print(AccessSpecifier AS);
-
+
public:
- DeclPrinter(llvm::raw_ostream &Out, ASTContext &Context,
+ DeclPrinter(llvm::raw_ostream &Out, ASTContext &Context,
const PrintingPolicy &Policy,
unsigned Indentation = 0)
: Out(Out), Context(Context), Policy(Policy), Indentation(Indentation) { }
@@ -186,7 +186,7 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
bool PrintAccess = isa<CXXRecordDecl>(DC);
AccessSpecifier CurAS = AS_none;
-
+
llvm::SmallVector<Decl*, 2> Decls;
for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
D != DEnd; ++D) {
@@ -209,7 +209,7 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
CurAS = AS;
}
}
-
+
// The next bits of code handles stuff like "struct {int x;} a,b"; we're
// forced to merge the declarations because there's no other way to
// refer to the struct in question. This limited merging is safe without
@@ -240,16 +240,16 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
}
this->Indent();
Visit(*D);
-
- // FIXME: Need to be able to tell the DeclPrinter when
+
+ // FIXME: Need to be able to tell the DeclPrinter when
const char *Terminator = 0;
- if (isa<FunctionDecl>(*D) &&
+ if (isa<FunctionDecl>(*D) &&
cast<FunctionDecl>(*D)->isThisDeclarationADefinition())
Terminator = 0;
else if (isa<ObjCMethodDecl>(*D) && cast<ObjCMethodDecl>(*D)->getBody())
Terminator = 0;
else if (isa<NamespaceDecl>(*D) || isa<LinkageSpecDecl>(*D) ||
- isa<ObjCImplementationDecl>(*D) ||
+ isa<ObjCImplementationDecl>(*D) ||
isa<ObjCInterfaceDecl>(*D) ||
isa<ObjCProtocolDecl>(*D) ||
isa<ObjCCategoryImplDecl>(*D) ||
@@ -299,7 +299,7 @@ void DeclPrinter::VisitRecordDecl(RecordDecl *D) {
Out << " ";
Out << D->getNameAsString();
}
-
+
if (D->isDefinition()) {
Out << " {\n";
VisitDeclContext(D);
@@ -315,7 +315,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) {
}
}
-void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
if (!Policy.SuppressSpecifiers) {
switch (D->getStorageClass()) {
case FunctionDecl::None: break;
@@ -346,7 +346,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
if (i) POut << ", ";
ParamPrinter.VisitParmVarDecl(D->getParamDecl(i));
}
-
+
if (FT->isVariadic()) {
if (D->getNumParams()) POut << ", ";
POut << "...";
@@ -367,29 +367,29 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
Proto += " : ";
Out << Proto;
Proto.clear();
- for (CXXConstructorDecl::init_const_iterator B = CDecl->init_begin(),
+ for (CXXConstructorDecl::init_const_iterator B = CDecl->init_begin(),
E = CDecl->init_end();
B != E; ++B) {
CXXBaseOrMemberInitializer * BMInitializer = (*B);
if (B != CDecl->init_begin())
Out << ", ";
- bool hasArguments = (BMInitializer->arg_begin() !=
+ bool hasArguments = (BMInitializer->arg_begin() !=
BMInitializer->arg_end());
if (BMInitializer->isMemberInitializer()) {
FieldDecl *FD = BMInitializer->getMember();
Out << FD->getNameAsString();
}
else // FIXME. skip dependent types for now.
- if (const RecordType *RT =
+ if (const RecordType *RT =
BMInitializer->getBaseClass()->getAs<RecordType>()) {
- const CXXRecordDecl *BaseDecl =
+ const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(RT->getDecl());
Out << BaseDecl->getNameAsString();
}
if (hasArguments) {
Out << "(";
- for (CXXBaseOrMemberInitializer::const_arg_iterator BE =
- BMInitializer->const_arg_begin(),
+ for (CXXBaseOrMemberInitializer::const_arg_iterator BE =
+ BMInitializer->const_arg_begin(),
EE = BMInitializer->const_arg_end(); BE != EE; ++BE) {
if (BE != BMInitializer->const_arg_begin())
Out<< ", ";
@@ -407,7 +407,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
// List order of base/member destruction for visualization purposes.
assert (D->isThisDeclarationADefinition() && "Destructor with dtor-list");
Proto += "/* : ";
- for (CXXDestructorDecl::destr_const_iterator *B = DDecl->destr_begin(),
+ for (CXXDestructorDecl::destr_const_iterator *B = DDecl->destr_begin(),
*E = DDecl->destr_end();
B != E; ++B) {
uintptr_t BaseOrMember = (*B);
@@ -420,10 +420,10 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
Proto += FD->getNameAsString();
}
else // FIXME. skip dependent types for now.
- if (const RecordType *RT =
+ if (const RecordType *RT =
DDecl->getAnyBaseClassToDestroy(BaseOrMember)
->getAs<RecordType>()) {
- const CXXRecordDecl *BaseDecl =
+ const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(RT->getDecl());
Proto += "~";
Proto += BaseDecl->getNameAsString();
@@ -522,7 +522,7 @@ void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
// C++ declarations
//----------------------------------------------------------------------------
void DeclPrinter::VisitOverloadedFunctionDecl(OverloadedFunctionDecl *D) {
- assert(false &&
+ assert(false &&
"OverloadedFunctionDecls aren't really decls and are never printed");
}
@@ -552,14 +552,13 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
Out << " ";
Out << D->getNameAsString();
}
-
+
if (D->isDefinition()) {
// Print the base classes
if (D->getNumBases()) {
Out << " : ";
- for(CXXRecordDecl::base_class_iterator Base = D->bases_begin(),
- BaseEnd = D->bases_end();
- Base != BaseEnd; ++Base) {
+ for (CXXRecordDecl::base_class_iterator Base = D->bases_begin(),
+ BaseEnd = D->bases_end(); Base != BaseEnd; ++Base) {
if (Base != D->bases_begin())
Out << ", ";
@@ -578,7 +577,7 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
Out << " {\n";
VisitDeclContext(D);
Indent() << "}";
- }
+ }
}
void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
@@ -602,17 +601,17 @@ void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
Out << "template <";
-
+
TemplateParameterList *Params = D->getTemplateParameters();
for (unsigned i = 0, e = Params->size(); i != e; ++i) {
if (i != 0)
Out << ", ";
-
+
const Decl *Param = Params->getParam(i);
- if (const TemplateTypeParmDecl *TTP =
+ if (const TemplateTypeParmDecl *TTP =
dyn_cast<TemplateTypeParmDecl>(Param)) {
-
- QualType ParamType =
+
+ QualType ParamType =
Context.getTypeDeclType(const_cast<TemplateTypeParmDecl*>(TTP));
if (TTP->wasDeclaredWithTypename())
@@ -622,14 +621,14 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
if (TTP->isParameterPack())
Out << "... ";
-
+
Out << ParamType.getAsString(Policy);
if (TTP->hasDefaultArgument()) {
Out << " = ";
Out << TTP->getDefaultArgument().getAsString(Policy);
};
- } else if (const NonTypeTemplateParmDecl *NTTP =
+ } else if (const NonTypeTemplateParmDecl *NTTP =
dyn_cast<NonTypeTemplateParmDecl>(Param)) {
Out << NTTP->getType().getAsString(Policy);
@@ -637,15 +636,15 @@ void DeclPrinter::VisitTemplateDecl(TemplateDecl *D) {
Out << ' ';
Out << Name->getName();
}
-
+
if (NTTP->hasDefaultArgument()) {
Out << " = ";
- NTTP->getDefaultArgument()->printPretty(Out, Context, 0, Policy,
+ NTTP->getDefaultArgument()->printPretty(Out, Context, 0, Policy,
Indentation);
}
}
}
-
+
Out << "> ";
Visit(D->getTemplatedDecl());
@@ -667,29 +666,29 @@ void DeclPrinter::VisitObjCClassDecl(ObjCClassDecl *D) {
void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
if (OMD->isInstanceMethod())
Out << "- ";
- else
+ else
Out << "+ ";
if (!OMD->getResultType().isNull())
Out << '(' << OMD->getResultType().getAsString(Policy) << ")";
-
+
std::string name = OMD->getSelector().getAsString();
std::string::size_type pos, lastPos = 0;
for (ObjCMethodDecl::param_iterator PI = OMD->param_begin(),
E = OMD->param_end(); PI != E; ++PI) {
- // FIXME: selector is missing here!
+ // FIXME: selector is missing here!
pos = name.find_first_of(":", lastPos);
Out << " " << name.substr(lastPos, pos - lastPos);
Out << ":(" << (*PI)->getType().getAsString(Policy) << ")"
- << (*PI)->getNameAsString();
+ << (*PI)->getNameAsString();
lastPos = pos + 1;
}
-
+
if (OMD->param_begin() == OMD->param_end())
Out << " " << name;
-
+
if (OMD->isVariadic())
Out << ", ...";
-
+
if (OMD->getBody()) {
Out << ' ';
OMD->getBody()->printPretty(Out, Context, 0, Policy);
@@ -718,7 +717,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
Out << "@interface " << I << " : " << SID->getNameAsString();
else
Out << "@interface " << I;
-
+
// Protocols?
const ObjCList<ObjCProtocolDecl> &Protocols = OID->getReferencedProtocols();
if (!Protocols.empty()) {
@@ -726,22 +725,22 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
E = Protocols.end(); I != E; ++I)
Out << (I == Protocols.begin() ? '<' : ',') << (*I)->getNameAsString();
}
-
+
if (!Protocols.empty())
Out << "> ";
-
+
if (OID->ivar_size() > 0) {
Out << "{\n";
Indentation += Policy.Indentation;
for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(),
E = OID->ivar_end(); I != E; ++I) {
Indent() << (*I)->getType().getAsString(Policy)
- << ' ' << (*I)->getNameAsString() << ";\n";
+ << ' ' << (*I)->getNameAsString() << ";\n";
}
Indentation -= Policy.Indentation;
Out << "}\n";
}
-
+
VisitDeclContext(OID, false);
Out << "@end";
// FIXME: implement the rest...
@@ -749,7 +748,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
void DeclPrinter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
Out << "@protocol ";
- for (ObjCForwardProtocolDecl::protocol_iterator I = D->protocol_begin(),
+ for (ObjCForwardProtocolDecl::protocol_iterator I = D->protocol_begin(),
E = D->protocol_end();
I != E; ++I) {
if (I != D->protocol_begin()) Out << ", ";
@@ -766,7 +765,7 @@ void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) {
void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
Out << "@implementation "
<< PID->getClassInterface()->getNameAsString()
- << '(' << PID->getNameAsString() << ")\n";
+ << '(' << PID->getNameAsString() << ")\n";
VisitDeclContext(PID, false);
Out << "@end";
@@ -774,18 +773,18 @@ void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) {
}
void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) {
- Out << "@interface "
+ Out << "@interface "
<< PID->getClassInterface()->getNameAsString()
<< '(' << PID->getNameAsString() << ")\n";
VisitDeclContext(PID, false);
Out << "@end";
-
+
// FIXME: implement the rest...
}
void DeclPrinter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID) {
- Out << "@compatibility_alias " << AID->getNameAsString()
- << ' ' << AID->getClassInterface()->getNameAsString() << ";\n";
+ Out << "@compatibility_alias " << AID->getNameAsString()
+ << ' ' << AID->getClassInterface()->getNameAsString() << ";\n";
}
/// PrintObjCPropertyDecl - print a property declaration.
@@ -795,17 +794,17 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
Out << "@required\n";
else if (PDecl->getPropertyImplementation() == ObjCPropertyDecl::Optional)
Out << "@optional\n";
-
+
Out << "@property";
if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
bool first = true;
Out << " (";
- if (PDecl->getPropertyAttributes() &
+ if (PDecl->getPropertyAttributes() &
ObjCPropertyDecl::OBJC_PR_readonly) {
Out << (first ? ' ' : ',') << "readonly";
first = false;
}
-
+
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
Out << (first ? ' ' : ',') << "getter = "
<< PDecl->getGetterName().getAsString();
@@ -816,29 +815,29 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
<< PDecl->getSetterName().getAsString();
first = false;
}
-
+
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_assign) {
Out << (first ? ' ' : ',') << "assign";
first = false;
}
-
+
if (PDecl->getPropertyAttributes() &
ObjCPropertyDecl::OBJC_PR_readwrite) {
Out << (first ? ' ' : ',') << "readwrite";
first = false;
}
-
+
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain) {
Out << (first ? ' ' : ',') << "retain";
first = false;
}
-
+
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy) {
Out << (first ? ' ' : ',') << "copy";
first = false;
}
-
- if (PDecl->getPropertyAttributes() &
+
+ if (PDecl->getPropertyAttributes() &
ObjCPropertyDecl::OBJC_PR_nonatomic) {
Out << (first ? ' ' : ',') << "nonatomic";
first = false;
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 08e53eb088..b46f6275d3 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -40,26 +40,26 @@ TemplateParameterList::Create(ASTContext &C, SourceLocation TemplateLoc,
unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams;
unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment;
void *Mem = C.Allocate(Size, Align);
- return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params,
+ return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params,
NumParams, RAngleLoc);
}
unsigned TemplateParameterList::getMinRequiredArguments() const {
unsigned NumRequiredArgs = size();
- iterator Param = const_cast<TemplateParameterList *>(this)->end(),
+ iterator Param = const_cast<TemplateParameterList *>(this)->end(),
ParamBegin = const_cast<TemplateParameterList *>(this)->begin();
while (Param != ParamBegin) {
--Param;
-
+
if (!(*Param)->isTemplateParameterPack() &&
- !(isa<TemplateTypeParmDecl>(*Param) &&
+ !(isa<TemplateTypeParmDecl>(*Param) &&
cast<TemplateTypeParmDecl>(*Param)->hasDefaultArgument()) &&
!(isa<NonTypeTemplateParmDecl>(*Param) &&
cast<NonTypeTemplateParmDecl>(*Param)->hasDefaultArgument()) &&
!(isa<TemplateTemplateParmDecl>(*Param) &&
cast<TemplateTemplateParmDecl>(*Param)->hasDefaultArgument()))
break;
-
+
--NumRequiredArgs;
}
@@ -94,7 +94,7 @@ void FunctionTemplateDecl::Destroy(ASTContext &C) {
Spec != SpecEnd; ++Spec)
C.Deallocate(&*Spec);
}
-
+
Decl::Destroy(C);
}
@@ -110,7 +110,7 @@ FunctionTemplateDecl::Common *FunctionTemplateDecl::getCommonPtr() {
FunctionTemplateDecl *First = this;
while (First->getPreviousDeclaration())
First = First->getPreviousDeclaration();
-
+
if (First->CommonOrPrev.isNull()) {
// FIXME: Allocate with the ASTContext
First->CommonOrPrev = new Common;
@@ -142,7 +142,7 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C,
else
CommonPtr = new (C) Common;
- return new (C) ClassTemplateDecl(DC, L, Name, Params, Decl, PrevDecl,
+ return new (C) ClassTemplateDecl(DC, L, Name, Params, Decl, PrevDecl,
CommonPtr);
}
@@ -172,7 +172,7 @@ ClassTemplateDecl::findPartialSpecialization(QualType T) {
if (Context.hasSameType(Context.getTypeDeclType(&*P), T))
return &*P;
}
-
+
return 0;
}
@@ -188,21 +188,21 @@ QualType ClassTemplateDecl::getInjectedClassNameType(ASTContext &Context) {
TemplateParameterList *Params = getTemplateParameters();
llvm::SmallVector<TemplateArgument, 16> TemplateArgs;
TemplateArgs.reserve(Params->size());
- for (TemplateParameterList::iterator Param = Params->begin(),
- ParamEnd = Params->end();
+ for (TemplateParameterList::iterator Param = Params->begin(),
+ ParamEnd = Params->end();
Param != ParamEnd; ++Param) {
if (isa<TemplateTypeParmDecl>(*Param)) {
QualType ParamType = Context.getTypeDeclType(cast<TypeDecl>(*Param));
- TemplateArgs.push_back(TemplateArgument((*Param)->getLocation(),
+ TemplateArgs.push_back(TemplateArgument((*Param)->getLocation(),
ParamType));
- } else if (NonTypeTemplateParmDecl *NTTP =
+ } else if (NonTypeTemplateParmDecl *NTTP =
dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
Expr *E = new (Context) DeclRefExpr(NTTP, NTTP->getType(),
NTTP->getLocation(),
NTTP->getType()->isDependentType(),
/*Value-dependent=*/true);
TemplateArgs.push_back(TemplateArgument(E));
- } else {
+ } else {
TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*Param);
TemplateArgs.push_back(TemplateArgument(TTP->getLocation(), TTP));
}
@@ -242,7 +242,7 @@ NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation NonTypeTemplateParmDecl::getDefaultArgumentLoc() const {
return DefaultArgument? DefaultArgument->getSourceRange().getBegin()
- : SourceLocation();
+ : SourceLocation();
}
//===----------------------------------------------------------------------===//
@@ -259,7 +259,7 @@ TemplateTemplateParmDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation TemplateTemplateParmDecl::getDefaultArgumentLoc() const {
return DefaultArgument? DefaultArgument->getSourceRange().getBegin()
- : SourceLocation();
+ : SourceLocation();
}
//===----------------------------------------------------------------------===//
@@ -272,10 +272,10 @@ TemplateArgument::TemplateArgument(Expr *E) : Kind(Expression) {
}
/// \brief Construct a template argument pack.
-void TemplateArgument::setArgumentPack(TemplateArgument *args, unsigned NumArgs,
+void TemplateArgument::setArgumentPack(TemplateArgument *args, unsigned NumArgs,
bool CopyArgs) {
assert(isNull() && "Must call setArgumentPack on a null argument");
-
+
Kind = Pack;
Args.NumArgs = NumArgs;
Args.CopyArgs = CopyArgs;
@@ -283,7 +283,7 @@ void TemplateArgument::setArgumentPack(TemplateArgument *args, unsigned NumArgs,
Args.Args = args;
return;
}
-
+
// FIXME: Allocate in ASTContext
Args.Args = new TemplateArgument[NumArgs];
for (unsigned I = 0; I != Args.NumArgs; ++I)
@@ -301,21 +301,21 @@ void TemplateArgumentListBuilder::Append(const TemplateArgument& Arg) {
assert(Arg.getAsType()->isCanonical() && "Type must be canonical!");
break;
}
-
+
assert(NumFlatArgs < MaxFlatArgs && "Argument list builder is full!");
- assert(!StructuredArgs &&
+ assert(!StructuredArgs &&
"Can't append arguments when an argument pack has been added!");
-
+
if (!FlatArgs)
FlatArgs = new TemplateArgument[MaxFlatArgs];
-
+
FlatArgs[NumFlatArgs++] = Arg;
}
void TemplateArgumentListBuilder::BeginPack() {
assert(!AddingToPack && "Already adding to pack!");
assert(!StructuredArgs && "Argument list already contains a pack!");
-
+
AddingToPack = true;
PackBeginIndex = NumFlatArgs;
}
@@ -323,24 +323,24 @@ void TemplateArgumentListBuilder::BeginPack() {
void TemplateArgumentListBuilder::EndPack() {
assert(AddingToPack && "Not adding to pack!");
assert(!StructuredArgs && "Argument list already contains a pack!");
-
+
AddingToPack = false;
StructuredArgs = new TemplateArgument[MaxStructuredArgs];
-
+
// First copy the flat entries over to the list (if any)
for (unsigned I = 0; I != PackBeginIndex; ++I) {
NumStructuredArgs++;
StructuredArgs[I] = FlatArgs[I];
}
-
+
// Next, set the pack.
TemplateArgument *PackArgs = 0;
unsigned NumPackArgs = NumFlatArgs - PackBeginIndex;
if (NumPackArgs)
PackArgs = &FlatArgs[PackBeginIndex];
-
- StructuredArgs[NumStructuredArgs++].setArgumentPack(PackArgs, NumPackArgs,
+
+ StructuredArgs[NumStructuredArgs++].setArgumentPack(PackArgs, NumPackArgs,
/*CopyArgs=*/false);
}
@@ -359,14 +359,14 @@ void TemplateArgumentListBuilder::ReleaseArgs() {
TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
TemplateArgumentListBuilder &Builder,
bool TakeArgs)
- : FlatArguments(Builder.getFlatArguments(), TakeArgs),
- NumFlatArguments(Builder.flatSize()),
+ : FlatArguments(Builder.getFlatArguments(), TakeArgs),
+ NumFlatArguments(Builder.flatSize()),
StructuredArguments(Builder.getStructuredArguments(), TakeArgs),
NumStructuredArguments(Builder.structuredSize()) {
-
+
if (!TakeArgs)
return;
-
+
if (Builder.getStructuredArguments() == Builder.getFlatArguments())
StructuredArguments.setInt(0);
Builder.ReleaseArgs();
@@ -385,8 +385,8 @@ ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK,
ClassTemplateDecl *SpecializedTemplate,
TemplateArgumentListBuilder &Builder,
ClassTemplateSpecializationDecl *PrevDecl)
- : CXXRecordDecl(DK,
- SpecializedTemplate->getTemplatedDecl()->getTagKind(),
+ : CXXRecordDecl(DK,
+ SpecializedTemplate->getTemplatedDecl()->getTagKind(),
DC, L,
// FIXME: Should we use DeclarationName for the name of
// class template specializations?
@@ -396,17 +396,17 @@ ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK,
TemplateArgs(Context, Builder, /*TakeArgs=*/true),
SpecializationKind(TSK_Undeclared) {
}
-
+
ClassTemplateSpecializationDecl *
-ClassTemplateSpecializationDecl::Create(ASTContext &Context,
+ClassTemplateSpecializationDecl::Create(ASTContext &Context,
DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
TemplateArgumentListBuilder &Builder,
ClassTemplateSpecializationDecl *PrevDecl) {
ClassTemplateSpecializationDecl *Result
- = new (Context)ClassTemplateSpecializationDecl(Context,
+ = new (Context)ClassTemplateSpecializationDecl(Context,
ClassTemplateSpecialization,
- DC, L,
+ DC, L,
SpecializedTemplate,
Builder,
PrevDecl);
@@ -415,16 +415,16 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context,
}
void ClassTemplateSpecializationDecl::Destroy(ASTContext &C) {
- if (SpecializedPartialSpecialization *PartialSpec
+ if (SpecializedPartialSpecialization *PartialSpec
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
C.Deallocate(PartialSpec);
-
+
CXXRecordDecl::Destroy(C);
}
ClassTemplateDecl *
-ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
- if (SpecializedPartialSpecialization *PartialSpec
+ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
+ if (SpecializedPartialSpecialization *PartialSpec
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
return PartialSpec->PartialSpecialization->getSpecializedTemplate();
return SpecializedTemplate.get<ClassTemplateDecl*>();
@@ -441,7 +441,7 @@ Create(ASTContext &Context, DeclContext *DC, SourceLocation L,
TemplateArgumentListBuilder &Builder,
ClassTemplatePartialSpecializationDecl *PrevDecl) {
ClassTemplatePartialSpecializationDecl *Result
- = new (Context)ClassTemplatePartialSpecializationDecl(Context,
+ = new (Context)ClassTemplatePartialSpecializationDecl(Context,
DC, L, Params,
SpecializedTemplate,
Builder, PrevDecl);
diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp
index da9f01a9aa..a01a89201a 100644
--- a/lib/AST/DeclarationName.cpp
+++ b/lib/AST/DeclarationName.cpp
@@ -23,7 +23,7 @@ namespace clang {
/// CXXSpecialName - Records the type associated with one of the
/// "special" kinds of declaration names in C++, e.g., constructors,
/// destructors, and conversion functions.
-class CXXSpecialName
+class CXXSpecialName
: public DeclarationNameExtra, public llvm::FoldingSetNode {
public:
/// Type - The type associated with this declaration name.
@@ -40,7 +40,7 @@ public:
};
/// CXXOperatorIdName - Contains extra information for the name of an
-/// overloaded operator in C++, such as "operator+.
+/// overloaded operator in C++, such as "operator+.
class CXXOperatorIdName : public DeclarationNameExtra {
public:
/// FETokenInfo - Extra information associated with this operator
@@ -93,13 +93,13 @@ DeclarationName::NameKind DeclarationName::getNameKind() const {
case StoredDeclarationNameExtra:
switch (getExtra()->ExtraKindOrNumArgs) {
- case DeclarationNameExtra::CXXConstructor:
+ case DeclarationNameExtra::CXXConstructor:
return CXXConstructorName;
- case DeclarationNameExtra::CXXDestructor:
+ case DeclarationNameExtra::CXXDestructor:
return CXXDestructorName;
- case DeclarationNameExtra::CXXConversionFunction:
+ case DeclarationNameExtra::CXXConversionFunction:
return CXXConversionFunctionName;
case DeclarationNameExtra::CXXUsingDirective:
@@ -107,7 +107,7 @@ DeclarationName::NameKind DeclarationName::getNameKind() const {
default:
// Check if we have one of the CXXOperator* enumeration values.
- if (getExtra()->ExtraKindOrNumArgs <
+ if (getExtra()->ExtraKindOrNumArgs <
DeclarationNameExtra::CXXUsingDirective)
return CXXOperatorName;
@@ -159,7 +159,7 @@ std::string DeclarationName::getAsString() const {
};
const char *OpName = OperatorNames[getCXXOverloadedOperator()];
assert(OpName && "not an overloaded operator");
-
+
std::string Result = "operator";
if (OpName[0] >= 'a' && OpName[0] <= 'z')
Result += ' ';
@@ -193,7 +193,7 @@ QualType DeclarationName::getCXXNameType() const {
OverloadedOperatorKind DeclarationName::getCXXOverloadedOperator() const {
if (CXXOperatorIdName *CXXOp = getAsCXXOperatorIdName()) {
- unsigned value
+ unsigned value
= CXXOp->ExtraKindOrNumArgs - DeclarationNameExtra::CXXConversionFunction;
return static_cast<OverloadedOperatorKind>(value);
} else {
@@ -276,7 +276,7 @@ DeclarationNameTable::DeclarationNameTable() {
// Initialize the overloaded operator names.
CXXOperatorNames = new CXXOperatorIdName[NUM_OVERLOADED_OPERATORS];
for (unsigned Op = 0; Op < NUM_OVERLOADED_OPERATORS; ++Op) {
- CXXOperatorNames[Op].ExtraKindOrNumArgs
+ CXXOperatorNames[Op].ExtraKindOrNumArgs
= Op + DeclarationNameExtra::CXXConversionFunction;
CXXOperatorNames[Op].FETokenInfo = 0;
}
@@ -296,18 +296,18 @@ DeclarationNameTable::~DeclarationNameTable() {
delete [] CXXOperatorNames;
}
-DeclarationName
-DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
+DeclarationName
+DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
CanQualType Ty) {
assert(Kind >= DeclarationName::CXXConstructorName &&
Kind <= DeclarationName::CXXConversionFunctionName &&
"Kind must be a C++ special name kind");
- llvm::FoldingSet<CXXSpecialName> *SpecialNames
+ llvm::FoldingSet<CXXSpecialName> *SpecialNames
= static_cast<llvm::FoldingSet<CXXSpecialName>*>(CXXSpecialNamesImpl);
DeclarationNameExtra::ExtraKind EKind;
switch (Kind) {
- case DeclarationName::CXXConstructorName:
+ case DeclarationName::CXXConstructorName:
EKind = DeclarationNameExtra::CXXConstructor;
assert(Ty.getCVRQualifiers() == 0 &&"Constructor type must be unqualified");
break;
@@ -340,12 +340,12 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
return DeclarationName(SpecialName);
}
-DeclarationName
+DeclarationName
DeclarationNameTable::getCXXOperatorName(OverloadedOperatorKind Op) {
return DeclarationName(&CXXOperatorNames[(unsigned)Op]);
}
-unsigned
+unsigned
llvm::DenseMapInfo<clang::DeclarationName>::
getHashValue(clang::DeclarationName N) {
return DenseMapInfo<void*>::getHashValue(N.getAsOpaquePtr());
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 013a9418f1..a90b9984d4 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -120,7 +120,7 @@ double FloatingLiteral::getValueAsApproximateDouble() const {
StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
unsigned ByteLength, bool Wide,
QualType Ty,
- const SourceLocation *Loc,
+ const SourceLocation *Loc,
unsigned NumStrs) {
// Allocate enough space for the StringLiteral plus an array of locations for
// any concatenated string tokens.
@@ -128,7 +128,7 @@ StringLiteral *StringLiteral::Create(ASTContext &C, const char *StrData,
sizeof(SourceLocation)*(NumStrs-1),
llvm::alignof<StringLiteral>());
StringLiteral *SL = new (Mem) StringLiteral(Ty);
-
+
// OPTIMIZE: could allocate this appended to the StringLiteral.
char *AStrData = new (C, 1) char[ByteLength];
memcpy(AStrData, StrData, ByteLength);
@@ -191,7 +191,7 @@ const char *UnaryOperator::getOpcodeStr(Opcode Op) {
}
}
-UnaryOperator::Opcode
+UnaryOperator::Opcode
UnaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix) {
switch (OO) {
default: assert(false && "No unary operator for overloaded function");
@@ -227,11 +227,11 @@ OverloadedOperatorKind UnaryOperator::getOverloadedOperator(Opcode Opc) {
CallExpr::CallExpr(ASTContext& C, StmtClass SC, Expr *fn, Expr **args,
unsigned numargs, QualType t, SourceLocation rparenloc)
- : Expr(SC, t,
+ : Expr(SC, t,
fn->isTypeDependent() || hasAnyTypeDependentArguments(args, numargs),
fn->isValueDependent() || hasAnyValueDependentArguments(args,numargs)),
NumArgs(numargs) {
-
+
SubExprs = new (C) Stmt*[numargs+1];
SubExprs[FN] = fn;
for (unsigned i = 0; i != numargs; ++i)
@@ -255,8 +255,8 @@ CallExpr::CallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs,
RParenLoc = rparenloc;
}
-CallExpr::CallExpr(ASTContext &C, StmtClass SC, EmptyShell Empty)
- : Expr(SC, Empty), SubExprs(0), NumArgs(0) {
+CallExpr::CallExpr(ASTContext &C, StmtClass SC, EmptyShell Empty)
+ : Expr(SC, Empty), SubExprs(0), NumArgs(0) {
SubExprs = new (C) Stmt*[1];
}
@@ -281,7 +281,7 @@ FunctionDecl *CallExpr::getDirectCallee() {
void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) {
// No change, just return.
if (NumArgs == getNumArgs()) return;
-
+
// If shrinking # arguments, just delete the extras and forgot them.
if (NumArgs < getNumArgs()) {
for (unsigned i = NumArgs, e = getNumArgs(); i != e; ++i)
@@ -298,7 +298,7 @@ void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) {
// Null out new args.
for (unsigned i = getNumArgs()+ARGS_START; i != NumArgs+ARGS_START; ++i)
NewSubExprs[i] = 0;
-
+
if (SubExprs) C.Deallocate(SubExprs);
SubExprs = NewSubExprs;
this->NumArgs = NumArgs;
@@ -308,20 +308,20 @@ void CallExpr::setNumArgs(ASTContext& C, unsigned NumArgs) {
/// not, return 0.
unsigned CallExpr::isBuiltinCall(ASTContext &Context) const {
// All simple function calls (e.g. func()) are implicitly cast to pointer to
- // function. As a result, we try and obtain the DeclRefExpr from the
+ // function. As a result, we try and obtain the DeclRefExpr from the
// ImplicitCastExpr.
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(getCallee());
if (!ICE) // FIXME: deal with more complex calls (e.g. (func)(), (*func)()).
return 0;
-
+
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
if (!DRE)
return 0;
-
+
const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());
if (!FDecl)
return 0;
-
+
if (!FDecl->getIdentifier())
return 0;
@@ -334,18 +334,18 @@ QualType CallExpr::getCallReturnType() const {
CalleeType = FnTypePtr->getPointeeType();
else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>())
CalleeType = BPT->getPointeeType();
-
+
const FunctionType *FnType = CalleeType->getAsFunctionType();
return FnType->getResultType();
}
-MemberExpr::MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual,
- SourceRange qualrange, NamedDecl *memberdecl,
+MemberExpr::MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual,
+ SourceRange qualrange, NamedDecl *memberdecl,
SourceLocation l, bool has_explicit,
SourceLocation langle,
const TemplateArgument *targs, unsigned numtargs,
SourceLocation rangle, QualType ty)
- : Expr(MemberExprClass, ty,
+ : Expr(MemberExprClass, ty,
base->isTypeDependent() || (qual && qual->isDependent()),
base->isValueDependent() || (qual && qual->isDependent())),
Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow),
@@ -356,26 +356,26 @@ MemberExpr::MemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *qual,
NQ->NNS = qual;
NQ->Range = qualrange;
}
-
+
// Initialize the explicit template argument list, if any.
if (HasExplicitTemplateArgumentList) {
- ExplicitTemplateArgumentList *ETemplateArgs
+ ExplicitTemplateArgumentList *ETemplateArgs
= getExplicitTemplateArgumentList();
ETemplateArgs->LAngleLoc = langle;
ETemplateArgs->RAngleLoc = rangle;
ETemplateArgs->NumTemplateArgs = numtargs;
-
+
TemplateArgument *TemplateArgs = ETemplateArgs->getTemplateArgs();
for (unsigned I = 0; I < numtargs; ++I)
- new (TemplateArgs + I) TemplateArgument(targs[I]);
+ new (TemplateArgs + I) TemplateArgument(targs[I]);
}
}
-MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
- NestedNameSpecifier *qual,
+MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
+ NestedNameSpecifier *qual,
SourceRange qualrange,
- NamedDecl *memberdecl,
- SourceLocation l,
+ NamedDecl *memberdecl,
+ SourceLocation l,
bool has_explicit,
SourceLocation langle,
const TemplateArgument *targs,
@@ -385,11 +385,11 @@ MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow,
std::size_t Size = sizeof(MemberExpr);
if (qual != 0)
Size += sizeof(NameQualifier);
-
+
if (has_explicit)
- Size += sizeof(ExplicitTemplateArgumentList) +
+ Size += sizeof(ExplicitTemplateArgumentList) +
sizeof(TemplateArgument) * numtargs;
-
+
void *Mem = C.Allocate(Size, llvm::alignof<MemberExpr>());
return new (Mem) MemberExpr(base, isarrow, qual, qualrange, memberdecl, l,
has_explicit, langle, targs, numtargs, rangle,
@@ -423,7 +423,7 @@ const char *CastExpr::getCastKindName() const {
case CastExpr::CK_ConstructorConversion:
return "ConstructorConversion";
}
-
+
assert(0 && "Unhandled cast kind!");
return 0;
}
@@ -469,7 +469,7 @@ const char *BinaryOperator::getOpcodeStr(Opcode Op) {
return "";
}
-BinaryOperator::Opcode
+BinaryOperator::Opcode
BinaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO) {
switch (OO) {
default: assert(false && "Not an overloadable binary operator");
@@ -531,13 +531,13 @@ OverloadedOperatorKind BinaryOperator::getOverloadedOperator(Opcode Opc) {
return OverOps[Opc];
}
-InitListExpr::InitListExpr(SourceLocation lbraceloc,
+InitListExpr::InitListExpr(SourceLocation lbraceloc,
Expr **initExprs, unsigned numInits,
SourceLocation rbraceloc)
: Expr(InitListExprClass, QualType(),
hasAnyTypeDependentArguments(initExprs, numInits),
hasAnyValueDependentArguments(initExprs, numInits)),
- LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), SyntacticForm(0),
+ LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), SyntacticForm(0),
UnionFieldInit(0), HadArrayRangeDesignator(false) {
InitExprs.insert(InitExprs.end(), initExprs, initExprs+numInits);
@@ -561,7 +561,7 @@ Expr *InitListExpr::updateInit(unsigned Init, Expr *expr) {
InitExprs.back() = expr;
return 0;
}
-
+
Expr *Result = cast_or_null<Expr>(InitExprs[Init]);
InitExprs[Init] = expr;
return Result;
@@ -574,14 +574,14 @@ const FunctionType *BlockExpr::getFunctionType() const {
getPointeeType()->getAsFunctionType();
}
-SourceLocation BlockExpr::getCaretLocation() const {
- return TheBlock->getCaretLocation();
+SourceLocation BlockExpr::getCaretLocation() const {
+ return TheBlock->getCaretLocation();
}
-const Stmt *BlockExpr::getBody() const {
+const Stmt *BlockExpr::getBody() const {
return TheBlock->getBody();
}
-Stmt *BlockExpr::getBody() {
- return TheBlock->getBody();
+Stmt *BlockExpr::getBody() {
+ return TheBlock->getBody();
}
@@ -599,7 +599,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
// instantiating to void.
if (isTypeDependent())
return false;
-
+
switch (getStmtClass()) {
default:
Loc = getExprLoc();
@@ -610,7 +610,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
isUnusedResultAWarning(Loc, R1, R2);
case UnaryOperatorClass: {
const UnaryOperator *UO = cast<UnaryOperator>(this);
-
+
switch (UO->getOpcode()) {
default: break;
case UnaryOperator::PostInc:
@@ -642,7 +642,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
if (BO->getOpcode() == BinaryOperator::Comma)
return BO->getRHS()->isUnusedResultAWarning(Loc, R1, R2) ||
BO->getLHS()->isUnusedResultAWarning(Loc, R1, R2);
-
+
if (BO->isAssignmentOp())
return false;
Loc = BO->getOperatorLoc();
@@ -657,7 +657,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
// The condition must be evaluated, but if either the LHS or RHS is a
// warning, warn about them.
const ConditionalOperator *Exp = cast<ConditionalOperator>(this);
- if (Exp->getLHS() &&
+ if (Exp->getLHS() &&
Exp->getLHS()->isUnusedResultAWarning(Loc, R1, R2))
return true;
return Exp->getRHS()->isUnusedResultAWarning(Loc, R1, R2);
@@ -672,7 +672,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
R1 = SourceRange(Loc, Loc);
R2 = cast<MemberExpr>(this)->getBase()->getSourceRange();
return true;
-
+
case ArraySubscriptExprClass:
// If the base pointer or element is to a volatile pointer/field, accessing
// it is a side effect.
@@ -697,7 +697,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
FD->getAttr<PureAttr>() || FD->getAttr<ConstAttr>()) {
Loc = CE->getCallee()->getLocStart();
R1 = CE->getCallee()->getSourceRange();
-
+
if (unsigned NumArgs = CE->getNumArgs())
R2 = SourceRange(CE->getArg(0)->getLocStart(),
CE->getArg(NumArgs-1)->getLocEnd());
@@ -708,10 +708,10 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
}
case ObjCMessageExprClass:
return false;
-
+
case ObjCImplicitSetterGetterRefExprClass: { // Dot syntax for message send.
#if 0
- const ObjCImplicitSetterGetterRefExpr *Ref =
+ const ObjCImplicitSetterGetterRefExpr *Ref =
cast<ObjCImplicitSetterGetterRefExpr>(this);
// FIXME: We really want the location of the '.' here.
Loc = Ref->getLocation();
@@ -734,7 +734,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
if (!CS->body_empty())
if (const Expr *E = dyn_cast<Expr>(CS->body_back()))
return E->isUnusedResultAWarning(Loc, R1, R2);
-
+
Loc = cast<StmtExpr>(this)->getLParenLoc();
R1 = getSourceRange();
return true;
@@ -756,7 +756,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
Loc = cast<CXXFunctionalCastExpr>(this)->getTypeBeginLoc();
R1 = cast<CXXFunctionalCastExpr>(this)->getSubExpr()->getSourceRange();
return true;
-
+
case ImplicitCastExprClass:
// Check the operand, since implicit casts are inserted by Sema
return cast<ImplicitCastExpr>(this)
@@ -785,7 +785,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
static bool DeclCanBeLvalue(const NamedDecl *Decl, ASTContext &Ctx) {
// C++ [temp.param]p6:
// A non-type non-reference template-parameter is not an lvalue.
- if (const NonTypeTemplateParmDecl *NTTParm
+ if (const NonTypeTemplateParmDecl *NTTParm
= dyn_cast<NonTypeTemplateParmDecl>(Decl))
return NTTParm->getType()->isReferenceType();
@@ -838,7 +838,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
if (cast<ArraySubscriptExpr>(this)->getBase()->getType()->isVectorType())
return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue(Ctx);
return LV_Valid;
- case DeclRefExprClass:
+ case DeclRefExprClass:
case QualifiedDeclRefExprClass: { // C99 6.5.1p2
const NamedDecl *RefdDecl = cast<DeclRefExpr>(this)->getDecl();
if (DeclCanBeLvalue(RefdDecl, Ctx))
@@ -885,7 +885,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
// Not an lvalue.
return LV_InvalidExpression;
- }
+ }
// C99 6.5.2.3p4
return m->isArrow() ? LV_Valid : m->getBase()->isLvalue(Ctx);
@@ -905,7 +905,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
return LV_Valid;
break;
case ImplicitCastExprClass:
- return cast<ImplicitCastExpr>(this)->isLvalueCast()? LV_Valid
+ return cast<ImplicitCastExpr>(this)->isLvalueCast()? LV_Valid
: LV_InvalidExpression;
case ParenExprClass: // C99 6.5.1p5
return cast<ParenExpr>(this)->getSubExpr()->isLvalue(Ctx);
@@ -927,7 +927,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
return LV_InvalidExpression;
if (Ctx.getLangOptions().CPlusPlus)
- // C++ [expr.ass]p1:
+ // C++ [expr.ass]p1:
// The result of an assignment operation [...] is an lvalue.
return LV_Valid;
@@ -936,7 +936,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
// An assignment expression [...] is not an lvalue.
return LV_InvalidExpression;
}
- case CallExprClass:
+ case CallExprClass:
case CXXOperatorCallExprClass:
case CXXMemberCallExprClass: {
// C++0x [expr.call]p10
@@ -1023,15 +1023,15 @@ Expr::isLvalueResult Expr::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,
+/// if it is a structure or union, does not have any member (including,
/// recursively, any member or element of all contained aggregates or unions)
/// with a const-qualified type.
-Expr::isModifiableLvalueResult
+Expr::isModifiableLvalueResult
Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const {
isLvalueResult lvalResult = isLvalue(Ctx);
-
+
switch (lvalResult) {
- case LV_Valid:
+ case LV_Valid:
// C++ 3.10p11: Functions cannot be modified, but pointers to
// functions can be modifiable.
if (Ctx.getLangOptions().CPlusPlus && TR->isFunctionType())
@@ -1068,27 +1068,27 @@ Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const {
}
QualType CT = Ctx.getCanonicalType(getType());
-
+
if (CT.isConstQualified())
return MLV_ConstQualified;
if (CT->isArrayType())
return MLV_ArrayType;
if (CT->isIncompleteType())
return MLV_IncompleteType;
-
+
if (const RecordType *r = CT->getAs<RecordType>()) {
- if (r->hasConstFields())
+ if (r->hasConstFields())
return MLV_ConstQualified;
}
-
+
// Assigning to an 'implicit' property?
else if (isa<ObjCImplicitSetterGetterRefExpr>(this)) {
- const ObjCImplicitSetterGetterRefExpr* Expr =
+ const ObjCImplicitSetterGetterRefExpr* Expr =
cast<ObjCImplicitSetterGetterRefExpr>(this);
if (Expr->getSetterMethod() == 0)
return MLV_NoSetterProperty;
}
- return MLV_Valid;
+ return MLV_Valid;
}
/// isOBJCGCCandidate - Check if an expression is objc gc'able.
@@ -1131,7 +1131,7 @@ Expr* Expr::IgnoreParens() {
Expr* E = this;
while (ParenExpr* P = dyn_cast<ParenExpr>(E))
E = P->getSubExpr();
-
+
return E;
}
@@ -1159,17 +1159,17 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) {
E = P->getSubExpr();
continue;
}
-
+
if (CastExpr *P = dyn_cast<CastExpr>(E)) {
// We ignore integer <-> casts that are of the same width, ptr<->ptr and
// ptr<->int casts of the same width. We also ignore all identify casts.
Expr *SE = P->getSubExpr();
-
+
if (Ctx.hasSameUnqualifiedType(E->getType(), SE->getType())) {
E = SE;
continue;
}
-
+
if ((E->getType()->isPointerType() || E->getType()->isIntegralType()) &&
(SE->getType()->isPointerType() || SE->getType()->isIntegralType()) &&
Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SE->getType())) {
@@ -1177,7 +1177,7 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) {
continue;
}
}
-
+
return E;
}
}
@@ -1233,7 +1233,7 @@ bool Expr::isConstantInitializer(ASTContext &Ctx) const {
const InitListExpr *Exp = cast<InitListExpr>(this);
unsigned numInits = Exp->getNumInits();
for (unsigned i = 0; i < numInits; i++) {
- if (!Exp->getInit(i)->isConstantInitializer(Ctx))
+ if (!Exp->getInit(i)->isConstantInitializer(Ctx))
return false;
}
return true;
@@ -1274,9 +1274,9 @@ bool Expr::isConstantInitializer(ASTContext &Ctx) const {
// CheckICE - This function does the fundamental ICE checking: the returned
// ICEDiag contains a Val of 0, 1, or 2, and a possibly null SourceLocation.
// Note that to reduce code duplication, this helper does no evaluation
-// itself; the caller checks whether the expression is evaluatable, and
+// itself; the caller checks whether the expression is evaluatable, and
// in the rare cases where CheckICE actually cares about the evaluated
-// value, it calls into Evalute.
+// value, it calls into Evalute.
//
// Meanings of Val:
// 0: This expression is an ICE if it can be evaluated by Evaluate.
@@ -1323,7 +1323,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
case Expr::TypesCompatibleExprClass:
case Expr::UnaryTypeTraitExprClass:
return NoDiag();
- case Expr::CallExprClass:
+ case Expr::CallExprClass:
case Expr::CXXOperatorCallExprClass: {
const CallExpr *CE = cast<CallExpr>(E);
if (CE->isBuiltinCall(Ctx))
@@ -1474,7 +1474,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
}
case Expr::ConditionalOperatorClass: {
const ConditionalOperator *Exp = cast<ConditionalOperator>(E);
- // If the condition (ignoring parens) is a __builtin_constant_p call,
+ // If the condition (ignoring parens) is a __builtin_constant_p call,
// then only the true side is actually considered in an integer constant
// expression, and it is fully evaluated. This is an important GNU
// extension. See GCC PR38377 for discussion.
@@ -1535,15 +1535,14 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
/// isNullPointerConstant - C99 6.3.2.3p3 - Return true if this is either an
/// integer constant expression with the value zero, or if this is one that is
/// cast to void*.
-bool Expr::isNullPointerConstant(ASTContext &Ctx) const
-{
+bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
// Strip off a cast to void*, if it exists. Except in C++.
if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) {
if (!Ctx.getLangOptions().CPlusPlus) {
// Check that it is a cast to void*.
if (const PointerType *PT = CE->getType()->getAs<PointerType>()) {
QualType Pointee = PT->getPointeeType();
- if (Pointee.getCVRQualifiers() == 0 &&
+ if (Pointee.getCVRQualifiers() == 0 &&
Pointee->isVoidType() && // to void*
CE->getSubExpr()->getType()->isIntegerType()) // from int.
return CE->getSubExpr()->isNullPointerConstant(Ctx);
@@ -1556,7 +1555,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
// Accept ((void*)0) as a null pointer constant, as many other
// implementations do.
return PE->getSubExpr()->isNullPointerConstant(Ctx);
- } else if (const CXXDefaultArgExpr *DefaultArg
+ } else if (const CXXDefaultArgExpr *DefaultArg
= dyn_cast<CXXDefaultArgExpr>(this)) {
// See through default argument expressions
return DefaultArg->getExpr()->isNullPointerConstant(Ctx);
@@ -1572,7 +1571,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
// This expression must be an integer type.
if (!getType()->isIntegerType())
return false;
-
+
// If we have an integer constant expression, we need to *evaluate* it and
// test for the value 0.
llvm::APSInt Result;
@@ -1612,20 +1611,20 @@ bool ExtVectorElementExpr::containsDuplicateElements() const {
unsigned length = Accessor->getLength();
// Halving swizzles do not contain duplicate elements.
- if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") ||
+ if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") ||
!strcmp(compStr, "even") || !strcmp(compStr, "odd"))
return false;
-
+
// Advance past s-char prefix on hex swizzles.
if (*compStr == 's' || *compStr == 'S') {
compStr++;
length--;
}
-
+
for (unsigned i = 0; i != length-1; i++) {
const char *s = compStr+i;
for (const char c = *s++; *s; s++)
- if (c == *s)
+ if (c == *s)
return true;
}
return false;
@@ -1637,15 +1636,15 @@ void ExtVectorElementExpr::getEncodedElementAccess(
const char *compStr = Accessor->getName();
if (*compStr == 's' || *compStr == 'S')
compStr++;
-
+
bool isHi = !strcmp(compStr, "hi");
bool isLo = !strcmp(compStr, "lo");
bool isEven = !strcmp(compStr, "even");
bool isOdd = !strcmp(compStr, "odd");
-
+
for (unsigned i = 0, e = getNumElements(); i != e; ++i) {
uint64_t Index;
-
+
if (isHi)
Index = e + i;
else if (isLo)
@@ -1666,7 +1665,7 @@ ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo,
QualType retType, ObjCMethodDecl *mproto,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned nargs)
- : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
+ : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
MethodProto(mproto) {
NumArgs = nargs;
SubExprs = new Stmt*[NumArgs+1];
@@ -1679,13 +1678,13 @@ ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo,
RBracloc = RBrac;
}
-// constructor for class messages.
+// constructor for class messages.
// FIXME: clsName should be typed to ObjCInterfaceType
ObjCMessageExpr::ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
QualType retType, ObjCMethodDecl *mproto,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned nargs)
- : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
+ : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
MethodProto(mproto) {
NumArgs = nargs;
SubExprs = new Stmt*[NumArgs+1];
@@ -1698,12 +1697,12 @@ ObjCMessageExpr::ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
RBracloc = RBrac;
}
-// constructor for class messages.
+// constructor for class messages.
ObjCMessageExpr::ObjCMessageExpr(ObjCInterfaceDecl *cls, Selector selInfo,
QualType retType, ObjCMethodDecl *mproto,
SourceLocation LBrac, SourceLocation RBrac,
Expr **ArgExprs, unsigned nargs)
-: Expr(ObjCMessageExprClass, retType), SelName(selInfo),
+: Expr(ObjCMessageExprClass, retType), SelName(selInfo),
MethodProto(mproto) {
NumArgs = nargs;
SubExprs = new Stmt*[NumArgs+1];
@@ -1753,7 +1752,7 @@ void ShuffleVectorExpr::setExprs(ASTContext &C, Expr ** Exprs,
SubExprs = new (C) Stmt* [NumExprs];
this->NumExprs = NumExprs;
memcpy(SubExprs, Exprs, sizeof(Expr *) * NumExprs);
-}
+}
void ShuffleVectorExpr::DoDestroy(ASTContext& C) {
DestroyChildren(C);
@@ -1788,17 +1787,17 @@ IdentifierInfo *DesignatedInitExpr::Designator::getFieldName() {
return getField()->getIdentifier();
}
-DesignatedInitExpr::DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
+DesignatedInitExpr::DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
const Designator *Designators,
- SourceLocation EqualOrColonLoc,
+ SourceLocation EqualOrColonLoc,
bool GNUSyntax,
- Expr **IndexExprs,
+ Expr **IndexExprs,
unsigned NumIndexExprs,
Expr *Init)
- : Expr(DesignatedInitExprClass, Ty,
+ : Expr(DesignatedInitExprClass, Ty,
Init->isTypeDependent(), Init->isValueDependent()),
- EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
- NumDesignators(NumDesignators), NumSubExprs(NumIndexExprs + 1) {
+ EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
+ NumDesignators(NumDesignators), NumSubExprs(NumIndexExprs + 1) {
this->Designators = new Designator[NumDesignators];
// Record the initializer itself.
@@ -1814,7 +1813,7 @@ DesignatedInitExpr::DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
if (this->Designators[I].isArrayDesignator()) {
// Compute type- and value-dependence.
Expr *Index = IndexExprs[IndexIdx];
- ValueDependent = ValueDependent ||
+ ValueDependent = ValueDependent ||
Index->isTypeDependent() || Index->isValueDependent();
// Copy the index expressions into permanent storage.
@@ -1823,7 +1822,7 @@ DesignatedInitExpr::DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
// Compute type- and value-dependence.
Expr *Start = IndexExprs[IndexIdx];
Expr *End = IndexExprs[IndexIdx + 1];
- ValueDependent = ValueDependent ||
+ ValueDependent = ValueDependent ||
Start->isTypeDependent() || Start->isValueDependent() ||
End->isTypeDependent() || End->isValueDependent();
@@ -1837,7 +1836,7 @@ DesignatedInitExpr::DesignatedInitExpr(QualType Ty, unsigned NumDesignators,
}
DesignatedInitExpr *
-DesignatedInitExpr::Create(ASTContext &C, Designator *Designators,
+DesignatedInitExpr::Create(ASTContext &C, Designator *Designators,
unsigned NumDesignators,
Expr **IndexExprs, unsigned NumIndexExprs,
SourceLocation ColonOrEqualLoc,
@@ -1849,14 +1848,14 @@ DesignatedInitExpr::Create(ASTContext &C, Designator *Designators,
IndexExprs, NumIndexExprs, Init);
}
-DesignatedInitExpr *DesignatedInitExpr::CreateEmpty(ASTContext &C,
+DesignatedInitExpr *DesignatedInitExpr::CreateEmpty(ASTContext &C,
unsigned NumIndexExprs) {
void *Mem = C.Allocate(sizeof(DesignatedInitExpr) +
sizeof(Stmt *) * (NumIndexExprs + 1), 8);
return new (Mem) DesignatedInitExpr(NumIndexExprs + 1);
}
-void DesignatedInitExpr::setDesignators(const Designator *Desigs,
+void DesignatedInitExpr::setDesignators(const Designator *Desigs,
unsigned NumDesigs) {
if (Designators)
delete [] Designators;
@@ -1891,7 +1890,7 @@ Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) {
}
Expr *DesignatedInitExpr::getArrayRangeStart(const Designator& D) {
- assert(D.Kind == Designator::ArrayRangeDesignator &&
+ assert(D.Kind == Designator::ArrayRangeDesignator &&
"Requires array range designator");
char* Ptr = static_cast<char*>(static_cast<void *>(this));
Ptr += sizeof(DesignatedInitExpr);
@@ -1900,7 +1899,7 @@ Expr *DesignatedInitExpr::getArrayRangeStart(const Designator& D) {
}
Expr *DesignatedInitExpr::getArrayRangeEnd(const Designator& D) {
- assert(D.Kind == Designator::ArrayRangeDesignator &&
+ assert(D.Kind == Designator::ArrayRangeDesignator &&
"Requires array range designator");
char* Ptr = static_cast<char*>(static_cast<void *>(this));
Ptr += sizeof(DesignatedInitExpr);
@@ -1910,8 +1909,8 @@ Expr *DesignatedInitExpr::getArrayRangeEnd(const Designator& D) {
/// \brief Replaces the designator at index @p Idx with the series
/// of designators in [First, Last).
-void DesignatedInitExpr::ExpandDesignator(unsigned Idx,
- const Designator *First,
+void DesignatedInitExpr::ExpandDesignator(unsigned Idx,
+ const Designator *First,
const Designator *Last) {
unsigned NumNewDesignators = Last - First;
if (NumNewDesignators == 0) {
@@ -1925,7 +1924,7 @@ void DesignatedInitExpr::ExpandDesignator(unsigned Idx,
return;
}
- Designator *NewDesignators
+ Designator *NewDesignators
= new Designator[NumDesignators - 1 + NumNewDesignators];
std::copy(Designators, Designators + Idx, NewDesignators);
std::copy(First, Last, NewDesignators + Idx);
@@ -1941,14 +1940,14 @@ void DesignatedInitExpr::DoDestroy(ASTContext &C) {
Expr::DoDestroy(C);
}
-ParenListExpr::ParenListExpr(ASTContext& C, SourceLocation lparenloc,
+ParenListExpr::ParenListExpr(ASTContext& C, SourceLocation lparenloc,
Expr **exprs, unsigned nexprs,
SourceLocation rparenloc)
: Expr(ParenListExprClass, QualType(),
hasAnyTypeDependentArguments(exprs, nexprs),
- hasAnyValueDependentArguments(exprs, nexprs)),
+ hasAnyValueDependentArguments(exprs, nexprs)),
NumExprs(nexprs), LParenLoc(lparenloc), RParenLoc(rparenloc) {
-
+
Exprs = new (C) Stmt*[nexprs];
for (unsigned i = 0; i != nexprs; ++i)
Exprs[i] = exprs[i];
@@ -1991,11 +1990,11 @@ Stmt::child_iterator ObjCPropertyRefExpr::child_begin() { return &Base; }
Stmt::child_iterator ObjCPropertyRefExpr::child_end() { return &Base+1; }
// ObjCImplicitSetterGetterRefExpr
-Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_begin() {
- return &Base;
+Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_begin() {
+ return &Base;
}
-Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_end() {
- return &Base+1;
+Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_end() {
+ return &Base+1;
}
// ObjCSuperExpr
@@ -2039,7 +2038,7 @@ Stmt::child_iterator UnaryOperator::child_begin() { return &Val; }
Stmt::child_iterator UnaryOperator::child_end() { return &Val+1; }
// SizeOfAlignOfExpr
-Stmt::child_iterator SizeOfAlignOfExpr::child_begin() {
+Stmt::child_iterator SizeOfAlignOfExpr::child_begin() {
// If this is of a type and the type is a VLA type (and not a typedef), the
// size expression of the VLA needs to be treated as an executable expression.
// Why isn't this weirdness documented better in StmtIterator?
@@ -2161,12 +2160,12 @@ Stmt::child_iterator DesignatedInitExpr::child_end() {
}
// ImplicitValueInitExpr
-Stmt::child_iterator ImplicitValueInitExpr::child_begin() {
- return child_iterator();
+Stmt::child_iterator ImplicitValueInitExpr::child_begin() {
+ return child_iterator();
}
-Stmt::child_iterator ImplicitValueInitExpr::child_end() {
- return child_iterator();
+Stmt::child_iterator ImplicitValueInitExpr::child_end() {
+ return child_iterator();
}
// ParenListExpr
@@ -2178,7 +2177,7 @@ Stmt::child_iterator ParenListExpr::child_end() {
}
// ObjCStringLiteral
-Stmt::child_iterator ObjCStringLiteral::child_begin() {
+Stmt::child_iterator ObjCStringLiteral::child_begin() {
return &String;
}
Stmt::child_iterator ObjCStringLiteral::child_end() {
@@ -2190,7 +2189,7 @@ Stmt::child_iterator ObjCEncodeExpr::child_begin() { return child_iterator(); }
Stmt::child_iterator ObjCEncodeExpr::child_end() { return child_iterator(); }
// ObjCSelectorExpr
-Stmt::child_iterator ObjCSelectorExpr::child_begin() {
+Stmt::child_iterator ObjCSelectorExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator ObjCSelectorExpr::child_end() {
@@ -2206,7 +2205,7 @@ Stmt::child_iterator ObjCProtocolExpr::child_end() {
}
// ObjCMessageExpr
-Stmt::child_iterator ObjCMessageExpr::child_begin() {
+Stmt::child_iterator ObjCMessageExpr::child_begin() {
return getReceiver() ? &SubExprs[0] : &SubExprs[0] + ARGS_START;
}
Stmt::child_iterator ObjCMessageExpr::child_end() {
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 7c36caad58..7f39793c04 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -30,7 +30,7 @@ Stmt::child_iterator CXXTypeidExpr::child_end() {
}
// CXXBoolLiteralExpr
-Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
+Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
@@ -38,7 +38,7 @@ Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
}
// CXXNullPtrLiteralExpr
-Stmt::child_iterator CXXNullPtrLiteralExpr::child_begin() {
+Stmt::child_iterator CXXNullPtrLiteralExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXNullPtrLiteralExpr::child_end() {
@@ -65,7 +65,7 @@ Stmt::child_iterator CXXDefaultArgExpr::child_end() {
}
// CXXZeroInitValueExpr
-Stmt::child_iterator CXXZeroInitValueExpr::child_begin() {
+Stmt::child_iterator CXXZeroInitValueExpr::child_begin() {
return child_iterator();
}
Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
@@ -93,8 +93,7 @@ CXXNewExpr::CXXNewExpr(bool globalNew, FunctionDecl *operatorNew,
Initializer(initializer), Array(arraySize), NumPlacementArgs(numPlaceArgs),
NumConstructorArgs(numConsArgs), OperatorNew(operatorNew),
OperatorDelete(operatorDelete), Constructor(constructor),
- StartLoc(startLoc), EndLoc(endLoc)
-{
+ StartLoc(startLoc), EndLoc(endLoc) {
unsigned TotalSize = Array + NumPlacementArgs + NumConstructorArgs;
SubExprs = new Stmt*[TotalSize];
unsigned i = 0;
@@ -123,8 +122,8 @@ Stmt::child_iterator CXXPseudoDestructorExpr::child_end() {
}
// UnresolvedFunctionNameExpr
-Stmt::child_iterator UnresolvedFunctionNameExpr::child_begin() {
- return child_iterator();
+Stmt::child_iterator UnresolvedFunctionNameExpr::child_begin() {
+ return child_iterator();
}
Stmt::child_iterator UnresolvedFunctionNameExpr::child_end() {
return child_iterator();
@@ -147,16 +146,16 @@ StmtIterator UnresolvedDeclRefExpr::child_end() {
}
TemplateIdRefExpr::TemplateIdRefExpr(QualType T,
- NestedNameSpecifier *Qualifier,
+ NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
- TemplateName Template,
+ TemplateName Template,
SourceLocation TemplateNameLoc,
- SourceLocation LAngleLoc,
+ SourceLocation LAngleLoc,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc)
: Expr(TemplateIdRefExprClass, T,
- (Template.isDependent() ||
+ (Template.isDependent() ||
TemplateSpecializationType::anyDependentTemplateArguments(
TemplateArgs, NumTemplateArgs)),
(Template.isDependent() ||
@@ -164,10 +163,8 @@ TemplateIdRefExpr::TemplateIdRefExpr(QualType T,
TemplateArgs, NumTemplateArgs))),
Qualifier(Qualifier), QualifierRange(QualifierRange), Template(Template),
TemplateNameLoc(TemplateNameLoc), LAngleLoc(LAngleLoc),
- RAngleLoc(RAngleLoc), NumTemplateArgs(NumTemplateArgs)
-
-{
- TemplateArgument *StoredTemplateArgs
+ RAngleLoc(RAngleLoc), NumTemplateArgs(NumTemplateArgs) {
+ TemplateArgument *StoredTemplateArgs
= reinterpret_cast<TemplateArgument *> (this+1);
for (unsigned I = 0; I != NumTemplateArgs; ++I)
new (StoredTemplateArgs + I) TemplateArgument(TemplateArgs[I]);
@@ -175,10 +172,10 @@ TemplateIdRefExpr::TemplateIdRefExpr(QualType T,
TemplateIdRefExpr *
TemplateIdRefExpr::Create(ASTContext &Context, QualType T,
- NestedNameSpecifier *Qualifier,
+ NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
TemplateName Template, SourceLocation TemplateNameLoc,
- SourceLocation LAngleLoc,
+ SourceLocation LAngleLoc,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs, SourceLocation RAngleLoc) {
void *Mem = Context.Allocate(sizeof(TemplateIdRefExpr) +
@@ -298,7 +295,7 @@ SourceRange CXXOperatorCallExpr::getSourceRange() const {
if (Kind == OO_PlusPlus || Kind == OO_MinusMinus) {
if (getNumArgs() == 1)
// Prefix operator
- return SourceRange(getOperatorLoc(),
+ return SourceRange(getOperatorLoc(),
getArg(0)->getSourceRange().getEnd());
else
// Postfix operator
@@ -343,7 +340,7 @@ const char *CXXNamedCastExpr::getCastName() const {
}
}
-CXXTemporary *CXXTemporary::Create(ASTContext &C,
+CXXTemporary *CXXTemporary::Create(ASTContext &C,
const CXXDestructorDecl *Destructor) {
return new (C) CXXTemporary(Destructor);
}
@@ -353,10 +350,10 @@ void CXXTemporary::Destroy(ASTContext &Ctx) {
Ctx.Deallocate(this);
}
-CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
+CXXBindTemporaryExpr *CXXBindTemporaryExpr::Create(ASTContext &C,
CXXTemporary *Temp,
Expr* SubExpr) {
- assert(SubExpr->getType()->isRecordType() &&
+ assert(SubExpr->getType()->isRecordType() &&
"Expression bound to a temporary must have record type!");
return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
@@ -371,46 +368,46 @@ void CXXBindTemporaryExpr::DoDestroy(ASTContext &C) {
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
CXXConstructorDecl *Cons,
QualType writtenTy,
- SourceLocation tyBeginLoc,
+ SourceLocation tyBeginLoc,
Expr **Args,
- unsigned NumArgs,
+ unsigned NumArgs,
SourceLocation rParenLoc)
- : CXXConstructExpr(C, CXXTemporaryObjectExprClass, writtenTy, Cons,
- false, Args, NumArgs),
+ : CXXConstructExpr(C, CXXTemporaryObjectExprClass, writtenTy, Cons,
+ false, Args, NumArgs),
TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {
}
-CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
+CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
CXXConstructorDecl *D, bool Elidable,
Expr **Args, unsigned NumArgs) {
- return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, D, Elidable,
+ return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, D, Elidable,
Args, NumArgs);
}
-CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
+CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
CXXConstructorDecl *D, bool elidable,
- Expr **args, unsigned numargs)
+ Expr **args, unsigned numargs)
: Expr(SC, T,
T->isDependentType(),
(T->isDependentType() ||
CallExpr::hasAnyValueDependentArguments(args, numargs))),
Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) {
// leave room for default arguments;
- const FunctionProtoType *FTy =
+ const FunctionProtoType *FTy =
cast<FunctionDecl>(D)->getType()->getAsFunctionProtoType();
-
+
unsigned NumArgsInProto = FTy->getNumArgs();
unsigned NumArgsToAllocate = FTy->isVariadic() ? NumArgs : NumArgsInProto;
if (NumArgsToAllocate) {
Args = new (C) Stmt*[NumArgsToAllocate];
-
+
for (unsigned i = 0; i != NumArgs; ++i)
Args[i] = args[i];
-
+
// Set default arguments to 0.
for (unsigned i = NumArgs; i != NumArgsToAllocate; ++i)
Args[i] = 0;
-
+
NumArgs = NumArgsToAllocate;
}
}
@@ -423,13 +420,13 @@ void CXXConstructExpr::DoDestroy(ASTContext &C) {
C.Deallocate(this);
}
-CXXExprWithTemporaries::CXXExprWithTemporaries(Expr *subexpr,
- CXXTemporary **temps,
+CXXExprWithTemporaries::CXXExprWithTemporaries(Expr *subexpr,
+ CXXTemporary **temps,
unsigned numtemps,
bool shoulddestroytemps)
: Expr(CXXExprWithTemporariesClass, subexpr->getType(),
- subexpr->isTypeDependent(), subexpr->isValueDependent()),
- SubExpr(subexpr), Temps(0), NumTemps(numtemps),
+ subexpr->isTypeDependent(), subexpr->isValueDependent()),
+ SubExpr(subexpr), Temps(0), NumTemps(numtemps),
ShouldDestroyTemps(shoulddestroytemps) {
if (NumTemps > 0) {
Temps = new CXXTemporary*[NumTemps];
@@ -438,12 +435,12 @@ CXXExprWithTemporaries::CXXExprWithTemporaries(Expr *subexpr,
}
}
-CXXExprWithTemporaries *CXXExprWithTemporaries::Create(ASTContext &C,
+CXXExprWithTemporaries *CXXExprWithTemporaries::Create(ASTContext &C,
Expr *SubExpr,
- CXXTemporary **Temps,
+ CXXTemporary **Temps,
unsigned NumTemps,
bool ShouldDestroyTemps){
- return new (C) CXXExprWithTemporaries(SubExpr, Temps, NumTemps,
+ return new (C) CXXExprWithTemporaries(SubExpr, Temps, NumTemps,
ShouldDestroyTemps);
}
@@ -462,7 +459,7 @@ Stmt::child_iterator CXXBindTemporaryExpr::child_begin() {
return &SubExpr;
}
-Stmt::child_iterator CXXBindTemporaryExpr::child_end() {
+Stmt::child_iterator CXXBindTemporaryExpr::child_end() {
return &SubExpr + 1;
}
@@ -479,7 +476,7 @@ Stmt::child_iterator CXXExprWithTemporaries::child_begin() {
return &SubExpr;
}
-Stmt::child_iterator CXXExprWithTemporaries::child_end() {
+Stmt::child_iterator CXXExprWithTemporaries::child_end() {
return &SubExpr + 1;
}
@@ -502,7 +499,7 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
}
CXXUnresolvedConstructExpr *
-CXXUnresolvedConstructExpr::Create(ASTContext &C,
+CXXUnresolvedConstructExpr::Create(ASTContext &C,
SourceLocation TyBegin,
QualType T,
SourceLocation LParenLoc,
@@ -523,8 +520,8 @@ Stmt::child_iterator CXXUnresolvedConstructExpr::child_end() {
return child_iterator(reinterpret_cast<Stmt **>(this + 1) + NumArgs);
}
-CXXUnresolvedMemberExpr::CXXUnresolvedMemberExpr(ASTContext &C,
- Expr *Base, bool IsArrow,
+CXXUnresolvedMemberExpr::CXXUnresolvedMemberExpr(ASTContext &C,
+ Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
@@ -537,29 +534,28 @@ CXXUnresolvedMemberExpr::CXXUnresolvedMemberExpr(ASTContext &C,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc)
: Expr(CXXUnresolvedMemberExprClass, C.DependentTy, true, true),
- Base(Base), IsArrow(IsArrow),
+ Base(Base), IsArrow(IsArrow),
HasExplicitTemplateArgumentList(HasExplicitTemplateArgs),
OperatorLoc(OperatorLoc),
Qualifier(Qualifier), QualifierRange(QualifierRange),
FirstQualifierFoundInScope(FirstQualifierFoundInScope),
- Member(Member), MemberLoc(MemberLoc)
-{
+ Member(Member), MemberLoc(MemberLoc) {
if (HasExplicitTemplateArgumentList) {
- ExplicitTemplateArgumentList *ETemplateArgs
+ ExplicitTemplateArgumentList *ETemplateArgs
= getExplicitTemplateArgumentList();
ETemplateArgs->LAngleLoc = LAngleLoc;
ETemplateArgs->RAngleLoc = RAngleLoc;
ETemplateArgs->NumTemplateArgs = NumTemplateArgs;
-
+
TemplateArgument *SavedTemplateArgs = ETemplateArgs->getTemplateArgs();
for (unsigned I = 0; I < NumTemplateArgs; ++I)
- new (SavedTemplateArgs + I) TemplateArgument(TemplateArgs[I]);
+ new (SavedTemplateArgs + I) TemplateArgument(TemplateArgs[I]);
}
}
CXXUnresolvedMemberExpr *
-CXXUnresolvedMemberExpr::Create(ASTContext &C,
- Expr *Base, bool IsArrow,
+CXXUnresolvedMemberExpr::Create(ASTContext &C,
+ Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
@@ -570,16 +566,15 @@ CXXUnresolvedMemberExpr::Create(ASTContext &C,
SourceLocation LAngleLoc,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
- SourceLocation RAngleLoc)
-{
+ SourceLocation RAngleLoc) {
if (!HasExplicitTemplateArgs)
return new (C) CXXUnresolvedMemberExpr(C, Base, IsArrow, OperatorLoc,
Qualifier, QualifierRange,
FirstQualifierFoundInScope,
Member, MemberLoc);
-
+
void *Mem = C.Allocate(sizeof(CXXUnresolvedMemberExpr) +
- sizeof(ExplicitTemplateArgumentList) +
+ sizeof(ExplicitTemplateArgumentList) +
sizeof(TemplateArgument) * NumTemplateArgs,
llvm::alignof<CXXUnresolvedMemberExpr>());
return new (Mem) CXXUnresolvedMemberExpr(C, Base, IsArrow, OperatorLoc,
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 7d281494d6..4494896d2c 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -42,11 +42,11 @@ using llvm::APFloat;
/// certain things in certain situations.
struct EvalInfo {
ASTContext &Ctx;
-
+
/// EvalResult - Contains information about the evaluation.
Expr::EvalResult &EvalResult;
- EvalInfo(ASTContext &ctx, Expr::EvalResult& evalresult) : Ctx(ctx),
+ EvalInfo(ASTContext &ctx, Expr::EvalResult& evalresult) : Ctx(ctx),
EvalResult(evalresult) {}
};
@@ -104,12 +104,12 @@ static bool HandleConversionToBool(Expr* E, bool& Result, EvalInfo &Info) {
return false;
}
-static APSInt HandleFloatToIntCast(QualType DestType, QualType SrcType,
+static APSInt HandleFloatToIntCast(QualType DestType, QualType SrcType,
APFloat &Value, ASTContext &Ctx) {
unsigned DestWidth = Ctx.getIntWidth(DestType);
// Determine whether we are converting to unsigned or signed.
bool DestSigned = DestType->isSignedIntegerType();
-
+
// FIXME: Warning for overflow.
uint64_t Space[4];
bool ignored;
@@ -118,16 +118,16 @@ static APSInt HandleFloatToIntCast(QualType DestType, QualType SrcType,
return APSInt(llvm::APInt(DestWidth, 4, Space), !DestSigned);
}
-static APFloat HandleFloatToFloatCast(QualType DestType, QualType SrcType,
+static APFloat HandleFloatToFloatCast(QualType DestType, QualType SrcType,
APFloat &Value, ASTContext &Ctx) {
bool ignored;
APFloat Result = Value;
- Result.convert(Ctx.getFloatTypeSemantics(DestType),
+ Result.convert(Ctx.getFloatTypeSemantics(DestType),
APFloat::rmNearestTiesToEven, &ignored);
return Result;
}
-static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType,
+static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType,
APSInt &Value, ASTContext &Ctx) {
unsigned DestWidth = Ctx.getIntWidth(DestType);
APSInt Result = Value;
@@ -138,7 +138,7 @@ static APSInt HandleIntToIntCast(QualType DestType, QualType SrcType,
return Result;
}
-static APFloat HandleIntToFloatCast(QualType DestType, QualType SrcType,
+static APFloat HandleIntToFloatCast(QualType DestType, QualType SrcType,
APSInt &Value, ASTContext &Ctx) {
APFloat Result(Ctx.getFloatTypeSemantics(DestType), 1);
@@ -155,7 +155,7 @@ class VISIBILITY_HIDDEN LValueExprEvaluator
: public StmtVisitor<LValueExprEvaluator, APValue> {
EvalInfo &Info;
public:
-
+
LValueExprEvaluator(EvalInfo &info) : Info(info) {}
APValue VisitStmt(Stmt *S) {
@@ -185,8 +185,7 @@ static bool EvaluateLValue(const Expr* E, APValue& Result, EvalInfo &Info) {
return Result.isLValue();
}
-APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E)
-{
+APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E) {
if (isa<FunctionDecl>(E->getDecl())) {
return APValue(E, 0);
} else if (VarDecl* VD = dyn_cast<VarDecl>(E->getDecl())) {
@@ -202,11 +201,10 @@ APValue LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E)
return APValue();
}
-APValue LValueExprEvaluator::VisitBlockExpr(BlockExpr *E)
-{
+APValue LValueExprEvaluator::VisitBlockExpr(BlockExpr *E) {
if (E->hasBlockDeclRefExprs())
return APValue();
-
+
return APValue(E, 0);
}
@@ -255,13 +253,12 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
return result;
}
-APValue LValueExprEvaluator::VisitArraySubscriptExpr(ArraySubscriptExpr *E)
-{
+APValue LValueExprEvaluator::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
APValue Result;
-
+
if (!EvaluatePointer(E->getBase(), Result, Info))
return APValue();
-
+
APSInt Index;
if (!EvaluateInteger(E->getIdx(), Index, Info))
return APValue();
@@ -269,13 +266,12 @@ APValue LValueExprEvaluator::VisitArraySubscriptExpr(ArraySubscriptExpr *E)
uint64_t ElementSize = Info.Ctx.getTypeSize(E->getType()) / 8;
uint64_t Offset = Index.getSExtValue() * ElementSize;
- Result.setLValue(Result.getLValueBase(),
+ Result.setLValue(Result.getLValueBase(),
Result.getLValueOffset() + Offset);
return Result;
}
-APValue LValueExprEvaluator::VisitUnaryDeref(UnaryOperator *E)
-{
+APValue LValueExprEvaluator::VisitUnaryDeref(UnaryOperator *E) {
APValue Result;
if (!EvaluatePointer(E->getSubExpr(), Result, Info))
return APValue();
@@ -291,7 +287,7 @@ class VISIBILITY_HIDDEN PointerExprEvaluator
: public StmtVisitor<PointerExprEvaluator, APValue> {
EvalInfo &Info;
public:
-
+
PointerExprEvaluator(EvalInfo &info) : Info(info) {}
APValue VisitStmt(Stmt *S) {
@@ -337,23 +333,23 @@ APValue PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->getOpcode() != BinaryOperator::Add &&
E->getOpcode() != BinaryOperator::Sub)
return APValue();
-
+
const Expr *PExp = E->getLHS();
const Expr *IExp = E->getRHS();
if (IExp->getType()->isPointerType())
std::swap(PExp, IExp);
-
+
APValue ResultLValue;
if (!EvaluatePointer(PExp, ResultLValue, Info))
return APValue();
-
+
llvm::APSInt AdditionalOffset(32);
if (!EvaluateInteger(IExp, AdditionalOffset, Info))
return APValue();
QualType PointeeType = PExp->getType()->getAs<PointerType>()->getPointeeType();
uint64_t SizeOfPointee;
-
+
// Explicitly handle GNU void* and function pointer arithmetic extensions.
if (PointeeType->isVoidType() || PointeeType->isFunctionType())
SizeOfPointee = 1;
@@ -376,7 +372,7 @@ APValue PointerExprEvaluator::VisitUnaryAddrOf(const UnaryOperator *E) {
return result;
return APValue();
}
-
+
APValue PointerExprEvaluator::VisitCastExpr(const CastExpr* E) {
const Expr* SubExpr = E->getSubExpr();
@@ -389,7 +385,7 @@ APValue PointerExprEvaluator::VisitCastExpr(const CastExpr* E) {
return Result;
return APValue();
}
-
+
if (SubExpr->getType()->isIntegralType()) {
APValue Result;
if (!EvaluateIntegerOrLValue(SubExpr, Result, Info))
@@ -399,7 +395,7 @@ APValue PointerExprEvaluator::VisitCastExpr(const CastExpr* E) {
Result.getInt().extOrTrunc((unsigned)Info.Ctx.getTypeSize(E->getType()));
return APValue(0, Result.getInt().getZExtValue());
}
-
+
// Cast is of an lvalue, no need to change value.
return Result;
}
@@ -414,10 +410,10 @@ APValue PointerExprEvaluator::VisitCastExpr(const CastExpr* E) {
}
return APValue();
-}
+}
APValue PointerExprEvaluator::VisitCallExpr(CallExpr *E) {
- if (E->isBuiltinCall(Info.Ctx) ==
+ if (E->isBuiltinCall(Info.Ctx) ==
Builtin::BI__builtin___CFStringMakeConstantString)
return APValue(E, 0);
return APValue();
@@ -446,13 +442,13 @@ namespace {
EvalInfo &Info;
APValue GetZeroVector(QualType VecType);
public:
-
+
VectorExprEvaluator(EvalInfo &info) : Info(info) {}
-
+
APValue VisitStmt(Stmt *S) {
return APValue();
}
-
+
APValue VisitParenExpr(ParenExpr *E)
{ return Visit(E->getSubExpr()); }
APValue VisitUnaryExtension(const UnaryOperator *E)
@@ -490,7 +486,7 @@ APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
QualType EltTy = VTy->getElementType();
unsigned NElts = VTy->getNumElements();
unsigned EltWidth = Info.Ctx.getTypeSize(EltTy);
-
+
const Expr* SE = E->getSubExpr();
QualType SETy = SE->getType();
APValue Result = APValue();
@@ -540,12 +536,12 @@ APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
// element.
APSInt Init;
Init = Result.isInt() ? Result.getInt() : Result.getFloat().bitcastToAPInt();
-
+
llvm::SmallVector<APValue, 4> Elts;
for (unsigned i = 0; i != NElts; ++i) {
APSInt Tmp = Init;
Tmp.extOrTrunc(EltWidth);
-
+
if (EltTy->isIntegerType())
Elts.push_back(APValue(Tmp));
else if (EltTy->isRealFloatingType())
@@ -558,17 +554,17 @@ APValue VectorExprEvaluator::VisitCastExpr(const CastExpr* E) {
return APValue(&Elts[0], Elts.size());
}
-APValue
+APValue
VectorExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
return this->Visit(const_cast<Expr*>(E->getInitializer()));
}
-APValue
+APValue
VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
const VectorType *VT = E->getType()->getAsVectorType();
unsigned NumInits = E->getNumInits();
unsigned NumElements = VT->getNumElements();
-
+
QualType EltTy = VT->getElementType();
llvm::SmallVector<APValue, 4> Elements;
@@ -596,7 +592,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
return APValue(&Elements[0], Elements.size());
}
-APValue
+APValue
VectorExprEvaluator::GetZeroVector(QualType T) {
const VectorType *VT = T->getAsVectorType();
QualType EltTy = VT->getElementType();
@@ -677,20 +673,20 @@ public:
}
return false;
}
-
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
-
+
bool VisitStmt(Stmt *) {
assert(0 && "This should be called on integers, stmts are not integers");
return false;
}
-
+
bool VisitExpr(Expr *E) {
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
}
-
+
bool VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
bool VisitIntegerLiteral(const IntegerLiteral *E) {
@@ -705,7 +701,7 @@ public:
// be able to strip CRV qualifiers from the type.
QualType T0 = Info.Ctx.getCanonicalType(E->getArgType1());
QualType T1 = Info.Ctx.getCanonicalType(E->getArgType2());
- return Success(Info.Ctx.typesAreCompatible(T0.getUnqualifiedType(),
+ return Success(Info.Ctx.typesAreCompatible(T0.getUnqualifiedType(),
T1.getUnqualifiedType()),
E);
}
@@ -721,11 +717,11 @@ public:
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
return Success(E->getValue(), E);
}
-
+
bool VisitGNUNullExpr(const GNUNullExpr *E) {
return Success(0, E);
}
-
+
bool VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
return Success(0, E);
}
@@ -755,7 +751,7 @@ private:
static bool EvaluateIntegerOrLValue(const Expr* E, APValue &Result, EvalInfo &Info) {
if (!E->getType()->isIntegralType())
return false;
-
+
return IntExprEvaluator(Info, Result).Visit(const_cast<Expr*>(E));
}
@@ -818,12 +814,12 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) {
array_type_class, string_type_class,
lang_type_class
};
-
- // If no argument was supplied, default to "no_type_class". This isn't
+
+ // If no argument was supplied, default to "no_type_class". This isn't
// ideal, however it is what gcc does.
if (E->getNumArgs() == 0)
return no_type_class;
-
+
QualType ArgTy = E->getArg(0)->getType();
if (ArgTy->isVoidType())
return void_type_class;
@@ -864,7 +860,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) {
return Error(E->getLocStart(), diag::note_invalid_subexpr_in_ice, E);
case Builtin::BI__builtin_classify_type:
return Success(EvaluateBuiltinClassifyType(E), E);
-
+
case Builtin::BI__builtin_constant_p:
// __builtin_constant_p always has one operand: it returns true if that
// operand can be folded, false otherwise.
@@ -889,7 +885,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
// These need to be handled specially because the operands aren't
// necessarily integral
bool lhsResult, rhsResult;
-
+
if (HandleConversionToBool(E->getLHS(), lhsResult, Info)) {
// We were able to evaluate the LHS, see if we can get away with not
// evaluating the RHS: 0 && X -> 0, 1 || X -> 1
@@ -906,7 +902,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (HandleConversionToBool(E->getRHS(), rhsResult, Info)) {
// We can't evaluate the LHS; however, sometimes the result
// is determined by the RHS: X && 0 -> 0, X || 1 -> 1.
- if (rhsResult == (E->getOpcode() == BinaryOperator::LOr) ||
+ if (rhsResult == (E->getOpcode() == BinaryOperator::LOr) ||
!rhsResult == (E->getOpcode() == BinaryOperator::LAnd)) {
// Since we weren't able to evaluate the left hand side, it
// must have had side effects.
@@ -934,9 +930,9 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return false;
if (LHS.isComplexFloat()) {
- APFloat::cmpResult CR_r =
+ APFloat::cmpResult CR_r =
LHS.getComplexFloatReal().compare(RHS.getComplexFloatReal());
- APFloat::cmpResult CR_i =
+ APFloat::cmpResult CR_i =
LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag());
if (E->getOpcode() == BinaryOperator::EQ)
@@ -945,9 +941,9 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
else {
assert(E->getOpcode() == BinaryOperator::NE &&
"Invalid complex comparison.");
- return Success(((CR_r == APFloat::cmpGreaterThan ||
+ return Success(((CR_r == APFloat::cmpGreaterThan ||
CR_r == APFloat::cmpLessThan) &&
- (CR_i == APFloat::cmpGreaterThan ||
+ (CR_i == APFloat::cmpGreaterThan ||
CR_i == APFloat::cmpLessThan)), E);
}
} else {
@@ -962,17 +958,17 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
}
}
}
-
+
if (LHSTy->isRealFloatingType() &&
RHSTy->isRealFloatingType()) {
APFloat RHS(0.0), LHS(0.0);
-
+
if (!EvaluateFloat(E->getRHS(), RHS, Info))
return false;
-
+
if (!EvaluateFloat(E->getLHS(), LHS, Info))
return false;
-
+
APFloat::cmpResult CR = LHS.compare(RHS);
switch (E->getOpcode()) {
@@ -985,16 +981,16 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
case BinaryOperator::LE:
return Success(CR == APFloat::cmpLessThan || CR == APFloat::cmpEqual, E);
case BinaryOperator::GE:
- return Success(CR == APFloat::cmpGreaterThan || CR == APFloat::cmpEqual,
+ return Success(CR == APFloat::cmpGreaterThan || CR == APFloat::cmpEqual,
E);
case BinaryOperator::EQ:
return Success(CR == APFloat::cmpEqual, E);
case BinaryOperator::NE:
- return Success(CR == APFloat::cmpGreaterThan
+ return Success(CR == APFloat::cmpGreaterThan
|| CR == APFloat::cmpLessThan, E);
}
}
-
+
if (LHSTy->isPointerType() && RHSTy->isPointerType()) {
if (E->getOpcode() == BinaryOperator::Sub || E->isEqualityOp()) {
APValue LHSValue;
@@ -1106,16 +1102,16 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return Success(Result.getInt() % RHS, E);
case BinaryOperator::Shl: {
// FIXME: Warn about out of range shift amounts!
- unsigned SA =
+ unsigned SA =
(unsigned) RHS.getLimitedValue(Result.getInt().getBitWidth()-1);
return Success(Result.getInt() << SA, E);
}
case BinaryOperator::Shr: {
- unsigned SA =
+ unsigned SA =
(unsigned) RHS.getLimitedValue(Result.getInt().getBitWidth()-1);
return Success(Result.getInt() >> SA, E);
}
-
+
case BinaryOperator::LT: return Success(Result.getInt() < RHS, E);
case BinaryOperator::GT: return Success(Result.getInt() > RHS, E);
case BinaryOperator::LE: return Success(Result.getInt() <= RHS, E);
@@ -1145,7 +1141,7 @@ unsigned IntExprEvaluator::GetAlignOfExpr(const Expr *E) {
E = E->IgnoreParens();
// alignof decl is always accepted, even if it doesn't make sense: we default
- // to 1 in those cases.
+ // to 1 in those cases.
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
return Info.Ctx.getDeclAlignInBytes(DRE->getDecl());
@@ -1225,7 +1221,7 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
// If so, we could clear the diagnostic ID.
return true;
case UnaryOperator::Plus:
- // The result is always just the subexpr.
+ // The result is always just the subexpr.
return true;
case UnaryOperator::Minus:
if (!Result.isInt()) return false;
@@ -1235,7 +1231,7 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
return Success(~Result.getInt(), E);
}
}
-
+
/// HandleCast - This is used to evaluate implicit or explicit casts where the
/// result type is integer.
bool IntExprEvaluator::VisitCastExpr(CastExpr *E) {
@@ -1263,7 +1259,7 @@ bool IntExprEvaluator::VisitCastExpr(CastExpr *E) {
return Success(HandleIntToIntCast(DestType, SrcType,
Result.getInt(), Info.Ctx), E);
}
-
+
// FIXME: Clean this up!
if (SrcType->isPointerType()) {
APValue LV;
@@ -1317,7 +1313,7 @@ bool IntExprEvaluator::VisitCastExpr(CastExpr *E) {
APFloat F(0.0);
if (!EvaluateFloat(SubExpr, F, Info))
return Error(E->getExprLoc(), diag::note_invalid_subexpr_in_ice, E);
-
+
return Success(HandleFloatToIntCast(DestType, SrcType, F, Info.Ctx), E);
}
@@ -1400,13 +1396,13 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
Result = llvm::APFloat::getInf(Sem);
return true;
}
-
+
case Builtin::BI__builtin_nan:
case Builtin::BI__builtin_nanf:
case Builtin::BI__builtin_nanl:
// If this is __builtin_nan() turn this into a nan, otherwise we
// can't constant fold it.
- if (const StringLiteral *S =
+ if (const StringLiteral *S =
dyn_cast<StringLiteral>(E->getArg(0)->IgnoreParenCasts())) {
if (!S->isWide()) {
const llvm::fltSemantics &Sem =
@@ -1431,13 +1427,13 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
case Builtin::BI__builtin_fabsl:
if (!EvaluateFloat(E->getArg(0), Result, Info))
return false;
-
+
if (Result.isNegative())
Result.changeSign();
return true;
- case Builtin::BI__builtin_copysign:
- case Builtin::BI__builtin_copysignf:
+ case Builtin::BI__builtin_copysign:
+ case Builtin::BI__builtin_copysignf:
case Builtin::BI__builtin_copysignl: {
APFloat RHS(0.);
if (!EvaluateFloat(E->getArg(0), Result, Info) ||
@@ -1458,7 +1454,7 @@ bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
switch (E->getOpcode()) {
default: return false;
- case UnaryOperator::Plus:
+ case UnaryOperator::Plus:
return true;
case UnaryOperator::Minus:
Result.changeSign();
@@ -1499,12 +1495,12 @@ bool FloatExprEvaluator::VisitFloatingLiteral(const FloatingLiteral *E) {
bool FloatExprEvaluator::VisitCastExpr(CastExpr *E) {
Expr* SubExpr = E->getSubExpr();
-
+
if (SubExpr->getType()->isIntegralType()) {
APSInt IntResult;
if (!EvaluateInteger(SubExpr, IntResult, Info))
return false;
- Result = HandleIntToFloatCast(E->getType(), SubExpr->getType(),
+ Result = HandleIntToFloatCast(E->getType(), SubExpr->getType(),
IntResult, Info.Ctx);
return true;
}
@@ -1533,10 +1529,10 @@ namespace {
class VISIBILITY_HIDDEN ComplexExprEvaluator
: public StmtVisitor<ComplexExprEvaluator, APValue> {
EvalInfo &Info;
-
+
public:
ComplexExprEvaluator(EvalInfo &info) : Info(info) {}
-
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
@@ -1544,7 +1540,7 @@ public:
APValue VisitStmt(Stmt *S) {
return APValue();
}
-
+
APValue VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
APValue VisitImaginaryLiteral(ImaginaryLiteral *E) {
@@ -1555,17 +1551,17 @@ public:
if (!EvaluateFloat(SubExpr, Result, Info))
return APValue();
-
- return APValue(APFloat(Result.getSemantics(), APFloat::fcZero, false),
+
+ return APValue(APFloat(Result.getSemantics(), APFloat::fcZero, false),
Result);
} else {
- assert(SubExpr->getType()->isIntegerType() &&
+ assert(SubExpr->getType()->isIntegerType() &&
"Unexpected imaginary literal.");
llvm::APSInt Result;
if (!EvaluateInteger(SubExpr, Result, Info))
return APValue();
-
+
llvm::APSInt Zero(Result.getBitWidth(), !Result.isSigned());
Zero = 0;
return APValue(Zero, Result);
@@ -1585,7 +1581,7 @@ public:
if (EltType->isRealFloatingType()) {
Result = HandleFloatToFloatCast(EltType, SubType, Result, Info.Ctx);
- return APValue(Result,
+ return APValue(Result,
APFloat(Result.getSemantics(), APFloat::fcZero, false));
} else {
llvm::APSInt IResult;
@@ -1603,7 +1599,7 @@ public:
if (EltType->isRealFloatingType()) {
APFloat FResult =
HandleIntToFloatCast(EltType, SubType, Result, Info.Ctx);
- return APValue(FResult,
+ return APValue(FResult,
APFloat(FResult.getSemantics(), APFloat::fcZero, false));
} else {
Result = HandleIntToIntCast(EltType, SubType, Result, Info.Ctx);
@@ -1621,36 +1617,36 @@ public:
if (Src.isComplexFloat()) {
if (EltType->isRealFloatingType()) {
- return APValue(HandleFloatToFloatCast(EltType, SrcType,
+ return APValue(HandleFloatToFloatCast(EltType, SrcType,
Src.getComplexFloatReal(),
Info.Ctx),
- HandleFloatToFloatCast(EltType, SrcType,
+ HandleFloatToFloatCast(EltType, SrcType,
Src.getComplexFloatImag(),
Info.Ctx));
} else {
return APValue(HandleFloatToIntCast(EltType, SrcType,
Src.getComplexFloatReal(),
Info.Ctx),
- HandleFloatToIntCast(EltType, SrcType,
+ HandleFloatToIntCast(EltType, SrcType,
Src.getComplexFloatImag(),
- Info.Ctx));
+ Info.Ctx));
}
} else {
assert(Src.isComplexInt() && "Invalid evaluate result.");
if (EltType->isRealFloatingType()) {
- return APValue(HandleIntToFloatCast(EltType, SrcType,
+ return APValue(HandleIntToFloatCast(EltType, SrcType,
Src.getComplexIntReal(),
Info.Ctx),
- HandleIntToFloatCast(EltType, SrcType,
+ HandleIntToFloatCast(EltType, SrcType,
Src.getComplexIntImag(),
Info.Ctx));
} else {
return APValue(HandleIntToIntCast(EltType, SrcType,
Src.getComplexIntReal(),
Info.Ctx),
- HandleIntToIntCast(EltType, SrcType,
+ HandleIntToIntCast(EltType, SrcType,
Src.getComplexIntImag(),
- Info.Ctx));
+ Info.Ctx));
}
}
}
@@ -1658,7 +1654,7 @@ public:
// FIXME: Handle more casts.
return APValue();
}
-
+
APValue VisitBinaryOperator(const BinaryOperator *E);
APValue VisitChooseExpr(const ChooseExpr *E)
{ return Visit(E->getChosenSubExpr(Info.Ctx)); }
@@ -1669,23 +1665,21 @@ public:
};
} // end anonymous namespace
-static bool EvaluateComplex(const Expr *E, APValue &Result, EvalInfo &Info)
-{
+static bool EvaluateComplex(const Expr *E, APValue &Result, EvalInfo &Info) {
Result = ComplexExprEvaluator(Info).Visit(const_cast<Expr*>(E));
assert((!Result.isComplexFloat() ||
- (&Result.getComplexFloatReal().getSemantics() ==
- &Result.getComplexFloatImag().getSemantics())) &&
+ (&Result.getComplexFloatReal().getSemantics() ==
+ &Result.getComplexFloatImag().getSemantics())) &&
"Invalid complex evaluation.");
return Result.isComplexFloat() || Result.isComplexInt();
}
-APValue ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E)
-{
+APValue ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
APValue Result, RHS;
-
+
if (!EvaluateComplex(E->getLHS(), Result, Info))
return APValue();
-
+
if (!EvaluateComplex(E->getRHS(), RHS, Info))
return APValue();
@@ -1722,7 +1716,7 @@ APValue ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E)
APFloat &LHS_i = LHS.getComplexFloatImag();
APFloat &RHS_r = RHS.getComplexFloatReal();
APFloat &RHS_i = RHS.getComplexFloatImag();
-
+
APFloat Tmp = LHS_r;
Tmp.multiply(RHS_r, APFloat::rmNearestTiesToEven);
Result.getComplexFloatReal() = Tmp;
@@ -1738,10 +1732,10 @@ APValue ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E)
Result.getComplexFloatImag().add(Tmp, APFloat::rmNearestTiesToEven);
} else {
APValue LHS = Result;
- Result.getComplexIntReal() =
+ Result.getComplexIntReal() =
(LHS.getComplexIntReal() * RHS.getComplexIntReal() -
LHS.getComplexIntImag() * RHS.getComplexIntImag());
- Result.getComplexIntImag() =
+ Result.getComplexIntImag() =
(LHS.getComplexIntReal() * RHS.getComplexIntImag() +
LHS.getComplexIntImag() * RHS.getComplexIntReal());
}
@@ -1775,7 +1769,7 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
llvm::APFloat f(0.0);
if (!EvaluateFloat(this, f, Info))
return false;
-
+
Result.Val = APValue(f);
} else if (getType()->isAnyComplexType()) {
if (!EvaluateComplex(this, Result.Val, Info))
diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp
index 323048c88b..c47a9dadba 100644
--- a/lib/AST/InheritViz.cpp
+++ b/lib/AST/InheritViz.cpp
@@ -89,7 +89,7 @@ void InheritanceHierarchyWriter::WriteNode(QualType Type, bool FromVirtual) {
Out << " \"];\n";
// Display the base classes.
- const CXXRecordDecl *Decl
+ const CXXRecordDecl *Decl
= static_cast<const CXXRecordDecl *>(Type->getAs<RecordType>()->getDecl());
for (CXXRecordDecl::base_class_const_iterator Base = Decl->bases_begin();
Base != Decl->bases_end(); ++Base) {
@@ -120,8 +120,8 @@ void InheritanceHierarchyWriter::WriteNode(QualType Type, bool FromVirtual) {
/// WriteNodeReference - Write out a reference to the given node,
/// using a unique identifier for each direct base and for the
/// (only) virtual base.
-llvm::raw_ostream&
-InheritanceHierarchyWriter::WriteNodeReference(QualType Type,
+llvm::raw_ostream&
+InheritanceHierarchyWriter::WriteNodeReference(QualType Type,
bool FromVirtual) {
QualType CanonType = Context.getCanonicalType(Type);
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index 2ed8eb0099..d969776aa0 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -22,13 +22,13 @@
using namespace clang;
NestedNameSpecifier *
-NestedNameSpecifier::FindOrInsert(ASTContext &Context,
+NestedNameSpecifier::FindOrInsert(ASTContext &Context,
const NestedNameSpecifier &Mockup) {
llvm::FoldingSetNodeID ID;
Mockup.Profile(ID);
void *InsertPos = 0;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= Context.NestedNameSpecifiers.FindNodeOrInsertPos(ID, InsertPos);
if (!NNS) {
NNS = new (Context, 4) NestedNameSpecifier(Mockup);
@@ -39,7 +39,7 @@ NestedNameSpecifier::FindOrInsert(ASTContext &Context,
}
NestedNameSpecifier *
-NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix,
+NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix,
IdentifierInfo *II) {
assert(II && "Identifier cannot be NULL");
assert((!Prefix || Prefix->isDependent()) && "Prefix must be dependent");
@@ -52,10 +52,10 @@ NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix,
}
NestedNameSpecifier *
-NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix,
+NestedNameSpecifier::Create(ASTContext &Context, NestedNameSpecifier *Prefix,
NamespaceDecl *NS) {
assert(NS && "Namespace cannot be NULL");
- assert((!Prefix ||
+ assert((!Prefix ||
(Prefix->getAsType() == 0 && Prefix->getAsIdentifier() == 0)) &&
"Broken nested name specifier");
NestedNameSpecifier Mockup;
@@ -115,8 +115,8 @@ bool NestedNameSpecifier::isDependent() const {
/// \brief Print this nested name specifier to the given output
/// stream.
-void
-NestedNameSpecifier::print(llvm::raw_ostream &OS,
+void
+NestedNameSpecifier::print(llvm::raw_ostream &OS,
const PrintingPolicy &Policy) const {
if (getPrefix())
getPrefix()->print(OS, Policy);
@@ -144,26 +144,26 @@ NestedNameSpecifier::print(llvm::raw_ostream &OS,
PrintingPolicy InnerPolicy(Policy);
InnerPolicy.SuppressTagKind = true;
InnerPolicy.SuppressScope = true;
-
+
// Nested-name-specifiers are intended to contain minimally-qualified
// types. An actual QualifiedNameType will not occur, since we'll store
// just the type that is referred to in the nested-name-specifier (e.g.,
// a TypedefType, TagType, etc.). However, when we are dealing with
- // dependent template-id types (e.g., Outer<T>::template Inner<U>),
+ // dependent template-id types (e.g., Outer<T>::template Inner<U>),
// the type requires its own nested-name-specifier for uniqueness, so we
// suppress that nested-name-specifier during printing.
- assert(!isa<QualifiedNameType>(T) &&
+ assert(!isa<QualifiedNameType>(T) &&
"Qualified name type in nested-name-specifier");
if (const TemplateSpecializationType *SpecType
= dyn_cast<TemplateSpecializationType>(T)) {
- // Print the template name without its corresponding
+ // Print the template name without its corresponding
// nested-name-specifier.
SpecType->getTemplateName().print(OS, InnerPolicy, true);
-
+
// Print the template argument list.
TypeStr = TemplateSpecializationType::PrintTemplateArgumentList(
- SpecType->getArgs(),
- SpecType->getNumArgs(),
+ SpecType->getArgs(),
+ SpecType->getNumArgs(),
InnerPolicy);
} else {
// Print the type normally
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp
index 9d87daa0bf..48251d52fd 100644
--- a/lib/AST/ParentMap.cpp
+++ b/lib/AST/ParentMap.cpp
@@ -32,7 +32,7 @@ ParentMap::ParentMap(Stmt* S) : Impl(0) {
if (S) {
MapTy *M = new MapTy();
BuildParentMap(*M, S);
- Impl = M;
+ Impl = M;
}
}
@@ -54,16 +54,16 @@ Stmt *ParentMap::getParentIgnoreParens(Stmt *S) const {
bool ParentMap::isConsumedExpr(Expr* E) const {
Stmt *P = getParent(E);
Stmt *DirectChild = E;
-
+
// Ignore parents that are parentheses or casts.
while (P && (isa<ParenExpr>(P) || isa<CastExpr>(P))) {
DirectChild = P;
P = getParent(P);
}
-
+
if (!P)
return false;
-
+
switch (P->getStmtClass()) {
default:
return isa<Expr>(P);
@@ -78,7 +78,7 @@ bool ParentMap::isConsumedExpr(Expr* E) const {
case Stmt::ForStmtClass:
return DirectChild == cast<ForStmt>(P)->getCond();
case Stmt::WhileStmtClass:
- return DirectChild == cast<WhileStmt>(P)->getCond();
+ return DirectChild == cast<WhileStmt>(P)->getCond();
case Stmt::DoStmtClass:
return DirectChild == cast<DoStmt>(P)->getCond();
case Stmt::IfStmtClass:
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index 071e3e8955..05b5ee977c 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -21,8 +21,8 @@
using namespace clang;
-ASTRecordLayoutBuilder::ASTRecordLayoutBuilder(ASTContext &Ctx)
- : Ctx(Ctx), Size(0), Alignment(8), Packed(false), MaxFieldAlignment(0),
+ASTRecordLayoutBuilder::ASTRecordLayoutBuilder(ASTContext &Ctx)
+ : Ctx(Ctx), Size(0), Alignment(8), Packed(false), MaxFieldAlignment(0),
NextOffset(0), IsUnion(false), NonVirtualSize(0), NonVirtualAlignment(8) {}
/// LayoutVtable - Lay out the vtable and set PrimaryBase.
@@ -43,12 +43,12 @@ void ASTRecordLayoutBuilder::LayoutVtable(const CXXRecordDecl *RD,
}
}
-void
+void
ASTRecordLayoutBuilder::LayoutNonVirtualBases(const CXXRecordDecl *RD) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
if (!i->isVirtual()) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
// Skip the PrimaryBase here, as it is laid down first.
if (Base != PrimaryBase || PrimaryBaseWasVirtual)
@@ -83,7 +83,7 @@ void ASTRecordLayoutBuilder::SelectPrimaryForBase(const CXXRecordDecl *RD,
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
// Only bases with virtual bases participate in computing the
// indirect primary virtual base classes.
@@ -97,7 +97,7 @@ void ASTRecordLayoutBuilder::SelectPrimaryVBase(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (!i->isVirtual()) {
SelectPrimaryVBase(Base, FirstPrimary, IndirectPrimary);
@@ -125,7 +125,7 @@ void ASTRecordLayoutBuilder::SelectPrimaryBase(const CXXRecordDecl *RD,
const CXXRecordDecl *FirstPrimary = 0;
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
SelectPrimaryForBase(Base, IndirectPrimary);
}
@@ -135,7 +135,7 @@ void ASTRecordLayoutBuilder::SelectPrimaryBase(const CXXRecordDecl *RD,
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
if (!i->isVirtual()) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base->isDynamicClass()) {
setPrimaryBase(Base, false);
@@ -174,7 +174,7 @@ void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
#if 0
const ASTRecordLayout &L = Ctx.getASTRecordLayout(Base);
@@ -224,12 +224,12 @@ void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
void ASTRecordLayoutBuilder::LayoutBaseNonVirtually(const CXXRecordDecl *RD,
bool IsVirtualBase) {
const ASTRecordLayout &BaseInfo = Ctx.getASTRecordLayout(RD);
- assert(BaseInfo.getDataSize() > 0 &&
+ assert(BaseInfo.getDataSize() > 0 &&
"FIXME: Handle empty classes.");
-
+
unsigned BaseAlign = BaseInfo.getNonVirtualAlign();
uint64_t BaseSize = BaseInfo.getNonVirtualSize();
-
+
// Round up the current record size to the base's alignment boundary.
Size = (Size + (BaseAlign-1)) & ~(BaseAlign-1);
@@ -260,10 +260,10 @@ void ASTRecordLayoutBuilder::LayoutBaseNonVirtually(const CXXRecordDecl *RD,
// Reserve space for this base.
Size += BaseSize;
-
+
// Remember the next available offset.
NextOffset = Size;
-
+
// Remember max struct/class alignment.
UpdateAlignment(BaseAlign);
}
@@ -276,7 +276,7 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
// The #pragma pack attribute specifies the maximum field alignment.
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
MaxFieldAlignment = PPA->getAlignment();
-
+
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
UpdateAlignment(AA->getAlignment());
@@ -296,7 +296,7 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
}
LayoutFields(D);
-
+
NonVirtualSize = Size;
NonVirtualAlignment = Alignment;
@@ -316,28 +316,28 @@ void ASTRecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D,
const ASTRecordLayout &SL = Ctx.getASTObjCInterfaceLayout(SD);
UpdateAlignment(SL.getAlignment());
-
+
// We start laying out ivars not at the end of the superclass
// structure, but at the next byte following the last field.
Size = llvm::RoundUpToAlignment(SL.getDataSize(), 8);
NextOffset = Size;
}
-
+
Packed = D->hasAttr<PackedAttr>();
-
+
// The #pragma pack attribute specifies the maximum field alignment.
if (const PragmaPackAttr *PPA = D->getAttr<PragmaPackAttr>())
MaxFieldAlignment = PPA->getAlignment();
-
+
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
UpdateAlignment(AA->getAlignment());
-
+
// Layout each ivar sequentially.
llvm::SmallVector<ObjCIvarDecl*, 16> Ivars;
Ctx.ShallowCollectObjCIvars(D, Ivars, Impl);
for (unsigned i = 0, e = Ivars.size(); i != e; ++i)
LayoutField(Ivars[i]);
-
+
// Finally, round the size of the total struct up to the alignment of the
// struct itself.
FinishLayout();
@@ -346,7 +346,7 @@ void ASTRecordLayoutBuilder::Layout(const ObjCInterfaceDecl *D,
void ASTRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
// Layout each field, for now, just sequentially, respecting alignment. In
// the future, this will need to be tweakable by targets.
- for (RecordDecl::field_iterator Field = D->field_begin(),
+ for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field)
LayoutField(*Field);
}
@@ -356,19 +356,19 @@ void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
uint64_t FieldOffset = IsUnion ? 0 : Size;
uint64_t FieldSize;
unsigned FieldAlign;
-
- FieldPacked |= D->hasAttr<PackedAttr>();
-
+
+ FieldPacked |= D->hasAttr<PackedAttr>();
+
if (const Expr *BitWidthExpr = D->getBitWidth()) {
// TODO: Need to check this algorithm on other targets!
// (tested on Linux-X86)
FieldSize = BitWidthExpr->EvaluateAsInt(Ctx).getZExtValue();
-
+
std::pair<uint64_t, unsigned> FieldInfo = Ctx.getTypeInfo(D->getType());
uint64_t TypeSize = FieldInfo.first;
FieldAlign = FieldInfo.second;
-
+
if (FieldPacked)
FieldAlign = 1;
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
@@ -381,7 +381,7 @@ void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
// alignment.
if (FieldSize == 0 || (FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)
FieldOffset = (FieldOffset + (FieldAlign-1)) & ~(FieldAlign-1);
-
+
// Padding members don't affect overall alignment
if (!D->getIdentifier())
FieldAlign = 1;
@@ -403,7 +403,7 @@ void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
FieldSize = FieldInfo.first;
FieldAlign = FieldInfo.second;
}
-
+
if (FieldPacked)
FieldAlign = 8;
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
@@ -411,23 +411,23 @@ void ASTRecordLayoutBuilder::LayoutField(const FieldDecl *D) {
// The maximum field alignment overrides the aligned attribute.
if (MaxFieldAlignment)
FieldAlign = std::min(FieldAlign, MaxFieldAlignment);
-
+
// Round up the current record size to the field's alignment boundary.
FieldOffset = (FieldOffset + (FieldAlign-1)) & ~(FieldAlign-1);
}
-
+
// Place this field at the current location.
FieldOffsets.push_back(FieldOffset);
-
+
// Reserve space for this field.
if (IsUnion)
Size = std::max(Size, FieldSize);
else
Size = FieldOffset + FieldSize;
-
+
// Remember the next available offset.
NextOffset = Size;
-
+
// Remember max struct/class alignment.
UpdateAlignment(FieldAlign);
}
@@ -444,14 +444,14 @@ void ASTRecordLayoutBuilder::FinishLayout() {
void ASTRecordLayoutBuilder::UpdateAlignment(unsigned NewAlignment) {
if (NewAlignment <= Alignment)
return;
-
+
assert(llvm::isPowerOf2_32(NewAlignment && "Alignment not a power of 2"));
-
+
Alignment = NewAlignment;
}
-
+
const ASTRecordLayout *
-ASTRecordLayoutBuilder::ComputeLayout(ASTContext &Ctx,
+ASTRecordLayoutBuilder::ComputeLayout(ASTContext &Ctx,
const RecordDecl *D) {
ASTRecordLayoutBuilder Builder(Ctx);
@@ -459,27 +459,27 @@ ASTRecordLayoutBuilder::ComputeLayout(ASTContext &Ctx,
if (!isa<CXXRecordDecl>(D))
return new ASTRecordLayout(Builder.Size, Builder.Alignment, Builder.Size,
- Builder.FieldOffsets.data(),
+ Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
-
+
// FIXME: This is not always correct. See the part about bitfields at
// http://www.codesourcery.com/public/cxx-abi/abi.html#POD for more info.
// FIXME: IsPODForThePurposeOfLayout should be stored in the record layout.
bool IsPODForThePurposeOfLayout = cast<CXXRecordDecl>(D)->isPOD();
-
- assert(Builder.Bases.size() == Builder.BaseOffsets.size() &&
+
+ assert(Builder.Bases.size() == Builder.BaseOffsets.size() &&
"Base offsets vector must be same size as bases vector!");
- assert(Builder.VBases.size() == Builder.VBaseOffsets.size() &&
+ assert(Builder.VBases.size() == Builder.VBaseOffsets.size() &&
"Base offsets vector must be same size as bases vector!");
// FIXME: This should be done in FinalizeLayout.
- uint64_t DataSize =
+ uint64_t DataSize =
IsPODForThePurposeOfLayout ? Builder.Size : Builder.NextOffset;
- uint64_t NonVirtualSize =
+ uint64_t NonVirtualSize =
IsPODForThePurposeOfLayout ? DataSize : Builder.NonVirtualSize;
-
+
return new ASTRecordLayout(Builder.Size, Builder.Alignment, DataSize,
- Builder.FieldOffsets.data(),
+ Builder.FieldOffsets.data(),
Builder.FieldOffsets.size(),
NonVirtualSize,
Builder.NonVirtualAlignment,
@@ -498,11 +498,11 @@ ASTRecordLayoutBuilder::ComputeLayout(ASTContext &Ctx,
const ObjCInterfaceDecl *D,
const ObjCImplementationDecl *Impl) {
ASTRecordLayoutBuilder Builder(Ctx);
-
+
Builder.Layout(D, Impl);
-
+
return new ASTRecordLayout(Builder.Size, Builder.Alignment,
Builder.NextOffset,
- Builder.FieldOffsets.data(),
+ Builder.FieldOffsets.data(),
Builder.FieldOffsets.size());
}
diff --git a/lib/AST/RecordLayoutBuilder.h b/lib/AST/RecordLayoutBuilder.h
index 5813e27a84..efaa2eeb98 100644
--- a/lib/AST/RecordLayoutBuilder.h
+++ b/lib/AST/RecordLayoutBuilder.h
@@ -22,19 +22,19 @@ namespace clang {
class ObjCImplementationDecl;
class ObjCInterfaceDecl;
class RecordDecl;
-
+
class ASTRecordLayoutBuilder {
ASTContext &Ctx;
uint64_t Size;
unsigned Alignment;
llvm::SmallVector<uint64_t, 16> FieldOffsets;
-
+
bool Packed;
unsigned MaxFieldAlignment;
uint64_t NextOffset;
bool IsUnion;
-
+
uint64_t NonVirtualSize;
unsigned NonVirtualAlignment;
const CXXRecordDecl *PrimaryBase;
@@ -45,9 +45,9 @@ class ASTRecordLayoutBuilder {
llvm::SmallVector<const CXXRecordDecl *, 4> VBases;
llvm::SmallVector<uint64_t, 4> VBaseOffsets;
-
+
ASTRecordLayoutBuilder(ASTContext &Ctx);
-
+
void Layout(const RecordDecl *D);
void Layout(const CXXRecordDecl *D);
void Layout(const ObjCInterfaceDecl *D,
@@ -77,23 +77,23 @@ class ASTRecordLayoutBuilder {
int64_t Offset,
llvm::SmallSet<const CXXRecordDecl*, 32> &mark,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary);
-
+
/// FinishLayout - Finalize record layout. Adjust record size based on the
/// alignment.
void FinishLayout();
-
+
void UpdateAlignment(unsigned NewAlignment);
ASTRecordLayoutBuilder(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
void operator=(const ASTRecordLayoutBuilder&); // DO NOT IMPLEMENT
public:
- static const ASTRecordLayout *ComputeLayout(ASTContext &Ctx,
+ static const ASTRecordLayout *ComputeLayout(ASTContext &Ctx,
const RecordDecl *RD);
static const ASTRecordLayout *ComputeLayout(ASTContext &Ctx,
const ObjCInterfaceDecl *D,
const ObjCImplementationDecl *Impl);
};
-
+
} // end namespace clang
#endif
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index f230018c0d..3a838fadaf 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -95,7 +95,7 @@ bool Stmt::CollectingStats(bool enable) {
void SwitchStmt::DoDestroy(ASTContext &Ctx) {
// Destroy the SwitchCase statements in this switch. In the normal
- // case, this loop will merely decrement the reference counts from
+ // case, this loop will merely decrement the reference counts from
// the Retain() calls in addSwitchCase();
SwitchCase *SC = FirstCase;
while (SC) {
@@ -103,7 +103,7 @@ void SwitchStmt::DoDestroy(ASTContext &Ctx) {
SC->Destroy(Ctx);
SC = Next;
}
-
+
Stmt::DoDestroy(Ctx);
}
@@ -187,7 +187,7 @@ std::string AsmStmt::getInputConstraint(unsigned i) const {
void AsmStmt::setOutputsAndInputs(unsigned NumOutputs,
- unsigned NumInputs,
+ unsigned NumInputs,
const std::string *Names,
StringLiteral **Constraints,
Stmt **Exprs) {
@@ -196,7 +196,7 @@ void AsmStmt::setOutputsAndInputs(unsigned NumOutputs,
this->Names.clear();
this->Names.insert(this->Names.end(), Names, Names + NumOutputs + NumInputs);
this->Constraints.clear();
- this->Constraints.insert(this->Constraints.end(),
+ this->Constraints.insert(this->Constraints.end(),
Constraints, Constraints + NumOutputs + NumInputs);
this->Exprs.clear();
this->Exprs.insert(this->Exprs.end(), Exprs, Exprs + NumOutputs + NumInputs);
@@ -207,13 +207,13 @@ void AsmStmt::setOutputsAndInputs(unsigned NumOutputs,
/// This returns -1 if the operand name is invalid.
int AsmStmt::getNamedOperand(const std::string &SymbolicName) const {
unsigned NumPlusOperands = 0;
-
+
// Check if this is an output operand.
for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
if (getOutputName(i) == SymbolicName)
return i;
}
-
+
for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
if (getInputName(i) == SymbolicName)
return getNumOutputs() + NumPlusOperands + i;
@@ -235,7 +235,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
const char *StrStart = getAsmString()->getStrData();
const char *StrEnd = StrStart + getAsmString()->getByteLength();
const char *CurPtr = StrStart;
-
+
// "Simple" inline asms have no constraints or operands, just convert the asm
// string to escape $'s.
if (isSimple()) {
@@ -257,7 +257,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
// CurStringPiece - The current string that we are building up as we scan the
// asm string.
std::string CurStringPiece;
-
+
while (1) {
// Done with the string?
if (CurPtr == StrEnd) {
@@ -265,7 +265,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
Pieces.push_back(AsmStringPiece(CurStringPiece));
return 0;
}
-
+
char CurChar = *CurPtr++;
if (CurChar == '$') {
CurStringPiece += "$$";
@@ -274,48 +274,48 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
CurStringPiece += CurChar;
continue;
}
-
+
// Escaped "%" character in asm string.
if (CurPtr == StrEnd) {
// % at end of string is invalid (no escape).
DiagOffs = CurPtr-StrStart-1;
return diag::err_asm_invalid_escape;
}
-
+
char EscapedChar = *CurPtr++;
if (EscapedChar == '%') { // %% -> %
// Escaped percentage sign.
CurStringPiece += '%';
continue;
}
-
+
if (EscapedChar == '=') { // %= -> Generate an unique ID.
CurStringPiece += "${:uid}";
continue;
}
-
+
// Otherwise, we have an operand. If we have accumulated a string so far,
// add it to the Pieces list.
if (!CurStringPiece.empty()) {
Pieces.push_back(AsmStringPiece(CurStringPiece));
CurStringPiece.clear();
}
-
+
// Handle %x4 and %x[foo] by capturing x as the modifier character.
char Modifier = '\0';
if (isalpha(EscapedChar)) {
Modifier = EscapedChar;
EscapedChar = *CurPtr++;
}
-
+
if (isdigit(EscapedChar)) {
// %n - Assembler operand n
unsigned N = 0;
-
+
--CurPtr;
while (CurPtr != StrEnd && isdigit(*CurPtr))
N = N*10 + ((*CurPtr++)-'0');
-
+
unsigned NumOperands =
getNumOutputs() + getNumPlusOperands() + getNumInputs();
if (N >= NumOperands) {
@@ -326,20 +326,20 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
Pieces.push_back(AsmStringPiece(N, Modifier));
continue;
}
-
+
// Handle %[foo], a symbolic operand reference.
if (EscapedChar == '[') {
DiagOffs = CurPtr-StrStart-1;
-
+
// Find the ']'.
const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr);
if (NameEnd == 0)
return diag::err_asm_unterminated_symbolic_operand_name;
if (NameEnd == CurPtr)
return diag::err_asm_empty_symbolic_operand_name;
-
+
std::string SymbolicName(CurPtr, NameEnd);
-
+
int N = getNamedOperand(SymbolicName);
if (N == -1) {
// Verify that an operand with that name exists.
@@ -347,11 +347,11 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
return diag::err_asm_unknown_symbolic_operand_name;
}
Pieces.push_back(AsmStringPiece(N, Modifier));
-
+
CurPtr = NameEnd+1;
continue;
}
-
+
DiagOffs = CurPtr-StrStart-1;
return diag::err_asm_invalid_escape;
}
@@ -509,7 +509,7 @@ Stmt::child_iterator ReturnStmt::child_end() {
}
// AsmStmt
-Stmt::child_iterator AsmStmt::child_begin() {
+Stmt::child_iterator AsmStmt::child_begin() {
return Exprs.empty() ? 0 : &Exprs[0];
}
Stmt::child_iterator AsmStmt::child_end() {
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index 5f320095e7..ed92da375f 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -30,12 +30,12 @@ namespace {
SourceManager *SM;
FILE *F;
unsigned IndentLevel;
-
+
/// MaxDepth - When doing a normal dump (not dumpAll) we only want to dump
/// the first few levels of an AST. This keeps track of how many ast levels
/// are left.
unsigned MaxDepth;
-
+
/// LastLocFilename/LastLocLine - Keep track of the last location we print
/// out so that we can print out deltas from then on out.
const char *LastLocFilename;
@@ -47,18 +47,18 @@ namespace {
LastLocFilename = "";
LastLocLine = ~0U;
}
-
+
void DumpSubTree(Stmt *S) {
// Prune the recursion if not using dump all.
if (MaxDepth == 0) return;
-
+
++IndentLevel;
if (S) {
if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
VisitDeclStmt(DS);
- else {
+ else {
Visit(S);
-
+
// Print out children.
Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
if (CI != CE) {
@@ -75,14 +75,14 @@ namespace {
}
--IndentLevel;
}
-
+
void DumpDeclarator(Decl *D);
-
+
void Indent() const {
for (int i = 0, e = IndentLevel; i < e; ++i)
fprintf(F, " ");
}
-
+
void DumpType(QualType T) {
fprintf(F, "'%s'", T.getAsString().c_str());
@@ -90,7 +90,7 @@ namespace {
// If the type is directly a typedef, strip off typedefness to give at
// least one level of concreteness.
if (TypedefType *TDT = dyn_cast<TypedefType>(T)) {
- QualType Simplified =
+ QualType Simplified =
TDT->LookThroughTypedefs().getQualifiedType(T.getCVRQualifiers());
fprintf(F, ":'%s'", Simplified.getAsString().c_str());
}
@@ -108,13 +108,13 @@ namespace {
}
void DumpSourceRange(const Stmt *Node);
void DumpLocation(SourceLocation Loc);
-
+
// Stmts.
void VisitStmt(Stmt *Node);
void VisitDeclStmt(DeclStmt *Node);
void VisitLabelStmt(LabelStmt *Node);
void VisitGotoStmt(GotoStmt *Node);
-
+
// Exprs
void VisitExpr(Expr *Node);
void VisitCastExpr(CastExpr *Node);
@@ -142,7 +142,7 @@ namespace {
void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node);
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *Node);
void DumpCXXTemporary(CXXTemporary *Temporary);
-
+
// ObjC
void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
void VisitObjCMessageExpr(ObjCMessageExpr* Node);
@@ -162,7 +162,7 @@ namespace {
void StmtDumper::DumpLocation(SourceLocation Loc) {
SourceLocation SpellingLoc = SM->getSpellingLoc(Loc);
-
+
if (SpellingLoc.isInvalid()) {
fprintf(stderr, "<invalid sloc>");
return;
@@ -188,11 +188,11 @@ void StmtDumper::DumpLocation(SourceLocation Loc) {
void StmtDumper::DumpSourceRange(const Stmt *Node) {
// Can't translate locations if a SourceManager isn't available.
if (SM == 0) return;
-
+
// TODO: If the parent expression is available, we can print a delta vs its
// location.
SourceRange R = Node->getSourceRange();
-
+
fprintf(stderr, " <");
DumpLocation(R.getBegin());
if (R.getBegin() != R.getEnd()) {
@@ -200,7 +200,7 @@ void StmtDumper::DumpSourceRange(const Stmt *Node) {
DumpLocation(R.getEnd());
}
fprintf(stderr, ">");
-
+
// <t2.c:123:421[blah], t2.c:412:321>
}
@@ -226,15 +226,15 @@ void StmtDumper::DumpDeclarator(Decl *D) {
// Emit storage class for vardecls.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
if (V->getStorageClass() != VarDecl::None)
- fprintf(F, "%s ",
+ fprintf(F, "%s ",
VarDecl::getStorageClassSpecifierString(V->getStorageClass()));
}
-
+
std::string Name = VD->getNameAsString();
- VD->getType().getAsStringInternal(Name,
+ VD->getType().getAsStringInternal(Name,
PrintingPolicy(VD->getASTContext().getLangOptions()));
fprintf(F, "%s", Name.c_str());
-
+
// If this is a vardecl with an initializer, emit it.
if (VarDecl *V = dyn_cast<VarDecl>(VD)) {
if (V->getInit()) {
@@ -321,15 +321,15 @@ void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
case Decl::ObjCInterface: fprintf(F,"ObjCInterface"); break;
case Decl::ObjCClass: fprintf(F,"ObjCClass"); break;
}
-
- fprintf(F, "='%s' %p", Node->getDecl()->getNameAsString().c_str(),
+
+ fprintf(F, "='%s' %p", Node->getDecl()->getNameAsString().c_str(),
(void*)Node->getDecl());
}
void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
DumpExpr(Node);
- fprintf(F, " %sDecl='%s' %p", Node->getDecl()->getDeclKindName(),
+ fprintf(F, " %sDecl='%s' %p", Node->getDecl()->getDeclKindName(),
Node->getDecl()->getNameAsString().c_str(), (void*)Node->getDecl());
if (Node->isFreeIvar())
fprintf(F, " isFreeIvar");
@@ -370,7 +370,7 @@ void StmtDumper::VisitStringLiteral(StringLiteral *Str) {
switch (char C = Str->getStrData()[i]) {
default:
if (isprint(C))
- fputc(C, F);
+ fputc(C, F);
else
fprintf(F, "\\%03o", C);
break;
@@ -401,7 +401,7 @@ void StmtDumper::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
DumpExpr(Node);
fprintf(F, " %s%s %p", Node->isArrow() ? "->" : ".",
- Node->getMemberDecl()->getNameAsString().c_str(),
+ Node->getMemberDecl()->getNameAsString().c_str(),
(void*)Node->getMemberDecl());
}
void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
@@ -459,7 +459,7 @@ void StmtDumper::VisitCXXThisExpr(CXXThisExpr *Node) {
void StmtDumper::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
DumpExpr(Node);
- fprintf(F, " functional cast to %s",
+ fprintf(F, " functional cast to %s",
Node->getTypeAsWritten().getAsString().c_str());
}
@@ -503,21 +503,21 @@ void StmtDumper::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
DumpExpr(Node);
-
+
fprintf(F, " ");
DumpType(Node->getEncodedType());
}
void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
DumpExpr(Node);
-
+
fprintf(F, " ");
fprintf(F, "%s", Node->getSelector().getAsString().c_str());
}
void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
DumpExpr(Node);
-
+
fprintf(F, " ");
fprintf(F, "%s", Node->getProtocol()->getNameAsString().c_str());
}
@@ -525,17 +525,17 @@ void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
DumpExpr(Node);
- fprintf(F, " Kind=PropertyRef Property=\"%s\"",
+ fprintf(F, " Kind=PropertyRef Property=\"%s\"",
Node->getProperty()->getNameAsString().c_str());
}
void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(
ObjCImplicitSetterGetterRefExpr *Node) {
DumpExpr(Node);
-
+
ObjCMethodDecl *Getter = Node->getGetterMethod();
ObjCMethodDecl *Setter = Node->getSetterMethod();
- fprintf(F, " Kind=MethodRef Getter=\"%s\" Setter=\"%s\"",
+ fprintf(F, " Kind=MethodRef Getter=\"%s\" Setter=\"%s\"",
Getter->getSelector().getAsString().c_str(),
Setter ? Setter->getSelector().getAsString().c_str() : "(null)");
}
diff --git a/lib/AST/StmtIterator.cpp b/lib/AST/StmtIterator.cpp
index 5c22e28894..4f62b66e25 100644
--- a/lib/AST/StmtIterator.cpp
+++ b/lib/AST/StmtIterator.cpp
@@ -23,10 +23,10 @@ static inline VariableArrayType* FindVA(Type* t) {
if (VariableArrayType* vat = dyn_cast<VariableArrayType>(vt))
if (vat->getSizeExpr())
return vat;
-
+
t = vt->getElementType().getTypePtr();
}
-
+
return NULL;
}
@@ -39,20 +39,20 @@ void StmtIteratorBase::NextVA() {
if (p)
return;
-
+
if (inDecl()) {
- if (VarDecl* VD = dyn_cast<VarDecl>(decl))
+ if (VarDecl* VD = dyn_cast<VarDecl>(decl))
if (VD->Init)
return;
-
+
NextDecl();
}
else if (inDeclGroup()) {
- if (VarDecl* VD = dyn_cast<VarDecl>(*DGI))
+ if (VarDecl* VD = dyn_cast<VarDecl>(*DGI))
if (VD->Init)
return;
-
- NextDecl();
+
+ NextDecl();
}
else {
assert (inSizeOfTypeVA());
@@ -63,10 +63,10 @@ void StmtIteratorBase::NextVA() {
void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
assert (getVAPtr() == NULL);
-
+
if (inDecl()) {
assert (decl);
-
+
// FIXME: SIMPLIFY AWAY.
if (ImmediateAdvance)
decl = 0;
@@ -75,10 +75,10 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
}
else {
assert (inDeclGroup());
-
+
if (ImmediateAdvance)
++DGI;
-
+
for ( ; DGI != DGE; ++DGI)
if (HandleDecl(*DGI))
return;
@@ -88,18 +88,18 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
}
bool StmtIteratorBase::HandleDecl(Decl* D) {
-
- if (VarDecl* VD = dyn_cast<VarDecl>(D)) {
+
+ if (VarDecl* VD = dyn_cast<VarDecl>(D)) {
if (VariableArrayType* VAPtr = FindVA(VD->getType().getTypePtr())) {
setVAPtr(VAPtr);
return true;
}
-
+
if (VD->getInit())
return true;
}
else if (TypedefDecl* TD = dyn_cast<TypedefDecl>(D)) {
- if (VariableArrayType* VAPtr =
+ if (VariableArrayType* VAPtr =
FindVA(TD->getUnderlyingType().getTypePtr())) {
setVAPtr(VAPtr);
return true;
@@ -110,7 +110,7 @@ bool StmtIteratorBase::HandleDecl(Decl* D) {
return true;
}
- return false;
+ return false;
}
StmtIteratorBase::StmtIteratorBase(Decl* d)
@@ -130,19 +130,19 @@ StmtIteratorBase::StmtIteratorBase(VariableArrayType* t)
}
Stmt*& StmtIteratorBase::GetDeclExpr() const {
-
+
if (VariableArrayType* VAPtr = getVAPtr()) {
assert (VAPtr->SizeExpr);
return VAPtr->SizeExpr;
}
assert (inDecl() || inDeclGroup());
-
+
if (inDeclGroup()) {
VarDecl* VD = cast<VarDecl>(*DGI);
return *VD->getInitAddress();
}
-
+
assert (inDecl());
if (VarDecl* VD = dyn_cast<VarDecl>(decl)) {
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 7a0d6d6349..a6f2b823fe 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -33,12 +33,12 @@ namespace {
PrintingPolicy Policy;
public:
- StmtPrinter(llvm::raw_ostream &os, ASTContext &C, PrinterHelper* helper,
+ StmtPrinter(llvm::raw_ostream &os, ASTContext &C, PrinterHelper* helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0)
: OS(os), Context(C), IndentLevel(Indentation), Helper(helper),
Policy(Policy) {}
-
+
void PrintStmt(Stmt *S) {
PrintStmt(S, Policy.Indentation);
}
@@ -63,29 +63,29 @@ namespace {
void PrintRawDeclStmt(DeclStmt *S);
void PrintRawIfStmt(IfStmt *If);
void PrintRawCXXCatchStmt(CXXCatchStmt *Catch);
-
+
void PrintExpr(Expr *E) {
if (E)
Visit(E);
else
OS << "<null expr>";
}
-
+
llvm::raw_ostream &Indent(int Delta = 0) {
for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
OS << " ";
return OS;
}
-
+
bool PrintOffsetOfDesignator(Expr *E);
void VisitUnaryOffsetOf(UnaryOperator *Node);
-
- void Visit(Stmt* S) {
+
+ void Visit(Stmt* S) {
if (Helper && Helper->handledStmt(S,OS))
return;
else StmtVisitor<StmtPrinter>::Visit(S);
}
-
+
void VisitStmt(Stmt *Node);
#define STMT(CLASS, PARENT) \
void Visit##CLASS(CLASS *Node);
@@ -108,7 +108,7 @@ void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
for (CompoundStmt::body_iterator I = Node->body_begin(), E = Node->body_end();
I != E; ++I)
PrintStmt(*I);
-
+
Indent() << "}";
}
@@ -119,7 +119,7 @@ void StmtPrinter::PrintRawDecl(Decl *D) {
void StmtPrinter::PrintRawDeclStmt(DeclStmt *S) {
DeclStmt::decl_iterator Begin = S->decl_begin(), End = S->decl_end();
llvm::SmallVector<Decl*, 2> Decls;
- for ( ; Begin != End; ++Begin)
+ for ( ; Begin != End; ++Begin)
Decls.push_back(*Begin);
Decl::printGroup(Decls.data(), Decls.size(), OS, Policy, IndentLevel);
@@ -149,7 +149,7 @@ void StmtPrinter::VisitCaseStmt(CaseStmt *Node) {
PrintExpr(Node->getRHS());
}
OS << ":\n";
-
+
PrintStmt(Node->getSubStmt(), 0);
}
@@ -167,7 +167,7 @@ void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
OS << "if (";
PrintExpr(If->getCond());
OS << ')';
-
+
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(If->getThen())) {
OS << ' ';
PrintRawCompoundStmt(CS);
@@ -177,10 +177,10 @@ void StmtPrinter::PrintRawIfStmt(IfStmt *If) {
PrintStmt(If->getThen());
if (If->getElse()) Indent();
}
-
+
if (Stmt *Else = If->getElse()) {
OS << "else";
-
+
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Else)) {
OS << ' ';
PrintRawCompoundStmt(CS);
@@ -204,7 +204,7 @@ void StmtPrinter::VisitSwitchStmt(SwitchStmt *Node) {
Indent() << "switch (";
PrintExpr(Node->getCond());
OS << ")";
-
+
// Pretty print compoundstmt bodies (very common).
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
OS << " ";
@@ -237,7 +237,7 @@ void StmtPrinter::VisitDoStmt(DoStmt *Node) {
PrintStmt(Node->getBody());
Indent();
}
-
+
OS << "while (";
PrintExpr(Node->getCond());
OS << ");\n";
@@ -262,7 +262,7 @@ void StmtPrinter::VisitForStmt(ForStmt *Node) {
PrintExpr(Node->getInc());
}
OS << ") ";
-
+
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
PrintRawCompoundStmt(CS);
OS << "\n";
@@ -281,7 +281,7 @@ void StmtPrinter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *Node) {
OS << " in ";
PrintExpr(Node->getCollection());
OS << ") ";
-
+
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getBody())) {
PrintRawCompoundStmt(CS);
OS << "\n";
@@ -322,63 +322,63 @@ void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
Indent() << "asm ";
-
+
if (Node->isVolatile())
OS << "volatile ";
-
+
OS << "(";
VisitStringLiteral(Node->getAsmString());
-
+
// Outputs
if (Node->getNumOutputs() != 0 || Node->getNumInputs() != 0 ||
Node->getNumClobbers() != 0)
OS << " : ";
-
+
for (unsigned i = 0, e = Node->getNumOutputs(); i != e; ++i) {
if (i != 0)
OS << ", ";
-
+
if (!Node->getOutputName(i).empty()) {
OS << '[';
OS << Node->getOutputName(i);
OS << "] ";
}
-
+
VisitStringLiteral(Node->getOutputConstraintLiteral(i));
OS << " ";
Visit(Node->getOutputExpr(i));
}
-
+
// Inputs
if (Node->getNumInputs() != 0 || Node->getNumClobbers() != 0)
OS << " : ";
-
+
for (unsigned i = 0, e = Node->getNumInputs(); i != e; ++i) {
if (i != 0)
OS << ", ";
-
+
if (!Node->getInputName(i).empty()) {
OS << '[';
OS << Node->getInputName(i);
OS << "] ";
}
-
+
VisitStringLiteral(Node->getInputConstraintLiteral(i));
OS << " ";
Visit(Node->getInputExpr(i));
}
-
+
// Clobbers
if (Node->getNumClobbers() != 0)
OS << " : ";
-
+
for (unsigned i = 0, e = Node->getNumClobbers(); i != e; ++i) {
if (i != 0)
OS << ", ";
-
+
VisitStringLiteral(Node->getClobber(i));
}
-
+
OS << ");\n";
}
@@ -388,11 +388,11 @@ void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
PrintRawCompoundStmt(TS);
OS << "\n";
}
-
- for (ObjCAtCatchStmt *catchStmt =
+
+ for (ObjCAtCatchStmt *catchStmt =
static_cast<ObjCAtCatchStmt *>(Node->getCatchStmts());
- catchStmt;
- catchStmt =
+ catchStmt;
+ catchStmt =
static_cast<ObjCAtCatchStmt *>(catchStmt->getNextCatchStmt())) {
Indent() << "@catch(";
if (catchStmt->getCatchParamDecl()) {
@@ -400,19 +400,18 @@ void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
PrintRawDecl(DS);
}
OS << ")";
- if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody()))
- {
- PrintRawCompoundStmt(CS);
- OS << "\n";
- }
+ if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody())) {
+ PrintRawCompoundStmt(CS);
+ OS << "\n";
+ }
}
-
- if (ObjCAtFinallyStmt *FS =static_cast<ObjCAtFinallyStmt *>(
- Node->getFinallyStmt())) {
+
+ if (ObjCAtFinallyStmt *FS = static_cast<ObjCAtFinallyStmt *>(
+ Node->getFinallyStmt())) {
Indent() << "@finally";
PrintRawCompoundStmt(dyn_cast<CompoundStmt>(FS->getFinallyBody()));
OS << "\n";
- }
+ }
}
void StmtPrinter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *Node) {
@@ -458,7 +457,7 @@ void StmtPrinter::VisitCXXCatchStmt(CXXCatchStmt *Node) {
void StmtPrinter::VisitCXXTryStmt(CXXTryStmt *Node) {
Indent() << "try ";
PrintRawCompoundStmt(Node->getTryBlock());
- for(unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
+ for (unsigned i = 0, e = Node->getNumHandlers(); i < e; ++i) {
OS << " ";
PrintRawCXXCatchStmt(Node->getHandler(i));
}
@@ -477,14 +476,14 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
OS << Node->getDecl()->getNameAsString();
}
-void StmtPrinter::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *Node) {
+void StmtPrinter::VisitQualifiedDeclRefExpr(QualifiedDeclRefExpr *Node) {
NamedDecl *D = Node->getDecl();
Node->getQualifier()->print(OS, Policy);
OS << D->getNameAsString();
}
-void StmtPrinter::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *Node) {
+void StmtPrinter::VisitUnresolvedDeclRefExpr(UnresolvedDeclRefExpr *Node) {
Node->getQualifier()->print(OS, Policy);
OS << Node->getDeclName().getAsString();
}
@@ -523,7 +522,7 @@ void StmtPrinter::VisitObjCImplicitSetterGetterRefExpr(
}
if (Node->getGetterMethod())
OS << Node->getGetterMethod()->getNameAsString();
-
+
}
void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
@@ -594,7 +593,7 @@ void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
bool isSigned = Node->getType()->isSignedIntegerType();
OS << Node->getValue().toString(10, isSigned);
-
+
// Emit suffixes. Integer literals are always a builtin integer type.
switch (Node->getType()->getAsBuiltinType()->getKind()) {
default: assert(0 && "Unexpected type for integer literal!");
@@ -623,7 +622,7 @@ void StmtPrinter::VisitStringLiteral(StringLiteral *Str) {
// FIXME: this doesn't print wstrings right.
for (unsigned i = 0, e = Str->getByteLength(); i != e; ++i) {
unsigned char Char = Str->getStrData()[i];
-
+
switch (Char) {
default:
if (isprint(Char))
@@ -653,7 +652,7 @@ void StmtPrinter::VisitParenExpr(ParenExpr *Node) {
void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
if (!Node->isPostfix()) {
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
-
+
// Print a space if this is an "identifier operator" like __real, or if
// it might be concatenated incorrectly like '+'.
switch (Node->getOpcode()) {
@@ -671,7 +670,7 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) {
}
}
PrintExpr(Node->getSubExpr());
-
+
if (Node->isPostfix())
OS << UnaryOperator::getOpcodeStr(Node->getOpcode());
}
@@ -741,7 +740,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
Qualifier->print(OS, Policy);
OS << Node->getMemberDecl()->getNameAsString();
-
+
if (Node->hasExplicitTemplateArgumentList())
OS << TemplateSpecializationType::PrintTemplateArgumentList(
Node->getTemplateArgs(),
@@ -788,7 +787,7 @@ void StmtPrinter::VisitCompoundAssignOperator(CompoundAssignOperator *Node) {
}
void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
PrintExpr(Node->getCond());
-
+
if (Node->getLHS()) {
OS << " ? ";
PrintExpr(Node->getLHS());
@@ -797,7 +796,7 @@ void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
else { // Handle GCC extension where LHS can be NULL.
OS << " ?: ";
}
-
+
PrintExpr(Node->getRHS());
}
@@ -884,7 +883,7 @@ void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
} else {
PrintExpr(Node->getArrayRangeStart(*D));
OS << " ... ";
- PrintExpr(Node->getArrayRangeEnd(*D));
+ PrintExpr(Node->getArrayRangeEnd(*D));
}
OS << "]";
}
@@ -1036,7 +1035,7 @@ void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) {
OS << Node->getType().getAsString();
OS << "(";
for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
- ArgEnd = Node->arg_end();
+ ArgEnd = Node->arg_end();
Arg != ArgEnd; ++Arg) {
if (Arg != Node->arg_begin())
OS << ", ";
@@ -1113,7 +1112,7 @@ void StmtPrinter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
OS << '.';
if (E->getQualifier())
E->getQualifier()->print(OS, Policy);
-
+
std::string TypeS;
E->getDestroyedType().getAsStringInternal(TypeS, Policy);
OS << TypeS;
@@ -1132,13 +1131,13 @@ void StmtPrinter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
PrintExpr(E->getSubExpr());
}
-void
+void
StmtPrinter::VisitCXXUnresolvedConstructExpr(
CXXUnresolvedConstructExpr *Node) {
OS << Node->getTypeAsWritten().getAsString();
OS << "(";
for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(),
- ArgEnd = Node->arg_end();
+ ArgEnd = Node->arg_end();
Arg != ArgEnd; ++Arg) {
if (Arg != Node->arg_begin())
OS << ", ";
@@ -1155,9 +1154,9 @@ void StmtPrinter::VisitCXXUnresolvedMemberExpr(CXXUnresolvedMemberExpr *Node) {
else if (Node->hasExplicitTemplateArgumentList())
// FIXME: Track use of "template" keyword explicitly?
OS << "template ";
-
+
OS << Node->getMember().getAsString();
-
+
if (Node->hasExplicitTemplateArgumentList()) {
OS << TemplateSpecializationType::PrintTemplateArgumentList(
Node->getTemplateArgs(),
@@ -1192,7 +1191,7 @@ void StmtPrinter::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
<< E->getQueriedType().getAsString() << ")";
}
-// Obj-C
+// Obj-C
void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
OS << "@";
@@ -1230,7 +1229,7 @@ void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
OS << ":";
}
else OS << ", "; // Handle variadic methods.
-
+
PrintExpr(Mess->getArg(i));
}
}
@@ -1244,9 +1243,9 @@ void StmtPrinter::VisitObjCSuperExpr(ObjCSuperExpr *) {
void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
BlockDecl *BD = Node->getBlockDecl();
OS << "^";
-
+
const FunctionType *AFT = Node->getFunctionType();
-
+
if (isa<FunctionNoProtoType>(AFT)) {
OS << "()";
} else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
@@ -1259,7 +1258,7 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
(*AI)->getType().getAsStringInternal(ParamStr, Policy);
OS << ParamStr;
}
-
+
const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
if (FT->isVariadic()) {
if (!BD->param_empty()) OS << ", ";
@@ -1294,7 +1293,7 @@ void Stmt::printPretty(llvm::raw_ostream &OS, ASTContext& Context,
dump(Context.getSourceManager());
return;
}
-
+
StmtPrinter P(OS, Context, Helper, Policy, Indentation);
P.Visit(const_cast<Stmt*>(this));
}
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 806eb8de81..5a5badd289 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -28,36 +28,36 @@ namespace {
llvm::FoldingSetNodeID &ID;
ASTContext &Context;
bool Canonical;
-
+
public:
StmtProfiler(llvm::FoldingSetNodeID &ID, ASTContext &Context,
- bool Canonical)
+ bool Canonical)
: ID(ID), Context(Context), Canonical(Canonical) { }
-
+
void VisitStmt(Stmt *S);
-
+
#define STMT(Node, Base) void Visit##Node(Node *S);
#include "clang/AST/StmtNodes.def"
-
+
/// \brief Visit a declaration that is referenced within an expression
/// or statement.
void VisitDecl(Decl *D);
-
- /// \brief Visit a type that is referenced within an expression or
+
+ /// \brief Visit a type that is referenced within an expression or
/// statement.
void VisitType(QualType T);
-
+
/// \brief Visit a name that occurs within an expression or statement.
void VisitName(DeclarationName Name);
-
+
/// \brief Visit a nested-name-specifier that occurs within an expression
/// or statement.
void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
-
+
/// \brief Visit a template name that occurs within an expression or
/// statement.
void VisitTemplateName(TemplateName Name);
-
+
/// \brief Visit template arguments that occur within an expression or
/// statement.
void VisitTemplateArguments(const TemplateArgument *Args, unsigned NumArgs);
@@ -348,7 +348,7 @@ void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
VisitInitListExpr(S->getSyntacticForm());
return;
}
-
+
VisitExpr(S);
}
@@ -363,7 +363,7 @@ void StmtProfiler::VisitDesignatedInitExpr(DesignatedInitExpr *S) {
VisitName(D->getFieldName());
continue;
}
-
+
if (D->isArrayDesignator()) {
ID.AddInteger(1);
} else {
@@ -509,7 +509,7 @@ void StmtProfiler::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *S) {
VisitType(S->getDestroyedType());
}
-void
+void
StmtProfiler::VisitUnresolvedFunctionNameExpr(UnresolvedFunctionNameExpr *S) {
VisitExpr(S);
VisitName(S->getName());
@@ -548,7 +548,7 @@ void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
}
-void
+void
StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
VisitExpr(S);
VisitType(S->getTypeAsWritten());
@@ -617,7 +617,7 @@ void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
void StmtProfiler::VisitDecl(Decl *D) {
ID.AddInteger(D? D->getKind() : 0);
-
+
if (Canonical && D) {
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
ID.AddInteger(NTTP->getDepth());
@@ -625,38 +625,38 @@ void StmtProfiler::VisitDecl(Decl *D) {
VisitType(NTTP->getType());
return;
}
-
+
if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
// The Itanium C++ ABI uses the type of a parameter when mangling
// expressions that involve function parameters, so we will use the
// parameter's type for establishing function parameter identity. That
- // way, our definition of "equivalent" (per C++ [temp.over.link])
+ // way, our definition of "equivalent" (per C++ [temp.over.link])
// matches the definition of "equivalent" used for name mangling.
VisitType(Parm->getType());
return;
}
-
+
if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
ID.AddInteger(TTP->getDepth());
ID.AddInteger(TTP->getIndex());
return;
}
-
+
if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
- // The Itanium C++ ABI mangles references to a set of overloaded
+ // The Itanium C++ ABI mangles references to a set of overloaded
// functions using just the function name, so we do the same here.
VisitName(Ovl->getDeclName());
return;
}
}
-
+
ID.AddPointer(D? D->getCanonicalDecl() : 0);
}
void StmtProfiler::VisitType(QualType T) {
if (Canonical)
T = Context.getCanonicalType(T);
-
+
ID.AddPointer(T.getAsOpaquePtr());
}
@@ -673,39 +673,39 @@ void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
void StmtProfiler::VisitTemplateName(TemplateName Name) {
if (Canonical)
Name = Context.getCanonicalTemplateName(Name);
-
+
Name.Profile(ID);
}
-void StmtProfiler::VisitTemplateArguments(const TemplateArgument *Args,
+void StmtProfiler::VisitTemplateArguments(const TemplateArgument *Args,
unsigned NumArgs) {
ID.AddInteger(NumArgs);
for (unsigned I = 0; I != NumArgs; ++I) {
const TemplateArgument &Arg = Args[I];
-
+
// Mostly repetitive with TemplateArgument::Profile!
ID.AddInteger(Arg.getKind());
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
-
+
case TemplateArgument::Type:
VisitType(Arg.getAsType());
break;
-
+
case TemplateArgument::Declaration:
VisitDecl(Arg.getAsDecl());
break;
-
+
case TemplateArgument::Integral:
Arg.getAsIntegral()->Profile(ID);
VisitType(Arg.getIntegralType());
break;
-
+
case TemplateArgument::Expression:
Visit(Arg.getAsExpr());
break;
-
+
case TemplateArgument::Pack:
VisitTemplateArguments(Arg.pack_begin(), Arg.pack_size());
break;
diff --git a/lib/AST/StmtViz.cpp b/lib/AST/StmtViz.cpp
index a8f7c76ebe..61fd750ccc 100644
--- a/lib/AST/StmtViz.cpp
+++ b/lib/AST/StmtViz.cpp
@@ -32,26 +32,26 @@ template<>
struct DOTGraphTraits<const Stmt*> : public DefaultDOTGraphTraits {
static std::string getNodeLabel(const Stmt* Node, const Stmt* Graph,
bool ShortNames) {
-
+
#ifndef NDEBUG
std::string OutSStr;
llvm::raw_string_ostream Out(OutSStr);
-
+
if (Node)
Out << Node->getStmtClassName();
else
Out << "<NULL>";
-
- std::string OutStr = Out.str();
+
+ std::string OutStr = Out.str();
if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
-
+
// Process string output to make it nicer...
for (unsigned i = 0; i != OutStr.length(); ++i)
if (OutStr[i] == '\n') { // Left justify
OutStr[i] = '\\';
OutStr.insert(OutStr.begin()+i+1, 'l');
}
-
+
return OutStr;
#else
return "";
diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp
index 92c741b35d..24588bc5f1 100644
--- a/lib/AST/TemplateName.cpp
+++ b/lib/AST/TemplateName.cpp
@@ -22,7 +22,7 @@ using namespace clang;
TemplateDecl *TemplateName::getAsTemplateDecl() const {
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
return Template;
-
+
if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
return QTN->getTemplateDecl();
@@ -30,34 +30,34 @@ TemplateDecl *TemplateName::getAsTemplateDecl() const {
}
OverloadedFunctionDecl *TemplateName::getAsOverloadedFunctionDecl() const {
- if (OverloadedFunctionDecl *Ovl
+ if (OverloadedFunctionDecl *Ovl
= Storage.dyn_cast<OverloadedFunctionDecl *>())
return Ovl;
-
+
if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
return QTN->getOverloadedFunctionDecl();
-
+
return 0;
}
bool TemplateName::isDependent() const {
if (TemplateDecl *Template = getAsTemplateDecl()) {
- return isa<TemplateTemplateParmDecl>(Template) ||
+ return isa<TemplateTemplateParmDecl>(Template) ||
Template->getDeclContext()->isDependentContext();
}
if (OverloadedFunctionDecl *Ovl = getAsOverloadedFunctionDecl())
return Ovl->getDeclContext()->isDependentContext();
-
+
return true;
}
-void
+void
TemplateName::print(llvm::raw_ostream &OS, const PrintingPolicy &Policy,
bool SuppressNNS) const {
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
OS << Template->getIdentifier()->getName();
- else if (OverloadedFunctionDecl *Ovl
+ else if (OverloadedFunctionDecl *Ovl
= Storage.dyn_cast<OverloadedFunctionDecl *>())
OS << Ovl->getNameAsString();
else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) {
@@ -82,12 +82,12 @@ void TemplateName::dump() const {
print(llvm::errs(), PrintingPolicy(LO));
}
-TemplateDecl *QualifiedTemplateName::getTemplateDecl() const {
- return dyn_cast<TemplateDecl>(Template);
+TemplateDecl *QualifiedTemplateName::getTemplateDecl() const {
+ return dyn_cast<TemplateDecl>(Template);
}
OverloadedFunctionDecl *
QualifiedTemplateName::getOverloadedFunctionDecl() const {
- return dyn_cast<OverloadedFunctionDecl>(Template);
+ return dyn_cast<OverloadedFunctionDecl>(Template);
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 9bcfb2ad8f..1a6ea0a136 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -64,7 +64,7 @@ void DependentSizedArrayType::Destroy(ASTContext& C) {
C.Deallocate(this);
}
-void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
+void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
QualType ET,
ArraySizeModifier SizeMod,
@@ -76,8 +76,8 @@ void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
E->Profile(ID, Context, true);
}
-void
-DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
+void
+DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
QualType ElementType, Expr *SizeExpr) {
ID.AddPointer(ElementType.getAsOpaquePtr());
@@ -99,7 +99,7 @@ const Type *Type::getArrayElementTypeNoTypeQual() const {
// If this is directly an array type, return it.
if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
return ATy->getElementType().getTypePtr();
-
+
// If the canonical form of this type isn't the right kind, reject it.
if (!isa<ArrayType>(CanonicalType)) {
// Look through type qualifiers
@@ -107,7 +107,7 @@ const Type *Type::getArrayElementTypeNoTypeQual() const {
return AT->getElementType().getTypePtr();
return 0;
}
-
+
// If this is a typedef for an array type, strip the typedef off without
// losing all typedef information.
return cast<ArrayType>(getDesugaredType())->getElementType().getTypePtr();
@@ -153,7 +153,7 @@ QualType Type::getDesugaredType(bool ForDisplay) const {
if (!DTT->getUnderlyingType()->isDependentType())
return DTT->getUnderlyingType().getDesugaredType();
}
- if (const TemplateSpecializationType *Spec
+ if (const TemplateSpecializationType *Spec
= dyn_cast<TemplateSpecializationType>(this)) {
if (ForDisplay)
return QualType(this, 0);
@@ -262,7 +262,7 @@ const ComplexType *Type::getAsComplexIntegerType() const {
return CTy;
return 0;
}
-
+
// If the canonical form of this type isn't what we want, reject it.
if (!isa<ComplexType>(CanonicalType)) {
// Look through type qualifiers (e.g. ExtQualType's).
@@ -270,7 +270,7 @@ const ComplexType *Type::getAsComplexIntegerType() const {
return CanonicalType.getUnqualifiedType()->getAsComplexIntegerType();
return 0;
}
-
+
// If this is a typedef for a complex type, strip the typedef off without
// losing all typedef information.
return cast<ComplexType>(getDesugaredType());
@@ -306,7 +306,7 @@ const FunctionType *Type::getAsFunctionType() const {
return CanonicalType.getUnqualifiedType()->getAsFunctionType();
return 0;
}
-
+
// If this is a typedef for a function type, strip the typedef off without
// losing all typedef information.
return cast<FunctionType>(getDesugaredType());
@@ -374,7 +374,7 @@ const RecordType *Type::getAsStructureType() const {
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
if (!RT->getDecl()->isStruct())
return 0;
-
+
// If this is a typedef for a structure type, strip the typedef off without
// losing all typedef information.
return cast<RecordType>(getDesugaredType());
@@ -385,13 +385,13 @@ const RecordType *Type::getAsStructureType() const {
return 0;
}
-const RecordType *Type::getAsUnionType() const {
+const RecordType *Type::getAsUnionType() const {
// If this is directly a union type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
if (RT->getDecl()->isUnion())
return RT;
}
-
+
// If the canonical form of this type isn't the right kind, reject it.
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
if (!RT->getDecl()->isUnion())
@@ -401,7 +401,7 @@ const RecordType *Type::getAsUnionType() const {
// losing all typedef information.
return cast<RecordType>(getDesugaredType());
}
-
+
// Look through type qualifiers
if (isa<RecordType>(CanonicalType.getUnqualifiedType()))
return CanonicalType.getUnqualifiedType()->getAsUnionType();
@@ -419,7 +419,7 @@ const ComplexType *Type::getAsComplexType() const {
// Are we directly a complex type?
if (const ComplexType *CTy = dyn_cast<ComplexType>(this))
return CTy;
-
+
// If the canonical form of this type isn't the right kind, reject it.
if (!isa<ComplexType>(CanonicalType)) {
// Look through type qualifiers
@@ -437,7 +437,7 @@ const VectorType *Type::getAsVectorType() const {
// Are we directly a vector type?
if (const VectorType *VTy = dyn_cast<VectorType>(this))
return VTy;
-
+
// If the canonical form of this type isn't the right kind, reject it.
if (!isa<VectorType>(CanonicalType)) {
// Look through type qualifiers
@@ -455,9 +455,9 @@ const ExtVectorType *Type::getAsExtVectorType() const {
// Are we directly an OpenCU vector type?
if (const ExtVectorType *VTy = dyn_cast<ExtVectorType>(this))
return VTy;
-
+
// If the canonical form of this type isn't the right kind, reject it.
- if (!isa<ExtVectorType>(CanonicalType)) {
+ if (!isa<ExtVectorType>(CanonicalType)) {
// Look through type qualifiers
if (isa<ExtVectorType>(CanonicalType.getUnqualifiedType()))
return CanonicalType.getUnqualifiedType()->getAsExtVectorType();
@@ -612,14 +612,14 @@ bool Type::isSignedIntegerType() const {
return BT->getKind() >= BuiltinType::Char_S &&
BT->getKind() <= BuiltinType::LongLong;
}
-
+
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
return ET->getDecl()->getIntegerType()->isSignedIntegerType();
-
+
if (const FixedWidthIntType *FWIT =
dyn_cast<FixedWidthIntType>(CanonicalType))
return FWIT->isSigned();
-
+
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isSignedIntegerType();
if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(CanonicalType))
@@ -763,8 +763,8 @@ bool Type::isConstantSizeType() const {
/// isIncompleteType - Return true if this is an incomplete type (C99 6.2.5p1)
/// - a type that can describe objects, but which lacks information needed to
/// determine its size.
-bool Type::isIncompleteType() const {
- switch (CanonicalType->getTypeClass()) {
+bool Type::isIncompleteType() const {
+ switch (CanonicalType->getTypeClass()) {
default: return false;
case ExtQual:
return cast<ExtQualType>(CanonicalType)->getBaseType()->isIncompleteType();
@@ -816,7 +816,7 @@ bool Type::isPODType() const {
return true;
case Record:
- if (CXXRecordDecl *ClassDecl
+ if (CXXRecordDecl *ClassDecl
= dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
return ClassDecl->isPOD();
@@ -836,7 +836,7 @@ bool Type::isPromotableIntegerType() const {
case BuiltinType::Short:
case BuiltinType::UShort:
return true;
- default:
+ default:
return false;
}
return false;
@@ -918,7 +918,7 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
ID.AddInteger(hasExceptionSpec);
if (hasExceptionSpec) {
ID.AddInteger(anyExceptionSpec);
- for(unsigned i = 0; i != NumExceptions; ++i)
+ for (unsigned i = 0; i != NumExceptions; ++i)
ID.AddPointer(Exs[i].getAsOpaquePtr());
}
ID.AddInteger(NoReturn);
@@ -957,14 +957,14 @@ QualType TypedefType::LookThroughTypedefs() const {
QualType FirstType = getDecl()->getUnderlyingType();
if (!isa<TypedefType>(FirstType))
return FirstType;
-
+
// Otherwise, do the fully general loop.
unsigned TypeQuals = 0;
const TypedefType *TDT = this;
while (1) {
QualType CurType = TDT->getDecl()->getUnderlyingType();
-
-
+
+
/// FIXME:
/// FIXME: This is incorrect for ExtQuals!
/// FIXME:
@@ -980,25 +980,25 @@ TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
: Type(TypeOfExpr, can, E->isTypeDependent()), TOExpr(E) {
}
-void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
+void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context, Expr *E) {
E->Profile(ID, Context, true);
}
DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can)
- : Type(Decltype, can, E->isTypeDependent()), E(E),
+ : Type(Decltype, can, E->isTypeDependent()), E(E),
UnderlyingType(underlyingType) {
}
DependentDecltypeType::DependentDecltypeType(ASTContext &Context, Expr *E)
: DecltypeType(E, Context.DependentTy), Context(Context) { }
-void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
+void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context, Expr *E) {
E->Profile(ID, Context, true);
}
-TagType::TagType(TypeClass TC, TagDecl *D, QualType can)
+TagType::TagType(TypeClass TC, TagDecl *D, QualType can)
: Type(TC, can, D->isDependentType()), decl(D, 0) {}
bool RecordType::classof(const TagType *TT) {
@@ -1009,7 +1009,7 @@ bool EnumType::classof(const TagType *TT) {
return isa<EnumDecl>(TT->getDecl());
}
-bool
+bool
TemplateSpecializationType::
anyDependentTemplateArguments(const TemplateArgument *Args, unsigned NumArgs) {
for (unsigned Idx = 0; Idx < NumArgs; ++Idx) {
@@ -1017,12 +1017,12 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned NumArgs) {
case TemplateArgument::Null:
assert(false && "Should not have a NULL template argument");
break;
-
+
case TemplateArgument::Type:
if (Args[Idx].getAsType()->isDependentType())
return true;
break;
-
+
case TemplateArgument::Declaration:
case TemplateArgument::Integral:
// Never dependent
@@ -1033,7 +1033,7 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned NumArgs) {
Args[Idx].getAsExpr()->isValueDependent())
return true;
break;
-
+
case TemplateArgument::Pack:
assert(0 && "FIXME: Implement!");
break;
@@ -1044,20 +1044,19 @@ anyDependentTemplateArguments(const TemplateArgument *Args, unsigned NumArgs) {
}
TemplateSpecializationType::
-TemplateSpecializationType(ASTContext &Context, TemplateName T,
+TemplateSpecializationType(ASTContext &Context, TemplateName T,
const TemplateArgument *Args,
unsigned NumArgs, QualType Canon)
- : Type(TemplateSpecialization,
+ : Type(TemplateSpecialization,
Canon.isNull()? QualType(this, 0) : Canon,
T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)),
Context(Context),
- Template(T), NumArgs(NumArgs)
-{
- assert((!Canon.isNull() ||
+ Template(T), NumArgs(NumArgs) {
+ assert((!Canon.isNull() ||
T.isDependent() || anyDependentTemplateArguments(Args, NumArgs)) &&
"No canonical type for non-dependent class template specialization");
- TemplateArgument *TemplateArgs
+ TemplateArgument *TemplateArgs
= reinterpret_cast<TemplateArgument *>(this + 1);
for (unsigned Arg = 0; Arg < NumArgs; ++Arg)
new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]);
@@ -1083,10 +1082,10 @@ TemplateSpecializationType::getArg(unsigned Idx) const {
return getArgs()[Idx];
}
-void
-TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
- TemplateName T,
- const TemplateArgument *Args,
+void
+TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
+ TemplateName T,
+ const TemplateArgument *Args,
unsigned NumArgs,
ASTContext &Context) {
T.Profile(ID);
@@ -1097,7 +1096,7 @@ TemplateSpecializationType::Profile(llvm::FoldingSetNodeID &ID,
const Type *QualifierSet::strip(const Type* T) {
QualType DT = T->getDesugaredType();
addCVR(DT.getCVRQualifiers());
-
+
if (const ExtQualType* EQT = dyn_cast<ExtQualType>(DT)) {
if (EQT->getAddressSpace())
addAddressSpace(EQT->getAddressSpace());
@@ -1162,8 +1161,8 @@ std::string QualType::getAsString() const {
return S;
}
-void
-QualType::getAsStringInternal(std::string &S,
+void
+QualType::getAsStringInternal(std::string &S,
const PrintingPolicy &Policy) const {
if (isNull()) {
S += "NULL TYPE";
@@ -1186,7 +1185,7 @@ QualType::getAsStringInternal(std::string &S,
getTypePtr()->getAsStringInternal(S, Policy);
}
-void BuiltinType::getAsStringInternal(std::string &S,
+void BuiltinType::getAsStringInternal(std::string &S,
const PrintingPolicy &Policy) const {
if (S.empty()) {
S = getName(Policy.LangOpts);
@@ -1238,12 +1237,12 @@ void ExtQualType::getAsStringInternal(std::string &S, const PrintingPolicy &Poli
void PointerType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const {
S = '*' + S;
-
+
// Handle things like 'int (*A)[4];' correctly.
// FIXME: this should include vectors, but vectors use attributes I guess.
if (isa<ArrayType>(getPointeeType()))
S = '(' + S + ')';
-
+
getPointeeType().getAsStringInternal(S, Policy);
}
@@ -1292,7 +1291,7 @@ void ConstantArrayType::getAsStringInternal(std::string &S, const PrintingPolicy
S += '[';
S += llvm::utostr(getSize().getZExtValue());
S += ']';
-
+
getElementType().getAsStringInternal(S, Policy);
}
@@ -1327,17 +1326,17 @@ void IncompleteArrayType::getAsStringInternal(std::string &S, const PrintingPoli
void VariableArrayType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const {
S += '[';
-
+
if (getIndexTypeQualifier()) {
AppendTypeQualList(S, getIndexTypeQualifier());
S += ' ';
}
-
+
if (getSizeModifier() == Static)
S += "static";
else if (getSizeModifier() == Star)
S += '*';
-
+
if (getSizeExpr()) {
std::string SStr;
llvm::raw_string_ostream s(SStr);
@@ -1345,23 +1344,23 @@ void VariableArrayType::getAsStringInternal(std::string &S, const PrintingPolicy
S += s.str();
}
S += ']';
-
+
getElementType().getAsStringInternal(S, Policy);
}
void DependentSizedArrayType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const {
S += '[';
-
+
if (getIndexTypeQualifier()) {
AppendTypeQualList(S, getIndexTypeQualifier());
S += ' ';
}
-
+
if (getSizeModifier() == Static)
S += "static";
else if (getSizeModifier() == Star)
S += '*';
-
+
if (getSizeExpr()) {
std::string SStr;
llvm::raw_string_ostream s(SStr);
@@ -1369,7 +1368,7 @@ void DependentSizedArrayType::getAsStringInternal(std::string &S, const Printing
S += s.str();
}
S += ']';
-
+
getElementType().getAsStringInternal(S, Policy);
}
@@ -1419,7 +1418,7 @@ void TypeOfType::getAsStringInternal(std::string &InnerString, const PrintingPol
InnerString = "typeof(" + Tmp + ")" + InnerString;
}
-void DecltypeType::getAsStringInternal(std::string &InnerString,
+void DecltypeType::getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'decltype(t) X'.
InnerString = ' ' + InnerString;
@@ -1433,7 +1432,7 @@ void FunctionNoProtoType::getAsStringInternal(std::string &S, const PrintingPoli
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
-
+
S += "()";
if (getNoReturnAttr())
S += " __attribute__((noreturn))";
@@ -1444,7 +1443,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
-
+
S += "(";
std::string Tmp;
PrintingPolicy ParamPolicy(Policy);
@@ -1455,7 +1454,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
S += Tmp;
Tmp.clear();
}
-
+
if (isVariadic()) {
if (getNumArgs())
S += ", ";
@@ -1464,7 +1463,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
// Do not emit int() if we have a proto, emit 'int(void)'.
S += "void";
}
-
+
S += ")";
if (getNoReturnAttr())
S += " __attribute__((noreturn))";
@@ -1483,13 +1482,13 @@ void TemplateTypeParmType::getAsStringInternal(std::string &InnerString, const P
InnerString = ' ' + InnerString;
if (!Name)
- InnerString = "type-parameter-" + llvm::utostr_32(Depth) + '-' +
+ InnerString = "type-parameter-" + llvm::utostr_32(Depth) + '-' +
llvm::utostr_32(Index) + InnerString;
else
InnerString = Name->getName() + InnerString;
}
-std::string
+std::string
TemplateSpecializationType::PrintTemplateArgumentList(
const TemplateArgument *Args,
unsigned NumArgs,
@@ -1499,7 +1498,7 @@ TemplateSpecializationType::PrintTemplateArgumentList(
for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
if (Arg)
SpecString += ", ";
-
+
// Print the argument into a string.
std::string ArgString;
switch (Args[Arg].getKind()) {
@@ -1549,7 +1548,7 @@ TemplateSpecializationType::PrintTemplateArgumentList(
return SpecString;
}
-void
+void
TemplateSpecializationType::
getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
std::string SpecString;
@@ -1573,7 +1572,7 @@ void QualifiedNameType::getAsStringInternal(std::string &InnerString, const Prin
llvm::raw_string_ostream OS(MyString);
NNS->print(OS, Policy);
}
-
+
std::string TypeStr;
PrintingPolicy InnerPolicy(Policy);
InnerPolicy.SuppressTagKind = true;
@@ -1600,12 +1599,12 @@ void TypenameType::getAsStringInternal(std::string &InnerString, const PrintingP
else if (const TemplateSpecializationType *Spec = getTemplateId()) {
Spec->getTemplateName().print(OS, Policy, true);
OS << TemplateSpecializationType::PrintTemplateArgumentList(
- Spec->getArgs(),
+ Spec->getArgs(),
Spec->getNumArgs(),
Policy);
}
}
-
+
if (InnerString.empty())
InnerString.swap(MyString);
else
@@ -1614,7 +1613,7 @@ void TypenameType::getAsStringInternal(std::string &InnerString, const PrintingP
void ObjCInterfaceType::Profile(llvm::FoldingSetNodeID &ID,
const ObjCInterfaceDecl *Decl,
- ObjCProtocolDecl **protocols,
+ ObjCProtocolDecl **protocols,
unsigned NumProtocols) {
ID.AddPointer(Decl);
for (unsigned i = 0; i != NumProtocols; i++)
@@ -1632,7 +1631,7 @@ void ObjCInterfaceType::getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
-
+
std::string ObjCQIString = getDecl()->getNameAsString();
if (getNumProtocols()) {
ObjCQIString += '<';
@@ -1649,10 +1648,10 @@ void ObjCInterfaceType::getAsStringInternal(std::string &InnerString,
InnerString = ObjCQIString + InnerString;
}
-void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString,
+void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const {
std::string ObjCQIString;
-
+
if (isObjCIdType() || isObjCQualifiedIdType())
ObjCQIString = "id";
else if (isObjCClassType() || isObjCQualifiedClassType())
@@ -1677,7 +1676,7 @@ void ObjCObjectPointerType::getAsStringInternal(std::string &InnerString,
InnerString = ObjCQIString + InnerString;
}
-void ElaboratedType::getAsStringInternal(std::string &InnerString,
+void ElaboratedType::getAsStringInternal(std::string &InnerString,
const PrintingPolicy &Policy) const {
std::string TypeStr;
PrintingPolicy InnerPolicy(Policy);
@@ -1693,7 +1692,7 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString;
-
+
const char *Kind = Policy.SuppressTagKind? 0 : getDecl()->getKindName();
const char *ID;
if (const IdentifierInfo *II = getDecl()->getIdentifier())
@@ -1707,10 +1706,10 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
// If this is a class template specialization, print the template
// arguments.
- if (ClassTemplateSpecializationDecl *Spec
+ if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(getDecl())) {
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
- std::string TemplateArgsStr
+ std::string TemplateArgsStr
= TemplateSpecializationType::PrintTemplateArgumentList(
TemplateArgs.getFlatArgumentList(),
TemplateArgs.flat_size(),
@@ -1722,13 +1721,13 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
// Compute the full nested-name-specifier for this type. In C,
// this will always be empty.
std::string ContextStr;
- for (DeclContext *DC = getDecl()->getDeclContext();
+ for (DeclContext *DC = getDecl()->getDeclContext();
!DC->isTranslationUnit(); DC = DC->getParent()) {
std::string MyPart;
if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(DC)) {
if (NS->getIdentifier())
MyPart = NS->getNameAsString();
- } else if (ClassTemplateSpecializationDecl *Spec
+ } else if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
std::string TemplateArgsStr
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp
index 85415ba09a..a95f38897a 100644
--- a/lib/AST/TypeLoc.cpp
+++ b/lib/AST/TypeLoc.cpp
@@ -30,7 +30,7 @@ TypeSpecLoc TypeLoc::getTypeSpecLoc() const {
if (const DeclaratorLoc *DL = dyn_cast<DeclaratorLoc>(this))
return DL->getTypeSpecLoc();
- return cast<TypeSpecLoc>(*this);
+ return cast<TypeSpecLoc>(*this);
}
/// \brief Find the TypeSpecLoc that is part of this TypeLoc and return its
@@ -46,9 +46,9 @@ class TypeSizer : public TypeLocVisitor<TypeSizer, unsigned> {
public:
#define ABSTRACT_TYPELOC(CLASS)
#define TYPELOC(CLASS, PARENT, TYPE) \
- unsigned Visit##CLASS(CLASS TyLoc) { return TyLoc.getFullDataSize(); }
+ unsigned Visit##CLASS(CLASS TyLoc) { return TyLoc.getFullDataSize(); }
#include "clang/AST/TypeLocNodes.def"
-
+
unsigned VisitTypeLoc(TypeLoc TyLoc) {
assert(0 && "A type loc wrapper was not handled!");
return 0;
@@ -70,7 +70,7 @@ class NextLoc : public TypeLocVisitor<NextLoc, TypeLoc> {
public:
#define TYPELOC(CLASS, PARENT, TYPE)
#define DECLARATOR_TYPELOC(CLASS, TYPE) \
- TypeLoc Visit##CLASS(CLASS TyLoc);
+ TypeLoc Visit##CLASS(CLASS TyLoc);
#include "clang/AST/TypeLocNodes.def"
TypeLoc VisitTypeSpecLoc(TypeLoc TyLoc) { return TypeLoc(); }
@@ -84,16 +84,16 @@ public:
}
TypeLoc NextLoc::VisitPointerLoc(PointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getPointeeLoc();
}
TypeLoc NextLoc::VisitMemberPointerLoc(MemberPointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getPointeeLoc();
}
TypeLoc NextLoc::VisitBlockPointerLoc(BlockPointerLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getPointeeLoc();
}
TypeLoc NextLoc::VisitReferenceLoc(ReferenceLoc TL) {
- return TL.getPointeeLoc();
+ return TL.getPointeeLoc();
}
TypeLoc NextLoc::VisitFunctionLoc(FunctionLoc TL) {
return TL.getResultLoc();
@@ -105,7 +105,7 @@ TypeLoc NextLoc::VisitArrayLoc(ArrayLoc TL) {
/// \brief Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the
/// TypeLoc is a PointerLoc and next TypeLoc is for "int".
TypeLoc TypeLoc::getNextTypeLoc() const {
- return NextLoc().Visit(*this);
+ return NextLoc().Visit(*this);
}
//===----------------------------------------------------------------------===//
@@ -119,7 +119,7 @@ class TypeSpecRanger : public TypeLocVisitor<TypeSpecRanger, SourceRange> {
public:
#define TYPELOC(CLASS, PARENT, TYPE)
#define TYPESPEC_TYPELOC(CLASS, TYPE) \
- SourceRange Visit##CLASS(CLASS TyLoc) { return TyLoc.getSourceRange(); }
+ SourceRange Visit##CLASS(CLASS TyLoc) { return TyLoc.getSourceRange(); }
#include "clang/AST/TypeLocNodes.def"
SourceRange VisitTypeLoc(TypeLoc TyLoc) {
@@ -139,13 +139,13 @@ SourceRange TypeSpecLoc::getSourceRange() const {
namespace {
class TypeSpecChecker : public TypeLocVisitor<TypeSpecChecker, bool> {
public:
- bool VisitTypeSpecLoc(TypeSpecLoc TyLoc) { return true; }
+ bool VisitTypeSpecLoc(TypeSpecLoc TyLoc) { return true; }
};
}
bool TypeSpecLoc::classof(const TypeLoc *TL) {
- return TypeSpecChecker().Visit(*TL);
+ return TypeSpecChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -159,7 +159,7 @@ class TypeSpecGetter : public TypeLocVisitor<TypeSpecGetter, TypeSpecLoc> {
public:
#define TYPELOC(CLASS, PARENT, TYPE)
#define DECLARATOR_TYPELOC(CLASS, TYPE) \
- TypeSpecLoc Visit##CLASS(CLASS TyLoc) { return TyLoc.getTypeSpecLoc(); }
+ TypeSpecLoc Visit##CLASS(CLASS TyLoc) { return TyLoc.getTypeSpecLoc(); }
#include "clang/AST/TypeLocNodes.def"
TypeSpecLoc VisitTypeLoc(TypeLoc TyLoc) {
@@ -179,13 +179,13 @@ namespace {
class DeclaratorLocChecker : public TypeLocVisitor<DeclaratorLocChecker, bool> {
public:
- bool VisitDeclaratorLoc(DeclaratorLoc TyLoc) { return true; }
+ bool VisitDeclaratorLoc(DeclaratorLoc TyLoc) { return true; }
};
}
bool DeclaratorLoc::classof(const TypeLoc *TL) {
- return DeclaratorLocChecker().Visit(*TL);
+ return DeclaratorLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -197,13 +197,13 @@ namespace {
class DefaultTypeSpecLocChecker :
public TypeLocVisitor<DefaultTypeSpecLocChecker, bool> {
public:
- bool VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) { return true; }
+ bool VisitDefaultTypeSpecLoc(DefaultTypeSpecLoc TyLoc) { return true; }
};
}
bool DefaultTypeSpecLoc::classof(const TypeLoc *TL) {
- return DefaultTypeSpecLocChecker().Visit(*TL);
+ return DefaultTypeSpecLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -214,13 +214,13 @@ namespace {
class TypedefLocChecker : public TypeLocVisitor<TypedefLocChecker, bool> {
public:
- bool VisitTypedefLoc(TypedefLoc TyLoc) { return true; }
+ bool VisitTypedefLoc(TypedefLoc TyLoc) { return true; }
};
}
bool TypedefLoc::classof(const TypeLoc *TL) {
- return TypedefLocChecker().Visit(*TL);
+ return TypedefLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -231,13 +231,13 @@ namespace {
class PointerLocChecker : public TypeLocVisitor<PointerLocChecker, bool> {
public:
- bool VisitPointerLoc(PointerLoc TyLoc) { return true; }
+ bool VisitPointerLoc(PointerLoc TyLoc) { return true; }
};
}
bool PointerLoc::classof(const TypeLoc *TL) {
- return PointerLocChecker().Visit(*TL);
+ return PointerLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -249,13 +249,13 @@ namespace {
class BlockPointerLocChecker :
public TypeLocVisitor<BlockPointerLocChecker, bool> {
public:
- bool VisitBlockPointerLoc(BlockPointerLoc TyLoc) { return true; }
+ bool VisitBlockPointerLoc(BlockPointerLoc TyLoc) { return true; }
};
}
bool BlockPointerLoc::classof(const TypeLoc *TL) {
- return BlockPointerLocChecker().Visit(*TL);
+ return BlockPointerLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -267,13 +267,13 @@ namespace {
class MemberPointerLocChecker :
public TypeLocVisitor<MemberPointerLocChecker, bool> {
public:
- bool VisitMemberPointerLoc(MemberPointerLoc TyLoc) { return true; }
+ bool VisitMemberPointerLoc(MemberPointerLoc TyLoc) { return true; }
};
}
bool MemberPointerLoc::classof(const TypeLoc *TL) {
- return MemberPointerLocChecker().Visit(*TL);
+ return MemberPointerLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -284,13 +284,13 @@ namespace {
class ReferenceLocChecker : public TypeLocVisitor<ReferenceLocChecker, bool> {
public:
- bool VisitReferenceLoc(ReferenceLoc TyLoc) { return true; }
+ bool VisitReferenceLoc(ReferenceLoc TyLoc) { return true; }
};
}
bool ReferenceLoc::classof(const TypeLoc *TL) {
- return ReferenceLocChecker().Visit(*TL);
+ return ReferenceLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -301,13 +301,13 @@ namespace {
class FunctionLocChecker : public TypeLocVisitor<FunctionLocChecker, bool> {
public:
- bool VisitFunctionLoc(FunctionLoc TyLoc) { return true; }
+ bool VisitFunctionLoc(FunctionLoc TyLoc) { return true; }
};
}
bool FunctionLoc::classof(const TypeLoc *TL) {
- return FunctionLocChecker().Visit(*TL);
+ return FunctionLocChecker().Visit(*TL);
}
//===----------------------------------------------------------------------===//
@@ -318,11 +318,11 @@ namespace {
class ArrayLocChecker : public TypeLocVisitor<ArrayLocChecker, bool> {
public:
- bool VisitArrayLoc(ArrayLoc TyLoc) { return true; }
+ bool VisitArrayLoc(ArrayLoc TyLoc) { return true; }
};
}
bool ArrayLoc::classof(const TypeLoc *TL) {
- return ArrayLocChecker().Visit(*TL);
+ return ArrayLocChecker().Visit(*TL);
}
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index da671d62f1..a4cb66be04 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -45,18 +45,18 @@ Stmt *AnalysisContext::getBody() {
const ImplicitParamDecl *AnalysisContext::getSelfDecl() const {
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
return MD->getSelfDecl();
-
+
return NULL;
}
CFG *AnalysisContext::getCFG() {
- if (!cfg)
+ if (!cfg)
cfg = CFG::buildCFG(getBody(), &D->getASTContext());
return cfg;
}
ParentMap &AnalysisContext::getParentMap() {
- if (!PM)
+ if (!PM)
PM = new ParentMap(getBody());
return *PM;
}
@@ -66,12 +66,12 @@ LiveVariables *AnalysisContext::getLiveVariables() {
CFG *c = getCFG();
if (!c)
return 0;
-
+
liveness = new LiveVariables(D->getASTContext(), *c);
liveness->runOnCFG(*c);
liveness->runOnAllBlocks(*c, 0, true);
}
-
+
return liveness;
}
@@ -79,7 +79,7 @@ AnalysisContext *AnalysisContextManager::getContext(const Decl *D) {
AnalysisContext *&AC = Contexts[D];
if (!AC)
AC = new AnalysisContext(D);
-
+
return AC;
}
@@ -104,14 +104,14 @@ void ScopeContext::Profile(llvm::FoldingSetNodeID &ID, AnalysisContext *ctx,
}
StackFrameContext*
-LocationContextManager::getStackFrame(AnalysisContext *ctx,
+LocationContextManager::getStackFrame(AnalysisContext *ctx,
const LocationContext *parent,
const Stmt *s) {
llvm::FoldingSetNodeID ID;
StackFrameContext::Profile(ID, ctx, parent, s);
void *InsertPos;
- StackFrameContext *f =
+ StackFrameContext *f =
cast_or_null<StackFrameContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
if (!f) {
f = new StackFrameContext(ctx, parent, s);
@@ -126,7 +126,7 @@ ScopeContext *LocationContextManager::getScope(AnalysisContext *ctx,
llvm::FoldingSetNodeID ID;
ScopeContext::Profile(ID, ctx, parent, s);
void *InsertPos;
-
+
ScopeContext *scope =
cast_or_null<ScopeContext>(Contexts.FindNodeOrInsertPos(ID, InsertPos));
diff --git a/lib/Analysis/AnalysisManager.cpp b/lib/Analysis/AnalysisManager.cpp
index b73e86da8e..623db17b92 100644
--- a/lib/Analysis/AnalysisManager.cpp
+++ b/lib/Analysis/AnalysisManager.cpp
@@ -17,12 +17,12 @@
using namespace clang;
void AnalysisManager::DisplayFunction() {
-
+
if (DisplayedFunction)
return;
-
+
DisplayedFunction = true;
-
+
// FIXME: Is getCodeDecl() always a named decl?
if (isa<FunctionDecl>(getCodeDecl()) ||
isa<ObjCMethodDecl>(getCodeDecl())) {
diff --git a/lib/Analysis/BasicConstraintManager.cpp b/lib/Analysis/BasicConstraintManager.cpp
index cb89d30651..d0b8289528 100644
--- a/lib/Analysis/BasicConstraintManager.cpp
+++ b/lib/Analysis/BasicConstraintManager.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines BasicConstraintManager, a class that tracks simple
+// This file defines BasicConstraintManager, a class that tracks simple
// equality and inequality constraints on symbolic values of GRState.
//
//===----------------------------------------------------------------------===//
@@ -27,22 +27,22 @@ namespace { class VISIBILITY_HIDDEN ConstEq {}; }
typedef llvm::ImmutableMap<SymbolRef,GRState::IntSetTy> ConstNotEqTy;
typedef llvm::ImmutableMap<SymbolRef,const llvm::APSInt*> ConstEqTy;
-
+
static int ConstEqIndex = 0;
static int ConstNotEqIndex = 0;
namespace clang {
template<>
struct GRStateTrait<ConstNotEq> : public GRStatePartialTrait<ConstNotEqTy> {
- static inline void* GDMIndex() { return &ConstNotEqIndex; }
+ static inline void* GDMIndex() { return &ConstNotEqIndex; }
};
template<>
struct GRStateTrait<ConstEq> : public GRStatePartialTrait<ConstEqTy> {
- static inline void* GDMIndex() { return &ConstEqIndex; }
+ static inline void* GDMIndex() { return &ConstEqIndex; }
};
-}
-
+}
+
namespace {
// BasicConstraintManager only tracks equality and inequality constraints of
// constants and integer variables.
@@ -50,7 +50,7 @@ class VISIBILITY_HIDDEN BasicConstraintManager
: public SimpleConstraintManager {
GRState::IntSetTy::Factory ISetFactory;
public:
- BasicConstraintManager(GRStateManager& statemgr)
+ BasicConstraintManager(GRStateManager& statemgr)
: ISetFactory(statemgr.getAllocator()) {}
const GRState* AssumeSymNE(const GRState* state, SymbolRef sym,
@@ -83,7 +83,7 @@ public:
const GRState* RemoveDeadBindings(const GRState* state, SymbolReaper& SymReaper);
- void print(const GRState* state, llvm::raw_ostream& Out,
+ void print(const GRState* state, llvm::raw_ostream& Out,
const char* nl, const char *sep);
};
@@ -133,7 +133,7 @@ const GRState *BasicConstraintManager::AssumeSymEQ(const GRState *state,
// These logic will be handled in another ConstraintManager.
const GRState *BasicConstraintManager::AssumeSymLT(const GRState *state,
SymbolRef sym,
- const llvm::APSInt& V) {
+ const llvm::APSInt& V) {
// Is 'V' the smallest possible value?
if (V == llvm::APSInt::getMinValue(V.getBitWidth(), V.isUnsigned())) {
// sym cannot be any value less than 'V'. This path is infeasible.
@@ -167,14 +167,14 @@ const GRState *BasicConstraintManager::AssumeSymGE(const GRState *state,
bool isFeasible = *X >= V;
return isFeasible ? state : NULL;
}
-
+
// Sym is not a constant, but it is worth looking to see if V is the
// maximum integer value.
if (V == llvm::APSInt::getMaxValue(V.getBitWidth(), V.isUnsigned())) {
// If we know that sym != V, then this condition is infeasible since
- // there is no other value greater than V.
+ // there is no other value greater than V.
bool isFeasible = !isNotEqual(state, sym, V);
-
+
// If the path is still feasible then as a consequence we know that
// 'sym == V' because we cannot have 'sym > V' (no larger values).
// Add this constraint.
@@ -193,20 +193,20 @@ BasicConstraintManager::AssumeSymLE(const GRState* state, SymbolRef sym,
bool isFeasible = *X <= V;
return isFeasible ? state : NULL;
}
-
+
// Sym is not a constant, but it is worth looking to see if V is the
// minimum integer value.
if (V == llvm::APSInt::getMinValue(V.getBitWidth(), V.isUnsigned())) {
// If we know that sym != V, then this condition is infeasible since
- // there is no other value less than V.
+ // there is no other value less than V.
bool isFeasible = !isNotEqual(state, sym, V);
-
+
// If the path is still feasible then as a consequence we know that
// 'sym == V' because we cannot have 'sym < V' (no smaller values).
// Add this constraint.
return isFeasible ? AddEQ(state, sym, V) : NULL;
}
-
+
return state;
}
@@ -222,10 +222,10 @@ const GRState* BasicConstraintManager::AddNE(const GRState* state, SymbolRef sym
// First, retrieve the NE-set associated with the given symbol.
ConstNotEqTy::data_type* T = state->get<ConstNotEq>(sym);
GRState::IntSetTy S = T ? *T : ISetFactory.GetEmptySet();
-
+
// Now add V to the NE set.
S = ISetFactory.Add(S, &V);
-
+
// Create a new state with the old binding replaced.
return state->set<ConstNotEq>(sym, S);
}
@@ -236,7 +236,7 @@ const llvm::APSInt* BasicConstraintManager::getSymVal(const GRState* state,
return T ? *T : NULL;
}
-bool BasicConstraintManager::isNotEqual(const GRState* state, SymbolRef sym,
+bool BasicConstraintManager::isNotEqual(const GRState* state, SymbolRef sym,
const llvm::APSInt& V) const {
// Retrieve the NE-set associated with the given symbol.
@@ -273,14 +273,14 @@ BasicConstraintManager::RemoveDeadBindings(const GRState* state,
ConstNotEqTy::Factory& CNEFactory = state->get_context<ConstNotEq>();
for (ConstNotEqTy::iterator I = CNE.begin(), E = CNE.end(); I != E; ++I) {
- SymbolRef sym = I.getKey();
+ SymbolRef sym = I.getKey();
if (SymReaper.maybeDead(sym)) CNE = CNEFactory.Remove(CNE, sym);
}
-
+
return state->set<ConstNotEq>(CNE);
}
-void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out,
+void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
// Print equality constraints.
@@ -293,23 +293,23 @@ void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out,
}
// Print != constraints.
-
+
ConstNotEqTy CNE = state->get<ConstNotEq>();
-
+
if (!CNE.isEmpty()) {
Out << nl << sep << "'!=' constraints:";
-
+
for (ConstNotEqTy::iterator I = CNE.begin(), EI = CNE.end(); I!=EI; ++I) {
Out << nl << " $" << I.getKey() << " : ";
bool isFirst = true;
-
- GRState::IntSetTy::iterator J = I.getData().begin(),
- EJ = I.getData().end();
-
- for ( ; J != EJ; ++J) {
+
+ GRState::IntSetTy::iterator J = I.getData().begin(),
+ EJ = I.getData().end();
+
+ for ( ; J != EJ; ++J) {
if (isFirst) isFirst = false;
else Out << ", ";
-
+
Out << (*J)->getSExtValue(); // Hack: should print to raw_ostream.
}
}
diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp
index 88910990ce..9c20089b4f 100644
--- a/lib/Analysis/BasicObjCFoundationChecks.cpp
+++ b/lib/Analysis/BasicObjCFoundationChecks.cpp
@@ -33,10 +33,10 @@ using namespace clang;
static const ObjCInterfaceType* GetReceiverType(const ObjCMessageExpr* ME) {
const Expr* Receiver = ME->getReceiver();
-
+
if (!Receiver)
return NULL;
-
+
if (const ObjCObjectPointerType *PT =
Receiver->getType()->getAsObjCObjectPointerType())
return PT->getInterfaceType();
@@ -56,75 +56,75 @@ class VISIBILITY_HIDDEN APIMisuse : public BugType {
public:
APIMisuse(const char* name) : BugType(name, "API Misuse (Apple)") {}
};
-
+
class VISIBILITY_HIDDEN BasicObjCFoundationChecks : public GRSimpleAPICheck {
APIMisuse *BT;
BugReporter& BR;
ASTContext &Ctx;
-
+
bool isNSString(const ObjCInterfaceType *T, const char* suffix);
bool AuditNSString(ExplodedNode* N, const ObjCMessageExpr* ME);
-
- void Warn(ExplodedNode* N, const Expr* E, const std::string& s);
+
+ void Warn(ExplodedNode* N, const Expr* E, const std::string& s);
void WarnNilArg(ExplodedNode* N, const Expr* E);
-
+
bool CheckNilArg(ExplodedNode* N, unsigned Arg);
public:
- BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br)
+ BasicObjCFoundationChecks(ASTContext& ctx, BugReporter& br)
: BT(0), BR(br), Ctx(ctx) {}
-
+
bool Audit(ExplodedNode* N, GRStateManager&);
-
-private:
- void WarnNilArg(ExplodedNode* N, const ObjCMessageExpr* ME, unsigned Arg) {
+
+private:
+ void WarnNilArg(ExplodedNode* N, const ObjCMessageExpr* ME, unsigned Arg) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Argument to '" << GetReceiverNameType(ME) << "' method '"
<< ME->getSelector().getAsString() << "' cannot be nil.";
-
+
// Lazily create the BugType object for NilArg. This will be owned
// by the BugReporter object 'BR' once we call BR.EmitWarning.
if (!BT) BT = new APIMisuse("nil argument");
-
+
RangedBugReport *R = new RangedBugReport(*BT, os.str().c_str(), N);
R->addRange(ME->getArg(Arg)->getSourceRange());
BR.EmitReport(R);
}
};
-
+
} // end anonymous namespace
GRSimpleAPICheck*
clang::CreateBasicObjCFoundationChecks(ASTContext& Ctx, BugReporter& BR) {
- return new BasicObjCFoundationChecks(Ctx, BR);
+ return new BasicObjCFoundationChecks(Ctx, BR);
}
bool BasicObjCFoundationChecks::Audit(ExplodedNode* N,
GRStateManager&) {
-
+
const ObjCMessageExpr* ME =
cast<ObjCMessageExpr>(cast<PostStmt>(N->getLocation()).getStmt());
const ObjCInterfaceType *ReceiverType = GetReceiverType(ME);
-
+
if (!ReceiverType)
return false;
-
+
const char* name = ReceiverType->getDecl()->getIdentifier()->getName();
-
+
if (!name)
return false;
if (name[0] != 'N' || name[1] != 'S')
return false;
-
+
name += 2;
-
- // FIXME: Make all of this faster.
+
+ // FIXME: Make all of this faster.
if (isNSString(ReceiverType, name))
return AuditNSString(N, ME);
@@ -132,7 +132,7 @@ bool BasicObjCFoundationChecks::Audit(ExplodedNode* N,
}
static inline bool isNil(SVal X) {
- return isa<loc::ConcreteInt>(X);
+ return isa<loc::ConcreteInt>(X);
}
//===----------------------------------------------------------------------===//
@@ -142,14 +142,14 @@ static inline bool isNil(SVal X) {
bool BasicObjCFoundationChecks::CheckNilArg(ExplodedNode* N, unsigned Arg) {
const ObjCMessageExpr* ME =
cast<ObjCMessageExpr>(cast<PostStmt>(N->getLocation()).getStmt());
-
+
const Expr * E = ME->getArg(Arg);
-
+
if (isNil(N->getState()->getSVal(E))) {
WarnNilArg(N, ME, Arg);
return true;
}
-
+
return false;
}
@@ -158,35 +158,35 @@ bool BasicObjCFoundationChecks::CheckNilArg(ExplodedNode* N, unsigned Arg) {
//===----------------------------------------------------------------------===//
bool BasicObjCFoundationChecks::isNSString(const ObjCInterfaceType *T,
- const char* suffix) {
+ const char* suffix) {
return !strcmp("String", suffix) || !strcmp("MutableString", suffix);
}
-bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N,
+bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N,
const ObjCMessageExpr* ME) {
-
+
Selector S = ME->getSelector();
-
+
if (S.isUnarySelector())
return false;
// FIXME: This is going to be really slow doing these checks with
// lexical comparisons.
-
+
std::string name = S.getAsString();
assert (!name.empty());
const char* cstr = &name[0];
unsigned len = name.size();
-
+
switch (len) {
default:
break;
- case 8:
+ case 8:
if (!strcmp(cstr, "compare:"))
return CheckNilArg(N, 0);
-
+
break;
-
+
case 15:
// FIXME: Checking for initWithFormat: will not work in most cases
// yet because [NSString alloc] returns id, not NSString*. We will
@@ -194,41 +194,41 @@ bool BasicObjCFoundationChecks::AuditNSString(ExplodedNode* N,
// to find these errors.
if (!strcmp(cstr, "initWithFormat:"))
return CheckNilArg(N, 0);
-
+
break;
-
+
case 16:
if (!strcmp(cstr, "compare:options:"))
return CheckNilArg(N, 0);
-
+
break;
-
+
case 22:
if (!strcmp(cstr, "compare:options:range:"))
return CheckNilArg(N, 0);
-
+
break;
-
+
case 23:
-
+
if (!strcmp(cstr, "caseInsensitiveCompare:"))
return CheckNilArg(N, 0);
-
+
break;
case 29:
if (!strcmp(cstr, "compare:options:range:locale:"))
return CheckNilArg(N, 0);
-
- break;
-
+
+ break;
+
case 37:
if (!strcmp(cstr, "componentsSeparatedByCharactersInSet:"))
return CheckNilArg(N, 0);
-
- break;
+
+ break;
}
-
+
return false;
}
@@ -240,7 +240,7 @@ namespace {
class VISIBILITY_HIDDEN AuditCFNumberCreate : public GRSimpleAPICheck {
APIMisuse* BT;
-
+
// FIXME: Either this should be refactored into GRSimpleAPICheck, or
// it should always be passed with a call to Audit. The latter
// approach makes this class more stateless.
@@ -249,16 +249,16 @@ class VISIBILITY_HIDDEN AuditCFNumberCreate : public GRSimpleAPICheck {
BugReporter& BR;
public:
- AuditCFNumberCreate(ASTContext& ctx, BugReporter& br)
+ AuditCFNumberCreate(ASTContext& ctx, BugReporter& br)
: BT(0), Ctx(ctx), II(&Ctx.Idents.get("CFNumberCreate")), BR(br){}
-
+
~AuditCFNumberCreate() {}
-
+
bool Audit(ExplodedNode* N, GRStateManager&);
-
+
private:
void AddError(const TypedRegion* R, const Expr* Ex, ExplodedNode *N,
- uint64_t SourceSize, uint64_t TargetSize, uint64_t NumberKind);
+ uint64_t SourceSize, uint64_t TargetSize, uint64_t NumberKind);
};
} // end anonymous namespace
@@ -289,7 +289,7 @@ namespace {
public:
Optional() : IsKnown(false), Val(0) {}
Optional(const T& val) : IsKnown(true), Val(val) {}
-
+
bool isKnown() const { return IsKnown; }
const T& getValue() const {
@@ -305,12 +305,12 @@ namespace {
static Optional<uint64_t> GetCFNumberSize(ASTContext& Ctx, uint64_t i) {
static unsigned char FixedSize[] = { 8, 16, 32, 64, 32, 64 };
-
+
if (i < kCFNumberCharType)
return FixedSize[i-1];
-
+
QualType T;
-
+
switch (i) {
case kCFNumberCharType: T = Ctx.CharTy; break;
case kCFNumberShortType: T = Ctx.ShortTy; break;
@@ -322,11 +322,11 @@ static Optional<uint64_t> GetCFNumberSize(ASTContext& Ctx, uint64_t i) {
case kCFNumberCFIndexType:
case kCFNumberNSIntegerType:
case kCFNumberCGFloatType:
- // FIXME: We need a way to map from names to Type*.
+ // FIXME: We need a way to map from names to Type*.
default:
return Optional<uint64_t>();
}
-
+
return Ctx.getTypeSize(T);
}
@@ -350,72 +350,72 @@ static const char* GetCFNumberTypeStr(uint64_t i) {
"kCFNumberNSIntegerType",
"kCFNumberCGFloatType"
};
-
+
return i <= kCFNumberCGFloatType ? Names[i-1] : "Invalid CFNumberType";
}
#endif
-bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){
+bool AuditCFNumberCreate::Audit(ExplodedNode* N,GRStateManager&){
const CallExpr* CE =
cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
- const Expr* Callee = CE->getCallee();
- SVal CallV = N->getState()->getSVal(Callee);
+ const Expr* Callee = CE->getCallee();
+ SVal CallV = N->getState()->getSVal(Callee);
const FunctionDecl* FD = CallV.getAsFunctionDecl();
if (!FD || FD->getIdentifier() != II || CE->getNumArgs()!=3)
return false;
-
+
// Get the value of the "theType" argument.
SVal TheTypeVal = N->getState()->getSVal(CE->getArg(1));
-
+
// FIXME: We really should allow ranges of valid theType values, and
// bifurcate the state appropriately.
nonloc::ConcreteInt* V = dyn_cast<nonloc::ConcreteInt>(&TheTypeVal);
-
+
if (!V)
return false;
-
+
uint64_t NumberKind = V->getValue().getLimitedValue();
Optional<uint64_t> TargetSize = GetCFNumberSize(Ctx, NumberKind);
-
+
// FIXME: In some cases we can emit an error.
if (!TargetSize.isKnown())
return false;
-
+
// Look at the value of the integer being passed by reference. Essentially
// we want to catch cases where the value passed in is not equal to the
// size of the type being created.
SVal TheValueExpr = N->getState()->getSVal(CE->getArg(2));
-
+
// FIXME: Eventually we should handle arbitrary locations. We can do this
// by having an enhanced memory model that does low-level typing.
loc::MemRegionVal* LV = dyn_cast<loc::MemRegionVal>(&TheValueExpr);
if (!LV)
return false;
-
+
const TypedRegion* R = dyn_cast<TypedRegion>(LV->getBaseRegion());
if (!R)
return false;
QualType T = Ctx.getCanonicalType(R->getValueType(Ctx));
-
+
// FIXME: If the pointee isn't an integer type, should we flag a warning?
// People can do weird stuff with pointers.
-
- if (!T->isIntegerType())
+
+ if (!T->isIntegerType())
return false;
-
+
uint64_t SourceSize = Ctx.getTypeSize(T);
-
+
// CHECK: is SourceSize == TargetSize
-
+
if (SourceSize == TargetSize)
return false;
-
+
AddError(R, CE->getArg(2), N, SourceSize, TargetSize, NumberKind);
-
+
// FIXME: We can actually create an abstract "CFNumber" object that has
// the bits initialized to the provided values.
return SourceSize < TargetSize;
@@ -425,23 +425,23 @@ void AuditCFNumberCreate::AddError(const TypedRegion* R, const Expr* Ex,
ExplodedNode *N,
uint64_t SourceSize, uint64_t TargetSize,
uint64_t NumberKind) {
-
+
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << (SourceSize == 8 ? "An " : "A ")
<< SourceSize << " bit integer is used to initialize a CFNumber "
"object that represents "
<< (TargetSize == 8 ? "an " : "a ")
- << TargetSize << " bit integer. ";
+ << TargetSize << " bit integer. ";
if (SourceSize < TargetSize)
os << (TargetSize - SourceSize)
- << " bits of the CFNumber value will be garbage." ;
+ << " bits of the CFNumber value will be garbage." ;
else
os << (SourceSize - TargetSize)
<< " bits of the input integer will be lost.";
-
+
// Lazily create the BugType object. This will be owned
// by the BugReporter object 'BR' once we call BR.EmitWarning.
if (!BT) BT = new APIMisuse("Bad use of CFNumberCreate");
@@ -451,7 +451,7 @@ void AuditCFNumberCreate::AddError(const TypedRegion* R, const Expr* Ex,
}
GRSimpleAPICheck*
-clang::CreateAuditCFNumberCreate(ASTContext& Ctx, BugReporter& BR) {
+clang::CreateAuditCFNumberCreate(ASTContext& Ctx, BugReporter& BR) {
return new AuditCFNumberCreate(Ctx, BR);
}
@@ -462,22 +462,22 @@ clang::CreateAuditCFNumberCreate(ASTContext& Ctx, BugReporter& BR) {
namespace {
class VISIBILITY_HIDDEN AuditCFRetainRelease : public GRSimpleAPICheck {
APIMisuse *BT;
-
+
// FIXME: Either this should be refactored into GRSimpleAPICheck, or
// it should always be passed with a call to Audit. The latter
// approach makes this class more stateless.
ASTContext& Ctx;
IdentifierInfo *Retain, *Release;
BugReporter& BR;
-
+
public:
- AuditCFRetainRelease(ASTContext& ctx, BugReporter& br)
+ AuditCFRetainRelease(ASTContext& ctx, BugReporter& br)
: BT(0), Ctx(ctx),
Retain(&Ctx.Idents.get("CFRetain")), Release(&Ctx.Idents.get("CFRelease")),
BR(br){}
-
+
~AuditCFRetainRelease() {}
-
+
bool Audit(ExplodedNode* N, GRStateManager&);
};
} // end anonymous namespace
@@ -485,23 +485,23 @@ public:
bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) {
const CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt());
-
+
// If the CallExpr doesn't have exactly 1 argument just give up checking.
if (CE->getNumArgs() != 1)
return false;
-
+
// Check if we called CFRetain/CFRelease.
const GRState* state = N->getState();
SVal X = state->getSVal(CE->getCallee());
const FunctionDecl* FD = X.getAsFunctionDecl();
-
+
if (!FD)
return false;
-
- const IdentifierInfo *FuncII = FD->getIdentifier();
+
+ const IdentifierInfo *FuncII = FD->getIdentifier();
if (!(FuncII == Retain || FuncII == Release))
return false;
-
+
// Finally, check if the argument is NULL.
// FIXME: We should be able to bifurcate the state here, as a successful
// check will result in the value not being NULL afterwards.
@@ -511,7 +511,7 @@ bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) {
if (state->getStateManager().isEqual(state, CE->getArg(0), 0)) {
if (!BT)
BT = new APIMisuse("null passed to CFRetain/CFRelease");
-
+
const char *description = (FuncII == Retain)
? "Null pointer argument in call to CFRetain"
: "Null pointer argument in call to CFRelease";
@@ -524,10 +524,10 @@ bool AuditCFRetainRelease::Audit(ExplodedNode* N, GRStateManager&) {
return false;
}
-
-
+
+
GRSimpleAPICheck*
-clang::CreateAuditCFRetainRelease(ASTContext& Ctx, BugReporter& BR) {
+clang::CreateAuditCFRetainRelease(ASTContext& Ctx, BugReporter& BR) {
return new AuditCFRetainRelease(Ctx, BR);
}
@@ -541,8 +541,8 @@ void clang::RegisterAppleChecks(GRExprEngine& Eng, const Decl &D) {
Eng.AddCheck(CreateBasicObjCFoundationChecks(Ctx, BR),
Stmt::ObjCMessageExprClass);
- Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, BR), Stmt::CallExprClass);
+ Eng.AddCheck(CreateAuditCFNumberCreate(Ctx, BR), Stmt::CallExprClass);
Eng.AddCheck(CreateAuditCFRetainRelease(Ctx, BR), Stmt::CallExprClass);
-
+
RegisterNSErrorChecks(BR, Eng, D);
}
diff --git a/lib/Analysis/BasicObjCFoundationChecks.h b/lib/Analysis/BasicObjCFoundationChecks.h
index 8aa996095b..1271ae4ab1 100644
--- a/lib/Analysis/BasicObjCFoundationChecks.h
+++ b/lib/Analysis/BasicObjCFoundationChecks.h
@@ -25,24 +25,24 @@
#define LLVM_CLANG_ANALYSIS_BASICOBJCFOUNDATIONCHECKS
namespace clang {
-
+
class GRSimpleAPICheck;
class ASTContext;
-class GRStateManager;
+class GRStateManager;
class BugReporter;
class GRExprEngine;
-
+
GRSimpleAPICheck *CreateBasicObjCFoundationChecks(ASTContext& Ctx,
BugReporter& BR);
-
+
GRSimpleAPICheck *CreateAuditCFNumberCreate(ASTContext& Ctx,
BugReporter& BR);
-
+
GRSimpleAPICheck *CreateAuditCFRetainRelease(ASTContext& Ctx,
BugReporter& BR);
-
+
void RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng, const Decl &D);
-
+
} // end clang namespace
#endif
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index 682feb50d8..388b2e9144 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -20,10 +20,10 @@
using namespace clang;
-typedef llvm::ImmutableMap<const MemRegion*,SVal> BindingsTy;
+typedef llvm::ImmutableMap<const MemRegion*,SVal> BindingsTy;
namespace {
-
+
class VISIBILITY_HIDDEN BasicStoreSubRegionMap : public SubRegionMap {
public:
BasicStoreSubRegionMap() {}
@@ -32,13 +32,13 @@ public:
return true; // Do nothing. No subregions.
}
};
-
+
class VISIBILITY_HIDDEN BasicStoreManager : public StoreManager {
BindingsTy::Factory VBFactory;
public:
BasicStoreManager(GRStateManager& mgr)
: StoreManager(mgr), VBFactory(mgr.getAllocator()) {}
-
+
~BasicStoreManager() {}
SubRegionMap *getSubRegionMap(const GRState *state) {
@@ -47,7 +47,7 @@ public:
SValuator::CastResult Retrieve(const GRState *state, Loc loc,
QualType T = QualType());
-
+
const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
const Expr *E, unsigned Count);
@@ -57,8 +57,8 @@ public:
Store scanForIvars(Stmt *B, const Decl* SelfDecl,
const MemRegion *SelfRegion, Store St);
-
- Store BindInternal(Store St, Loc loc, SVal V);
+
+ Store BindInternal(Store St, Loc loc, SVal V);
Store Remove(Store St, Loc loc);
Store getInitialStore(const LocationContext *InitLoc);
@@ -66,27 +66,27 @@ public:
virtual Loc getLoc(const VarDecl* VD, const LocationContext *LC) {
return ValMgr.makeLoc(MRMgr.getVarRegion(VD, LC));
}
-
+
const GRState *BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* cl,
SVal val) {
return state;
}
-
+
SVal getLValueVar(const GRState *state, const VarDecl *VD,
const LocationContext *LC);
SVal getLValueString(const GRState *state, const StringLiteral *S);
SVal getLValueCompoundLiteral(const GRState *state,
const CompoundLiteralExpr *CL);
SVal getLValueIvar(const GRState *state, const ObjCIvarDecl* D, SVal Base);
- SVal getLValueField(const GRState *state, SVal Base, const FieldDecl *D);
+ SVal getLValueField(const GRState *state, SVal Base, const FieldDecl *D);
SVal getLValueElement(const GRState *state, QualType elementType,
SVal Base, SVal Offset);
/// ArrayToPointer - Used by GRExprEngine::VistCast to handle implicit
/// conversions between arrays and pointers.
SVal ArrayToPointer(Loc Array) { return Array; }
-
+
/// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values.
/// It updatees the GRState object in place with the values removed.
void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper,
@@ -118,7 +118,7 @@ public:
private:
ASTContext& getContext() { return StateMgr.getContext(); }
};
-
+
} // end anonymous namespace
@@ -131,7 +131,7 @@ SVal BasicStoreManager::getLValueVar(const GRState *state, const VarDecl* VD,
return ValMgr.makeLoc(MRMgr.getVarRegion(VD, LC));
}
-SVal BasicStoreManager::getLValueString(const GRState *state,
+SVal BasicStoreManager::getLValueString(const GRState *state,
const StringLiteral* S) {
return ValMgr.makeLoc(MRMgr.getStringRegion(S));
}
@@ -144,7 +144,7 @@ SVal BasicStoreManager::getLValueCompoundLiteral(const GRState *state,
SVal BasicStoreManager::getLValueIvar(const GRState *state,
const ObjCIvarDecl* D,
SVal Base) {
-
+
if (Base.isUnknownOrUndef())
return Base;
@@ -154,7 +154,7 @@ SVal BasicStoreManager::getLValueIvar(const GRState *state,
const MemRegion *BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
return ValMgr.makeLoc(MRMgr.getObjCIvarRegion(D, BaseR));
}
-
+
return UnknownVal();
}
@@ -163,10 +163,10 @@ SVal BasicStoreManager::getLValueField(const GRState *state, SVal Base,
if (Base.isUnknownOrUndef())
return Base;
-
- Loc BaseL = cast<Loc>(Base);
+
+ Loc BaseL = cast<Loc>(Base);
const MemRegion* BaseR = 0;
-
+
switch(BaseL.getSubKind()) {
case loc::GotoLabelKind:
return UndefinedVal();
@@ -174,7 +174,7 @@ SVal BasicStoreManager::getLValueField(const GRState *state, SVal Base,
case loc::MemRegionKind:
BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
break;
-
+
case loc::ConcreteIntKind:
// While these seem funny, this can happen through casts.
// FIXME: What we should return is the field offset. For example,
@@ -186,7 +186,7 @@ SVal BasicStoreManager::getLValueField(const GRState *state, SVal Base,
assert ("Unhandled Base.");
return Base;
}
-
+
return ValMgr.makeLoc(MRMgr.getFieldRegion(D, BaseR));
}
@@ -196,18 +196,18 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
if (Base.isUnknownOrUndef())
return Base;
-
- Loc BaseL = cast<Loc>(Base);
+
+ Loc BaseL = cast<Loc>(Base);
const MemRegion* BaseR = 0;
-
+
switch(BaseL.getSubKind()) {
case loc::GotoLabelKind:
// Technically we can get here if people do funny things with casts.
return UndefinedVal();
-
+
case loc::MemRegionKind: {
const MemRegion *R = cast<loc::MemRegionVal>(BaseL).getRegion();
-
+
if (isa<ElementRegion>(R)) {
// int x;
// char* y = (char*) &x;
@@ -215,12 +215,12 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
// y[0] = 'a';
return Base;
}
-
+
if (isa<TypedRegion>(R) || isa<SymbolicRegion>(R)) {
BaseR = R;
break;
}
-
+
break;
}
@@ -230,13 +230,13 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
// add the field offset to the integer value. That way funny things
// like this work properly: &(((struct foo *) 0xa)->f)
return Base;
-
+
default:
assert ("Unhandled Base.");
return Base;
}
-
- if (BaseR) {
+
+ if (BaseR) {
return ValMgr.makeLoc(MRMgr.getElementRegion(elementType, UnknownVal(),
BaseR, getContext()));
}
@@ -246,38 +246,38 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
static bool isHigherOrderRawPtr(QualType T, ASTContext &C) {
bool foundPointer = false;
- while (1) {
+ while (1) {
const PointerType *PT = T->getAs<PointerType>();
if (!PT) {
if (!foundPointer)
return false;
-
+
// intptr_t* or intptr_t**, etc?
if (T->isIntegerType() && C.getTypeSize(T) == C.getTypeSize(C.VoidPtrTy))
return true;
-
+
QualType X = C.getCanonicalType(T).getUnqualifiedType();
return X == C.VoidTy;
}
-
+
foundPointer = true;
T = PT->getPointeeType();
- }
+ }
}
-
+
SValuator::CastResult BasicStoreManager::Retrieve(const GRState *state,
Loc loc, QualType T) {
-
+
if (isa<UnknownVal>(loc))
return SValuator::CastResult(state, UnknownVal());
-
+
assert(!isa<UndefinedVal>(loc));
-
+
switch (loc.getSubKind()) {
case loc::MemRegionKind: {
const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
-
+
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
// Just support void**, void***, intptr_t*, intptr_t**, etc., for now.
// This is needed to handle OSCompareAndSwapPtr() and friends.
@@ -286,45 +286,45 @@ SValuator::CastResult BasicStoreManager::Retrieve(const GRState *state,
if (!isHigherOrderRawPtr(T, Ctx))
return SValuator::CastResult(state, UnknownVal());
-
+
// FIXME: Should check for element 0.
// Otherwise, strip the element region.
R = ER->getSuperRegion();
}
-
+
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
return SValuator::CastResult(state, UnknownVal());
-
+
BindingsTy B = GetBindings(state->getStore());
BindingsTy::data_type *Val = B.lookup(R);
-
+
if (!Val)
break;
-
+
return CastRetrievedVal(*Val, state, cast<TypedRegion>(R), T);
}
-
+
case loc::ConcreteIntKind:
// Some clients may call GetSVal with such an option simply because
// they are doing a quick scan through their Locs (potentially to
// invalidate their bindings). Just return Undefined.
return SValuator::CastResult(state, UndefinedVal());
-
+
default:
assert (false && "Invalid Loc.");
break;
}
-
+
return SValuator::CastResult(state, UnknownVal());
}
-
-Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
+
+Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
if (isa<loc::ConcreteInt>(loc))
return store;
const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
ASTContext &C = StateMgr.getContext();
-
+
// Special case: handle store of pointer values (Loc) to pointers via
// a cast to intXX_t*, void*, etc. This is needed to handle
// OSCompareAndSwap32Barrier/OSCompareAndSwap64Barrier.
@@ -332,20 +332,20 @@ Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
// FIXME: Should check for index 0.
QualType T = ER->getLocationType(C);
-
+
if (isHigherOrderRawPtr(T, C))
R = ER->getSuperRegion();
- }
-
+ }
+
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
return store;
const TypedRegion *TyR = cast<TypedRegion>(R);
-
+
// Do not bind to arrays. We need to explicitly check for this so that
// we do not encounter any weirdness of trying to load/store from arrays.
if (TyR->isBoundable() && TyR->getValueType(C)->isArrayType())
- return store;
+ return store;
if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(&V)) {
// Only convert 'V' to a location iff the underlying region type
@@ -354,7 +354,7 @@ Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
// a pointer. We may wish to flag a type error here if the types
// are incompatible. This may also cause lots of breakage
// elsewhere. Food for thought.
- if (TyR->isBoundable() && Loc::IsLocType(TyR->getValueType(C)))
+ if (TyR->isBoundable() && Loc::IsLocType(TyR->getValueType(C)))
V = X->getLoc();
}
@@ -368,10 +368,10 @@ Store BasicStoreManager::Remove(Store store, Loc loc) {
switch (loc.getSubKind()) {
case loc::MemRegionKind: {
const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
-
+
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
return store;
-
+
return VBFactory.Remove(GetBindings(store), R).getRoot();
}
default:
@@ -384,11 +384,11 @@ void
BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
-{
+{
Store store = state.getStore();
BindingsTy B = GetBindings(store);
typedef SVal::symbol_iterator symbol_iterator;
-
+
// Iterate over the variable bindings.
for (BindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I) {
if (const VarRegion *VR = dyn_cast<VarRegion>(I.getKey())) {
@@ -402,20 +402,20 @@ BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
}
else
continue;
-
+
// Mark the bindings in the data as live.
SVal X = I.getData();
for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
SymReaper.markLive(*SI);
}
-
+
// Scan for live variables and live symbols.
llvm::SmallPtrSet<const MemRegion*, 10> Marked;
-
+
while (!RegionRoots.empty()) {
const MemRegion* MR = RegionRoots.back();
RegionRoots.pop_back();
-
+
while (MR) {
if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(MR)) {
SymReaper.markLive(SymR->getSymbol());
@@ -424,17 +424,17 @@ BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
else if (isa<VarRegion>(MR) || isa<ObjCIvarRegion>(MR)) {
if (Marked.count(MR))
break;
-
- Marked.insert(MR);
+
+ Marked.insert(MR);
SVal X = Retrieve(&state, loc::MemRegionVal(MR)).getSVal();
-
+
// FIXME: We need to handle symbols nested in region definitions.
for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI)
SymReaper.markLive(*SI);
-
+
if (!isa<loc::MemRegionVal>(X))
break;
-
+
const loc::MemRegionVal& LVD = cast<loc::MemRegionVal>(X);
RegionRoots.push_back(LVD.getRegion());
break;
@@ -445,15 +445,15 @@ BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
break;
}
}
-
- // Remove dead variable bindings.
+
+ // Remove dead variable bindings.
for (BindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I) {
const MemRegion* R = I.getKey();
-
+
if (!Marked.count(R)) {
store = Remove(store, ValMgr.makeLoc(R));
SVal X = I.getData();
-
+
for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
SymReaper.maybeDead(*SI);
}
@@ -467,10 +467,10 @@ Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl,
const MemRegion *SelfRegion, Store St) {
for (Stmt::child_iterator CI=B->child_begin(), CE=B->child_end();
CI != CE; ++CI) {
-
+
if (!*CI)
continue;
-
+
// Check if the statement is an ivar reference. We only
// care about self.ivar.
if (ObjCIvarRefExpr *IV = dyn_cast<ObjCIvarRefExpr>(*CI)) {
@@ -478,8 +478,8 @@ Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl,
if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Base)) {
if (DR->getDecl() == SelfDecl) {
const MemRegion *IVR = MRMgr.getObjCIvarRegion(IV->getDecl(),
- SelfRegion);
- SVal X = ValMgr.getRegionValueSymbolVal(IVR);
+ SelfRegion);
+ SVal X = ValMgr.getRegionValueSymbolVal(IVR);
St = BindInternal(St, ValMgr.makeLoc(IVR), X);
}
}
@@ -487,11 +487,11 @@ Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl,
else
St = scanForIvars(*CI, SelfDecl, SelfRegion, St);
}
-
+
return St;
}
-Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
+Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
// The LiveVariables information already has a compilation of all VarDecls
// used in the function. Iterate through this set, and "symbolicate"
// any VarDecl whose value originally comes from outside the function.
@@ -504,7 +504,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
// Handle implicit parameters.
if (ImplicitParamDecl* PD = dyn_cast<ImplicitParamDecl>(ND)) {
- const Decl& CD = *InitLoc->getDecl();
+ const Decl& CD = *InitLoc->getDecl();
if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(&CD)) {
if (MD->getSelfDecl() == PD) {
// FIXME: Just use a symbolic region, and remove ObjCObjectRegion
@@ -512,10 +512,10 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
const ObjCObjectRegion *SelfRegion =
MRMgr.getObjCObjectRegion(MD->getClassInterface(),
MRMgr.getHeapRegion());
-
+
St = BindInternal(St, ValMgr.makeLoc(MRMgr.getVarRegion(PD, InitLoc)),
ValMgr.makeLoc(SelfRegion));
-
+
// Scan the method for ivar references. While this requires an
// entire AST scan, the cost should not be high in practice.
St = scanForIvars(MD->getBody(), PD, SelfRegion, St);
@@ -543,9 +543,9 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD,
const LocationContext *LC,
SVal* InitVal) {
-
+
BasicValueFactory& BasicVals = StateMgr.getBasicVals();
-
+
// BasicStore does not model arrays and structs.
if (VD->getType()->isArrayType() || VD->getType()->isStructureType())
return store;
@@ -560,14 +560,14 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD,
// Static global variables should not be visited here.
assert(!(VD->getStorageClass() == VarDecl::Static &&
VD->isFileVarDecl()));
-
+
// Process static variables.
if (VD->getStorageClass() == VarDecl::Static) {
// C99: 6.7.8 Initialization
// If an object that has static storage duration is not initialized
- // explicitly, then:
- // —if it has pointer type, it is initialized to a null pointer;
- // —if it has arithmetic type, it is initialized to (positive or
+ // explicitly, then:
+ // —if it has pointer type, it is initialized to a null pointer;
+ // —if it has arithmetic type, it is initialized to (positive or
// unsigned) zero;
if (!InitVal) {
QualType T = VD->getType();
@@ -598,18 +598,18 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD,
void BasicStoreManager::print(Store store, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
-
+
BindingsTy B = GetBindings(store);
Out << "Variables:" << nl;
-
+
bool isFirst = true;
-
+
for (BindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I) {
if (isFirst)
isFirst = false;
else
Out << nl;
-
+
Out << ' ' << I.getKey() << " : " << I.getData();
}
}
@@ -617,7 +617,7 @@ void BasicStoreManager::print(Store store, llvm::raw_ostream& Out,
void BasicStoreManager::iterBindings(Store store, BindingsHandler& f) {
BindingsTy B = GetBindings(store);
-
+
for (BindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I)
f.HandleBinding(*this, store, I.getKey(), I.getData());
@@ -634,10 +634,10 @@ const GRState *BasicStoreManager::InvalidateRegion(const GRState *state,
const Expr *E,
unsigned Count) {
R = R->getBaseRegion();
-
+
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
return state;
-
+
QualType T = cast<TypedRegion>(R)->getValueType(R->getContext());
SVal V = ValMgr.getConjuredSymbolVal(E, T, Count);
return Bind(state, loc::MemRegionVal(R), V);
diff --git a/lib/Analysis/BasicValueFactory.cpp b/lib/Analysis/BasicValueFactory.cpp
index 5ed6d22769..b33c277f86 100644
--- a/lib/Analysis/BasicValueFactory.cpp
+++ b/lib/Analysis/BasicValueFactory.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
//
// This file defines BasicValueFactory, a class that manages the lifetime
-// of APSInt objects and symbolic constraints used by GRExprEngine
+// of APSInt objects and symbolic constraints used by GRExprEngine
// and related classes.
//
//===----------------------------------------------------------------------===//
@@ -17,7 +17,7 @@
using namespace clang;
-void CompoundValData::Profile(llvm::FoldingSetNodeID& ID, QualType T,
+void CompoundValData::Profile(llvm::FoldingSetNodeID& ID, QualType T,
llvm::ImmutableList<SVal> L) {
T.Profile(ID);
ID.AddPointer(L.getInternalPointer());
@@ -40,7 +40,7 @@ template<> struct FoldingSetTrait<SValData> {
ID.AddPointer( (void*) X.second);
}
};
-
+
template<> struct FoldingSetTrait<SValPair> {
static inline void Profile(const SValPair& X, llvm::FoldingSetNodeID& ID) {
X.first.Profile(ID);
@@ -61,8 +61,8 @@ BasicValueFactory::~BasicValueFactory() {
// frees an aux. memory allocated to represent very large constants.
for (APSIntSetTy::iterator I=APSIntSet.begin(), E=APSIntSet.end(); I!=E; ++I)
I->getValue().~APSInt();
-
- delete (PersistentSValsTy*) PersistentSVals;
+
+ delete (PersistentSValsTy*) PersistentSVals;
delete (PersistentSValPairsTy*) PersistentSValPairs;
}
@@ -70,16 +70,16 @@ const llvm::APSInt& BasicValueFactory::getValue(const llvm::APSInt& X) {
llvm::FoldingSetNodeID ID;
void* InsertPos;
typedef llvm::FoldingSetNodeWrapper<llvm::APSInt> FoldNodeTy;
-
+
X.Profile(ID);
FoldNodeTy* P = APSIntSet.FindNodeOrInsertPos(ID, InsertPos);
-
- if (!P) {
+
+ if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(X);
APSIntSet.InsertNode(P, InsertPos);
}
-
+
return *P;
}
@@ -92,22 +92,22 @@ const llvm::APSInt& BasicValueFactory::getValue(const llvm::APInt& X,
const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, unsigned BitWidth,
bool isUnsigned) {
llvm::APSInt V(BitWidth, isUnsigned);
- V = X;
+ V = X;
return getValue(V);
}
const llvm::APSInt& BasicValueFactory::getValue(uint64_t X, QualType T) {
-
+
unsigned bits = Ctx.getTypeSize(T);
llvm::APSInt V(bits, T->isUnsignedIntegerType() || Loc::IsLocType(T));
V = X;
return getValue(V);
}
-const CompoundValData*
+const CompoundValData*
BasicValueFactory::getCompoundValData(QualType T,
llvm::ImmutableList<SVal> Vals) {
-
+
llvm::FoldingSetNodeID ID;
CompoundValData::Profile(ID, T, Vals);
void* InsertPos;
@@ -129,104 +129,104 @@ BasicValueFactory::getLazyCompoundValData(const GRState *state,
llvm::FoldingSetNodeID ID;
LazyCompoundValData::Profile(ID, state, region);
void* InsertPos;
-
+
LazyCompoundValData *D =
LazyCompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos);
-
+
if (!D) {
D = (LazyCompoundValData*) BPAlloc.Allocate<LazyCompoundValData>();
new (D) LazyCompoundValData(state, region);
LazyCompoundValDataSet.InsertNode(D, InsertPos);
}
-
+
return D;
}
const llvm::APSInt*
BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op,
const llvm::APSInt& V1, const llvm::APSInt& V2) {
-
+
switch (Op) {
default:
assert (false && "Invalid Opcode.");
-
+
case BinaryOperator::Mul:
return &getValue( V1 * V2 );
-
+
case BinaryOperator::Div:
return &getValue( V1 / V2 );
-
+
case BinaryOperator::Rem:
return &getValue( V1 % V2 );
-
+
case BinaryOperator::Add:
return &getValue( V1 + V2 );
-
+
case BinaryOperator::Sub:
return &getValue( V1 - V2 );
-
+
case BinaryOperator::Shl: {
// FIXME: This logic should probably go higher up, where we can
// test these conditions symbolically.
-
+
// FIXME: Expand these checks to include all undefined behavior.
-
+
if (V2.isSigned() && V2.isNegative())
return NULL;
-
+
uint64_t Amt = V2.getZExtValue();
-
+
if (Amt > V1.getBitWidth())
return NULL;
-
+
return &getValue( V1.operator<<( (unsigned) Amt ));
}
-
+
case BinaryOperator::Shr: {
-
+
// FIXME: This logic should probably go higher up, where we can
// test these conditions symbolically.
-
+
// FIXME: Expand these checks to include all undefined behavior.
-
+
if (V2.isSigned() && V2.isNegative())
return NULL;
-
+
uint64_t Amt = V2.getZExtValue();
-
+
if (Amt > V1.getBitWidth())
return NULL;
-
+
return &getValue( V1.operator>>( (unsigned) Amt ));
}
-
+
case BinaryOperator::LT:
return &getTruthValue( V1 < V2 );
-
+
case BinaryOperator::GT:
return &getTruthValue( V1 > V2 );
-
+
case BinaryOperator::LE:
return &getTruthValue( V1 <= V2 );
-
+
case BinaryOperator::GE:
return &getTruthValue( V1 >= V2 );
-
+
case BinaryOperator::EQ:
return &getTruthValue( V1 == V2 );
-
+
case BinaryOperator::NE:
return &getTruthValue( V1 != V2 );
-
+
// Note: LAnd, LOr, Comma are handled specially by higher-level logic.
-
+
case BinaryOperator::And:
return &getValue( V1 & V2 );
-
+
case BinaryOperator::Or:
return &getValue( V1 | V2 );
-
+
case BinaryOperator::Xor:
return &getValue( V1 ^ V2 );
}
@@ -235,21 +235,21 @@ BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op,
const std::pair<SVal, uintptr_t>&
BasicValueFactory::getPersistentSValWithData(const SVal& V, uintptr_t Data) {
-
+
// Lazily create the folding set.
if (!PersistentSVals) PersistentSVals = new PersistentSValsTy();
-
+
llvm::FoldingSetNodeID ID;
void* InsertPos;
V.Profile(ID);
ID.AddPointer((void*) Data);
-
+
PersistentSValsTy& Map = *((PersistentSValsTy*) PersistentSVals);
-
+
typedef llvm::FoldingSetNodeWrapper<SValData> FoldNodeTy;
FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
-
- if (!P) {
+
+ if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(std::make_pair(V, Data));
Map.InsertNode(P, InsertPos);
@@ -260,31 +260,31 @@ BasicValueFactory::getPersistentSValWithData(const SVal& V, uintptr_t Data) {
const std::pair<SVal, SVal>&
BasicValueFactory::getPersistentSValPair(const SVal& V1, const SVal& V2) {
-
+
// Lazily create the folding set.
if (!PersistentSValPairs) PersistentSValPairs = new PersistentSValPairsTy();
-
+
llvm::FoldingSetNodeID ID;
void* InsertPos;
V1.Profile(ID);
V2.Profile(ID);
-
+
PersistentSValPairsTy& Map = *((PersistentSValPairsTy*) PersistentSValPairs);
-
+
typedef llvm::FoldingSetNodeWrapper<SValPair> FoldNodeTy;
FoldNodeTy* P = Map.FindNodeOrInsertPos(ID, InsertPos);
-
- if (!P) {
+
+ if (!P) {
P = (FoldNodeTy*) BPAlloc.Allocate<FoldNodeTy>();
new (P) FoldNodeTy(std::make_pair(V1, V2));
Map.InsertNode(P, InsertPos);
}
-
+
return P->getValue();
}
const SVal* BasicValueFactory::getPersistentSVal(SVal X) {
return &getPersistentSValWithData(X, 0).first;
-}
+}
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index e54a50078e..23ca53d6e9 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -53,7 +53,7 @@ static inline const Stmt* GetStmt(ProgramPoint P) {
return SP->getStmt();
else if (const BlockEdge* BE = dyn_cast<BlockEdge>(&P))
return BE->getSrc()->getTerminator();
-
+
return 0;
}
@@ -71,7 +71,7 @@ static const Stmt* GetPreviousStmt(const ExplodedNode* N) {
for (N = GetPredecessorNode(N); N; N = GetPredecessorNode(N))
if (const Stmt *S = GetStmt(N->getLocation()))
return S;
-
+
return 0;
}
@@ -92,30 +92,30 @@ static const Stmt* GetNextStmt(const ExplodedNode* N) {
default:
break;
}
-
+
// Some expressions don't have locations.
if (S->getLocStart().isInvalid())
continue;
-
+
return S;
}
-
+
return 0;
}
static inline const Stmt*
-GetCurrentOrPreviousStmt(const ExplodedNode* N) {
+GetCurrentOrPreviousStmt(const ExplodedNode* N) {
if (const Stmt *S = GetStmt(N->getLocation()))
return S;
-
+
return GetPreviousStmt(N);
}
-
+
static inline const Stmt*
-GetCurrentOrNextStmt(const ExplodedNode* N) {
+GetCurrentOrNextStmt(const ExplodedNode* N) {
if (const Stmt *S = GetStmt(N->getLocation()))
return S;
-
+
return GetNextStmt(N);
}
@@ -132,63 +132,62 @@ class VISIBILITY_HIDDEN NodeMapClosure : public BugReport::NodeResolver {
public:
NodeMapClosure(NodeBackMap *m) : M(*m) {}
~NodeMapClosure() {}
-
+
const ExplodedNode* getOriginalNode(const ExplodedNode* N) {
NodeBackMap::iterator I = M.find(N);
return I == M.end() ? 0 : I->second;
}
};
-
+
class VISIBILITY_HIDDEN PathDiagnosticBuilder : public BugReporterContext {
BugReport *R;
PathDiagnosticClient *PDC;
llvm::OwningPtr<ParentMap> PM;
NodeMapClosure NMC;
-public:
+public:
PathDiagnosticBuilder(GRBugReporter &br,
- BugReport *r, NodeBackMap *Backmap,
+ BugReport *r, NodeBackMap *Backmap,
PathDiagnosticClient *pdc)
: BugReporterContext(br),
- R(r), PDC(pdc), NMC(Backmap)
- {
+ R(r), PDC(pdc), NMC(Backmap) {
addVisitor(R);
}
-
+
PathDiagnosticLocation ExecutionContinues(const ExplodedNode* N);
-
+
PathDiagnosticLocation ExecutionContinues(llvm::raw_string_ostream& os,
const ExplodedNode* N);
-
+
ParentMap& getParentMap() {
if (PM.get() == 0)
PM.reset(new ParentMap(getCodeDecl().getBody()));
return *PM.get();
}
-
+
const Stmt *getParent(const Stmt *S) {
return getParentMap().getParent(S);
}
-
+
virtual NodeMapClosure& getNodeResolver() { return NMC; }
BugReport& getReport() { return *R; }
PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S);
-
+
PathDiagnosticLocation
getEnclosingStmtLocation(const PathDiagnosticLocation &L) {
if (const Stmt *S = L.asStmt())
return getEnclosingStmtLocation(S);
-
+
return L;
}
-
+
PathDiagnosticClient::PathGenerationScheme getGenerationScheme() const {
return PDC ? PDC->getGenerationScheme() : PathDiagnosticClient::Extensive;
}
bool supportsLogicalOpControlFlow() const {
return PDC ? PDC->supportsLogicalOpControlFlow() : true;
- }
+ }
};
} // end anonymous namespace
@@ -197,10 +196,10 @@ PathDiagnosticBuilder::ExecutionContinues(const ExplodedNode* N) {
if (const Stmt *S = GetNextStmt(N))
return PathDiagnosticLocation(S, getSourceManager());
- return FullSourceLoc(N->getLocationContext()->getDecl()->getBodyRBrace(),
+ return FullSourceLoc(N->getLocationContext()->getDecl()->getBodyRBrace(),
getSourceManager());
}
-
+
PathDiagnosticLocation
PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os,
const ExplodedNode* N) {
@@ -208,9 +207,9 @@ PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os,
// Slow, but probably doesn't matter.
if (os.str().empty())
os << ' ';
-
+
const PathDiagnosticLocation &Loc = ExecutionContinues(N);
-
+
if (Loc.asStmt())
os << "Execution continues on line "
<< getSourceManager().getInstantiationLineNumber(Loc.asLocation())
@@ -219,16 +218,16 @@ PathDiagnosticBuilder::ExecutionContinues(llvm::raw_string_ostream& os,
os << "Execution jumps to the end of the "
<< (isa<ObjCMethodDecl>(N->getLocationContext()->getDecl()) ?
"method" : "function") << '.';
-
+
return Loc;
}
static bool IsNested(const Stmt *S, ParentMap &PM) {
if (isa<Expr>(S) && PM.isConsumedExpr(cast<Expr>(S)))
return true;
-
+
const Stmt *Parent = PM.getParentIgnoreParens(S);
-
+
if (Parent)
switch (Parent->getStmtClass()) {
case Stmt::ForStmtClass:
@@ -238,29 +237,29 @@ static bool IsNested(const Stmt *S, ParentMap &PM) {
default:
break;
}
-
- return false;
+
+ return false;
}
PathDiagnosticLocation
PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
assert(S && "Null Stmt* passed to getEnclosingStmtLocation");
- ParentMap &P = getParentMap();
+ ParentMap &P = getParentMap();
SourceManager &SMgr = getSourceManager();
while (IsNested(S, P)) {
const Stmt *Parent = P.getParentIgnoreParens(S);
-
+
if (!Parent)
break;
-
+
switch (Parent->getStmtClass()) {
case Stmt::BinaryOperatorClass: {
const BinaryOperator *B = cast<BinaryOperator>(Parent);
if (B->isLogicalOp())
return PathDiagnosticLocation(S, SMgr);
break;
- }
+ }
case Stmt::CompoundStmtClass:
case Stmt::StmtExprClass:
return PathDiagnosticLocation(S, SMgr);
@@ -270,20 +269,20 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
if (cast<ChooseExpr>(Parent)->getCond() == S)
return PathDiagnosticLocation(Parent, SMgr);
else
- return PathDiagnosticLocation(S, SMgr);
+ return PathDiagnosticLocation(S, SMgr);
case Stmt::ConditionalOperatorClass:
// For '?', if we are referring to condition, just have the edge point
// to the entire '?' expression.
if (cast<ConditionalOperator>(Parent)->getCond() == S)
return PathDiagnosticLocation(Parent, SMgr);
else
- return PathDiagnosticLocation(S, SMgr);
+ return PathDiagnosticLocation(S, SMgr);
case Stmt::DoStmtClass:
- return PathDiagnosticLocation(S, SMgr);
+ return PathDiagnosticLocation(S, SMgr);
case Stmt::ForStmtClass:
if (cast<ForStmt>(Parent)->getBody() == S)
- return PathDiagnosticLocation(S, SMgr);
- break;
+ return PathDiagnosticLocation(S, SMgr);
+ break;
case Stmt::IfStmtClass:
if (cast<IfStmt>(Parent)->getCond() != S)
return PathDiagnosticLocation(S, SMgr);
@@ -302,7 +301,7 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
S = Parent;
}
-
+
assert(S && "Cannot have null Stmt for PathDiagnosticLocation");
// Special case: DeclStmts can appear in for statement declarations, in which
@@ -315,8 +314,8 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
return PathDiagnosticLocation(Parent, SMgr);
default:
break;
- }
- }
+ }
+ }
}
else if (isa<BinaryOperator>(S)) {
// Special case: the binary operator represents the initialization
@@ -339,84 +338,84 @@ PathDiagnosticBuilder::getEnclosingStmtLocation(const Stmt *S) {
static const VarDecl*
GetMostRecentVarDeclBinding(const ExplodedNode* N,
GRStateManager& VMgr, SVal X) {
-
+
for ( ; N ; N = N->pred_empty() ? 0 : *N->pred_begin()) {
-
+
ProgramPoint P = N->getLocation();
-
+
if (!isa<PostStmt>(P))
continue;
-
+
const DeclRefExpr* DR = dyn_cast<DeclRefExpr>(cast<PostStmt>(P).getStmt());
-
+
if (!DR)
continue;
-
+
SVal Y = N->getState()->getSVal(DR);
-
+
if (X != Y)
continue;
-
+
const VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl());
-
+
if (!VD)
continue;
-
+
return VD;
}
-
+
return 0;
}
namespace {
-class VISIBILITY_HIDDEN NotableSymbolHandler
+class VISIBILITY_HIDDEN NotableSymbolHandler
: public StoreManager::BindingsHandler {
-
+
SymbolRef Sym;
const GRState* PrevSt;
const Stmt* S;
GRStateManager& VMgr;
const ExplodedNode* Pred;
- PathDiagnostic& PD;
+ PathDiagnostic& PD;
BugReporter& BR;
-
+
public:
-
+
NotableSymbolHandler(SymbolRef sym, const GRState* prevst, const Stmt* s,
GRStateManager& vmgr, const ExplodedNode* pred,
PathDiagnostic& pd, BugReporter& br)
: Sym(sym), PrevSt(prevst), S(s), VMgr(vmgr), Pred(pred), PD(pd), BR(br) {}
-
+
bool HandleBinding(StoreManager& SMgr, Store store, const MemRegion* R,
SVal V) {
-
+
SymbolRef ScanSym = V.getAsSymbol();
-
+
if (ScanSym != Sym)
return true;
-
- // Check if the previous state has this binding.
+
+ // Check if the previous state has this binding.
SVal X = PrevSt->getSVal(loc::MemRegionVal(R));
-
+
if (X == V) // Same binding?
return true;
-
+
// Different binding. Only handle assignments for now. We don't pull
- // this check out of the loop because we will eventually handle other
+ // this check out of the loop because we will eventually handle other
// cases.
-
+
VarDecl *VD = 0;
-
+
if (const BinaryOperator* B = dyn_cast<BinaryOperator>(S)) {
if (!B->isAssignmentOp())
return true;
-
+
// What variable did we assign to?
DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParenCasts());
-
+
if (!DR)
return true;
-
+
VD = dyn_cast<VarDecl>(DR->getDecl());
}
else if (const DeclStmt* DS = dyn_cast<DeclStmt>(S)) {
@@ -425,28 +424,28 @@ public:
// holds by contruction in the CFG.
VD = dyn_cast<VarDecl>(*DS->decl_begin());
}
-
+
if (!VD)
return true;
-
+
// What is the most recently referenced variable with this binding?
const VarDecl* MostRecent = GetMostRecentVarDeclBinding(Pred, VMgr, V);
-
+
if (!MostRecent)
return true;
-
+
// Create the diagnostic.
FullSourceLoc L(S->getLocStart(), BR.getSourceManager());
-
+
if (Loc::IsLocType(VD->getType())) {
std::string msg = "'" + std::string(VD->getNameAsString()) +
"' now aliases '" + MostRecent->getNameAsString() + "'";
-
+
PD.push_front(new PathDiagnosticEventPiece(L, msg));
}
-
+
return true;
- }
+ }
};
}
@@ -454,13 +453,13 @@ static void HandleNotableSymbol(const ExplodedNode* N,
const Stmt* S,
SymbolRef Sym, BugReporter& BR,
PathDiagnostic& PD) {
-
+
const ExplodedNode* Pred = N->pred_empty() ? 0 : *N->pred_begin();
const GRState* PrevSt = Pred ? Pred->getState() : 0;
-
+
if (!PrevSt)
return;
-
+
// Look at the region bindings of the current state that map to the
// specified symbol. Are any of them not in the previous state?
GRStateManager& VMgr = cast<GRBugReporter>(BR).getStateManager();
@@ -471,34 +470,34 @@ static void HandleNotableSymbol(const ExplodedNode* N,
namespace {
class VISIBILITY_HIDDEN ScanNotableSymbols
: public StoreManager::BindingsHandler {
-
+
llvm::SmallSet<SymbolRef, 10> AlreadyProcessed;
const ExplodedNode* N;
const Stmt* S;
GRBugReporter& BR;
PathDiagnostic& PD;
-
+
public:
ScanNotableSymbols(const ExplodedNode* n, const Stmt* s,
GRBugReporter& br, PathDiagnostic& pd)
: N(n), S(s), BR(br), PD(pd) {}
-
+
bool HandleBinding(StoreManager& SMgr, Store store,
const MemRegion* R, SVal V) {
-
+
SymbolRef ScanSym = V.getAsSymbol();
-
+
if (!ScanSym)
return true;
-
+
if (!BR.isNotable(ScanSym))
return true;
-
+
if (AlreadyProcessed.count(ScanSym))
return true;
-
+
AlreadyProcessed.insert(ScanSym);
-
+
HandleNotableSymbol(N, S, ScanSym, BR, PD);
return true;
}
@@ -516,54 +515,54 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
const ExplodedNode *N) {
SourceManager& SMgr = PDB.getSourceManager();
- const ExplodedNode* NextNode = N->pred_empty()
+ const ExplodedNode* NextNode = N->pred_empty()
? NULL : *(N->pred_begin());
while (NextNode) {
- N = NextNode;
+ N = NextNode;
NextNode = GetPredecessorNode(N);
-
+
ProgramPoint P = N->getLocation();
-
+
if (const BlockEdge* BE = dyn_cast<BlockEdge>(&P)) {
CFGBlock* Src = BE->getSrc();
CFGBlock* Dst = BE->getDst();
Stmt* T = Src->getTerminator();
-
+
if (!T)
continue;
-
+
FullSourceLoc Start(T->getLocStart(), SMgr);
-
+
switch (T->getStmtClass()) {
default:
break;
-
+
case Stmt::GotoStmtClass:
- case Stmt::IndirectGotoStmtClass: {
+ case Stmt::IndirectGotoStmtClass: {
const Stmt* S = GetNextStmt(N);
-
+
if (!S)
continue;
-
+
std::string sbuf;
- llvm::raw_string_ostream os(sbuf);
+ llvm::raw_string_ostream os(sbuf);
const PathDiagnosticLocation &End = PDB.getEnclosingStmtLocation(S);
-
+
os << "Control jumps to line "
<< End.asLocation().getInstantiationLineNumber();
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;
}
-
- case Stmt::SwitchStmtClass: {
+
+ case Stmt::SwitchStmtClass: {
// Figure out what case arm we took.
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
if (Stmt* S = Dst->getLabel()) {
PathDiagnosticLocation End(S, SMgr);
-
+
switch (S->getStmtClass()) {
default:
os << "No cases match in the switch statement. "
@@ -574,21 +573,21 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
os << "Control jumps to the 'default' case at line "
<< End.asLocation().getInstantiationLineNumber();
break;
-
+
case Stmt::CaseStmtClass: {
- os << "Control jumps to 'case ";
- CaseStmt* Case = cast<CaseStmt>(S);
+ os << "Control jumps to 'case ";
+ CaseStmt* Case = cast<CaseStmt>(S);
Expr* LHS = Case->getLHS()->IgnoreParenCasts();
-
- // Determine if it is an enum.
+
+ // Determine if it is an enum.
bool GetRawInt = true;
-
+
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS)) {
// FIXME: Maybe this should be an assertion. Are there cases
// were it is not an EnumConstantDecl?
EnumConstantDecl* D =
dyn_cast<EnumConstantDecl>(DR->getDecl());
-
+
if (D) {
GetRawInt = false;
os << D->getNameAsString();
@@ -608,14 +607,14 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
}
else {
os << "'Default' branch taken. ";
- const PathDiagnosticLocation &End = PDB.ExecutionContinues(os, N);
+ const PathDiagnosticLocation &End = PDB.ExecutionContinues(os, N);
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
-
+
break;
}
-
+
case Stmt::BreakStmtClass:
case Stmt::ContinueStmtClass: {
std::string sbuf;
@@ -625,117 +624,117 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
os.str()));
break;
}
-
+
// Determine control-flow for ternary '?'.
case Stmt::ConditionalOperatorClass: {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "'?' condition is ";
-
+
if (*(Src->succ_begin()+1) == Dst)
os << "false";
else
os << "true";
-
+
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
-
+
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
break;
}
-
+
// Determine control-flow for short-circuited '&&' and '||'.
case Stmt::BinaryOperatorClass: {
if (!PDB.supportsLogicalOpControlFlow())
break;
-
+
BinaryOperator *B = cast<BinaryOperator>(T);
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Left side of '";
-
+
if (B->getOpcode() == BinaryOperator::LAnd) {
os << "&&" << "' is ";
-
+
if (*(Src->succ_begin()+1) == Dst) {
os << "false";
PathDiagnosticLocation End(B->getLHS(), SMgr);
PathDiagnosticLocation Start(B->getOperatorLoc(), SMgr);
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
- }
+ }
else {
os << "true";
PathDiagnosticLocation Start(B->getLHS(), SMgr);
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
- }
+ }
}
else {
assert(B->getOpcode() == BinaryOperator::LOr);
os << "||" << "' is ";
-
+
if (*(Src->succ_begin()+1) == Dst) {
os << "false";
PathDiagnosticLocation Start(B->getLHS(), SMgr);
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
- os.str()));
+ os.str()));
}
else {
os << "true";
PathDiagnosticLocation End(B->getLHS(), SMgr);
PathDiagnosticLocation Start(B->getOperatorLoc(), SMgr);
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
- os.str()));
+ os.str()));
}
}
-
+
break;
}
-
- case Stmt::DoStmtClass: {
+
+ case Stmt::DoStmtClass: {
if (*(Src->succ_begin()) == Dst) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "Loop condition is true. ";
PathDiagnosticLocation End = PDB.ExecutionContinues(os, N);
-
+
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
else {
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
-
+
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Loop condition is false. Exiting loop"));
}
-
+
break;
}
-
+
case Stmt::WhileStmtClass:
- case Stmt::ForStmtClass: {
+ case Stmt::ForStmtClass: {
if (*(Src->succ_begin()+1) == Dst) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "Loop condition is false. ";
PathDiagnosticLocation End = PDB.ExecutionContinues(os, N);
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
os.str()));
}
@@ -743,32 +742,32 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Loop condition is true. Entering loop body"));
}
-
+
break;
}
-
+
case Stmt::IfStmtClass: {
PathDiagnosticLocation End = PDB.ExecutionContinues(N);
-
+
if (const Stmt *S = End.asStmt())
End = PDB.getEnclosingStmtLocation(S);
-
+
if (*(Src->succ_begin()+1) == Dst)
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Taking false branch"));
- else
+ else
PD.push_front(new PathDiagnosticControlFlowPiece(Start, End,
"Taking true branch"));
-
+
break;
}
}
}
-
+
if (NextNode) {
for (BugReporterContext::visitor_iterator I = PDB.visitor_begin(),
E = PDB.visitor_end(); I!=E; ++I) {
@@ -776,15 +775,15 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
PD.push_front(p);
}
}
-
- if (const PostStmt* PS = dyn_cast<PostStmt>(&P)) {
+
+ if (const PostStmt* PS = dyn_cast<PostStmt>(&P)) {
// Scan the region bindings, and see if a "notable" symbol has a new
// lval binding.
ScanNotableSymbols SNS(N, PS->getStmt(), PDB.getBugReporter(), PD);
PDB.getStateManager().iterBindings(N->getState(), SNS);
}
}
-
+
// After constructing the full PathDiagnostic, do a pass over it to compact
// PathDiagnosticPieces that occur within a macro.
CompactPathDiagnostic(PD, PDB.getSourceManager());
@@ -796,20 +795,20 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
static bool IsControlFlowExpr(const Stmt *S) {
const Expr *E = dyn_cast<Expr>(S);
-
+
if (!E)
return false;
-
- E = E->IgnoreParenCasts();
-
+
+ E = E->IgnoreParenCasts();
+
if (isa<ConditionalOperator>(E))
return true;
-
+
if (const BinaryOperator *B = dyn_cast<BinaryOperator>(E))
if (B->isLogicalOp())
return true;
-
- return false;
+
+ return false;
}
namespace {
@@ -818,25 +817,25 @@ class VISIBILITY_HIDDEN ContextLocation : public PathDiagnosticLocation {
public:
ContextLocation(const PathDiagnosticLocation &L, bool isdead = false)
: PathDiagnosticLocation(L), IsDead(isdead) {}
-
- void markDead() { IsDead = true; }
+
+ void markDead() { IsDead = true; }
bool isDead() const { return IsDead; }
};
-
+
class VISIBILITY_HIDDEN EdgeBuilder {
std::vector<ContextLocation> CLocs;
typedef std::vector<ContextLocation>::iterator iterator;
PathDiagnostic &PD;
PathDiagnosticBuilder &PDB;
PathDiagnosticLocation PrevLoc;
-
+
bool IsConsumedExpr(const PathDiagnosticLocation &L);
-
+
bool containsLocation(const PathDiagnosticLocation &Container,
const PathDiagnosticLocation &Containee);
-
+
PathDiagnosticLocation getContextLocation(const PathDiagnosticLocation &L);
-
+
PathDiagnosticLocation cleanUpLocation(PathDiagnosticLocation L,
bool firstCharOnly = false) {
if (const Stmt *S = L.asStmt()) {
@@ -864,20 +863,20 @@ class VISIBILITY_HIDDEN EdgeBuilder {
firstCharOnly = true;
continue;
}
-
+
break;
}
-
+
if (S != Original)
L = PathDiagnosticLocation(S, L.getManager());
}
-
+
if (firstCharOnly)
L = PathDiagnosticLocation(L.asLocation());
return L;
}
-
+
void popLocation() {
if (!CLocs.back().isDead() && CLocs.back().asLocation().isFileID()) {
// For contexts, we only one the first character as the range.
@@ -885,18 +884,18 @@ class VISIBILITY_HIDDEN EdgeBuilder {
}
CLocs.pop_back();
}
-
- PathDiagnosticLocation IgnoreParens(const PathDiagnosticLocation &L);
+
+ PathDiagnosticLocation IgnoreParens(const PathDiagnosticLocation &L);
public:
EdgeBuilder(PathDiagnostic &pd, PathDiagnosticBuilder &pdb)
: PD(pd), PDB(pdb) {
-
+
// If the PathDiagnostic already has pieces, add the enclosing statement
// of the first piece as a context as well.
if (!PD.empty()) {
PrevLoc = PD.begin()->getLocation();
-
+
if (const Stmt *S = PrevLoc.asStmt())
addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
@@ -904,7 +903,7 @@ public:
~EdgeBuilder() {
while (!CLocs.empty()) popLocation();
-
+
// Finally, add an initial edge from the start location of the first
// statement (if it doesn't already exist).
// FIXME: Should handle CXXTryStmt if analyser starts supporting C++.
@@ -914,20 +913,20 @@ public:
SourceLocation Loc = (*CS->body_begin())->getLocStart();
rawAddEdge(PathDiagnosticLocation(Loc, PDB.getSourceManager()));
}
-
+
}
void addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd = false);
-
+
void addEdge(const Stmt *S, bool alwaysAdd = false) {
addEdge(PathDiagnosticLocation(S, PDB.getSourceManager()), alwaysAdd);
}
-
+
void rawAddEdge(PathDiagnosticLocation NewLoc);
-
+
void addContext(const Stmt *S);
void addExtendedContext(const Stmt *S);
-};
+};
} // end anonymous namespace
@@ -936,10 +935,10 @@ EdgeBuilder::getContextLocation(const PathDiagnosticLocation &L) {
if (const Stmt *S = L.asStmt()) {
if (IsControlFlowExpr(S))
return L;
-
- return PDB.getEnclosingStmtLocation(S);
+
+ return PDB.getEnclosingStmtLocation(S);
}
-
+
return L;
}
@@ -948,10 +947,10 @@ bool EdgeBuilder::containsLocation(const PathDiagnosticLocation &Container,
if (Container == Containee)
return true;
-
+
if (Container.asDecl())
return true;
-
+
if (const Stmt *S = Containee.asStmt())
if (const Stmt *ContainerS = Container.asStmt()) {
while (S) {
@@ -965,25 +964,25 @@ bool EdgeBuilder::containsLocation(const PathDiagnosticLocation &Container,
// Less accurate: compare using source ranges.
SourceRange ContainerR = Container.asRange();
SourceRange ContaineeR = Containee.asRange();
-
+
SourceManager &SM = PDB.getSourceManager();
SourceLocation ContainerRBeg = SM.getInstantiationLoc(ContainerR.getBegin());
SourceLocation ContainerREnd = SM.getInstantiationLoc(ContainerR.getEnd());
SourceLocation ContaineeRBeg = SM.getInstantiationLoc(ContaineeR.getBegin());
SourceLocation ContaineeREnd = SM.getInstantiationLoc(ContaineeR.getEnd());
-
+
unsigned ContainerBegLine = SM.getInstantiationLineNumber(ContainerRBeg);
unsigned ContainerEndLine = SM.getInstantiationLineNumber(ContainerREnd);
unsigned ContaineeBegLine = SM.getInstantiationLineNumber(ContaineeRBeg);
unsigned ContaineeEndLine = SM.getInstantiationLineNumber(ContaineeREnd);
-
+
assert(ContainerBegLine <= ContainerEndLine);
- assert(ContaineeBegLine <= ContaineeEndLine);
-
+ assert(ContaineeBegLine <= ContaineeEndLine);
+
return (ContainerBegLine <= ContaineeBegLine &&
ContainerEndLine >= ContaineeEndLine &&
(ContainerBegLine != ContaineeBegLine ||
- SM.getInstantiationColumnNumber(ContainerRBeg) <=
+ SM.getInstantiationColumnNumber(ContainerRBeg) <=
SM.getInstantiationColumnNumber(ContaineeRBeg)) &&
(ContainerEndLine != ContaineeEndLine ||
SM.getInstantiationColumnNumber(ContainerREnd) >=
@@ -1003,13 +1002,13 @@ void EdgeBuilder::rawAddEdge(PathDiagnosticLocation NewLoc) {
PrevLoc = NewLoc;
return;
}
-
+
const PathDiagnosticLocation &NewLocClean = cleanUpLocation(NewLoc);
const PathDiagnosticLocation &PrevLocClean = cleanUpLocation(PrevLoc);
-
+
if (NewLocClean.asLocation() == PrevLocClean.asLocation())
return;
-
+
// FIXME: Ignore intra-macro edges for now.
if (NewLocClean.asLocation().getInstantiationLoc() ==
PrevLocClean.asLocation().getInstantiationLoc())
@@ -1020,15 +1019,15 @@ void EdgeBuilder::rawAddEdge(PathDiagnosticLocation NewLoc) {
}
void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) {
-
+
if (!alwaysAdd && NewLoc.asLocation().isMacroID())
return;
-
+
const PathDiagnosticLocation &CLoc = getContextLocation(NewLoc);
while (!CLocs.empty()) {
ContextLocation &TopContextLoc = CLocs.back();
-
+
// Is the top location context the same as the one for the new location?
if (TopContextLoc == CLoc) {
if (alwaysAdd) {
@@ -1045,21 +1044,21 @@ void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) {
if (containsLocation(TopContextLoc, CLoc)) {
if (alwaysAdd) {
rawAddEdge(NewLoc);
-
+
if (IsConsumedExpr(CLoc) && !IsControlFlowExpr(CLoc.asStmt())) {
CLocs.push_back(ContextLocation(CLoc, true));
return;
}
}
-
+
CLocs.push_back(CLoc);
- return;
+ return;
}
// Context does not contain the location. Flush it.
popLocation();
}
-
+
// If we reach here, there is no enclosing context. Just add the edge.
rawAddEdge(NewLoc);
}
@@ -1067,15 +1066,15 @@ void EdgeBuilder::addEdge(PathDiagnosticLocation NewLoc, bool alwaysAdd) {
bool EdgeBuilder::IsConsumedExpr(const PathDiagnosticLocation &L) {
if (const Expr *X = dyn_cast_or_null<Expr>(L.asStmt()))
return PDB.getParentMap().isConsumedExpr(X) && !IsControlFlowExpr(X);
-
+
return false;
}
-
+
void EdgeBuilder::addExtendedContext(const Stmt *S) {
if (!S)
return;
-
- const Stmt *Parent = PDB.getParent(S);
+
+ const Stmt *Parent = PDB.getParent(S);
while (Parent) {
if (isa<CompoundStmt>(Parent))
Parent = PDB.getParent(Parent);
@@ -1092,16 +1091,16 @@ void EdgeBuilder::addExtendedContext(const Stmt *S) {
break;
}
}
-
+
addContext(S);
}
-
+
void EdgeBuilder::addContext(const Stmt *S) {
if (!S)
return;
PathDiagnosticLocation L(S, PDB.getSourceManager());
-
+
while (!CLocs.empty()) {
const PathDiagnosticLocation &TopContextLoc = CLocs.back();
@@ -1111,7 +1110,7 @@ void EdgeBuilder::addContext(const Stmt *S) {
if (containsLocation(TopContextLoc, L)) {
CLocs.push_back(L);
- return;
+ return;
}
// Context does not contain the location. Flush it.
@@ -1124,11 +1123,11 @@ void EdgeBuilder::addContext(const Stmt *S) {
static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
PathDiagnosticBuilder &PDB,
const ExplodedNode *N) {
-
-
+
+
EdgeBuilder EB(PD, PDB);
- const ExplodedNode* NextNode = N->pred_empty()
+ const ExplodedNode* NextNode = N->pred_empty()
? NULL : *(N->pred_begin());
while (NextNode) {
N = NextNode;
@@ -1140,26 +1139,26 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
const CFGBlock &Blk = *BE->getSrc();
const Stmt *Term = Blk.getTerminator();
-
+
// Are we jumping to the head of a loop? Add a special diagnostic.
if (const Stmt *Loop = BE->getDst()->getLoopTarget()) {
PathDiagnosticLocation L(Loop, PDB.getSourceManager());
const CompoundStmt *CS = NULL;
-
+
if (!Term) {
if (const ForStmt *FS = dyn_cast<ForStmt>(Loop))
CS = dyn_cast<CompoundStmt>(FS->getBody());
else if (const WhileStmt *WS = dyn_cast<WhileStmt>(Loop))
- CS = dyn_cast<CompoundStmt>(WS->getBody());
+ CS = dyn_cast<CompoundStmt>(WS->getBody());
}
-
+
PathDiagnosticEventPiece *p =
new PathDiagnosticEventPiece(L,
"Looping back to the head of the loop");
-
+
EB.addEdge(p->getLocation(), true);
PD.push_front(p);
-
+
if (CS) {
PathDiagnosticLocation BL(CS->getRBracLoc(),
PDB.getSourceManager());
@@ -1167,14 +1166,14 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
EB.addEdge(BL);
}
}
-
+
if (Term)
EB.addContext(Term);
-
+
break;
}
- if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) {
+ if (const BlockEntrance *BE = dyn_cast<BlockEntrance>(&P)) {
if (const Stmt* S = BE->getFirstStmt()) {
if (IsControlFlowExpr(S)) {
// Add the proper context for '&&', '||', and '?'.
@@ -1187,10 +1186,10 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
break;
}
} while (0);
-
+
if (!NextNode)
continue;
-
+
for (BugReporterContext::visitor_iterator I = PDB.visitor_begin(),
E = PDB.visitor_end(); I!=E; ++I) {
if (PathDiagnosticPiece* p = (*I)->VisitNode(N, NextNode, PDB)) {
@@ -1198,9 +1197,9 @@ static void GenerateExtensivePathDiagnostic(PathDiagnostic& PD,
EB.addEdge(Loc, true);
PD.push_front(p);
if (const Stmt *S = Loc.asStmt())
- EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
+ EB.addExtendedContext(PDB.getEnclosingStmtLocation(S).asStmt());
}
- }
+ }
}
}
@@ -1216,46 +1215,46 @@ void BugType::FlushReports(BugReporter &BR) {}
BugReport::~BugReport() {}
RangedBugReport::~RangedBugReport() {}
-const Stmt* BugReport::getStmt() const {
- ProgramPoint ProgP = EndNode->getLocation();
+const Stmt* BugReport::getStmt() const {
+ ProgramPoint ProgP = EndNode->getLocation();
const Stmt *S = NULL;
-
+
if (BlockEntrance* BE = dyn_cast<BlockEntrance>(&ProgP)) {
CFGBlock &Exit = ProgP.getLocationContext()->getCFG()->getExit();
if (BE->getBlock() == &Exit)
S = GetPreviousStmt(EndNode);
}
if (!S)
- S = GetStmt(ProgP);
-
- return S;
+ S = GetStmt(ProgP);
+
+ return S;
}
PathDiagnosticPiece*
BugReport::getEndPath(BugReporterContext& BRC,
const ExplodedNode* EndPathNode) {
-
+
const Stmt* S = getStmt();
-
+
if (!S)
return NULL;
const SourceRange *Beg, *End;
- getRanges(Beg, End);
+ getRanges(Beg, End);
PathDiagnosticLocation L(S, BRC.getSourceManager());
-
+
// Only add the statement itself as a range if we didn't specify any
// special ranges for this report.
PathDiagnosticPiece* P = new PathDiagnosticEventPiece(L, getDescription(),
Beg == End);
-
+
for (; Beg != End; ++Beg)
P->addRange(*Beg);
-
+
return P;
}
-void BugReport::getRanges(const SourceRange*& beg, const SourceRange*& end) {
+void BugReport::getRanges(const SourceRange*& beg, const SourceRange*& end) {
if (const Expr* E = dyn_cast_or_null<Expr>(getStmt())) {
R = E->getSourceRange();
assert(R.isValid());
@@ -1266,7 +1265,7 @@ void BugReport::getRanges(const SourceRange*& beg, const SourceRange*& end) {
beg = end = 0;
}
-SourceLocation BugReport::getLocation() const {
+SourceLocation BugReport::getLocation() const {
if (EndNode)
if (const Stmt* S = GetCurrentOrPreviousStmt(EndNode)) {
// For member expressions, return the location of the '.' or '->'.
@@ -1325,8 +1324,8 @@ void BugReporter::FlushReports() {
BugReportEquivClass& EQ = *EI;
FlushReport(EQ);
}
-
- // Delete the BugType object.
+
+ // Delete the BugType object.
// FIXME: this will *not* delete the BugReportEquivClasses, since FoldingSet
// only deletes the buckets, not the nodes themselves.
@@ -1346,9 +1345,9 @@ static std::pair<std::pair<ExplodedGraph*, NodeBackMap*>,
MakeReportGraph(const ExplodedGraph* G,
const ExplodedNode** NStart,
const ExplodedNode** NEnd) {
-
+
// Create the trimmed graph. It will contain the shortest paths from the
- // error nodes to the root. In the new graph we should only have one
+ // error nodes to the root. In the new graph we should only have one
// error node unless there are two or more error nodes with the same minimum
// path length.
ExplodedGraph* GTrim;
@@ -1356,12 +1355,12 @@ MakeReportGraph(const ExplodedGraph* G,
llvm::DenseMap<const void*, const void*> InverseMap;
llvm::tie(GTrim, NMap) = G->Trim(NStart, NEnd, &InverseMap);
-
+
// Create owning pointers for GTrim and NMap just to ensure that they are
// released when this function exists.
llvm::OwningPtr<ExplodedGraph> AutoReleaseGTrim(GTrim);
llvm::OwningPtr<InterExplodedGraphMap> AutoReleaseNMap(NMap);
-
+
// Find the (first) error node in the trimmed graph. We just need to consult
// the node map (NMap) which maps from nodes in the original graph to nodes
// in the new graph.
@@ -1376,68 +1375,68 @@ MakeReportGraph(const ExplodedGraph* G,
WS.push(N);
IndexMap[*I] = NodeIndex;
}
-
+
assert(!WS.empty() && "No error node found in the trimmed graph.");
// Create a new (third!) graph with a single path. This is the graph
// that will be returned to the caller.
ExplodedGraph *GNew = new ExplodedGraph(GTrim->getContext());
-
+
// Sometimes the trimmed graph can contain a cycle. Perform a reverse BFS
// to the root node, and then construct a new graph that contains only
// a single path.
llvm::DenseMap<const void*,unsigned> Visited;
-
+
unsigned cnt = 0;
const ExplodedNode* Root = 0;
-
+
while (!WS.empty()) {
const ExplodedNode* Node = WS.front();
WS.pop();
-
+
if (Visited.find(Node) != Visited.end())
continue;
-
+
Visited[Node] = cnt++;
-
+
if (Node->pred_empty()) {
Root = Node;
break;
}
-
+
for (ExplodedNode::const_pred_iterator I=Node->pred_begin(),
E=Node->pred_end(); I!=E; ++I)
WS.push(*I);
}
-
+
assert(Root);
-
+
// Now walk from the root down the BFS path, always taking the successor
// with the lowest number.
- ExplodedNode *Last = 0, *First = 0;
+ ExplodedNode *Last = 0, *First = 0;
NodeBackMap *BM = new NodeBackMap();
unsigned NodeIndex = 0;
-
+
for ( const ExplodedNode *N = Root ;;) {
// Lookup the number associated with the current node.
llvm::DenseMap<const void*,unsigned>::iterator I = Visited.find(N);
assert(I != Visited.end());
-
+
// Create the equivalent node in the new graph with the same state
// and location.
ExplodedNode* NewN = GNew->getNode(N->getLocation(), N->getState());
-
+
// Store the mapping to the original node.
llvm::DenseMap<const void*, const void*>::iterator IMitr=InverseMap.find(N);
assert(IMitr != InverseMap.end() && "No mapping to original node.");
(*BM)[NewN] = (const ExplodedNode*) IMitr->second;
-
+
// Link up the new node with the previous node.
if (Last)
NewN->addPredecessor(Last);
-
+
Last = NewN;
-
+
// Are we at the final node?
IndexMapTy::iterator IMI =
IndexMap.find((const ExplodedNode*)(IMitr->second));
@@ -1446,29 +1445,29 @@ MakeReportGraph(const ExplodedGraph* G,
NodeIndex = IMI->second;
break;
}
-
+
// Find the next successor node. We choose the node that is marked
// with the lowest DFS number.
ExplodedNode::const_succ_iterator SI = N->succ_begin();
ExplodedNode::const_succ_iterator SE = N->succ_end();
N = 0;
-
+
for (unsigned MinVal = 0; SI != SE; ++SI) {
-
+
I = Visited.find(*SI);
-
+
if (I == Visited.end())
continue;
-
+
if (!N || I->second < MinVal) {
N = *SI;
MinVal = I->second;
}
}
-
+
assert(N);
}
-
+
assert(First);
return std::make_pair(std::make_pair(GNew, BM),
@@ -1480,23 +1479,23 @@ MakeReportGraph(const ExplodedGraph* G,
static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
typedef std::vector<std::pair<PathDiagnosticMacroPiece*, SourceLocation> >
MacroStackTy;
-
+
typedef std::vector<PathDiagnosticPiece*>
PiecesTy;
-
+
MacroStackTy MacroStack;
PiecesTy Pieces;
-
+
for (PathDiagnostic::iterator I = PD.begin(), E = PD.end(); I!=E; ++I) {
// Get the location of the PathDiagnosticPiece.
- const FullSourceLoc Loc = I->getLocation().asLocation();
-
+ const FullSourceLoc Loc = I->getLocation().asLocation();
+
// Determine the instantiation location, which is the location we group
// related PathDiagnosticPieces.
- SourceLocation InstantiationLoc = Loc.isMacroID() ?
+ SourceLocation InstantiationLoc = Loc.isMacroID() ?
SM.getInstantiationLoc(Loc) :
SourceLocation();
-
+
if (Loc.isFileID()) {
MacroStack.clear();
Pieces.push_back(&*I);
@@ -1504,7 +1503,7 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
}
assert(Loc.isMacroID());
-
+
// Is the PathDiagnosticPiece within the same macro group?
if (!MacroStack.empty() && InstantiationLoc == MacroStack.back().second) {
MacroStack.back().first->push_back(&*I);
@@ -1518,22 +1517,22 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
SourceLocation ParentInstantiationLoc = InstantiationLoc.isMacroID() ?
SM.getInstantiationLoc(Loc) :
SourceLocation();
-
+
// Walk the entire macro stack.
while (!MacroStack.empty()) {
if (InstantiationLoc == MacroStack.back().second) {
MacroGroup = MacroStack.back().first;
break;
}
-
+
if (ParentInstantiationLoc == MacroStack.back().second) {
MacroGroup = MacroStack.back().first;
break;
}
-
+
MacroStack.pop_back();
}
-
+
if (!MacroGroup || ParentInstantiationLoc == MacroStack.back().second) {
// Create a new macro group and add it to the stack.
PathDiagnosticMacroPiece *NewGroup = new PathDiagnosticMacroPiece(Loc);
@@ -1544,7 +1543,7 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
assert(InstantiationLoc.isFileID());
Pieces.push_back(NewGroup);
}
-
+
MacroGroup = NewGroup;
MacroStack.push_back(std::make_pair(MacroGroup, InstantiationLoc));
}
@@ -1552,62 +1551,62 @@ static void CompactPathDiagnostic(PathDiagnostic &PD, const SourceManager& SM) {
// Finally, add the PathDiagnosticPiece to the group.
MacroGroup->push_back(&*I);
}
-
+
// Now take the pieces and construct a new PathDiagnostic.
PD.resetPath(false);
-
+
for (PiecesTy::iterator I=Pieces.begin(), E=Pieces.end(); I!=E; ++I) {
if (PathDiagnosticMacroPiece *MP=dyn_cast<PathDiagnosticMacroPiece>(*I))
if (!MP->containsEvent()) {
delete MP;
continue;
}
-
+
PD.push_back(*I);
}
}
void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
BugReportEquivClass& EQ) {
-
+
std::vector<const ExplodedNode*> Nodes;
-
+
for (BugReportEquivClass::iterator I=EQ.begin(), E=EQ.end(); I!=E; ++I) {
const ExplodedNode* N = I->getEndNode();
if (N) Nodes.push_back(N);
}
-
+
if (Nodes.empty())
return;
-
+
// Construct a new graph that contains only a single path from the error
- // node to a root.
+ // node to a root.
const std::pair<std::pair<ExplodedGraph*, NodeBackMap*>,
std::pair<ExplodedNode*, unsigned> >&
GPair = MakeReportGraph(&getGraph(), &Nodes[0], &Nodes[0] + Nodes.size());
-
+
// Find the BugReport with the original location.
BugReport *R = 0;
unsigned i = 0;
for (BugReportEquivClass::iterator I=EQ.begin(), E=EQ.end(); I!=E; ++I, ++i)
if (i == GPair.second.second) { R = *I; break; }
-
+
assert(R && "No original report found for sliced graph.");
-
+
llvm::OwningPtr<ExplodedGraph> ReportGraph(GPair.first.first);
llvm::OwningPtr<NodeBackMap> BackMap(GPair.first.second);
const ExplodedNode *N = GPair.second.first;
-
- // Start building the path diagnostic...
+
+ // Start building the path diagnostic...
PathDiagnosticBuilder PDB(*this, R, BackMap.get(), getPathDiagnosticClient());
-
+
if (PathDiagnosticPiece* Piece = R->getEndPath(PDB, N))
PD.push_back(Piece);
else
return;
-
+
R->registerInitialVisitors(PDB, N);
-
+
switch (PDB.getGenerationScheme()) {
case PathDiagnosticClient::Extensive:
GenerateExtensivePathDiagnostic(PD, PDB, N);
@@ -1622,17 +1621,17 @@ void BugReporter::Register(BugType *BT) {
BugTypes = F.Add(BugTypes, BT);
}
-void BugReporter::EmitReport(BugReport* R) {
+void BugReporter::EmitReport(BugReport* R) {
// Compute the bug report's hash to determine its equivalence class.
llvm::FoldingSetNodeID ID;
R->Profile(ID);
-
- // Lookup the equivance class. If there isn't one, create it.
+
+ // Lookup the equivance class. If there isn't one, create it.
BugType& BT = R->getBugType();
Register(&BT);
void *InsertPos;
- BugReportEquivClass* EQ = BT.EQClasses.FindNodeOrInsertPos(ID, InsertPos);
-
+ BugReportEquivClass* EQ = BT.EQClasses.FindNodeOrInsertPos(ID, InsertPos);
+
if (!EQ) {
EQ = new BugReportEquivClass(R);
BT.EQClasses.InsertNode(EQ, InsertPos);
@@ -1645,11 +1644,11 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
assert(!EQ.Reports.empty());
BugReport &R = **EQ.begin();
PathDiagnosticClient* PD = getPathDiagnosticClient();
-
+
// FIXME: Make sure we use the 'R' for the path that was actually used.
- // Probably doesn't make a difference in practice.
+ // Probably doesn't make a difference in practice.
BugType& BT = R.getBugType();
-
+
llvm::OwningPtr<PathDiagnostic>
D(new PathDiagnostic(R.getBugType().getName(),
!PD || PD->useVerboseDescription()
@@ -1657,16 +1656,16 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
BT.getCategory()));
GeneratePathDiagnostic(*D.get(), EQ);
-
+
// Get the meta data.
std::pair<const char**, const char**> Meta = R.getExtraDescriptiveText();
for (const char** s = Meta.first; s != Meta.second; ++s) D->addMeta(*s);
// Emit a summary diagnostic to the regular Diagnostics engine.
const SourceRange *Beg = 0, *End = 0;
- R.getRanges(Beg, End);
+ R.getRanges(Beg, End);
Diagnostic& Diag = getDiagnostic();
- FullSourceLoc L(R.getLocation(), getSourceManager());
+ FullSourceLoc L(R.getLocation(), getSourceManager());
unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning,
R.getShortDescription().c_str());
@@ -1681,15 +1680,15 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
// Emit a full diagnostic for the path if we have a PathDiagnosticClient.
if (!PD)
return;
-
- if (D->empty()) {
+
+ if (D->empty()) {
PathDiagnosticPiece* piece =
new PathDiagnosticEventPiece(L, R.getDescription());
for ( ; Beg != End; ++Beg) piece->addRange(*Beg);
D->push_back(piece);
}
-
+
PD->HandlePathDiagnostic(D.take());
}
@@ -1702,7 +1701,7 @@ void BugReporter::EmitBasicReport(const char* name, const char* str,
void BugReporter::EmitBasicReport(const char* name, const char* category,
const char* str, SourceLocation Loc,
SourceRange* RBeg, unsigned NumRanges) {
-
+
// 'BT' will be owned by BugReporter as soon as we call 'EmitReport'.
BugType *BT = new BugType(name, category);
FullSourceLoc L = getContext().getFullLoc(Loc);
diff --git a/lib/Analysis/BugReporterVisitors.cpp b/lib/Analysis/BugReporterVisitors.cpp
index 8b3502805d..b76ffb18a6 100644
--- a/lib/Analysis/BugReporterVisitors.cpp
+++ b/lib/Analysis/BugReporterVisitors.cpp
@@ -28,7 +28,7 @@ const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) {
// Pattern match for a few useful cases (do something smarter later):
// a[0], p->f, *p
const Stmt *S = N->getLocationAs<PostStmt>()->getStmt();
-
+
if (const UnaryOperator *U = dyn_cast<UnaryOperator>(S)) {
if (U->getOpcode() == UnaryOperator::Deref)
return U->getSubExpr()->IgnoreParenCasts();
@@ -41,8 +41,8 @@ const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) {
// to reason about them.
return AE->getBase();
}
-
- return NULL;
+
+ return NULL;
}
const Stmt*
@@ -91,19 +91,19 @@ class VISIBILITY_HIDDEN FindLastStoreBRVisitor : public BugReporterVisitor {
public:
FindLastStoreBRVisitor(SVal v, const MemRegion *r)
: R(r), V(v), satisfied(false), StoreSite(0) {}
-
+
PathDiagnosticPiece* VisitNode(const ExplodedNode *N,
const ExplodedNode *PrevN,
BugReporterContext& BRC) {
-
+
if (satisfied)
return NULL;
-
- if (!StoreSite) {
+
+ if (!StoreSite) {
const ExplodedNode *Node = N, *Last = NULL;
-
+
for ( ; Node ; Last = Node, Node = Node->getFirstPred()) {
-
+
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
if (const PostStmt *P = Node->getLocationAs<PostStmt>())
if (const DeclStmt *DS = P->getStmtAs<DeclStmt>())
@@ -112,35 +112,35 @@ public:
break;
}
}
-
+
if (Node->getState()->getSVal(R) != V)
break;
}
-
+
if (!Node || !Last) {
satisfied = true;
return NULL;
}
-
+
StoreSite = Last;
}
-
+
if (StoreSite != N)
return NULL;
-
+
satisfied = true;
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
if (const PostStmt *PS = N->getLocationAs<PostStmt>()) {
if (const DeclStmt *DS = PS->getStmtAs<DeclStmt>()) {
-
+
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
os << "Variable '" << VR->getDecl()->getNameAsString() << "' ";
}
else
return NULL;
-
+
if (isa<loc::ConcreteInt>(V)) {
bool b = false;
ASTContext &C = BRC.getASTContext();
@@ -152,7 +152,7 @@ public:
}
}
}
-
+
if (!b)
os << "initialized to a null pointer value";
}
@@ -165,13 +165,13 @@ public:
if (VD->getInit())
os << "initialized to a garbage value";
else
- os << "declared without an initial value";
- }
+ os << "declared without an initial value";
+ }
}
}
}
-
- if (os.str().empty()) {
+
+ if (os.str().empty()) {
if (isa<loc::ConcreteInt>(V)) {
bool b = false;
ASTContext &C = BRC.getASTContext();
@@ -183,7 +183,7 @@ public:
}
}
}
-
+
if (!b)
os << "Null pointer value stored to ";
}
@@ -196,18 +196,18 @@ public:
}
else
return NULL;
-
+
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
os << '\'' << VR->getDecl()->getNameAsString() << '\'';
}
else
return NULL;
}
-
+
// FIXME: Refactor this into BugReporterContext.
- const Stmt *S = 0;
+ const Stmt *S = 0;
ProgramPoint P = N->getLocation();
-
+
if (BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
CFGBlock *BSrc = BE->getSrc();
S = BSrc->getTerminatorCondition();
@@ -215,10 +215,10 @@ public:
else if (PostStmt *PS = dyn_cast<PostStmt>(&P)) {
S = PS->getStmt();
}
-
+
if (!S)
return NULL;
-
+
// Construct a new PathDiagnosticPiece.
PathDiagnosticLocation L(S, BRC.getSourceManager());
return new PathDiagnosticEventPiece(L, os.str());
@@ -238,42 +238,42 @@ class VISIBILITY_HIDDEN TrackConstraintBRVisitor : public BugReporterVisitor {
public:
TrackConstraintBRVisitor(SVal constraint, bool assumption)
: Constraint(constraint), Assumption(assumption), isSatisfied(false) {}
-
+
PathDiagnosticPiece* VisitNode(const ExplodedNode *N,
const ExplodedNode *PrevN,
BugReporterContext& BRC) {
if (isSatisfied)
return NULL;
-
+
// Check if in the previous state it was feasible for this constraint
// to *not* be true.
if (PrevN->getState()->assume(Constraint, !Assumption)) {
-
+
isSatisfied = true;
-
+
// As a sanity check, make sure that the negation of the constraint
// was infeasible in the current state. If it is feasible, we somehow
// missed the transition point.
if (N->getState()->assume(Constraint, !Assumption))
return NULL;
-
+
// We found the transition point for the constraint. We now need to
- // pretty-print the constraint. (work-in-progress)
+ // pretty-print the constraint. (work-in-progress)
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
if (isa<Loc>(Constraint)) {
os << "Assuming pointer value is ";
os << (Assumption ? "non-null" : "null");
}
-
+
if (os.str().empty())
return NULL;
-
+
// FIXME: Refactor this into BugReporterContext.
- const Stmt *S = 0;
+ const Stmt *S = 0;
ProgramPoint P = N->getLocation();
-
+
if (BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
CFGBlock *BSrc = BE->getSrc();
S = BSrc->getTerminatorCondition();
@@ -281,65 +281,65 @@ public:
else if (PostStmt *PS = dyn_cast<PostStmt>(&P)) {
S = PS->getStmt();
}
-
+
if (!S)
return NULL;
-
+
// Construct a new PathDiagnosticPiece.
PathDiagnosticLocation L(S, BRC.getSourceManager());
return new PathDiagnosticEventPiece(L, os.str());
}
-
+
return NULL;
- }
+ }
};
} // end anonymous namespace
static void registerTrackConstraint(BugReporterContext& BRC, SVal Constraint,
bool Assumption) {
- BRC.addVisitor(new TrackConstraintBRVisitor(Constraint, Assumption));
+ BRC.addVisitor(new TrackConstraintBRVisitor(Constraint, Assumption));
}
void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC,
const void *data,
const ExplodedNode* N) {
-
+
const Stmt *S = static_cast<const Stmt*>(data);
-
+
if (!S)
return;
-
+
GRStateManager &StateMgr = BRC.getStateManager();
- const GRState *state = N->getState();
-
- if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S)) {
- if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
+ const GRState *state = N->getState();
+
+ if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S)) {
+ if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
const VarRegion *R =
StateMgr.getRegionManager().getVarRegion(VD, N->getLocationContext());
-
+
// What did we load?
SVal V = state->getSVal(S);
-
- if (isa<loc::ConcreteInt>(V) || isa<nonloc::ConcreteInt>(V)
+
+ if (isa<loc::ConcreteInt>(V) || isa<nonloc::ConcreteInt>(V)
|| V.isUndef()) {
registerFindLastStore(BRC, R, V);
}
}
}
-
+
SVal V = state->getSValAsScalarOrLoc(S);
-
+
// Uncomment this to find cases where we aren't properly getting the
// base value that was dereferenced.
// assert(!V.isUnknownOrUndef());
-
+
// Is it a symbolic value?
if (loc::MemRegionVal *L = dyn_cast<loc::MemRegionVal>(&V)) {
const SubRegion *R = cast<SubRegion>(L->getRegion());
while (R && !isa<SymbolicRegion>(R)) {
R = dyn_cast<SubRegion>(R->getSuperRegion());
}
-
+
if (R) {
assert(isa<SymbolicRegion>(R));
registerTrackConstraint(BRC, loc::MemRegionVal(R), false);
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index ee64bd2f3f..d5fde0a819 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -133,8 +133,8 @@ private:
CFGBlock *createBlock(bool add_successor = true);
bool FinishBlock(CFGBlock* B);
CFGBlock *addStmt(Stmt *S) { return Visit(S, true); }
-
-
+
+
/// TryResult - a class representing a variant over the values
/// 'true', 'false', or 'unknown'. This is returned by TryEvaluateBool,
/// and is used by the CFGBuilder to decide if a branch condition
@@ -144,7 +144,7 @@ private:
public:
TryResult(bool b) : X(b ? 1 : 0) {}
TryResult() : X(-1) {}
-
+
bool isTrue() const { return X == 1; }
bool isFalse() const { return X == 0; }
bool isKnown() const { return X >= 0; }
@@ -153,7 +153,7 @@ private:
X ^= 0x1;
}
};
-
+
/// TryEvaluateBool - Try and evaluate the Stmt and return 0 or 1
/// if we can evaluate to a known value, otherwise return -1.
TryResult TryEvaluateBool(Expr *S) {
@@ -292,109 +292,109 @@ tryAgain:
case Stmt::AddrLabelExprClass:
return VisitAddrLabelExpr(cast<AddrLabelExpr>(S), alwaysAdd);
-
+
case Stmt::BinaryOperatorClass:
return VisitBinaryOperator(cast<BinaryOperator>(S), alwaysAdd);
-
+
case Stmt::BlockExprClass:
return VisitBlockExpr(cast<BlockExpr>(S), alwaysAdd);
case Stmt::BlockDeclRefExprClass:
return VisitBlockDeclRefExpr(cast<BlockDeclRefExpr>(S), alwaysAdd);
-
+
case Stmt::BreakStmtClass:
return VisitBreakStmt(cast<BreakStmt>(S));
-
+
case Stmt::CallExprClass:
return VisitCallExpr(cast<CallExpr>(S), alwaysAdd);
-
+
case Stmt::CaseStmtClass:
return VisitCaseStmt(cast<CaseStmt>(S));
case Stmt::ChooseExprClass:
return VisitChooseExpr(cast<ChooseExpr>(S));
-
+
case Stmt::CompoundStmtClass:
return VisitCompoundStmt(cast<CompoundStmt>(S));
-
+
case Stmt::ConditionalOperatorClass:
return VisitConditionalOperator(cast<ConditionalOperator>(S));
-
+
case Stmt::ContinueStmtClass:
return VisitContinueStmt(cast<ContinueStmt>(S));
-
+
case Stmt::DeclStmtClass:
return VisitDeclStmt(cast<DeclStmt>(S));
-
+
case Stmt::DefaultStmtClass:
return VisitDefaultStmt(cast<DefaultStmt>(S));
-
+
case Stmt::DoStmtClass:
return VisitDoStmt(cast<DoStmt>(S));
-
+
case Stmt::ForStmtClass:
return VisitForStmt(cast<ForStmt>(S));
-
+
case Stmt::GotoStmtClass:
return VisitGotoStmt(cast<GotoStmt>(S));
-
+
case Stmt::IfStmtClass:
return VisitIfStmt(cast<IfStmt>(S));
-
+
case Stmt::IndirectGotoStmtClass:
return VisitIndirectGotoStmt(cast<IndirectGotoStmt>(S));
-
+
case Stmt::LabelStmtClass:
return VisitLabelStmt(cast<LabelStmt>(S));
-
+
case Stmt::ObjCAtCatchStmtClass:
- return VisitObjCAtCatchStmt(cast<ObjCAtCatchStmt>(S));
-
+ return VisitObjCAtCatchStmt(cast<ObjCAtCatchStmt>(S));
+
case Stmt::CXXThrowExprClass:
return VisitCXXThrowExpr(cast<CXXThrowExpr>(S));
case Stmt::ObjCAtSynchronizedStmtClass:
return VisitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(S));
-
+
case Stmt::ObjCAtThrowStmtClass:
return VisitObjCAtThrowStmt(cast<ObjCAtThrowStmt>(S));
-
+
case Stmt::ObjCAtTryStmtClass:
return VisitObjCAtTryStmt(cast<ObjCAtTryStmt>(S));
-
+
case Stmt::ObjCForCollectionStmtClass:
return VisitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(S));
-
+
case Stmt::ParenExprClass:
S = cast<ParenExpr>(S)->getSubExpr();
- goto tryAgain;
-
+ goto tryAgain;
+
case Stmt::NullStmtClass:
return Block;
-
+
case Stmt::ReturnStmtClass:
return VisitReturnStmt(cast<ReturnStmt>(S));
-
+
case Stmt::SizeOfAlignOfExprClass:
- return VisitSizeOfAlignOfExpr(cast<SizeOfAlignOfExpr>(S), alwaysAdd);
-
+ return VisitSizeOfAlignOfExpr(cast<SizeOfAlignOfExpr>(S), alwaysAdd);
+
case Stmt::StmtExprClass:
return VisitStmtExpr(cast<StmtExpr>(S), alwaysAdd);
-
+
case Stmt::SwitchStmtClass:
return VisitSwitchStmt(cast<SwitchStmt>(S));
-
+
case Stmt::WhileStmtClass:
return VisitWhileStmt(cast<WhileStmt>(S));
}
}
-
+
CFGBlock *CFGBuilder::VisitStmt(Stmt *S, bool alwaysAdd) {
if (alwaysAdd) {
autoCreateBlock();
Block->appendStmt(S);
}
-
+
return VisitChildren(S);
}
@@ -407,7 +407,7 @@ CFGBlock *CFGBuilder::VisitChildren(Stmt* Terminator) {
}
return B;
}
-
+
CFGBlock *CFGBuilder::VisitAddrLabelExpr(AddrLabelExpr *A, bool alwaysAdd) {
AddressTakenLabels.insert(A->getLabel());
@@ -418,26 +418,26 @@ CFGBlock *CFGBuilder::VisitAddrLabelExpr(AddrLabelExpr *A, bool alwaysAdd) {
return Block;
}
-
+
CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, bool alwaysAdd) {
if (B->isLogicalOp()) { // && or ||
CFGBlock* ConfluenceBlock = Block ? Block : createBlock();
ConfluenceBlock->appendStmt(B);
-
+
if (!FinishBlock(ConfluenceBlock))
return 0;
-
+
// create the block evaluating the LHS
CFGBlock* LHSBlock = createBlock(false);
LHSBlock->setTerminator(B);
-
+
// create the block evaluating the RHS
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = addStmt(B->getRHS());
if (!FinishBlock(RHSBlock))
return 0;
-
+
// See if this is a known constant.
TryResult KnownVal = TryEvaluateBool(B->getLHS());
if (KnownVal.isKnown() && (B->getOpcode() == BinaryOperator::LOr))
@@ -447,23 +447,23 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, bool alwaysAdd) {
if (B->getOpcode() == BinaryOperator::LOr) {
LHSBlock->addSuccessor(KnownVal.isTrue() ? NULL : ConfluenceBlock);
LHSBlock->addSuccessor(KnownVal.isFalse() ? NULL : RHSBlock);
- } else {
+ } else {
assert (B->getOpcode() == BinaryOperator::LAnd);
LHSBlock->addSuccessor(KnownVal.isFalse() ? NULL : RHSBlock);
LHSBlock->addSuccessor(KnownVal.isTrue() ? NULL : ConfluenceBlock);
}
-
+
// Generate the blocks for evaluating the LHS.
Block = LHSBlock;
return addStmt(B->getLHS());
- }
+ }
else if (B->getOpcode() == BinaryOperator::Comma) { // ,
autoCreateBlock();
Block->appendStmt(B);
addStmt(B->getRHS());
return addStmt(B->getLHS());
}
-
+
return VisitStmt(B, alwaysAdd);
}
@@ -477,28 +477,28 @@ CFGBlock *CFGBuilder::VisitBlockDeclRefExpr(BlockDeclRefExpr* E,
// FIXME
return NYS();
}
-
+
CFGBlock *CFGBuilder::VisitBreakStmt(BreakStmt *B) {
// "break" is a control-flow statement. Thus we stop processing the current
// block.
if (Block && !FinishBlock(Block))
return 0;
-
+
// Now create a new block that ends with the break statement.
Block = createBlock(false);
Block->setTerminator(B);
-
+
// If there is no target for the break, then we are looking at an incomplete
// AST. This means that the CFG cannot be constructed.
if (BreakTargetBlock)
Block->addSuccessor(BreakTargetBlock);
else
badCFG = true;
-
-
+
+
return Block;
}
-
+
CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, bool alwaysAdd) {
// If this is a call to a no-return function, this stops the block here.
bool NoReturn = false;
@@ -512,17 +512,17 @@ CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, bool alwaysAdd) {
if (!NoReturn)
return VisitStmt(C, alwaysAdd);
-
+
if (Block && !FinishBlock(Block))
return 0;
-
+
// Create new block with no successor for the remaining pieces.
Block = createBlock(false);
Block->appendStmt(C);
// Wire this to the exit block directly.
Block->addSuccessor(&cfg->getExit());
-
+
return VisitChildren(C);
}
@@ -531,42 +531,42 @@ CFGBlock *CFGBuilder::VisitChooseExpr(ChooseExpr *C) {
ConfluenceBlock->appendStmt(C);
if (!FinishBlock(ConfluenceBlock))
return 0;
-
+
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* LHSBlock = addStmt(C->getLHS());
if (!FinishBlock(LHSBlock))
return 0;
-
+
Succ = ConfluenceBlock;
Block = NULL;
CFGBlock* RHSBlock = addStmt(C->getRHS());
if (!FinishBlock(RHSBlock))
return 0;
-
+
Block = createBlock(false);
// See if this is a known constant.
const TryResult& KnownVal = TryEvaluateBool(C->getCond());
Block->addSuccessor(KnownVal.isFalse() ? NULL : LHSBlock);
Block->addSuccessor(KnownVal.isTrue() ? NULL : RHSBlock);
Block->setTerminator(C);
- return addStmt(C->getCond());
+ return addStmt(C->getCond());
}
-
-
-CFGBlock* CFGBuilder::VisitCompoundStmt(CompoundStmt* C) {
- CFGBlock* LastBlock = Block;
+
+
+CFGBlock* CFGBuilder::VisitCompoundStmt(CompoundStmt* C) {
+ CFGBlock* LastBlock = Block;
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
I != E; ++I ) {
LastBlock = addStmt(*I);
-
+
if (badCFG)
return NULL;
- }
+ }
return LastBlock;
}
-
+
CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C) {
// Create the confluence block that will "merge" the results of the ternary
// expression.
@@ -574,7 +574,7 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C) {
ConfluenceBlock->appendStmt(C);
if (!FinishBlock(ConfluenceBlock))
return 0;
-
+
// Create a block for the LHS expression if there is an LHS expression. A
// GCC extension allows LHS to be NULL, causing the condition to be the
// value that is returned instead.
@@ -588,16 +588,16 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C) {
return 0;
Block = NULL;
}
-
+
// Create the block for the RHS expression.
Succ = ConfluenceBlock;
CFGBlock* RHSBlock = addStmt(C->getRHS());
if (!FinishBlock(RHSBlock))
return 0;
-
+
// Create the block that will contain the condition.
Block = createBlock(false);
-
+
// See if this is a known constant.
const TryResult& KnownVal = TryEvaluateBool(C->getCond());
if (LHSBlock) {
@@ -622,8 +622,8 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(ConditionalOperator *C) {
ConfluenceBlock->pred_end());
}
}
-
- Block->addSuccessor(KnownVal.isTrue() ? NULL : RHSBlock);
+
+ Block->addSuccessor(KnownVal.isTrue() ? NULL : RHSBlock);
Block->setTerminator(C);
return addStmt(C->getCond());
}
@@ -635,45 +635,45 @@ CFGBlock *CFGBuilder::VisitDeclStmt(DeclStmt *DS) {
Block->appendStmt(DS);
return VisitDeclSubExpr(DS->getSingleDecl());
}
-
+
CFGBlock *B = 0;
-
+
// FIXME: Add a reverse iterator for DeclStmt to avoid this extra copy.
typedef llvm::SmallVector<Decl*,10> BufTy;
BufTy Buf(DS->decl_begin(), DS->decl_end());
-
+
for (BufTy::reverse_iterator I = Buf.rbegin(), E = Buf.rend(); I != E; ++I) {
// Get the alignment of the new DeclStmt, padding out to >=8 bytes.
unsigned A = llvm::AlignOf<DeclStmt>::Alignment < 8
? 8 : llvm::AlignOf<DeclStmt>::Alignment;
-
+
// Allocate the DeclStmt using the BumpPtrAllocator. It will get
// automatically freed with the CFG.
DeclGroupRef DG(*I);
Decl *D = *I;
- void *Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A);
+ void *Mem = cfg->getAllocator().Allocate(sizeof(DeclStmt), A);
DeclStmt *DSNew = new (Mem) DeclStmt(DG, D->getLocation(), GetEndLoc(D));
-
+
// Append the fake DeclStmt to block.
Block->appendStmt(DSNew);
B = VisitDeclSubExpr(D);
}
-
- return B;
+
+ return B;
}
-
+
/// VisitDeclSubExpr - Utility method to add block-level expressions for
/// initializers in Decls.
CFGBlock *CFGBuilder::VisitDeclSubExpr(Decl* D) {
assert(Block);
VarDecl *VD = dyn_cast<VarDecl>(D);
-
+
if (!VD)
return Block;
-
+
Expr *Init = VD->getInit();
-
+
if (Init) {
// Optimization: Don't create separate block-level statements for literals.
switch (Init->getStmtClass()) {
@@ -685,12 +685,12 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(Decl* D) {
Block = addStmt(Init);
}
}
-
+
// If the type of VD is a VLA, then we must process its size expressions.
for (VariableArrayType* VA = FindVA(VD->getType().getTypePtr()); VA != 0;
VA = FindVA(VA->getElementType().getTypePtr()))
Block = addStmt(VA->getSizeExpr());
-
+
return Block;
}
@@ -879,7 +879,7 @@ CFGBlock* CFGBuilder::VisitForStmt(ForStmt* F) {
// See if this is a known constant.
TryResult KnownVal(true);
-
+
if (F->getCond())
KnownVal = TryEvaluateBool(F->getCond());
@@ -1171,8 +1171,8 @@ CFGBlock* CFGBuilder::VisitWhileStmt(WhileStmt* W) {
Succ = EntryConditionBlock;
return EntryConditionBlock;
}
-
-
+
+
CFGBlock *CFGBuilder::VisitObjCAtCatchStmt(ObjCAtCatchStmt* S) {
// FIXME: For now we pretend that @catch and the code it contains does not
// exit.
@@ -1329,7 +1329,7 @@ CFGBlock* CFGBuilder::VisitContinueStmt(ContinueStmt* C) {
return Block;
}
-
+
CFGBlock *CFGBuilder::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E,
bool alwaysAdd) {
@@ -1337,17 +1337,17 @@ CFGBlock *CFGBuilder::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E,
autoCreateBlock();
Block->appendStmt(E);
}
-
+
// VLA types have expressions that must be evaluated.
if (E->isArgumentType()) {
for (VariableArrayType* VA = FindVA(E->getArgumentType().getTypePtr());
VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
addStmt(VA->getSizeExpr());
}
-
+
return Block;
}
-
+
/// VisitStmtExpr - Utility method to handle (nested) statement
/// expressions (a GCC extension).
CFGBlock* CFGBuilder::VisitStmtExpr(StmtExpr *SE, bool alwaysAdd) {
@@ -1416,7 +1416,7 @@ CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) {
if (CS->getSubStmt())
addStmt(CS->getSubStmt());
-
+
CFGBlock* CaseBlock = Block;
if (!CaseBlock)
CaseBlock = createBlock();
@@ -1445,7 +1445,7 @@ CFGBlock* CFGBuilder::VisitCaseStmt(CaseStmt* CS) {
CFGBlock* CFGBuilder::VisitDefaultStmt(DefaultStmt* Terminator) {
if (Terminator->getSubStmt())
addStmt(Terminator->getSubStmt());
-
+
DefaultCaseBlock = Block;
if (!DefaultCaseBlock)
@@ -1454,7 +1454,7 @@ CFGBlock* CFGBuilder::VisitDefaultStmt(DefaultStmt* Terminator) {
// Default statements partition blocks, so this is the top of the basic block
// we were processing (the "default:" is the label).
DefaultCaseBlock->setLabel(Terminator);
-
+
if (!FinishBlock(DefaultCaseBlock))
return 0;
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 9cd59c2c14..e511f76195 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -22,7 +22,7 @@
#include "clang/Analysis/PathSensitive/BugReporter.h"
#include "clang/Analysis/PathSensitive/SymbolManager.h"
#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
-#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclObjC.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/ImmutableMap.h"
@@ -44,7 +44,7 @@ using namespace clang;
// MemoryMgmt/Tasks/MemoryManagementRules.html
//
// "You take ownership of an object if you create it using a method whose name
-// begins with "alloc" or "new" or contains "copy" (for example, alloc,
+// begins with "alloc" or "new" or contains "copy" (for example, alloc,
// newObject, or mutableCopy), or if you send it a retain message. You are
// responsible for relinquishing ownership of objects you own using release
// or autorelease. Any other time you receive an object, you must
@@ -62,8 +62,8 @@ static inline bool isWordEnd(char ch, char prev, char next) {
|| (isupper(prev) && isupper(ch) && islower(next)) // XXCreate
|| !isalpha(ch);
}
-
-static inline const char* parseWord(const char* s) {
+
+static inline const char* parseWord(const char* s) {
char ch = *s, prev = '\0';
assert(ch != '\0');
char next = *(s+1);
@@ -77,18 +77,18 @@ static inline const char* parseWord(const char* s) {
static NamingConvention deriveNamingConvention(Selector S) {
IdentifierInfo *II = S.getIdentifierInfoForSlot(0);
-
+
if (!II)
return NoConvention;
-
+
const char *s = II->getName();
-
+
// A method/function name may contain a prefix. We don't know it is there,
// however, until we encounter the first '_'.
bool InPossiblePrefix = true;
bool AtBeginning = true;
NamingConvention C = NoConvention;
-
+
while (*s != '\0') {
// Skip '_'.
if (*s == '_') {
@@ -103,24 +103,24 @@ static NamingConvention deriveNamingConvention(Selector S) {
++s;
continue;
}
-
+
// Skip numbers, ':', etc.
if (!isalpha(*s)) {
++s;
continue;
}
-
+
const char *wordEnd = parseWord(s);
assert(wordEnd > s);
unsigned len = wordEnd - s;
-
+
switch (len) {
default:
break;
case 3:
// Methods starting with 'new' follow the create rule.
if (AtBeginning && StringsEqualNoCase("new", s, len))
- C = CreateRule;
+ C = CreateRule;
break;
case 4:
// Methods starting with 'alloc' or contain 'copy' follow the
@@ -136,7 +136,7 @@ static NamingConvention deriveNamingConvention(Selector S) {
C = CreateRule;
break;
}
-
+
// If we aren't in the prefix and have a derived convention then just
// return it now.
if (!InPossiblePrefix && C != NoConvention)
@@ -156,10 +156,10 @@ static bool followsFundamentalRule(Selector S) {
}
static const ObjCMethodDecl*
-ResolveToInterfaceMethodDecl(const ObjCMethodDecl *MD) {
+ResolveToInterfaceMethodDecl(const ObjCMethodDecl *MD) {
ObjCInterfaceDecl *ID =
const_cast<ObjCInterfaceDecl*>(MD->getClassInterface());
-
+
return MD->isInstanceMethod()
? ID->lookupInstanceMethod(MD->getSelector())
: ID->lookupClassMethod(MD->getSelector());
@@ -178,12 +178,12 @@ public:
GenericNodeBuilder(GREndPathNodeBuilder &enb)
: SNB(0), S(0), tag(0), ENB(&enb) {}
-
+
ExplodedNode *MakeNode(const GRState *state, ExplodedNode *Pred) {
if (SNB)
- return SNB->generateNode(PostStmt(S, Pred->getLocationContext(), tag),
+ return SNB->generateNode(PostStmt(S, Pred->getLocationContext(), tag),
state, Pred);
-
+
assert(ENB);
return ENB->generateNode(state, Pred);
}
@@ -211,16 +211,16 @@ static inline Selector GetUnarySelector(const char* name, ASTContext& Ctx) {
static bool hasPrefix(const char* s, const char* prefix) {
if (!prefix)
return true;
-
+
char c = *s;
char cP = *prefix;
-
+
while (c != '\0' && cP != '\0') {
if (c != cP) break;
c = *(++s);
cP = *(++prefix);
}
-
+
return cP == '\0';
}
@@ -231,14 +231,14 @@ static bool hasSuffix(const char* s, const char* suffix) {
static bool isRefType(QualType RetTy, const char* prefix,
ASTContext* Ctx = 0, const char* name = 0) {
-
+
// Recursively walk the typedef stack, allowing typedefs of reference types.
while (1) {
if (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
const char* TDName = TD->getDecl()->getIdentifier()->getName();
if (hasPrefix(TDName, prefix) && hasSuffix(TDName, "Ref"))
return true;
-
+
RetTy = TD->getDecl()->getUnderlyingType();
continue;
}
@@ -282,14 +282,14 @@ typedef llvm::ImmutableMap<unsigned,ArgEffect> ArgEffects;
namespace {
/// RetEffect is used to summarize a function/method call's behavior with
-/// respect to its return value.
+/// respect to its return value.
class VISIBILITY_HIDDEN RetEffect {
public:
enum Kind { NoRet, Alias, OwnedSymbol, OwnedAllocatedSymbol,
NotOwnedSymbol, GCNotOwnedSymbol, ReceiverAlias,
OwnedWhenTrackedReceiver };
-
- enum ObjKind { CF, ObjC, AnyObj };
+
+ enum ObjKind { CF, ObjC, AnyObj };
private:
Kind K;
@@ -298,124 +298,124 @@ private:
RetEffect(Kind k, unsigned idx = 0) : K(k), O(AnyObj), index(idx) {}
RetEffect(Kind k, ObjKind o) : K(k), O(o), index(0) {}
-
+
public:
Kind getKind() const { return K; }
ObjKind getObjKind() const { return O; }
-
- unsigned getIndex() const {
+
+ unsigned getIndex() const {
assert(getKind() == Alias);
return index;
}
-
+
bool isOwned() const {
return K == OwnedSymbol || K == OwnedAllocatedSymbol ||
K == OwnedWhenTrackedReceiver;
}
-
+
static RetEffect MakeOwnedWhenTrackedReceiver() {
return RetEffect(OwnedWhenTrackedReceiver, ObjC);
}
-
+
static RetEffect MakeAlias(unsigned Idx) {
return RetEffect(Alias, Idx);
}
static RetEffect MakeReceiverAlias() {
return RetEffect(ReceiverAlias);
- }
+ }
static RetEffect MakeOwned(ObjKind o, bool isAllocated = false) {
return RetEffect(isAllocated ? OwnedAllocatedSymbol : OwnedSymbol, o);
- }
+ }
static RetEffect MakeNotOwned(ObjKind o) {
return RetEffect(NotOwnedSymbol, o);
}
static RetEffect MakeGCNotOwned() {
return RetEffect(GCNotOwnedSymbol, ObjC);
}
-
+
static RetEffect MakeNoRet() {
return RetEffect(NoRet);
}
-
+
void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned)K);
ID.AddInteger((unsigned)O);
ID.AddInteger(index);
}
};
-
-
+
+
class VISIBILITY_HIDDEN RetainSummary {
/// Args - an ordered vector of (index, ArgEffect) pairs, where index
/// specifies the argument (starting from 0). This can be sparsely
/// populated; arguments with no entry in Args use 'DefaultArgEffect'.
ArgEffects Args;
-
+
/// DefaultArgEffect - The default ArgEffect to apply to arguments that
/// do not have an entry in Args.
ArgEffect DefaultArgEffect;
-
+
/// Receiver - If this summary applies to an Objective-C message expression,
/// this is the effect applied to the state of the receiver.
ArgEffect Receiver;
-
+
/// Ret - The effect on the return value. Used to indicate if the
/// function/method call returns a new tracked symbol, returns an
/// alias of one of the arguments in the call, and so on.
RetEffect Ret;
-
+
/// EndPath - Indicates that execution of this method/function should
/// terminate the simulation of a path.
bool EndPath;
-
+
public:
RetainSummary(ArgEffects A, RetEffect R, ArgEffect defaultEff,
ArgEffect ReceiverEff, bool endpath = false)
: Args(A), DefaultArgEffect(defaultEff), Receiver(ReceiverEff), Ret(R),
- EndPath(endpath) {}
-
+ EndPath(endpath) {}
+
/// getArg - Return the argument effect on the argument specified by
/// idx (starting from 0).
ArgEffect getArg(unsigned idx) const {
if (const ArgEffect *AE = Args.lookup(idx))
return *AE;
-
+
return DefaultArgEffect;
}
-
+
/// setDefaultArgEffect - Set the default argument effect.
void setDefaultArgEffect(ArgEffect E) {
DefaultArgEffect = E;
}
-
+
/// setArg - Set the argument effect on the argument specified by idx.
void setArgEffect(ArgEffects::Factory& AF, unsigned idx, ArgEffect E) {
Args = AF.Add(Args, idx, E);
}
-
+
/// getRetEffect - Returns the effect on the return value of the call.
RetEffect getRetEffect() const { return Ret; }
-
+
/// setRetEffect - Set the effect of the return value of the call.
void setRetEffect(RetEffect E) { Ret = E; }
-
+
/// isEndPath - Returns true if executing the given method/function should
/// terminate the path.
bool isEndPath() const { return EndPath; }
-
+
/// getReceiverEffect - Returns the effect on the receiver of the call.
/// This is only meaningful if the summary applies to an ObjCMessageExpr*.
ArgEffect getReceiverEffect() const { return Receiver; }
-
+
/// setReceiverEffect - Set the effect on the receiver of the call.
void setReceiverEffect(ArgEffect E) { Receiver = E; }
-
+
typedef ArgEffects::iterator ExprIterator;
-
+
ExprIterator begin_args() const { return Args.begin(); }
ExprIterator end_args() const { return Args.end(); }
-
+
static void Profile(llvm::FoldingSetNodeID& ID, ArgEffects A,
RetEffect RetEff, ArgEffect DefaultEff,
ArgEffect ReceiverEff, bool EndPath) {
@@ -425,7 +425,7 @@ public:
ID.AddInteger((unsigned) ReceiverEff);
ID.AddInteger((unsigned) EndPath);
}
-
+
void Profile(llvm::FoldingSetNodeID& ID) const {
Profile(ID, Args, Ret, DefaultArgEffect, Receiver, EndPath);
}
@@ -440,7 +440,7 @@ namespace {
class VISIBILITY_HIDDEN ObjCSummaryKey {
IdentifierInfo* II;
Selector S;
-public:
+public:
ObjCSummaryKey(IdentifierInfo* ii, Selector s)
: II(ii), S(s) {}
@@ -449,10 +449,10 @@ public:
ObjCSummaryKey(const ObjCInterfaceDecl* d, IdentifierInfo *ii, Selector s)
: II(d ? d->getIdentifier() : ii), S(s) {}
-
+
ObjCSummaryKey(Selector s)
: II(0), S(s) {}
-
+
IdentifierInfo* getIdentifier() const { return II; }
Selector getSelector() const { return S; }
};
@@ -464,56 +464,56 @@ template <> struct DenseMapInfo<ObjCSummaryKey> {
return ObjCSummaryKey(DenseMapInfo<IdentifierInfo*>::getEmptyKey(),
DenseMapInfo<Selector>::getEmptyKey());
}
-
+
static inline ObjCSummaryKey getTombstoneKey() {
return ObjCSummaryKey(DenseMapInfo<IdentifierInfo*>::getTombstoneKey(),
- DenseMapInfo<Selector>::getTombstoneKey());
+ DenseMapInfo<Selector>::getTombstoneKey());
}
-
+
static unsigned getHashValue(const ObjCSummaryKey &V) {
return (DenseMapInfo<IdentifierInfo*>::getHashValue(V.getIdentifier())
- & 0x88888888)
+ & 0x88888888)
| (DenseMapInfo<Selector>::getHashValue(V.getSelector())
& 0x55555555);
}
-
+
static bool isEqual(const ObjCSummaryKey& LHS, const ObjCSummaryKey& RHS) {
return DenseMapInfo<IdentifierInfo*>::isEqual(LHS.getIdentifier(),
RHS.getIdentifier()) &&
DenseMapInfo<Selector>::isEqual(LHS.getSelector(),
RHS.getSelector());
}
-
+
static bool isPod() {
return DenseMapInfo<ObjCInterfaceDecl*>::isPod() &&
DenseMapInfo<Selector>::isPod();
}
};
} // end llvm namespace
-
+
namespace {
class VISIBILITY_HIDDEN ObjCSummaryCache {
typedef llvm::DenseMap<ObjCSummaryKey, RetainSummary*> MapTy;
MapTy M;
public:
ObjCSummaryCache() {}
-
+
RetainSummary* find(const ObjCInterfaceDecl* D, IdentifierInfo *ClsName,
Selector S) {
// Lookup the method using the decl for the class @interface. If we
// have no decl, lookup using the class name.
return D ? find(D, S) : find(ClsName, S);
}
-
- RetainSummary* find(const ObjCInterfaceDecl* D, Selector S) {
+
+ RetainSummary* find(const ObjCInterfaceDecl* D, Selector S) {
// Do a lookup with the (D,S) pair. If we find a match return
// the iterator.
ObjCSummaryKey K(D, S);
MapTy::iterator I = M.find(K);
-
+
if (I != M.end() || !D)
return I->second;
-
+
// Walk the super chain. If we find a hit with a parent, we'll end
// up returning that summary. We actually allow that key (null,S), as
// we cache summaries for the null ObjCInterfaceDecl* to allow us to
@@ -523,62 +523,62 @@ public:
for (ObjCInterfaceDecl* C=D->getSuperClass() ;; C=C->getSuperClass()) {
if ((I = M.find(ObjCSummaryKey(C, S))) != M.end())
break;
-
+
if (!C)
return NULL;
}
-
- // Cache the summary with original key to make the next lookup faster
+
+ // Cache the summary with original key to make the next lookup faster
// and return the iterator.
RetainSummary *Summ = I->second;
M[K] = Summ;
return Summ;
}
-
+
RetainSummary* find(Expr* Receiver, Selector S) {
return find(getReceiverDecl(Receiver), S);
}
-
+
RetainSummary* find(IdentifierInfo* II, Selector S) {
// FIXME: Class method lookup. Right now we dont' have a good way
// of going between IdentifierInfo* and the class hierarchy.
MapTy::iterator I = M.find(ObjCSummaryKey(II, S));
-
+
if (I == M.end())
I = M.find(ObjCSummaryKey(S));
-
+
return I == M.end() ? NULL : I->second;
}
-
- const ObjCInterfaceDecl* getReceiverDecl(Expr* E) {
+
+ const ObjCInterfaceDecl* getReceiverDecl(Expr* E) {
if (const ObjCObjectPointerType* PT =
E->getType()->getAsObjCObjectPointerType())
return PT->getInterfaceDecl();
return NULL;
}
-
+
RetainSummary*& operator[](ObjCMessageExpr* ME) {
-
+
Selector S = ME->getSelector();
-
+
if (Expr* Receiver = ME->getReceiver()) {
const ObjCInterfaceDecl* OD = getReceiverDecl(Receiver);
return OD ? M[ObjCSummaryKey(OD->getIdentifier(), S)] : M[S];
}
-
+
return M[ObjCSummaryKey(ME->getClassName(), S)];
}
-
+
RetainSummary*& operator[](ObjCSummaryKey K) {
return M[K];
}
-
+
RetainSummary*& operator[](Selector S) {
return M[ ObjCSummaryKey(S) ];
}
-};
+};
} // end anonymous namespace
//===----------------------------------------------------------------------===//
@@ -591,29 +591,29 @@ class VISIBILITY_HIDDEN RetainSummaryManager {
//==-----------------------------------------------------------------==//
// Typedefs.
//==-----------------------------------------------------------------==//
-
+
typedef llvm::DenseMap<FunctionDecl*, RetainSummary*>
FuncSummariesTy;
-
+
typedef ObjCSummaryCache ObjCMethodSummariesTy;
-
+
//==-----------------------------------------------------------------==//
// Data.
//==-----------------------------------------------------------------==//
-
+
/// Ctx - The ASTContext object for the analyzed ASTs.
ASTContext& Ctx;
/// CFDictionaryCreateII - An IdentifierInfo* representing the indentifier
/// "CFDictionaryCreate".
IdentifierInfo* CFDictionaryCreateII;
-
+
/// GCEnabled - Records whether or not the analyzed code runs in GC mode.
const bool GCEnabled;
-
+
/// FuncSummaries - A map from FunctionDecls to summaries.
- FuncSummariesTy FuncSummaries;
-
+ FuncSummariesTy FuncSummaries;
+
/// ObjCClassMethodSummaries - A map from selectors (for instance methods)
/// to summaries.
ObjCMethodSummariesTy ObjCClassMethodSummaries;
@@ -624,34 +624,34 @@ class VISIBILITY_HIDDEN RetainSummaryManager {
/// BPAlloc - A BumpPtrAllocator used for allocating summaries, ArgEffects,
/// and all other data used by the checker.
llvm::BumpPtrAllocator BPAlloc;
-
+
/// AF - A factory for ArgEffects objects.
- ArgEffects::Factory AF;
-
+ ArgEffects::Factory AF;
+
/// ScratchArgs - A holding buffer for construct ArgEffects.
ArgEffects ScratchArgs;
-
+
/// ObjCAllocRetE - Default return effect for methods returning Objective-C
/// objects.
RetEffect ObjCAllocRetE;
- /// ObjCInitRetE - Default return effect for init methods returning
+ /// ObjCInitRetE - Default return effect for init methods returning
/// Objective-C objects.
RetEffect ObjCInitRetE;
-
+
RetainSummary DefaultSummary;
RetainSummary* StopSummary;
-
+
//==-----------------------------------------------------------------==//
// Methods.
//==-----------------------------------------------------------------==//
-
+
/// getArgEffects - Returns a persistent ArgEffects object based on the
/// data in ScratchArgs.
ArgEffects getArgEffects();
- enum UnaryFuncKind { cfretain, cfrelease, cfmakecollectable };
-
+ enum UnaryFuncKind { cfretain, cfrelease, cfmakecollectable };
+
public:
RetEffect getObjAllocRetEffect() const { return ObjCAllocRetE; }
@@ -659,13 +659,13 @@ public:
RetainSummary *Summ = (RetainSummary*) BPAlloc.Allocate<RetainSummary>();
return new (Summ) RetainSummary(DefaultSummary);
}
-
+
RetainSummary* getUnarySummary(const FunctionType* FT, UnaryFuncKind func);
-
+
RetainSummary* getCFSummaryCreateRule(FunctionDecl* FD);
- RetainSummary* getCFSummaryGetRule(FunctionDecl* FD);
+ RetainSummary* getCFSummaryGetRule(FunctionDecl* FD);
RetainSummary* getCFCreateGetRuleSummary(FunctionDecl* FD, const char* FName);
-
+
RetainSummary* getPersistentSummary(ArgEffects AE, RetEffect RetEff,
ArgEffect ReceiverEff = DoNothing,
ArgEffect DefaultEff = MayEscape,
@@ -676,36 +676,36 @@ public:
ArgEffect DefaultEff = MayEscape) {
return getPersistentSummary(getArgEffects(), RE, ReceiverEff, DefaultEff);
}
-
+
RetainSummary *getPersistentStopSummary() {
if (StopSummary)
return StopSummary;
-
+
StopSummary = getPersistentSummary(RetEffect::MakeNoRet(),
StopTracking, StopTracking);
return StopSummary;
- }
+ }
RetainSummary *getInitMethodSummary(QualType RetTy);
void InitializeClassMethodSummaries();
void InitializeMethodSummaries();
-
+
bool isTrackedObjCObjectType(QualType T);
bool isTrackedCFObjectType(QualType T);
-
+
private:
-
+
void addClsMethSummary(IdentifierInfo* ClsII, Selector S,
RetainSummary* Summ) {
ObjCClassMethodSummaries[ObjCSummaryKey(ClsII, S)] = Summ;
}
-
+
void addNSObjectClsMethSummary(Selector S, RetainSummary *Summ) {
ObjCClassMethodSummaries[S] = Summ;
}
-
+
void addNSObjectMethSummary(Selector S, RetainSummary *Summ) {
ObjCMethodSummaries[S] = Summ;
}
@@ -716,43 +716,43 @@ private:
Selector S = GetNullarySelector(nullaryName, Ctx);
ObjCClassMethodSummaries[ObjCSummaryKey(ClsII, S)] = Summ;
}
-
+
void addInstMethSummary(const char* Cls, const char* nullaryName,
RetainSummary *Summ) {
IdentifierInfo* ClsII = &Ctx.Idents.get(Cls);
Selector S = GetNullarySelector(nullaryName, Ctx);
ObjCMethodSummaries[ObjCSummaryKey(ClsII, S)] = Summ;
}
-
+
Selector generateSelector(va_list argp) {
llvm::SmallVector<IdentifierInfo*, 10> II;
while (const char* s = va_arg(argp, const char*))
II.push_back(&Ctx.Idents.get(s));
- return Ctx.Selectors.getSelector(II.size(), &II[0]);
+ return Ctx.Selectors.getSelector(II.size(), &II[0]);
}
-
+
void addMethodSummary(IdentifierInfo *ClsII, ObjCMethodSummariesTy& Summaries,
RetainSummary* Summ, va_list argp) {
Selector S = generateSelector(argp);
Summaries[ObjCSummaryKey(ClsII, S)] = Summ;
}
-
+
void addInstMethSummary(const char* Cls, RetainSummary* Summ, ...) {
va_list argp;
va_start(argp, Summ);
addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, argp);
- va_end(argp);
+ va_end(argp);
}
-
+
void addClsMethSummary(const char* Cls, RetainSummary* Summ, ...) {
va_list argp;
va_start(argp, Summ);
addMethodSummary(&Ctx.Idents.get(Cls),ObjCClassMethodSummaries, Summ, argp);
va_end(argp);
}
-
+
void addClsMethSummary(IdentifierInfo *II, RetainSummary* Summ, ...) {
va_list argp;
va_start(argp, Summ);
@@ -769,9 +769,9 @@ private:
addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, argp);
va_end(argp);
}
-
+
public:
-
+
RetainSummaryManager(ASTContext& ctx, bool gcenabled)
: Ctx(ctx),
CFDictionaryCreateII(&ctx.Idents.get("CFDictionaryCreate")),
@@ -789,17 +789,17 @@ public:
InitializeClassMethodSummaries();
InitializeMethodSummaries();
}
-
+
~RetainSummaryManager();
-
- RetainSummary* getSummary(FunctionDecl* FD);
-
+
+ RetainSummary* getSummary(FunctionDecl* FD);
+
RetainSummary* getInstanceMethodSummary(ObjCMessageExpr* ME,
const ObjCInterfaceDecl* ID) {
return getInstanceMethodSummary(ME->getSelector(), ME->getClassName(),
- ID, ME->getMethodDecl(), ME->getType());
+ ID, ME->getMethodDecl(), ME->getType());
}
-
+
RetainSummary* getInstanceMethodSummary(Selector S, IdentifierInfo *ClsName,
const ObjCInterfaceDecl* ID,
const ObjCMethodDecl *MD,
@@ -809,7 +809,7 @@ public:
const ObjCInterfaceDecl *ID,
const ObjCMethodDecl *MD,
QualType RetTy);
-
+
RetainSummary *getClassMethodSummary(ObjCMessageExpr *ME) {
return getClassMethodSummary(ME->getSelector(), ME->getClassName(),
ME->getClassInfo().first,
@@ -824,17 +824,17 @@ public:
Selector S = MD->getSelector();
IdentifierInfo *ClsName = ID->getIdentifier();
QualType ResultTy = MD->getResultType();
-
- // Resolve the method decl last.
+
+ // Resolve the method decl last.
if (const ObjCMethodDecl *InterfaceMD = ResolveToInterfaceMethodDecl(MD))
MD = InterfaceMD;
-
+
if (MD->isInstanceMethod())
return getInstanceMethodSummary(S, ClsName, ID, MD, ResultTy);
else
return getClassMethodSummary(S, ClsName, ID, MD, ResultTy);
}
-
+
RetainSummary* getCommonMethodSummary(const ObjCMethodDecl* MD,
Selector S, QualType RetTy);
@@ -845,14 +845,14 @@ public:
const FunctionDecl *FD);
bool isGCEnabled() const { return GCEnabled; }
-
+
RetainSummary *copySummary(RetainSummary *OldSumm) {
RetainSummary *Summ = (RetainSummary*) BPAlloc.Allocate<RetainSummary>();
new (Summ) RetainSummary(*OldSumm);
return Summ;
- }
+ }
};
-
+
} // end anonymous namespace
//===----------------------------------------------------------------------===//
@@ -871,7 +871,7 @@ RetainSummary*
RetainSummaryManager::getPersistentSummary(ArgEffects AE, RetEffect RetEff,
ArgEffect ReceiverEff,
ArgEffect DefaultEff,
- bool isEndPath) {
+ bool isEndPath) {
// Create the summary and return it.
RetainSummary *Summ = (RetainSummary*) BPAlloc.Allocate<RetainSummary>();
new (Summ) RetainSummary(AE, RetEff, DefaultEff, ReceiverEff, isEndPath);
@@ -887,31 +887,31 @@ bool RetainSummaryManager::isTrackedObjCObjectType(QualType Ty) {
return false;
const ObjCObjectPointerType *PT = Ty->getAsObjCObjectPointerType();
-
+
// Can be true for objects with the 'NSObject' attribute.
if (!PT)
return true;
-
+
// We assume that id<..>, id, and "Class" all represent tracked objects.
if (PT->isObjCIdType() || PT->isObjCQualifiedIdType() ||
PT->isObjCClassType())
return true;
- // Does the interface subclass NSObject?
- // FIXME: We can memoize here if this gets too expensive.
- const ObjCInterfaceDecl *ID = PT->getInterfaceDecl();
+ // Does the interface subclass NSObject?
+ // FIXME: We can memoize here if this gets too expensive.
+ const ObjCInterfaceDecl *ID = PT->getInterfaceDecl();
// Assume that anything declared with a forward declaration and no
// @interface subclasses NSObject.
if (ID->isForwardDecl())
return true;
-
+
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
for ( ; ID ; ID = ID->getSuperClass())
if (ID->getIdentifier() == NSObjectII)
return true;
-
+
return false;
}
@@ -945,33 +945,33 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
// No summary? Generate one.
RetainSummary *S = 0;
-
+
do {
// We generate "stop" summaries for implicitly defined functions.
if (FD->isImplicit()) {
S = getPersistentStopSummary();
break;
}
-
+
// [PR 3337] Use 'getAsFunctionType' to strip away any typedefs on the
// function's type.
const FunctionType* FT = FD->getType()->getAsFunctionType();
const char* FName = FD->getIdentifier()->getName();
-
+
// Strip away preceding '_'. Doing this here will effect all the checks
// down below.
while (*FName == '_') ++FName;
-
+
// Inspect the result type.
QualType RetTy = FT->getResultType();
-
+
// FIXME: This should all be refactored into a chain of "summary lookup"
// filters.
assert (ScratchArgs.isEmpty());
-
+
switch (strlen(FName)) {
default: break;
-
+
case 17:
// Handle: id NSMakeCollectable(CFTypeRef)
@@ -1003,10 +1003,10 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
// Part of <rdar://problem/6961230>. (IOKit)
// This should be addressed using a API table.
ScratchArgs = AF.Add(ScratchArgs, 2, DecRef);
- S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
+ S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
}
break;
-
+
case 25:
if (!memcmp(FName, "IORegistryEntryIDMatching", 25)) {
// Part of <rdar://problem/6961230>. (IOKit)
@@ -1015,13 +1015,13 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
DoNothing, DoNothing);
}
break;
-
+
case 26:
if (!memcmp(FName, "IOOpenFirmwarePathMatching", 26)) {
// Part of <rdar://problem/6961230>. (IOKit)
// This should be addressed using a API table.
S = getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true),
- DoNothing, DoNothing);
+ DoNothing, DoNothing);
}
break;
@@ -1030,7 +1030,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
// Part of <rdar://problem/6961230>.
// This should be addressed using a API table.
ScratchArgs = AF.Add(ScratchArgs, 1, DecRef);
- S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
+ S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
}
break;
@@ -1043,17 +1043,17 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
}
break;
-
+
case 32:
if (!memcmp(FName, "IOServiceAddMatchingNotification", 32)) {
// Part of <rdar://problem/6961230>.
// This should be addressed using a API table.
ScratchArgs = AF.Add(ScratchArgs, 2, DecRef);
- S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
+ S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
}
break;
}
-
+
// Did we get a summary?
if (S)
break;
@@ -1063,7 +1063,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
#if 0
// Handle: NSDeallocateObject(id anObject);
// This method does allow 'nil' (although we don't check it now).
- if (strcmp(FName, "NSDeallocateObject") == 0) {
+ if (strcmp(FName, "NSDeallocateObject") == 0) {
return RetTy == Ctx.VoidTy
? getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, Dealloc)
: getPersistentStopSummary();
@@ -1077,7 +1077,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
S = getUnarySummary(FT, cfretain);
else if (strstr(FName, "MakeCollectable"))
S = getUnarySummary(FT, cfmakecollectable);
- else
+ else
S = getCFCreateGetRuleSummary(FD, FName);
break;
@@ -1100,7 +1100,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
S = getCFCreateGetRuleSummary(FD, FName);
break;
}
-
+
break;
}
@@ -1112,7 +1112,7 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
FName += 4;
else
FName += 2;
-
+
if (isRelease(FD, FName))
S = getUnarySummary(FT, cfrelease);
else {
@@ -1122,9 +1122,9 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
// and that ownership cannot be transferred. While this is technically
// correct, many methods allow a tracked object to escape. For example:
//
- // CFMutableDictionaryRef x = CFDictionaryCreateMutable(...);
+ // CFMutableDictionaryRef x = CFDictionaryCreateMutable(...);
// CFDictionaryAddValue(y, key, x);
- // CFRelease(x);
+ // CFRelease(x);
// ... it is okay to use 'x' since 'y' has a reference to it
//
// We handle this and similar cases with the follow heuristic. If the
@@ -1138,34 +1138,34 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
CStrInCStrNoCase(FName, "AppendValue") ||
CStrInCStrNoCase(FName, "SetAttribute"))
? MayEscape : DoNothing;
-
+
S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, E);
}
}
}
while (0);
-
+
if (!S)
S = getDefaultSummary();
// Annotations override defaults.
assert(S);
updateSummaryFromAnnotations(*S, FD);
-
+
FuncSummaries[FD] = S;
- return S;
+ return S;
}
RetainSummary*
RetainSummaryManager::getCFCreateGetRuleSummary(FunctionDecl* FD,
const char* FName) {
-
+
if (strstr(FName, "Create") || strstr(FName, "Copy"))
return getCFSummaryCreateRule(FD);
-
+
if (strstr(FName, "Get"))
return getCFSummaryGetRule(FD);
-
+
return getDefaultSummary();
}
@@ -1178,27 +1178,27 @@ RetainSummaryManager::getUnarySummary(const FunctionType* FT,
const FunctionProtoType* FTP = dyn_cast<FunctionProtoType>(FT);
if (!FTP || FTP->getNumArgs() != 1)
return getPersistentStopSummary();
-
+
assert (ScratchArgs.isEmpty());
-
+
switch (func) {
case cfretain: {
ScratchArgs = AF.Add(ScratchArgs, 0, IncRef);
return getPersistentSummary(RetEffect::MakeAlias(0),
DoNothing, DoNothing);
}
-
+
case cfrelease: {
ScratchArgs = AF.Add(ScratchArgs, 0, DecRef);
return getPersistentSummary(RetEffect::MakeNoRet(),
DoNothing, DoNothing);
}
-
+
case cfmakecollectable: {
ScratchArgs = AF.Add(ScratchArgs, 0, MakeCollectable);
- return getPersistentSummary(RetEffect::MakeAlias(0),DoNothing, DoNothing);
+ return getPersistentSummary(RetEffect::MakeAlias(0),DoNothing, DoNothing);
}
-
+
default:
assert (false && "Not a supported unary function.");
return getDefaultSummary();
@@ -1207,17 +1207,17 @@ RetainSummaryManager::getUnarySummary(const FunctionType* FT,
RetainSummary* RetainSummaryManager::getCFSummaryCreateRule(FunctionDecl* FD) {
assert (ScratchArgs.isEmpty());
-
+
if (FD->getIdentifier() == CFDictionaryCreateII) {
ScratchArgs = AF.Add(ScratchArgs, 1, DoNothingByRef);
ScratchArgs = AF.Add(ScratchArgs, 2, DoNothingByRef);
}
-
+
return getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true));
}
RetainSummary* RetainSummaryManager::getCFSummaryGetRule(FunctionDecl* FD) {
- assert (ScratchArgs.isEmpty());
+ assert (ScratchArgs.isEmpty());
return getPersistentSummary(RetEffect::MakeNotOwned(RetEffect::CF),
DoNothing, DoNothing);
}
@@ -1228,12 +1228,12 @@ RetainSummary* RetainSummaryManager::getCFSummaryGetRule(FunctionDecl* FD) {
RetainSummary*
RetainSummaryManager::getInitMethodSummary(QualType RetTy) {
- assert(ScratchArgs.isEmpty());
+ assert(ScratchArgs.isEmpty());
// 'init' methods conceptually return a newly allocated object and claim
- // the receiver.
+ // the receiver.
if (isTrackedObjCObjectType(RetTy) || isTrackedCFObjectType(RetTy))
return getPersistentSummary(ObjCInitRetE, DecRefMsg);
-
+
return getDefaultSummary();
}
@@ -1244,7 +1244,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
return;
QualType RetTy = FD->getResultType();
-
+
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(RetTy)) {
if (FD->getAttr<NSReturnsRetainedAttr>()) {
@@ -1268,20 +1268,20 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
return;
bool isTrackedLoc = false;
-
+
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(MD->getResultType())) {
if (MD->getAttr<NSReturnsRetainedAttr>()) {
Summ.setRetEffect(ObjCAllocRetE);
return;
}
-
+
isTrackedLoc = true;
}
-
+
if (!isTrackedLoc)
isTrackedLoc = MD->getResultType()->getAs<PointerType>() != NULL;
-
+
if (isTrackedLoc && MD->getAttr<CFReturnsRetainedAttr>())
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
}
@@ -1304,10 +1304,10 @@ RetainSummaryManager::getCommonMethodSummary(const ObjCMethodDecl* MD,
ScratchArgs = AF.Add(ScratchArgs, i, StopTracking);
}
}
-
+
// Any special effect for the receiver?
ArgEffect ReceiverEff = DoNothing;
-
+
// If one of the arguments in the selector has the keyword 'delegate' we
// should stop tracking the reference count for the receiver. This is
// because the reference count is quite possibly handled by a delegate
@@ -1317,29 +1317,29 @@ RetainSummaryManager::getCommonMethodSummary(const ObjCMethodDecl* MD,
assert(!str.empty());
if (CStrInCStrNoCase(&str[0], "delegate:")) ReceiverEff = StopTracking;
}
-
+
// Look for methods that return an owned object.
- if (isTrackedObjCObjectType(RetTy)) {
+ if (isTrackedObjCObjectType(RetTy)) {
// EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
// by instance methods.
RetEffect E = followsFundamentalRule(S)
? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
-
- return getPersistentSummary(E, ReceiverEff, MayEscape);
+
+ return getPersistentSummary(E, ReceiverEff, MayEscape);
}
-
+
// Look for methods that return an owned core foundation object.
if (isTrackedCFObjectType(RetTy)) {
RetEffect E = followsFundamentalRule(S)
? RetEffect::MakeOwned(RetEffect::CF, true)
: RetEffect::MakeNotOwned(RetEffect::CF);
-
+
return getPersistentSummary(E, ReceiverEff, MayEscape);
}
-
+
if (ScratchArgs.isEmpty() && ReceiverEff == DoNothing)
return getDefaultSummary();
-
+
return getPersistentSummary(RetEffect::MakeNoRet(), ReceiverEff, MayEscape);
}
@@ -1352,23 +1352,23 @@ RetainSummaryManager::getInstanceMethodSummary(Selector S,
// Look up a summary in our summary cache.
RetainSummary *Summ = ObjCMethodSummaries.find(ID, ClsName, S);
-
+
if (!Summ) {
assert(ScratchArgs.isEmpty());
-
+
// "initXXX": pass-through for receiver.
if (deriveNamingConvention(S) == InitRule)
Summ = getInitMethodSummary(RetTy);
else
Summ = getCommonMethodSummary(MD, S, RetTy);
-
+
// Annotations override defaults.
updateSummaryFromAnnotations(*Summ, MD);
-
+
// Memoize the summary.
ObjCMethodSummaries[ObjCSummaryKey(ID, ClsName, S)] = Summ;
}
-
+
return Summ;
}
@@ -1379,8 +1379,8 @@ RetainSummaryManager::getClassMethodSummary(Selector S, IdentifierInfo *ClsName,
QualType RetTy) {
assert(ClsName && "Class name must be specified.");
- RetainSummary *Summ = ObjCClassMethodSummaries.find(ID, ClsName, S);
-
+ RetainSummary *Summ = ObjCClassMethodSummaries.find(ID, ClsName, S);
+
if (!Summ) {
Summ = getCommonMethodSummary(MD, S, RetTy);
// Annotations override defaults.
@@ -1388,32 +1388,32 @@ RetainSummaryManager::getClassMethodSummary(Selector S, IdentifierInfo *ClsName,
// Memoize the summary.
ObjCClassMethodSummaries[ObjCSummaryKey(ID, ClsName, S)] = Summ;
}
-
+
return Summ;
}
-void RetainSummaryManager::InitializeClassMethodSummaries() {
+void RetainSummaryManager::InitializeClassMethodSummaries() {
assert(ScratchArgs.isEmpty());
RetainSummary* Summ = getPersistentSummary(ObjCAllocRetE);
-
+
// Create the summaries for "alloc", "new", and "allocWithZone:" for
// NSObject and its derivatives.
addNSObjectClsMethSummary(GetNullarySelector("alloc", Ctx), Summ);
addNSObjectClsMethSummary(GetNullarySelector("new", Ctx), Summ);
addNSObjectClsMethSummary(GetUnarySelector("allocWithZone", Ctx), Summ);
-
- // Create the [NSAssertionHandler currentHander] summary.
+
+ // Create the [NSAssertionHandler currentHander] summary.
addClsMethSummary(&Ctx.Idents.get("NSAssertionHandler"),
GetNullarySelector("currentHandler", Ctx),
getPersistentSummary(RetEffect::MakeNotOwned(RetEffect::ObjC)));
-
+
// Create the [NSAutoreleasePool addObject:] summary.
ScratchArgs = AF.Add(ScratchArgs, 0, Autorelease);
addClsMethSummary(&Ctx.Idents.get("NSAutoreleasePool"),
GetUnarySelector("addObject", Ctx),
getPersistentSummary(RetEffect::MakeNoRet(),
DoNothing, Autorelease));
-
+
// Create the summaries for [NSObject performSelector...]. We treat
// these as 'stop tracking' for the arguments because they are often
// used for delegates that can release the object. When we have better
@@ -1435,7 +1435,7 @@ void RetainSummaryManager::InitializeClassMethodSummaries() {
"withObject", "waitUntilDone", "modes", NULL);
addClsMethSummary(NSObjectII, Summ, "performSelectorInBackground",
"withObject", NULL);
-
+
// Specially handle NSData.
RetainSummary *dataWithBytesNoCopySumm =
getPersistentSummary(RetEffect::MakeNotOwned(RetEffect::ObjC), DoNothing,
@@ -1447,43 +1447,43 @@ void RetainSummaryManager::InitializeClassMethodSummaries() {
}
void RetainSummaryManager::InitializeMethodSummaries() {
-
- assert (ScratchArgs.isEmpty());
-
+
+ assert (ScratchArgs.isEmpty());
+
// Create the "init" selector. It just acts as a pass-through for the
// receiver.
- RetainSummary *InitSumm = getPersistentSummary(ObjCInitRetE, DecRefMsg);
+ RetainSummary *InitSumm = getPersistentSummary(ObjCInitRetE, DecRefMsg);
addNSObjectMethSummary(GetNullarySelector("init", Ctx), InitSumm);
// awakeAfterUsingCoder: behaves basically like an 'init' method. It
// claims the receiver and returns a retained object.
addNSObjectMethSummary(GetUnarySelector("awakeAfterUsingCoder", Ctx),
InitSumm);
-
+
// The next methods are allocators.
RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE);
- RetainSummary *CFAllocSumm =
+ RetainSummary *CFAllocSumm =
getPersistentSummary(RetEffect::MakeOwned(RetEffect::CF, true));
-
- // Create the "copy" selector.
- addNSObjectMethSummary(GetNullarySelector("copy", Ctx), AllocSumm);
+
+ // Create the "copy" selector.
+ addNSObjectMethSummary(GetNullarySelector("copy", Ctx), AllocSumm);
// Create the "mutableCopy" selector.
addNSObjectMethSummary(GetNullarySelector("mutableCopy", Ctx), AllocSumm);
-
+
// Create the "retain" selector.
RetEffect E = RetEffect::MakeReceiverAlias();
RetainSummary *Summ = getPersistentSummary(E, IncRefMsg);
addNSObjectMethSummary(GetNullarySelector("retain", Ctx), Summ);
-
+
// Create the "release" selector.
Summ = getPersistentSummary(E, DecRefMsg);
addNSObjectMethSummary(GetNullarySelector("release", Ctx), Summ);
-
+
// Create the "drain" selector.
Summ = getPersistentSummary(E, isGCEnabled() ? DoNothing : DecRef);
addNSObjectMethSummary(GetNullarySelector("drain", Ctx), Summ);
-
+
// Create the -dealloc summary.
Summ = getPersistentSummary(RetEffect::MakeNoRet(), Dealloc);
addNSObjectMethSummary(GetNullarySelector("dealloc", Ctx), Summ);
@@ -1491,13 +1491,13 @@ void RetainSummaryManager::InitializeMethodSummaries() {
// Create the "autorelease" selector.
Summ = getPersistentSummary(E, Autorelease);
addNSObjectMethSummary(GetNullarySelector("autorelease", Ctx), Summ);
-
+
// Specially handle NSAutoreleasePool.
addInstMethSummary("NSAutoreleasePool", "init",
getPersistentSummary(RetEffect::MakeReceiverAlias(),
NewAutoreleasePool));
-
- // For NSWindow, allocated objects are (initially) self-owned.
+
+ // For NSWindow, allocated objects are (initially) self-owned.
// FIXME: For now we opt for false negatives with NSWindow, as these objects
// self-own themselves. However, they only do this once they are displayed.
// Thus, we need to track an NSWindow's display status.
@@ -1506,42 +1506,42 @@ void RetainSummaryManager::InitializeMethodSummaries() {
RetainSummary *NoTrackYet = getPersistentSummary(RetEffect::MakeNoRet(),
StopTracking,
StopTracking);
-
+
addClassMethSummary("NSWindow", "alloc", NoTrackYet);
#if 0
addInstMethSummary("NSWindow", NoTrackYet, "initWithContentRect",
"styleMask", "backing", "defer", NULL);
-
+
addInstMethSummary("NSWindow", NoTrackYet, "initWithContentRect",
"styleMask", "backing", "defer", "screen", NULL);
#endif
-
+
// For NSPanel (which subclasses NSWindow), allocated objects are not
// self-owned.
// FIXME: For now we don't track NSPanels. object for the same reason
// as for NSWindow objects.
addClassMethSummary("NSPanel", "alloc", NoTrackYet);
-
+
#if 0
addInstMethSummary("NSPanel", NoTrackYet, "initWithContentRect",
"styleMask", "backing", "defer", NULL);
-
+
addInstMethSummary("NSPanel", NoTrackYet, "initWithContentRect",
"styleMask", "backing", "defer", "screen", NULL);
#endif
-
+
// Don't track allocated autorelease pools yet, as it is okay to prematurely
// exit a method.
addClassMethSummary("NSAutoreleasePool", "alloc", NoTrackYet);
// Create NSAssertionHandler summaries.
addPanicSummary("NSAssertionHandler", "handleFailureInFunction", "file",
- "lineNumber", "description", NULL);
-
+ "lineNumber", "description", NULL);
+
addPanicSummary("NSAssertionHandler", "handleFailureInMethod", "object",
"file", "lineNumber", "description", NULL);
-
+
// Create summaries QCRenderer/QCView -createSnapShotImageOfType:
addInstMethSummary("QCRenderer", AllocSumm,
"createSnapshotImageOfType", NULL);
@@ -1554,7 +1554,7 @@ void RetainSummaryManager::InitializeMethodSummaries() {
addInstMethSummary("CIContext", CFAllocSumm,
"createCGImage", "fromRect", NULL);
addInstMethSummary("CIContext", CFAllocSumm,
- "createCGImage", "fromRect", "format", "colorSpace", NULL);
+ "createCGImage", "fromRect", "format", "colorSpace", NULL);
addInstMethSummary("CIContext", CFAllocSumm, "createCGLayerWithSize",
"info", NULL);
}
@@ -1564,19 +1564,19 @@ void RetainSummaryManager::InitializeMethodSummaries() {
//===----------------------------------------------------------------------===//
namespace {
-
+
class VISIBILITY_HIDDEN RefVal {
-public:
+public:
enum Kind {
- Owned = 0, // Owning reference.
- NotOwned, // Reference is not owned by still valid (not freed).
+ Owned = 0, // Owning reference.
+ NotOwned, // Reference is not owned by still valid (not freed).
Released, // Object has been released.
ReturnedOwned, // Returned object passes ownership to caller.
ReturnedNotOwned, // Return object does not pass ownership to caller.
ERROR_START,
ErrorDeallocNotOwned, // -dealloc called on non-owned object.
ErrorDeallocGC, // Calling -dealloc with GC enabled.
- ErrorUseAfterRelease, // Object used after released.
+ ErrorUseAfterRelease, // Object used after released.
ErrorReleaseNotOwned, // Release of an object that was not owned.
ERROR_LEAK_START,
ErrorLeak, // A memory leak due to excessive reference counts.
@@ -1587,7 +1587,7 @@ public:
ErrorReturnedNotOwned
};
-private:
+private:
Kind kind;
RetEffect::ObjKind okind;
unsigned Cnt;
@@ -1600,9 +1600,9 @@ private:
RefVal(Kind k, unsigned cnt = 0)
: kind(k), okind(RetEffect::AnyObj), Cnt(cnt), ACnt(0) {}
-public:
+public:
Kind getKind() const { return kind; }
-
+
RetEffect::ObjKind getObjKind() const { return okind; }
unsigned getCount() const { return Cnt; }
@@ -1611,72 +1611,72 @@ public:
void clearCounts() { Cnt = 0; ACnt = 0; }
void setCount(unsigned i) { Cnt = i; }
void setAutoreleaseCount(unsigned i) { ACnt = i; }
-
+
QualType getType() const { return T; }
-
+
// Useful predicates.
-
+
static bool isError(Kind k) { return k >= ERROR_START; }
-
+
static bool isLeak(Kind k) { return k >= ERROR_LEAK_START; }
-
+
bool isOwned() const {
return getKind() == Owned;
}
-
+
bool isNotOwned() const {
return getKind() == NotOwned;
}
-
+
bool isReturnedOwned() const {
return getKind() == ReturnedOwned;
}
-
+
bool isReturnedNotOwned() const {
return getKind() == ReturnedNotOwned;
}
-
+
bool isNonLeakError() const {
Kind k = getKind();
return isError(k) && !isLeak(k);
}
-
+
static RefVal makeOwned(RetEffect::ObjKind o, QualType t,
unsigned Count = 1) {
return RefVal(Owned, o, Count, 0, t);
}
-
+
static RefVal makeNotOwned(RetEffect::ObjKind o, QualType t,
unsigned Count = 0) {
return RefVal(NotOwned, o, Count, 0, t);
}
-
+
// Comparison, profiling, and pretty-printing.
-
+
bool operator==(const RefVal& X) const {
return kind == X.kind && Cnt == X.Cnt && T == X.T && ACnt == X.ACnt;
}
-
+
RefVal operator-(size_t i) const {
return RefVal(getKind(), getObjKind(), getCount() - i,
getAutoreleaseCount(), getType());
}
-
+
RefVal operator+(size_t i) const {
return RefVal(getKind(), getObjKind(), getCount() + i,
getAutoreleaseCount(), getType());
}
-
+
RefVal operator^(Kind k) const {
return RefVal(k, getObjKind(), getCount(), getAutoreleaseCount(),
getType());
}
-
+
RefVal autorelease() const {
return RefVal(getKind(), getObjKind(), getCount(), getAutoreleaseCount()+1,
getType());
}
-
+
void Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned) kind);
ID.AddInteger(Cnt);
@@ -1686,41 +1686,41 @@ public:
void print(llvm::raw_ostream& Out) const;
};
-
+
void RefVal::print(llvm::raw_ostream& Out) const {
if (!T.isNull())
Out << "Tracked Type:" << T.getAsString() << '\n';
-
+
switch (getKind()) {
default: assert(false);
- case Owned: {
+ case Owned: {
Out << "Owned";
unsigned cnt = getCount();
if (cnt) Out << " (+ " << cnt << ")";
break;
}
-
+
case NotOwned: {
Out << "NotOwned";
unsigned cnt = getCount();
if (cnt) Out << " (+ " << cnt << ")";
break;
}
-
- case ReturnedOwned: {
+
+ case ReturnedOwned: {
Out << "ReturnedOwned";
unsigned cnt = getCount();
if (cnt) Out << " (+ " << cnt << ")";
break;
}
-
+
case ReturnedNotOwned: {
Out << "ReturnedNotOwned";
unsigned cnt = getCount();
if (cnt) Out << " (+ " << cnt << ")";
break;
}
-
+
case Released:
Out << "Released";
break;
@@ -1728,19 +1728,19 @@ void RefVal::print(llvm::raw_ostream& Out) const {
case ErrorDeallocGC:
Out << "-dealloc (GC)";
break;
-
+
case ErrorDeallocNotOwned:
Out << "-dealloc (not-owned)";
break;
-
+
case ErrorLeak:
Out << "Leaked";
- break;
-
+ break;
+
case ErrorLeakReturned:
Out << "Leaked (Bad naming)";
break;
-
+
case ErrorGCLeakReturned:
Out << "Leaked (GC-ed at return)";
break;
@@ -1748,38 +1748,38 @@ void RefVal::print(llvm::raw_ostream& Out) const {
case ErrorUseAfterRelease:
Out << "Use-After-Release [ERROR]";
break;
-
+
case ErrorReleaseNotOwned:
Out << "Release of Not-Owned [ERROR]";
break;
-
+
case RefVal::ErrorOverAutorelease:
Out << "Over autoreleased";
break;
-
+
case RefVal::ErrorReturnedNotOwned:
Out << "Non-owned object returned instead of owned";
break;
}
-
+
if (ACnt) {
Out << " [ARC +" << ACnt << ']';
}
}
-
+
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// RefBindings - State used to track object reference counts.
//===----------------------------------------------------------------------===//
-
+
typedef llvm::ImmutableMap<SymbolRef, RefVal> RefBindings;
static int RefBIndex = 0;
namespace clang {
template<>
struct GRStateTrait<RefBindings> : public GRStatePartialTrait<RefBindings> {
- static inline void* GDMIndex() { return &RefBIndex; }
+ static inline void* GDMIndex() { return &RefBIndex; }
};
}
@@ -1800,12 +1800,12 @@ namespace { class VISIBILITY_HIDDEN AutoreleaseStack {}; }
namespace clang {
template<> struct GRStateTrait<AutoreleaseStack>
: public GRStatePartialTrait<ARStack> {
- static inline void* GDMIndex() { return &AutoRBIndex; }
+ static inline void* GDMIndex() { return &AutoRBIndex; }
};
template<> struct GRStateTrait<AutoreleasePoolContents>
: public GRStatePartialTrait<ARPoolContents> {
- static inline void* GDMIndex() { return &AutoRCIndex; }
+ static inline void* GDMIndex() { return &AutoRCIndex; }
};
} // end clang namespace
@@ -1820,14 +1820,14 @@ static const GRState * SendAutorelease(const GRState *state,
SymbolRef pool = GetCurrentAutoreleasePool(state);
const ARCounts *cnts = state->get<AutoreleasePoolContents>(pool);
ARCounts newCnts(0);
-
+
if (cnts) {
const unsigned *cnt = (*cnts).lookup(sym);
newCnts = F.Add(*cnts, sym, cnt ? *cnt + 1 : 1);
}
else
newCnts = F.Add(F.GetEmptyMap(), sym, 1);
-
+
return state->set<AutoreleasePoolContents>(pool, newCnts);
}
@@ -1836,7 +1836,7 @@ static const GRState * SendAutorelease(const GRState *state,
//===----------------------------------------------------------------------===//
namespace {
-
+
class VISIBILITY_HIDDEN CFRefCount : public GRTransferFuncs {
public:
class BindingsPrinter : public GRState::Printer {
@@ -1847,9 +1847,9 @@ public:
private:
typedef llvm::DenseMap<const ExplodedNode*, const RetainSummary*>
- SummaryLogTy;
+ SummaryLogTy;
- RetainSummaryManager Summaries;
+ RetainSummaryManager Summaries;
SummaryLogTy SummaryLog;
const LangOptions& LOpts;
ARCounts::Factory ARCountFactory;
@@ -1860,7 +1860,7 @@ private:
BugType *overAutorelease;
BugType *returnNotOwnedForOwned;
BugReporter *BR;
-
+
const GRState * Update(const GRState * state, SymbolRef sym, RefVal V, ArgEffect E,
RefVal::Kind& hasErr);
@@ -1870,40 +1870,40 @@ private:
ExplodedNode* Pred,
const GRState* St,
RefVal::Kind hasErr, SymbolRef Sym);
-
+
const GRState * HandleSymbolDeath(const GRState * state, SymbolRef sid, RefVal V,
llvm::SmallVectorImpl<SymbolRef> &Leaked);
-
+
ExplodedNode* ProcessLeaks(const GRState * state,
llvm::SmallVectorImpl<SymbolRef> &Leaked,
GenericNodeBuilder &Builder,
GRExprEngine &Eng,
ExplodedNode *Pred = 0);
-
-public:
+
+public:
CFRefCount(ASTContext& Ctx, bool gcenabled, const LangOptions& lopts)
: Summaries(Ctx, gcenabled),
LOpts(lopts), useAfterRelease(0), releaseNotOwned(0),
deallocGC(0), deallocNotOwned(0),
leakWithinFunction(0), leakAtReturn(0), overAutorelease(0),
returnNotOwnedForOwned(0), BR(0) {}
-
+
virtual ~CFRefCount() {}
-
+
void RegisterChecks(BugReporter &BR);
-
+
virtual void RegisterPrinters(std::vector<GRState::Printer*>& Printers) {
Printers.push_back(new BindingsPrinter());
}
-
+
bool isGCEnabled() const { return Summaries.isGCEnabled(); }
const LangOptions& getLangOptions() const { return LOpts; }
-
+
const RetainSummary *getSummaryOfNode(const ExplodedNode *N) const {
SummaryLogTy::const_iterator I = SummaryLog.find(N);
return I == SummaryLog.end() ? 0 : I->second;
}
-
+
// Calls.
void EvalSummary(ExplodedNodeSet& Dst,
@@ -1914,47 +1914,47 @@ public:
const RetainSummary& Summ,
ExprIterator arg_beg, ExprIterator arg_end,
ExplodedNode* Pred);
-
+
virtual void EvalCall(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
GRStmtNodeBuilder& Builder,
CallExpr* CE, SVal L,
- ExplodedNode* Pred);
-
-
+ ExplodedNode* Pred);
+
+
virtual void EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
-
+
bool EvalObjCMessageExprAux(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
ExplodedNode* Pred);
- // Stores.
+ // Stores.
virtual void EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val);
// End-of-path.
-
+
virtual void EvalEndPath(GRExprEngine& Engine,
GREndPathNodeBuilder& Builder);
-
+
virtual void EvalDeadSymbols(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
ExplodedNode* Pred,
Stmt* S, const GRState* state,
SymbolReaper& SymReaper);
-
+
std::pair<ExplodedNode*, const GRState *>
HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd,
ExplodedNode* Pred, GRExprEngine &Eng,
SymbolRef Sym, RefVal V, bool &stop);
// Return statements.
-
+
virtual void EvalReturn(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
@@ -1977,34 +1977,34 @@ static void PrintPool(llvm::raw_ostream &Out, SymbolRef Sym,
else
Out << "<pool>";
Out << ":{";
-
+
// Get the contents of the pool.
if (const ARCounts *cnts = state->get<AutoreleasePoolContents>(Sym))
for (ARCounts::iterator J=cnts->begin(), EJ=cnts->end(); J != EJ; ++J)
Out << '(' << J.getKey() << ',' << J.getData() << ')';
- Out << '}';
+ Out << '}';
}
void CFRefCount::BindingsPrinter::Print(llvm::raw_ostream& Out,
const GRState* state,
const char* nl, const char* sep) {
-
+
RefBindings B = state->get<RefBindings>();
-
+
if (!B.isEmpty())
Out << sep << nl;
-
+
for (RefBindings::iterator I=B.begin(), E=B.end(); I!=E; ++I) {
Out << (*I).first << " : ";
(*I).second.print(Out);
Out << nl;
}
-
+
// Print the autorelease stack.
Out << sep << nl << "AR pool stack:";
ARStack stack = state->get<AutoreleaseStack>();
-
+
PrintPool(Out, SymbolRef(), state); // Print the caller's pool.
for (ARStack::iterator I=stack.begin(), E=stack.end(); I!=E; ++I)
PrintPool(Out, *I, state);
@@ -2017,117 +2017,117 @@ void CFRefCount::BindingsPrinter::Print(llvm::raw_ostream& Out,
//===----------------------------------------------------------------------===//
namespace {
-
+
//===-------------===//
// Bug Descriptions. //
- //===-------------===//
-
+ //===-------------===//
+
class VISIBILITY_HIDDEN CFRefBug : public BugType {
protected:
CFRefCount& TF;
-
- CFRefBug(CFRefCount* tf, const char* name)
- : BugType(name, "Memory (Core Foundation/Objective-C)"), TF(*tf) {}
+
+ CFRefBug(CFRefCount* tf, const char* name)
+ : BugType(name, "Memory (Core Foundation/Objective-C)"), TF(*tf) {}
public:
-
+
CFRefCount& getTF() { return TF; }
const CFRefCount& getTF() const { return TF; }
-
+
// FIXME: Eventually remove.
virtual const char* getDescription() const = 0;
-
+
virtual bool isLeak() const { return false; }
};
-
+
class VISIBILITY_HIDDEN UseAfterRelease : public CFRefBug {
public:
UseAfterRelease(CFRefCount* tf)
: CFRefBug(tf, "Use-after-release") {}
-
+
const char* getDescription() const {
return "Reference-counted object is used after it is released";
- }
+ }
};
-
+
class VISIBILITY_HIDDEN BadRelease : public CFRefBug {
public:
BadRelease(CFRefCount* tf) : CFRefBug(tf, "Bad release") {}
-
+
const char* getDescription() const {
return "Incorrect decrement of the reference count of an "
"object is not owned at this point by the caller";
}
};
-
+
class VISIBILITY_HIDDEN DeallocGC : public CFRefBug {
public:
DeallocGC(CFRefCount *tf)
: CFRefBug(tf, "-dealloc called while using garbage collection") {}
-
+
const char *getDescription() const {
return "-dealloc called while using garbage collection";
}
};
-
+
class VISIBILITY_HIDDEN DeallocNotOwned : public CFRefBug {
public:
DeallocNotOwned(CFRefCount *tf)
: CFRefBug(tf, "-dealloc sent to non-exclusively owned object") {}
-
+
const char *getDescription() const {
return "-dealloc sent to object that may be referenced elsewhere";
}
- };
-
+ };
+
class VISIBILITY_HIDDEN OverAutorelease : public CFRefBug {
public:
- OverAutorelease(CFRefCount *tf) :
+ OverAutorelease(CFRefCount *tf) :
CFRefBug(tf, "Object sent -autorelease too many times") {}
-
+
const char *getDescription() const {
return "Object sent -autorelease too many times";
}
};
-
+
class VISIBILITY_HIDDEN ReturnedNotOwnedForOwned : public CFRefBug {
public:
ReturnedNotOwnedForOwned(CFRefCount *tf) :
CFRefBug(tf, "Method should return an owned object") {}
-
+
const char *getDescription() const {
return "Object with +0 retain counts returned to caller where a +1 "
"(owning) retain count is expected";
}
};
-
+
class VISIBILITY_HIDDEN Leak : public CFRefBug {
const bool isReturn;
protected:
Leak(CFRefCount* tf, const char* name, bool isRet)
: CFRefBug(tf, name), isReturn(isRet) {}
public:
-
+
const char* getDescription() const { return ""; }
-
+
bool isLeak() const { return true; }
};
-
+
class VISIBILITY_HIDDEN LeakAtReturn : public Leak {
public:
LeakAtReturn(CFRefCount* tf, const char* name)
: Leak(tf, name, true) {}
};
-
+
class VISIBILITY_HIDDEN LeakWithinFunction : public Leak {
public:
LeakWithinFunction(CFRefCount* tf, const char* name)
: Leak(tf, name, false) {}
- };
-
+ };
+
//===---------===//
// Bug Reports. //
//===---------===//
-
+
class VISIBILITY_HIDDEN CFRefReport : public RangedBugReport {
protected:
SymbolRef Sym;
@@ -2140,30 +2140,30 @@ namespace {
CFRefReport(CFRefBug& D, const CFRefCount &tf,
ExplodedNode *n, SymbolRef sym, const char* endText)
: RangedBugReport(D, D.getDescription(), endText, n), Sym(sym), TF(tf) {}
-
+
virtual ~CFRefReport() {}
-
+
CFRefBug& getBugType() {
return (CFRefBug&) RangedBugReport::getBugType();
}
const CFRefBug& getBugType() const {
return (const CFRefBug&) RangedBugReport::getBugType();
}
-
+
virtual void getRanges(const SourceRange*& beg, const SourceRange*& end) {
if (!getBugType().isLeak())
RangedBugReport::getRanges(beg, end);
else
beg = end = 0;
}
-
+
SymbolRef getSymbol() const { return Sym; }
-
+
PathDiagnosticPiece* getEndPath(BugReporterContext& BRC,
const ExplodedNode* N);
-
+
std::pair<const char**,const char**> getExtraDescriptiveText();
-
+
PathDiagnosticPiece* VisitNode(const ExplodedNode* N,
const ExplodedNode* PrevN,
BugReporterContext& BRC);
@@ -2176,36 +2176,36 @@ namespace {
CFRefLeakReport(CFRefBug& D, const CFRefCount &tf,
ExplodedNode *n, SymbolRef sym,
GRExprEngine& Eng);
-
+
PathDiagnosticPiece* getEndPath(BugReporterContext& BRC,
const ExplodedNode* N);
-
+
SourceLocation getLocation() const { return AllocSite; }
- };
+ };
} // end anonymous namespace
void CFRefCount::RegisterChecks(BugReporter& BR) {
useAfterRelease = new UseAfterRelease(this);
BR.Register(useAfterRelease);
-
+
releaseNotOwned = new BadRelease(this);
BR.Register(releaseNotOwned);
-
+
deallocGC = new DeallocGC(this);
BR.Register(deallocGC);
-
+
deallocNotOwned = new DeallocNotOwned(this);
BR.Register(deallocNotOwned);
-
+
overAutorelease = new OverAutorelease(this);
BR.Register(overAutorelease);
-
+
returnNotOwnedForOwned = new ReturnedNotOwnedForOwned(this);
BR.Register(returnNotOwnedForOwned);
-
+
// First register "return" leaks.
const char* name = 0;
-
+
if (isGCEnabled())
name = "Leak of returned object when using garbage collection";
else if (getLangOptions().getGCMode() == LangOptions::HybridGC)
@@ -2215,13 +2215,13 @@ void CFRefCount::RegisterChecks(BugReporter& BR) {
assert(getLangOptions().getGCMode() == LangOptions::NonGC);
name = "Leak of returned object";
}
-
+
leakAtReturn = new LeakAtReturn(this, name);
BR.Register(leakAtReturn);
-
+
// Second, register leaks within a function/method.
if (isGCEnabled())
- name = "Leak of object when using garbage collection";
+ name = "Leak of object when using garbage collection";
else if (getLangOptions().getGCMode() == LangOptions::HybridGC)
name = "Leak of object when not using garbage collection (GC) in "
"dual GC/non-GC code";
@@ -2229,22 +2229,22 @@ void CFRefCount::RegisterChecks(BugReporter& BR) {
assert(getLangOptions().getGCMode() == LangOptions::NonGC);
name = "Leak";
}
-
+
leakWithinFunction = new LeakWithinFunction(this, name);
BR.Register(leakWithinFunction);
-
+
// Save the reference to the BugReporter.
this->BR = &BR;
}
static const char* Msgs[] = {
// GC only
- "Code is compiled to only use garbage collection",
+ "Code is compiled to only use garbage collection",
// No GC.
"Code is compiled to use reference counts",
// Hybrid, with GC.
"Code is compiled to use either garbage collection (GC) or reference counts"
- " (non-GC). The bug occurs with GC enabled",
+ " (non-GC). The bug occurs with GC enabled",
// Hybrid, without GC
"Code is compiled to use either garbage collection (GC) or reference counts"
" (non-GC). The bug occurs in non-GC mode"
@@ -2252,19 +2252,19 @@ static const char* Msgs[] = {
std::pair<const char**,const char**> CFRefReport::getExtraDescriptiveText() {
CFRefCount& TF = static_cast<CFRefBug&>(getBugType()).getTF();
-
+
switch (TF.getLangOptions().getGCMode()) {
default:
assert(false);
-
+
case LangOptions::GCOnly:
assert (TF.isGCEnabled());
- return std::make_pair(&Msgs[0], &Msgs[0]+1);
-
+ return std::make_pair(&Msgs[0], &Msgs[0]+1);
+
case LangOptions::NonGC:
assert (!TF.isGCEnabled());
return std::make_pair(&Msgs[1], &Msgs[1]+1);
-
+
case LangOptions::HybridGC:
if (TF.isGCEnabled())
return std::make_pair(&Msgs[2], &Msgs[2]+1);
@@ -2278,50 +2278,50 @@ static inline bool contains(const llvm::SmallVectorImpl<ArgEffect>& V,
for (llvm::SmallVectorImpl<ArgEffect>::const_iterator I=V.begin(), E=V.end();
I!=E; ++I)
if (*I == X) return true;
-
+
return false;
}
PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
const ExplodedNode* PrevN,
BugReporterContext& BRC) {
-
+
if (!isa<PostStmt>(N->getLocation()))
return NULL;
-
+
// Check if the type state has changed.
const GRState *PrevSt = PrevN->getState();
const GRState *CurrSt = N->getState();
-
- const RefVal* CurrT = CurrSt->get<RefBindings>(Sym);
+
+ const RefVal* CurrT = CurrSt->get<RefBindings>(Sym);
if (!CurrT) return NULL;
-
+
const RefVal &CurrV = *CurrT;
const RefVal *PrevT = PrevSt->get<RefBindings>(Sym);
-
+
// Create a string buffer to constain all the useful things we want
// to tell the user.
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
// This is the allocation site since the previous node had no bindings
// for this symbol.
if (!PrevT) {
const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
-
+
if (const CallExpr *CE = dyn_cast<CallExpr>(S)) {
// Get the name of the callee (if it is available).
SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee());
if (const FunctionDecl* FD = X.getAsFunctionDecl())
os << "Call to function '" << FD->getNameAsString() <<'\'';
else
- os << "function call";
- }
+ os << "function call";
+ }
else {
assert (isa<ObjCMessageExpr>(S));
os << "Method";
}
-
+
if (CurrV.getObjKind() == RetEffect::CF) {
os << " returns a Core Foundation object with a ";
}
@@ -2329,10 +2329,10 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
assert (CurrV.getObjKind() == RetEffect::ObjC);
os << " returns an Objective-C object with a ";
}
-
+
if (CurrV.isOwned()) {
os << "+1 retain count (owning reference).";
-
+
if (static_cast<CFRefBug&>(getBugType()).getTF().isGCEnabled()) {
assert(CurrV.getObjKind() == RetEffect::CF);
os << " "
@@ -2343,39 +2343,39 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
assert (CurrV.isNotOwned());
os << "+0 retain count (non-owning reference).";
}
-
+
PathDiagnosticLocation Pos(S, BRC.getSourceManager());
return new PathDiagnosticEventPiece(Pos, os.str());
}
-
+
// Gather up the effects that were performed on the object at this
// program point
llvm::SmallVector<ArgEffect, 2> AEffects;
-
+
if (const RetainSummary *Summ =
TF.getSummaryOfNode(BRC.getNodeResolver().getOriginalNode(N))) {
// We only have summaries attached to nodes after evaluating CallExpr and
// ObjCMessageExprs.
const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
-
+
if (const CallExpr *CE = dyn_cast<CallExpr>(S)) {
// Iterate through the parameter expressions and see if the symbol
// was ever passed as an argument.
unsigned i = 0;
-
+
for (CallExpr::const_arg_iterator AI=CE->arg_begin(), AE=CE->arg_end();
AI!=AE; ++AI, ++i) {
-
+
// Retrieve the value of the argument. Is it the symbol
// we are interested in?
if (CurrSt->getSValAsScalarOrLoc(*AI).getAsLocSymbol() != Sym)
continue;
-
+
// We have an argument. Get the effect!
AEffects.push_back(Summ->getArg(i));
}
}
- else if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S)) {
+ else if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(S)) {
if (const Expr *receiver = ME->getReceiver())
if (CurrSt->getSValAsScalarOrLoc(receiver).getAsLocSymbol() == Sym) {
// The symbol we are tracking is the receiver.
@@ -2383,11 +2383,11 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
}
}
}
-
+
do {
// Get the previous type state.
RefVal PrevV = *PrevT;
-
+
// Specially handle -dealloc.
if (!TF.isGCEnabled() && contains(AEffects, Dealloc)) {
// Determine if the object's reference count was pushed to zero.
@@ -2400,7 +2400,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
break;
}
}
-
+
// Specially handle CFMakeCollectable and friends.
if (contains(AEffects, MakeCollectable)) {
// Get the name of the function.
@@ -2408,15 +2408,15 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
SVal X = CurrSt->getSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
const FunctionDecl* FD = X.getAsFunctionDecl();
const std::string& FName = FD->getNameAsString();
-
+
if (TF.isGCEnabled()) {
// Determine if the object's reference count was pushed to zero.
assert(!(PrevV == CurrV) && "The typestate *must* have changed.");
-
+
os << "In GC mode a call to '" << FName
<< "' decrements an object's retain count and registers the "
"object with the garbage collector. ";
-
+
if (CurrV.getKind() == RefVal::Released) {
assert(CurrV.getCount() == 0);
os << "Since it now has a 0 retain count the object can be "
@@ -2427,67 +2427,67 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
"After this call its retain count is +" << CurrV.getCount()
<< '.';
}
- else
+ else
os << "When GC is not enabled a call to '" << FName
<< "' has no effect on its argument.";
-
+
// Nothing more to say.
break;
}
-
- // Determine if the typestate has changed.
+
+ // Determine if the typestate has changed.
if (!(PrevV == CurrV))
switch (CurrV.getKind()) {
case RefVal::Owned:
case RefVal::NotOwned:
-
+
if (PrevV.getCount() == CurrV.getCount()) {
// Did an autorelease message get sent?
if (PrevV.getAutoreleaseCount() == CurrV.getAutoreleaseCount())
return 0;
-
+
assert(PrevV.getAutoreleaseCount() < CurrV.getAutoreleaseCount());
os << "Object sent -autorelease message";
break;
}
-
+
if (PrevV.getCount() > CurrV.getCount())
os << "Reference count decremented.";
else
os << "Reference count incremented.";
-
+
if (unsigned Count = CurrV.getCount())
os << " The object now has a +" << Count << " retain count.";
-
+
if (PrevV.getKind() == RefVal::Released) {
assert(TF.isGCEnabled() && CurrV.getCount() > 0);
os << " The object is not eligible for garbage collection until the "
"retain count reaches 0 again.";
}
-
+
break;
-
+
case RefVal::Released:
os << "Object released.";
break;
-
+
case RefVal::ReturnedOwned:
os << "Object returned to caller as an owning reference (single retain "
"count transferred to caller).";
break;
-
+
case RefVal::ReturnedNotOwned:
os << "Object returned to caller with a +0 (non-owning) retain count.";
break;
-
+
default:
return NULL;
}
-
+
// Emit any remaining diagnostics for the argument effects (if any).
for (llvm::SmallVectorImpl<ArgEffect>::iterator I=AEffects.begin(),
E=AEffects.end(); I != E; ++I) {
-
+
// A bunch of things have alternate behavior under GC.
if (TF.isGCEnabled())
switch (*I) {
@@ -2503,25 +2503,25 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
continue;
}
}
- } while(0);
-
+ } while (0);
+
if (os.str().empty())
return 0; // We have nothing to say!
const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
PathDiagnosticLocation Pos(S, BRC.getSourceManager());
PathDiagnosticPiece* P = new PathDiagnosticEventPiece(Pos, os.str());
-
+
// Add the range by scanning the children of the statement for any bindings
// to Sym.
- for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
+ for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
I!=E; ++I)
if (const Expr* Exp = dyn_cast_or_null<Expr>(*I))
if (CurrSt->getSValAsScalarOrLoc(Exp).getAsLocSymbol() == Sym) {
P->addRange(Exp->getSourceRange());
break;
}
-
+
return P;
}
@@ -2531,56 +2531,56 @@ namespace {
SymbolRef Sym;
const MemRegion* Binding;
bool First;
-
+
public:
FindUniqueBinding(SymbolRef sym) : Sym(sym), Binding(0), First(true) {}
-
+
bool HandleBinding(StoreManager& SMgr, Store store, const MemRegion* R,
SVal val) {
-
- SymbolRef SymV = val.getAsSymbol();
+
+ SymbolRef SymV = val.getAsSymbol();
if (!SymV || SymV != Sym)
return true;
-
+
if (Binding) {
First = false;
return false;
}
else
Binding = R;
-
- return true;
+
+ return true;
}
-
+
operator bool() { return First && Binding; }
const MemRegion* getRegion() { return Binding; }
- };
+ };
}
static std::pair<const ExplodedNode*,const MemRegion*>
GetAllocationSite(GRStateManager& StateMgr, const ExplodedNode* N,
SymbolRef Sym) {
-
+
// Find both first node that referred to the tracked symbol and the
// memory location that value was store to.
const ExplodedNode* Last = N;
- const MemRegion* FirstBinding = 0;
-
+ const MemRegion* FirstBinding = 0;
+
while (N) {
const GRState* St = N->getState();
RefBindings B = St->get<RefBindings>();
-
+
if (!B.lookup(Sym))
break;
-
+
FindUniqueBinding FB(Sym);
- StateMgr.iterBindings(St, FB);
- if (FB) FirstBinding = FB.getRegion();
-
+ StateMgr.iterBindings(St, FB);
+ if (FB) FirstBinding = FB.getRegion();
+
Last = N;
- N = N->pred_empty() ? NULL : *(N->pred_begin());
+ N = N->pred_empty() ? NULL : *(N->pred_begin());
}
-
+
return std::make_pair(Last, FirstBinding);
}
@@ -2596,36 +2596,36 @@ CFRefReport::getEndPath(BugReporterContext& BRC,
PathDiagnosticPiece*
CFRefLeakReport::getEndPath(BugReporterContext& BRC,
const ExplodedNode* EndN){
-
+
// Tell the BugReporterContext to report cases when the tracked symbol is
// assigned to different variables, etc.
BRC.addNotableSymbol(Sym);
-
+
// We are reporting a leak. Walk up the graph to get to the first node where
// the symbol appeared, and also get the first VarDecl that tracked object
// is stored to.
const ExplodedNode* AllocNode = 0;
const MemRegion* FirstBinding = 0;
-
+
llvm::tie(AllocNode, FirstBinding) =
GetAllocationSite(BRC.getStateManager(), EndN, Sym);
-
- // Get the allocate site.
+
+ // Get the allocate site.
assert(AllocNode);
const Stmt* FirstStmt = cast<PostStmt>(AllocNode->getLocation()).getStmt();
-
+
SourceManager& SMgr = BRC.getSourceManager();
unsigned AllocLine =SMgr.getInstantiationLineNumber(FirstStmt->getLocStart());
-
+
// Compute an actual location for the leak. Sometimes a leak doesn't
// occur at an actual statement (e.g., transition between blocks; end
// of function) so we need to walk the graph and compute a real location.
const ExplodedNode* LeakN = EndN;
PathDiagnosticLocation L;
-
+
while (LeakN) {
ProgramPoint P = LeakN->getLocation();
-
+
if (const PostStmt *PS = dyn_cast<PostStmt>(&P)) {
L = PathDiagnosticLocation(PS->getStmt()->getLocStart(), SMgr);
break;
@@ -2636,26 +2636,26 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC,
break;
}
}
-
+
LeakN = LeakN->succ_empty() ? 0 : *(LeakN->succ_begin());
}
-
+
if (!L.isValid()) {
const Decl &D = BRC.getCodeDecl();
L = PathDiagnosticLocation(D.getBodyRBrace(), SMgr);
}
-
+
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "Object allocated on line " << AllocLine;
-
+
if (FirstBinding)
- os << " and stored into '" << FirstBinding->getString() << '\'';
-
+ os << " and stored into '" << FirstBinding->getString() << '\'';
+
// Get the retain count.
const RefVal* RV = EndN->getState()->get<RefBindings>(Sym);
-
+
if (RV->getKind() == RefVal::ErrorLeakReturned) {
// FIXME: Per comments in rdar://6320065, "create" only applies to CF
// ojbects. Only "copy", "alloc", "retain" and "new" transfer ownership
@@ -2678,16 +2678,15 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC,
else
os << " is no longer referenced after this point and has a retain count of"
" +" << RV->getCount() << " (object leaked)";
-
+
return new PathDiagnosticEventPiece(L, os.str());
}
CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf,
ExplodedNode *n,
SymbolRef sym, GRExprEngine& Eng)
-: CFRefReport(D, tf, n, sym)
-{
-
+: CFRefReport(D, tf, n, sym) {
+
// Most bug reports are cached at the location where they occured.
// With leaks, we want to unique them by the location where they were
// allocated, and only report a single path. To do this, we need to find
@@ -2697,14 +2696,14 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf,
// that all ancestor nodes that represent the allocation site have the
// same SourceLocation.
const ExplodedNode* AllocNode = 0;
-
+
llvm::tie(AllocNode, AllocBinding) = // Set AllocBinding.
GetAllocationSite(Eng.getStateManager(), getEndNode(), getSymbol());
-
+
// Get the SourceLocation for the allocation site.
ProgramPoint P = AllocNode->getLocation();
AllocSite = cast<PostStmt>(P).getStmt()->getLocStart();
-
+
// Fill in the description of the bug.
Description.clear();
llvm::raw_string_ostream os(Description);
@@ -2713,9 +2712,9 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf,
os << "Potential leak ";
if (tf.isGCEnabled()) {
os << "(when using garbage collection) ";
- }
+ }
os << "of an object allocated on line " << AllocLine;
-
+
// FIXME: AllocBinding doesn't get populated for RegionStore yet.
if (AllocBinding)
os << " and stored into '" << AllocBinding->getString() << '\'';
@@ -2737,16 +2736,16 @@ static QualType GetReturnType(const Expr* RetE, ASTContext& Ctx) {
/// more specific than id.
if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(RetE))
if (const ObjCObjectPointerType *PT = RetTy->getAsObjCObjectPointerType())
- if (PT->isObjCQualifiedIdType() || PT->isObjCIdType() ||
+ if (PT->isObjCQualifiedIdType() || PT->isObjCIdType() ||
PT->isObjCClassType()) {
// At this point we know the return type of the message expression is
// id, id<...>, or Class. If we have an ObjCInterfaceDecl, we know this
// is a call to a class method whose type we can resolve. In such
// cases, promote the return type to XXX* (where XXX is the class).
- const ObjCInterfaceDecl *D = ME->getClassInfo().first;
+ const ObjCInterfaceDecl *D = ME->getClassInfo().first;
return !D ? RetTy : Ctx.getPointerType(Ctx.getObjCInterfaceType(D));
}
-
+
return RetTy;
}
@@ -2758,7 +2757,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
const RetainSummary& Summ,
ExprIterator arg_beg, ExprIterator arg_end,
ExplodedNode* Pred) {
-
+
// Get the state.
const GRState *state = Builder.GetState(Pred);
@@ -2766,10 +2765,10 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
RefVal::Kind hasErr = (RefVal::Kind) 0;
unsigned idx = 0;
Expr* ErrorExpr = NULL;
- SymbolRef ErrorSym = 0;
-
- for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) {
- SVal V = state->getSValAsScalarOrLoc(*I);
+ SymbolRef ErrorSym = 0;
+
+ for (ExprIterator I = arg_beg; I != arg_end; ++I, ++idx) {
+ SVal V = state->getSValAsScalarOrLoc(*I);
SymbolRef Sym = V.getAsLocSymbol();
if (Sym)
@@ -2779,7 +2778,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
ErrorExpr = *I;
ErrorSym = Sym;
break;
- }
+ }
continue;
}
@@ -2787,14 +2786,14 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
if (loc::MemRegionVal* MR = dyn_cast<loc::MemRegionVal>(&V)) {
if (Summ.getArg(idx) == DoNothingByRef)
continue;
-
- // Invalidate the value of the variable passed by reference.
-
+
+ // Invalidate the value of the variable passed by reference.
+
// FIXME: We can have collisions on the conjured symbol if the
// expression *I also creates conjured symbols. We probably want
// to identify conjured symbols by an expression pair: the enclosing
// expression (the context) and the expression itself. This should
- // disambiguate conjured symbols.
+ // disambiguate conjured symbols.
unsigned Count = Builder.getCurrentBlockCount();
StoreManager& StoreMgr = Eng.getStateManager().getStoreManager();
@@ -2825,9 +2824,9 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
// Is the invalidated variable something that we were tracking?
SymbolRef Sym = state->getSValAsScalarOrLoc(R).getAsLocSymbol();
-
+
// Remove any existing reference-count binding.
- if (Sym)
+ if (Sym)
state = state->remove<RefBindings>(Sym);
state = StoreMgr.InvalidateRegion(state, R, *I, Count);
@@ -2845,9 +2844,9 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
// We should bind it to UnknownVal explicitly. Otherwise default value
// may be loaded.
state = state->unbindLoc(cast<nonloc::LocAsInteger>(V).getLoc());
- }
-
- // Evaluate the effect on the message receiver.
+ }
+
+ // Evaluate the effect on the message receiver.
if (!ErrorExpr && Receiver) {
SymbolRef Sym = state->getSValAsScalarOrLoc(Receiver).getAsLocSymbol();
if (Sym) {
@@ -2860,17 +2859,17 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
}
}
}
-
- // Process any errors.
+
+ // Process any errors.
if (hasErr) {
ProcessNonLeakError(Dst, Builder, Ex, ErrorExpr, Pred, state,
hasErr, ErrorSym);
return;
}
-
- // Consult the summary for the return value.
+
+ // Consult the summary for the return value.
RetEffect RE = Summ.getRetEffect();
-
+
if (RE.getKind() == RetEffect::OwnedWhenTrackedReceiver) {
assert(Receiver);
SVal V = state->getSValAsScalarOrLoc(Receiver);
@@ -2883,32 +2882,32 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
if (!found)
RE = RetEffect::MakeNoRet();
- }
-
+ }
+
switch (RE.getKind()) {
default:
assert (false && "Unhandled RetEffect."); break;
-
- case RetEffect::NoRet: {
+
+ case RetEffect::NoRet: {
// Make up a symbol for the return value (not reference counted).
// FIXME: Most of this logic is not specific to the retain/release
// checker.
-
+
// FIXME: We eventually should handle structs and other compound types
// that are returned by value.
-
+
QualType T = Ex->getType();
-
+
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
unsigned Count = Builder.getCurrentBlockCount();
ValueManager &ValMgr = Eng.getValueManager();
SVal X = ValMgr.getConjuredSymbolVal(Ex, T, Count);
state = state->BindExpr(Ex, X, false);
- }
-
+ }
+
break;
}
-
+
case RetEffect::Alias: {
unsigned idx = RE.getIndex();
assert (arg_end >= arg_beg);
@@ -2917,20 +2916,20 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
state = state->BindExpr(Ex, V, false);
break;
}
-
+
case RetEffect::ReceiverAlias: {
assert (Receiver);
SVal V = state->getSValAsScalarOrLoc(Receiver);
state = state->BindExpr(Ex, V, false);
break;
}
-
+
case RetEffect::OwnedAllocatedSymbol:
case RetEffect::OwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount();
- ValueManager &ValMgr = Eng.getValueManager();
+ ValueManager &ValMgr = Eng.getValueManager();
SymbolRef Sym = ValMgr.getConjuredSymbol(Ex, Count);
- QualType RetT = GetReturnType(Ex, ValMgr.getContext());
+ QualType RetT = GetReturnType(Ex, ValMgr.getContext());
state = state->set<RefBindings>(Sym, RefVal::makeOwned(RE.getObjKind(),
RetT));
state = state->BindExpr(Ex, ValMgr.makeLoc(Sym), false);
@@ -2941,31 +2940,31 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst,
if (RE.getKind() == RetEffect::OwnedAllocatedSymbol) {
bool isFeasible;
state = state.Assume(loc::SymbolVal(Sym), true, isFeasible);
- assert(isFeasible && "Cannot assume fresh symbol is non-null.");
+ assert(isFeasible && "Cannot assume fresh symbol is non-null.");
}
#endif
-
+
break;
}
-
+
case RetEffect::GCNotOwnedSymbol:
case RetEffect::NotOwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount();
ValueManager &ValMgr = Eng.getValueManager();
SymbolRef Sym = ValMgr.getConjuredSymbol(Ex, Count);
- QualType RetT = GetReturnType(Ex, ValMgr.getContext());
+ QualType RetT = GetReturnType(Ex, ValMgr.getContext());
state = state->set<RefBindings>(Sym, RefVal::makeNotOwned(RE.getObjKind(),
RetT));
state = state->BindExpr(Ex, ValMgr.makeLoc(Sym), false);
break;
}
}
-
+
// Generate a sink node if we are at the end of a path.
ExplodedNode *NewNode =
Summ.isEndPath() ? Builder.MakeSinkNode(Dst, Ex, Pred, state)
: Builder.MakeNode(Dst, Ex, Pred, state);
-
+
// Annotate the edge with summary we used.
if (NewNode) SummaryLog[NewNode] = &Summ;
}
@@ -2977,9 +2976,9 @@ void CFRefCount::EvalCall(ExplodedNodeSet& Dst,
CallExpr* CE, SVal L,
ExplodedNode* Pred) {
const FunctionDecl* FD = L.getAsFunctionDecl();
- RetainSummary* Summ = !FD ? Summaries.getDefaultSummary()
+ RetainSummary* Summ = !FD ? Summaries.getDefaultSummary()
: Summaries.getSummary(const_cast<FunctionDecl*>(FD));
-
+
assert(Summ);
EvalSummary(Dst, Eng, Builder, CE, 0, *Summ,
CE->arg_begin(), CE->arg_end(), Pred);
@@ -2989,9 +2988,9 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
GRExprEngine& Eng,
GRStmtNodeBuilder& Builder,
ObjCMessageExpr* ME,
- ExplodedNode* Pred) {
+ ExplodedNode* Pred) {
RetainSummary* Summ = 0;
-
+
if (Expr* Receiver = ME->getReceiver()) {
// We need the type-information of the tracked receiver object
// Retrieve it from the state.
@@ -3005,7 +3004,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
SVal V = St->getSValAsScalarOrLoc(Receiver);
SymbolRef Sym = V.getAsLocSymbol();
-
+
if (Sym) {
if (const RefVal* T = St->get<RefBindings>(Sym)) {
if (const ObjCObjectPointerType* PT =
@@ -3028,21 +3027,21 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst,
// Special-case: are we sending a mesage to "self"?
// This is a hack. When we have full-IP this should be removed.
- if (isa<ObjCMethodDecl>(Pred->getLocationContext()->getDecl())) {
+ if (isa<ObjCMethodDecl>(Pred->getLocationContext()->getDecl())) {
if (Expr* Receiver = ME->getReceiver()) {
SVal X = St->getSValAsScalarOrLoc(Receiver);
- if (loc::MemRegionVal* L = dyn_cast<loc::MemRegionVal>(&X)) {
+ if (loc::MemRegionVal* L = dyn_cast<loc::MemRegionVal>(&X)) {
// Get the region associated with 'self'.
- const LocationContext *LC = Pred->getLocationContext();
+ const LocationContext *LC = Pred->getLocationContext();
if (const ImplicitParamDecl *SelfDecl = LC->getSelfDecl()) {
- SVal SelfVal = St->getSVal(St->getRegion(SelfDecl, LC));
+ SVal SelfVal = St->getSVal(St->getRegion(SelfDecl, LC));
if (L->getBaseRegion() == SelfVal.getAsRegion()) {
// Update the summary to make the default argument effect
// 'StopTracking'.
Summ = Summaries.copySummary(Summ);
Summ->setDefaultArgEffect(StopTracking);
}
- }
+ }
}
}
}
@@ -3070,18 +3069,18 @@ public:
}
};
} // end anonymous namespace
-
-void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
- // Are we storing to something that causes the value to "escape"?
+
+void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
+ // Are we storing to something that causes the value to "escape"?
bool escapes = false;
-
+
// A value escapes in three possible cases (this may change):
//
// (1) we are binding to something that is not a memory region.
// (2) we are binding to a memregion that does not have stack storage
// (3) we are binding to a memregion with stack storage that the store
- // does not understand.
+ // does not understand.
const GRState *state = B.getState();
if (!isa<loc::MemRegionVal>(location))
@@ -3089,7 +3088,7 @@ void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
else {
const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion();
escapes = !R->hasStackStorage();
-
+
if (!escapes) {
// To test (3), generate a new state with the binding removed. If it is
// the same state, then it escapes (since the store cannot represent
@@ -3116,35 +3115,35 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
GRStmtNodeBuilder& Builder,
ReturnStmt* S,
ExplodedNode* Pred) {
-
+
Expr* RetE = S->getRetValue();
if (!RetE)
return;
-
+
const GRState *state = Builder.GetState(Pred);
SymbolRef Sym = state->getSValAsScalarOrLoc(RetE).getAsLocSymbol();
-
+
if (!Sym)
return;
-
+
// Get the reference count binding (if any).
const RefVal* T = state->get<RefBindings>(Sym);
-
+
if (!T)
return;
-
- // Change the reference count.
- RefVal X = *T;
-
- switch (X.getKind()) {
- case RefVal::Owned: {
+
+ // Change the reference count.
+ RefVal X = *T;
+
+ switch (X.getKind()) {
+ case RefVal::Owned: {
unsigned cnt = X.getCount();
assert (cnt > 0);
X.setCount(cnt - 1);
X = X ^ RefVal::ReturnedOwned;
break;
}
-
+
case RefVal::NotOwned: {
unsigned cnt = X.getCount();
if (cnt) {
@@ -3156,39 +3155,39 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
}
break;
}
-
- default:
+
+ default:
return;
}
-
+
// Update the binding.
state = state->set<RefBindings>(Sym, X);
Pred = Builder.MakeNode(Dst, S, Pred, state);
-
+
// Did we cache out?
if (!Pred)
return;
-
+
// Update the autorelease counts.
static unsigned autoreleasetag = 0;
GenericNodeBuilder Bd(Builder, S, &autoreleasetag);
bool stop = false;
llvm::tie(Pred, state) = HandleAutoreleaseCounts(state , Bd, Pred, Eng, Sym,
X, stop);
-
+
// Did we cache out?
if (!Pred || stop)
return;
-
+
// Get the updated binding.
T = state->get<RefBindings>(Sym);
assert(T);
X = *T;
-
+
// Any leaks or other errors?
if (X.isReturnedOwned() && X.getCount() == 0) {
- const Decl *CD = Eng.getAnalysisManager().getCodeDecl();
- if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(CD)) {
+ const Decl *CD = Eng.getAnalysisManager().getCodeDecl();
+ if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(CD)) {
const RetainSummary &Summ = *Summaries.getMethodSummary(MD);
RetEffect RE = Summ.getRetEffect();
bool hasError = false;
@@ -3200,20 +3199,20 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
// a leak (as the caller expects a GC'ed object) because no
// method should return ownership unless it returns a CF object.
X = X ^ RefVal::ErrorGCLeakReturned;
-
+
// Keep this false until this is properly tested.
hasError = true;
}
else if (!RE.isOwned()) {
// Either we are using GC and the returned object is a CF type
// or we aren't using GC. In either case, we expect that the
- // enclosing method is expected to return ownership.
+ // enclosing method is expected to return ownership.
hasError = true;
X = X ^ RefVal::ErrorLeakReturned;
}
}
-
- if (hasError) {
+
+ if (hasError) {
// Generate an error node.
static int ReturnOwnLeakTag = 0;
state = state->set<RefBindings>(Sym, X);
@@ -3227,16 +3226,16 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst,
BR->EmitReport(report);
}
}
- }
+ }
}
else if (X.isReturnedNotOwned()) {
- const Decl *CD = Eng.getAnalysisManager().getCodeDecl();
+ const Decl *CD = Eng.getAnalysisManager().getCodeDecl();
if (const ObjCMethodDecl* MD = dyn_cast<ObjCMethodDecl>(CD)) {
const RetainSummary &Summ = *Summaries.getMethodSummary(MD);
if (Summ.getRetEffect().isOwned()) {
// Trying to return a not owned object to a caller expecting an
// owned object.
-
+
static int ReturnNotOwnedForOwnedTag = 0;
state = state->set<RefBindings>(Sym, X ^ RefVal::ErrorReturnedNotOwned);
if (ExplodedNode *N =
@@ -3261,18 +3260,18 @@ const GRState* CFRefCount::EvalAssume(const GRState *state,
// FIXME: We may add to the interface of EvalAssume the list of symbols
// whose assumptions have changed. For now we just iterate through the
// bindings and check if any of the tracked symbols are NULL. This isn't
- // too bad since the number of symbols we will track in practice are
+ // too bad since the number of symbols we will track in practice are
// probably small and EvalAssume is only called at branches and a few
// other places.
RefBindings B = state->get<RefBindings>();
-
+
if (B.isEmpty())
return state;
-
- bool changed = false;
+
+ bool changed = false;
RefBindings::Factory& RefBFactory = state->get_context<RefBindings>();
- for (RefBindings::iterator I=B.begin(), E=B.end(); I!=E; ++I) {
+ for (RefBindings::iterator I=B.begin(), E=B.end(); I!=E; ++I) {
// Check if the symbol is null (or equal to any constant).
// If this is the case, stop tracking the symbol.
if (state->getSymVal(I.getKey())) {
@@ -3280,10 +3279,10 @@ const GRState* CFRefCount::EvalAssume(const GRState *state,
B = RefBFactory.Remove(B, I.getKey());
}
}
-
+
if (changed)
state = state->set<RefBindings>(B);
-
+
return state;
}
@@ -3297,21 +3296,21 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
case IncRefMsg: E = isGCEnabled() ? DoNothing : IncRef; break;
case DecRefMsg: E = isGCEnabled() ? DoNothing : DecRef; break;
case MakeCollectable: E = isGCEnabled() ? DecRef : DoNothing; break;
- case NewAutoreleasePool: E = isGCEnabled() ? DoNothing :
+ case NewAutoreleasePool: E = isGCEnabled() ? DoNothing :
NewAutoreleasePool; break;
}
-
+
// Handle all use-after-releases.
if (!isGCEnabled() && V.getKind() == RefVal::Released) {
V = V ^ RefVal::ErrorUseAfterRelease;
hasErr = V.getKind();
return state->set<RefBindings>(sym, V);
- }
-
+ }
+
switch (E) {
default:
assert (false && "Unhandled CFRef transition.");
-
+
case Dealloc:
// Any use of -dealloc in GC is *bad*.
if (isGCEnabled()) {
@@ -3319,7 +3318,7 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
hasErr = V.getKind();
break;
}
-
+
switch (V.getKind()) {
default:
assert(false && "Invalid case.");
@@ -3332,13 +3331,13 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
V = V ^ RefVal::ErrorDeallocNotOwned;
hasErr = V.getKind();
break;
- }
+ }
break;
case NewAutoreleasePool:
assert(!isGCEnabled());
return state->add<AutoreleaseStack>(sym);
-
+
case MayEscape:
if (V.getKind() == RefVal::Owned) {
V = V ^ RefVal::NotOwned;
@@ -3346,7 +3345,7 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
}
// Fall-through.
-
+
case DoNothingByRef:
case DoNothing:
return state;
@@ -3354,7 +3353,7 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
case Autorelease:
if (isGCEnabled())
return state;
-
+
// Update the autorelease counts.
state = SendAutorelease(state, ARCountFactory, sym);
V = V.autorelease();
@@ -3363,7 +3362,7 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
case StopTracking:
return state->remove<RefBindings>(sym);
- case IncRef:
+ case IncRef:
switch (V.getKind()) {
default:
assert(false);
@@ -3371,15 +3370,15 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
case RefVal::Owned:
case RefVal::NotOwned:
V = V + 1;
- break;
+ break;
case RefVal::Released:
// Non-GC cases are handled above.
assert(isGCEnabled());
V = (V ^ RefVal::Owned) + 1;
break;
- }
+ }
break;
-
+
case SelfOwn:
V = V ^ RefVal::NotOwned;
// Fall-through.
@@ -3394,23 +3393,23 @@ const GRState * CFRefCount::Update(const GRState * state, SymbolRef sym,
if (V.getCount() == 1) V = V ^ RefVal::Released;
V = V - 1;
break;
-
+
case RefVal::NotOwned:
if (V.getCount() > 0)
V = V - 1;
else {
V = V ^ RefVal::ErrorReleaseNotOwned;
hasErr = V.getKind();
- }
+ }
break;
-
+
case RefVal::Released:
// Non-GC cases are handled above.
assert(isGCEnabled());
V = V ^ RefVal::ErrorUseAfterRelease;
hasErr = V.getKind();
- break;
- }
+ break;
+ }
break;
}
return state->set<RefBindings>(sym, V);
@@ -3425,22 +3424,22 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd
ExplodedNode* Pred,
GRExprEngine &Eng,
SymbolRef Sym, RefVal V, bool &stop) {
-
+
unsigned ACnt = V.getAutoreleaseCount();
stop = false;
// No autorelease counts? Nothing to be done.
if (!ACnt)
return std::make_pair(Pred, state);
-
- assert(!isGCEnabled() && "Autorelease counts in GC mode?");
+
+ assert(!isGCEnabled() && "Autorelease counts in GC mode?");
unsigned Cnt = V.getCount();
-
+
// FIXME: Handle sending 'autorelease' to already released object.
if (V.getKind() == RefVal::ReturnedOwned)
++Cnt;
-
+
if (ACnt <= Cnt) {
if (ACnt == Cnt) {
V.clearCounts();
@@ -3457,7 +3456,7 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd
ExplodedNode *N = Bd.MakeNode(state, Pred);
stop = (N == 0);
return std::make_pair(N, state);
- }
+ }
// Woah! More autorelease counts then retain counts left.
// Emit hard error.
@@ -3467,7 +3466,7 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd
if (ExplodedNode *N = Bd.MakeNode(state, Pred)) {
N->markAsSink();
-
+
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Object over-autoreleased: object was sent -autorelease";
@@ -3479,26 +3478,26 @@ CFRefCount::HandleAutoreleaseCounts(const GRState * state, GenericNodeBuilder Bd
else
os << "+" << V.getCount();
os << " retain counts";
-
+
CFRefReport *report =
new CFRefReport(*static_cast<CFRefBug*>(overAutorelease),
*this, N, Sym, os.str().c_str());
BR->EmitReport(report);
}
-
+
return std::make_pair((ExplodedNode*)0, state);
}
const GRState *
CFRefCount::HandleSymbolDeath(const GRState * state, SymbolRef sid, RefVal V,
llvm::SmallVectorImpl<SymbolRef> &Leaked) {
-
- bool hasLeak = V.isOwned() ||
+
+ bool hasLeak = V.isOwned() ||
((V.isNotOwned() || V.isReturnedOwned()) && V.getCount() > 0);
-
+
if (!hasLeak)
return state->remove<RefBindings>(sid);
-
+
Leaked.push_back(sid);
return state->set<RefBindings>(sid, V ^ RefVal::ErrorLeak);
}
@@ -3509,49 +3508,49 @@ CFRefCount::ProcessLeaks(const GRState * state,
GenericNodeBuilder &Builder,
GRExprEngine& Eng,
ExplodedNode *Pred) {
-
+
if (Leaked.empty())
return Pred;
-
+
// Generate an intermediate node representing the leak point.
ExplodedNode *N = Builder.MakeNode(state, Pred);
-
+
if (N) {
for (llvm::SmallVectorImpl<SymbolRef>::iterator
I = Leaked.begin(), E = Leaked.end(); I != E; ++I) {
-
- CFRefBug *BT = static_cast<CFRefBug*>(Pred ? leakWithinFunction
+
+ CFRefBug *BT = static_cast<CFRefBug*>(Pred ? leakWithinFunction
: leakAtReturn);
assert(BT && "BugType not initialized.");
CFRefLeakReport* report = new CFRefLeakReport(*BT, *this, N, *I, Eng);
BR->EmitReport(report);
}
}
-
+
return N;
}
void CFRefCount::EvalEndPath(GRExprEngine& Eng,
GREndPathNodeBuilder& Builder) {
-
+
const GRState *state = Builder.getState();
GenericNodeBuilder Bd(Builder);
- RefBindings B = state->get<RefBindings>();
+ RefBindings B = state->get<RefBindings>();
ExplodedNode *Pred = 0;
for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) {
bool stop = false;
llvm::tie(Pred, state) = HandleAutoreleaseCounts(state, Bd, Pred, Eng,
(*I).first,
- (*I).second, stop);
+ (*I).second, stop);
if (stop)
return;
}
-
- B = state->get<RefBindings>();
- llvm::SmallVector<SymbolRef, 10> Leaked;
-
+
+ B = state->get<RefBindings>();
+ llvm::SmallVector<SymbolRef, 10> Leaked;
+
for (RefBindings::iterator I = B.begin(), E = B.end(); I != E; ++I)
state = HandleSymbolDeath(state, (*I).first, (*I).second, Leaked);
@@ -3567,7 +3566,7 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst,
SymbolReaper& SymReaper) {
RefBindings B = state->get<RefBindings>();
-
+
// Update counts from autorelease pools
for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
E = SymReaper.dead_end(); I != E; ++I) {
@@ -3583,32 +3582,32 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst,
return;
}
}
-
+
B = state->get<RefBindings>();
llvm::SmallVector<SymbolRef, 10> Leaked;
-
+
for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
- E = SymReaper.dead_end(); I != E; ++I) {
+ E = SymReaper.dead_end(); I != E; ++I) {
if (const RefVal* T = B.lookup(*I))
state = HandleSymbolDeath(state, *I, *T, Leaked);
- }
-
+ }
+
static unsigned LeakPPTag = 0;
{
GenericNodeBuilder Bd(Builder, S, &LeakPPTag);
Pred = ProcessLeaks(state, Leaked, Bd, Eng, Pred);
}
-
+
// Did we cache out?
if (!Pred)
return;
-
+
// Now generate a new node that nukes the old bindings.
RefBindings::Factory& F = state->get_context<RefBindings>();
-
+
for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
E = SymReaper.dead_end(); I!=E; ++I) B = F.Remove(B, *I);
-
+
state = state->set<RefBindings>(B);
Builder.MakeNode(Dst, S, Pred, state);
}
@@ -3621,19 +3620,19 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
RefVal::Kind hasErr, SymbolRef Sym) {
Builder.BuildSinks = true;
ExplodedNode *N = Builder.MakeNode(Dst, NodeExpr, Pred, St);
-
+
if (!N)
return;
-
+
CFRefBug *BT = 0;
-
+
switch (hasErr) {
default:
assert(false && "Unhandled error.");
return;
case RefVal::ErrorUseAfterRelease:
BT = static_cast<CFRefBug*>(useAfterRelease);
- break;
+ break;
case RefVal::ErrorReleaseNotOwned:
BT = static_cast<CFRefBug*>(releaseNotOwned);
break;
@@ -3644,7 +3643,7 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
BT = static_cast<CFRefBug*>(deallocNotOwned);
break;
}
-
+
CFRefReport *report = new CFRefReport(*BT, *this, N, Sym);
report->addRange(ErrorExpr->getSourceRange());
BR->EmitReport(report);
@@ -3657,4 +3656,4 @@ void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
const LangOptions& lopts) {
return new CFRefCount(Ctx, GCEnabled, lopts);
-}
+}
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index 1e28411eb4..fdca1dc2f4 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -41,8 +41,8 @@ public:
void VisitChildren(Stmt *S) {
for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I)
- if (*I)
- static_cast<CGBuilder*>(this)->Visit(*I);
+ if (*I)
+ static_cast<CGBuilder*>(this)->Visit(*I);
}
};
}
@@ -53,7 +53,7 @@ void CGBuilder::VisitCallExpr(CallExpr *CE) {
CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent);
Decl *Parent = ASTLocation::FindImmediateParent(FD, CE);
-
+
CallerNode->addCallee(ASTLocation(Parent, CE), CalleeNode);
}
}
@@ -92,7 +92,7 @@ void CallGraph::addTU(ASTUnit &AST) {
// Set root node to 'main' function.
if (FD->getNameAsString() == "main")
Root = Node;
-
+
CGBuilder builder(*this, FD, Ent, Node);
builder.Visit(FD->getBody());
}
@@ -118,9 +118,9 @@ Decl *CallGraph::getDecl(CallGraphNode *Node) {
void CallGraph::print(llvm::raw_ostream &os) {
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->second->hasCallee()) {
- os << "function: " << I->first.getPrintableName()
+ os << "function: " << I->first.getPrintableName()
<< " calls:\n";
- for (CallGraphNode::iterator CI = I->second->begin(),
+ for (CallGraphNode::iterator CI = I->second->begin(),
CE = I->second->end(); CI != CE; ++CI) {
os << " " << CI->second->getName().c_str();
}
@@ -139,13 +139,13 @@ void CallGraph::ViewCallGraph() const {
namespace llvm {
-template <>
+template <>
struct DOTGraphTraits<CallGraph> : public DefaultDOTGraphTraits {
- static std::string getNodeLabel(const CallGraphNode *Node,
+ static std::string getNodeLabel(const CallGraphNode *Node,
const CallGraph &CG, bool ShortNames) {
return Node->getName();
-
+
}
};
diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp
index 69433d6396..716affb846 100644
--- a/lib/Analysis/CheckDeadStores.cpp
+++ b/lib/Analysis/CheckDeadStores.cpp
@@ -33,14 +33,14 @@ class VISIBILITY_HIDDEN DeadStoreObs : public LiveVariables::ObserverTy {
BugReporter& BR;
ParentMap& Parents;
llvm::SmallPtrSet<VarDecl*, 20> Escaped;
-
+
enum DeadStoreKind { Standard, Enclosing, DeadIncrement, DeadInit };
-
+
public:
DeadStoreObs(ASTContext &ctx, BugReporter& br, ParentMap& parents,
llvm::SmallPtrSet<VarDecl*, 20> &escaped)
: Ctx(ctx), BR(br), Parents(parents), Escaped(escaped) {}
-
+
virtual ~DeadStoreObs() {}
void Report(VarDecl* V, DeadStoreKind dsk, SourceLocation L, SourceRange R) {
@@ -48,27 +48,27 @@ public:
return;
std::string name = V->getNameAsString();
-
+
const char* BugType = 0;
std::string msg;
-
+
switch (dsk) {
default:
assert(false && "Impossible dead store type.");
-
+
case DeadInit:
BugType = "Dead initialization";
msg = "Value stored to '" + name +
"' during its initialization is never read";
break;
-
+
case DeadIncrement:
BugType = "Dead increment";
case Standard:
if (!BugType) BugType = "Dead assignment";
msg = "Value stored to '" + name + "' is never read";
break;
-
+
case Enclosing:
BugType = "Dead nested assignment";
msg = "Although the value stored to '" + name +
@@ -76,10 +76,10 @@ public:
" read from '" + name + "'";
break;
}
-
- BR.EmitBasicReport(BugType, "Dead store", msg.c_str(), L, R);
+
+ BR.EmitBasicReport(BugType, "Dead store", msg.c_str(), L, R);
}
-
+
void CheckVarDecl(VarDecl* VD, Expr* Ex, Expr* Val,
DeadStoreKind dsk,
const LiveVariables::AnalysisDataTy& AD,
@@ -87,60 +87,60 @@ public:
if (VD->hasLocalStorage() && !Live(VD, AD) && !VD->getAttr<UnusedAttr>())
Report(VD, dsk, Ex->getSourceRange().getBegin(),
- Val->getSourceRange());
+ Val->getSourceRange());
}
-
+
void CheckDeclRef(DeclRefExpr* DR, Expr* Val, DeadStoreKind dsk,
const LiveVariables::AnalysisDataTy& AD,
const LiveVariables::ValTy& Live) {
-
+
if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl()))
CheckVarDecl(VD, DR, Val, dsk, AD, Live);
}
-
+
bool isIncrement(VarDecl* VD, BinaryOperator* B) {
if (B->isCompoundAssignmentOp())
return true;
-
+
Expr* RHS = B->getRHS()->IgnoreParenCasts();
BinaryOperator* BRHS = dyn_cast<BinaryOperator>(RHS);
-
+
if (!BRHS)
return false;
-
+
DeclRefExpr *DR;
-
+
if ((DR = dyn_cast<DeclRefExpr>(BRHS->getLHS()->IgnoreParenCasts())))
if (DR->getDecl() == VD)
return true;
-
+
if ((DR = dyn_cast<DeclRefExpr>(BRHS->getRHS()->IgnoreParenCasts())))
if (DR->getDecl() == VD)
return true;
-
+
return false;
}
-
+
virtual void ObserveStmt(Stmt* S,
const LiveVariables::AnalysisDataTy& AD,
const LiveVariables::ValTy& Live) {
-
+
// Skip statements in macros.
if (S->getLocStart().isMacroID())
return;
-
- if (BinaryOperator* B = dyn_cast<BinaryOperator>(S)) {
+
+ if (BinaryOperator* B = dyn_cast<BinaryOperator>(S)) {
if (!B->isAssignmentOp()) return; // Skip non-assignments.
-
+
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(B->getLHS()))
if (VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
Expr* RHS = B->getRHS()->IgnoreParenCasts();
-
+
// Special case: check for assigning null to a pointer.
- // This is a common form of defensive programming.
+ // This is a common form of defensive programming.
if (VD->getType()->isPointerType()) {
if (IntegerLiteral* L = dyn_cast<IntegerLiteral>(RHS))
- // FIXME: Probably should have an Expr::isNullPointerConstant.
+ // FIXME: Probably should have an Expr::isNullPointerConstant.
if (L->getValue() == 0)
return;
}
@@ -149,19 +149,19 @@ public:
if (DeclRefExpr* RhsDR = dyn_cast<DeclRefExpr>(RHS))
if (VD == dyn_cast<VarDecl>(RhsDR->getDecl()))
return;
-
+
// Otherwise, issue a warning.
DeadStoreKind dsk = Parents.isConsumedExpr(B)
- ? Enclosing
+ ? Enclosing
: (isIncrement(VD,B) ? DeadIncrement : Standard);
-
+
CheckVarDecl(VD, DR, B->getRHS(), dsk, AD, Live);
- }
+ }
}
else if (UnaryOperator* U = dyn_cast<UnaryOperator>(S)) {
if (!U->isIncrementOp())
return;
-
+
// Handle: ++x within a subexpression. The solution is not warn
// about preincrements to dead variables when the preincrement occurs
// as a subexpression. This can lead to false negatives, e.g. "(++x);"
@@ -170,21 +170,21 @@ public:
return;
Expr *Ex = U->getSubExpr()->IgnoreParenCasts();
-
+
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(Ex))
CheckDeclRef(DR, U, DeadIncrement, AD, Live);
- }
+ }
else if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
// Iterate through the decls. Warn if any initializers are complex
// expressions that are not live (never used).
for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end();
DI != DE; ++DI) {
-
+
VarDecl* V = dyn_cast<VarDecl>(*DI);
if (!V)
continue;
-
+
if (V->hasLocalStorage())
if (Expr* E = V->getInit()) {
// A dead initialization is a variable that is dead after it
@@ -200,7 +200,7 @@ public:
// due to defensive programming.
if (E->isConstantInitializer(Ctx))
return;
-
+
// Special case: check for initializations from constant
// variables.
//
@@ -211,14 +211,14 @@ public:
if (VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl()))
if (VD->hasGlobalStorage() &&
VD->getType().isConstQualified()) return;
-
+
Report(V, DeadInit, V->getLocation(), E->getSourceRange());
}
}
}
}
};
-
+
} // end anonymous namespace
//===----------------------------------------------------------------------===//
@@ -230,9 +230,9 @@ class VISIBILITY_HIDDEN FindEscaped : public CFGRecStmtDeclVisitor<FindEscaped>{
CFG *cfg;
public:
FindEscaped(CFG *c) : cfg(c) {}
-
+
CFG& getCFG() { return *cfg; }
-
+
llvm::SmallPtrSet<VarDecl*, 20> Escaped;
void VisitUnaryOperator(UnaryOperator* U) {
@@ -249,11 +249,11 @@ public:
}
};
} // end anonymous namespace
-
+
void clang::CheckDeadStores(LiveVariables& L, BugReporter& BR) {
FindEscaped FS(BR.getCFG());
- FS.getCFG().VisitBlockStmts(FS);
+ FS.getCFG().VisitBlockStmts(FS);
DeadStoreObs A(BR.getContext(), BR, BR.getParentMap(), FS.Escaped);
L.runOnAllBlocks(*BR.getCFG(), &A);
}
diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp
index 0b9ae04ece..7e596435d0 100644
--- a/lib/Analysis/CheckNSError.cpp
+++ b/lib/Analysis/CheckNSError.cpp
@@ -32,37 +32,37 @@ class VISIBILITY_HIDDEN NSErrorCheck : public BugType {
const bool isNSErrorWarning;
IdentifierInfo * const II;
GRExprEngine &Eng;
-
+
void CheckSignature(const ObjCMethodDecl& MD, QualType& ResultTy,
llvm::SmallVectorImpl<VarDecl*>& ErrorParams);
-
+
void CheckSignature(const FunctionDecl& MD, QualType& ResultTy,
llvm::SmallVectorImpl<VarDecl*>& ErrorParams);
bool CheckNSErrorArgument(QualType ArgTy);
bool CheckCFErrorArgument(QualType ArgTy);
-
+
void CheckParamDeref(const VarDecl *V, const LocationContext *LC,
const GRState *state, BugReporter& BR);
-
+
void EmitRetTyWarning(BugReporter& BR, const Decl& CodeDecl);
-
+
public:
NSErrorCheck(const Decl &D, bool isNSError, GRExprEngine& eng)
- : BugType(isNSError ? "NSError** null dereference"
+ : BugType(isNSError ? "NSError** null dereference"
: "CFErrorRef* null dereference",
"Coding conventions (Apple)"),
CodeDecl(D),
- isNSErrorWarning(isNSError),
+ isNSErrorWarning(isNSError),
II(&eng.getContext().Idents.get(isNSErrorWarning ? "NSError":"CFErrorRef")),
Eng(eng) {}
-
+
void FlushReports(BugReporter& BR);
-};
-
+};
+
} // end anonymous namespace
-void clang::RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng,
+void clang::RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng,
const Decl &D) {
BR.Register(new NSErrorCheck(D, true, Eng));
BR.Register(new NSErrorCheck(D, false, Eng));
@@ -71,7 +71,7 @@ void clang::RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng,
void NSErrorCheck::FlushReports(BugReporter& BR) {
// Get the analysis engine and the exploded analysis graph.
ExplodedGraph& G = Eng.getGraph();
-
+
// Get the ASTContext, which is useful for querying type information.
ASTContext &Ctx = BR.getContext();
@@ -84,17 +84,17 @@ void NSErrorCheck::FlushReports(BugReporter& BR) {
CheckSignature(*FD, ResultTy, ErrorParams);
else
return;
-
+
if (ErrorParams.empty())
return;
-
+
if (ResultTy == Ctx.VoidTy) EmitRetTyWarning(BR, CodeDecl);
-
- for (ExplodedGraph::roots_iterator RI=G.roots_begin(), RE=G.roots_end();
+
+ for (ExplodedGraph::roots_iterator RI=G.roots_begin(), RE=G.roots_end();
RI!=RE; ++RI) {
// Scan the parameters for an implicit null dereference.
for (llvm::SmallVectorImpl<VarDecl*>::iterator I=ErrorParams.begin(),
- E=ErrorParams.end(); I!=E; ++I)
+ E=ErrorParams.end(); I!=E; ++I)
CheckParamDeref(*I, (*RI)->getLocationContext(), (*RI)->getState(), BR);
}
}
@@ -102,17 +102,17 @@ void NSErrorCheck::FlushReports(BugReporter& BR) {
void NSErrorCheck::EmitRetTyWarning(BugReporter& BR, const Decl& CodeDecl) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
if (isa<ObjCMethodDecl>(CodeDecl))
os << "Method";
else
- os << "Function";
-
+ os << "Function";
+
os << " accepting ";
os << (isNSErrorWarning ? "NSError**" : "CFErrorRef*");
os << " should have a non-void return value to indicate whether or not an "
"error occurred";
-
+
BR.EmitBasicReport(isNSErrorWarning
? "Bad return type when passing NSError**"
: "Bad return type when passing CFError*",
@@ -125,11 +125,11 @@ NSErrorCheck::CheckSignature(const ObjCMethodDecl& M, QualType& ResultTy,
llvm::SmallVectorImpl<VarDecl*>& ErrorParams) {
ResultTy = M.getResultType();
-
- for (ObjCMethodDecl::param_iterator I=M.param_begin(),
+
+ for (ObjCMethodDecl::param_iterator I=M.param_begin(),
E=M.param_end(); I!=E; ++I) {
- QualType T = (*I)->getType();
+ QualType T = (*I)->getType();
if (isNSErrorWarning) {
if (CheckNSErrorArgument(T)) ErrorParams.push_back(*I);
@@ -142,14 +142,14 @@ NSErrorCheck::CheckSignature(const ObjCMethodDecl& M, QualType& ResultTy,
void
NSErrorCheck::CheckSignature(const FunctionDecl& F, QualType& ResultTy,
llvm::SmallVectorImpl<VarDecl*>& ErrorParams) {
-
+
ResultTy = F.getResultType();
-
- for (FunctionDecl::param_const_iterator I = F.param_begin(),
+
+ for (FunctionDecl::param_const_iterator I = F.param_begin(),
E = F.param_end(); I != E; ++I) {
-
- QualType T = (*I)->getType();
-
+
+ QualType T = (*I)->getType();
+
if (isNSErrorWarning) {
if (CheckNSErrorArgument(T)) ErrorParams.push_back(*I);
}
@@ -160,31 +160,31 @@ NSErrorCheck::CheckSignature(const FunctionDecl& F, QualType& ResultTy,
bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
-
+
const PointerType* PPT = ArgTy->getAs<PointerType>();
if (!PPT)
return false;
-
+
const ObjCObjectPointerType* PT =
PPT->getPointeeType()->getAsObjCObjectPointerType();
if (!PT)
return false;
-
+
const ObjCInterfaceDecl *ID = PT->getInterfaceDecl();
-
+
// FIXME: Can ID ever be NULL?
if (ID)
return II == ID->getIdentifier();
-
+
return false;
}
bool NSErrorCheck::CheckCFErrorArgument(QualType ArgTy) {
-
+
const PointerType* PPT = ArgTy->getAs<PointerType>();
if (!PPT) return false;
-
+
const TypedefType* TT = PPT->getPointeeType()->getAsTypedefType();
if (!TT) return false;
@@ -195,24 +195,24 @@ void NSErrorCheck::CheckParamDeref(const VarDecl *Param,
const LocationContext *LC,
const GRState *rootState,
BugReporter& BR) {
-
+
SVal ParamL = rootState->getLValue(Param, LC);
const MemRegion* ParamR = cast<loc::MemRegionVal>(ParamL).getRegionAs<VarRegion>();
assert (ParamR && "Parameters always have VarRegions.");
SVal ParamSVal = rootState->getSVal(ParamR);
-
+
// FIXME: For now assume that ParamSVal is symbolic. We need to generalize
// this later.
SymbolRef ParamSym = ParamSVal.getAsLocSymbol();
if (!ParamSym)
return;
-
+
// Iterate over the implicit-null dereferences.
for (GRExprEngine::null_deref_iterator I=Eng.implicit_null_derefs_begin(),
E=Eng.implicit_null_derefs_end(); I!=E; ++I) {
-
+
const GRState *state = (*I)->getState();
- const SVal* X = state->get<GRState::NullDerefTag>();
+ const SVal* X = state->get<GRState::NullDerefTag>();
if (!X || X->getAsSymbol() != ParamSym)
continue;
@@ -221,14 +221,14 @@ void NSErrorCheck::CheckParamDeref(const VarDecl *Param,
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Potential null dereference. According to coding standards ";
-
+
if (isNSErrorWarning)
os << "in 'Creating and Returning NSError Objects' the parameter '";
else
os << "documented in CoreFoundation/CFError.h the parameter '";
-
+
os << Param->getNameAsString() << "' may be null.";
-
+
BugReport *report = new BugReport(*this, os.str().c_str(), *I);
// FIXME: Notable symbols are now part of the report. We should
// add support for notable symbols in BugReport.
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 3392fcfdc3..d89edff2de 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -24,11 +24,11 @@
using namespace clang;
-static bool scan_dealloc(Stmt* S, Selector Dealloc) {
-
+static bool scan_dealloc(Stmt* S, Selector Dealloc) {
+
if (ObjCMessageExpr* ME = dyn_cast<ObjCMessageExpr>(S))
if (ME->getSelector() == Dealloc)
- if(ME->getReceiver())
+ if (ME->getReceiver())
if (Expr* Receiver = ME->getReceiver()->IgnoreParenCasts())
return isa<ObjCSuperExpr>(Receiver);
@@ -37,20 +37,20 @@ static bool scan_dealloc(Stmt* S, Selector Dealloc) {
for (Stmt::child_iterator I = S->child_begin(), E= S->child_end(); I!=E; ++I)
if (*I && scan_dealloc(*I, Dealloc))
return true;
-
+
return false;
}
-static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID,
- const ObjCPropertyDecl* PD,
- Selector Release,
+static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID,
+ const ObjCPropertyDecl* PD,
+ Selector Release,
IdentifierInfo* SelfII,
- ASTContext& Ctx) {
-
+ ASTContext& Ctx) {
+
// [mMyIvar release]
if (ObjCMessageExpr* ME = dyn_cast<ObjCMessageExpr>(S))
if (ME->getSelector() == Release)
- if(ME->getReceiver())
+ if (ME->getReceiver())
if (Expr* Receiver = ME->getReceiver()->IgnoreParenCasts())
if (ObjCIvarRefExpr* E = dyn_cast<ObjCIvarRefExpr>(Receiver))
if (E->getDecl() == ID)
@@ -58,7 +58,7 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID,
// [self setMyIvar:nil];
if (ObjCMessageExpr* ME = dyn_cast<ObjCMessageExpr>(S))
- if(ME->getReceiver())
+ if (ME->getReceiver())
if (Expr* Receiver = ME->getReceiver()->IgnoreParenCasts())
if (DeclRefExpr* E = dyn_cast<DeclRefExpr>(Receiver))
if (E->getDecl()->getIdentifier() == SelfII)
@@ -66,19 +66,19 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID,
ME->getNumArgs() == 1 &&
ME->getArg(0)->isNullPointerConstant(Ctx))
return true;
-
+
// self.myIvar = nil;
if (BinaryOperator* BO = dyn_cast<BinaryOperator>(S))
if (BO->isAssignmentOp())
- if(ObjCPropertyRefExpr* PRE =
+ if (ObjCPropertyRefExpr* PRE =
dyn_cast<ObjCPropertyRefExpr>(BO->getLHS()->IgnoreParenCasts()))
- if(PRE->getProperty() == PD)
- if(BO->getRHS()->isNullPointerConstant(Ctx)) {
+ if (PRE->getProperty() == PD)
+ if (BO->getRHS()->isNullPointerConstant(Ctx)) {
// This is only a 'release' if the property kind is not
// 'assign'.
return PD->getSetterKind() != ObjCPropertyDecl::Assign;;
}
-
+
// Recurse to children.
for (Stmt::child_iterator I = S->child_begin(), E= S->child_end(); I!=E; ++I)
if (*I && scan_ivar_release(*I, ID, PD, Release, SelfII, Ctx))
@@ -91,39 +91,39 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
const LangOptions& LOpts, BugReporter& BR) {
assert (LOpts.getGCMode() != LangOptions::GCOnly);
-
+
ASTContext& Ctx = BR.getContext();
const ObjCInterfaceDecl* ID = D->getClassInterface();
-
+
// Does the class contain any ivars that are pointers (or id<...>)?
// If not, skip the check entirely.
// NOTE: This is motivated by PR 2517:
// http://llvm.org/bugs/show_bug.cgi?id=2517
-
+
bool containsPointerIvar = false;
-
+
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
I!=E; ++I) {
-
+
ObjCIvarDecl* ID = *I;
QualType T = ID->getType();
-
+
if (!T->isObjCObjectPointerType() ||
ID->getAttr<IBOutletAttr>()) // Skip IBOutlets.
continue;
-
+
containsPointerIvar = true;
break;
}
-
+
if (!containsPointerIvar)
return;
-
+
// Determine if the class subclasses NSObject.
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
IdentifierInfo* SenTestCaseII = &Ctx.Idents.get("SenTestCase");
-
+
for ( ; ID ; ID = ID->getSuperClass()) {
IdentifierInfo *II = ID->getIdentifier();
@@ -137,118 +137,118 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
if (II == SenTestCaseII)
return;
}
-
+
if (!ID)
return;
-
+
// Get the "dealloc" selector.
IdentifierInfo* II = &Ctx.Idents.get("dealloc");
- Selector S = Ctx.Selectors.getSelector(0, &II);
+ Selector S = Ctx.Selectors.getSelector(0, &II);
ObjCMethodDecl* MD = 0;
-
+
// Scan the instance methods for "dealloc".
for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
E = D->instmeth_end(); I!=E; ++I) {
-
+
if ((*I)->getSelector() == S) {
MD = *I;
break;
- }
+ }
}
-
+
if (!MD) { // No dealloc found.
-
- const char* name = LOpts.getGCMode() == LangOptions::NonGC
- ? "missing -dealloc"
+
+ const char* name = LOpts.getGCMode() == LangOptions::NonGC
+ ? "missing -dealloc"
: "missing -dealloc (Hybrid MM, non-GC)";
-
+
std::string buf;
llvm::raw_string_ostream os(buf);
os << "Objective-C class '" << D->getNameAsString()
<< "' lacks a 'dealloc' instance method";
-
+
BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
return;
}
-
+
// dealloc found. Scan for missing [super dealloc].
if (MD->getBody() && !scan_dealloc(MD->getBody(), S)) {
-
+
const char* name = LOpts.getGCMode() == LangOptions::NonGC
? "missing [super dealloc]"
: "missing [super dealloc] (Hybrid MM, non-GC)";
-
+
std::string buf;
llvm::raw_string_ostream os(buf);
os << "The 'dealloc' instance method in Objective-C class '"
<< D->getNameAsString()
<< "' does not send a 'dealloc' message to its super class"
" (missing [super dealloc])";
-
+
BR.EmitBasicReport(name, os.str().c_str(), D->getLocStart());
return;
- }
-
+ }
+
// Get the "release" selector.
IdentifierInfo* RII = &Ctx.Idents.get("release");
- Selector RS = Ctx.Selectors.getSelector(0, &RII);
-
+ Selector RS = Ctx.Selectors.getSelector(0, &RII);
+
// Get the "self" identifier
IdentifierInfo* SelfII = &Ctx.Idents.get("self");
-
+
// Scan for missing and extra releases of ivars used by implementations
// of synthesized properties
for (ObjCImplementationDecl::propimpl_iterator I = D->propimpl_begin(),
E = D->propimpl_end(); I!=E; ++I) {
// We can only check the synthesized properties
- if((*I)->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
+ if ((*I)->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
continue;
-
+
ObjCIvarDecl* ID = (*I)->getPropertyIvarDecl();
if (!ID)
continue;
-
+
QualType T = ID->getType();
if (!T->isObjCObjectPointerType()) // Skip non-pointer ivars
continue;
const ObjCPropertyDecl* PD = (*I)->getPropertyDecl();
- if(!PD)
+ if (!PD)
continue;
-
+
// ivars cannot be set via read-only properties, so we'll skip them
- if(PD->isReadOnly())
+ if (PD->isReadOnly())
continue;
-
+
// ivar must be released if and only if the kind of setter was not 'assign'
bool requiresRelease = PD->getSetterKind() != ObjCPropertyDecl::Assign;
- if(scan_ivar_release(MD->getBody(), ID, PD, RS, SelfII, Ctx)
+ if (scan_ivar_release(MD->getBody(), ID, PD, RS, SelfII, Ctx)
!= requiresRelease) {
const char *name;
const char* category = "Memory (Core Foundation/Objective-C)";
-
+
std::string buf;
llvm::raw_string_ostream os(buf);
- if(requiresRelease) {
+ if (requiresRelease) {
name = LOpts.getGCMode() == LangOptions::NonGC
? "missing ivar release (leak)"
: "missing ivar release (Hybrid MM, non-GC)";
-
+
os << "The '" << ID->getNameAsString()
<< "' instance variable was retained by a synthesized property but "
- "wasn't released in 'dealloc'";
+ "wasn't released in 'dealloc'";
} else {
name = LOpts.getGCMode() == LangOptions::NonGC
? "extra ivar release (use-after-release)"
: "extra ivar release (Hybrid MM, non-GC)";
-
+
os << "The '" << ID->getNameAsString()
<< "' instance variable was not retained by a synthesized property "
"but was released in 'dealloc'";
}
-
+
BR.EmitBasicReport(name, category,
os.str().c_str(), (*I)->getLocation());
}
diff --git a/lib/Analysis/CheckObjCInstMethSignature.cpp b/lib/Analysis/CheckObjCInstMethSignature.cpp
index aae1e1da3b..8c0d39629d 100644
--- a/lib/Analysis/CheckObjCInstMethSignature.cpp
+++ b/lib/Analysis/CheckObjCInstMethSignature.cpp
@@ -40,14 +40,14 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
const ObjCMethodDecl *MethAncestor,
BugReporter &BR, ASTContext &Ctx,
const ObjCImplementationDecl *ID) {
-
+
QualType ResDerived = MethDerived->getResultType();
- QualType ResAncestor = MethAncestor->getResultType();
-
+ QualType ResAncestor = MethAncestor->getResultType();
+
if (!AreTypesCompatible(ResDerived, ResAncestor, Ctx)) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "The Objective-C class '"
<< MethDerived->getClassInterface()->getNameAsString()
<< "', which is derived from class '"
@@ -63,7 +63,7 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
<< ResAncestor.getAsString()
<< "'. These two types are incompatible, and may result in undefined "
"behavior for clients of these classes.";
-
+
BR.EmitBasicReport("Incompatible instance method return type",
os.str().c_str(), MethDerived->getLocStart());
}
@@ -71,23 +71,23 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
void clang::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID,
BugReporter& BR) {
-
+
const ObjCInterfaceDecl* D = ID->getClassInterface();
const ObjCInterfaceDecl* C = D->getSuperClass();
if (!C)
return;
-
+
ASTContext& Ctx = BR.getContext();
-
+
// Build a DenseMap of the methods for quick querying.
typedef llvm::DenseMap<Selector,ObjCMethodDecl*> MapTy;
MapTy IMeths;
unsigned NumMethods = 0;
-
+
for (ObjCImplementationDecl::instmeth_iterator I=ID->instmeth_begin(),
- E=ID->instmeth_end(); I!=E; ++I) {
-
+ E=ID->instmeth_end(); I!=E; ++I) {
+
ObjCMethodDecl* M = *I;
IMeths[M->getSelector()] = M;
++NumMethods;
@@ -101,19 +101,19 @@ void clang::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID,
ObjCMethodDecl* M = *I;
Selector S = M->getSelector();
-
+
MapTy::iterator MI = IMeths.find(S);
if (MI == IMeths.end() || MI->second == 0)
continue;
-
+
--NumMethods;
ObjCMethodDecl* MethDerived = MI->second;
MI->second = 0;
-
+
CompareReturnTypes(MethDerived, M, BR, Ctx, ID);
}
-
+
C = C->getSuperClass();
}
}
diff --git a/lib/Analysis/CheckObjCUnusedIVars.cpp b/lib/Analysis/CheckObjCUnusedIVars.cpp
index 75470972f3..1a900f8976 100644
--- a/lib/Analysis/CheckObjCUnusedIVars.cpp
+++ b/lib/Analysis/CheckObjCUnusedIVars.cpp
@@ -29,7 +29,7 @@ typedef llvm::DenseMap<const ObjCIvarDecl*,IVarState> IvarUsageMap;
static void Scan(IvarUsageMap& M, const Stmt* S) {
if (!S)
return;
-
+
if (const ObjCIvarRefExpr *Ex = dyn_cast<ObjCIvarRefExpr>(S)) {
const ObjCIvarDecl *D = Ex->getDecl();
IvarUsageMap::iterator I = M.find(D);
@@ -37,7 +37,7 @@ static void Scan(IvarUsageMap& M, const Stmt* S) {
I->second = Used;
return;
}
-
+
// Blocks can reference an instance variable of a class.
if (const BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
Scan(M, BE->getBody());
@@ -51,12 +51,12 @@ static void Scan(IvarUsageMap& M, const Stmt* S) {
static void Scan(IvarUsageMap& M, const ObjCPropertyImplDecl* D) {
if (!D)
return;
-
+
const ObjCIvarDecl* ID = D->getPropertyIvarDecl();
if (!ID)
return;
-
+
IvarUsageMap::iterator I = M.find(ID);
if (I != M.end())
I->second = Used;
@@ -71,9 +71,9 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
// Iterate over the ivars.
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(),
E=ID->ivar_end(); I!=E; ++I) {
-
+
const ObjCIvarDecl* ID = *I;
-
+
// Ignore ivars that aren't private.
if (ID->getAccessControl() != ObjCIvarDecl::Private)
continue;
@@ -81,31 +81,31 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
// Skip IB Outlets.
if (ID->getAttr<IBOutletAttr>())
continue;
-
+
M[ID] = Unused;
}
if (M.empty())
return;
-
+
// Now scan the methods for accesses.
for (ObjCImplementationDecl::instmeth_iterator I = D->instmeth_begin(),
E = D->instmeth_end(); I!=E; ++I)
Scan(M, (*I)->getBody());
-
+
// Scan for @synthesized property methods that act as setters/getters
// to an ivar.
for (ObjCImplementationDecl::propimpl_iterator I = D->propimpl_begin(),
E = D->propimpl_end(); I!=E; ++I)
- Scan(M, *I);
-
+ Scan(M, *I);
+
// Find ivars that are unused.
for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
if (I->second == Unused) {
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
os << "Instance variable '" << I->first->getNameAsString()
- << "' in class '" << ID->getNameAsString()
+ << "' in class '" << ID->getNameAsString()
<< "' is never used by the methods in its @implementation "
"(although it may be used by category methods).";
diff --git a/lib/Analysis/CheckSecuritySyntaxOnly.cpp b/lib/Analysis/CheckSecuritySyntaxOnly.cpp
index 1bed9d1a5b..9f0d059cb6 100644
--- a/lib/Analysis/CheckSecuritySyntaxOnly.cpp
+++ b/lib/Analysis/CheckSecuritySyntaxOnly.cpp
@@ -21,18 +21,18 @@ using namespace clang;
namespace {
class VISIBILITY_HIDDEN WalkAST : public StmtVisitor<WalkAST> {
- BugReporter &BR;
+ BugReporter &BR;
IdentifierInfo *II_gets;
enum { num_rands = 9 };
IdentifierInfo *II_rand[num_rands];
IdentifierInfo *II_random;
enum { num_setids = 6 };
IdentifierInfo *II_setid[num_setids];
-
+
public:
WalkAST(BugReporter &br) : BR(br),
II_gets(0), II_rand(), II_random(0), II_setid() {}
-
+
// Statement visitor methods.
void VisitCallExpr(CallExpr *CE);
void VisitForStmt(ForStmt *S);
@@ -40,10 +40,10 @@ public:
void VisitStmt(Stmt *S) { VisitChildren(S); }
void VisitChildren(Stmt *S);
-
+
// Helpers.
IdentifierInfo *GetIdentifier(IdentifierInfo *& II, const char *str);
-
+
// Checker-specific methods.
void CheckLoopConditionForFloat(const ForStmt *FS);
void CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD);
@@ -60,8 +60,8 @@ public:
IdentifierInfo *WalkAST::GetIdentifier(IdentifierInfo *& II, const char *str) {
if (!II)
II = &BR.getContext().Idents.get(str);
-
- return II;
+
+ return II;
}
//===----------------------------------------------------------------------===//
@@ -80,23 +80,22 @@ void WalkAST::VisitCallExpr(CallExpr *CE) {
CheckCall_rand(CE, FD);
CheckCall_random(CE, FD);
}
-
+
// Recurse and check children.
VisitChildren(CE);
}
void WalkAST::VisitCompoundStmt(CompoundStmt *S) {
for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I)
- if (Stmt *child = *I)
- {
- if (CallExpr *CE = dyn_cast<CallExpr>(child))
- CheckUncheckedReturnValue(CE);
- Visit(child);
- }
+ if (Stmt *child = *I) {
+ if (CallExpr *CE = dyn_cast<CallExpr>(child))
+ CheckUncheckedReturnValue(CE);
+ Visit(child);
+ }
}
void WalkAST::VisitForStmt(ForStmt *FS) {
- CheckLoopConditionForFloat(FS);
+ CheckLoopConditionForFloat(FS);
// Recurse and check children.
VisitChildren(FS);
@@ -111,26 +110,26 @@ void WalkAST::VisitForStmt(ForStmt *FS) {
static const DeclRefExpr*
GetIncrementedVar(const Expr *expr, const VarDecl *x, const VarDecl *y) {
expr = expr->IgnoreParenCasts();
-
- if (const BinaryOperator *B = dyn_cast<BinaryOperator>(expr)) {
+
+ if (const BinaryOperator *B = dyn_cast<BinaryOperator>(expr)) {
if (!(B->isAssignmentOp() || B->isCompoundAssignmentOp() ||
B->getOpcode() == BinaryOperator::Comma))
return NULL;
-
+
if (const DeclRefExpr *lhs = GetIncrementedVar(B->getLHS(), x, y))
return lhs;
-
+
if (const DeclRefExpr *rhs = GetIncrementedVar(B->getRHS(), x, y))
return rhs;
-
+
return NULL;
}
-
+
if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(expr)) {
const NamedDecl *ND = DR->getDecl();
return ND == x || ND == y ? DR : NULL;
}
-
+
if (const UnaryOperator *U = dyn_cast<UnaryOperator>(expr))
return U->isIncrementDecrementOp()
? GetIncrementedVar(U->getSubExpr(), x, y) : NULL;
@@ -145,68 +144,68 @@ GetIncrementedVar(const Expr *expr, const VarDecl *x, const VarDecl *y) {
void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) {
// Does the loop have a condition?
const Expr *condition = FS->getCond();
-
+
if (!condition)
return;
// Does the loop have an increment?
const Expr *increment = FS->getInc();
-
+
if (!increment)
return;
-
+
// Strip away '()' and casts.
condition = condition->IgnoreParenCasts();
increment = increment->IgnoreParenCasts();
-
+
// Is the loop condition a comparison?
const BinaryOperator *B = dyn_cast<BinaryOperator>(condition);
if (!B)
return;
-
+
// Is this a comparison?
if (!(B->isRelationalOp() || B->isEqualityOp()))
return;
-
+
// Are we comparing variables?
const DeclRefExpr *drLHS = dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParens());
const DeclRefExpr *drRHS = dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParens());
-
+
// Does at least one of the variables have a floating point type?
drLHS = drLHS && drLHS->getType()->isFloatingType() ? drLHS : NULL;
drRHS = drRHS && drRHS->getType()->isFloatingType() ? drRHS : NULL;
-
+
if (!drLHS && !drRHS)
return;
const VarDecl *vdLHS = drLHS ? dyn_cast<VarDecl>(drLHS->getDecl()) : NULL;
const VarDecl *vdRHS = drRHS ? dyn_cast<VarDecl>(drRHS->getDecl()) : NULL;
-
+
if (!vdLHS && !vdRHS)
- return;
-
+ return;
+
// Does either variable appear in increment?
const DeclRefExpr *drInc = GetIncrementedVar(increment, vdLHS, vdRHS);
-
+
if (!drInc)
return;
-
+
// Emit the error. First figure out which DeclRefExpr in the condition
// referenced the compared variable.
const DeclRefExpr *drCond = vdLHS == drInc->getDecl() ? drLHS : drRHS;
- llvm::SmallVector<SourceRange, 2> ranges;
+ llvm::SmallVector<SourceRange, 2> ranges;
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "Variable '" << drCond->getDecl()->getNameAsCString()
<< "' with floating point type '" << drCond->getType().getAsString()
<< "' should not be used as a loop counter";
ranges.push_back(drCond->getSourceRange());
ranges.push_back(drInc->getSourceRange());
-
+
const char *bugType = "Floating point variable used as loop counter";
BR.EmitBasicReport(bugType, "Security", os.str().c_str(),
FS->getLocStart(), ranges.data(), ranges.size());
@@ -221,11 +220,11 @@ void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) {
void WalkAST::CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD) {
if (FD->getIdentifier() != GetIdentifier(II_gets, "gets"))
return;
-
+
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FD->getType());
if (!FTP)
return;
-
+
// Verify that the function takes a single argument.
if (FTP->getNumArgs() != 1)
return;
@@ -234,10 +233,10 @@ void WalkAST::CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD) {
const PointerType *PT = dyn_cast<PointerType>(FTP->getArgType(0));
if (!PT)
return;
-
+
if (PT->getPointeeType().getUnqualifiedType() != BR.getContext().CharTy)
return;
-
+
// Issue a warning.
SourceRange R = CE->getCallee()->getSourceRange();
BR.EmitBasicReport("Potential buffer overflow in call to 'gets'",
@@ -261,11 +260,11 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
"lcong48",
"rand", "rand_r"
};
-
+
for (size_t i = 0; i < num_rands; i++)
- II_rand[i] = &BR.getContext().Idents.get(identifiers[i]);
+ II_rand[i] = &BR.getContext().Idents.get(identifiers[i]);
}
-
+
const IdentifierInfo *id = FD->getIdentifier();
size_t identifierid;
@@ -275,24 +274,24 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
if (identifierid >= num_rands)
return;
-
+
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FD->getType());
if (!FTP)
return;
-
+
if (FTP->getNumArgs() == 1) {
// Is the argument an 'unsigned short *'?
// (Actually any integer type is allowed.)
const PointerType *PT = dyn_cast<PointerType>(FTP->getArgType(0));
if (!PT)
return;
-
+
if (! PT->getPointeeType()->isIntegerType())
return;
}
- else if (FTP->getNumArgs() != 0)
+ else if (FTP->getNumArgs() != 0)
return;
-
+
// Issue a warning.
std::string buf1;
llvm::raw_string_ostream os1(buf1);
@@ -305,7 +304,7 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
<< " Use 'arc4random' instead";
SourceRange R = CE->getCallee()->getSourceRange();
-
+
BR.EmitBasicReport(os1.str().c_str(), "Security", os2.str().c_str(),
CE->getLocStart(), &R, 1);
}
@@ -318,15 +317,15 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
void WalkAST::CheckCall_random(const CallExpr *CE, const FunctionDecl *FD) {
if (FD->getIdentifier() != GetIdentifier(II_random, "random"))
return;
-
+
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FD->getType());
if (!FTP)
return;
-
+
// Verify that the function takes no argument.
if (FTP->getNumArgs() != 0)
return;
-
+
// Issue a warning.
SourceRange R = CE->getCallee()->getSourceRange();
BR.EmitBasicReport("'random' is not a secure random number generator",
@@ -352,11 +351,11 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) {
"setuid", "setgid", "seteuid", "setegid",
"setreuid", "setregid"
};
-
+
for (size_t i = 0; i < num_setids; i++)
- II_setid[i] = &BR.getContext().Idents.get(identifiers[i]);
+ II_setid[i] = &BR.getContext().Idents.get(identifiers[i]);
}
-
+
const IdentifierInfo *id = FD->getIdentifier();
size_t identifierid;
@@ -366,11 +365,11 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) {
if (identifierid >= num_setids)
return;
-
+
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FD->getType());
if (!FTP)
return;
-
+
// Verify that the function takes one or two arguments (depending on
// the function).
if (FTP->getNumArgs() != (identifierid < 4 ? 1 : 2))
@@ -395,7 +394,7 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) {
<< "', the following code may execute with unexpected privileges";
SourceRange R = CE->getCallee()->getSourceRange();
-
+
BR.EmitBasicReport(os1.str().c_str(), "Security", os2.str().c_str(),
CE->getLocStart(), &R, 1);
}
@@ -404,7 +403,7 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) {
// Entry point for check.
//===----------------------------------------------------------------------===//
-void clang::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) {
+void clang::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) {
WalkAST walker(BR);
- walker.Visit(D->getBody());
+ walker.Visit(D->getBody());
}
diff --git a/lib/Analysis/Environment.cpp b/lib/Analysis/Environment.cpp
index 0b8ee66f15..1610ad4d27 100644
--- a/lib/Analysis/Environment.cpp
+++ b/lib/Analysis/Environment.cpp
@@ -18,61 +18,61 @@
using namespace clang;
SVal Environment::GetSVal(const Stmt *E, ValueManager& ValMgr) const {
-
+
for (;;) {
-
+
switch (E->getStmtClass()) {
-
- case Stmt::AddrLabelExprClass:
+
+ case Stmt::AddrLabelExprClass:
return ValMgr.makeLoc(cast<AddrLabelExpr>(E));
-
+
// ParenExprs are no-ops.
-
- case Stmt::ParenExprClass:
+
+ case Stmt::ParenExprClass:
E = cast<ParenExpr>(E)->getSubExpr();
continue;
-
+
case Stmt::CharacterLiteralClass: {
const CharacterLiteral* C = cast<CharacterLiteral>(E);
return ValMgr.makeIntVal(C->getValue(), C->getType());
}
-
+
case Stmt::IntegerLiteralClass: {
return ValMgr.makeIntVal(cast<IntegerLiteral>(E));
}
-
+
// Casts where the source and target type are the same
// are no-ops. We blast through these to get the descendant
// subexpression that has a value.
-
+
case Stmt::ImplicitCastExprClass:
case Stmt::CStyleCastExprClass: {
const CastExpr* C = cast<CastExpr>(E);
QualType CT = C->getType();
-
+
if (CT->isVoidType())
return UnknownVal();
-
+
break;
}
-
+
// Handle all other Stmt* using a lookup.
-
+
default:
break;
};
-
+
break;
}
-
+
return LookupExpr(E);
}
Environment EnvironmentManager::BindExpr(Environment Env, const Stmt *S,
- SVal V, bool Invalidate) {
+ SVal V, bool Invalidate) {
assert(S);
-
- if (V.isUnknown()) {
+
+ if (V.isUnknown()) {
if (Invalidate)
return Environment(F.Remove(Env.ExprBindings, S), Env.ACtx);
else
@@ -86,7 +86,7 @@ namespace {
class VISIBILITY_HIDDEN MarkLiveCallback : public SymbolVisitor {
SymbolReaper &SymReaper;
public:
- MarkLiveCallback(SymbolReaper &symreaper) : SymReaper(symreaper) {}
+ MarkLiveCallback(SymbolReaper &symreaper) : SymReaper(symreaper) {}
bool VisitSymbol(SymbolRef sym) { SymReaper.markLive(sym); return true; }
};
} // end anonymous namespace
@@ -95,45 +95,45 @@ public:
// - Remove subexpression bindings.
// - Remove dead block expression bindings.
// - Keep live block expression bindings:
-// - Mark their reachable symbols live in SymbolReaper,
+// - Mark their reachable symbols live in SymbolReaper,
// see ScanReachableSymbols.
// - Mark the region in DRoots if the binding is a loc::MemRegionVal.
-Environment
+Environment
EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S,
SymbolReaper &SymReaper,
const GRState *ST,
llvm::SmallVectorImpl<const MemRegion*> &DRoots) {
-
+
CFG &C = *Env.getAnalysisContext().getCFG();
-
+
// We construct a new Environment object entirely, as this is cheaper than
// individually removing all the subexpression bindings (which will greatly
// outnumber block-level expression bindings).
Environment NewEnv = getInitialEnvironment(&Env.getAnalysisContext());
-
+
// Iterate over the block-expr bindings.
- for (Environment::iterator I = Env.begin(), E = Env.end();
+ for (Environment::iterator I = Env.begin(), E = Env.end();
I != E; ++I) {
-
+
const Stmt *BlkExpr = I.getKey();
-
+
// Not a block-level expression?
if (!C.isBlkExpr(BlkExpr))
continue;
-
+
const SVal &X = I.getData();
-
+
if (SymReaper.isLive(S, BlkExpr)) {
// Copy the binding to the new map.
NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X);
-
+
// If the block expr's value is a memory region, then mark that region.
if (isa<loc::MemRegionVal>(X)) {
const MemRegion* R = cast<loc::MemRegionVal>(X).getRegion();
DRoots.push_back(R);
// Mark the super region of the RX as live.
- // e.g.: int x; char *y = (char*) &x; if (*y) ...
+ // e.g.: int x; char *y = (char*) &x; if (*y) ...
// 'y' => element region. 'x' is its super region.
// We only add one level super region for now.
diff --git a/lib/Analysis/ExplodedGraph.cpp b/lib/Analysis/ExplodedGraph.cpp
index 88bb120f5d..463b171249 100644
--- a/lib/Analysis/ExplodedGraph.cpp
+++ b/lib/Analysis/ExplodedGraph.cpp
@@ -64,10 +64,10 @@ void ExplodedNode::addPredecessor(ExplodedNode* V) {
}
void ExplodedNode::NodeGroup::addNode(ExplodedNode* N) {
-
+
assert ((reinterpret_cast<uintptr_t>(N) & Mask) == 0x0);
assert (!getFlag());
-
+
if (getKind() == Size1) {
if (ExplodedNode* NOld = getNode()) {
std::vector<ExplodedNode*>* V = new std::vector<ExplodedNode*>();
@@ -93,7 +93,7 @@ void ExplodedNode::NodeGroup::addNode(ExplodedNode* N) {
unsigned ExplodedNode::NodeGroup::size() const {
if (getFlag())
return 0;
-
+
if (getKind() == Size1)
return getNode() ? 1 : 0;
else
@@ -103,7 +103,7 @@ unsigned ExplodedNode::NodeGroup::size() const {
ExplodedNode** ExplodedNode::NodeGroup::begin() const {
if (getFlag())
return NULL;
-
+
if (getKind() == Size1)
return (ExplodedNode**) (getPtr() ? &P : NULL);
else
@@ -113,7 +113,7 @@ ExplodedNode** ExplodedNode::NodeGroup::begin() const {
ExplodedNode** ExplodedNode::NodeGroup::end() const {
if (getFlag())
return NULL;
-
+
if (getKind() == Size1)
return (ExplodedNode**) (getPtr() ? &P+1 : NULL);
else {
@@ -127,47 +127,47 @@ ExplodedNode::NodeGroup::~NodeGroup() {
if (getKind() == SizeOther) delete &getVector(getPtr());
}
-ExplodedNode *ExplodedGraph::getNode(const ProgramPoint& L,
+ExplodedNode *ExplodedGraph::getNode(const ProgramPoint& L,
const GRState* State, bool* IsNew) {
// Profile 'State' to determine if we already have an existing node.
- llvm::FoldingSetNodeID profile;
+ llvm::FoldingSetNodeID profile;
void* InsertPos = 0;
-
+
NodeTy::Profile(profile, L, State);
NodeTy* V = Nodes.FindNodeOrInsertPos(profile, InsertPos);
-
+
if (!V) {
// Allocate a new node.
V = (NodeTy*) Allocator.Allocate<NodeTy>();
new (V) NodeTy(L, State);
-
+
// Insert the node into the node set and return it.
Nodes.InsertNode(V, InsertPos);
-
+
++NumNodes;
-
+
if (IsNew) *IsNew = true;
}
else
if (IsNew) *IsNew = false;
-
+
return V;
}
std::pair<ExplodedGraph*, InterExplodedGraphMap*>
ExplodedGraph::Trim(const NodeTy* const* NBeg, const NodeTy* const* NEnd,
llvm::DenseMap<const void*, const void*> *InverseMap) const {
-
+
if (NBeg == NEnd)
return std::make_pair((ExplodedGraph*) 0,
(InterExplodedGraphMap*) 0);
-
+
assert (NBeg < NEnd);
llvm::OwningPtr<InterExplodedGraphMap> M(new InterExplodedGraphMap());
-
+
ExplodedGraph* G = TrimInternal(NBeg, NEnd, M.get(), InverseMap);
-
+
return std::make_pair(static_cast<ExplodedGraph*>(G), M.take());
}
@@ -179,10 +179,10 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
typedef llvm::DenseSet<const ExplodedNode*> Pass1Ty;
Pass1Ty Pass1;
-
+
typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*> Pass2Ty;
Pass2Ty& Pass2 = M->M;
-
+
llvm::SmallVector<const ExplodedNode*, 10> WL1, WL2;
// ===- Pass 1 (reverse DFS) -===
@@ -190,59 +190,59 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
assert(*I);
WL1.push_back(*I);
}
-
+
// Process the first worklist until it is empty. Because it is a std::list
// it acts like a FIFO queue.
while (!WL1.empty()) {
const ExplodedNode *N = WL1.back();
WL1.pop_back();
-
+
// Have we already visited this node? If so, continue to the next one.
if (Pass1.count(N))
continue;
// Otherwise, mark this node as visited.
Pass1.insert(N);
-
+
// If this is a root enqueue it to the second worklist.
if (N->Preds.empty()) {
WL2.push_back(N);
continue;
}
-
+
// Visit our predecessors and enqueue them.
for (ExplodedNode** I=N->Preds.begin(), **E=N->Preds.end(); I!=E; ++I)
WL1.push_back(*I);
}
-
+
// We didn't hit a root? Return with a null pointer for the new graph.
if (WL2.empty())
return 0;
// Create an empty graph.
ExplodedGraph* G = MakeEmptyGraph();
-
- // ===- Pass 2 (forward DFS to construct the new graph) -===
+
+ // ===- Pass 2 (forward DFS to construct the new graph) -===
while (!WL2.empty()) {
const ExplodedNode* N = WL2.back();
WL2.pop_back();
-
+
// Skip this node if we have already processed it.
if (Pass2.find(N) != Pass2.end())
continue;
-
+
// Create the corresponding node in the new graph and record the mapping
// from the old node to the new node.
ExplodedNode* NewN = G->getNode(N->getLocation(), N->State, NULL);
Pass2[N] = NewN;
-
+
// Also record the reverse mapping from the new node to the old node.
if (InverseMap) (*InverseMap)[NewN] = N;
-
+
// If this node is a root, designate it as such in the graph.
if (N->Preds.empty())
G->addRoot(NewN);
-
+
// In the case that some of the intended predecessors of NewN have already
// been created, we should hook them up as predecessors.
@@ -252,7 +252,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
Pass2Ty::iterator PI = Pass2.find(*I);
if (PI == Pass2.end())
continue;
-
+
NewN->addPredecessor(PI->second);
}
@@ -261,7 +261,7 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
// the new nodes from the original graph that should have nodes created
// in the new graph.
for (ExplodedNode **I=N->Succs.begin(), **E=N->Succs.end(); I!=E; ++I) {
- Pass2Ty::iterator PI = Pass2.find(*I);
+ Pass2Ty::iterator PI = Pass2.find(*I);
if (PI != Pass2.end()) {
PI->second->addPredecessor(NewN);
continue;
@@ -271,12 +271,12 @@ ExplodedGraph::TrimInternal(const ExplodedNode* const* BeginSources,
if (Pass1.count(*I))
WL2.push_back(*I);
}
-
+
// Finally, explictly mark all nodes without any successors as sinks.
if (N->isSink())
NewN->markAsSink();
}
-
+
return G;
}
diff --git a/lib/Analysis/GRBlockCounter.cpp b/lib/Analysis/GRBlockCounter.cpp
index f69a16da40..4f4103ac45 100644
--- a/lib/Analysis/GRBlockCounter.cpp
+++ b/lib/Analysis/GRBlockCounter.cpp
@@ -1,5 +1,5 @@
//==- GRBlockCounter.h - ADT for counting block visits -------------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
diff --git a/lib/Analysis/GRCoreEngine.cpp b/lib/Analysis/GRCoreEngine.cpp
index 7983dd841b..909f6196d6 100644
--- a/lib/Analysis/GRCoreEngine.cpp
+++ b/lib/Analysis/GRCoreEngine.cpp
@@ -1,5 +1,5 @@
//==- GRCoreEngine.cpp - Path-Sensitive Dataflow Engine ------------*- C++ -*-//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
@@ -48,27 +48,27 @@ public:
return U;
}
};
-
+
class VISIBILITY_HIDDEN BFS : public GRWorkList {
std::queue<GRWorkListUnit> Queue;
public:
virtual bool hasWork() const {
return !Queue.empty();
}
-
+
virtual void Enqueue(const GRWorkListUnit& U) {
Queue.push(U);
}
-
+
virtual GRWorkListUnit Dequeue() {
// Don't use const reference. The subsequent pop_back() might make it
// unsafe.
- GRWorkListUnit U = Queue.front();
+ GRWorkListUnit U = Queue.front();
Queue.pop();
return U;
}
};
-
+
} // end anonymous namespace
// Place the dstor for GRWorkList here because it contains virtual member
@@ -86,14 +86,14 @@ namespace {
virtual bool hasWork() const {
return !Queue.empty() || !Stack.empty();
}
-
+
virtual void Enqueue(const GRWorkListUnit& U) {
if (isa<BlockEntrance>(U.getNode()->getLocation()))
Queue.push(U);
else
Stack.push_back(U);
}
-
+
virtual GRWorkListUnit Dequeue() {
// Process all basic blocks to completion.
if (!Stack.empty()) {
@@ -101,13 +101,13 @@ namespace {
Stack.pop_back(); // This technically "invalidates" U, but we are fine.
return U;
}
-
+
assert(!Queue.empty());
// Don't use const reference. The subsequent pop_back() might make it
// unsafe.
- GRWorkListUnit U = Queue.front();
+ GRWorkListUnit U = Queue.front();
Queue.pop();
- return U;
+ return U;
}
};
} // end anonymous namespace
@@ -128,13 +128,13 @@ void GRCoreEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& Builder) {
}
bool GRCoreEngine::ProcessBlockEntrance(CFGBlock* Blk, const GRState* State,
- GRBlockCounter BC) {
+ GRBlockCounter BC) {
return SubEngine.ProcessBlockEntrance(Blk, State, BC);
}
void GRCoreEngine::ProcessBranch(Stmt* Condition, Stmt* Terminator,
GRBranchNodeBuilder& Builder) {
- SubEngine.ProcessBranch(Condition, Terminator, Builder);
+ SubEngine.ProcessBranch(Condition, Terminator, Builder);
}
void GRCoreEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& Builder) {
@@ -147,52 +147,52 @@ void GRCoreEngine::ProcessSwitch(GRSwitchNodeBuilder& Builder) {
/// ExecuteWorkList - Run the worklist algorithm for a maximum number of steps.
bool GRCoreEngine::ExecuteWorkList(const LocationContext *L, unsigned Steps) {
-
+
if (G->num_roots() == 0) { // Initialize the analysis by constructing
// the root if none exists.
-
+
CFGBlock* Entry = &(L->getCFG()->getEntry());
-
- assert (Entry->empty() &&
+
+ assert (Entry->empty() &&
"Entry block must be empty.");
-
+
assert (Entry->succ_size() == 1 &&
"Entry block must have 1 successor.");
-
+
// Get the solitary successor.
- CFGBlock* Succ = *(Entry->succ_begin());
-
+ CFGBlock* Succ = *(Entry->succ_begin());
+
// Construct an edge representing the
// starting location in the function.
BlockEdge StartLoc(Entry, Succ, L);
-
+
// Set the current block counter to being empty.
WList->setBlockCounter(BCounterFactory.GetEmptyCounter());
-
+
// Generate the root.
GenerateNode(StartLoc, getInitialState(L), 0);
}
-
+
while (Steps && WList->hasWork()) {
--Steps;
const GRWorkListUnit& WU = WList->Dequeue();
-
+
// Set the current block counter.
WList->setBlockCounter(WU.getBlockCounter());
// Retrieve the node.
ExplodedNode* Node = WU.getNode();
-
+
// Dispatch on the location type.
switch (Node->getLocation().getKind()) {
case ProgramPoint::BlockEdgeKind:
HandleBlockEdge(cast<BlockEdge>(Node->getLocation()), Node);
break;
-
+
case ProgramPoint::BlockEntranceKind:
HandleBlockEntrance(cast<BlockEntrance>(Node->getLocation()), Node);
break;
-
+
case ProgramPoint::BlockExitKind:
assert (false && "BlockExit location never occur in forward analysis.");
break;
@@ -201,22 +201,22 @@ bool GRCoreEngine::ExecuteWorkList(const LocationContext *L, unsigned Steps) {
assert(isa<PostStmt>(Node->getLocation()));
HandlePostStmt(cast<PostStmt>(Node->getLocation()), WU.getBlock(),
WU.getIndex(), Node);
- break;
+ break;
}
}
-
+
return WList->hasWork();
}
void GRCoreEngine::HandleBlockEdge(const BlockEdge& L, ExplodedNode* Pred) {
-
+
CFGBlock* Blk = L.getDst();
-
- // Check if we are entering the EXIT block.
+
+ // Check if we are entering the EXIT block.
if (Blk == &(Pred->getLocationContext()->getCFG()->getExit())) {
-
- assert (Pred->getLocationContext()->getCFG()->getExit().size() == 0
+
+ assert (Pred->getLocationContext()->getCFG()->getExit().size() == 0
&& "EXIT block cannot contain Stmts.");
// Process the final state transition.
@@ -228,81 +228,81 @@ void GRCoreEngine::HandleBlockEdge(const BlockEdge& L, ExplodedNode* Pred) {
}
// FIXME: Should we allow ProcessBlockEntrance to also manipulate state?
-
+
if (ProcessBlockEntrance(Blk, Pred->State, WList->getBlockCounter()))
GenerateNode(BlockEntrance(Blk, Pred->getLocationContext()), Pred->State, Pred);
}
void GRCoreEngine::HandleBlockEntrance(const BlockEntrance& L,
ExplodedNode* Pred) {
-
+
// Increment the block counter.
GRBlockCounter Counter = WList->getBlockCounter();
Counter = BCounterFactory.IncrementCount(Counter, L.getBlock()->getBlockID());
WList->setBlockCounter(Counter);
-
- // Process the entrance of the block.
+
+ // Process the entrance of the block.
if (Stmt* S = L.getFirstStmt()) {
- GRStmtNodeBuilder Builder(L.getBlock(), 0, Pred, this,
+ GRStmtNodeBuilder Builder(L.getBlock(), 0, Pred, this,
SubEngine.getStateManager());
ProcessStmt(S, Builder);
}
- else
+ else
HandleBlockExit(L.getBlock(), Pred);
}
void GRCoreEngine::HandleBlockExit(CFGBlock * B, ExplodedNode* Pred) {
-
+
if (Stmt* Term = B->getTerminator()) {
switch (Term->getStmtClass()) {
default:
assert(false && "Analysis for this terminator not implemented.");
break;
-
+
case Stmt::BinaryOperatorClass: // '&&' and '||'
HandleBranch(cast<BinaryOperator>(Term)->getLHS(), Term, B, Pred);
return;
-
+
case Stmt::ConditionalOperatorClass:
HandleBranch(cast<ConditionalOperator>(Term)->getCond(), Term, B, Pred);
return;
-
+
// FIXME: Use constant-folding in CFG construction to simplify this
// case.
-
+
case Stmt::ChooseExprClass:
HandleBranch(cast<ChooseExpr>(Term)->getCond(), Term, B, Pred);
return;
-
+
case Stmt::DoStmtClass:
HandleBranch(cast<DoStmt>(Term)->getCond(), Term, B, Pred);
return;
-
+
case Stmt::ForStmtClass:
HandleBranch(cast<ForStmt>(Term)->getCond(), Term, B, Pred);
return;
-
+
case Stmt::ContinueStmtClass:
case Stmt::BreakStmtClass:
- case Stmt::GotoStmtClass:
+ case Stmt::GotoStmtClass:
break;
-
+
case Stmt::IfStmtClass:
HandleBranch(cast<IfStmt>(Term)->getCond(), Term, B, Pred);
return;
-
+
case Stmt::IndirectGotoStmtClass: {
// Only 1 successor: the indirect goto dispatch block.
assert (B->succ_size() == 1);
-
+
GRIndirectGotoNodeBuilder
builder(Pred, B, cast<IndirectGotoStmt>(Term)->getTarget(),
*(B->succ_begin()), this);
-
+
ProcessIndirectGoto(builder);
return;
}
-
+
case Stmt::ObjCForCollectionStmtClass: {
// In the case of ObjCForCollectionStmt, it appears twice in a CFG:
//
@@ -317,15 +317,15 @@ void GRCoreEngine::HandleBlockExit(CFGBlock * B, ExplodedNode* Pred) {
HandleBranch(Term, Term, B, Pred);
return;
}
-
+
case Stmt::SwitchStmtClass: {
GRSwitchNodeBuilder builder(Pred, B, cast<SwitchStmt>(Term)->getCond(),
this);
-
+
ProcessSwitch(builder);
return;
}
-
+
case Stmt::WhileStmtClass:
HandleBranch(cast<WhileStmt>(Term)->getCond(), Term, B, Pred);
return;
@@ -334,8 +334,8 @@ void GRCoreEngine::HandleBlockExit(CFGBlock * B, ExplodedNode* Pred) {
assert (B->succ_size() == 1 &&
"Blocks with no terminator should have at most 1 successor.");
-
- GenerateNode(BlockEdge(B, *(B->succ_begin()), Pred->getLocationContext()),
+
+ GenerateNode(BlockEdge(B, *(B->succ_begin()), Pred->getLocationContext()),
Pred->State, Pred);
}
@@ -345,19 +345,19 @@ void GRCoreEngine::HandleBranch(Stmt* Cond, Stmt* Term, CFGBlock * B,
GRBranchNodeBuilder Builder(B, *(B->succ_begin()), *(B->succ_begin()+1),
Pred, this);
-
+
ProcessBranch(Cond, Term, Builder);
}
void GRCoreEngine::HandlePostStmt(const PostStmt& L, CFGBlock* B,
unsigned StmtIdx, ExplodedNode* Pred) {
-
+
assert (!B->empty());
if (StmtIdx == B->size())
HandleBlockExit(B, Pred);
else {
- GRStmtNodeBuilder Builder(B, StmtIdx, Pred, this,
+ GRStmtNodeBuilder Builder(B, StmtIdx, Pred, this,
SubEngine.getStateManager());
ProcessStmt((*B)[StmtIdx], Builder);
}
@@ -365,19 +365,19 @@ void GRCoreEngine::HandlePostStmt(const PostStmt& L, CFGBlock* B,
/// GenerateNode - Utility method to generate nodes, hook up successors,
/// and add nodes to the worklist.
-void GRCoreEngine::GenerateNode(const ProgramPoint& Loc,
+void GRCoreEngine::GenerateNode(const ProgramPoint& Loc,
const GRState* State, ExplodedNode* Pred) {
-
+
bool IsNew;
ExplodedNode* Node = G->getNode(Loc, State, &IsNew);
-
- if (Pred)
+
+ if (Pred)
Node->addPredecessor(Pred); // Link 'Node' with its predecessor.
else {
assert (IsNew);
G->addRoot(Node); // 'Node' has no predecessor. Make it a root.
}
-
+
// Only add 'Node' to the worklist if it was freshly generated.
if (IsNew) WList->Enqueue(Node);
}
@@ -385,7 +385,7 @@ void GRCoreEngine::GenerateNode(const ProgramPoint& Loc,
GRStmtNodeBuilder::GRStmtNodeBuilder(CFGBlock* b, unsigned idx,
ExplodedNode* N, GRCoreEngine* e,
GRStateManager &mgr)
- : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N), Mgr(mgr), Auditor(0),
+ : Eng(*e), B(*b), Idx(idx), Pred(N), LastNode(N), Mgr(mgr), Auditor(0),
PurgingDeadSymbols(false), BuildSinks(false), HasGeneratedNode(false),
PointKind(ProgramPoint::PostStmtKind), Tag(0) {
Deferred.insert(N);
@@ -400,16 +400,16 @@ GRStmtNodeBuilder::~GRStmtNodeBuilder() {
void GRStmtNodeBuilder::GenerateAutoTransition(ExplodedNode* N) {
assert (!N->isSink());
-
+
PostStmt Loc(getStmt(), N->getLocationContext());
-
+
if (Loc == N->getLocation()) {
// Note: 'N' should be a fresh node because otherwise it shouldn't be
// a member of Deferred.
Eng.WList->Enqueue(N, B, Idx+1);
return;
}
-
+
bool IsNew;
ExplodedNode* Succ = Eng.G->getNode(Loc, N->State, &IsNew);
Succ->addPredecessor(N);
@@ -423,10 +423,10 @@ static inline PostStmt GetPostLoc(const Stmt* S, ProgramPoint::Kind K,
switch (K) {
default:
assert(false && "Invalid PostXXXKind.");
-
+
case ProgramPoint::PostStmtKind:
return PostStmt(S, L, tag);
-
+
case ProgramPoint::PostLoadKind:
return PostLoad(S, L, tag);
@@ -435,19 +435,19 @@ static inline PostStmt GetPostLoc(const Stmt* S, ProgramPoint::Kind K,
case ProgramPoint::PostLocationChecksSucceedKind:
return PostLocationChecksSucceed(S, L, tag);
-
+
case ProgramPoint::PostOutOfBoundsCheckFailedKind:
return PostOutOfBoundsCheckFailed(S, L, tag);
-
+
case ProgramPoint::PostNullCheckFailedKind:
return PostNullCheckFailed(S, L, tag);
-
+
case ProgramPoint::PostStoreKind:
return PostStore(S, L, tag);
-
+
case ProgramPoint::PostLValueKind:
return PostLValue(S, L, tag);
-
+
case ProgramPoint::PostPurgeDeadSymbolsKind:
return PostPurgeDeadSymbols(S, L, tag);
}
@@ -459,10 +459,10 @@ GRStmtNodeBuilder::generateNodeInternal(const Stmt* S, const GRState* State,
ProgramPoint::Kind K,
const void *tag) {
return K == ProgramPoint::PreStmtKind
- ? generateNodeInternal(PreStmt(S, Pred->getLocationContext(),tag),
+ ? generateNodeInternal(PreStmt(S, Pred->getLocationContext(),tag),
State, Pred)
: generateNodeInternal(GetPostLoc(S, K, Pred->getLocationContext(), tag),
- State, Pred);
+ State, Pred);
}
ExplodedNode*
@@ -473,49 +473,49 @@ GRStmtNodeBuilder::generateNodeInternal(const ProgramPoint &Loc,
ExplodedNode* N = Eng.G->getNode(Loc, State, &IsNew);
N->addPredecessor(Pred);
Deferred.erase(Pred);
-
+
if (IsNew) {
Deferred.insert(N);
LastNode = N;
return N;
}
-
+
LastNode = NULL;
- return NULL;
+ return NULL;
}
ExplodedNode* GRBranchNodeBuilder::generateNode(const GRState* State,
bool branch) {
-
+
// If the branch has been marked infeasible we should not generate a node.
if (!isFeasible(branch))
return NULL;
-
+
bool IsNew;
-
+
ExplodedNode* Succ =
Eng.G->getNode(BlockEdge(Src,branch ? DstT:DstF,Pred->getLocationContext()),
State, &IsNew);
-
+
Succ->addPredecessor(Pred);
-
+
if (branch)
GeneratedTrue = true;
else
- GeneratedFalse = true;
-
+ GeneratedFalse = true;
+
if (IsNew) {
Deferred.push_back(Succ);
return Succ;
}
-
+
return NULL;
}
GRBranchNodeBuilder::~GRBranchNodeBuilder() {
if (!GeneratedTrue) generateNode(Pred->State, true);
if (!GeneratedFalse) generateNode(Pred->State, false);
-
+
for (DeferredTy::iterator I=Deferred.begin(), E=Deferred.end(); I!=E; ++I)
if (!(*I)->isSink()) Eng.WList->Enqueue(*I);
}
@@ -525,22 +525,22 @@ ExplodedNode*
GRIndirectGotoNodeBuilder::generateNode(const iterator& I, const GRState* St,
bool isSink) {
bool IsNew;
-
- ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock(),
+
+ ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock(),
Pred->getLocationContext()), St, &IsNew);
-
+
Succ->addPredecessor(Pred);
-
+
if (IsNew) {
-
+
if (isSink)
Succ->markAsSink();
else
Eng.WList->Enqueue(Succ);
-
+
return Succ;
}
-
+
return NULL;
}
@@ -549,42 +549,42 @@ ExplodedNode*
GRSwitchNodeBuilder::generateCaseStmtNode(const iterator& I, const GRState* St){
bool IsNew;
-
+
ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, I.getBlock(),
Pred->getLocationContext()), St, &IsNew);
Succ->addPredecessor(Pred);
-
+
if (IsNew) {
Eng.WList->Enqueue(Succ);
return Succ;
}
-
+
return NULL;
}
ExplodedNode*
GRSwitchNodeBuilder::generateDefaultCaseNode(const GRState* St, bool isSink) {
-
+
// Get the block for the default case.
assert (Src->succ_rbegin() != Src->succ_rend());
CFGBlock* DefaultBlock = *Src->succ_rbegin();
-
+
bool IsNew;
-
+
ExplodedNode* Succ = Eng.G->getNode(BlockEdge(Src, DefaultBlock,
Pred->getLocationContext()), St, &IsNew);
Succ->addPredecessor(Pred);
-
+
if (IsNew) {
if (isSink)
Succ->markAsSink();
else
Eng.WList->Enqueue(Succ);
-
+
return Succ;
}
-
+
return NULL;
}
@@ -596,18 +596,18 @@ GREndPathNodeBuilder::~GREndPathNodeBuilder() {
ExplodedNode*
GREndPathNodeBuilder::generateNode(const GRState* State, const void *tag,
ExplodedNode* P) {
- HasGeneratedNode = true;
+ HasGeneratedNode = true;
bool IsNew;
-
- ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B,
+
+ ExplodedNode* Node = Eng.G->getNode(BlockEntrance(&B,
Pred->getLocationContext(), tag), State, &IsNew);
-
+
Node->addPredecessor(P ? P : Pred);
-
+
if (IsNew) {
Eng.G->addEndOfPath(Node);
return Node;
}
-
+
return NULL;
}
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 053da67c7d..b4b69cdcd6 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -44,7 +44,7 @@ namespace {
class VISIBILITY_HIDDEN MappedBatchAuditor : public GRSimpleAPICheck {
typedef llvm::ImmutableList<GRSimpleAPICheck*> Checks;
typedef llvm::DenseMap<void*,Checks> MapTy;
-
+
MapTy M;
Checks::Factory F;
Checks AllStmts;
@@ -52,18 +52,18 @@ class VISIBILITY_HIDDEN MappedBatchAuditor : public GRSimpleAPICheck {
public:
MappedBatchAuditor(llvm::BumpPtrAllocator& Alloc) :
F(Alloc), AllStmts(F.GetEmptyList()) {}
-
+
virtual ~MappedBatchAuditor() {
llvm::DenseSet<GRSimpleAPICheck*> AlreadyVisited;
-
+
for (MapTy::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI)
for (Checks::iterator I=MI->second.begin(), E=MI->second.end(); I!=E;++I){
GRSimpleAPICheck* check = *I;
-
+
if (AlreadyVisited.count(check))
continue;
-
+
AlreadyVisited.insert(check);
delete check;
}
@@ -75,10 +75,10 @@ public:
MapTy::iterator I = M.find(key);
M[key] = F.Concat(A, I == M.end() ? F.GetEmptyList() : I->second);
}
-
+
void AddCheck(GRSimpleAPICheck *A) {
assert (A && "Check cannot be null.");
- AllStmts = F.Concat(A, AllStmts);
+ AllStmts = F.Concat(A, AllStmts);
}
virtual bool Audit(ExplodedNode* N, GRStateManager& VMgr) {
@@ -86,17 +86,17 @@ public:
bool isSink = false;
for (Checks::iterator I = AllStmts.begin(), E = AllStmts.end(); I!=E; ++I)
isSink |= (*I)->Audit(N, VMgr);
-
+
// Next handle the auditors that accept only specific statements.
const Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
void* key = reinterpret_cast<void*>((uintptr_t) S->getStmtClass());
MapTy::iterator MI = M.find(key);
- if (MI != M.end()) {
+ if (MI != M.end()) {
for (Checks::iterator I=MI->second.begin(), E=MI->second.end(); I!=E; ++I)
isSink |= (*I)->Audit(N, VMgr);
}
-
- return isSink;
+
+ return isSink;
}
};
@@ -105,30 +105,30 @@ public:
//===----------------------------------------------------------------------===//
// Checker worklist routines.
//===----------------------------------------------------------------------===//
-
-void GRExprEngine::CheckerVisit(Stmt *S, ExplodedNodeSet &Dst,
+
+void GRExprEngine::CheckerVisit(Stmt *S, ExplodedNodeSet &Dst,
ExplodedNodeSet &Src, bool isPrevisit) {
-
+
if (Checkers.empty()) {
Dst = Src;
return;
}
-
+
ExplodedNodeSet Tmp;
ExplodedNodeSet *PrevSet = &Src;
-
+
for (std::vector<Checker*>::iterator I = Checkers.begin(), E = Checkers.end();
I != E; ++I) {
- ExplodedNodeSet *CurrSet = (I+1 == E) ? &Dst
+ ExplodedNodeSet *CurrSet = (I+1 == E) ? &Dst
: (PrevSet == &Tmp) ? &Src : &Tmp;
CurrSet->clear();
Checker *checker = *I;
-
+
for (ExplodedNodeSet::iterator NI = PrevSet->begin(), NE = PrevSet->end();
NI != NE; ++NI)
checker->GR_Visit(*CurrSet, *Builder, *this, S, *NI, isPrevisit);
-
+
// Update which NodeSet is the current one.
PrevSet = CurrSet;
}
@@ -149,20 +149,20 @@ static inline Selector GetNullarySelector(const char* name, ASTContext& Ctx) {
GRExprEngine::GRExprEngine(AnalysisManager &mgr)
: AMgr(mgr),
- CoreEngine(mgr.getASTContext(), *this),
+ CoreEngine(mgr.getASTContext(), *this),
G(CoreEngine.getGraph()),
Builder(NULL),
- StateMgr(G.getContext(), mgr.getStoreManagerCreator(),
+ StateMgr(G.getContext(), mgr.getStoreManagerCreator(),
mgr.getConstraintManagerCreator(), G.getAllocator()),
SymMgr(StateMgr.getSymbolManager()),
ValMgr(StateMgr.getValueManager()),
SVator(ValMgr.getSValuator()),
CurrentStmt(NULL),
NSExceptionII(NULL), NSExceptionInstanceRaiseSelectors(NULL),
- RaiseSel(GetNullarySelector("raise", G.getContext())),
+ RaiseSel(GetNullarySelector("raise", G.getContext())),
BR(mgr, *this) {}
-GRExprEngine::~GRExprEngine() {
+GRExprEngine::~GRExprEngine() {
BR.FlushReports();
delete [] NSExceptionInstanceRaiseSelectors;
for (std::vector<Checker*>::iterator I=Checkers.begin(), E=Checkers.end();
@@ -184,7 +184,7 @@ void GRExprEngine::setTransferFunctions(GRTransferFuncs* tf) {
void GRExprEngine::AddCheck(GRSimpleAPICheck* A, Stmt::StmtClass C) {
if (!BatchAuditor)
BatchAuditor.reset(new MappedBatchAuditor(getGraph().getAllocator()));
-
+
((MappedBatchAuditor*) BatchAuditor.get())->AddCheck(A, C);
}
@@ -197,7 +197,7 @@ void GRExprEngine::AddCheck(GRSimpleAPICheck *A) {
const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
const GRState *state = StateMgr.getInitialState(InitLoc);
-
+
// Precondition: the first argument of 'main' is an integer guaranteed
// to be > 0.
// FIXME: It would be nice if we had a more general mechanism to add
@@ -212,13 +212,13 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
SVal V = state->getSVal(loc::MemRegionVal(R));
SVal Constraint = EvalBinOp(state, BinaryOperator::GT, V,
ValMgr.makeZeroVal(T),
- getContext().IntTy);
+ getContext().IntTy);
if (const GRState *newState = state->assume(Constraint, true))
state = newState;
}
}
-
+
return state;
}
@@ -227,31 +227,31 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
//===----------------------------------------------------------------------===//
void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) {
-
+
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
"Error evaluating statement");
-
+
Builder = &builder;
EntryNode = builder.getLastNode();
-
+
// FIXME: Consolidate.
CurrentStmt = S;
StateMgr.CurrentStmt = S;
-
+
// Set up our simple checks.
if (BatchAuditor)
Builder->setAuditor(BatchAuditor.get());
-
- // Create the cleaned state.
- SymbolReaper SymReaper(*AMgr.getLiveVariables(), SymMgr);
+
+ // Create the cleaned state.
+ SymbolReaper SymReaper(*AMgr.getLiveVariables(), SymMgr);
CleanedState = AMgr.shouldPurgeDead()
? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, SymReaper)
: EntryNode->getState();
// Process any special transfer function for dead symbols.
ExplodedNodeSet Tmp;
-
+
if (!SymReaper.hasDeadSymbols())
Tmp.Add(EntryNode);
else {
@@ -260,36 +260,36 @@ void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) {
SaveAndRestore<bool> OldPurgeDeadSymbols(Builder->PurgingDeadSymbols);
Builder->PurgingDeadSymbols = true;
-
- getTF().EvalDeadSymbols(Tmp, *this, *Builder, EntryNode, S,
+
+ getTF().EvalDeadSymbols(Tmp, *this, *Builder, EntryNode, S,
CleanedState, SymReaper);
if (!Builder->BuildSinks && !Builder->HasGeneratedNode)
Tmp.Add(EntryNode);
}
-
+
bool HasAutoGenerated = false;
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
ExplodedNodeSet Dst;
-
- // Set the cleaned state.
+
+ // Set the cleaned state.
Builder->SetCleanedState(*I == EntryNode ? CleanedState : GetState(*I));
-
- // Visit the statement.
+
+ // Visit the statement.
Visit(S, *I, Dst);
// Do we need to auto-generate a node? We only need to do this to generate
// a node with a "cleaned" state; GRCoreEngine will actually handle
- // auto-transitions for other cases.
+ // auto-transitions for other cases.
if (Dst.size() == 1 && *Dst.begin() == EntryNode
&& !Builder->HasGeneratedNode && !HasAutoGenerated) {
HasAutoGenerated = true;
builder.generateNode(S, GetState(EntryNode), *I);
}
}
-
+
// NULL out these variables to cleanup.
CleanedState = NULL;
EntryNode = NULL;
@@ -297,11 +297,11 @@ void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) {
// FIXME: Consolidate.
StateMgr.CurrentStmt = 0;
CurrentStmt = 0;
-
+
Builder = NULL;
}
-void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
+void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
S->getLocStart(),
"Error evaluating statement");
@@ -309,32 +309,32 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// FIXME: add metadata to the CFG so that we can disable
// this check when we KNOW that there is no block-level subexpression.
// The motivation is that this check requires a hashtable lookup.
-
+
if (S != CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(S)) {
Dst.Add(Pred);
return;
}
-
+
switch (S->getStmtClass()) {
-
+
default:
// Cases we intentionally have "default" handle:
// AddrLabelExpr, IntegerLiteral, CharacterLiteral
-
+
Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
break;
-
+
case Stmt::ArraySubscriptExprClass:
VisitArraySubscriptExpr(cast<ArraySubscriptExpr>(S), Pred, Dst, false);
break;
-
+
case Stmt::AsmStmtClass:
VisitAsmStmt(cast<AsmStmt>(S), Pred, Dst);
break;
-
+
case Stmt::BinaryOperatorClass: {
BinaryOperator* B = cast<BinaryOperator>(S);
-
+
if (B->isLogicalOp()) {
VisitLogicalExpr(B, Pred, Dst);
break;
@@ -348,7 +348,7 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (AMgr.shouldEagerlyAssume() && (B->isRelationalOp() || B->isEqualityOp())) {
ExplodedNodeSet Tmp;
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Tmp);
- EvalEagerlyAssume(Dst, Tmp, cast<Expr>(S));
+ EvalEagerlyAssume(Dst, Tmp, cast<Expr>(S));
}
else
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst);
@@ -365,13 +365,13 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
// FIXME: ChooseExpr is really a constant. We need to fix
// the CFG do not model them as explicit control-flow.
-
+
case Stmt::ChooseExprClass: { // __builtin_choose_expr
ChooseExpr* C = cast<ChooseExpr>(S);
VisitGuardedExpr(C, C->getLHS(), C->getRHS(), Pred, Dst);
break;
}
-
+
case Stmt::CompoundAssignOperatorClass:
VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst);
break;
@@ -379,22 +379,22 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
case Stmt::CompoundLiteralExprClass:
VisitCompoundLiteralExpr(cast<CompoundLiteralExpr>(S), Pred, Dst, false);
break;
-
+
case Stmt::ConditionalOperatorClass: { // '?' operator
ConditionalOperator* C = cast<ConditionalOperator>(S);
VisitGuardedExpr(C, C->getLHS(), C->getRHS(), Pred, Dst);
break;
}
-
+
case Stmt::DeclRefExprClass:
case Stmt::QualifiedDeclRefExprClass:
VisitDeclRefExpr(cast<DeclRefExpr>(S), Pred, Dst, false);
break;
-
+
case Stmt::DeclStmtClass:
VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
break;
-
+
case Stmt::ImplicitCastExprClass:
case Stmt::CStyleCastExprClass: {
CastExpr* C = cast<CastExpr>(S);
@@ -405,11 +405,11 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
case Stmt::InitListExprClass:
VisitInitListExpr(cast<InitListExpr>(S), Pred, Dst);
break;
-
+
case Stmt::MemberExprClass:
VisitMemberExpr(cast<MemberExpr>(S), Pred, Dst, false);
break;
-
+
case Stmt::ObjCIvarRefExprClass:
VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(S), Pred, Dst, false);
break;
@@ -417,12 +417,12 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
case Stmt::ObjCForCollectionStmtClass:
VisitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(S), Pred, Dst);
break;
-
+
case Stmt::ObjCMessageExprClass: {
VisitObjCMessageExpr(cast<ObjCMessageExpr>(S), Pred, Dst);
break;
}
-
+
case Stmt::ObjCAtThrowStmtClass: {
// FIXME: This is not complete. We basically treat @throw as
// an abort.
@@ -431,19 +431,19 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
MakeNode(Dst, S, Pred, GetState(Pred));
break;
}
-
+
case Stmt::ParenExprClass:
Visit(cast<ParenExpr>(S)->getSubExpr()->IgnoreParens(), Pred, Dst);
break;
-
+
case Stmt::ReturnStmtClass:
VisitReturnStmt(cast<ReturnStmt>(S), Pred, Dst);
break;
-
+
case Stmt::SizeOfAlignOfExprClass:
VisitSizeOfAlignOfExpr(cast<SizeOfAlignOfExpr>(S), Pred, Dst);
break;
-
+
case Stmt::StmtExprClass: {
StmtExpr* SE = cast<StmtExpr>(S);
@@ -454,21 +454,21 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
Dst.Add(Pred);
break;
}
-
+
if (Expr* LastExpr = dyn_cast<Expr>(*SE->getSubStmt()->body_rbegin())) {
const GRState* state = GetState(Pred);
MakeNode(Dst, SE, Pred, state->BindExpr(SE, state->getSVal(LastExpr)));
}
else
Dst.Add(Pred);
-
+
break;
}
case Stmt::StringLiteralClass:
VisitLValue(cast<StringLiteral>(S), Pred, Dst);
break;
-
+
case Stmt::UnaryOperatorClass: {
UnaryOperator *U = cast<UnaryOperator>(S);
if (AMgr.shouldEagerlyAssume() && (U->getOpcode() == UnaryOperator::LNot)) {
@@ -483,43 +483,43 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
}
}
-void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
+void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
-
+
Ex = Ex->IgnoreParens();
-
+
if (Ex != CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(Ex)) {
Dst.Add(Pred);
return;
}
-
+
switch (Ex->getStmtClass()) {
-
+
case Stmt::ArraySubscriptExprClass:
VisitArraySubscriptExpr(cast<ArraySubscriptExpr>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::DeclRefExprClass:
case Stmt::QualifiedDeclRefExprClass:
VisitDeclRefExpr(cast<DeclRefExpr>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::ObjCIvarRefExprClass:
VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::UnaryOperatorClass:
VisitUnaryOperator(cast<UnaryOperator>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::MemberExprClass:
VisitMemberExpr(cast<MemberExpr>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::CompoundLiteralExprClass:
VisitCompoundLiteralExpr(cast<CompoundLiteralExpr>(Ex), Pred, Dst, true);
return;
-
+
case Stmt::ObjCPropertyRefExprClass:
case Stmt::ObjCImplicitSetterGetterRefExprClass:
// FIXME: Property assignments are lvalues, but not really "locations".
@@ -542,7 +542,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, V));
return;
}
-
+
default:
// Arbitrary subexpressions can return aggregate temporaries that
// can be used in a lvalue context. We need to enhance our support
@@ -551,7 +551,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
assert ((Ex->getType()->isAggregateType()) &&
"Other kinds of expressions with non-aggregate/union types do"
" not have lvalues.");
-
+
Visit(Ex, Pred, Dst);
}
}
@@ -562,7 +562,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
bool GRExprEngine::ProcessBlockEntrance(CFGBlock* B, const GRState*,
GRBlockCounter BC) {
-
+
return BC.getNumVisited(B->getBlockID()) < 3;
}
@@ -586,53 +586,53 @@ ExplodedNode* GRExprEngine::MakeNode(ExplodedNodeSet& Dst, Stmt* S,
const GRState* GRExprEngine::MarkBranch(const GRState* state,
Stmt* Terminator,
bool branchTaken) {
-
+
switch (Terminator->getStmtClass()) {
default:
return state;
-
+
case Stmt::BinaryOperatorClass: { // '&&' and '||'
-
+
BinaryOperator* B = cast<BinaryOperator>(Terminator);
BinaryOperator::Opcode Op = B->getOpcode();
-
+
assert (Op == BinaryOperator::LAnd || Op == BinaryOperator::LOr);
-
+
// For &&, if we take the true branch, then the value of the whole
// expression is that of the RHS expression.
//
// For ||, if we take the false branch, then the value of the whole
// expression is that of the RHS expression.
-
+
Expr* Ex = (Op == BinaryOperator::LAnd && branchTaken) ||
- (Op == BinaryOperator::LOr && !branchTaken)
+ (Op == BinaryOperator::LOr && !branchTaken)
? B->getRHS() : B->getLHS();
-
+
return state->BindExpr(B, UndefinedVal(Ex));
}
-
+
case Stmt::ConditionalOperatorClass: { // ?:
-
+
ConditionalOperator* C = cast<ConditionalOperator>(Terminator);
-
+
// For ?, if branchTaken == true then the value is either the LHS or
// the condition itself. (GNU extension).
-
- Expr* Ex;
-
+
+ Expr* Ex;
+
if (branchTaken)
- Ex = C->getLHS() ? C->getLHS() : C->getCond();
+ Ex = C->getLHS() ? C->getLHS() : C->getCond();
else
Ex = C->getRHS();
-
+
return state->BindExpr(C, UndefinedVal(Ex));
}
-
+
case Stmt::ChooseExprClass: { // ?:
-
+
ChooseExpr* C = cast<ChooseExpr>(Terminator);
-
- Expr* Ex = branchTaken ? C->getLHS() : C->getRHS();
+
+ Expr* Ex = branchTaken ? C->getLHS() : C->getRHS();
return state->BindExpr(C, UndefinedVal(Ex));
}
}
@@ -652,19 +652,19 @@ static SVal RecoverCastedSymbol(GRStateManager& StateMgr, const GRState* state,
uint64_t bits = 0;
bool bitsInit = false;
-
+
while (CastExpr *CE = dyn_cast<CastExpr>(Ex)) {
QualType T = CE->getType();
if (!T->isIntegerType())
return UnknownVal();
-
+
uint64_t newBits = Ctx.getTypeSize(T);
if (!bitsInit || newBits < bits) {
bitsInit = true;
bits = newBits;
}
-
+
Ex = CE->getSubExpr();
}
@@ -673,26 +673,26 @@ static SVal RecoverCastedSymbol(GRStateManager& StateMgr, const GRState* state,
if (!bitsInit || !T->isIntegerType() || Ctx.getTypeSize(T) > bits)
return UnknownVal();
-
+
return state->getSVal(Ex);
}
void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
GRBranchNodeBuilder& builder) {
-
+
// Check for NULL conditions; e.g. "for(;;)"
- if (!Condition) {
+ if (!Condition) {
builder.markInfeasible(false);
return;
}
-
+
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),
Condition->getLocStart(),
"Error evaluating branch");
- const GRState* PrevState = builder.getState();
+ const GRState* PrevState = builder.getState();
SVal V = PrevState->getSVal(Condition);
-
+
switch (V.getBaseKind()) {
default:
break;
@@ -707,32 +707,32 @@ void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
SVal recovered = RecoverCastedSymbol(getStateManager(),
builder.getState(), Condition,
getContext());
-
+
if (!recovered.isUnknown()) {
V = recovered;
break;
}
}
}
-
+
builder.generateNode(MarkBranch(PrevState, Term, true), true);
builder.generateNode(MarkBranch(PrevState, Term, false), false);
return;
}
-
- case SVal::UndefinedKind: {
+
+ case SVal::UndefinedKind: {
ExplodedNode* N = builder.generateNode(PrevState, true);
if (N) {
N->markAsSink();
UndefBranches.insert(N);
}
-
+
builder.markInfeasible(false);
return;
- }
+ }
}
-
+
// Process the true branch.
if (builder.isFeasible(true)) {
if (const GRState *state = PrevState->assume(V, true))
@@ -740,8 +740,8 @@ void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
else
builder.markInfeasible(true);
}
-
- // Process the false branch.
+
+ // Process the false branch.
if (builder.isFeasible(false)) {
if (const GRState *state = PrevState->assume(V, false))
builder.generateNode(MarkBranch(state, Term, false), false);
@@ -754,28 +754,28 @@ void GRExprEngine::ProcessBranch(Stmt* Condition, Stmt* Term,
/// nodes by processing the 'effects' of a computed goto jump.
void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) {
- const GRState *state = builder.getState();
+ const GRState *state = builder.getState();
SVal V = state->getSVal(builder.getTarget());
-
+
// Three possibilities:
//
// (1) We know the computed label.
// (2) The label is NULL (or some other constant), or Undefined.
// (3) We have no clue about the label. Dispatch to all targets.
//
-
+
typedef GRIndirectGotoNodeBuilder::iterator iterator;
if (isa<loc::GotoLabel>(V)) {
LabelStmt* L = cast<loc::GotoLabel>(V).getLabel();
-
+
for (iterator I=builder.begin(), E=builder.end(); I != E; ++I) {
if (I.getLabel() == L) {
builder.generateNode(I, state);
return;
}
}
-
+
assert (false && "No block with label.");
return;
}
@@ -786,10 +786,10 @@ void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) {
UndefBranches.insert(N);
return;
}
-
+
// This is really a catch-all. We don't support symbolics yet.
// FIXME: Implement dispatch for symbolic pointers.
-
+
for (iterator I=builder.begin(), E=builder.end(); I != E; ++I)
builder.generateNode(I, state);
}
@@ -797,27 +797,27 @@ void GRExprEngine::ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) {
void GRExprEngine::VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R,
ExplodedNode* Pred, ExplodedNodeSet& Dst) {
-
+
assert (Ex == CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(Ex));
-
+
const GRState* state = GetState(Pred);
SVal X = state->getSVal(Ex);
-
+
assert (X.isUndef());
-
+
Expr *SE = (Expr*) cast<UndefinedVal>(X).getData();
- assert(SE);
+ assert(SE);
X = state->getSVal(SE);
-
+
// Make sure that we invalidate the previous binding.
MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, X, true));
}
/// ProcessSwitch - Called by GRCoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a switch statement.
-void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
- typedef GRSwitchNodeBuilder::iterator iterator;
- const GRState* state = builder.getState();
+void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
+ typedef GRSwitchNodeBuilder::iterator iterator;
+ const GRState* state = builder.getState();
Expr* CondE = builder.getCondition();
SVal CondV = state->getSVal(CondE);
@@ -827,55 +827,55 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
return;
}
- const GRState* DefaultSt = state;
+ const GRState* DefaultSt = state;
bool defaultIsFeasible = false;
-
+
for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
CaseStmt* Case = cast<CaseStmt>(I.getCase());
// Evaluate the LHS of the case value.
Expr::EvalResult V1;
- bool b = Case->getLHS()->Evaluate(V1, getContext());
-
+ bool b = Case->getLHS()->Evaluate(V1, getContext());
+
// Sanity checks. These go away in Release builds.
- assert(b && V1.Val.isInt() && !V1.HasSideEffects
+ assert(b && V1.Val.isInt() && !V1.HasSideEffects
&& "Case condition must evaluate to an integer constant.");
- b = b; // silence unused variable warning
- assert(V1.Val.getInt().getBitWidth() ==
+ b = b; // silence unused variable warning
+ assert(V1.Val.getInt().getBitWidth() ==
getContext().getTypeSize(CondE->getType()));
-
+
// Get the RHS of the case, if it exists.
Expr::EvalResult V2;
-
+
if (Expr* E = Case->getRHS()) {
b = E->Evaluate(V2, getContext());
- assert(b && V2.Val.isInt() && !V2.HasSideEffects
+ assert(b && V2.Val.isInt() && !V2.HasSideEffects
&& "Case condition must evaluate to an integer constant.");
b = b; // silence unused variable warning
}
else
V2 = V1;
-
+
// FIXME: Eventually we should replace the logic below with a range
// comparison, rather than concretize the values within the range.
// This should be easy once we have "ranges" for NonLVals.
-
+
do {
- nonloc::ConcreteInt CaseVal(getBasicVals().getValue(V1.Val.getInt()));
+ nonloc::ConcreteInt CaseVal(getBasicVals().getValue(V1.Val.getInt()));
SVal Res = EvalBinOp(DefaultSt, BinaryOperator::EQ, CondV, CaseVal,
getContext().IntTy);
-
- // Now "assume" that the case matches.
+
+ // Now "assume" that the case matches.
if (const GRState* stateNew = state->assume(Res, true)) {
builder.generateCaseStmtNode(I, stateNew);
-
+
// If CondV evaluates to a constant, then we know that this
// is the *only* case that we can take, so stop evaluating the
// others.
if (isa<nonloc::ConcreteInt>(CondV))
return;
}
-
+
// Now "assume" that the case doesn't match. Add this state
// to the default state (if it is feasible).
if (const GRState *stateNew = DefaultSt->assume(Res, false)) {
@@ -886,15 +886,15 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
// Concretize the next value in the range.
if (V1.Val.getInt() == V2.Val.getInt())
break;
-
+
++V1.Val.getInt();
assert (V1.Val.getInt() <= V2.Val.getInt());
-
+
} while (true);
}
-
+
// If we reach here, than we know that the default branch is
- // possible.
+ // possible.
if (defaultIsFeasible) builder.generateDefaultCaseNode(DefaultSt);
}
@@ -904,62 +904,62 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) {
void GRExprEngine::VisitLogicalExpr(BinaryOperator* B, ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
-
+
assert(B->getOpcode() == BinaryOperator::LAnd ||
B->getOpcode() == BinaryOperator::LOr);
-
+
assert(B == CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(B));
-
+
const GRState* state = GetState(Pred);
SVal X = state->getSVal(B);
assert(X.isUndef());
-
+
Expr* Ex = (Expr*) cast<UndefinedVal>(X).getData();
-
+
assert(Ex);
-
+
if (Ex == B->getRHS()) {
-
+
X = state->getSVal(Ex);
-
+
// Handle undefined values.
-
+
if (X.isUndef()) {
MakeNode(Dst, B, Pred, state->BindExpr(B, X));
return;
}
-
+
// We took the RHS. Because the value of the '&&' or '||' expression must
// evaluate to 0 or 1, we must assume the value of the RHS evaluates to 0
// or 1. Alternatively, we could take a lazy approach, and calculate this
// value later when necessary. We don't have the machinery in place for
// this right now, and since most logical expressions are used for branches,
- // the payoff is not likely to be large. Instead, we do eager evaluation.
+ // the payoff is not likely to be large. Instead, we do eager evaluation.
if (const GRState *newState = state->assume(X, true))
- MakeNode(Dst, B, Pred,
+ MakeNode(Dst, B, Pred,
newState->BindExpr(B, ValMgr.makeIntVal(1U, B->getType())));
-
+
if (const GRState *newState = state->assume(X, false))
- MakeNode(Dst, B, Pred,
+ MakeNode(Dst, B, Pred,
newState->BindExpr(B, ValMgr.makeIntVal(0U, B->getType())));
}
else {
// We took the LHS expression. Depending on whether we are '&&' or
// '||' we know what the value of the expression is via properties of
// the short-circuiting.
- X = ValMgr.makeIntVal(B->getOpcode() == BinaryOperator::LAnd ? 0U : 1U,
+ X = ValMgr.makeIntVal(B->getOpcode() == BinaryOperator::LAnd ? 0U : 1U,
B->getType());
MakeNode(Dst, B, Pred, state->BindExpr(B, X));
}
}
-
+
//===----------------------------------------------------------------------===//
// Transfer functions: Loads and stores.
//===----------------------------------------------------------------------===//
-void GRExprEngine::VisitDeclRefExpr(DeclRefExpr *Ex, ExplodedNode *Pred,
+void GRExprEngine::VisitDeclRefExpr(DeclRefExpr *Ex, ExplodedNode *Pred,
ExplodedNodeSet &Dst, bool asLValue) {
-
+
const GRState* state = GetState(Pred);
const NamedDecl* D = Ex->getDecl();
@@ -989,20 +989,20 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr *Ex, ExplodedNode *Pred,
ProgramPoint::PostLValueKind);
return;
}
-
+
assert (false &&
"ValueDecl support for this ValueDecl not implemented.");
}
/// VisitArraySubscriptExpr - Transfer function for array accesses
-void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
+void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue){
-
+
Expr* Base = A->getBase()->IgnoreParens();
Expr* Idx = A->getIdx()->IgnoreParens();
ExplodedNodeSet Tmp;
-
+
if (Base->getType()->isVectorType()) {
// For vector types get its lvalue.
// FIXME: This may not be correct. Is the rvalue of a vector its location?
@@ -1010,13 +1010,13 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
// semantics.
VisitLValue(Base, Pred, Tmp);
}
- else
+ else
Visit(Base, Pred, Tmp); // Get Base's rvalue, which should be an LocVal.
-
+
for (ExplodedNodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
ExplodedNodeSet Tmp2;
Visit(Idx, *I1, Tmp2); // Evaluate the index.
-
+
for (ExplodedNodeSet::iterator I2=Tmp2.begin(),E2=Tmp2.end();I2!=E2; ++I2) {
const GRState* state = GetState(*I2);
SVal V = state->getLValue(A->getType(), state->getSVal(Base),
@@ -1034,15 +1034,15 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A,
/// VisitMemberExpr - Transfer function for member expressions.
void GRExprEngine::VisitMemberExpr(MemberExpr* M, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue) {
-
+
Expr* Base = M->getBase()->IgnoreParens();
ExplodedNodeSet Tmp;
-
- if (M->isArrow())
+
+ if (M->isArrow())
Visit(Base, Pred, Tmp); // p->f = ... or ... = p->f
else
VisitLValue(Base, Pred, Tmp); // x.f = ... or ... = x.f
-
+
FieldDecl *Field = dyn_cast<FieldDecl>(M->getMemberDecl());
if (!Field) // FIXME: skipping member expressions for non-fields
return;
@@ -1068,7 +1068,7 @@ void GRExprEngine::EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val) {
const GRState* newState = 0;
-
+
if (location.isUnknown()) {
// We know that the new state will be the same as the old state since
// the location of the binding is "unknown". Consequently, there
@@ -1086,7 +1086,7 @@ void GRExprEngine::EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
// doesn't do anything, just auto-propagate the current state.
GRStmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, Pred, newState, Ex,
newState != state);
-
+
getTF().EvalBind(BuilderRef, location, Val);
}
@@ -1099,19 +1099,19 @@ void GRExprEngine::EvalBind(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location, SVal Val,
const void *tag) {
-
+
assert (Builder && "GRStmtNodeBuilder must be defined.");
-
+
// Evaluate the location (checks for bad dereferences).
Pred = EvalLocation(Ex, Pred, state, location, tag);
-
+
if (!Pred)
return;
assert (!location.isUndef());
state = GetState(Pred);
- // Proceed with the store.
+ // Proceed with the store.
SaveAndRestore<ProgramPoint::Kind> OldSPointKind(Builder->PointKind);
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->PointKind = ProgramPoint::PostStoreKind;
@@ -1123,14 +1123,14 @@ void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
const GRState* state, SVal location,
const void *tag) {
- // Evaluate the location (checks for bad dereferences).
+ // Evaluate the location (checks for bad dereferences).
Pred = EvalLocation(Ex, Pred, state, location, tag);
-
+
if (!Pred)
return;
-
+
state = GetState(Pred);
-
+
// Proceed with the load.
ProgramPoint::Kind K = ProgramPoint::PostLoadKind;
@@ -1144,7 +1144,7 @@ void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
}
else {
SVal V = state->getSVal(cast<Loc>(location), Ex->getType());
-
+
// Casts can create weird scenarios where a location must be implicitly
// converted to something else. For example:
//
@@ -1152,19 +1152,19 @@ void GRExprEngine::EvalLoad(ExplodedNodeSet& Dst, Expr* Ex, ExplodedNode* Pred,
// int *y = (int*) &x; // void** -> int* cast.
// invalidate(y); // 'x' now binds to a symbolic region
// int z = *y;
- //
+ //
//if (isa<Loc>(V) && !Loc::IsLocType(Ex->getType())) {
// V = EvalCast(V, Ex->getType());
//}
-
+
MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, V), K, tag);
}
}
-void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, Expr* StoreE,
- ExplodedNode* Pred, const GRState* state,
+void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, Expr* StoreE,
+ ExplodedNode* Pred, const GRState* state,
SVal location, SVal Val, const void *tag) {
-
+
ExplodedNodeSet TmpDst;
EvalStore(TmpDst, StoreE, Pred, state, location, Val, tag);
@@ -1175,60 +1175,60 @@ void GRExprEngine::EvalStore(ExplodedNodeSet& Dst, Expr* Ex, Expr* StoreE,
ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
const GRState* state, SVal location,
const void *tag) {
-
+
SaveAndRestore<const void*> OldTag(Builder->Tag);
Builder->Tag = tag;
-
- // Check for loads/stores from/to undefined values.
+
+ // Check for loads/stores from/to undefined values.
if (location.isUndef()) {
ExplodedNode* N =
Builder->generateNode(Ex, state, Pred,
ProgramPoint::PostUndefLocationCheckFailedKind);
-
+
if (N) {
N->markAsSink();
UndefDeref.insert(N);
}
-
+
return 0;
}
-
+
// Check for loads/stores from/to unknown locations. Treat as No-Ops.
if (location.isUnknown())
return Pred;
-
+
// During a load, one of two possible situations arise:
// (1) A crash, because the location (pointer) was NULL.
// (2) The location (pointer) is not NULL, and the dereference works.
- //
+ //
// We add these assumptions.
-
- Loc LV = cast<Loc>(location);
-
+
+ Loc LV = cast<Loc>(location);
+
// "Assume" that the pointer is not NULL.
const GRState *StNotNull = state->assume(LV, true);
-
+
// "Assume" that the pointer is NULL.
const GRState *StNull = state->assume(LV, false);
- if (StNull) {
+ if (StNull) {
// Use the Generic Data Map to mark in the state what lval was null.
const SVal* PersistentLV = getBasicVals().getPersistentSVal(LV);
StNull = StNull->set<GRState::NullDerefTag>(PersistentLV);
-
+
// We don't use "MakeNode" here because the node will be a sink
// and we have no intention of processing it later.
ExplodedNode* NullNode =
- Builder->generateNode(Ex, StNull, Pred,
+ Builder->generateNode(Ex, StNull, Pred,
ProgramPoint::PostNullCheckFailedKind);
- if (NullNode) {
- NullNode->markAsSink();
+ if (NullNode) {
+ NullNode->markAsSink();
if (StNotNull) ImplicitNullDeref.insert(NullNode);
else ExplicitNullDeref.insert(NullNode);
}
}
-
+
if (!StNotNull)
return NULL;
@@ -1245,9 +1245,9 @@ ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
SVal NumElements = getStoreManager().getSizeInElements(StNotNull,
ER->getSuperRegion());
- const GRState * StInBound = StNotNull->assumeInBound(Idx, NumElements,
+ const GRState * StInBound = StNotNull->assumeInBound(Idx, NumElements,
true);
- const GRState* StOutBound = StNotNull->assumeInBound(Idx, NumElements,
+ const GRState* StOutBound = StNotNull->assumeInBound(Idx, NumElements,
false);
if (StOutBound) {
@@ -1273,7 +1273,7 @@ ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
}
}
#endif
-
+
// Generate a new node indicating the checks succeed.
return Builder->generateNode(Ex, StNotNull, Pred,
ProgramPoint::PostLocationChecksSucceedKind);
@@ -1292,45 +1292,45 @@ ExplodedNode* GRExprEngine::EvalLocation(Stmt* Ex, ExplodedNode* Pred,
static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
GRExprEngine& Engine,
GRStmtNodeBuilder& Builder,
- CallExpr* CE, SVal L,
+ CallExpr* CE, SVal L,
ExplodedNode* Pred) {
// Not enough arguments to match OSAtomicCompareAndSwap?
if (CE->getNumArgs() != 3)
return false;
-
+
ASTContext &C = Engine.getContext();
Expr *oldValueExpr = CE->getArg(0);
QualType oldValueType = C.getCanonicalType(oldValueExpr->getType());
Expr *newValueExpr = CE->getArg(1);
QualType newValueType = C.getCanonicalType(newValueExpr->getType());
-
+
// Do the types of 'oldValue' and 'newValue' match?
if (oldValueType != newValueType)
return false;
-
+
Expr *theValueExpr = CE->getArg(2);
const PointerType *theValueType =
theValueExpr->getType()->getAs<PointerType>();
-
+
// theValueType not a pointer?
if (!theValueType)
return false;
-
+
QualType theValueTypePointee =
C.getCanonicalType(theValueType->getPointeeType()).getUnqualifiedType();
-
+
// The pointee must match newValueType and oldValueType.
if (theValueTypePointee != newValueType)
return false;
-
+
static unsigned magic_load = 0;
static unsigned magic_store = 0;
const void *OSAtomicLoadTag = &magic_load;
const void *OSAtomicStoreTag = &magic_store;
-
+
// Load 'theValue'.
const GRState *state = Pred->getState();
ExplodedNodeSet Tmp;
@@ -1339,41 +1339,41 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end();
I != E; ++I) {
-
+
ExplodedNode *N = *I;
const GRState *stateLoad = N->getState();
SVal theValueVal = stateLoad->getSVal(theValueExpr);
SVal oldValueVal = stateLoad->getSVal(oldValueExpr);
-
+
// FIXME: Issue an error.
if (theValueVal.isUndef() || oldValueVal.isUndef()) {
- return false;
+ return false;
}
-
+
SValuator &SVator = Engine.getSValuator();
-
+
// Perform the comparison.
SVal Cmp = SVator.EvalBinOp(stateLoad, BinaryOperator::EQ, theValueVal,
oldValueVal, Engine.getContext().IntTy);
const GRState *stateEqual = stateLoad->assume(Cmp, true);
-
+
// Were they equal?
if (stateEqual) {
// Perform the store.
ExplodedNodeSet TmpStore;
SVal val = stateEqual->getSVal(newValueExpr);
-
+
// Handle implicit value casts.
if (const TypedRegion *R =
dyn_cast_or_null<TypedRegion>(location.getAsRegion())) {
llvm::tie(state, val) = SVator.EvalCast(val, state, R->getValueType(C),
newValueExpr->getType());
- }
-
- Engine.EvalStore(TmpStore, theValueExpr, N, stateEqual, location,
+ }
+
+ Engine.EvalStore(TmpStore, theValueExpr, N, stateEqual, location,
val, OSAtomicStoreTag);
-
+
// Now bind the result of the comparison.
for (ExplodedNodeSet::iterator I2 = TmpStore.begin(),
E2 = TmpStore.end(); I2 != E2; ++I2) {
@@ -1383,14 +1383,14 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
Engine.MakeNode(Dst, CE, predNew, stateNew->BindExpr(CE, Res));
}
}
-
+
// Were they not equal?
if (const GRState *stateNotEqual = stateLoad->assume(Cmp, false)) {
SVal Res = Engine.getValueManager().makeTruthVal(false, CE->getType());
Engine.MakeNode(Dst, CE, N, stateNotEqual->BindExpr(CE, Res));
}
}
-
+
return true;
}
@@ -1404,7 +1404,7 @@ static bool EvalOSAtomic(ExplodedNodeSet& Dst,
return false;
const char *FName = FD->getNameAsCString();
-
+
// Check for compare and swap.
if (strncmp(FName, "OSAtomicCompareAndSwap", 22) == 0 ||
strncmp(FName, "objc_atomicCompareAndSwap", 25) == 0)
@@ -1418,12 +1418,12 @@ static bool EvalOSAtomic(ExplodedNodeSet& Dst,
// Transfer function: Function calls.
//===----------------------------------------------------------------------===//
static void MarkNoReturnFunction(const FunctionDecl *FD, CallExpr *CE,
- const GRState *state,
+ const GRState *state,
GRStmtNodeBuilder *Builder) {
if (!FD)
return;
- if (FD->getAttr<NoReturnAttr>() ||
+ if (FD->getAttr<NoReturnAttr>() ||
FD->getAttr<AnalyzerNoReturnAttr>())
Builder->BuildSinks = true;
else {
@@ -1432,11 +1432,11 @@ static void MarkNoReturnFunction(const FunctionDecl *FD, CallExpr *CE,
// potentially cache these results.
const char* s = FD->getIdentifier()->getName();
unsigned n = strlen(s);
-
+
switch (n) {
default:
break;
-
+
case 4:
if (!memcmp(s, "exit", 4)) Builder->BuildSinks = true;
break;
@@ -1460,37 +1460,37 @@ static void MarkNoReturnFunction(const FunctionDecl *FD, CallExpr *CE,
Builder->BuildSinks = true;
break;
}
-
+
// FIXME: This is just a wrapper around throwing an exception.
// Eventually inter-procedural analysis should handle this easily.
if (!memcmp(s, "ziperr", 6)) Builder->BuildSinks = true;
break;
-
+
case 7:
if (!memcmp(s, "assfail", 7)) Builder->BuildSinks = true;
break;
-
+
case 8:
- if (!memcmp(s ,"db_error", 8) ||
+ if (!memcmp(s ,"db_error", 8) ||
!memcmp(s, "__assert", 8))
Builder->BuildSinks = true;
break;
-
+
case 12:
if (!memcmp(s, "__assert_rtn", 12)) Builder->BuildSinks = true;
break;
-
+
case 13:
if (!memcmp(s, "__assert_fail", 13)) Builder->BuildSinks = true;
break;
-
+
case 14:
if (!memcmp(s, "dtrace_assfail", 14) ||
!memcmp(s, "yy_fatal_error", 14))
Builder->BuildSinks = true;
break;
-
+
case 26:
if (!memcmp(s, "_XCAssertionFailureHandler", 26) ||
!memcmp(s, "_DTAssertionFailureHandler", 26) ||
@@ -1499,7 +1499,7 @@ static void MarkNoReturnFunction(const FunctionDecl *FD, CallExpr *CE,
break;
}
-
+
}
}
@@ -1508,7 +1508,7 @@ bool GRExprEngine::EvalBuiltinFunction(const FunctionDecl *FD, CallExpr *CE,
ExplodedNodeSet &Dst) {
if (!FD)
return false;
-
+
unsigned id = FD->getBuiltinID(getContext());
if (!id)
return false;
@@ -1518,18 +1518,18 @@ bool GRExprEngine::EvalBuiltinFunction(const FunctionDecl *FD, CallExpr *CE,
switch (id) {
case Builtin::BI__builtin_expect: {
// For __builtin_expect, just return the value of the subexpression.
- assert (CE->arg_begin() != CE->arg_end());
+ assert (CE->arg_begin() != CE->arg_end());
SVal X = state->getSVal(*(CE->arg_begin()));
MakeNode(Dst, CE, Pred, state->BindExpr(CE, X));
return true;
}
-
+
case Builtin::BI__builtin_alloca: {
// FIXME: Refactor into StoreManager itself?
MemRegionManager& RM = getStateManager().getRegionManager();
const MemRegion* R =
RM.getAllocaRegion(CE, Builder->getCurrentBlockCount());
-
+
// Set the extent of the region in bytes. This enables us to use the
// SVal of the argument directly. If we save the extent in bits, we
// cannot represent values like symbol*8.
@@ -1543,22 +1543,21 @@ bool GRExprEngine::EvalBuiltinFunction(const FunctionDecl *FD, CallExpr *CE,
return false;
}
-void GRExprEngine::EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L,
+void GRExprEngine::EvalCall(ExplodedNodeSet& Dst, CallExpr* CE, SVal L,
ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
-
+
// FIXME: Allow us to chain together transfer functions.
if (EvalOSAtomic(Dst, *this, *Builder, CE, L, Pred))
return;
-
+
getTF().EvalCall(Dst, *this, *Builder, CE, L, Pred);
}
void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- ExplodedNodeSet& Dst)
-{
+ ExplodedNodeSet& Dst) {
// Determine the type of function we're calling (if available).
const FunctionProtoType *Proto = NULL;
QualType FnType = CE->getCallee()->IgnoreParens()->getType();
@@ -1571,10 +1570,10 @@ void GRExprEngine::VisitCall(CallExpr* CE, ExplodedNode* Pred,
void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
CallExpr::arg_iterator AI,
CallExpr::arg_iterator AE,
- ExplodedNodeSet& Dst,
- const FunctionProtoType *Proto,
+ ExplodedNodeSet& Dst,
+ const FunctionProtoType *Proto,
unsigned ParamIdx) {
-
+
// Process the arguments.
if (AI != AE) {
// If the call argument is being bound to a reference parameter,
@@ -1583,17 +1582,17 @@ void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
if (Proto && ParamIdx < Proto->getNumArgs())
VisitAsLvalue = Proto->getArgType(ParamIdx)->isReferenceType();
- ExplodedNodeSet DstTmp;
+ ExplodedNodeSet DstTmp;
if (VisitAsLvalue)
- VisitLValue(*AI, Pred, DstTmp);
+ VisitLValue(*AI, Pred, DstTmp);
else
- Visit(*AI, Pred, DstTmp);
+ Visit(*AI, Pred, DstTmp);
++AI;
-
+
for (ExplodedNodeSet::iterator DI=DstTmp.begin(), DE=DstTmp.end(); DI != DE;
++DI)
VisitCallRec(CE, *DI, AI, AE, Dst, Proto, ParamIdx + 1);
-
+
return;
}
@@ -1601,17 +1600,17 @@ void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
// the callee expression.
ExplodedNodeSet DstTmp;
Expr* Callee = CE->getCallee()->IgnoreParens();
-
+
{ // Enter new scope to make the lifetime of 'DstTmp2' bounded.
ExplodedNodeSet DstTmp2;
Visit(Callee, Pred, DstTmp2);
-
+
// Perform the previsit of the CallExpr, storing the results in DstTmp.
CheckerVisit(CE, DstTmp, DstTmp2, true);
}
-
+
// Finally, evaluate the function call.
- for (ExplodedNodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end();
+ for (ExplodedNodeSet::iterator DI = DstTmp.begin(), DE = DstTmp.end();
DI != DE; ++DI) {
const GRState* state = GetState(*DI);
@@ -1621,25 +1620,25 @@ void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred,
// function pointer values that are symbolic).
// Check for the "noreturn" attribute.
-
+
SaveAndRestore<bool> OldSink(Builder->BuildSinks);
const FunctionDecl* FD = L.getAsFunctionDecl();
MarkNoReturnFunction(FD, CE, state, Builder);
-
+
// Evaluate the call.
if (EvalBuiltinFunction(FD, CE, *DI, Dst))
continue;
- // Dispatch to the plug-in transfer function.
-
+ // Dispatch to the plug-in transfer function.
+
unsigned size = Dst.size();
SaveOr OldHasGen(Builder->HasGeneratedNode);
EvalCall(Dst, CE, L, *DI);
-
+
// Handle the case where no nodes where generated. Auto-generate that
// contains the updated state if we aren't generating sinks.
-
+
if (!Builder->BuildSinks && Dst.size() == size &&
!Builder->HasGeneratedNode)
MakeNode(Dst, CE, *DI, state);
@@ -1656,31 +1655,31 @@ static std::pair<const void*,const void*> EagerlyAssumeTag
void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, Expr *Ex) {
for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) {
ExplodedNode *Pred = *I;
-
+
// Test if the previous node was as the same expression. This can happen
// when the expression fails to evaluate to anything meaningful and
// (as an optimization) we don't generate a node.
- ProgramPoint P = Pred->getLocation();
+ ProgramPoint P = Pred->getLocation();
if (!isa<PostStmt>(P) || cast<PostStmt>(P).getStmt() != Ex) {
- Dst.Add(Pred);
+ Dst.Add(Pred);
continue;
- }
+ }
- const GRState* state = Pred->getState();
- SVal V = state->getSVal(Ex);
+ const GRState* state = Pred->getState();
+ SVal V = state->getSVal(Ex);
if (isa<nonloc::SymExprVal>(V)) {
// First assume that the condition is true.
if (const GRState *stateTrue = state->assume(V, true)) {
- stateTrue = stateTrue->BindExpr(Ex,
+ stateTrue = stateTrue->BindExpr(Ex,
ValMgr.makeIntVal(1U, Ex->getType()));
- Dst.Add(Builder->generateNode(PostStmtCustom(Ex,
+ Dst.Add(Builder->generateNode(PostStmtCustom(Ex,
&EagerlyAssumeTag, Pred->getLocationContext()),
stateTrue, Pred));
}
-
+
// Next, assume that the condition is false.
if (const GRState *stateFalse = state->assume(V, false)) {
- stateFalse = stateFalse->BindExpr(Ex,
+ stateFalse = stateFalse->BindExpr(Ex,
ValMgr.makeIntVal(0U, Ex->getType()));
Dst.Add(Builder->generateNode(PostStmtCustom(Ex, &EagerlyAssumeTag,
Pred->getLocationContext()),
@@ -1699,16 +1698,16 @@ void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
ExplodedNode* Pred, ExplodedNodeSet& Dst,
bool asLValue) {
-
+
Expr* Base = cast<Expr>(Ex->getBase());
ExplodedNodeSet Tmp;
Visit(Base, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal BaseVal = state->getSVal(Base);
SVal location = state->getLValue(Ex->getDecl(), BaseVal);
-
+
if (asLValue)
MakeNode(Dst, Ex, *I, state->BindExpr(Ex, location));
else
@@ -1722,7 +1721,7 @@ void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
ExplodedNode* Pred, ExplodedNodeSet& Dst) {
-
+
// ObjCForCollectionStmts are processed in two places. This method
// handles the case where an ObjCForCollectionStmt* occurs as one of the
// statements within a basic block. This transfer function does two things:
@@ -1734,7 +1733,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
// whether or not the container has any more elements. This value
// will be tested in ProcessBranch. We need to explicitly bind
// this value because a container can contain nil elements.
- //
+ //
// FIXME: Eventually this logic should actually do dispatches to
// 'countByEnumeratingWithState:objects:count:' (NSFastEnumeration).
// This will require simulating a temporary NSFastEnumerationState, either
@@ -1747,10 +1746,10 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
// For now: simulate (1) by assigning either a symbol or nil if the
// container is empty. Thus this transfer function will by default
// result in state splitting.
-
+
Stmt* elem = S->getElement();
SVal ElementV;
-
+
if (DeclStmt* DS = dyn_cast<DeclStmt>(elem)) {
VarDecl* ElemD = cast<VarDecl>(DS->getSingleDecl());
assert (ElemD->getInit() == 0);
@@ -1761,7 +1760,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
ExplodedNodeSet Tmp;
VisitLValue(cast<Expr>(elem), Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
VisitObjCForCollectionStmtAux(S, *I, Dst, state->getSVal(elem));
@@ -1771,27 +1770,27 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S,
void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S,
ExplodedNode* Pred, ExplodedNodeSet& Dst,
SVal ElementV) {
-
-
+
+
// Get the current state. Use 'EvalLocation' to determine if it is a null
// pointer, etc.
Stmt* elem = S->getElement();
-
+
Pred = EvalLocation(elem, Pred, GetState(Pred), ElementV);
if (!Pred)
return;
-
+
const GRState *state = GetState(Pred);
// Handle the case where the container still has elements.
SVal TrueV = ValMgr.makeTruthVal(1);
const GRState *hasElems = state->BindExpr(S, TrueV);
-
+
// Handle the case where the container has no elements.
SVal FalseV = ValMgr.makeTruthVal(0);
const GRState *noElems = state->BindExpr(S, FalseV);
-
+
if (loc::MemRegionVal* MV = dyn_cast<loc::MemRegionVal>(&ElementV))
if (const TypedRegion* R = dyn_cast<TypedRegion>(MV->getRegion())) {
// FIXME: The proper thing to do is to really iterate over the
@@ -1805,10 +1804,10 @@ void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S,
hasElems = hasElems->bindLoc(ElementV, V);
// Bind the location to 'nil' on the false branch.
- SVal nilV = ValMgr.makeIntVal(0, T);
- noElems = noElems->bindLoc(ElementV, nilV);
+ SVal nilV = ValMgr.makeIntVal(0, T);
+ noElems = noElems->bindLoc(ElementV, nilV);
}
-
+
// Create the new nodes.
MakeNode(Dst, S, Pred, hasElems);
MakeNode(Dst, S, Pred, noElems);
@@ -1820,38 +1819,38 @@ void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S,
void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred,
ExplodedNodeSet& Dst){
-
+
VisitObjCMessageExprArgHelper(ME, ME->arg_begin(), ME->arg_end(),
Pred, Dst);
-}
+}
void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
ObjCMessageExpr::arg_iterator AI,
ObjCMessageExpr::arg_iterator AE,
ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (AI == AE) {
-
+
// Process the receiver.
-
+
if (Expr* Receiver = ME->getReceiver()) {
ExplodedNodeSet Tmp;
Visit(Receiver, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprDispatchHelper(ME, *NI, Dst);
-
+
return;
}
-
+
VisitObjCMessageExprDispatchHelper(ME, Pred, Dst);
return;
}
-
+
ExplodedNodeSet Tmp;
Visit(*AI, Pred, Tmp);
-
+
++AI;
-
+
for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitObjCMessageExprArgHelper(ME, AI, AE, *NI, Dst);
}
@@ -1859,53 +1858,53 @@ void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME,
void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
-
- // FIXME: More logic for the processing the method call.
-
+
+ // FIXME: More logic for the processing the method call.
+
const GRState* state = GetState(Pred);
bool RaisesException = false;
-
-
+
+
if (Expr* Receiver = ME->getReceiver()) {
-
+
SVal L = state->getSVal(Receiver);
-
- // Check for undefined control-flow.
+
+ // Check for undefined control-flow.
if (L.isUndef()) {
ExplodedNode* N = Builder->generateNode(ME, state, Pred);
-
+
if (N) {
N->markAsSink();
UndefReceivers.insert(N);
}
-
+
return;
}
-
- // "Assume" that the receiver is not NULL.
+
+ // "Assume" that the receiver is not NULL.
const GRState *StNotNull = state->assume(L, true);
-
- // "Assume" that the receiver is NULL.
+
+ // "Assume" that the receiver is NULL.
const GRState *StNull = state->assume(L, false);
-
+
if (StNull) {
QualType RetTy = ME->getType();
-
+
// Check if the receiver was nil and the return value a struct.
- if(RetTy->isRecordType()) {
+ if (RetTy->isRecordType()) {
if (BR.getParentMap().isConsumedExpr(ME)) {
// The [0 ...] expressions will return garbage. Flag either an
// explicit or implicit error. Because of the structure of this
// function we currently do not bifurfacte the state graph at
// this point.
// FIXME: We should bifurcate and fill the returned struct with
- // garbage.
+ // garbage.
if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
if (StNotNull)
NilReceiverStructRetImplicit.insert(N);
else
- NilReceiverStructRetExplicit.insert(N);
+ NilReceiverStructRetExplicit.insert(N);
}
}
}
@@ -1918,13 +1917,13 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
// sizeof(return type)
const uint64_t returnTypeSize = Ctx.getTypeSize(ME->getType());
- if(voidPtrSize < returnTypeSize) {
+ if (voidPtrSize < returnTypeSize) {
if (ExplodedNode* N = Builder->generateNode(ME, StNull, Pred)) {
N->markAsSink();
- if(StNotNull)
+ if (StNotNull)
NilReceiverLargerThanVoidPtrRetImplicit.insert(N);
else
- NilReceiverLargerThanVoidPtrRetExplicit.insert(N);
+ NilReceiverLargerThanVoidPtrRetExplicit.insert(N);
}
}
else if (!StNotNull) {
@@ -1952,99 +1951,99 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
// of this method should assume that the receiver is not nil.
if (!StNotNull)
return;
-
+
state = StNotNull;
}
-
+
// Check if the "raise" message was sent.
if (ME->getSelector() == RaiseSel)
RaisesException = true;
}
else {
-
+
IdentifierInfo* ClsName = ME->getClassName();
Selector S = ME->getSelector();
-
+
// Check for special instance methods.
-
- if (!NSExceptionII) {
+
+ if (!NSExceptionII) {
ASTContext& Ctx = getContext();
-
+
NSExceptionII = &Ctx.Idents.get("NSException");
}
-
+
if (ClsName == NSExceptionII) {
-
+
enum { NUM_RAISE_SELECTORS = 2 };
-
+
// Lazily create a cache of the selectors.
if (!NSExceptionInstanceRaiseSelectors) {
-
+
ASTContext& Ctx = getContext();
-
+
NSExceptionInstanceRaiseSelectors = new Selector[NUM_RAISE_SELECTORS];
-
+
llvm::SmallVector<IdentifierInfo*, NUM_RAISE_SELECTORS> II;
unsigned idx = 0;
-
- // raise:format:
+
+ // raise:format:
II.push_back(&Ctx.Idents.get("raise"));
- II.push_back(&Ctx.Idents.get("format"));
+ II.push_back(&Ctx.Idents.get("format"));
NSExceptionInstanceRaiseSelectors[idx++] =
- Ctx.Selectors.getSelector(II.size(), &II[0]);
-
- // raise:format::arguments:
+ Ctx.Selectors.getSelector(II.size(), &II[0]);
+
+ // raise:format::arguments:
II.push_back(&Ctx.Idents.get("arguments"));
NSExceptionInstanceRaiseSelectors[idx++] =
Ctx.Selectors.getSelector(II.size(), &II[0]);
}
-
+
for (unsigned i = 0; i < NUM_RAISE_SELECTORS; ++i)
if (S == NSExceptionInstanceRaiseSelectors[i]) {
RaisesException = true; break;
}
}
}
-
+
// Check for any arguments that are uninitialized/undefined.
-
+
for (ObjCMessageExpr::arg_iterator I = ME->arg_begin(), E = ME->arg_end();
I != E; ++I) {
-
+
if (state->getSVal(*I).isUndef()) {
-
+
// Generate an error node for passing an uninitialized/undefined value
// as an argument to a message expression. This node is a sink.
ExplodedNode* N = Builder->generateNode(ME, state, Pred);
-
+
if (N) {
N->markAsSink();
MsgExprUndefArgs[N] = *I;
}
-
+
return;
- }
+ }
}
-
+
// Check if we raise an exception. For now treat these as sinks. Eventually
// we will want to handle exceptions properly.
-
+
SaveAndRestore<bool> OldSink(Builder->BuildSinks);
if (RaisesException)
Builder->BuildSinks = true;
-
+
// Dispatch to plug-in transfer function.
-
+
unsigned size = Dst.size();
SaveOr OldHasGen(Builder->HasGeneratedNode);
-
+
EvalObjCMessageExpr(Dst, ME, Pred);
-
+
// Handle the case where no nodes where generated. Auto-generate that
// contains the updated state if we aren't generating sinks.
-
+
if (!Builder->BuildSinks && Dst.size() == size && !Builder->HasGeneratedNode)
MakeNode(Dst, ME, Pred, state);
}
@@ -2065,9 +2064,9 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, Exploded
VisitLValue(Ex, Pred, S1);
else
Visit(Ex, Pred, S1);
-
+
// Check for casting to "void".
- if (T->isVoidType()) {
+ if (T->isVoidType()) {
for (ExplodedNodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1)
Dst.Add(*I1);
@@ -2085,13 +2084,13 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, ExplodedNode* Pred, Exploded
}
void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL,
- ExplodedNode* Pred,
- ExplodedNodeSet& Dst,
+ ExplodedNode* Pred,
+ ExplodedNodeSet& Dst,
bool asLValue) {
InitListExpr* ILE = cast<InitListExpr>(CL->getInitializer()->IgnoreParens());
ExplodedNodeSet Tmp;
Visit(ILE, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
const GRState* state = GetState(*I);
SVal ILV = state->getSVal(ILE);
@@ -2105,15 +2104,15 @@ void GRExprEngine::VisitCompoundLiteralExpr(CompoundLiteralExpr* CL,
}
void GRExprEngine::VisitDeclStmt(DeclStmt *DS, ExplodedNode *Pred,
- ExplodedNodeSet& Dst) {
+ ExplodedNodeSet& Dst) {
- // The CFG has one DeclStmt per Decl.
+ // The CFG has one DeclStmt per Decl.
Decl* D = *DS->decl_begin();
-
+
if (!D || !isa<VarDecl>(D))
return;
-
- const VarDecl* VD = dyn_cast<VarDecl>(D);
+
+ const VarDecl* VD = dyn_cast<VarDecl>(D);
Expr* InitEx = const_cast<Expr*>(VD->getInit());
// FIXME: static variables may have an initializer, but the second
@@ -2124,7 +2123,7 @@ void GRExprEngine::VisitDeclStmt(DeclStmt *DS, ExplodedNode *Pred,
Visit(InitEx, Pred, Tmp);
else
Tmp.Add(Pred);
-
+
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
unsigned Count = Builder->getCurrentBlockCount();
@@ -2133,58 +2132,58 @@ void GRExprEngine::VisitDeclStmt(DeclStmt *DS, ExplodedNode *Pred,
QualType T = getContext().getCanonicalType(VD->getType());
if (VariableArrayType* VLA = dyn_cast<VariableArrayType>(T)) {
// FIXME: Handle multi-dimensional VLAs.
-
+
Expr* SE = VLA->getSizeExpr();
SVal Size = state->getSVal(SE);
-
+
if (Size.isUndef()) {
if (ExplodedNode* N = Builder->generateNode(DS, state, Pred)) {
- N->markAsSink();
+ N->markAsSink();
ExplicitBadSizedVLA.insert(N);
}
continue;
}
-
- const GRState* zeroState = state->assume(Size, false);
+
+ const GRState* zeroState = state->assume(Size, false);
state = state->assume(Size, true);
-
+
if (zeroState) {
if (ExplodedNode* N = Builder->generateNode(DS, zeroState, Pred)) {
- N->markAsSink();
+ N->markAsSink();
if (state)
ImplicitBadSizedVLA.insert(N);
else
ExplicitBadSizedVLA.insert(N);
}
}
-
+
if (!state)
- continue;
+ continue;
}
-
+
// Decls without InitExpr are not initialized explicitly.
const LocationContext *LC = (*I)->getLocationContext();
if (InitEx) {
SVal InitVal = state->getSVal(InitEx);
QualType T = VD->getType();
-
+
// Recover some path-sensitivity if a scalar value evaluated to
// UnknownVal.
- if (InitVal.isUnknown() ||
+ if (InitVal.isUnknown() ||
!getConstraintManager().canReasonAbout(InitVal)) {
InitVal = ValMgr.getConjuredSymbolVal(InitEx, Count);
- }
-
+ }
+
state = state->bindDecl(VD, LC, InitVal);
-
+
// The next thing to do is check if the GRTransferFuncs object wants to
// update the state based on the new binding. If the GRTransferFunc
// object doesn't do anything, just auto-propagate the current state.
GRStmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, *I, state, DS,true);
getTF().EvalBind(BuilderRef, loc::MemRegionVal(state->getRegion(VD, LC)),
- InitVal);
- }
+ InitVal);
+ }
else {
state = state->bindDeclWithNoInit(VD, LC);
MakeNode(Dst, DS, *I, state);
@@ -2200,7 +2199,7 @@ public:
llvm::ImmutableList<SVal> Vals;
ExplodedNode* N;
InitListExpr::reverse_iterator Itr;
-
+
InitListWLItem(ExplodedNode* n, llvm::ImmutableList<SVal> vals,
InitListExpr::reverse_iterator itr)
: Vals(vals), N(n), Itr(itr) {}
@@ -2208,52 +2207,52 @@ public:
}
-void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
+void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
const GRState* state = GetState(Pred);
QualType T = getContext().getCanonicalType(E->getType());
- unsigned NumInitElements = E->getNumInits();
+ unsigned NumInitElements = E->getNumInits();
if (T->isArrayType() || T->isStructureType() ||
T->isUnionType() || T->isVectorType()) {
llvm::ImmutableList<SVal> StartVals = getBasicVals().getEmptySValList();
-
+
// Handle base case where the initializer has no elements.
// e.g: static int* myArray[] = {};
if (NumInitElements == 0) {
SVal V = ValMgr.makeCompoundVal(T, StartVals);
MakeNode(Dst, E, Pred, state->BindExpr(E, V));
return;
- }
-
+ }
+
// Create a worklist to process the initializers.
llvm::SmallVector<InitListWLItem, 10> WorkList;
- WorkList.reserve(NumInitElements);
- WorkList.push_back(InitListWLItem(Pred, StartVals, E->rbegin()));
+ WorkList.reserve(NumInitElements);
+ WorkList.push_back(InitListWLItem(Pred, StartVals, E->rbegin()));
InitListExpr::reverse_iterator ItrEnd = E->rend();
-
+
// Process the worklist until it is empty.
while (!WorkList.empty()) {
InitListWLItem X = WorkList.back();
WorkList.pop_back();
-
+
ExplodedNodeSet Tmp;
Visit(*X.Itr, X.N, Tmp);
-
+
InitListExpr::reverse_iterator NewItr = X.Itr + 1;
for (ExplodedNodeSet::iterator NI=Tmp.begin(), NE=Tmp.end(); NI!=NE; ++NI) {
// Get the last initializer value.
state = GetState(*NI);
SVal InitV = state->getSVal(cast<Expr>(*X.Itr));
-
+
// Construct the new list of values by prepending the new value to
// the already constructed list.
llvm::ImmutableList<SVal> NewVals =
getBasicVals().consVals(InitV, X.Vals);
-
+
if (NewItr == ItrEnd) {
// Now we have a list holding all init values. Make CompoundValData.
SVal V = ValMgr.makeCompoundVal(T, NewVals);
@@ -2267,7 +2266,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
}
}
}
-
+
return;
}
@@ -2293,10 +2292,10 @@ void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
QualType T = Ex->getTypeOfArgument();
- uint64_t amt;
-
+ uint64_t amt;
+
if (Ex->isSizeOf()) {
- if (T == getContext().VoidTy) {
+ if (T == getContext().VoidTy) {
// sizeof(void) == 1 byte.
amt = 1;
}
@@ -2307,17 +2306,17 @@ void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
else if (T->isObjCInterfaceType()) {
// Some code tries to take the sizeof an ObjCInterfaceType, relying that
// the compiler has laid out its representation. Just report Unknown
- // for these.
+ // for these.
return;
}
else {
// All other cases.
amt = getContext().getTypeSize(T) / 8;
- }
+ }
}
else // Get alignment of the type.
amt = getContext().getTypeAlign(T) / 8;
-
+
MakeNode(Dst, Ex, Pred,
GetState(Pred)->BindExpr(Ex, ValMgr.makeIntVal(amt, Ex->getType())));
}
@@ -2327,61 +2326,61 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
ExplodedNodeSet& Dst, bool asLValue) {
switch (U->getOpcode()) {
-
+
default:
break;
-
+
case UnaryOperator::Deref: {
-
+
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
-
+
const GRState* state = GetState(*I);
SVal location = state->getSVal(Ex);
-
+
if (asLValue)
MakeNode(Dst, U, *I, state->BindExpr(U, location),
ProgramPoint::PostLValueKind);
else
EvalLoad(Dst, U, *I, state, location);
- }
+ }
return;
}
-
+
case UnaryOperator::Real: {
-
+
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
-
+
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
// Just report "Unknown."
Dst.Add(*I);
continue;
}
-
+
// For all other types, UnaryOperator::Real is an identity operation.
assert (U->getType() == Ex->getType());
const GRState* state = GetState(*I);
MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex)));
- }
-
+ }
+
return;
}
-
+
case UnaryOperator::Imag: {
-
+
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
// FIXME: We don't have complex SValues yet.
if (Ex->getType()->isAnyComplexType()) {
@@ -2389,25 +2388,25 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
Dst.Add(*I);
continue;
}
-
+
// For all other types, UnaryOperator::Float returns 0.
assert (Ex->getType()->isIntegerType());
const GRState* state = GetState(*I);
SVal X = ValMgr.makeZeroVal(Ex->getType());
MakeNode(Dst, U, *I, state->BindExpr(U, X));
}
-
+
return;
}
-
- // FIXME: Just report "Unknown" for OffsetOf.
+
+ // FIXME: Just report "Unknown" for OffsetOf.
case UnaryOperator::OffsetOf:
Dst.Add(Pred);
return;
-
+
case UnaryOperator::Plus: assert (!asLValue); // FALL-THROUGH.
case UnaryOperator::Extension: {
-
+
// Unary "+" is a no-op, similar to a parentheses. We still have places
// where it may be a block-level expression, so we need to
// generate an extra node that just propagates the value of the
@@ -2416,44 +2415,44 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
-
- for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex)));
}
-
+
return;
}
-
+
case UnaryOperator::AddrOf: {
-
+
assert(!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
VisitLValue(Ex, Pred, Tmp);
-
- for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
SVal V = state->getSVal(Ex);
state = state->BindExpr(U, V);
MakeNode(Dst, U, *I, state);
}
- return;
+ return;
}
-
+
case UnaryOperator::LNot:
case UnaryOperator::Minus:
case UnaryOperator::Not: {
-
+
assert (!asLValue);
Expr* Ex = U->getSubExpr()->IgnoreParens();
ExplodedNodeSet Tmp;
Visit(Ex, Pred, Tmp);
-
- for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+
+ for (ExplodedNodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
const GRState* state = GetState(*I);
-
+
// Get the value of the subexpression.
SVal V = state->getSVal(Ex);
@@ -2461,41 +2460,41 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
MakeNode(Dst, U, *I, state->BindExpr(U, V));
continue;
}
-
+
// QualType DstT = getContext().getCanonicalType(U->getType());
// QualType SrcT = getContext().getCanonicalType(Ex->getType());
-//
+//
// if (DstT != SrcT) // Perform promotions.
-// V = EvalCast(V, DstT);
-//
+// V = EvalCast(V, DstT);
+//
// if (V.isUnknownOrUndef()) {
// MakeNode(Dst, U, *I, BindExpr(St, U, V));
// continue;
// }
-
+
switch (U->getOpcode()) {
default:
assert(false && "Invalid Opcode.");
break;
-
+
case UnaryOperator::Not:
// FIXME: Do we need to handle promotions?
state = state->BindExpr(U, EvalComplement(cast<NonLoc>(V)));
- break;
-
+ break;
+
case UnaryOperator::Minus:
// FIXME: Do we need to handle promotions?
state = state->BindExpr(U, EvalMinus(cast<NonLoc>(V)));
- break;
-
- case UnaryOperator::LNot:
-
+ break;
+
+ case UnaryOperator::LNot:
+
// C99 6.5.3.3: "The expression !E is equivalent to (0==E)."
//
// Note: technically we do "E == 0", but this is the same in the
// transfer functions as "0 == E".
SVal Result;
-
+
if (isa<Loc>(V)) {
Loc X = ValMgr.makeNull();
Result = EvalBinOp(state, BinaryOperator::EQ, cast<Loc>(V), X,
@@ -2506,15 +2505,15 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
Result = EvalBinOp(BinaryOperator::EQ, cast<NonLoc>(V), X,
U->getType());
}
-
+
state = state->BindExpr(U, Result);
-
+
break;
}
-
+
MakeNode(Dst, U, *I, state);
}
-
+
return;
}
}
@@ -2525,28 +2524,28 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
ExplodedNodeSet Tmp;
Expr* Ex = U->getSubExpr()->IgnoreParens();
VisitLValue(Ex, Pred, Tmp);
-
+
for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I!=E; ++I) {
-
+
const GRState* state = GetState(*I);
SVal V1 = state->getSVal(Ex);
-
- // Perform a load.
+
+ // Perform a load.
ExplodedNodeSet Tmp2;
EvalLoad(Tmp2, Ex, *I, state, V1);
for (ExplodedNodeSet::iterator I2 = Tmp2.begin(), E2 = Tmp2.end(); I2!=E2; ++I2) {
-
+
state = GetState(*I2);
SVal V2 = state->getSVal(Ex);
-
- // Propagate unknown and undefined values.
+
+ // Propagate unknown and undefined values.
if (V2.isUnknownOrUndef()) {
MakeNode(Dst, U, *I2, state->BindExpr(U, V2));
continue;
}
-
- // Handle all other values.
+
+ // Handle all other values.
BinaryOperator::Opcode Op = U->isIncrementOp() ? BinaryOperator::Add
: BinaryOperator::Sub;
@@ -2560,37 +2559,37 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
else
RHS = ValMgr.makeIntVal(1, U->getType());
- SVal Result = EvalBinOp(state, Op, V2, RHS, U->getType());
-
+ SVal Result = EvalBinOp(state, Op, V2, RHS, U->getType());
+
// Conjure a new symbol if necessary to recover precision.
if (Result.isUnknown() || !getConstraintManager().canReasonAbout(Result)){
Result = ValMgr.getConjuredSymbolVal(Ex,
Builder->getCurrentBlockCount());
-
+
// If the value is a location, ++/-- should always preserve
// non-nullness. Check if the original value was non-null, and if so
- // propagate that constraint.
+ // propagate that constraint.
if (Loc::IsLocType(U->getType())) {
SVal Constraint = EvalBinOp(state, BinaryOperator::EQ, V2,
ValMgr.makeZeroVal(U->getType()),
- getContext().IntTy);
-
+ getContext().IntTy);
+
if (!state->assume(Constraint, true)) {
// It isn't feasible for the original value to be null.
// Propagate this constraint.
Constraint = EvalBinOp(state, BinaryOperator::EQ, Result,
ValMgr.makeZeroVal(U->getType()),
getContext().IntTy);
-
+
state = state->assume(Constraint, false);
assert(state);
- }
- }
+ }
+ }
}
-
+
state = state->BindExpr(U, U->isPostfix() ? V2 : Result);
- // Perform the store.
+ // Perform the store.
EvalStore(Dst, U, *I2, state, V1, Result);
}
}
@@ -2598,7 +2597,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
void GRExprEngine::VisitAsmStmt(AsmStmt* A, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
VisitAsmStmtHelperOutputs(A, A->begin_outputs(), A->end_outputs(), Pred, Dst);
-}
+}
void GRExprEngine::VisitAsmStmtHelperOutputs(AsmStmt* A,
AsmStmt::outputs_iterator I,
@@ -2608,12 +2607,12 @@ void GRExprEngine::VisitAsmStmtHelperOutputs(AsmStmt* A,
VisitAsmStmtHelperInputs(A, A->begin_inputs(), A->end_inputs(), Pred, Dst);
return;
}
-
+
ExplodedNodeSet Tmp;
VisitLValue(*I, Pred, Tmp);
-
+
++I;
-
+
for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI)
VisitAsmStmtHelperOutputs(A, I, E, *NI, Dst);
}
@@ -2623,35 +2622,35 @@ void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A,
AsmStmt::inputs_iterator E,
ExplodedNode* Pred, ExplodedNodeSet& Dst) {
if (I == E) {
-
+
// We have processed both the inputs and the outputs. All of the outputs
// should evaluate to Locs. Nuke all of their values.
-
+
// FIXME: Some day in the future it would be nice to allow a "plug-in"
// which interprets the inline asm and stores proper results in the
// outputs.
-
+
const GRState* state = GetState(Pred);
-
+
for (AsmStmt::outputs_iterator OI = A->begin_outputs(),
OE = A->end_outputs(); OI != OE; ++OI) {
-
- SVal X = state->getSVal(*OI);
+
+ SVal X = state->getSVal(*OI);
assert (!isa<NonLoc>(X)); // Should be an Lval, or unknown, undef.
-
+
if (isa<Loc>(X))
state = state->bindLoc(cast<Loc>(X), UnknownVal());
}
-
+
MakeNode(Dst, A, Pred, state);
return;
}
-
+
ExplodedNodeSet Tmp;
Visit(*I, Pred, Tmp);
-
+
++I;
-
+
for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI!=NE; ++NI)
VisitAsmStmtHelperInputs(A, I, E, *NI, Dst);
}
@@ -2659,16 +2658,16 @@ void GRExprEngine::VisitAsmStmtHelperInputs(AsmStmt* A,
void GRExprEngine::EvalReturn(ExplodedNodeSet& Dst, ReturnStmt* S,
ExplodedNode* Pred) {
assert (Builder && "GRStmtNodeBuilder must be defined.");
-
- unsigned size = Dst.size();
+
+ unsigned size = Dst.size();
SaveAndRestore<bool> OldSink(Builder->BuildSinks);
SaveOr OldHasGen(Builder->HasGeneratedNode);
getTF().EvalReturn(Dst, *this, *Builder, S, Pred);
-
+
// Handle the case where no nodes where generated.
-
+
if (!Builder->BuildSinks && Dst.size() == size && !Builder->HasGeneratedNode)
MakeNode(Dst, S, Pred, GetState(Pred));
}
@@ -2677,7 +2676,7 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, ExplodedNode* Pred,
ExplodedNodeSet& Dst) {
Expr* R = S->getRetValue();
-
+
if (!R) {
EvalReturn(Dst, S, Pred);
return;
@@ -2688,12 +2687,12 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, ExplodedNode* Pred,
for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) {
SVal X = (*I)->getState()->getSVal(R);
-
+
// Check if we return the address of a stack variable.
if (isa<loc::MemRegionVal>(X)) {
// Determine if the value is on the stack.
const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion();
-
+
if (R && R->hasStackStorage()) {
// Create a special node representing the error.
if (ExplodedNode* N = Builder->generateNode(S, GetState(*I), *I)) {
@@ -2711,7 +2710,7 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, ExplodedNode* Pred,
}
continue;
}
-
+
EvalReturn(Dst, S, *I);
}
}
@@ -2727,13 +2726,13 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
ExplodedNodeSet Tmp1;
Expr* LHS = B->getLHS()->IgnoreParens();
Expr* RHS = B->getRHS()->IgnoreParens();
-
+
// FIXME: Add proper support for ObjCImplicitSetterGetterRefExpr.
if (isa<ObjCImplicitSetterGetterRefExpr>(LHS)) {
- Visit(RHS, Pred, Dst);
+ Visit(RHS, Pred, Dst);
return;
}
-
+
if (B->isAssignmentOp())
VisitLValue(LHS, Pred, Tmp1);
else
@@ -2742,18 +2741,18 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
for (ExplodedNodeSet::iterator I1=Tmp1.begin(), E1=Tmp1.end(); I1!=E1; ++I1) {
SVal LeftV = (*I1)->getState()->getSVal(LHS);
-
+
// Process the RHS.
-
+
ExplodedNodeSet Tmp2;
Visit(RHS, *I1, Tmp2);
ExplodedNodeSet CheckedSet;
CheckerVisit(B, CheckedSet, Tmp2, true);
-
+
// With both the LHS and RHS evaluated, process the operation itself.
-
- for (ExplodedNodeSet::iterator I2=CheckedSet.begin(), E2=CheckedSet.end();
+
+ for (ExplodedNodeSet::iterator I2=CheckedSet.begin(), E2=CheckedSet.end();
I2 != E2; ++I2) {
const GRState* state = GetState(*I2);
@@ -2761,41 +2760,41 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
SVal RightV = state->getSVal(RHS);
BinaryOperator::Opcode Op = B->getOpcode();
-
+
switch (Op) {
-
+
case BinaryOperator::Assign: {
-
+
// EXPERIMENTAL: "Conjured" symbols.
// FIXME: Handle structs.
QualType T = RHS->getType();
-
- if ((RightV.isUnknown() ||
- !getConstraintManager().canReasonAbout(RightV))
- && (Loc::IsLocType(T) ||
+
+ if ((RightV.isUnknown() ||
+ !getConstraintManager().canReasonAbout(RightV))
+ && (Loc::IsLocType(T) ||
(T->isScalarType() && T->isIntegerType()))) {
- unsigned Count = Builder->getCurrentBlockCount();
+ unsigned Count = Builder->getCurrentBlockCount();
RightV = ValMgr.getConjuredSymbolVal(B->getRHS(), Count);
}
-
+
// Simulate the effects of a "store": bind the value of the RHS
- // to the L-Value represented by the LHS.
- EvalStore(Dst, B, LHS, *I2, state->BindExpr(B, RightV),
+ // to the L-Value represented by the LHS.
+ EvalStore(Dst, B, LHS, *I2, state->BindExpr(B, RightV),
LeftV, RightV);
continue;
}
-
+
// FALL-THROUGH.
default: {
-
+
if (B->isAssignmentOp())
break;
-
+
// Process non-assignments except commas or short-circuited
- // logical expressions (LAnd and LOr).
+ // logical expressions (LAnd and LOr).
SVal Result = EvalBinOp(state, Op, LeftV, RightV, B->getType());
-
+
if (Result.isUnknown()) {
if (OldSt != state) {
// Generate a new node if we have already created a new state.
@@ -2803,30 +2802,30 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
}
else
Dst.Add(*I2);
-
+
continue;
}
-
+
if (Result.isUndef() && !LeftV.isUndef() && !RightV.isUndef()) {
-
+
// The operands were *not* undefined, but the result is undefined.
// This is a special node that should be flagged as an error.
-
+
if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I2)){
- UndefNode->markAsSink();
+ UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
-
+
continue;
}
-
+
// Otherwise, create a new node.
-
+
MakeNode(Dst, B, *I2, state->BindExpr(B, Result));
continue;
}
}
-
+
assert (B->isCompoundAssignmentOp());
switch (Op) {
@@ -2843,26 +2842,26 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
case BinaryOperator::XorAssign: Op = BinaryOperator::Xor; break;
case BinaryOperator::OrAssign: Op = BinaryOperator::Or; break;
}
-
+
// Perform a load (the LHS). This performs the checks for
// null dereferences, and so on.
ExplodedNodeSet Tmp3;
SVal location = state->getSVal(LHS);
EvalLoad(Tmp3, LHS, *I2, state, location);
-
- for (ExplodedNodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3;
+
+ for (ExplodedNodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3;
++I3) {
-
+
state = GetState(*I3);
SVal V = state->getSVal(LHS);
- // Propagate undefined values (left-side).
+ // Propagate undefined values (left-side).
if (V.isUndef()) {
- EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, V),
+ EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, V),
location, V);
continue;
}
-
+
// Propagate unknown values (left and right-side).
if (RightV.isUnknown() || V.isUnknown()) {
EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, UnknownVal()),
@@ -2874,7 +2873,7 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
//
// The LHS is not Undef/Unknown.
// The RHS is not Unknown.
-
+
// Get the computation type.
QualType CTy =
cast<CompoundAssignOperator>(B)->getComputationResultType();
@@ -2890,24 +2889,24 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// Promote LHS.
llvm::tie(state, V) = SVator.EvalCast(V, state, CLHSTy, LTy);
- // Evaluate operands and promote to result type.
- if (RightV.isUndef()) {
- // Propagate undefined values (right-side).
+ // Evaluate operands and promote to result type.
+ if (RightV.isUndef()) {
+ // Propagate undefined values (right-side).
EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, RightV), location,
RightV);
continue;
}
-
- // Compute the result of the operation.
+
+ // Compute the result of the operation.
SVal Result;
llvm::tie(state, Result) = SVator.EvalCast(EvalBinOp(state, Op, V,
RightV, CTy),
state, B->getType(), CTy);
-
+
if (Result.isUndef()) {
// The operands were not undefined, but the result is undefined.
if (ExplodedNode* UndefNode = Builder->generateNode(B, state, *I3)) {
- UndefNode->markAsSink();
+ UndefNode->markAsSink();
UndefResults.insert(UndefNode);
}
continue;
@@ -2915,21 +2914,21 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// EXPERIMENTAL: "Conjured" symbols.
// FIXME: Handle structs.
-
+
SVal LHSVal;
-
- if ((Result.isUnknown() ||
+
+ if ((Result.isUnknown() ||
!getConstraintManager().canReasonAbout(Result))
- && (Loc::IsLocType(CTy)
+ && (Loc::IsLocType(CTy)
|| (CTy->isScalarType() && CTy->isIntegerType()))) {
-
+
unsigned Count = Builder->getCurrentBlockCount();
-
+
// The symbolic value is actually for the type of the left-hand side
// expression, not the computation type, as this is the value the
// LValue on the LHS will bind to.
LHSVal = ValMgr.getConjuredSymbolVal(B->getRHS(), LTy, Count);
-
+
// However, we need to convert the symbol to the computation type.
llvm::tie(state, Result) = SVator.EvalCast(LHSVal, state, CTy, LTy);
}
@@ -2938,8 +2937,8 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
// computation type.
llvm::tie(state, LHSVal) = SVator.EvalCast(Result, state, LTy, CTy);
}
-
- EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, Result),
+
+ EvalStore(Dst, B, LHS, *I3, state->BindExpr(B, Result),
location, LHSVal);
}
}
@@ -2958,9 +2957,9 @@ namespace llvm {
template<>
struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
public DefaultDOTGraphTraits {
-
+
static std::string getNodeAttributes(const ExplodedNode* N, void*) {
-
+
if (GraphPrintCheckerState->isImplicitNullDeref(N) ||
GraphPrintCheckerState->isExplicitNullDeref(N) ||
GraphPrintCheckerState->isUndefDeref(N) ||
@@ -2972,50 +2971,50 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
GraphPrintCheckerState->isBadCall(N) ||
GraphPrintCheckerState->isUndefArg(N))
return "color=\"red\",style=\"filled\"";
-
+
if (GraphPrintCheckerState->isNoReturnCall(N))
return "color=\"blue\",style=\"filled\"";
-
+
return "";
}
-
+
static std::string getNodeLabel(const ExplodedNode* N, void*,bool ShortNames){
-
+
std::string sbuf;
llvm::raw_string_ostream Out(sbuf);
// Program Location.
ProgramPoint Loc = N->getLocation();
-
+
switch (Loc.getKind()) {
case ProgramPoint::BlockEntranceKind:
- Out << "Block Entrance: B"
+ Out << "Block Entrance: B"
<< cast<BlockEntrance>(Loc).getBlock()->getBlockID();
break;
-
+
case ProgramPoint::BlockExitKind:
assert (false);
break;
-
+
default: {
if (StmtPoint *L = dyn_cast<StmtPoint>(&Loc)) {
const Stmt* S = L->getStmt();
SourceLocation SLoc = S->getLocStart();
- Out << S->getStmtClassName() << ' ' << (void*) S << ' ';
+ Out << S->getStmtClassName() << ' ' << (void*) S << ' ';
LangOptions LO; // FIXME.
S->printPretty(Out, 0, PrintingPolicy(LO));
-
- if (SLoc.isFileID()) {
+
+ if (SLoc.isFileID()) {
Out << "\\lline="
<< GraphPrintSourceManager->getInstantiationLineNumber(SLoc)
<< " col="
<< GraphPrintSourceManager->getInstantiationColumnNumber(SLoc)
<< "\\l";
}
-
+
if (isa<PreStmt>(Loc))
- Out << "\\lPreStmt\\l;";
+ Out << "\\lPreStmt\\l;";
else if (isa<PostLoad>(Loc))
Out << "\\lPostLoad\\l;";
else if (isa<PostStore>(Loc))
@@ -3026,7 +3025,7 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
Out << "\\lPostLocationChecksSucceed\\l";
else if (isa<PostNullCheckFailed>(Loc))
Out << "\\lPostNullCheckFailed\\l";
-
+
if (GraphPrintCheckerState->isImplicitNullDeref(N))
Out << "\\|Implicit-Null Dereference.\\l";
else if (GraphPrintCheckerState->isExplicitNullDeref(N))
@@ -3047,43 +3046,43 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
Out << "\\|Call to NULL/Undefined.";
else if (GraphPrintCheckerState->isUndefArg(N))
Out << "\\|Argument in call is undefined";
-
+
break;
}
const BlockEdge& E = cast<BlockEdge>(Loc);
Out << "Edge: (B" << E.getSrc()->getBlockID() << ", B"
<< E.getDst()->getBlockID() << ')';
-
+
if (Stmt* T = E.getSrc()->getTerminator()) {
-
+
SourceLocation SLoc = T->getLocStart();
-
+
Out << "\\|Terminator: ";
LangOptions LO; // FIXME.
E.getSrc()->printTerminator(Out, LO);
-
+
if (SLoc.isFileID()) {
Out << "\\lline="
<< GraphPrintSourceManager->getInstantiationLineNumber(SLoc)
<< " col="
<< GraphPrintSourceManager->getInstantiationColumnNumber(SLoc);
}
-
+
if (isa<SwitchStmt>(T)) {
Stmt* Label = E.getDst()->getLabel();
-
- if (Label) {
+
+ if (Label) {
if (CaseStmt* C = dyn_cast<CaseStmt>(Label)) {
Out << "\\lcase ";
LangOptions LO; // FIXME.
C->getLHS()->printPretty(Out, 0, PrintingPolicy(LO));
-
+
if (Stmt* RHS = C->getRHS()) {
Out << " .. ";
RHS->printPretty(Out, 0, PrintingPolicy(LO));
}
-
+
Out << ":";
}
else {
@@ -3091,7 +3090,7 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
Out << "\\ldefault:";
}
}
- else
+ else
Out << "\\l(implicit) default:";
}
else if (isa<IndirectGotoStmt>(T)) {
@@ -3102,28 +3101,28 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<ExplodedNode*> :
if (*E.getSrc()->succ_begin() == E.getDst())
Out << "true";
else
- Out << "false";
+ Out << "false";
}
-
+
Out << "\\l";
}
-
+
if (GraphPrintCheckerState->isUndefControlFlow(N)) {
Out << "\\|Control-flow based on\\lUndefined value.\\l";
}
}
}
-
+
Out << "\\|StateID: " << (void*) N->getState() << "\\|";
const GRState *state = N->getState();
state->printDOT(Out);
-
+
Out << "\\l";
return Out.str();
}
};
-} // end llvm namespace
+} // end llvm namespace
#endif
#ifndef NDEBUG
@@ -3138,7 +3137,7 @@ GetGraphNode<llvm::DenseMap<ExplodedNode*, Expr*>::iterator>
#endif
void GRExprEngine::ViewGraph(bool trim) {
-#ifndef NDEBUG
+#ifndef NDEBUG
if (trim) {
std::vector<ExplodedNode*> Src;
@@ -3150,14 +3149,14 @@ void GRExprEngine::ViewGraph(bool trim) {
// Iterate through the reports and get their nodes.
for (BugReporter::iterator I=BR.begin(), E=BR.end(); I!=E; ++I) {
for (BugType::const_iterator I2=(*I)->begin(), E2=(*I)->end();
- I2!=E2; ++I2) {
+ I2!=E2; ++I2) {
const BugReportEquivClass& EQ = *I2;
const BugReport &R = **EQ.begin();
ExplodedNode *N = const_cast<ExplodedNode*>(R.getEndNode());
if (N) Src.push_back(N);
}
}
-
+
ViewGraph(&Src[0], &Src[0]+Src.size());
}
else {
@@ -3165,7 +3164,7 @@ void GRExprEngine::ViewGraph(bool trim) {
GraphPrintSourceManager = &getContext().getSourceManager();
llvm::ViewGraph(*G.roots_begin(), "GRExprEngine");
-
+
GraphPrintCheckerState = NULL;
GraphPrintSourceManager = NULL;
}
@@ -3176,14 +3175,14 @@ void GRExprEngine::ViewGraph(ExplodedNode** Beg, ExplodedNode** End) {
#ifndef NDEBUG
GraphPrintCheckerState = this;
GraphPrintSourceManager = &getContext().getSourceManager();
-
+
std::auto_ptr<ExplodedGraph> TrimmedG(G.Trim(Beg, End).first);
if (!TrimmedG.get())
llvm::errs() << "warning: Trimmed ExplodedGraph is empty.\n";
else
- llvm::ViewGraph(*TrimmedG->roots_begin(), "TrimmedGRExprEngine");
-
+ llvm::ViewGraph(*TrimmedG->roots_begin(), "TrimmedGRExprEngine");
+
GraphPrintCheckerState = NULL;
GraphPrintSourceManager = NULL;
#endif
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp
index ab19a6a94a..ab6874ad60 100644
--- a/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -48,15 +48,15 @@ public:
BuiltinBugReport(BugType& bt, const char* desc,
ExplodedNode *n)
: RangedBugReport(bt, desc, n) {}
-
+
BuiltinBugReport(BugType& bt, const char *shortDesc, const char *desc,
ExplodedNode *n)
- : RangedBugReport(bt, shortDesc, desc, n) {}
-
+ : RangedBugReport(bt, shortDesc, desc, n) {}
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N);
-};
-
+};
+
class VISIBILITY_HIDDEN BuiltinBug : public BugType {
GRExprEngine &Eng;
protected:
@@ -69,30 +69,30 @@ public:
: BugType(n, "Logic errors"), Eng(*eng), desc(n) {}
const std::string &getDescription() const { return desc; }
-
+
virtual void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {}
void FlushReports(BugReporter& BR) { FlushReportsImpl(BR, Eng); }
-
+
virtual void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {}
-
+
template <typename ITER> void Emit(BugReporter& BR, ITER I, ITER E);
};
-
-
+
+
template <typename ITER>
void BuiltinBug::Emit(BugReporter& BR, ITER I, ITER E) {
for (; I != E; ++I) BR.EmitReport(new BuiltinBugReport(*this, desc.c_str(),
GetNode(I)));
-}
+}
void BuiltinBugReport::registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N) {
static_cast<BuiltinBug&>(getBugType()).registerInitialVisitors(BRC, N, this);
-}
-
+}
+
class VISIBILITY_HIDDEN NullDeref : public BuiltinBug {
public:
NullDeref(GRExprEngine* eng)
@@ -101,14 +101,14 @@ public:
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
Emit(BR, Eng.null_derefs_begin(), Eng.null_derefs_end());
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, GetDerefExpr(N), N);
}
};
-
+
class VISIBILITY_HIDDEN NilReceiverStructRet : public BuiltinBug {
public:
NilReceiverStructRet(GRExprEngine* eng) :
@@ -133,7 +133,7 @@ public:
BR.EmitReport(R);
}
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
@@ -146,12 +146,12 @@ public:
NilReceiverLargerThanVoidPtrRet(GRExprEngine* eng) :
BuiltinBug(eng,
"'nil' receiver with return type larger than sizeof(void *)") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::nil_receiver_larger_than_voidptr_ret_iterator
I=Eng.nil_receiver_larger_than_voidptr_ret_begin(),
E=Eng.nil_receiver_larger_than_voidptr_ret_end(); I!=E; ++I) {
-
+
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
PostStmt P = cast<PostStmt>((*I)->getLocation());
@@ -162,28 +162,28 @@ public:
<< "' and of size "
<< Eng.getContext().getTypeSize(ME->getType()) / 8
<< " bytes) to be garbage or otherwise undefined.";
-
+
BuiltinBugReport *R = new BuiltinBugReport(*this, os.str().c_str(), *I);
R->addRange(ME->getReceiver()->getSourceRange());
BR.EmitReport(R);
}
- }
+ }
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, GetReceiverExpr(N), N);
}
};
-
+
class VISIBILITY_HIDDEN UndefinedDeref : public BuiltinBug {
public:
UndefinedDeref(GRExprEngine* eng)
: BuiltinBug(eng,"Dereference of undefined pointer value") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
Emit(BR, Eng.undef_derefs_begin(), Eng.undef_derefs_end());
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
@@ -196,30 +196,30 @@ public:
DivZero(GRExprEngine* eng = 0)
: BuiltinBug(eng,"Division-by-zero",
"Division by zero or undefined value.") {}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, GetDenomExpr(N), N);
}
};
-
+
class VISIBILITY_HIDDEN UndefResult : public BuiltinBug {
public:
UndefResult(GRExprEngine* eng) : BuiltinBug(eng,"Undefined result",
"Result of operation is undefined.") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
Emit(BR, Eng.undef_results_begin(), Eng.undef_results_end());
}
};
-
+
class VISIBILITY_HIDDEN BadCall : public BuiltinBug {
public:
BadCall(GRExprEngine *eng = 0)
: BuiltinBug(eng, "Invalid function call",
"Called function pointer is a null or undefined pointer value") {}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
@@ -234,57 +234,57 @@ public:
ArgReport(BugType& bt, const char* desc, ExplodedNode *n,
const Stmt *arg)
: BuiltinBugReport(bt, desc, n), Arg(arg) {}
-
+
ArgReport(BugType& bt, const char *shortDesc, const char *desc,
ExplodedNode *n, const Stmt *arg)
- : BuiltinBugReport(bt, shortDesc, desc, n), Arg(arg) {}
-
- const Stmt *getArg() const { return Arg; }
+ : BuiltinBugReport(bt, shortDesc, desc, n), Arg(arg) {}
+
+ const Stmt *getArg() const { return Arg; }
};
class VISIBILITY_HIDDEN BadArg : public BuiltinBug {
-public:
- BadArg(GRExprEngine* eng=0) : BuiltinBug(eng,"Uninitialized argument",
+public:
+ BadArg(GRExprEngine* eng=0) : BuiltinBug(eng,"Uninitialized argument",
"Pass-by-value argument in function call is undefined.") {}
BadArg(GRExprEngine* eng, const char* d)
: BuiltinBug(eng,"Uninitialized argument", d) {}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, static_cast<ArgReport*>(R)->getArg(),
N);
- }
+ }
};
-
+
class VISIBILITY_HIDDEN BadMsgExprArg : public BadArg {
public:
- BadMsgExprArg(GRExprEngine* eng)
+ BadMsgExprArg(GRExprEngine* eng)
: BadArg(eng,"Pass-by-value argument in message expression is undefined"){}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::UndefArgsTy::iterator I=Eng.msg_expr_undef_arg_begin(),
- E = Eng.msg_expr_undef_arg_end(); I!=E; ++I) {
+ E = Eng.msg_expr_undef_arg_end(); I!=E; ++I) {
// Generate a report for this bug.
ArgReport *report = new ArgReport(*this, desc.c_str(), I->first,
I->second);
report->addRange(I->second->getSourceRange());
BR.EmitReport(report);
- }
- }
+ }
+ }
};
-
+
class VISIBILITY_HIDDEN BadReceiver : public BuiltinBug {
-public:
+public:
BadReceiver(GRExprEngine* eng)
: BuiltinBug(eng,"Uninitialized receiver",
"Receiver in message expression is an uninitialized value") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::ErrorNodes::iterator I=Eng.undef_receivers_begin(),
End = Eng.undef_receivers_end(); I!=End; ++I) {
-
+
// Generate a report for this bug.
BuiltinBugReport *report = new BuiltinBugReport(*this, desc.c_str(), *I);
ExplodedNode* N = *I;
@@ -300,14 +300,14 @@ public:
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, GetReceiverExpr(N), N);
- }
+ }
};
class VISIBILITY_HIDDEN RetStack : public BuiltinBug {
public:
RetStack(GRExprEngine* eng)
: BuiltinBug(eng, "Return of address to stack-allocated memory") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::ret_stackaddr_iterator I=Eng.ret_stackaddr_begin(),
End = Eng.ret_stackaddr_end(); I!=End; ++I) {
@@ -316,42 +316,42 @@ public:
const Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
const Expr* E = cast<ReturnStmt>(S)->getRetValue();
assert(E && "Return expression cannot be NULL");
-
+
// Get the value associated with E.
loc::MemRegionVal V = cast<loc::MemRegionVal>(N->getState()->getSVal(E));
-
+
// Generate a report for this bug.
std::string buf;
llvm::raw_string_ostream os(buf);
SourceRange R;
-
+
// Check if the region is a compound literal.
- if (const CompoundLiteralRegion* CR =
+ if (const CompoundLiteralRegion* CR =
dyn_cast<CompoundLiteralRegion>(V.getRegion())) {
-
+
const CompoundLiteralExpr* CL = CR->getLiteralExpr();
os << "Address of stack memory associated with a compound literal "
"declared on line "
<< BR.getSourceManager()
.getInstantiationLineNumber(CL->getLocStart())
<< " returned.";
-
+
R = CL->getSourceRange();
}
else if (const AllocaRegion* AR = dyn_cast<AllocaRegion>(V.getRegion())) {
const Expr* ARE = AR->getExpr();
SourceLocation L = ARE->getLocStart();
R = ARE->getSourceRange();
-
+
os << "Address of stack memory allocated by call to alloca() on line "
<< BR.getSourceManager().getInstantiationLineNumber(L)
<< " returned.";
- }
- else {
+ }
+ else {
os << "Address of stack memory associated with local variable '"
<< V.getRegion()->getString() << "' returned.";
}
-
+
RangedBugReport *report = new RangedBugReport(*this, os.str().c_str(), N);
report->addRange(E->getSourceRange());
if (R.isValid()) report->addRange(R);
@@ -359,51 +359,51 @@ public:
}
}
};
-
+
class VISIBILITY_HIDDEN RetUndef : public BuiltinBug {
public:
RetUndef(GRExprEngine* eng) : BuiltinBug(eng, "Uninitialized return value",
"Uninitialized or undefined value returned to caller.") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
Emit(BR, Eng.ret_undef_begin(), Eng.ret_undef_end());
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
registerTrackNullOrUndefValue(BRC, GetRetValExpr(N), N);
- }
+ }
};
class VISIBILITY_HIDDEN UndefBranch : public BuiltinBug {
struct VISIBILITY_HIDDEN FindUndefExpr {
GRStateManager& VM;
const GRState* St;
-
+
FindUndefExpr(GRStateManager& V, const GRState* S) : VM(V), St(S) {}
-
- Expr* FindExpr(Expr* Ex) {
+
+ Expr* FindExpr(Expr* Ex) {
if (!MatchesCriteria(Ex))
return 0;
-
+
for (Stmt::child_iterator I=Ex->child_begin(), E=Ex->child_end();I!=E;++I)
if (Expr* ExI = dyn_cast_or_null<Expr>(*I)) {
Expr* E2 = FindExpr(ExI);
if (E2) return E2;
}
-
+
return Ex;
}
-
+
bool MatchesCriteria(Expr* Ex) { return St->getSVal(Ex).isUndef(); }
};
-
+
public:
UndefBranch(GRExprEngine *eng)
: BuiltinBug(eng,"Use of uninitialized value",
"Branch condition evaluates to an uninitialized value.") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::undef_branch_iterator I=Eng.undef_branches_begin(),
E=Eng.undef_branches_end(); I!=E; ++I) {
@@ -442,7 +442,7 @@ public:
BR.EmitReport(R);
}
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
@@ -461,12 +461,12 @@ public:
Emit(BR, Eng.explicit_oob_memacc_begin(), Eng.explicit_oob_memacc_end());
}
};
-
+
class VISIBILITY_HIDDEN BadSizeVLA : public BuiltinBug {
public:
BadSizeVLA(GRExprEngine* eng) :
BuiltinBug(eng, "Bad variable-length array (VLA) size") {}
-
+
void FlushReportsImpl(BugReporter& BR, GRExprEngine& Eng) {
for (GRExprEngine::ErrorNodes::iterator
I = Eng.ExplicitBadSizedVLA.begin(),
@@ -475,26 +475,26 @@ public:
// Determine whether this was a 'zero-sized' VLA or a VLA with an
// undefined size.
ExplodedNode* N = *I;
- PostStmt PS = cast<PostStmt>(N->getLocation());
+ PostStmt PS = cast<PostStmt>(N->getLocation());
const DeclStmt *DS = cast<DeclStmt>(PS.getStmt());
VarDecl* VD = cast<VarDecl>(*DS->decl_begin());
QualType T = Eng.getContext().getCanonicalType(VD->getType());
VariableArrayType* VT = cast<VariableArrayType>(T);
Expr* SizeExpr = VT->getSizeExpr();
-
+
std::string buf;
llvm::raw_string_ostream os(buf);
os << "The expression used to specify the number of elements in the "
"variable-length array (VLA) '"
<< VD->getNameAsString() << "' evaluates to ";
-
+
bool isUndefined = N->getState()->getSVal(SizeExpr).isUndef();
-
+
if (isUndefined)
os << "an undefined or garbage value.";
else
os << "0. VLAs with no elements have undefined behavior.";
-
+
std::string shortBuf;
llvm::raw_string_ostream os_short(shortBuf);
os_short << "Variable-length array '" << VD->getNameAsString() << "' "
@@ -508,7 +508,7 @@ public:
BR.EmitReport(report);
}
}
-
+
void registerInitialVisitors(BugReporterContext& BRC,
const ExplodedNode* N,
BuiltinBugReport *R) {
@@ -524,7 +524,7 @@ class VISIBILITY_HIDDEN CheckAttrNonNull :
public CheckerVisitor<CheckAttrNonNull> {
BugType *BT;
-
+
public:
CheckAttrNonNull() : BT(0) {}
~CheckAttrNonNull() {}
@@ -537,73 +537,73 @@ public:
void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE) {
const GRState *state = C.getState();
const GRState *originalState = state;
-
+
// Check if the callee has a 'nonnull' attribute.
SVal X = state->getSVal(CE->getCallee());
-
+
const FunctionDecl* FD = X.getAsFunctionDecl();
if (!FD)
return;
- const NonNullAttr* Att = FD->getAttr<NonNullAttr>();
+ const NonNullAttr* Att = FD->getAttr<NonNullAttr>();
if (!Att)
return;
-
+
// Iterate through the arguments of CE and check them for null.
unsigned idx = 0;
-
+
for (CallExpr::const_arg_iterator I=CE->arg_begin(), E=CE->arg_end(); I!=E;
++I, ++idx) {
-
+
if (!Att->isNonNull(idx))
continue;
-
+
const SVal &V = state->getSVal(*I);
const DefinedSVal *DV = dyn_cast<DefinedSVal>(&V);
-
+
if (!DV)
continue;
-
+
ConstraintManager &CM = C.getConstraintManager();
const GRState *stateNotNull, *stateNull;
llvm::tie(stateNotNull, stateNull) = CM.AssumeDual(state, *DV);
-
+
if (stateNull && !stateNotNull) {
// Generate an error node. Check for a null node in case
// we cache out.
if (ExplodedNode *errorNode = C.GenerateNode(CE, stateNull, true)) {
-
+
// Lazily allocate the BugType object if it hasn't already been
// created. Ownership is transferred to the BugReporter object once
// the BugReport is passed to 'EmitWarning'.
if (!BT)
BT = new BugType("Argument with 'nonnull' attribute passed null",
"API");
-
+
EnhancedBugReport *R =
new EnhancedBugReport(*BT,
"Null pointer passed as an argument to a "
"'nonnull' parameter", errorNode);
-
+
// Highlight the range of the argument that was null.
const Expr *arg = *I;
R->addRange(arg->getSourceRange());
R->addVisitorCreator(registerTrackNullOrUndefValue, arg);
-
+
// Emit the bug report.
C.EmitReport(R);
}
-
+
// Always return. Either we cached out or we just emitted an error.
return;
}
-
+
// If a pointer value passed the check we should assume that it is
// indeed not null from this point forward.
assert(stateNotNull);
state = stateNotNull;
}
-
+
// If we reach here all of the arguments passed the nonnull check.
// If 'state' has been updated generated a new node.
if (state != originalState)
@@ -614,7 +614,7 @@ public:
// Undefined arguments checking.
namespace {
-class VISIBILITY_HIDDEN CheckUndefinedArg
+class VISIBILITY_HIDDEN CheckUndefinedArg
: public CheckerVisitor<CheckUndefinedArg> {
BadArg *BT;
@@ -690,7 +690,7 @@ public:
void PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
};
-void CheckBadDiv::PreVisitBinaryOperator(CheckerContext &C,
+void CheckBadDiv::PreVisitBinaryOperator(CheckerContext &C,
const BinaryOperator *B) {
BinaryOperator::Opcode Op = B->getOpcode();
if (Op != BinaryOperator::Div &&
@@ -719,19 +719,19 @@ void CheckBadDiv::PreVisitBinaryOperator(CheckerContext &C,
// Handle the case where 'Denom' is UnknownVal.
const DefinedSVal *DV = dyn_cast<DefinedSVal>(&Denom);
- if (!DV)
+ if (!DV)
return;
// Check for divide by zero.
ConstraintManager &CM = C.getConstraintManager();
const GRState *stateNotZero, *stateZero;
llvm::tie(stateNotZero, stateZero) = CM.AssumeDual(C.getState(), *DV);
-
+
if (stateZero && !stateNotZero) {
if (ExplodedNode *N = C.GenerateNode(B, stateZero, true)) {
if (!BT)
BT = new DivZero();
-
+
C.EmitReport(new BuiltinBugReport(*BT, BT->getDescription().c_str(), N));
}
return;
@@ -764,7 +764,7 @@ void GRExprEngine::RegisterInternalChecks() {
BR.Register(new BadSizeVLA(this));
BR.Register(new NilReceiverStructRet(this));
BR.Register(new NilReceiverLargerThanVoidPtrRet(this));
-
+
// The following checks do not need to have their associated BugTypes
// explicitly registered with the BugReporter. If they issue any BugReports,
// their associated BugType will get registered with the BugReporter
diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp
index 74b493dc55..f269824d54 100644
--- a/lib/Analysis/GRState.cpp
+++ b/lib/Analysis/GRState.cpp
@@ -27,7 +27,7 @@ GRStateManager::~GRStateManager() {
for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
E=Printers.end(); I!=E; ++I)
delete *I;
-
+
for (GDMContextsTy::iterator I=GDMContexts.begin(), E=GDMContexts.end();
I!=E; ++I)
I->second.second(I->second.first);
@@ -59,13 +59,13 @@ GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
const GRState *GRState::unbindLoc(Loc LV) const {
Store OldStore = getStore();
Store NewStore = getStateManager().StoreMgr->Remove(OldStore, LV);
-
+
if (NewStore == OldStore)
return this;
-
+
GRState NewSt = *this;
NewSt.St = NewStore;
- return getStateManager().getPersistentState(NewSt);
+ return getStateManager().getPersistentState(NewSt);
}
SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const {
@@ -87,7 +87,7 @@ SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const {
const GRState *GRState::BindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{
Environment NewEnv = getStateManager().EnvMgr.BindExpr(Env, Ex, V,
- Invalidate);
+ Invalidate);
if (NewEnv == Env)
return this;
@@ -98,7 +98,7 @@ const GRState *GRState::BindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{
const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
GRState State(this,
- EnvMgr.getInitialEnvironment(InitLoc->getAnalysisContext()),
+ EnvMgr.getInitialEnvironment(InitLoc->getAnalysisContext()),
StoreMgr->getInitialStore(InitLoc),
GDMFactory.GetEmptyMap());
@@ -106,16 +106,16 @@ const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
}
const GRState* GRStateManager::getPersistentState(GRState& State) {
-
+
llvm::FoldingSetNodeID ID;
- State.Profile(ID);
+ State.Profile(ID);
void* InsertPos;
-
+
if (GRState* I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
return I;
-
+
GRState* I = (GRState*) Alloc.Allocate<GRState>();
- new (I) GRState(State);
+ new (I) GRState(State);
StateSet.InsertNode(I, InsertPos);
return I;
}
@@ -131,32 +131,32 @@ const GRState* GRState::makeWithStore(Store store) const {
//===----------------------------------------------------------------------===//
void GRState::print(llvm::raw_ostream& Out, const char* nl,
- const char* sep) const {
+ const char* sep) const {
// Print the store.
GRStateManager &Mgr = getStateManager();
Mgr.getStoreManager().print(getStore(), Out, nl, sep);
-
+
CFG &C = *getAnalysisContext().getCFG();
-
+
// Print Subexpression bindings.
bool isFirst = true;
-
- for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
+
+ for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
if (C.isBlkExpr(I.getKey()))
continue;
-
+
if (isFirst) {
Out << nl << nl << "Sub-Expressions:" << nl;
isFirst = false;
}
else { Out << nl; }
-
+
Out << " (" << (void*) I.getKey() << ") ";
LangOptions LO; // FIXME.
I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
Out << " : " << I.getData();
}
-
+
// Print block-expression bindings.
isFirst = true;
@@ -169,15 +169,15 @@ void GRState::print(llvm::raw_ostream& Out, const char* nl,
isFirst = false;
}
else { Out << nl; }
-
+
Out << " (" << (void*) I.getKey() << ") ";
LangOptions LO; // FIXME.
I.getKey()->printPretty(Out, 0, PrintingPolicy(LO));
Out << " : " << I.getData();
}
-
+
Mgr.getConstraintManager().print(this, Out, nl, sep);
-
+
// Print checker-specific data.
for (std::vector<Printer*>::iterator I = Mgr.Printers.begin(),
E = Mgr.Printers.end(); I != E; ++I) {
@@ -205,23 +205,23 @@ void*
GRStateManager::FindGDMContext(void* K,
void* (*CreateContext)(llvm::BumpPtrAllocator&),
void (*DeleteContext)(void*)) {
-
+
std::pair<void*, void (*)(void*)>& p = GDMContexts[K];
if (!p.first) {
p.first = CreateContext(Alloc);
p.second = DeleteContext;
}
-
+
return p.first;
}
const GRState* GRStateManager::addGDM(const GRState* St, void* Key, void* Data){
GRState::GenericDataMap M1 = St->getGDM();
GRState::GenericDataMap M2 = GDMFactory.Add(M1, Key, Data);
-
+
if (M1 == M2)
return St;
-
+
GRState NewSt = *St;
NewSt.GDM = M2;
return getPersistentState(NewSt);
@@ -240,14 +240,14 @@ class VISIBILITY_HIDDEN ScanReachableSymbols : public SubRegionMap::Visitor {
SymbolVisitor &visitor;
llvm::OwningPtr<SubRegionMap> SRM;
public:
-
+
ScanReachableSymbols(const GRState *st, SymbolVisitor& v)
: state(st), visitor(v) {}
-
+
bool scan(nonloc::CompoundVal val);
bool scan(SVal val);
bool scan(const MemRegion *R);
-
+
// From SubRegionMap::Visitor.
bool Visit(const MemRegion* Parent, const MemRegion* SubRegion) {
return scan(SubRegion);
@@ -262,44 +262,44 @@ bool ScanReachableSymbols::scan(nonloc::CompoundVal val) {
return true;
}
-
+
bool ScanReachableSymbols::scan(SVal val) {
if (loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(&val))
return scan(X->getRegion());
if (SymbolRef Sym = val.getAsSymbol())
return visitor.VisitSymbol(Sym);
-
+
if (nonloc::CompoundVal *X = dyn_cast<nonloc::CompoundVal>(&val))
return scan(*X);
-
+
return true;
}
-
+
bool ScanReachableSymbols::scan(const MemRegion *R) {
if (isa<MemSpaceRegion>(R) || visited.count(R))
return true;
-
+
visited.insert(R);
// If this is a symbolic region, visit the symbol for the region.
if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R))
if (!visitor.VisitSymbol(SR->getSymbol()))
return false;
-
+
// If this is a subregion, also visit the parent regions.
if (const SubRegion *SR = dyn_cast<SubRegion>(R))
if (!scan(SR->getSuperRegion()))
return false;
-
+
// Now look at the binding to this region (if any).
if (!scan(state->getSValAsScalarOrLoc(R)))
return false;
-
+
// Now look at the subregions.
if (!SRM.get())
SRM.reset(state->getStateManager().getStoreManager().getSubRegionMap(state));
-
+
return SRM->iterSubRegions(R, *this);
}
@@ -314,21 +314,21 @@ bool GRState::scanReachableSymbols(SVal val, SymbolVisitor& visitor) const {
bool GRStateManager::isEqual(const GRState* state, const Expr* Ex,
const llvm::APSInt& Y) {
-
+
SVal V = state->getSVal(Ex);
-
+
if (loc::ConcreteInt* X = dyn_cast<loc::ConcreteInt>(&V))
return X->getValue() == Y;
if (nonloc::ConcreteInt* X = dyn_cast<nonloc::ConcreteInt>(&V))
return X->getValue() == Y;
-
+
if (SymbolRef Sym = V.getAsSymbol())
return ConstraintMgr->isEqual(state, Sym, Y);
return false;
}
-
+
bool GRStateManager::isEqual(const GRState* state, const Expr* Ex, uint64_t x) {
return isEqual(state, Ex, getBasicVals().getValue(x, Ex->getType()));
}
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp
index c9828ce551..4d96c8f8f4 100644
--- a/lib/Analysis/LiveVariables.cpp
+++ b/lib/Analysis/LiveVariables.cpp
@@ -29,35 +29,35 @@ using namespace clang;
//===----------------------------------------------------------------------===//
// Useful constants.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
static const bool Alive = true;
-static const bool Dead = false;
+static const bool Dead = false;
//===----------------------------------------------------------------------===//
// Dataflow initialization logic.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
-class VISIBILITY_HIDDEN RegisterDecls
+class VISIBILITY_HIDDEN RegisterDecls
: public CFGRecStmtDeclVisitor<RegisterDecls> {
-
+
LiveVariables::AnalysisDataTy& AD;
-
+
typedef llvm::SmallVector<VarDecl*, 20> AlwaysLiveTy;
AlwaysLiveTy AlwaysLive;
-
+
public:
RegisterDecls(LiveVariables::AnalysisDataTy& ad) : AD(ad) {}
~RegisterDecls() {
AD.AlwaysLive.resetValues(AD);
-
+
for (AlwaysLiveTy::iterator I = AlwaysLive.begin(), E = AlwaysLive.end();
- I != E; ++ I)
- AD.AlwaysLive(*I, AD) = Alive;
+ I != E; ++ I)
+ AD.AlwaysLive(*I, AD) = Alive;
}
void VisitImplicitParamDecl(ImplicitParamDecl* IPD) {
@@ -68,12 +68,12 @@ public:
void VisitVarDecl(VarDecl* VD) {
// Register the VarDecl for tracking.
AD.Register(VD);
-
+
// Does the variable have global storage? If so, it is always live.
if (VD->hasGlobalStorage())
- AlwaysLive.push_back(VD);
+ AlwaysLive.push_back(VD);
}
-
+
CFG& getCFG() { return AD.getCFG(); }
};
} // end anonymous namespace
@@ -82,14 +82,14 @@ LiveVariables::LiveVariables(ASTContext& Ctx, CFG& cfg) {
// Register all referenced VarDecls.
getAnalysisData().setCFG(cfg);
getAnalysisData().setContext(Ctx);
-
+
RegisterDecls R(getAnalysisData());
cfg.VisitBlockStmts(R);
}
//===----------------------------------------------------------------------===//
// Transfer functions.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
@@ -101,85 +101,85 @@ public:
LiveVariables::ValTy& getVal() { return LiveState; }
CFG& getCFG() { return AD.getCFG(); }
-
+
void VisitDeclRefExpr(DeclRefExpr* DR);
void VisitBinaryOperator(BinaryOperator* B);
void VisitAssign(BinaryOperator* B);
void VisitDeclStmt(DeclStmt* DS);
void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S);
void VisitUnaryOperator(UnaryOperator* U);
- void Visit(Stmt *S);
- void VisitTerminator(CFGBlock* B);
-
+ void Visit(Stmt *S);
+ void VisitTerminator(CFGBlock* B);
+
void SetTopValue(LiveVariables::ValTy& V) {
V = AD.AlwaysLive;
}
-
+
};
-
+
void TransferFuncs::Visit(Stmt *S) {
-
+
if (S == getCurrentBlkStmt()) {
-
+
if (AD.Observer)
AD.Observer->ObserveStmt(S,AD,LiveState);
-
+
if (getCFG().isBlkExpr(S)) LiveState(S,AD) = Dead;
StmtVisitor<TransferFuncs,void>::Visit(S);
}
else if (!getCFG().isBlkExpr(S)) {
-
+
if (AD.Observer)
AD.Observer->ObserveStmt(S,AD,LiveState);
-
+
StmtVisitor<TransferFuncs,void>::Visit(S);
-
+
}
else {
// For block-level expressions, mark that they are live.
LiveState(S,AD) = Alive;
}
}
-
+
void TransferFuncs::VisitTerminator(CFGBlock* B) {
-
+
const Stmt* E = B->getTerminatorCondition();
if (!E)
return;
-
+
assert (getCFG().isBlkExpr(E));
LiveState(E, AD) = Alive;
}
void TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
- if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
+ if (VarDecl* V = dyn_cast<VarDecl>(DR->getDecl()))
LiveState(V,AD) = Alive;
}
-
-void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
+
+void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
if (B->isAssignmentOp()) VisitAssign(B);
else VisitStmt(B);
}
void
TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
-
+
// This is a block-level expression. Its value is 'dead' before this point.
LiveState(S, AD) = Dead;
// This represents a 'use' of the collection.
Visit(S->getCollection());
-
+
// This represents a 'kill' for the variable.
Stmt* Element = S->getElement();
DeclRefExpr* DR = 0;
VarDecl* VD = 0;
-
+
if (DeclStmt* DS = dyn_cast<DeclStmt>(Element))
VD = cast<VarDecl>(DS->getSingleDecl());
else {
- Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();
+ Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();
if ((DR = dyn_cast<DeclRefExpr>(ElemExpr)))
VD = cast<VarDecl>(DR->getDecl());
else {
@@ -194,10 +194,10 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
}
}
-
+
void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
Expr *E = U->getSubExpr();
-
+
switch (U->getOpcode()) {
case UnaryOperator::PostInc:
case UnaryOperator::PostDec:
@@ -206,7 +206,7 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
// Walk through the subexpressions, blasting through ParenExprs
// until we either find a DeclRefExpr or some non-DeclRefExpr
// expression.
- if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
+ if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParens()))
if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl())) {
// Treat the --/++ operator as a kill.
if (AD.Observer) { AD.Observer->ObserverKill(DR); }
@@ -215,24 +215,24 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
}
// Fall-through.
-
+
default:
return Visit(E);
}
}
-
-void TransferFuncs::VisitAssign(BinaryOperator* B) {
+
+void TransferFuncs::VisitAssign(BinaryOperator* B) {
Expr* LHS = B->getLHS();
// Assigning to a variable?
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) {
-
+
// Update liveness inforamtion.
unsigned bit = AD.getIdx(DR->getDecl());
LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
-
+
if (AD.Observer) { AD.Observer->ObserverKill(DR); }
-
+
// Handle things like +=, etc., which also generate "uses"
// of a variable. Do this just by visiting the subexpression.
if (B->getOpcode() != BinaryOperator::Assign)
@@ -240,7 +240,7 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) {
}
else // Not assigning to a variable. Process LHS as usual.
Visit(LHS);
-
+
Visit(B->getRHS());
}
@@ -255,44 +255,44 @@ void TransferFuncs::VisitDeclStmt(DeclStmt* DS) {
// transfer function for this expression first.
if (Expr* Init = VD->getInit())
Visit(Init);
-
+
if (const VariableArrayType* VT =
AD.getContext().getAsVariableArrayType(VD->getType())) {
StmtIterator I(const_cast<VariableArrayType*>(VT));
- StmtIterator E;
+ StmtIterator E;
for (; I != E; ++I) Visit(*I);
}
-
+
// Update liveness information by killing the VarDecl.
unsigned bit = AD.getIdx(VD);
LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit);
}
}
-
+
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// Merge operator: if something is live on any successor block, it is live
// in the current block (a set union).
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
struct Merge {
- typedef StmtDeclBitVector_Types::ValTy ValTy;
-
+ typedef StmtDeclBitVector_Types::ValTy ValTy;
+
void operator()(ValTy& Dst, const ValTy& Src) {
Dst.OrDeclBits(Src);
Dst.OrBlkExprBits(Src);
}
};
-
+
typedef DataflowSolver<LiveVariables, TransferFuncs, Merge> Solver;
} // end anonymous namespace
//===----------------------------------------------------------------------===//
// External interface to run Liveness analysis.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
void LiveVariables::runOnCFG(CFG& cfg) {
Solver S(*this);
@@ -337,22 +337,22 @@ bool LiveVariables::isLive(const Stmt* Loc, const VarDecl* D) const {
void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const {
const AnalysisDataTy& AD = getAnalysisData();
-
+
for (AnalysisDataTy::decl_iterator I = AD.begin_decl(),
E = AD.end_decl(); I!=E; ++I)
- if (V.getDeclBit(I->second)) {
+ if (V.getDeclBit(I->second)) {
fprintf(stderr, " %s <", I->first->getIdentifier()->getName());
I->first->getLocation().dump(SM);
fprintf(stderr, ">\n");
}
-}
+}
void LiveVariables::dumpBlockLiveness(SourceManager& M) const {
for (BlockDataMapTy::iterator I = getBlockDataMap().begin(),
E = getBlockDataMap().end(); I!=E; ++I) {
fprintf(stderr, "\n[ B%d (live variables at block exit) ]\n",
I->first->getBlockID());
-
+
dumpLiveness(I->second,M);
}
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index bc51f50abc..353e632402 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -55,8 +55,8 @@ void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const {
ID.AddInteger((unsigned)getKind());
}
-void StringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
- const StringLiteral* Str,
+void StringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
+ const StringLiteral* Str,
const MemRegion* superRegion) {
ID.AddInteger((unsigned) StringRegionKind);
ID.AddPointer(Str);
@@ -114,7 +114,7 @@ void SymbolicRegion::Profile(llvm::FoldingSetNodeID& ID) const {
}
void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
- QualType ElementType, SVal Idx,
+ QualType ElementType, SVal Idx,
const MemRegion* superRegion) {
ID.AddInteger(MemRegion::ElementRegionKind);
ID.Add(ElementType);
@@ -182,7 +182,7 @@ void ObjCIvarRegion::dumpToStream(llvm::raw_ostream& os) const {
os << "ivar{" << superRegion << ',' << getDecl()->getNameAsString() << '}';
}
-void StringRegion::dumpToStream(llvm::raw_ostream& os) const {
+void StringRegion::dumpToStream(llvm::raw_ostream& os) const {
Str->printPretty(os, 0, PrintingPolicy(getContext().getLangOptions()));
}
@@ -206,8 +206,8 @@ void RegionRawOffset::dumpToStream(llvm::raw_ostream& os) const {
// MemRegionManager methods.
//===----------------------------------------------------------------------===//
-MemSpaceRegion* MemRegionManager::LazyAllocate(MemSpaceRegion*& region) {
- if (!region) {
+MemSpaceRegion* MemRegionManager::LazyAllocate(MemSpaceRegion*& region) {
+ if (!region) {
region = (MemSpaceRegion*) A.Allocate<MemSpaceRegion>();
new (region) MemSpaceRegion(this);
}
@@ -249,13 +249,13 @@ StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str) {
VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
const LocationContext *LC) {
-
+
// FIXME: Once we implement scope handling, we will need to properly lookup
// 'D' to the proper LocationContext. For now, just strip down to the
// StackFrame.
while (!isa<StackFrameContext>(LC))
LC = LC->getParent();
-
+
return getRegion<VarRegion>(D, LC);
}
@@ -320,12 +320,12 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
const MemSpaceRegion *MemRegion::getMemorySpace() const {
const MemRegion *R = this;
const SubRegion* SR = dyn_cast<SubRegion>(this);
-
+
while (SR) {
R = SR->getSuperRegion();
SR = dyn_cast<SubRegion>(R);
}
-
+
return dyn_cast<MemSpaceRegion>(R);
}
@@ -365,7 +365,7 @@ bool MemRegion::hasGlobalsStorage() const {
bool MemRegion::hasParametersStorage() const {
if (const MemSpaceRegion *MS = getMemorySpace())
return MS == getMemRegionManager()->getStackArgumentsRegion();
-
+
return false;
}
@@ -385,7 +385,7 @@ bool MemRegion::hasGlobalsOrParametersStorage() const {
const MemRegion *MemRegion::getBaseRegion() const {
const MemRegion *R = this;
while (true) {
- if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
+ if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
// FIXME: generalize. Essentially we want to strip away ElementRegions
// that were layered on a symbolic region because of casts. We only
// want to strip away ElementRegions, however, where the index is 0.
@@ -418,27 +418,27 @@ RegionRawOffset ElementRegion::getAsRawOffset() const {
const ElementRegion *ER = this;
const MemRegion *superR = NULL;
ASTContext &C = getContext();
-
+
// FIXME: Handle multi-dimensional arrays.
while (ER) {
superR = ER->getSuperRegion();
-
+
// FIXME: generalize to symbolic offsets.
SVal index = ER->getIndex();
if (nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&index)) {
// Update the offset.
int64_t i = CI->getValue().getSExtValue();
-
+
if (i != 0) {
QualType elemType = ER->getElementType();
-
+
// If we are pointing to an incomplete type, go no further.
if (!IsCompleteType(C, elemType)) {
superR = ER;
break;
}
-
+
int64_t size = (int64_t) (C.getTypeSize(elemType) / 8);
offset += (i * size);
}
@@ -447,10 +447,10 @@ RegionRawOffset ElementRegion::getAsRawOffset() const {
ER = dyn_cast<ElementRegion>(superR);
continue;
}
-
+
return NULL;
}
-
+
assert(superR && "super region cannot be NULL");
return RegionRawOffset(superR, offset);
}
diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp
index a608ce0d58..1c2f6bfca0 100644
--- a/lib/Analysis/PathDiagnostic.cpp
+++ b/lib/Analysis/PathDiagnostic.cpp
@@ -27,7 +27,7 @@ bool PathDiagnosticMacroPiece::containsEvent() const {
for (const_iterator I = begin(), E = end(); I!=E; ++I) {
if (isa<PathDiagnosticEventPiece>(*I))
return true;
-
+
if (PathDiagnosticMacroPiece *MP = dyn_cast<PathDiagnosticMacroPiece>(*I))
if (MP->containsEvent())
return true;
@@ -38,14 +38,14 @@ bool PathDiagnosticMacroPiece::containsEvent() const {
static size_t GetNumCharsToLastNonPeriod(const char *s) {
const char *start = s;
- const char *lastNonPeriod = 0;
+ const char *lastNonPeriod = 0;
for ( ; *s != '\0' ; ++s)
if (*s != '.') lastNonPeriod = s;
-
+
if (!lastNonPeriod)
return 0;
-
+
return (lastNonPeriod - start) + 1;
}
@@ -84,7 +84,7 @@ void PathDiagnostic::resetPath(bool deletePieces) {
if (deletePieces)
for (iterator I=begin(), E=end(); I!=E; ++I)
delete &*I;
-
+
path.clear();
}
@@ -97,7 +97,7 @@ PathDiagnostic::PathDiagnostic(const char* bugtype, const char* desc,
Category(category, GetNumCharsToLastNonPeriod(category)) {}
PathDiagnostic::PathDiagnostic(const std::string& bugtype,
- const std::string& desc,
+ const std::string& desc,
const std::string& category)
: Size(0),
BugType(bugtype, 0, GetNumCharsToLastNonPeriod(bugtype)),
@@ -106,11 +106,11 @@ PathDiagnostic::PathDiagnostic(const std::string& bugtype,
void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel,
const DiagnosticInfo &Info) {
-
+
// Create a PathDiagnostic with a single piece.
-
+
PathDiagnostic* D = new PathDiagnostic();
-
+
const char *LevelStr;
switch (DiagLevel) {
default:
@@ -124,18 +124,18 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel,
llvm::SmallString<100> StrC;
StrC += LevelStr;
Info.FormatDiagnostic(StrC);
-
+
PathDiagnosticPiece *P =
new PathDiagnosticEventPiece(Info.getLocation(),
std::string(StrC.begin(), StrC.end()));
-
+
for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
P->addRange(Info.getRange(i));
for (unsigned i = 0, e = Info.getNumCodeModificationHints(); i != e; ++i)
P->addCodeModificationHint(Info.getCodeModificationHint(i));
D->push_front(P);
- HandlePathDiagnostic(D);
+ HandlePathDiagnostic(D);
}
//===----------------------------------------------------------------------===//
@@ -155,7 +155,7 @@ FullSourceLoc PathDiagnosticLocation::asLocation() const {
case DeclK:
return FullSourceLoc(D->getLocation(), const_cast<SourceManager&>(*SM));
}
-
+
return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(*SM));
}
@@ -178,7 +178,7 @@ PathDiagnosticRange PathDiagnosticLocation::asRange() const {
if (DS->isSingleDecl()) {
// Should always be the case, but we'll be defensive.
return SourceRange(DS->getLocStart(),
- DS->getSingleDecl()->getLocation());
+ DS->getSingleDecl()->getLocation());
}
break;
}
@@ -197,7 +197,7 @@ PathDiagnosticRange PathDiagnosticLocation::asRange() const {
return SourceRange(L, L);
}
}
-
+
return S->getSourceRange();
}
case DeclK:
@@ -219,7 +219,7 @@ PathDiagnosticRange PathDiagnosticLocation::asRange() const {
return PathDiagnosticRange(SourceRange(L, L), true);
}
}
-
+
return R;
}
diff --git a/lib/Analysis/RangeConstraintManager.cpp b/lib/Analysis/RangeConstraintManager.cpp
index 079462e8d1..73b445e6ab 100644
--- a/lib/Analysis/RangeConstraintManager.cpp
+++ b/lib/Analysis/RangeConstraintManager.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines RangeConstraintManager, a class that tracks simple
+// This file defines RangeConstraintManager, a class that tracks simple
// equality and inequality constraints on symbolic values of GRState.
//
//===----------------------------------------------------------------------===//
@@ -66,7 +66,7 @@ public:
// consistent (instead of comparing by pointer values) and can potentially
// be used to speed up some of the operations in RangeSet.
static inline bool isLess(key_type_ref lhs, key_type_ref rhs) {
- return *lhs.first < *rhs.first || (!(*rhs.first < *lhs.first) &&
+ return *lhs.first < *rhs.first || (!(*rhs.first < *lhs.first) &&
*lhs.second < *rhs.second);
}
};
@@ -78,7 +78,7 @@ class VISIBILITY_HIDDEN RangeSet {
typedef llvm::ImmutableSet<Range, RangeTrait> PrimRangeSet;
PrimRangeSet ranges; // no need to make const, since it is an
// ImmutableSet - this allows default operator=
- // to work.
+ // to work.
public:
typedef PrimRangeSet::Factory Factory;
typedef PrimRangeSet::iterator iterator;
@@ -88,13 +88,13 @@ public:
iterator begin() const { return ranges.begin(); }
iterator end() const { return ranges.end(); }
-
+
bool isEmpty() const { return ranges.isEmpty(); }
-
+
/// Construct a new RangeSet representing '{ [from, to] }'.
RangeSet(Factory &F, const llvm::APSInt &from, const llvm::APSInt &to)
: ranges(F.Add(F.GetEmptySet(), Range(from, to))) {}
-
+
/// Profile - Generates a hash profile of this RangeSet for use
/// by FoldingSet.
void Profile(llvm::FoldingSetNodeID &ID) const { ranges.Profile(ID); }
@@ -122,7 +122,7 @@ public:
/// value be not be equal to V.
RangeSet AddNE(BasicValueFactory &BV, Factory &F, const llvm::APSInt &V) {
PrimRangeSet newRanges = ranges;
-
+
// FIXME: We can perhaps enhance ImmutableSet to do this search for us
// in log(N) time using the sorted property of the internal AVL tree.
for (iterator i = begin(), e = end(); i != e; ++i) {
@@ -134,11 +134,11 @@ public:
newRanges = F.Add(newRanges, Range(i->From(), BV.Sub1(V)));
if (V != i->To())
newRanges = F.Add(newRanges, Range(BV.Add1(V), i->To()));
- // All of the ranges are non-overlapping, so we can stop.
+ // All of the ranges are non-overlapping, so we can stop.
break;
}
}
-
+
return newRanges;
}
@@ -153,7 +153,7 @@ public:
else if (i->To() < V)
newRanges = F.Add(newRanges, *i);
}
-
+
return newRanges;
}
@@ -168,7 +168,7 @@ public:
else if (i->To() <= V)
newRanges = F.Add(newRanges, *i);
}
-
+
return newRanges;
}
@@ -181,7 +181,7 @@ public:
else if (i->From() > V)
newRanges = F.Add(newRanges, *i);
}
-
+
return newRanges;
}
@@ -208,13 +208,13 @@ public:
isFirst = false;
else
os << ", ";
-
+
os << '[' << i->From().toString(10) << ", " << i->To().toString(10)
<< ']';
}
- os << " }";
+ os << " }";
}
-
+
bool operator==(const RangeSet &other) const {
return ranges == other.ranges;
}
@@ -227,13 +227,13 @@ namespace clang {
template<>
struct GRStateTrait<ConstraintRange>
: public GRStatePartialTrait<ConstraintRangeTy> {
- static inline void* GDMIndex() { return &ConstraintRangeIndex; }
+ static inline void* GDMIndex() { return &ConstraintRangeIndex; }
};
-}
-
+}
+
namespace {
class VISIBILITY_HIDDEN RangeConstraintManager : public SimpleConstraintManager{
- RangeSet GetRange(const GRState *state, SymbolRef sym);
+ RangeSet GetRange(const GRState *state, SymbolRef sym);
public:
RangeConstraintManager() {}
@@ -256,7 +256,7 @@ public:
const llvm::APSInt& V);
const llvm::APSInt* getSymVal(const GRState* St, SymbolRef sym) const;
-
+
// FIXME: Refactor into SimpleConstraintManager?
bool isEqual(const GRState* St, SymbolRef sym, const llvm::APSInt& V) const {
const llvm::APSInt *i = getSymVal(St, sym);
@@ -265,7 +265,7 @@ public:
const GRState* RemoveDeadBindings(const GRState* St, SymbolReaper& SymReaper);
- void print(const GRState* St, llvm::raw_ostream& Out,
+ void print(const GRState* St, llvm::raw_ostream& Out,
const char* nl, const char *sep);
private:
@@ -294,11 +294,11 @@ RangeConstraintManager::RemoveDeadBindings(const GRState* state,
ConstraintRangeTy::Factory& CRFactory = state->get_context<ConstraintRange>();
for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
- SymbolRef sym = I.getKey();
+ SymbolRef sym = I.getKey();
if (SymReaper.maybeDead(sym))
CR = CRFactory.Remove(CR, sym);
}
-
+
return state->set<ConstraintRange>(CR);
}
@@ -310,11 +310,11 @@ RangeSet
RangeConstraintManager::GetRange(const GRState *state, SymbolRef sym) {
if (ConstraintRangeTy::data_type* V = state->get<ConstraintRange>(sym))
return *V;
-
+
// Lazily generate a new RangeSet representing all possible values for the
// given symbol type.
QualType T = state->getSymbolManager().getType(sym);
- BasicValueFactory& BV = state->getBasicVals();
+ BasicValueFactory& BV = state->getBasicVals();
return RangeSet(F, BV.getMinValue(T), BV.getMaxValue(T));
}
@@ -341,16 +341,16 @@ AssumeX(GE)
// Pretty-printing.
//===------------------------------------------------------------------------===/
-void RangeConstraintManager::print(const GRState* St, llvm::raw_ostream& Out,
+void RangeConstraintManager::print(const GRState* St, llvm::raw_ostream& Out,
const char* nl, const char *sep) {
-
+
ConstraintRangeTy Ranges = St->get<ConstraintRange>();
-
+
if (Ranges.isEmpty())
return;
-
+
Out << nl << sep << "ranges of symbol values:";
-
+
for (ConstraintRangeTy::iterator I=Ranges.begin(), E=Ranges.end(); I!=E; ++I){
Out << nl << ' ' << I.getKey() << " : ";
I.getData().print(Out);
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 5114035d5f..4186690939 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -41,21 +41,21 @@ typedef llvm::ImmutableMap<const MemRegion*, SVal> RegionBindings;
namespace {
struct VISIBILITY_HIDDEN minimal_features_tag {};
-struct VISIBILITY_HIDDEN maximal_features_tag {};
-
+struct VISIBILITY_HIDDEN maximal_features_tag {};
+
class VISIBILITY_HIDDEN RegionStoreFeatures {
bool SupportsFields;
bool SupportsRemaining;
-
+
public:
RegionStoreFeatures(minimal_features_tag) :
SupportsFields(false), SupportsRemaining(false) {}
-
+
RegionStoreFeatures(maximal_features_tag) :
SupportsFields(true), SupportsRemaining(false) {}
-
+
void enableFields(bool t) { SupportsFields = t; }
-
+
bool supportsFields() const { return SupportsFields; }
bool supportsRemaining() const { return SupportsRemaining; }
};
@@ -107,7 +107,7 @@ typedef RegionDefaultValue::MapTy RegionDefaultBindings;
static bool IsAnyPointerOrIntptr(QualType ty, ASTContext &Ctx) {
if (ty->isAnyPointerType())
return true;
-
+
return ty->isIntegerType() && ty->isScalarType() &&
Ctx.getTypeSize(ty) == Ctx.getTypeSize(Ctx.VoidPtrTy);
}
@@ -117,10 +117,10 @@ static bool IsAnyPointerOrIntptr(QualType ty, ASTContext &Ctx) {
//===----------------------------------------------------------------------===//
namespace {
-
+
class VISIBILITY_HIDDEN RegionStoreSubRegionMap : public SubRegionMap {
typedef llvm::ImmutableSet<const MemRegion*> SetTy;
- typedef llvm::DenseMap<const MemRegion*, SetTy> Map;
+ typedef llvm::DenseMap<const MemRegion*, SetTy> Map;
SetTy::Factory F;
Map M;
public:
@@ -135,27 +135,27 @@ public:
I->second = F.Add(I->second, SubRegion);
return false;
}
-
+
void process(llvm::SmallVectorImpl<const SubRegion*> &WL, const SubRegion *R);
-
+
~RegionStoreSubRegionMap() {}
-
+
bool iterSubRegions(const MemRegion* Parent, Visitor& V) const {
Map::iterator I = M.find(Parent);
if (I == M.end())
return true;
-
+
llvm::ImmutableSet<const MemRegion*> S = I->second;
for (llvm::ImmutableSet<const MemRegion*>::iterator SI=S.begin(),SE=S.end();
SI != SE; ++SI) {
if (!V.Visit(Parent, *SI))
return false;
}
-
+
return true;
}
-
+
typedef SetTy::iterator iterator;
std::pair<iterator, iterator> begin_end(const MemRegion *R) {
@@ -163,13 +163,13 @@ public:
SetTy S = I == M.end() ? F.GetEmptySet() : I->second;
return std::make_pair(S.begin(), S.end());
}
-};
+};
class VISIBILITY_HIDDEN RegionStoreManager : public StoreManager {
const RegionStoreFeatures Features;
RegionBindings::Factory RBFactory;
public:
- RegionStoreManager(GRStateManager& mgr, const RegionStoreFeatures &f)
+ RegionStoreManager(GRStateManager& mgr, const RegionStoreFeatures &f)
: StoreManager(mgr),
Features(f),
RBFactory(mgr.getAllocator()) {}
@@ -177,14 +177,14 @@ public:
virtual ~RegionStoreManager() {}
SubRegionMap *getSubRegionMap(const GRState *state);
-
+
RegionStoreSubRegionMap *getRegionStoreSubRegionMap(const GRState *state);
-
-
+
+
/// getDefaultBinding - Returns an SVal* representing an optional default
/// binding associated with a region and its subregions.
Optional<SVal> getDefaultBinding(const GRState *state, const MemRegion *R);
-
+
/// getLValueString - Returns an SVal representing the lvalue of a
/// StringLiteral. Within RegionStore a StringLiteral has an
/// associated StringRegion, and the lvalue of a StringLiteral is
@@ -202,11 +202,11 @@ public:
/// VarRegion, and the lvalue of the variable is the lvalue of that region.
SVal getLValueVar(const GRState *ST, const VarDecl *VD,
const LocationContext *LC);
-
+
SVal getLValueIvar(const GRState *state, const ObjCIvarDecl* D, SVal Base);
SVal getLValueField(const GRState *state, SVal Base, const FieldDecl* D);
-
+
SVal getLValueFieldOrIvar(const GRState *state, SVal Base, const Decl* D);
SVal getLValueElement(const GRState *state, QualType elementType,
@@ -224,7 +224,7 @@ public:
SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,
NonLoc R, QualType resultTy);
- Store getInitialStore(const LocationContext *InitLoc) {
+ Store getInitialStore(const LocationContext *InitLoc) {
return RBFactory.GetEmptyMap().getRoot();
}
@@ -234,20 +234,20 @@ public:
const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
const Expr *E, unsigned Count);
-
+
private:
void RemoveSubRegionBindings(RegionBindings &B,
RegionDefaultBindings &DVM,
RegionDefaultBindings::Factory &DVMFactory,
const MemRegion *R,
RegionStoreSubRegionMap &M);
-
-public:
+
+public:
const GRState *Bind(const GRState *state, Loc LV, SVal V);
const GRState *BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* CL, SVal V);
-
+
const GRState *BindDecl(const GRState *ST, const VarDecl *VD,
const LocationContext *LC, SVal InitVal);
@@ -258,10 +258,10 @@ public:
/// BindStruct - Bind a compound value to a structure.
const GRState *BindStruct(const GRState *, const TypedRegion* R, SVal V);
-
+
const GRState *BindArray(const GRState *state, const TypedRegion* R, SVal V);
-
- /// KillStruct - Set the entire struct to unknown.
+
+ /// KillStruct - Set the entire struct to unknown.
const GRState *KillStruct(const GRState *state, const TypedRegion* R);
const GRState *setDefaultValue(const GRState *state, const MemRegion* R, SVal V);
@@ -271,7 +271,7 @@ public:
//===------------------------------------------------------------------===//
// Loading values from regions.
//===------------------------------------------------------------------===//
-
+
/// The high level logic for this method is this:
/// Retrieve (L)
/// if L has binding
@@ -289,28 +289,28 @@ public:
SVal RetrieveElement(const GRState *state, const ElementRegion *R);
SVal RetrieveField(const GRState *state, const FieldRegion *R);
-
+
SVal RetrieveObjCIvar(const GRState *state, const ObjCIvarRegion *R);
-
+
SVal RetrieveVar(const GRState *state, const VarRegion *R);
-
+
SVal RetrieveLazySymbol(const GRState *state, const TypedRegion *R);
-
+
SVal RetrieveFieldOrElementCommon(const GRState *state, const TypedRegion *R,
QualType Ty, const MemRegion *superR);
-
+
/// Retrieve the values in a struct and return a CompoundVal, used when doing
- /// struct copy:
- /// struct s x, y;
+ /// struct copy:
+ /// struct s x, y;
/// x = y;
/// y's value is retrieved by this method.
SVal RetrieveStruct(const GRState *St, const TypedRegion* R);
-
+
SVal RetrieveArray(const GRState *St, const TypedRegion* R);
-
+
std::pair<const GRState*, const MemRegion*>
GetLazyBinding(RegionBindings B, const MemRegion *R);
-
+
const GRState* CopyLazyBindings(nonloc::LazyCompoundVal V,
const GRState *state,
const TypedRegion *R);
@@ -318,7 +318,7 @@ public:
//===------------------------------------------------------------------===//
// State pruning.
//===------------------------------------------------------------------===//
-
+
/// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
/// It returns a new Store with these values removed.
void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper,
@@ -327,14 +327,14 @@ public:
//===------------------------------------------------------------------===//
// Region "extents".
//===------------------------------------------------------------------===//
-
+
const GRState *setExtent(const GRState *state, const MemRegion* R, SVal Extent);
SVal getSizeInElements(const GRState *state, const MemRegion* R);
//===------------------------------------------------------------------===//
// Utility methods.
//===------------------------------------------------------------------===//
-
+
static inline RegionBindings GetRegionBindings(Store store) {
return RegionBindings(static_cast<const RegionBindings::TreeTy*>(store));
}
@@ -350,7 +350,7 @@ public:
BasicValueFactory& getBasicVals() {
return StateMgr.getBasicVals();
}
-
+
// FIXME: Remove.
ASTContext& getContext() { return StateMgr.getContext(); }
};
@@ -374,31 +374,31 @@ StoreManager *clang::CreateFieldsOnlyRegionStoreManager(GRStateManager &StMgr) {
void
RegionStoreSubRegionMap::process(llvm::SmallVectorImpl<const SubRegion*> &WL,
- const SubRegion *R) {
+ const SubRegion *R) {
const MemRegion *superR = R->getSuperRegion();
if (add(superR, R))
if (const SubRegion *sr = dyn_cast<SubRegion>(superR))
- WL.push_back(sr);
+ WL.push_back(sr);
}
RegionStoreSubRegionMap*
RegionStoreManager::getRegionStoreSubRegionMap(const GRState *state) {
RegionBindings B = GetRegionBindings(state->getStore());
RegionStoreSubRegionMap *M = new RegionStoreSubRegionMap();
-
+
llvm::SmallVector<const SubRegion*, 10> WL;
for (RegionBindings::iterator I=B.begin(), E=B.end(); I!=E; ++I)
if (const SubRegion *R = dyn_cast<SubRegion>(I.getKey()))
M->process(WL, R);
-
+
RegionDefaultBindings DVM = state->get<RegionDefaultValue>();
for (RegionDefaultBindings::iterator I = DVM.begin(), E = DVM.end();
- I != E; ++I)
+ I != E; ++I)
if (const SubRegion *R = dyn_cast<SubRegion>(I.getKey()))
M->process(WL, R);
- // We also need to record in the subregion map "intermediate" regions that
+ // We also need to record in the subregion map "intermediate" regions that
// don't have direct bindings but are super regions of those that do.
while (!WL.empty()) {
const SubRegion *R = WL.back();
@@ -423,12 +423,12 @@ RegionStoreManager::RemoveSubRegionBindings(RegionBindings &B,
RegionDefaultBindings::Factory &DVMFactory,
const MemRegion *R,
RegionStoreSubRegionMap &M) {
-
+
RegionStoreSubRegionMap::iterator I, E;
for (llvm::tie(I, E) = M.begin_end(R); I != E; ++I)
RemoveSubRegionBindings(B, DVM, DVMFactory, *I, M);
-
+
B = RBFactory.Remove(B, R);
DVM = DVMFactory.Remove(DVM, R);
}
@@ -439,48 +439,48 @@ const GRState *RegionStoreManager::InvalidateRegion(const GRState *state,
const Expr *E,
unsigned Count) {
ASTContext& Ctx = StateMgr.getContext();
-
+
// Strip away casts.
R = R->getBaseRegion();
// Remove the bindings to subregions.
- {
+ {
// Get the mapping of regions -> subregions.
llvm::OwningPtr<RegionStoreSubRegionMap>
SubRegions(getRegionStoreSubRegionMap(state));
-
+
RegionBindings B = GetRegionBindings(state->getStore());
- RegionDefaultBindings DVM = state->get<RegionDefaultValue>();
+ RegionDefaultBindings DVM = state->get<RegionDefaultValue>();
RegionDefaultBindings::Factory &DVMFactory =
state->get_context<RegionDefaultValue>();
-
- RemoveSubRegionBindings(B, DVM, DVMFactory, R, *SubRegions.get());
+
+ RemoveSubRegionBindings(B, DVM, DVMFactory, R, *SubRegions.get());
state = state->makeWithStore(B.getRoot())->set<RegionDefaultValue>(DVM);
}
if (!R->isBoundable())
return state;
-
+
if (isa<AllocaRegion>(R) || isa<SymbolicRegion>(R) ||
isa<ObjCObjectRegion>(R)) {
- // Invalidate the region by setting its default value to
+ // Invalidate the region by setting its default value to
// conjured symbol. The type of the symbol is irrelavant.
SVal V = ValMgr.getConjuredSymbolVal(E, Ctx.IntTy, Count);
return setDefaultValue(state, R, V);
}
-
+
const TypedRegion *TR = cast<TypedRegion>(R);
QualType T = TR->getValueType(Ctx);
-
+
if (const RecordType *RT = T->getAsStructureType()) {
// FIXME: handle structs with default region value.
const RecordDecl *RD = RT->getDecl()->getDefinition(Ctx);
-
+
// No record definition. There is nothing we can do.
if (!RD)
return state;
-
- // Invalidate the region by setting its default value to
+
+ // Invalidate the region by setting its default value to
// conjured symbol. The type of the symbol is irrelavant.
SVal V = ValMgr.getConjuredSymbolVal(E, Ctx.IntTy, Count);
return setDefaultValue(state, R, V);
@@ -492,7 +492,7 @@ const GRState *RegionStoreManager::InvalidateRegion(const GRState *state,
Count);
return setDefaultValue(state, TR, V);
}
-
+
SVal V = ValMgr.getConjuredSymbolVal(E, T, Count);
assert(SymbolManager::canSymbolicate(T) || V.isUnknown());
return Bind(state, ValMgr.makeLoc(TR), V);
@@ -506,7 +506,7 @@ const GRState *RegionStoreManager::InvalidateRegion(const GRState *state,
/// StringLiteral. Within RegionStore a StringLiteral has an
/// associated StringRegion, and the lvalue of a StringLiteral is the
/// lvalue of that region.
-SVal RegionStoreManager::getLValueString(const GRState *St,
+SVal RegionStoreManager::getLValueString(const GRState *St,
const StringLiteral* S) {
return loc::MemRegionVal(MRMgr.getStringRegion(S));
}
@@ -525,7 +525,7 @@ SVal RegionStoreManager::getLValueVar(const GRState *ST, const VarDecl *VD,
/// is the lvalue of that region.
SVal
RegionStoreManager::getLValueCompoundLiteral(const GRState *St,
- const CompoundLiteralExpr* CL) {
+ const CompoundLiteralExpr* CL) {
return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL));
}
@@ -567,7 +567,7 @@ SVal RegionStoreManager::getLValueFieldOrIvar(const GRState *St, SVal Base,
assert(0 && "Unhandled Base.");
return Base;
}
-
+
// NOTE: We must have this check first because ObjCIvarDecl is a subclass
// of FieldDecl.
if (const ObjCIvarDecl *ID = dyn_cast<ObjCIvarDecl>(D))
@@ -595,10 +595,10 @@ SVal RegionStoreManager::getLValueElement(const GRState *St,
// Pointer of any type can be cast and used as array base.
const ElementRegion *ElemR = dyn_cast<ElementRegion>(BaseRegion);
-
+
// Convert the offset to the appropriate size and signedness.
Offset = ValMgr.convertToArrayIndex(Offset);
-
+
if (!ElemR) {
//
// If the base region is not an ElementRegion, create one.
@@ -612,23 +612,23 @@ SVal RegionStoreManager::getLValueElement(const GRState *St,
return loc::MemRegionVal(MRMgr.getElementRegion(elementType, Offset,
BaseRegion, getContext()));
}
-
+
SVal BaseIdx = ElemR->getIndex();
-
+
if (!isa<nonloc::ConcreteInt>(BaseIdx))
return UnknownVal();
-
+
const llvm::APSInt& BaseIdxI = cast<nonloc::ConcreteInt>(BaseIdx).getValue();
const llvm::APSInt& OffI = cast<nonloc::ConcreteInt>(Offset).getValue();
assert(BaseIdxI.isSigned());
-
+
// Compute the new index.
SVal NewIdx = nonloc::ConcreteInt(getBasicVals().getValue(BaseIdxI + OffI));
-
+
// Construct the new ElementRegion.
const MemRegion *ArrayR = ElemR->getSuperRegion();
return loc::MemRegionVal(MRMgr.getElementRegion(elementType, NewIdx, ArrayR,
- getContext()));
+ getContext()));
}
//===----------------------------------------------------------------------===//
@@ -637,12 +637,12 @@ SVal RegionStoreManager::getLValueElement(const GRState *St,
SVal RegionStoreManager::getSizeInElements(const GRState *state,
const MemRegion *R) {
-
+
switch (R->getKind()) {
case MemRegion::MemSpaceRegionKind:
assert(0 && "Cannot index into a MemSpace");
- return UnknownVal();
-
+ return UnknownVal();
+
case MemRegion::CodeTextRegionKind:
// Technically this can happen if people do funny things with casts.
return UnknownVal();
@@ -656,23 +656,23 @@ SVal RegionStoreManager::getSizeInElements(const GRState *state,
case MemRegion::ObjCObjectRegionKind:
case MemRegion::SymbolicRegionKind:
return UnknownVal();
-
+
case MemRegion::StringRegionKind: {
const StringLiteral* Str = cast<StringRegion>(R)->getStringLiteral();
- // We intentionally made the size value signed because it participates in
+ // We intentionally made the size value signed because it participates in
// operations with signed indices.
return ValMgr.makeIntVal(Str->getByteLength()+1, false);
}
-
+
case MemRegion::VarRegionKind: {
const VarRegion* VR = cast<VarRegion>(R);
// Get the type of the variable.
QualType T = VR->getDesugaredValueType(getContext());
-
+
// FIXME: Handle variable-length arrays.
if (isa<VariableArrayType>(T))
return UnknownVal();
-
+
if (const ConstantArrayType* CAT = dyn_cast<ConstantArrayType>(T)) {
// return the size as signed integer.
return ValMgr.makeIntVal(CAT->getSize(), false);
@@ -682,7 +682,7 @@ SVal RegionStoreManager::getSizeInElements(const GRState *state,
// essentially are arrays of size 1.
return ValMgr.makeIntVal(1, false);
}
-
+
case MemRegion::BEG_DECL_REGIONS:
case MemRegion::END_DECL_REGIONS:
case MemRegion::BEG_TYPED_REGIONS:
@@ -690,7 +690,7 @@ SVal RegionStoreManager::getSizeInElements(const GRState *state,
assert(0 && "Infeasible region");
return UnknownVal();
}
-
+
assert(0 && "Unreachable");
return UnknownVal();
}
@@ -714,29 +714,29 @@ const GRState *RegionStoreManager::setExtent(const GRState *state,
SVal RegionStoreManager::ArrayToPointer(Loc Array) {
if (!isa<loc::MemRegionVal>(Array))
return UnknownVal();
-
+
const MemRegion* R = cast<loc::MemRegionVal>(&Array)->getRegion();
const TypedRegion* ArrayR = dyn_cast<TypedRegion>(R);
-
+
if (!ArrayR)
return UnknownVal();
-
+
// Strip off typedefs from the ArrayRegion's ValueType.
QualType T = ArrayR->getValueType(getContext())->getDesugaredType();
ArrayType *AT = cast<ArrayType>(T);
T = AT->getElementType();
-
+
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ElementRegion* ER = MRMgr.getElementRegion(T, ZeroIdx, ArrayR, getContext());
-
- return loc::MemRegionVal(ER);
+
+ return loc::MemRegionVal(ER);
}
//===----------------------------------------------------------------------===//
// Pointer arithmetic.
//===----------------------------------------------------------------------===//
-SVal RegionStoreManager::EvalBinOp(const GRState *state,
+SVal RegionStoreManager::EvalBinOp(const GRState *state,
BinaryOperator::Opcode Op, Loc L, NonLoc R,
QualType resultTy) {
// Assume the base location is MemRegionVal.
@@ -752,15 +752,15 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
SymbolRef Sym = SR->getSymbol();
QualType T = Sym->getType(getContext());
QualType EleTy;
-
+
if (const PointerType *PT = T->getAs<PointerType>())
EleTy = PT->getPointeeType();
else
EleTy = T->getAsObjCObjectPointerType()->getPointeeType();
-
+
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, getContext());
- break;
+ break;
}
case MemRegion::AllocaRegionKind: {
const AllocaRegion *AR = cast<AllocaRegion>(MR);
@@ -768,14 +768,14 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
QualType EleTy = T->getAs<PointerType>()->getPointeeType();
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, getContext());
- break;
+ break;
}
case MemRegion::ElementRegionKind: {
ER = cast<ElementRegion>(MR);
break;
}
-
+
// Not yet handled.
case MemRegion::VarRegionKind:
case MemRegion::StringRegionKind:
@@ -784,15 +784,15 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
case MemRegion::ObjCObjectRegionKind:
case MemRegion::ObjCIvarRegionKind:
return UnknownVal();
-
+
case MemRegion::CodeTextRegionKind:
// Technically this can happen if people do funny things with casts.
return UnknownVal();
-
+
case MemRegion::MemSpaceRegionKind:
assert(0 && "Cannot perform pointer arithmetic on a MemSpace");
return UnknownVal();
-
+
case MemRegion::BEG_DECL_REGIONS:
case MemRegion::END_DECL_REGIONS:
case MemRegion::BEG_TYPED_REGIONS:
@@ -815,7 +815,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
getContext());
return ValMgr.makeLoc(NewER);
}
-
+
return UnknownVal();
}
@@ -825,7 +825,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
Optional<SVal> RegionStoreManager::getDefaultBinding(const GRState *state,
const MemRegion *R) {
-
+
if (R->isBoundable())
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R))
if (TR->getValueType(getContext())->isUnionType())
@@ -837,21 +837,21 @@ Optional<SVal> RegionStoreManager::getDefaultBinding(const GRState *state,
static bool IsReinterpreted(QualType RTy, QualType UsedTy, ASTContext &Ctx) {
RTy = Ctx.getCanonicalType(RTy);
UsedTy = Ctx.getCanonicalType(UsedTy);
-
+
if (RTy == UsedTy)
return false;
-
-
+
+
// Recursively check the types. We basically want to see if a pointer value
- // is ever reinterpreted as a non-pointer, e.g. void** and intptr_t*
+ // is ever reinterpreted as a non-pointer, e.g. void** and intptr_t*
// represents a reinterpretation.
if (Loc::IsLocType(RTy) && Loc::IsLocType(UsedTy)) {
- const PointerType *PRTy = RTy->getAs<PointerType>();
+ const PointerType *PRTy = RTy->getAs<PointerType>();
const PointerType *PUsedTy = UsedTy->getAs<PointerType>();
return PUsedTy && PRTy &&
IsReinterpreted(PRTy->getPointeeType(),
- PUsedTy->getPointeeType(), Ctx);
+ PUsedTy->getPointeeType(), Ctx);
}
return true;
@@ -878,17 +878,17 @@ RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
// c = *p;
if (isa<AllocaRegion>(MR))
return SValuator::CastResult(state, UnknownVal());
-
+
if (isa<SymbolicRegion>(MR)) {
ASTContext &Ctx = getContext();
SVal idx = ValMgr.makeZeroArrayIndex();
assert(!T.isNull());
MR = MRMgr.getElementRegion(T, idx, MR, Ctx);
}
-
+
if (isa<CodeTextRegion>(MR))
return SValuator::CastResult(state, UnknownVal());
-
+
// FIXME: Perhaps this method should just take a 'const MemRegion*' argument
// instead of 'Loc', and have the other Loc cases handled at a higher level.
const TypedRegion *R = cast<TypedRegion>(MR);
@@ -911,12 +911,12 @@ RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
RTy = T;
assert(Ctx.getCanonicalType(RTy) ==
Ctx.getCanonicalType(R->getValueType(Ctx)));
- }
+ }
#endif
if (RTy->isStructureType())
return SValuator::CastResult(state, RetrieveStruct(state, R));
-
+
// FIXME: Handle unions.
if (RTy->isUnionType())
return SValuator::CastResult(state, UnknownVal());
@@ -933,10 +933,10 @@ RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
if (const ElementRegion* ER = dyn_cast<ElementRegion>(R))
return CastRetrievedVal(RetrieveElement(state, ER), state, ER, T);
-
+
if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R))
return CastRetrievedVal(RetrieveObjCIvar(state, IVR), state, IVR, T);
-
+
if (const VarRegion *VR = dyn_cast<VarRegion>(R))
return CastRetrievedVal(RetrieveVar(state, VR), state, VR, T);
@@ -967,26 +967,26 @@ RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
return SValuator::CastResult(state,
ValMgr.getRegionValueSymbolValOrUnknown(R, RTy));
}
-
+
std::pair<const GRState*, const MemRegion*>
RegionStoreManager::GetLazyBinding(RegionBindings B, const MemRegion *R) {
if (const nonloc::LazyCompoundVal *V =
dyn_cast_or_null<nonloc::LazyCompoundVal>(B.lookup(R)))
return std::make_pair(V->getState(), V->getRegion());
-
+
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
const std::pair<const GRState *, const MemRegion *> &X =
GetLazyBinding(B, ER->getSuperRegion());
-
+
if (X.first)
return std::make_pair(X.first,
MRMgr.getElementRegionWithSuper(ER, X.second));
- }
+ }
else if (const FieldRegion *FR = dyn_cast<FieldRegion>(R)) {
const std::pair<const GRState *, const MemRegion *> &X =
GetLazyBinding(B, FR->getSuperRegion());
-
+
if (X.first)
return std::make_pair(X.first,
MRMgr.getFieldRegionWithSuper(FR, X.second));
@@ -1010,23 +1010,23 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state,
SVal Idx = R->getIndex();
if (nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&Idx)) {
int64_t i = CI->getValue().getSExtValue();
- int64_t byteLength = Str->getByteLength();
+ int64_t byteLength = Str->getByteLength();
if (i > byteLength) {
// Buffer overflow checking in GRExprEngine should handle this case,
// but we shouldn't rely on it to not overflow here if that checking
// is disabled.
return UnknownVal();
- }
+ }
char c = (i == byteLength) ? '\0' : Str->getStrData()[i];
return ValMgr.makeIntVal(c, getContext().CharTy);
}
}
-
+
// Special case: the current region represents a cast and it and the super
// region both have pointer types or intptr_t types. If so, perform the
// retrieve from the super region and appropriately "cast" the value.
// This is needed to support OSAtomicCompareAndSwap and friends or other
- // loads that treat integers as pointers and vis versa.
+ // loads that treat integers as pointers and vis versa.
if (R->getIndex().isZeroConstant()) {
if (const TypedRegion *superTR = dyn_cast<TypedRegion>(superR)) {
ASTContext &Ctx = getContext();
@@ -1054,21 +1054,21 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state,
// Handle LazyCompoundVals for the immediate super region. Other cases
// are handled in 'RetrieveFieldOrElementCommon'.
- if (const nonloc::LazyCompoundVal *LCV =
+ if (const nonloc::LazyCompoundVal *LCV =
dyn_cast<nonloc::LazyCompoundVal>(V)) {
-
+
R = MRMgr.getElementRegionWithSuper(R, LCV->getRegion());
return RetrieveElement(LCV->getState(), R);
}
-
+
// Other cases: give up.
return UnknownVal();
}
-
+
return RetrieveFieldOrElementCommon(state, R, R->getElementType(), superR);
}
-SVal RegionStoreManager::RetrieveField(const GRState* state,
+SVal RegionStoreManager::RetrieveField(const GRState* state,
const FieldRegion* R) {
// Check if the region has a binding.
@@ -1079,76 +1079,76 @@ SVal RegionStoreManager::RetrieveField(const GRState* state,
QualType Ty = R->getValueType(getContext());
return RetrieveFieldOrElementCommon(state, R, Ty, R->getSuperRegion());
}
-
+
SVal RegionStoreManager::RetrieveFieldOrElementCommon(const GRState *state,
const TypedRegion *R,
QualType Ty,
const MemRegion *superR) {
- // At this point we have already checked in either RetrieveElement or
+ // At this point we have already checked in either RetrieveElement or
// RetrieveField if 'R' has a direct binding.
-
+
RegionBindings B = GetRegionBindings(state->getStore());
-
+
while (superR) {
if (const Optional<SVal> &D = getDefaultBinding(state, superR)) {
if (SymbolRef parentSym = D->getAsSymbol())
return ValMgr.getDerivedRegionValueSymbolVal(parentSym, R);
-
+
if (D->isZeroConstant())
return ValMgr.makeZeroVal(Ty);
-
+
if (D->isUnknown())
return *D;
-
+
assert(0 && "Unknown default value");
}
-
+
// If our super region is a field or element itself, walk up the region
// hierarchy to see if there is a default value installed in an ancestor.
if (isa<FieldRegion>(superR) || isa<ElementRegion>(superR)) {
superR = cast<SubRegion>(superR)->getSuperRegion();
continue;
}
-
+
break;
}
-
+
// Lazy binding?
const GRState *lazyBindingState = NULL;
const MemRegion *lazyBindingRegion = NULL;
llvm::tie(lazyBindingState, lazyBindingRegion) = GetLazyBinding(B, R);
-
+
if (lazyBindingState) {
assert(lazyBindingRegion && "Lazy-binding region not set");
-
+
if (isa<ElementRegion>(R))
return RetrieveElement(lazyBindingState,
cast<ElementRegion>(lazyBindingRegion));
-
+
return RetrieveField(lazyBindingState,
cast<FieldRegion>(lazyBindingRegion));
- }
-
+ }
+
if (R->hasStackStorage() && !R->hasParametersStorage()) {
-
+
if (isa<ElementRegion>(R)) {
// Currently we don't reason specially about Clang-style vectors. Check
// if superR is a vector and if so return Unknown.
if (const TypedRegion *typedSuperR = dyn_cast<TypedRegion>(superR)) {
if (typedSuperR->getValueType(getContext())->isVectorType())
return UnknownVal();
- }
+ }
}
-
+
return UndefinedVal();
}
-
+
// All other values are symbolic.
return ValMgr.getRegionValueSymbolValOrUnknown(R, Ty);
}
-
-SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
+
+SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
const ObjCIvarRegion* R) {
// Check if the region has a binding.
@@ -1156,50 +1156,50 @@ SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
if (const SVal* V = B.lookup(R))
return *V;
-
+
const MemRegion *superR = R->getSuperRegion();
// Check if the super region has a binding.
if (const SVal *V = B.lookup(superR)) {
if (SymbolRef parentSym = V->getAsSymbol())
return ValMgr.getDerivedRegionValueSymbolVal(parentSym, R);
-
+
// Other cases: give up.
return UnknownVal();
}
-
+
return RetrieveLazySymbol(state, R);
}
SVal RegionStoreManager::RetrieveVar(const GRState *state,
const VarRegion *R) {
-
+
// Check if the region has a binding.
RegionBindings B = GetRegionBindings(state->getStore());
-
+
if (const SVal* V = B.lookup(R))
return *V;
-
+
// Lazily derive a value for the VarRegion.
const VarDecl *VD = R->getDecl();
-
+
if (R->hasGlobalsOrParametersStorage())
return ValMgr.getRegionValueSymbolValOrUnknown(R, VD->getType());
-
+
return UndefinedVal();
}
-SVal RegionStoreManager::RetrieveLazySymbol(const GRState *state,
+SVal RegionStoreManager::RetrieveLazySymbol(const GRState *state,
const TypedRegion *R) {
-
+
QualType valTy = R->getValueType(getContext());
// All other values are symbolic.
return ValMgr.getRegionValueSymbolValOrUnknown(R, valTy);
}
-SVal RegionStoreManager::RetrieveStruct(const GRState *state,
- const TypedRegion* R){
+SVal RegionStoreManager::RetrieveStruct(const GRState *state,
+ const TypedRegion* R) {
QualType T = R->getValueType(getContext());
assert(T->isStructureType());
@@ -1240,7 +1240,7 @@ SVal RegionStoreManager::RetrieveArray(const GRState *state,
for (uint64_t i = 0; i < size; ++i) {
SVal Idx = ValMgr.makeArrayIndex(i);
ElementRegion* ER = MRMgr.getElementRegion(CAT->getElementType(), Idx, R,
- getContext());
+ getContext());
QualType ETy = ER->getElementType();
SVal ElementVal = Retrieve(state, loc::MemRegionVal(ER), ETy).getSVal();
ArrayVal = getBasicVals().consVals(ElementVal, ArrayVal);
@@ -1259,15 +1259,15 @@ SVal RegionStoreManager::RetrieveArray(const GRState *state,
Store RegionStoreManager::Remove(Store store, Loc L) {
const MemRegion* R = 0;
-
+
if (isa<loc::MemRegionVal>(L))
R = cast<loc::MemRegionVal>(L).getRegion();
-
+
if (R) {
- RegionBindings B = GetRegionBindings(store);
+ RegionBindings B = GetRegionBindings(store);
return RBFactory.Remove(B, R).getRoot();
}
-
+
return store;
}
@@ -1277,17 +1277,17 @@ const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) {
// If we get here, the location should be a region.
const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion();
-
+
// Check if the region is a struct region.
if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
if (TR->getValueType(getContext())->isStructureType())
return BindStruct(state, TR, V);
-
+
// Special case: the current region represents a cast and it and the super
// region both have pointer types or intptr_t types. If so, perform the
// bind to the super region.
// This is needed to support OSAtomicCompareAndSwap and friends or other
- // loads that treat integers as pointers and vis versa.
+ // loads that treat integers as pointers and vis versa.
if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
if (ER->getIndex().isZeroConstant()) {
if (const TypedRegion *superR =
@@ -1295,17 +1295,17 @@ const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) {
ASTContext &Ctx = getContext();
QualType superTy = superR->getValueType(Ctx);
QualType erTy = ER->getValueType(Ctx);
-
- if (IsAnyPointerOrIntptr(superTy, Ctx) &&
+
+ if (IsAnyPointerOrIntptr(superTy, Ctx) &&
IsAnyPointerOrIntptr(erTy, Ctx)) {
- SValuator::CastResult cr =
- ValMgr.getSValuator().EvalCast(V, state, superTy, erTy);
+ SValuator::CastResult cr =
+ ValMgr.getSValuator().EvalCast(V, state, superTy, erTy);
return Bind(cr.getState(), loc::MemRegionVal(superR), cr.getSVal());
}
}
}
}
-
+
// Perform the binding.
RegionBindings B = GetRegionBindings(state->getStore());
return state->makeWithStore(RBFactory.Add(B, R, V).getRoot());
@@ -1332,7 +1332,7 @@ const GRState *
RegionStoreManager::BindCompoundLiteral(const GRState *state,
const CompoundLiteralExpr* CL,
SVal V) {
-
+
CompoundLiteralRegion* R = MRMgr.getCompoundLiteralRegion(CL);
return Bind(state, loc::MemRegionVal(R), V);
}
@@ -1376,12 +1376,12 @@ const GRState *RegionStoreManager::BindArray(const GRState *state,
// Handle lazy compound values.
if (nonloc::LazyCompoundVal *LCV = dyn_cast<nonloc::LazyCompoundVal>(&Init))
return CopyLazyBindings(*LCV, state, R);
-
- // Remaining case: explicit compound values.
+
+ // Remaining case: explicit compound values.
nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(Init);
nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
uint64_t i = 0;
-
+
for (; i < size; ++i, ++VI) {
// The init list might be shorter than the array length.
if (VI == VE)
@@ -1411,10 +1411,10 @@ const GRState *RegionStoreManager::BindArray(const GRState *state,
const GRState *
RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
SVal V) {
-
+
if (!Features.supportsFields())
return state;
-
+
QualType T = R->getValueType(getContext());
assert(T->isStructureType());
@@ -1427,7 +1427,7 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
// Handle lazy compound values.
if (const nonloc::LazyCompoundVal *LCV = dyn_cast<nonloc::LazyCompoundVal>(&V))
return CopyLazyBindings(*LCV, state, R);
-
+
// We may get non-CompoundVal accidentally due to imprecise cast logic.
// Ignore them and kill the field values.
if (V.isUnknown() || !isa<nonloc::CompoundVal>(V))
@@ -1447,7 +1447,7 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
if (Loc::IsLocType(FTy) || FTy->isIntegerType())
- state = Bind(state, ValMgr.makeLoc(FR), *VI);
+ state = Bind(state, ValMgr.makeLoc(FR), *VI);
else if (FTy->isArrayType())
state = BindArray(state, FR, *VI);
else if (FTy->isStructureType())
@@ -1484,7 +1484,7 @@ const GRState *RegionStoreManager::setDefaultValue(const GRState *state,
const MemRegion* R, SVal V) {
return state->set<RegionDefaultValue>(R, V);
}
-
+
const GRState*
RegionStoreManager::CopyLazyBindings(nonloc::LazyCompoundVal V,
const GRState *state,
@@ -1496,46 +1496,46 @@ RegionStoreManager::CopyLazyBindings(nonloc::LazyCompoundVal V,
RegionDefaultBindings::Factory &DVMFactory =
state->get_context<RegionDefaultValue>();
- llvm::OwningPtr<RegionStoreSubRegionMap>
+ llvm::OwningPtr<RegionStoreSubRegionMap>
SubRegions(getRegionStoreSubRegionMap(state));
- // B and DVM are updated after the call to RemoveSubRegionBindings.
+ // B and DVM are updated after the call to RemoveSubRegionBindings.
RemoveSubRegionBindings(B, DVM, DVMFactory, R, *SubRegions.get());
-
+
// Now copy the bindings. This amounts to just binding 'V' to 'R'. This
// results in a zero-copy algorithm.
return state->makeWithStore(RBFactory.Add(B, R, V).getRoot());
}
-
+
//===----------------------------------------------------------------------===//
// State pruning.
//===----------------------------------------------------------------------===//
-
+
static void UpdateLiveSymbols(SVal X, SymbolReaper& SymReaper) {
if (loc::MemRegionVal *XR = dyn_cast<loc::MemRegionVal>(&X)) {
const MemRegion *R = XR->getRegion();
-
+
while (R) {
if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R)) {
SymReaper.markLive(SR->getSymbol());
return;
}
-
+
if (const SubRegion *SR = dyn_cast<SubRegion>(R)) {
R = SR->getSuperRegion();
continue;
}
-
+
break;
}
-
+
return;
}
-
+
for (SVal::symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end();SI!=SE;++SI)
SymReaper.markLive(*SI);
}
-
+
namespace {
class VISIBILITY_HIDDEN TreeScanner {
RegionBindings B;
@@ -1558,71 +1558,71 @@ public:
: B(b), DB(db), SymReaper(symReaper), Marked(marked),
ScannedLazyVals(scannedLazyVals), M(m),
RS(rs), RegionRoots(regionRoots), MarkKeys(markKeys) {}
-
+
void scanTree(const MemRegion *R);
};
} // end anonymous namespace
-
-
+
+
void TreeScanner::scanTree(const MemRegion *R) {
if (MarkKeys) {
if (Marked.count(R))
- return;
-
+ return;
+
Marked.insert(R);
}
-
+
// Mark the symbol for any live SymbolicRegion as "live". This means we
// should continue to track that symbol.
if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R))
SymReaper.markLive(SymR->getSymbol());
-
+
// Get the data binding for R (if any).
const SVal* Xptr = B.lookup(R);
-
+
// Check for lazy bindings.
if (const nonloc::LazyCompoundVal *V =
dyn_cast_or_null<nonloc::LazyCompoundVal>(Xptr)) {
-
- const LazyCompoundValData *D = V->getCVData();
+
+ const LazyCompoundValData *D = V->getCVData();
if (!ScannedLazyVals.count(D)) {
// Scan the bindings in the LazyCompoundVal.
ScannedLazyVals.insert(D);
-
+
// FIXME: Cache subregion maps.
const GRState *lazyState = D->getState();
llvm::OwningPtr<RegionStoreSubRegionMap>
lazySM(RS.getRegionStoreSubRegionMap(lazyState));
-
+
Store lazyStore = lazyState->getStore();
RegionBindings lazyB = RS.GetRegionBindings(lazyStore);
-
+
RegionDefaultBindings lazyDB = lazyState->get<RegionDefaultValue>();
-
+
// Scan the bindings.
TreeScanner scan(lazyB, lazyDB, SymReaper, Marked, ScannedLazyVals,
*lazySM.get(), RS, RegionRoots, false);
-
+
scan.scanTree(D->getRegion());
}
}
- else {
- // No direct binding? Get the default binding for R (if any).
+ else {
+ // No direct binding? Get the default binding for R (if any).
if (!Xptr)
Xptr = DB.lookup(R);
-
+
// Direct or default binding?
if (Xptr) {
SVal X = *Xptr;
UpdateLiveSymbols(X, SymReaper); // Update the set of live symbols.
-
+
// If X is a region, then add it to the RegionRoots.
if (const MemRegion *RX = X.getAsRegion()) {
RegionRoots.push_back(RX);
// Mark the super region of the RX as live.
- // e.g.: int x; char *y = (char*) &x; if (*y) ...
+ // e.g.: int x; char *y = (char*) &x; if (*y) ...
// 'y' => element region. 'x' is its super region.
if (const SubRegion *SR = dyn_cast<SubRegion>(RX)) {
RegionRoots.push_back(SR->getSuperRegion());
@@ -1630,39 +1630,39 @@ void TreeScanner::scanTree(const MemRegion *R) {
}
}
}
-
- RegionStoreSubRegionMap::iterator I, E;
+
+ RegionStoreSubRegionMap::iterator I, E;
for (llvm::tie(I, E) = M.begin_end(R); I != E; ++I)
scanTree(*I);
}
-void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
+void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
-{
+{
Store store = state.getStore();
RegionBindings B = GetRegionBindings(store);
-
+
// Lazily constructed backmap from MemRegions to SubRegions.
typedef llvm::ImmutableSet<const MemRegion*> SubRegionsTy;
typedef llvm::ImmutableMap<const MemRegion*, SubRegionsTy> SubRegionsMapTy;
-
+
// The backmap from regions to subregions.
llvm::OwningPtr<RegionStoreSubRegionMap>
SubRegions(getRegionStoreSubRegionMap(&state));
-
+
// Do a pass over the regions in the store. For VarRegions we check if
// the variable is still live and if so add it to the list of live roots.
- // For other regions we populate our region backmap.
+ // For other regions we populate our region backmap.
llvm::SmallVector<const MemRegion*, 10> IntermediateRoots;
-
+
// Scan the direct bindings for "intermediate" roots.
for (RegionBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) {
const MemRegion *R = I.getKey();
IntermediateRoots.push_back(R);
}
-
+
// Scan the default bindings for "intermediate" roots.
RegionDefaultBindings DVM = state.get<RegionDefaultValue>();
for (RegionDefaultBindings::iterator I = DVM.begin(), E = DVM.end();
@@ -1672,18 +1672,18 @@ void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
}
// Process the "intermediate" roots to find if they are referenced by
- // real roots.
+ // real roots.
while (!IntermediateRoots.empty()) {
const MemRegion* R = IntermediateRoots.back();
IntermediateRoots.pop_back();
-
+
if (const VarRegion* VR = dyn_cast<VarRegion>(R)) {
if (SymReaper.isLive(Loc, VR->getDecl())) {
RegionRoots.push_back(VR); // This is a live "root".
}
continue;
}
-
+
if (const SymbolicRegion* SR = dyn_cast<SymbolicRegion>(R)) {
if (SymReaper.isLive(SR->getSymbol()))
RegionRoots.push_back(SR);
@@ -1695,9 +1695,9 @@ void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
dyn_cast<SubRegion>(cast<SubRegion>(R)->getSuperRegion()))
IntermediateRoots.push_back(superR);
}
-
+
// Process the worklist of RegionRoots. This performs a "mark-and-sweep"
- // of the store. We want to find all live symbols and dead regions.
+ // of the store. We want to find all live symbols and dead regions.
llvm::DenseSet<const MemRegion*> Marked;
llvm::DenseSet<const LazyCompoundValData*> LazyVals;
TreeScanner TS(B, DVM, SymReaper, Marked, LazyVals, *SubRegions.get(),
@@ -1707,59 +1707,59 @@ void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
const MemRegion *R = RegionRoots.back();
RegionRoots.pop_back();
TS.scanTree(R);
- }
-
+ }
+
// We have now scanned the store, marking reachable regions and symbols
// as live. We now remove all the regions that are dead from the store
- // as well as update DSymbols with the set symbols that are now dead.
+ // as well as update DSymbols with the set symbols that are now dead.
for (RegionBindings::iterator I = B.begin(), E = B.end(); I != E; ++I) {
const MemRegion* R = I.getKey();
// If this region live? Is so, none of its symbols are dead.
if (Marked.count(R))
continue;
-
+
// Remove this dead region from the store.
store = Remove(store, ValMgr.makeLoc(R));
-
+
// Mark all non-live symbols that this region references as dead.
if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R))
SymReaper.maybeDead(SymR->getSymbol());
-
+
SVal X = I.getData();
SVal::symbol_iterator SI = X.symbol_begin(), SE = X.symbol_end();
for (; SI != SE; ++SI)
SymReaper.maybeDead(*SI);
}
-
- // Remove dead 'default' bindings.
+
+ // Remove dead 'default' bindings.
RegionDefaultBindings NewDVM = DVM;
- RegionDefaultBindings::Factory &DVMFactory =
+ RegionDefaultBindings::Factory &DVMFactory =
state.get_context<RegionDefaultValue>();
-
+
for (RegionDefaultBindings::iterator I = DVM.begin(), E = DVM.end();
I != E; ++I) {
const MemRegion *R = I.getKey();
-
+
// If this region live? Is so, none of its symbols are dead.
if (Marked.count(R))
continue;
-
+
// Remove this dead region.
NewDVM = DVMFactory.Remove(NewDVM, R);
-
+
// Mark all non-live symbols that this region references as dead.
if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R))
SymReaper.maybeDead(SymR->getSymbol());
-
+
SVal X = I.getData();
SVal::symbol_iterator SI = X.symbol_begin(), SE = X.symbol_end();
for (; SI != SE; ++SI)
SymReaper.maybeDead(*SI);
}
-
+
// Write the store back.
state.setStore(store);
-
+
// Write the updated default bindings back.
// FIXME: Right now this involves a fetching of a persistent state.
// We can do better.
@@ -1775,7 +1775,7 @@ void RegionStoreManager::print(Store store, llvm::raw_ostream& OS,
const char* nl, const char *sep) {
RegionBindings B = GetRegionBindings(store);
OS << "Store (direct bindings):" << nl;
-
+
for (RegionBindings::iterator I = B.begin(), E = B.end(); I != E; ++I)
- OS << ' ' << I.getKey() << " : " << I.getData() << nl;
+ OS << ' ' << I.getKey() << " : " << I.getData() << nl;
}
diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp
index 91674b82ed..688b7ff6e1 100644
--- a/lib/Analysis/SVals.cpp
+++ b/lib/Analysis/SVals.cpp
@@ -58,7 +58,7 @@ const FunctionDecl *SVal::getAsFunctionDecl() const {
return NULL;
}
-/// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
+/// getAsLocSymbol - If this SVal is a location (subclasses Loc) and
/// wraps a symbol, return that SymbolRef. Otherwise return 0.
// FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
SymbolRef SVal::getAsLocSymbol() const {
@@ -76,11 +76,11 @@ SymbolRef SVal::getAsLocSymbol() const {
SymbolRef SVal::getAsSymbol() const {
if (const nonloc::SymbolVal *X = dyn_cast<nonloc::SymbolVal>(this))
return X->getSymbol();
-
+
if (const nonloc::SymExprVal *X = dyn_cast<nonloc::SymExprVal>(this))
if (SymbolRef Y = dyn_cast<SymbolData>(X->getSymbolicExpression()))
return Y;
-
+
return getAsLocSymbol();
}
@@ -89,7 +89,7 @@ SymbolRef SVal::getAsSymbol() const {
const SymExpr *SVal::getAsSymbolicExpression() const {
if (const nonloc::SymExprVal *X = dyn_cast<nonloc::SymExprVal>(this))
return X->getSymbolicExpression();
-
+
return getAsSymbol();
}
@@ -115,13 +115,13 @@ bool SVal::symbol_iterator::operator!=(const symbol_iterator &X) const {
SVal::symbol_iterator::symbol_iterator(const SymExpr *SE) {
itr.push_back(SE);
- while (!isa<SymbolData>(itr.back())) expand();
+ while (!isa<SymbolData>(itr.back())) expand();
}
SVal::symbol_iterator& SVal::symbol_iterator::operator++() {
assert(!itr.empty() && "attempting to iterate on an 'end' iterator");
assert(isa<SymbolData>(itr.back()));
- itr.pop_back();
+ itr.pop_back();
if (!itr.empty())
while (!isa<SymbolData>(itr.back())) expand();
return *this;
@@ -135,17 +135,17 @@ SymbolRef SVal::symbol_iterator::operator*() {
void SVal::symbol_iterator::expand() {
const SymExpr *SE = itr.back();
itr.pop_back();
-
+
if (const SymIntExpr *SIE = dyn_cast<SymIntExpr>(SE)) {
itr.push_back(SIE->getLHS());
return;
- }
+ }
else if (const SymSymExpr *SSE = dyn_cast<SymSymExpr>(SE)) {
itr.push_back(SSE->getLHS());
itr.push_back(SSE->getRHS());
return;
}
-
+
assert(false && "unhandled expansion case");
}
@@ -189,10 +189,10 @@ bool SVal::isZeroConstant() const {
SVal nonloc::ConcreteInt::evalBinOp(ValueManager &ValMgr,
BinaryOperator::Opcode Op,
- const nonloc::ConcreteInt& R) const {
+ const nonloc::ConcreteInt& R) const {
const llvm::APSInt* X =
ValMgr.getBasicValueFactory().EvaluateAPSInt(Op, getValue(), R.getValue());
-
+
if (X)
return nonloc::ConcreteInt(*X);
else
@@ -215,12 +215,12 @@ nonloc::ConcreteInt nonloc::ConcreteInt::evalMinus(ValueManager &ValMgr) const {
SVal loc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals,
BinaryOperator::Opcode Op,
const loc::ConcreteInt& R) const {
-
+
assert (Op == BinaryOperator::Add || Op == BinaryOperator::Sub ||
(Op >= BinaryOperator::LT && Op <= BinaryOperator::NE));
-
+
const llvm::APSInt* X = BasicVals.EvaluateAPSInt(Op, getValue(), R.getValue());
-
+
if (X)
return loc::ConcreteInt(*X);
else
@@ -234,40 +234,40 @@ SVal loc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals,
void SVal::dump() const { dumpToStream(llvm::errs()); }
void SVal::dumpToStream(llvm::raw_ostream& os) const {
- switch (getBaseKind()) {
+ switch (getBaseKind()) {
case UnknownKind:
os << "Invalid";
- break;
+ break;
case NonLocKind:
cast<NonLoc>(this)->dumpToStream(os);
- break;
+ break;
case LocKind:
cast<Loc>(this)->dumpToStream(os);
- break;
+ break;
case UndefinedKind:
os << "Undefined";
- break;
+ break;
default:
assert (false && "Invalid SVal.");
}
}
void NonLoc::dumpToStream(llvm::raw_ostream& os) const {
- switch (getSubKind()) {
+ switch (getSubKind()) {
case nonloc::ConcreteIntKind:
os << cast<nonloc::ConcreteInt>(this)->getValue().getZExtValue();
if (cast<nonloc::ConcreteInt>(this)->getValue().isUnsigned())
- os << 'U';
- break;
+ os << 'U';
+ break;
case nonloc::SymbolValKind:
os << '$' << cast<nonloc::SymbolVal>(this)->getSymbol();
- break;
+ break;
case nonloc::SymExprValKind: {
const nonloc::SymExprVal& C = *cast<nonloc::SymExprVal>(this);
const SymExpr *SE = C.getSymbolicExpression();
os << SE;
break;
- }
+ }
case nonloc::LocAsIntegerKind: {
const nonloc::LocAsInteger& C = *cast<nonloc::LocAsInteger>(this);
os << C.getLoc() << " [as " << C.getNumBits() << " bit integer]";
@@ -278,7 +278,7 @@ void NonLoc::dumpToStream(llvm::raw_ostream& os) const {
os << "compoundVal{";
bool first = true;
for (nonloc::CompoundVal::iterator I=C.begin(), E=C.end(); I!=E; ++I) {
- if (first) {
+ if (first) {
os << ' '; first = false;
}
else
@@ -294,24 +294,24 @@ void NonLoc::dumpToStream(llvm::raw_ostream& os) const {
os << "lazyCompoundVal{" << (void*) C.getState() << ',' << C.getRegion()
<< '}';
break;
- }
+ }
default:
assert (false && "Pretty-printed not implemented for this NonLoc.");
break;
}
}
-void Loc::dumpToStream(llvm::raw_ostream& os) const {
- switch (getSubKind()) {
+void Loc::dumpToStream(llvm::raw_ostream& os) const {
+ switch (getSubKind()) {
case loc::ConcreteIntKind:
os << cast<loc::ConcreteInt>(this)->getValue().getZExtValue() << " (Loc)";
- break;
+ break;
case loc::GotoLabelKind:
os << "&&" << cast<loc::GotoLabel>(this)->getLabel()->getID()->getName();
break;
case loc::MemRegionKind:
os << '&' << cast<loc::MemRegionVal>(this)->getRegion()->getString();
- break;
+ break;
default:
assert(false && "Pretty-printing not implemented for this Loc.");
break;
diff --git a/lib/Analysis/SValuator.cpp b/lib/Analysis/SValuator.cpp
index 2542cfdd3c..383fe45c1d 100644
--- a/lib/Analysis/SValuator.cpp
+++ b/lib/Analysis/SValuator.cpp
@@ -23,94 +23,94 @@ SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op,
if (L.isUndef() || R.isUndef())
return UndefinedVal();
-
+
if (L.isUnknown() || R.isUnknown())
return UnknownVal();
-
+
if (isa<Loc>(L)) {
if (isa<Loc>(R))
return EvalBinOpLL(Op, cast<Loc>(L), cast<Loc>(R), T);
return EvalBinOpLN(ST, Op, cast<Loc>(L), cast<NonLoc>(R), T);
}
-
+
if (isa<Loc>(R)) {
// Support pointer arithmetic where the increment/decrement operand
- // is on the left and the pointer on the right.
+ // is on the left and the pointer on the right.
assert(Op == BinaryOperator::Add || Op == BinaryOperator::Sub);
-
+
// Commute the operands.
return EvalBinOpLN(ST, Op, cast<Loc>(R), cast<NonLoc>(L), T);
}
- return EvalBinOpNN(Op, cast<NonLoc>(L), cast<NonLoc>(R), T);
+ return EvalBinOpNN(Op, cast<NonLoc>(L), cast<NonLoc>(R), T);
}
-SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state,
+SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state,
QualType castTy, QualType originalTy){
-
+
if (val.isUnknownOrUndef() || castTy == originalTy)
return CastResult(state, val);
-
+
ASTContext &C = ValMgr.getContext();
-
+
// For const casts, just propagate the value.
- if (C.getCanonicalType(castTy).getUnqualifiedType() ==
+ if (C.getCanonicalType(castTy).getUnqualifiedType() ==
C.getCanonicalType(originalTy).getUnqualifiedType())
return CastResult(state, val);
-
+
// Check for casts from pointers to integers.
if (castTy->isIntegerType() && Loc::IsLocType(originalTy))
return CastResult(state, EvalCastL(cast<Loc>(val), castTy));
-
+
// Check for casts from integers to pointers.
if (Loc::IsLocType(castTy) && originalTy->isIntegerType()) {
if (nonloc::LocAsInteger *LV = dyn_cast<nonloc::LocAsInteger>(&val)) {
// Just unpackage the lval and return it.
return CastResult(state, LV->getLoc());
}
-
+
goto DispatchCast;
}
-
+
// Just pass through function and block pointers.
if (originalTy->isBlockPointerType() || originalTy->isFunctionPointerType()) {
assert(Loc::IsLocType(castTy));
return CastResult(state, val);
}
-
+
// Check for casts from array type to another type.
if (originalTy->isArrayType()) {
// We will always decay to a pointer.
val = ValMgr.getStateManager().ArrayToPointer(cast<Loc>(val));
-
+
// Are we casting from an array to a pointer? If so just pass on
// the decayed value.
if (castTy->isPointerType())
return CastResult(state, val);
-
+
// Are we casting from an array to an integer? If so, cast the decayed
// pointer value to an integer.
assert(castTy->isIntegerType());
-
+
// FIXME: Keep these here for now in case we decide soon that we
// need the original decayed type.
// QualType elemTy = cast<ArrayType>(originalTy)->getElementType();
// QualType pointerTy = C.getPointerType(elemTy);
return CastResult(state, EvalCastL(cast<Loc>(val), castTy));
}
-
+
// Check for casts from a region to a specific type.
if (const MemRegion *R = val.getAsRegion()) {
// FIXME: We should handle the case where we strip off view layers to get
// to a desugared type.
-
+
assert(Loc::IsLocType(castTy));
// We get a symbolic function pointer for a dereference of a function
// pointer, but it is of function type. Example:
-
+
// struct FPRec {
- // void (*my_func)(int * x);
+ // void (*my_func)(int * x);
// };
//
// int bar(int x);
@@ -120,29 +120,29 @@ SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state,
// (*foo->my_func)(&x);
// return bar(x)+1; // no-warning
// }
-
+
assert(Loc::IsLocType(originalTy) || originalTy->isFunctionType() ||
originalTy->isBlockPointerType());
-
+
StoreManager &storeMgr = ValMgr.getStateManager().getStoreManager();
-
+
// Delegate to store manager to get the result of casting a region
// to a different type.
const StoreManager::CastResult& Res = storeMgr.CastRegion(state, R, castTy);
-
+
// Inspect the result. If the MemRegion* returned is NULL, this
// expression evaluates to UnknownVal.
R = Res.getRegion();
-
+
if (R)
return CastResult(Res.getState(), loc::MemRegionVal(R));
-
+
return CastResult(Res.getState(), UnknownVal());
}
-
- // All other cases.
+
+ // All other cases.
DispatchCast:
return CastResult(state,
- isa<Loc>(val) ? EvalCastL(cast<Loc>(val), castTy)
+ isa<Loc>(val) ? EvalCastL(cast<Loc>(val), castTy)
: EvalCastNL(cast<NonLoc>(val), castTy));
}
diff --git a/lib/Analysis/SimpleConstraintManager.cpp b/lib/Analysis/SimpleConstraintManager.cpp
index 82801eb05d..db3d68a2c7 100644
--- a/lib/Analysis/SimpleConstraintManager.cpp
+++ b/lib/Analysis/SimpleConstraintManager.cpp
@@ -23,10 +23,10 @@ SimpleConstraintManager::~SimpleConstraintManager() {}
bool SimpleConstraintManager::canReasonAbout(SVal X) const {
if (nonloc::SymExprVal *SymVal = dyn_cast<nonloc::SymExprVal>(&X)) {
const SymExpr *SE = SymVal->getSymbolicExpression();
-
+
if (isa<SymbolData>(SE))
return true;
-
+
if (const SymIntExpr *SIE = dyn_cast<SymIntExpr>(SE)) {
switch (SIE->getOpcode()) {
// We don't reason yet about bitwise-constraints on symbolic values.
@@ -46,7 +46,7 @@ bool SimpleConstraintManager::canReasonAbout(SVal X) const {
// All other cases.
default:
return true;
- }
+ }
}
return false;
@@ -54,7 +54,7 @@ bool SimpleConstraintManager::canReasonAbout(SVal X) const {
return true;
}
-
+
const GRState *SimpleConstraintManager::Assume(const GRState *state,
SVal Cond, bool Assumption) {
if (Cond.isUnknown()) {
@@ -74,14 +74,14 @@ const GRState *SimpleConstraintManager::Assume(const GRState *state, Loc Cond,
// EvalAssume is used to call into the GRTransferFunction object to perform
// any checker-specific update of the state based on this assumption being
- // true or false.
+ // true or false.
return state ? state->getTransferFuncs().EvalAssume(state, Cond, Assumption)
: NULL;
}
const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
Loc Cond, bool Assumption) {
-
+
BasicValueFactory &BasicVals = state->getBasicVals();
switch (Cond.getSubKind()) {
@@ -91,7 +91,7 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
case loc::MemRegionKind: {
// FIXME: Should this go into the storemanager?
-
+
const MemRegion *R = cast<loc::MemRegionVal>(Cond).getRegion();
const SubRegion *SubR = dyn_cast<SubRegion>(R);
@@ -99,7 +99,7 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
// FIXME: now we only find the first symbolic region.
if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(SubR)) {
if (Assumption)
- return AssumeSymNE(state, SymR->getSymbol(),
+ return AssumeSymNE(state, SymR->getSymbol(),
BasicVals.getZeroWithPtrWidth());
else
return AssumeSymEQ(state, SymR->getSymbol(),
@@ -107,15 +107,15 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
}
SubR = dyn_cast<SubRegion>(SubR->getSuperRegion());
}
-
+
// FALL-THROUGH.
}
-
+
case loc::GotoLabelKind:
return Assumption ? state : NULL;
case loc::ConcreteIntKind: {
- bool b = cast<loc::ConcreteInt>(Cond).getValue() != 0;
+ bool b = cast<loc::ConcreteInt>(Cond).getValue() != 0;
bool isFeasible = b ? Assumption : !Assumption;
return isFeasible ? state : NULL;
}
@@ -130,7 +130,7 @@ const GRState *SimpleConstraintManager::Assume(const GRState *state,
// EvalAssume is used to call into the GRTransferFunction object to perform
// any checker-specific update of the state based on this assumption being
- // true or false.
+ // true or false.
return state ? state->getTransferFuncs().EvalAssume(state, Cond, Assumption)
: NULL;
}
@@ -138,13 +138,13 @@ const GRState *SimpleConstraintManager::Assume(const GRState *state,
const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
NonLoc Cond,
bool Assumption) {
-
+
// We cannot reason about SymIntExpr and SymSymExpr.
if (!canReasonAbout(Cond)) {
// Just return the current state indicating that the path is feasible.
// This may be an over-approximation of what is possible.
return state;
- }
+ }
BasicValueFactory &BasicVals = state->getBasicVals();
SymbolManager &SymMgr = state->getSymbolManager();
@@ -156,7 +156,7 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
case nonloc::SymbolValKind: {
nonloc::SymbolVal& SV = cast<nonloc::SymbolVal>(Cond);
SymbolRef sym = SV.getSymbol();
- QualType T = SymMgr.getType(sym);
+ QualType T = SymMgr.getType(sym);
const llvm::APSInt &zero = BasicVals.getValue(0, T);
return Assumption ? AssumeSymNE(state, sym, zero)
@@ -167,7 +167,7 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state,
nonloc::SymExprVal V = cast<nonloc::SymExprVal>(Cond);
if (const SymIntExpr *SE = dyn_cast<SymIntExpr>(V.getSymbolicExpression()))
return AssumeSymInt(state, Assumption, SE);
-
+
// For all other symbolic expressions, over-approximate and consider
// the constraint feasible.
return state;
@@ -194,7 +194,7 @@ const GRState *SimpleConstraintManager::AssumeSymInt(const GRState *state,
// rest of the constraint manager logic.
SymbolRef Sym = cast<SymbolData>(SE->getLHS());
const llvm::APSInt &Int = SE->getRHS();
-
+
switch (SE->getOpcode()) {
default:
// No logic yet for other operators. Assume the constraint is feasible.
@@ -218,7 +218,7 @@ const GRState *SimpleConstraintManager::AssumeSymInt(const GRState *state,
case BinaryOperator::LT:
return Assumption ? AssumeSymLT(state, Sym, Int)
: AssumeSymGE(state, Sym, Int);
-
+
case BinaryOperator::LE:
return Assumption ? AssumeSymLE(state, Sym, Int)
: AssumeSymGT(state, Sym, Int);
@@ -226,9 +226,9 @@ const GRState *SimpleConstraintManager::AssumeSymInt(const GRState *state,
}
const GRState *SimpleConstraintManager::AssumeInBound(const GRState *state,
- SVal Idx,
+ SVal Idx,
SVal UpperBound,
- bool Assumption) {
+ bool Assumption) {
// Only support ConcreteInt for now.
if (!(isa<nonloc::ConcreteInt>(Idx) && isa<nonloc::ConcreteInt>(UpperBound)))
diff --git a/lib/Analysis/SimpleConstraintManager.h b/lib/Analysis/SimpleConstraintManager.h
index 1e1a10da03..d626dfec8c 100644
--- a/lib/Analysis/SimpleConstraintManager.h
+++ b/lib/Analysis/SimpleConstraintManager.h
@@ -22,8 +22,8 @@ namespace clang {
class SimpleConstraintManager : public ConstraintManager {
public:
SimpleConstraintManager() {}
- virtual ~SimpleConstraintManager();
-
+ virtual ~SimpleConstraintManager();
+
//===------------------------------------------------------------------===//
// Common implementation for the interface provided by ConstraintManager.
//===------------------------------------------------------------------===//
@@ -38,16 +38,16 @@ public:
const GRState *AssumeSymInt(const GRState *state, bool Assumption,
const SymIntExpr *SE);
-
+
const GRState *AssumeInBound(const GRState *state, SVal Idx, SVal UpperBound,
bool Assumption);
-
+
protected:
-
+
//===------------------------------------------------------------------===//
// Interface that subclasses must implement.
//===------------------------------------------------------------------===//
-
+
virtual const GRState *AssumeSymNE(const GRState *state, SymbolRef sym,
const llvm::APSInt& V) = 0;
@@ -65,13 +65,13 @@ protected:
virtual const GRState *AssumeSymGE(const GRState *state, SymbolRef sym,
const llvm::APSInt& V) = 0;
-
+
//===------------------------------------------------------------------===//
// Internal implementation.
//===------------------------------------------------------------------===//
-
+
const GRState *AssumeAux(const GRState *state, Loc Cond,bool Assumption);
-
+
const GRState *AssumeAux(const GRState *state, NonLoc Cond, bool Assumption);
};
diff --git a/lib/Analysis/SimpleSValuator.cpp b/lib/Analysis/SimpleSValuator.cpp
index 9850b2e036..442845a7c5 100644
--- a/lib/Analysis/SimpleSValuator.cpp
+++ b/lib/Analysis/SimpleSValuator.cpp
@@ -20,22 +20,22 @@ using namespace clang;
namespace {
class VISIBILITY_HIDDEN SimpleSValuator : public SValuator {
protected:
- virtual SVal EvalCastNL(NonLoc val, QualType castTy);
- virtual SVal EvalCastL(Loc val, QualType castTy);
+ virtual SVal EvalCastNL(NonLoc val, QualType castTy);
+ virtual SVal EvalCastL(Loc val, QualType castTy);
public:
SimpleSValuator(ValueManager &valMgr) : SValuator(valMgr) {}
virtual ~SimpleSValuator() {}
-
- virtual SVal EvalMinus(NonLoc val);
- virtual SVal EvalComplement(NonLoc val);
+
+ virtual SVal EvalMinus(NonLoc val);
+ virtual SVal EvalComplement(NonLoc val);
virtual SVal EvalBinOpNN(BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs,
QualType resultTy);
virtual SVal EvalBinOpLL(BinaryOperator::Opcode op, Loc lhs, Loc rhs,
QualType resultTy);
virtual SVal EvalBinOpLN(const GRState *state, BinaryOperator::Opcode op,
Loc lhs, NonLoc rhs, QualType resultTy);
-};
+};
} // end anonymous namespace
SValuator *clang::CreateSimpleSValuator(ValueManager &valMgr) {
@@ -47,19 +47,19 @@ SValuator *clang::CreateSimpleSValuator(ValueManager &valMgr) {
//===----------------------------------------------------------------------===//
SVal SimpleSValuator::EvalCastNL(NonLoc val, QualType castTy) {
-
+
bool isLocType = Loc::IsLocType(castTy);
-
+
if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val)) {
if (isLocType)
return LI->getLoc();
-
- ASTContext &Ctx = ValMgr.getContext();
-
+
+ ASTContext &Ctx = ValMgr.getContext();
+
// FIXME: Support promotions/truncations.
if (Ctx.getTypeSize(castTy) == Ctx.getTypeSize(Ctx.VoidPtrTy))
return val;
-
+
return UnknownVal();
}
@@ -68,17 +68,17 @@ SVal SimpleSValuator::EvalCastNL(NonLoc val, QualType castTy) {
QualType T = Ctx.getCanonicalType(se->getType(Ctx));
if (T == Ctx.getCanonicalType(castTy))
return val;
-
+
return UnknownVal();
}
-
+
if (!isa<nonloc::ConcreteInt>(val))
return UnknownVal();
-
+
// Only handle casts from integers to integers.
if (!isLocType && !castTy->isIntegerType())
return UnknownVal();
-
+
llvm::APSInt i = cast<nonloc::ConcreteInt>(val).getValue();
i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
i.extOrTrunc(ValMgr.getContext().getTypeSize(castTy));
@@ -90,7 +90,7 @@ SVal SimpleSValuator::EvalCastNL(NonLoc val, QualType castTy) {
}
SVal SimpleSValuator::EvalCastL(Loc val, QualType castTy) {
-
+
// Casts from pointers -> pointers, just return the lval.
//
// Casts from pointers -> references, just return the lval. These
@@ -98,21 +98,21 @@ SVal SimpleSValuator::EvalCastL(Loc val, QualType castTy) {
// casting from va_list* to __builtin_va_list&.
//
assert(!val.isUnknownOrUndef());
-
+
if (Loc::IsLocType(castTy) || castTy->isReferenceType())
return val;
-
+
// FIXME: Handle transparent unions where a value can be "transparently"
// lifted into a union type.
if (castTy->isUnionType())
return UnknownVal();
-
+
assert(castTy->isIntegerType());
unsigned BitWidth = ValMgr.getContext().getTypeSize(castTy);
if (!isa<loc::ConcreteInt>(val))
return ValMgr.makeLocAsInteger(val, BitWidth);
-
+
llvm::APSInt i = cast<loc::ConcreteInt>(val).getValue();
i.setIsUnsigned(castTy->isUnsignedIntegerType() || Loc::IsLocType(castTy));
i.extOrTrunc(BitWidth);
@@ -124,7 +124,7 @@ SVal SimpleSValuator::EvalCastL(Loc val, QualType castTy) {
//===----------------------------------------------------------------------===//
SVal SimpleSValuator::EvalMinus(NonLoc val) {
- switch (val.getSubKind()) {
+ switch (val.getSubKind()) {
case nonloc::ConcreteIntKind:
return cast<nonloc::ConcreteInt>(val).evalMinus(ValMgr);
default:
@@ -158,18 +158,18 @@ static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
}
}
-// Equality operators for Locs.
+// Equality operators for Locs.
// FIXME: All this logic will be revamped when we have MemRegion::getLocation()
// implemented.
static SVal EvalEquality(ValueManager &ValMgr, Loc lhs, Loc rhs, bool isEqual,
QualType resultTy) {
-
+
switch (lhs.getSubKind()) {
default:
assert(false && "EQ/NE not implemented for this Loc.");
return UnknownVal();
-
+
case loc::ConcreteIntKind: {
if (SymbolRef rSym = rhs.getAsSymbol())
return ValMgr.makeNonLoc(rSym,
@@ -178,7 +178,7 @@ static SVal EvalEquality(ValueManager &ValMgr, Loc lhs, Loc rhs, bool isEqual,
cast<loc::ConcreteInt>(lhs).getValue(),
resultTy);
break;
- }
+ }
case loc::MemRegionKind: {
if (SymbolRef lSym = lhs.getAsLocSymbol()) {
if (isa<loc::ConcreteInt>(rhs)) {
@@ -191,11 +191,11 @@ static SVal EvalEquality(ValueManager &ValMgr, Loc lhs, Loc rhs, bool isEqual,
}
break;
}
-
+
case loc::GotoLabelKind:
break;
}
-
+
return ValMgr.makeTruthVal(isEqual ? lhs == rhs : lhs != rhs, resultTy);
}
@@ -220,17 +220,17 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
case BinaryOperator::NE:
return ValMgr.makeTruthVal(false, resultTy);
}
-
+
while (1) {
switch (lhs.getSubKind()) {
default:
- return UnknownVal();
+ return UnknownVal();
case nonloc::LocAsIntegerKind: {
- Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
+ Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
switch (rhs.getSubKind()) {
case nonloc::LocAsIntegerKind:
return EvalBinOpLL(op, lhsL, cast<nonloc::LocAsInteger>(rhs).getLoc(),
- resultTy);
+ resultTy);
case nonloc::ConcreteIntKind: {
// Transform the integer into a location and compare.
ASTContext& Ctx = ValMgr.getContext();
@@ -239,7 +239,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
i.extOrTrunc(Ctx.getTypeSize(Ctx.VoidPtrTy));
return EvalBinOpLL(op, lhsL, ValMgr.makeLoc(i), resultTy);
}
- default:
+ default:
switch (op) {
case BinaryOperator::EQ:
return ValMgr.makeTruthVal(false, resultTy);
@@ -250,15 +250,15 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
return UnknownVal();
}
}
- }
+ }
case nonloc::SymExprValKind: {
- // Logical not?
+ // Logical not?
if (!(op == BinaryOperator::EQ && rhs.isZeroConstant()))
return UnknownVal();
const SymExpr *symExpr =
cast<nonloc::SymExprVal>(lhs).getSymbolicExpression();
-
+
// Only handle ($sym op constant) for now.
if (const SymIntExpr *symIntExpr = dyn_cast<SymIntExpr>(symExpr)) {
BinaryOperator::Opcode opc = symIntExpr->getOpcode();
@@ -301,7 +301,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
case BinaryOperator::GT:
case BinaryOperator::LE:
case BinaryOperator::GE:
- case BinaryOperator::EQ:
+ case BinaryOperator::EQ:
case BinaryOperator::NE:
opc = NegateComparison(opc);
assert(symIntExpr->getType(ValMgr.getContext()) == resultTy);
@@ -310,7 +310,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
}
}
}
- case nonloc::ConcreteIntKind: {
+ case nonloc::ConcreteIntKind: {
if (isa<nonloc::ConcreteInt>(rhs)) {
const nonloc::ConcreteInt& lhsInt = cast<nonloc::ConcreteInt>(lhs);
return lhsInt.evalBinOp(ValMgr, op, cast<nonloc::ConcreteInt>(rhs));
@@ -322,7 +322,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
NonLoc tmp = rhs;
rhs = lhs;
lhs = tmp;
-
+
switch (op) {
case BinaryOperator::LT: op = BinaryOperator::GT; continue;
case BinaryOperator::GT: op = BinaryOperator::LT; continue;
@@ -335,7 +335,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
continue;
default:
return UnknownVal();
- }
+ }
}
}
case nonloc::SymbolValKind: {
@@ -352,7 +352,7 @@ SVal SimpleSValuator::EvalBinOpNN(BinaryOperator::Opcode op,
}
SVal SimpleSValuator::EvalBinOpLL(BinaryOperator::Opcode op, Loc lhs, Loc rhs,
- QualType resultTy) {
+ QualType resultTy) {
switch (op) {
default:
return UnknownVal();
@@ -364,7 +364,7 @@ SVal SimpleSValuator::EvalBinOpLL(BinaryOperator::Opcode op, Loc lhs, Loc rhs,
SVal SimpleSValuator::EvalBinOpLN(const GRState *state,
BinaryOperator::Opcode op,
- Loc lhs, NonLoc rhs, QualType resultTy) {
+ Loc lhs, NonLoc rhs, QualType resultTy) {
// Special case: 'rhs' is an integer that has the same width as a pointer and
// we are using the integer location in a comparison. Normally this cannot be
// triggered, but transfer functions like those for OSCommpareAndSwapBarrier32
@@ -377,13 +377,13 @@ SVal SimpleSValuator::EvalBinOpLN(const GRState *state,
if (ctx.getTypeSize(ctx.VoidPtrTy) == x->getBitWidth()) {
// Convert the signedness of the integer (if necessary).
if (x->isSigned())
- x = &ValMgr.getBasicValueFactory().getValue(*x, true);
+ x = &ValMgr.getBasicValueFactory().getValue(*x, true);
return EvalBinOpLL(op, lhs, loc::ConcreteInt(*x), resultTy);
}
}
}
-
+
// Delegate pointer arithmetic to the StoreManager.
return state->getStateManager().getStoreManager().EvalBinOp(state, op, lhs,
rhs, resultTy);
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index f0ecda73de..d1abd57640 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -27,7 +27,7 @@ StoreManager::MakeElementRegion(const GRState *state, const MemRegion *region,
// Create a new ElementRegion.
SVal idx = ValMgr.makeArrayIndex(index);
return CastResult(state, MRMgr.getElementRegion(pointeeTy, idx, region,
- ValMgr.getContext()));
+ ValMgr.getContext()));
}
// FIXME: Merge with the implementation of the same method in MemRegion.cpp
@@ -37,16 +37,16 @@ static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
if (!D->getDefinition(Ctx))
return false;
}
-
+
return true;
}
StoreManager::CastResult
StoreManager::CastRegion(const GRState *state, const MemRegion* R,
QualType CastToTy) {
-
+
ASTContext& Ctx = StateMgr.getContext();
-
+
// Handle casts to Objective-C objects.
if (CastToTy->isObjCObjectPointerType())
return CastResult(state, R->getBaseRegion());
@@ -55,7 +55,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// FIXME: We may need different solutions, depending on the symbol
// involved. Blocks can be casted to/from 'id', as they can be treated
// as Objective-C objects. This could possibly be handled by enhancing
- // our reasoning of downcasts of symbolic objects.
+ // our reasoning of downcasts of symbolic objects.
if (isa<CodeTextRegion>(R) || isa<SymbolicRegion>(R))
return CastResult(state, R);
@@ -72,7 +72,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// Handle casts to void*. We just pass the region through.
if (CanonPointeeTy.getUnqualifiedType() == Ctx.VoidTy)
return CastResult(state, R);
-
+
// Handle casts from compatible types.
if (R->isBoundable())
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
@@ -90,7 +90,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
case MemRegion::END_TYPED_REGIONS: {
assert(0 && "Invalid region cast");
break;
- }
+ }
case MemRegion::CodeTextRegionKind: {
// CodeTextRegion should be cast to only a function or block pointer type,
// although they can in practice be casted to anything, e.g, void*,
@@ -98,7 +98,7 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// Just pass the region through.
break;
}
-
+
case MemRegion::StringRegionKind:
case MemRegion::ObjCObjectRegionKind:
// FIXME: Need to handle arbitrary downcasts.
@@ -107,9 +107,9 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
case MemRegion::CompoundLiteralRegionKind:
case MemRegion::FieldRegionKind:
case MemRegion::ObjCIvarRegionKind:
- case MemRegion::VarRegionKind:
+ case MemRegion::VarRegionKind:
return MakeElementRegion(state, R, PointeeTy, CastToTy);
-
+
case MemRegion::ElementRegionKind: {
// If we are casting from an ElementRegion to another type, the
// algorithm is as follows:
@@ -117,51 +117,51 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
// (1) Compute the "raw offset" of the ElementRegion from the
// base region. This is done by calling 'getAsRawOffset()'.
//
- // (2a) If we get a 'RegionRawOffset' after calling
+ // (2a) If we get a 'RegionRawOffset' after calling
// 'getAsRawOffset()', determine if the absolute offset
- // can be exactly divided into chunks of the size of the
- // casted-pointee type. If so, create a new ElementRegion with
+ // can be exactly divided into chunks of the size of the
+ // casted-pointee type. If so, create a new ElementRegion with
// the pointee-cast type as the new ElementType and the index
// being the offset divded by the chunk size. If not, create
// a new ElementRegion at offset 0 off the raw offset region.
//
// (2b) If we don't a get a 'RegionRawOffset' after calling
// 'getAsRawOffset()', it means that we are at offset 0.
- //
+ //
// FIXME: Handle symbolic raw offsets.
-
+
const ElementRegion *elementR = cast<ElementRegion>(R);
const RegionRawOffset &rawOff = elementR->getAsRawOffset();
const MemRegion *baseR = rawOff.getRegion();
-
+
// If we cannot compute a raw offset, throw up our hands and return
// a NULL MemRegion*.
if (!baseR)
return CastResult(state, NULL);
-
+
int64_t off = rawOff.getByteOffset();
-
+
if (off == 0) {
// Edge case: we are at 0 bytes off the beginning of baseR. We
// check to see if type we are casting to is the same as the base
- // region. If so, just return the base region.
+ // region. If so, just return the base region.
if (const TypedRegion *TR = dyn_cast<TypedRegion>(baseR)) {
QualType ObjTy = Ctx.getCanonicalType(TR->getValueType(Ctx));
QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
if (CanonPointeeTy == ObjTy)
return CastResult(state, baseR);
}
-
+
// Otherwise, create a new ElementRegion at offset 0.
return MakeElementRegion(state, baseR, PointeeTy, CastToTy, 0);
}
-
+
// We have a non-zero offset from the base region. We want to determine
// if the offset can be evenly divided by sizeof(PointeeTy). If so,
// we create an ElementRegion whose index is that value. Otherwise, we
// create two ElementRegions, one that reflects a raw offset and the other
// that reflects the cast.
-
+
// Compute the index for the new ElementRegion.
int64_t newIndex = 0;
const MemRegion *newSuperR = 0;
@@ -179,18 +179,18 @@ StoreManager::CastRegion(const GRState *state, const MemRegion* R,
newSuperR = baseR;
}
}
-
+
if (!newSuperR) {
// Create an intermediate ElementRegion to represent the raw byte.
// This will be the super region of the final ElementRegion.
SVal idx = ValMgr.makeArrayIndex(off);
newSuperR = MRMgr.getElementRegion(Ctx.CharTy, idx, baseR, Ctx);
}
-
+
return MakeElementRegion(state, newSuperR, PointeeTy, CastToTy, newIndex);
}
}
-
+
return CastResult(state, R);
}
@@ -204,8 +204,8 @@ SValuator::CastResult StoreManager::CastRetrievedVal(SVal V,
QualType castTy) {
if (castTy.isNull())
return SValuator::CastResult(state, V);
-
- ASTContext &Ctx = ValMgr.getContext();
+
+ ASTContext &Ctx = ValMgr.getContext();
return ValMgr.getSValuator().EvalCast(V, state, castTy, R->getValueType(Ctx));
}
diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp
index d2a82fd1fc..22e1101929 100644
--- a/lib/Analysis/SymbolManager.cpp
+++ b/lib/Analysis/SymbolManager.cpp
@@ -22,7 +22,7 @@ void SymExpr::dump() const {
dumpToStream(llvm::errs());
}
-static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) {
+static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) {
switch (Op) {
default:
assert(false && "operator printing not implemented");
@@ -37,13 +37,13 @@ static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) {
case BinaryOperator::LT: os << "<" ; break;
case BinaryOperator::GT: os << '>' ; break;
case BinaryOperator::LE: os << "<=" ; break;
- case BinaryOperator::GE: os << ">=" ; break;
+ case BinaryOperator::GE: os << ">=" ; break;
case BinaryOperator::EQ: os << "==" ; break;
case BinaryOperator::NE: os << "!=" ; break;
case BinaryOperator::And: os << '&' ; break;
case BinaryOperator::Xor: os << '^' ; break;
case BinaryOperator::Or: os << '|' ; break;
- }
+ }
}
void SymIntExpr::dumpToStream(llvm::raw_ostream& os) const {
@@ -54,14 +54,14 @@ void SymIntExpr::dumpToStream(llvm::raw_ostream& os) const {
os << ' ' << getRHS().getZExtValue();
if (getRHS().isUnsigned()) os << 'U';
}
-
+
void SymSymExpr::dumpToStream(llvm::raw_ostream& os) const {
os << '(';
getLHS()->dumpToStream(os);
os << ") ";
os << '(';
getRHS()->dumpToStream(os);
- os << ')';
+ os << ')';
}
void SymbolConjured::dumpToStream(llvm::raw_ostream& os) const {
@@ -77,60 +77,60 @@ void SymbolRegionValue::dumpToStream(llvm::raw_ostream& os) const {
os << "reg_$" << getSymbolID() << "<" << R << ">";
}
-const SymbolRegionValue*
+const SymbolRegionValue*
SymbolManager::getRegionValueSymbol(const MemRegion* R, QualType T) {
llvm::FoldingSetNodeID profile;
SymbolRegionValue::Profile(profile, R, T);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
+ void* InsertPos;
+ SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
+ if (!SD) {
SD = (SymExpr*) BPAlloc.Allocate<SymbolRegionValue>();
- new (SD) SymbolRegionValue(SymbolCounter, R, T);
+ new (SD) SymbolRegionValue(SymbolCounter, R, T);
DataSet.InsertNode(SD, InsertPos);
++SymbolCounter;
}
-
+
return cast<SymbolRegionValue>(SD);
}
const SymbolConjured*
SymbolManager::getConjuredSymbol(const Stmt* E, QualType T, unsigned Count,
const void* SymbolTag) {
-
+
llvm::FoldingSetNodeID profile;
SymbolConjured::Profile(profile, E, T, Count, SymbolTag);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
+ void* InsertPos;
+ SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
+ if (!SD) {
SD = (SymExpr*) BPAlloc.Allocate<SymbolConjured>();
- new (SD) SymbolConjured(SymbolCounter, E, T, Count, SymbolTag);
- DataSet.InsertNode(SD, InsertPos);
+ new (SD) SymbolConjured(SymbolCounter, E, T, Count, SymbolTag);
+ DataSet.InsertNode(SD, InsertPos);
++SymbolCounter;
}
-
+
return cast<SymbolConjured>(SD);
}
const SymbolDerived*
SymbolManager::getDerivedSymbol(SymbolRef parentSymbol,
const TypedRegion *R) {
-
+
llvm::FoldingSetNodeID profile;
SymbolDerived::Profile(profile, parentSymbol, R);
- void* InsertPos;
- SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
- if (!SD) {
+ void* InsertPos;
+ SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
+ if (!SD) {
SD = (SymExpr*) BPAlloc.Allocate<SymbolDerived>();
new (SD) SymbolDerived(SymbolCounter, parentSymbol, R);
- DataSet.InsertNode(SD, InsertPos);
+ DataSet.InsertNode(SD, InsertPos);
++SymbolCounter;
}
-
+
return cast<SymbolDerived>(SD);
}
const SymIntExpr *SymbolManager::getSymIntExpr(const SymExpr *lhs,
- BinaryOperator::Opcode op,
+ BinaryOperator::Opcode op,
const llvm::APSInt& v,
QualType t) {
llvm::FoldingSetNodeID ID;
@@ -143,7 +143,7 @@ const SymIntExpr *SymbolManager::getSymIntExpr(const SymExpr *lhs,
new (data) SymIntExpr(lhs, op, v, t);
DataSet.InsertNode(data, InsertPos);
}
-
+
return cast<SymIntExpr>(data);
}
@@ -161,7 +161,7 @@ const SymSymExpr *SymbolManager::getSymSymExpr(const SymExpr *lhs,
new (data) SymSymExpr(lhs, op, rhs, t);
DataSet.InsertNode(data, InsertPos);
}
-
+
return cast<SymSymExpr>(data);
}
@@ -180,7 +180,7 @@ QualType SymbolRegionValue::getType(ASTContext& C) const {
if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
return TR->getValueType(C);
-
+
return QualType();
}
@@ -198,7 +198,7 @@ void SymbolReaper::markLive(SymbolRef sym) {
bool SymbolReaper::maybeDead(SymbolRef sym) {
if (isLive(sym))
return false;
-
+
TheDead.insert(sym);
return true;
}
@@ -206,7 +206,7 @@ bool SymbolReaper::maybeDead(SymbolRef sym) {
bool SymbolReaper::isLive(SymbolRef sym) {
if (TheLiving.count(sym))
return true;
-
+
if (const SymbolDerived *derived = dyn_cast<SymbolDerived>(sym)) {
if (isLive(derived->getParentSymbol())) {
markLive(sym);
@@ -214,7 +214,7 @@ bool SymbolReaper::isLive(SymbolRef sym) {
}
return false;
}
-
+
// Interogate the symbol. It may derive from an input value to
// the analyzed function/method.
return isa<SymbolRegionValue>(sym);
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 014ea8255e..8e7b15862d 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -25,21 +25,21 @@ using namespace clang;
//===----------------------------------------------------------------------===//
// Dataflow initialization logic.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN RegisterDecls
- : public CFGRecStmtDeclVisitor<RegisterDecls> {
+ : public CFGRecStmtDeclVisitor<RegisterDecls> {
UninitializedValues::AnalysisDataTy& AD;
public:
RegisterDecls(UninitializedValues::AnalysisDataTy& ad) : AD(ad) {}
-
+
void VisitVarDecl(VarDecl* VD) { AD.Register(VD); }
CFG& getCFG() { return AD.getCFG(); }
};
-
+
} // end anonymous namespace
void UninitializedValues::InitializeValues(const CFG& cfg) {
@@ -49,25 +49,25 @@ void UninitializedValues::InitializeValues(const CFG& cfg) {
//===----------------------------------------------------------------------===//
// Transfer functions.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
class VISIBILITY_HIDDEN TransferFuncs
: public CFGStmtVisitor<TransferFuncs,bool> {
-
+
UninitializedValues::ValTy V;
UninitializedValues::AnalysisDataTy& AD;
public:
TransferFuncs(UninitializedValues::AnalysisDataTy& ad) : AD(ad) {}
-
+
UninitializedValues::ValTy& getVal() { return V; }
CFG& getCFG() { return AD.getCFG(); }
-
+
void SetTopValue(UninitializedValues::ValTy& X) {
X.setDeclValues(AD);
X.resetBlkExprValues(AD);
}
-
+
bool VisitDeclRefExpr(DeclRefExpr* DR);
bool VisitBinaryOperator(BinaryOperator* B);
bool VisitUnaryOperator(UnaryOperator* U);
@@ -76,24 +76,24 @@ public:
bool VisitDeclStmt(DeclStmt* D);
bool VisitConditionalOperator(ConditionalOperator* C);
bool BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S);
-
+
bool Visit(Stmt *S);
bool BlockStmt_VisitExpr(Expr* E);
-
+
void VisitTerminator(CFGBlock* B) { }
};
-
+
static const bool Initialized = false;
-static const bool Uninitialized = true;
+static const bool Uninitialized = true;
bool TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
-
+
if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl()))
if (VD->isBlockVarDecl()) {
-
+
if (AD.Observer)
AD.Observer->ObserveDeclRefExpr(V, AD, DR, VD);
-
+
// Pseudo-hack to prevent cascade of warnings. If an accessed variable
// is uninitialized, then we are already going to flag a warning for
// this variable, which a "source" of uninitialized values.
@@ -103,17 +103,17 @@ bool TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
if (AD.FullUninitTaint)
return V(VD,AD);
}
-
+
return Initialized;
}
static VarDecl* FindBlockVarDecl(Expr* E) {
-
+
// Blast through casts and parentheses to find any DeclRefExprs that
// refer to a block VarDecl.
-
+
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
- if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl()))
+ if (VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl()))
if (VD->isBlockVarDecl()) return VD;
return NULL;
@@ -136,7 +136,7 @@ bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
for (DeclStmt::decl_iterator I=S->decl_begin(), E=S->decl_end(); I!=E; ++I) {
VarDecl *VD = dyn_cast<VarDecl>(*I);
if (VD && VD->isBlockVarDecl()) {
- if (Stmt* I = VD->getInit())
+ if (Stmt* I = VD->getInit())
V(VD,AD) = AD.FullUninitTaint ? V(cast<Expr>(I),AD) : Initialized;
else {
// Special case for declarations of array types. For things like:
@@ -145,20 +145,20 @@ bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
//
// we should treat "x" as being initialized, because the variable
// "x" really refers to the memory block. Clearly x[1] is
- // uninitialized, but expressions like "(char *) x" really do refer to
- // an initialized value. This simple dataflow analysis does not reason
+ // uninitialized, but expressions like "(char *) x" really do refer to
+ // an initialized value. This simple dataflow analysis does not reason
// about the contents of arrays, although it could be potentially
// extended to do so if the array were of constant size.
if (VD->getType()->isArrayType())
V(VD,AD) = Initialized;
- else
+ else
V(VD,AD) = Uninitialized;
}
}
}
return Uninitialized; // Value is never consumed.
}
-
+
bool TransferFuncs::VisitCallExpr(CallExpr* C) {
VisitChildren(C);
return Initialized;
@@ -172,14 +172,14 @@ bool TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
return V(VD,AD) = Initialized;
break;
}
-
+
default:
break;
}
return Visit(U->getSubExpr());
}
-
+
bool
TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
// This represents a use of the 'collection'
@@ -203,12 +203,12 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
else
return Visit(ElemExpr);
}
-
+
V(VD,AD) = Initialized;
return Initialized;
}
-
-
+
+
bool TransferFuncs::VisitConditionalOperator(ConditionalOperator* C) {
Visit(C->getCond());
@@ -228,21 +228,21 @@ bool TransferFuncs::VisitStmt(Stmt* S) {
// or "Initialized" to variables referenced in the other subexpressions.
for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I)
if (*I && Visit(*I) == Uninitialized) x = Uninitialized;
-
+
return x;
}
-
+
bool TransferFuncs::Visit(Stmt *S) {
if (AD.isTracked(static_cast<Expr*>(S))) return V(static_cast<Expr*>(S),AD);
else return static_cast<CFGStmtVisitor<TransferFuncs,bool>*>(this)->Visit(S);
}
bool TransferFuncs::BlockStmt_VisitExpr(Expr* E) {
- bool x = static_cast<CFGStmtVisitor<TransferFuncs,bool>*>(this)->Visit(E);
+ bool x = static_cast<CFGStmtVisitor<TransferFuncs,bool>*>(this)->Visit(E);
if (AD.isTracked(E)) V(E,AD) = x;
return x;
}
-
+
} // end anonymous namespace
//===----------------------------------------------------------------------===//
@@ -255,7 +255,7 @@ bool TransferFuncs::BlockStmt_VisitExpr(Expr* E) {
// Merges take the same approach, preferring soundness. At a confluence point,
// if any predecessor has a variable marked uninitialized, the value is
// uninitialized at the confluence point.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
typedef StmtDeclBitVector_Types::Union Merge;
@@ -264,28 +264,28 @@ namespace {
//===----------------------------------------------------------------------===//
// Uninitialized values checker. Scan an AST and flag variable uses
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
UninitializedValues_ValueTypes::ObserverTy::~ObserverTy() {}
namespace {
class VISIBILITY_HIDDEN UninitializedValuesChecker
: public UninitializedValues::ObserverTy {
-
+
ASTContext &Ctx;
Diagnostic &Diags;
llvm::SmallPtrSet<VarDecl*,10> AlreadyWarned;
-
+
public:
UninitializedValuesChecker(ASTContext &ctx, Diagnostic &diags)
: Ctx(ctx), Diags(diags) {}
-
+
virtual void ObserveDeclRefExpr(UninitializedValues::ValTy& V,
UninitializedValues::AnalysisDataTy& AD,
DeclRefExpr* DR, VarDecl* VD) {
assert ( AD.isTracked(VD) && "Unknown VarDecl.");
-
+
if (V(VD,AD) == Uninitialized)
if (AlreadyWarned.insert(VD))
Diags.Report(Ctx.getFullLoc(DR->getSourceRange().getBegin()),
@@ -297,13 +297,13 @@ public:
namespace clang {
void CheckUninitializedValues(CFG& cfg, ASTContext &Ctx, Diagnostic &Diags,
bool FullUninitTaint) {
-
+
// Compute the uninitialized values information.
UninitializedValues U(cfg);
U.getAnalysisData().FullUninitTaint = FullUninitTaint;
Solver S(U);
S.runOnCFG(cfg);
-
+
// Scan for DeclRefExprs that use uninitialized values.
UninitializedValuesChecker Observer(Ctx,Diags);
U.getAnalysisData().Observer = &Observer;
diff --git a/lib/Analysis/ValueManager.cpp b/lib/Analysis/ValueManager.cpp
index 44334ce34d..9fe16af6c9 100644
--- a/lib/Analysis/ValueManager.cpp
+++ b/lib/Analysis/ValueManager.cpp
@@ -28,10 +28,10 @@ SVal ValueManager::makeZeroVal(QualType T) {
if (T->isIntegerType())
return makeIntVal(0, T);
-
+
// FIXME: Handle floats.
// FIXME: Handle structs.
- return UnknownVal();
+ return UnknownVal();
}
//===----------------------------------------------------------------------===//
@@ -58,14 +58,14 @@ NonLoc ValueManager::makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
SVal ValueManager::convertToArrayIndex(SVal V) {
if (V.isUnknownOrUndef())
return V;
-
+
// Common case: we have an appropriately sized integer.
if (nonloc::ConcreteInt* CI = dyn_cast<nonloc::ConcreteInt>(&V)) {
const llvm::APSInt& I = CI->getValue();
if (I.getBitWidth() == ArrayIndexWidth && I.isSigned())
return V;
}
-
+
return SVator->EvalCastNL(cast<NonLoc>(V), ArrayIndexTy);
}
@@ -75,24 +75,24 @@ SVal ValueManager::getRegionValueSymbolVal(const MemRegion* R, QualType T) {
const TypedRegion* TR = cast<TypedRegion>(R);
T = TR->getValueType(SymMgr.getContext());
}
-
+
if (!SymbolManager::canSymbolicate(T))
return UnknownVal();
SymbolRef sym = SymMgr.getRegionValueSymbol(R, T);
-
+
if (Loc::IsLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
-
+
return nonloc::SymbolVal(sym);
}
SVal ValueManager::getConjuredSymbolVal(const Expr *E, unsigned Count) {
QualType T = E->getType();
-
+
if (!SymbolManager::canSymbolicate(T))
return UnknownVal();
-
+
SymbolRef sym = SymMgr.getConjuredSymbol(E, Count);
if (Loc::IsLocType(T))
@@ -103,7 +103,7 @@ SVal ValueManager::getConjuredSymbolVal(const Expr *E, unsigned Count) {
SVal ValueManager::getConjuredSymbolVal(const Expr *E, QualType T,
unsigned Count) {
-
+
if (!SymbolManager::canSymbolicate(T))
return UnknownVal();
@@ -122,12 +122,12 @@ SVal ValueManager::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol,
if (!SymbolManager::canSymbolicate(T))
return UnknownVal();
-
+
SymbolRef sym = SymMgr.getDerivedSymbol(parentSymbol, R);
-
+
if (Loc::IsLocType(T))
return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));
-
+
return nonloc::SymbolVal(sym);
}
diff --git a/lib/Basic/Builtins.cpp b/lib/Basic/Builtins.cpp
index 6cb5dab53d..1a3293775e 100644
--- a/lib/Basic/Builtins.cpp
+++ b/lib/Basic/Builtins.cpp
@@ -34,7 +34,7 @@ Builtin::Context::Context(const TargetInfo &Target) {
// Get the target specific builtins from the target.
TSRecords = 0;
NumTSRecords = 0;
- Target.getTargetBuiltins(TSRecords, NumTSRecords);
+ Target.getTargetBuiltins(TSRecords, NumTSRecords);
}
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
@@ -51,13 +51,13 @@ void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
// Step #2: Register target-specific builtins.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
if (!TSRecords[i].Suppressed &&
- (!NoBuiltins ||
- (TSRecords[i].Attributes &&
+ (!NoBuiltins ||
+ (TSRecords[i].Attributes &&
!strchr(TSRecords[i].Attributes, 'f'))))
Table.get(TSRecords[i].Name).setBuiltinID(i+Builtin::FirstTSBuiltin);
}
-void
+void
Builtin::Context::GetBuiltinNames(llvm::SmallVectorImpl<const char *> &Names,
bool NoBuiltins) {
// Final all target-independent names
@@ -65,18 +65,18 @@ Builtin::Context::GetBuiltinNames(llvm::SmallVectorImpl<const char *> &Names,
if (!BuiltinInfo[i].Suppressed &&
(!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f')))
Names.push_back(BuiltinInfo[i].Name);
-
+
// Find target-specific names.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
if (!TSRecords[i].Suppressed &&
- (!NoBuiltins ||
- (TSRecords[i].Attributes &&
+ (!NoBuiltins ||
+ (TSRecords[i].Attributes &&
!strchr(TSRecords[i].Attributes, 'f'))))
Names.push_back(TSRecords[i].Name);
}
-bool
-Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
+bool
+Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
bool &HasVAListArg) {
const char *Printf = strpbrk(GetRecord(ID).Attributes, "pP");
if (!Printf)
diff --git a/lib/Basic/ConvertUTF.c b/lib/Basic/ConvertUTF.c
index e5dd3e6bf5..124e386c55 100644
--- a/lib/Basic/ConvertUTF.c
+++ b/lib/Basic/ConvertUTF.c
@@ -34,10 +34,10 @@
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
Sept 2001: fixed const & error conditions per
- mods suggested by S. Parent & A. Lillich.
+ mods suggested by S. Parent & A. Lillich.
June 2002: Tim Dodd added detection and handling of incomplete
- source sequences, enhanced error detection, added casts
- to eliminate compiler warnings.
+ source sequences, enhanced error detection, added casts
+ to eliminate compiler warnings.
July 2003: slight mods to back out aggressive FFFE detection.
Jan 2004: updated switches in from-UTF8 conversions.
Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
@@ -61,8 +61,8 @@ static const UTF32 halfMask = 0x3FFUL;
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
#define UNI_SUR_LOW_START (UTF32)0xDC00
#define UNI_SUR_LOW_END (UTF32)0xDFFF
-#define false 0
-#define true 1
+#define false 0
+#define true 1
/* --------------------------------------------------------------------- */
@@ -90,7 +90,7 @@ static const char trailingBytesForUTF8[256] = {
* in a UTF-8 sequence.
*/
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
/*
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
@@ -116,46 +116,46 @@ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF32toUTF16 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
+ const UTF32** sourceStart, const UTF32* sourceEnd,
+ UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF32* source = *sourceStart;
UTF16* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch;
- if (target >= targetEnd) {
- result = targetExhausted; break;
- }
- ch = *source++;
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = (UTF16)ch; /* normal case */
- }
- } else if (ch > UNI_MAX_LEGAL_UTF32) {
- if (flags == strictConversion) {
- result = sourceIllegal;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- if (target + 1 >= targetEnd) {
- --source; /* Back up source pointer! */
- result = targetExhausted; break;
- }
- ch -= halfBase;
- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
- }
+ UTF32 ch;
+ if (target >= targetEnd) {
+ result = targetExhausted; break;
+ }
+ ch = *source++;
+ if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
+ /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ if (flags == strictConversion) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ *target++ = (UTF16)ch; /* normal case */
+ }
+ } else if (ch > UNI_MAX_LEGAL_UTF32) {
+ if (flags == strictConversion) {
+ result = sourceIllegal;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ /* target is a character in range 0xFFFF - 0x10FFFF. */
+ if (target + 1 >= targetEnd) {
+ --source; /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ ch -= halfBase;
+ *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
+ *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
+ }
}
*sourceStart = source;
*targetStart = target;
@@ -165,48 +165,48 @@ ConversionResult ConvertUTF32toUTF16 (
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF16toUTF32 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
+ const UTF16** sourceStart, const UTF16* sourceEnd,
+ UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF16* source = *sourceStart;
UTF32* target = *targetStart;
UTF32 ch, ch2;
while (source < sourceEnd) {
- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
- ch = *source++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source buffer... */
- if (source < sourceEnd) {
- ch2 = *source;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++source;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- --source; /* return to the high surrogate */
- result = sourceExhausted;
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- if (target >= targetEnd) {
- source = oldSource; /* Back up source pointer! */
- result = targetExhausted; break;
- }
- *target++ = ch;
+ const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
+ ch = *source++;
+ /* If we have a surrogate pair, convert to UTF32 first. */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
+ /* If the 16 bits following the high surrogate are in the source buffer... */
+ if (source < sourceEnd) {
+ ch2 = *source;
+ /* If it's a low surrogate, convert to UTF32. */
+ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
+ ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ + (ch2 - UNI_SUR_LOW_START) + halfBase;
+ ++source;
+ } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ } else { /* We don't have the 16 bits following the high surrogate. */
+ --source; /* return to the high surrogate */
+ result = sourceExhausted;
+ break;
+ }
+ } else if (flags == strictConversion) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ if (target >= targetEnd) {
+ source = oldSource; /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ *target++ = ch;
}
*sourceStart = source;
*targetStart = target;
@@ -219,67 +219,67 @@ if (result == sourceIllegal) {
return result;
}
ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
+ const UTF16** sourceStart, const UTF16* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF16* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
- ch = *source++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source buffer... */
- if (source < sourceEnd) {
- UTF32 ch2 = *source;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++source;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- --source; /* return to the high surrogate */
- result = sourceExhausted;
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /* Figure out how many bytes the result will require */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- source = oldSource; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
+ UTF32 ch;
+ unsigned short bytesToWrite = 0;
+ const UTF32 byteMask = 0xBF;
+ const UTF32 byteMark = 0x80;
+ const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
+ ch = *source++;
+ /* If we have a surrogate pair, convert to UTF32 first. */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
+ /* If the 16 bits following the high surrogate are in the source buffer... */
+ if (source < sourceEnd) {
+ UTF32 ch2 = *source;
+ /* If it's a low surrogate, convert to UTF32. */
+ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
+ ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ + (ch2 - UNI_SUR_LOW_START) + halfBase;
+ ++source;
+ } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ } else { /* We don't have the 16 bits following the high surrogate. */
+ --source; /* return to the high surrogate */
+ result = sourceExhausted;
+ break;
+ }
+ } else if (flags == strictConversion) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ /* Figure out how many bytes the result will require */
+ if (ch < (UTF32)0x80) { bytesToWrite = 1;
+ } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
+ } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
+ } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
+ } else { bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ source = oldSource; /* Back up source pointer! */
+ target -= bytesToWrite; result = targetExhausted; break;
+ }
+ switch (bytesToWrite) { /* note: everything falls through. */
+ case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
@@ -289,50 +289,50 @@ ConversionResult ConvertUTF16toUTF8 (
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF32toUTF8 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
+ const UTF32** sourceStart, const UTF32* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF32* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- ch = *source++;
- if (flags == strictConversion ) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /*
- * Figure out how many bytes the result will require. Turn any
- * illegally large UTF32 things (> Plane 17) into replacement chars.
- */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- result = sourceIllegal;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- --source; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
+ UTF32 ch;
+ unsigned short bytesToWrite = 0;
+ const UTF32 byteMask = 0xBF;
+ const UTF32 byteMark = 0x80;
+ ch = *source++;
+ if (flags == strictConversion ) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ /*
+ * Figure out how many bytes the result will require. Turn any
+ * illegally large UTF32 things (> Plane 17) into replacement chars.
+ */
+ if (ch < (UTF32)0x80) { bytesToWrite = 1;
+ } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
+ } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
+ } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
+ } else { bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ result = sourceIllegal;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ --source; /* Back up source pointer! */
+ target -= bytesToWrite; result = targetExhausted; break;
+ }
+ switch (bytesToWrite) { /* note: everything falls through. */
+ case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
@@ -342,59 +342,59 @@ ConversionResult ConvertUTF32toUTF8 (
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF32 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
+ const UTF8** sourceStart, const UTF8* sourceEnd,
+ UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF32* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (!isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6;
- case 4: ch += *source++; ch <<= 6;
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up the source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_LEGAL_UTF32) {
- /*
- * UTF-16 surrogate values are illegal in UTF-32, and anything
- * over Plane 17 (> 0x10FFFF) is illegal.
- */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = ch;
- }
- } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
- result = sourceIllegal;
- *target++ = UNI_REPLACEMENT_CHAR;
- }
+ UTF32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd) {
+ result = sourceExhausted; break;
+ }
+ /* Do this check whether lenient or strict */
+ if (!isLegalUTF8(source, extraBytesToRead+1)) {
+ result = sourceIllegal;
+ break;
+ }
+ /*
+ * The cases all fall through. See "Note A" below.
+ */
+ switch (extraBytesToRead) {
+ case 5: ch += *source++; ch <<= 6;
+ case 4: ch += *source++; ch <<= 6;
+ case 3: ch += *source++; ch <<= 6;
+ case 2: ch += *source++; ch <<= 6;
+ case 1: ch += *source++; ch <<= 6;
+ case 0: ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (target >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up the source pointer! */
+ result = targetExhausted; break;
+ }
+ if (ch <= UNI_MAX_LEGAL_UTF32) {
+ /*
+ * UTF-16 surrogate values are illegal in UTF-32, and anything
+ * over Plane 17 (> 0x10FFFF) is illegal.
+ */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ if (flags == strictConversion) {
+ source -= (extraBytesToRead+1); /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ *target++ = ch;
+ }
+ } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
+ result = sourceIllegal;
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
}
*sourceStart = source;
*targetStart = target;
@@ -420,19 +420,19 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
const UTF8 *srcptr = source+length;
switch (length) {
default: return false;
- /* Everything else falls through when "true"... */
+ /* Everything else falls through when "true"... */
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 2: if ((a = (*--srcptr)) > 0xBF) return false;
- switch (*source) {
- /* no fall-through in this inner switch */
- case 0xE0: if (a < 0xA0) return false; break;
- case 0xED: if (a > 0x9F) return false; break;
- case 0xF0: if (a < 0x90) return false; break;
- case 0xF4: if (a > 0x8F) return false; break;
- default: if (a < 0x80) return false;
- }
+ switch (*source) {
+ /* no fall-through in this inner switch */
+ case 0xE0: if (a < 0xA0) return false; break;
+ case 0xED: if (a > 0x9F) return false; break;
+ case 0xF0: if (a < 0x90) return false; break;
+ case 0xF4: if (a > 0x8F) return false; break;
+ default: if (a < 0x80) return false;
+ }
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
}
@@ -449,7 +449,7 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
int length = trailingBytesForUTF8[*source]+1;
if (source+length > sourceEnd) {
- return false;
+ return false;
}
return isLegalUTF8(source, length);
}
@@ -457,70 +457,70 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
+ const UTF8** sourceStart, const UTF8* sourceEnd,
+ UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF16* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (!isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = (UTF16)ch; /* normal case */
- }
- } else if (ch > UNI_MAX_UTF16) {
- if (flags == strictConversion) {
- result = sourceIllegal;
- source -= (extraBytesToRead+1); /* return to the start */
- break; /* Bail out; shouldn't continue */
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- if (target + 1 >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- ch -= halfBase;
- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
- }
+ UTF32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd) {
+ result = sourceExhausted; break;
+ }
+ /* Do this check whether lenient or strict */
+ if (!isLegalUTF8(source, extraBytesToRead+1)) {
+ result = sourceIllegal;
+ break;
+ }
+ /*
+ * The cases all fall through. See "Note A" below.
+ */
+ switch (extraBytesToRead) {
+ case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 3: ch += *source++; ch <<= 6;
+ case 2: ch += *source++; ch <<= 6;
+ case 1: ch += *source++; ch <<= 6;
+ case 0: ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (target >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ if (flags == strictConversion) {
+ source -= (extraBytesToRead+1); /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ *target++ = (UTF16)ch; /* normal case */
+ }
+ } else if (ch > UNI_MAX_UTF16) {
+ if (flags == strictConversion) {
+ result = sourceIllegal;
+ source -= (extraBytesToRead+1); /* return to the start */
+ break; /* Bail out; shouldn't continue */
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ /* target is a character in range 0xFFFF - 0x10FFFF. */
+ if (target + 1 >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ ch -= halfBase;
+ *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
+ *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
+ }
}
*sourceStart = source;
*targetStart = target;
@@ -533,14 +533,14 @@ ConversionResult ConvertUTF8toUTF16 (
The fall-through switches in UTF-8 reading code save a
temp variable, some decrements & conditionals. The switches
are equivalent to the following loop:
- {
- int tmpBytesToRead = extraBytesToRead+1;
- do {
- ch += *source++;
- --tmpBytesToRead;
- if (tmpBytesToRead) ch <<= 6;
- } while (tmpBytesToRead > 0);
- }
+ {
+ int tmpBytesToRead = extraBytesToRead+1;
+ do {
+ ch += *source++;
+ --tmpBytesToRead;
+ if (tmpBytesToRead) ch <<= 6;
+ } while (tmpBytesToRead > 0);
+ }
In UTF-8 writing code, the switches on "bytesToWrite" are
similarly unrolled loops.
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 922702fdf5..81d19cc826 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -49,7 +49,7 @@ struct StaticDiagInfoRec {
bool SFINAE : 1;
const char *Description;
const char *OptionGroup;
-
+
bool operator<(const StaticDiagInfoRec &RHS) const {
return DiagID < RHS.DiagID;
}
@@ -88,16 +88,16 @@ static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
IsFirst = false;
}
#endif
-
+
// Search the diagnostic table with a binary search.
StaticDiagInfoRec Find = { DiagID, 0, 0, 0, 0, 0 };
-
+
const StaticDiagInfoRec *Found =
std::lower_bound(StaticDiagInfo, StaticDiagInfo + NumDiagEntries, Find);
if (Found == StaticDiagInfo + NumDiagEntries ||
Found->DiagID != DiagID)
return 0;
-
+
return Found;
}
@@ -141,7 +141,7 @@ namespace clang {
std::vector<DiagDesc> DiagInfo;
std::map<DiagDesc, unsigned> DiagIDs;
public:
-
+
/// getDescription - Return the description of the specified custom
/// diagnostic.
const char *getDescription(unsigned DiagID) const {
@@ -149,14 +149,14 @@ namespace clang {
"Invalid diagnosic ID");
return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second.c_str();
}
-
+
/// getLevel - Return the level of the specified custom diagnostic.
Diagnostic::Level getLevel(unsigned DiagID) const {
assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
"Invalid diagnosic ID");
return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first;
}
-
+
unsigned getOrCreateDiagID(Diagnostic::Level L, const char *Message,
Diagnostic &Diags) {
DiagDesc D(L, Message);
@@ -164,7 +164,7 @@ namespace clang {
std::map<DiagDesc, unsigned>::iterator I = DiagIDs.lower_bound(D);
if (I != DiagIDs.end() && I->first == D)
return I->second;
-
+
// If not, assign a new ID.
unsigned ID = DiagInfo.size()+DIAG_UPPER_LIMIT;
DiagIDs.insert(std::make_pair(D, ID));
@@ -172,9 +172,9 @@ namespace clang {
return ID;
}
};
-
- } // end diag namespace
-} // end clang namespace
+
+ } // end diag namespace
+} // end clang namespace
//===----------------------------------------------------------------------===//
@@ -197,7 +197,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
WarningsAsErrors = false;
SuppressSystemWarnings = false;
ExtBehavior = Ext_Ignore;
-
+
ErrorOccurred = false;
FatalErrorOccurred = false;
NumDiagnostics = 0;
@@ -206,10 +206,10 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
CustomDiagInfo = 0;
CurDiagID = ~0U;
LastDiagLevel = Ignored;
-
+
ArgToStringFn = DummyArgToStringFn;
ArgToStringCookie = 0;
-
+
// Set all mappings to 'unset'.
DiagMappings BlankDiags(diag::DIAG_UPPER_LIMIT/2, 0);
DiagMappingsStack.push_back(BlankDiags);
@@ -236,7 +236,7 @@ bool Diagnostic::popMappings() {
/// and level. If this is the first request for this diagnosic, it is
/// registered and created, otherwise the existing ID is returned.
unsigned Diagnostic::getCustomDiagID(Level L, const char *Message) {
- if (CustomDiagInfo == 0)
+ if (CustomDiagInfo == 0)
CustomDiagInfo = new diag::CustomDiagInfo();
return CustomDiagInfo->getOrCreateDiagID(L, Message, *this);
}
@@ -282,7 +282,7 @@ Diagnostic::Level Diagnostic::getDiagnosticLevel(unsigned DiagID) const {
// Handle custom diagnostics, which cannot be mapped.
if (DiagID >= diag::DIAG_UPPER_LIMIT)
return CustomDiagInfo->getLevel(DiagID);
-
+
unsigned DiagClass = getBuiltinDiagClass(DiagID);
assert(DiagClass != CLASS_NOTE && "Cannot get diagnostic level of a note!");
return getDiagnosticLevel(DiagID, DiagClass);
@@ -296,14 +296,14 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const {
// Specific non-error diagnostics may be mapped to various levels from ignored
// to error. Errors can only be mapped to fatal.
Diagnostic::Level Result = Diagnostic::Fatal;
-
+
// Get the mapping information, if unset, compute it lazily.
unsigned MappingInfo = getDiagnosticMappingInfo((diag::kind)DiagID);
if (MappingInfo == 0) {
MappingInfo = GetDefaultDiagMapping(DiagID);
setDiagnosticMappingInternal(DiagID, MappingInfo, false);
}
-
+
switch (MappingInfo & 7) {
default: assert(0 && "Unknown mapping!");
case diag::MAP_IGNORE:
@@ -326,29 +326,29 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const {
// If warnings are globally mapped to ignore or error, do it.
if (IgnoreAllWarnings)
return Diagnostic::Ignored;
-
+
Result = Diagnostic::Warning;
-
+
// If this is an extension diagnostic and we're in -pedantic-error mode, and
// if the user didn't explicitly map it, upgrade to an error.
if (ExtBehavior == Ext_Error &&
(MappingInfo & 8) == 0 &&
isBuiltinExtensionDiag(DiagID))
Result = Diagnostic::Error;
-
+
if (WarningsAsErrors)
Result = Diagnostic::Error;
break;
-
+
case diag::MAP_WARNING_NO_WERROR:
// Diagnostics specified with -Wno-error=foo should be set to warnings, but
// not be adjusted by -Werror or -pedantic-errors.
Result = Diagnostic::Warning;
-
+
// If warnings are globally mapped to ignore or error, do it.
if (IgnoreAllWarnings)
return Diagnostic::Ignored;
-
+
break;
}
@@ -357,7 +357,7 @@ Diagnostic::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass) const {
// block, silence it.
if (AllExtensionsSilenced && isBuiltinExtensionDiag(DiagID))
return Diagnostic::Ignored;
-
+
return Result;
}
@@ -392,7 +392,7 @@ static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping,
for (; *Member != -1; ++Member)
Diags.setDiagnosticMapping(*Member, Mapping);
}
-
+
// Enable/disable all subgroups along with this one.
if (const char *SubGroups = Group->SubGroups) {
for (; *SubGroups != (char)-1; ++SubGroups)
@@ -405,7 +405,7 @@ static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping,
/// ignores the request if "Group" was unknown, false otherwise.
bool Diagnostic::setDiagnosticGroupMapping(const char *Group,
diag::Mapping Map) {
-
+
WarningOption Key = { Group, 0, 0 };
const WarningOption *Found =
std::lower_bound(OptionTable, OptionTable + OptionTableSize, Key,
@@ -413,7 +413,7 @@ bool Diagnostic::setDiagnosticGroupMapping(const char *Group,
if (Found == OptionTable + OptionTableSize ||
strcmp(Found->Name, Group) != 0)
return true; // Option not found.
-
+
MapGroupMembers(Found, Map, *this);
return false;
}
@@ -423,19 +423,19 @@ bool Diagnostic::setDiagnosticGroupMapping(const char *Group,
/// finally fully formed.
bool Diagnostic::ProcessDiag() {
DiagnosticInfo Info(this);
-
+
// Figure out the diagnostic level of this message.
Diagnostic::Level DiagLevel;
unsigned DiagID = Info.getID();
-
+
// ShouldEmitInSystemHeader - True if this diagnostic should be produced even
// in a system header.
bool ShouldEmitInSystemHeader;
-
+
if (DiagID >= diag::DIAG_UPPER_LIMIT) {
// Handle custom diagnostics, which cannot be mapped.
DiagLevel = CustomDiagInfo->getLevel(DiagID);
-
+
// Custom diagnostics always are emitted in system headers.
ShouldEmitInSystemHeader = true;
} else {
@@ -447,12 +447,12 @@ bool Diagnostic::ProcessDiag() {
DiagLevel = Diagnostic::Note;
ShouldEmitInSystemHeader = false; // extra consideration is needed
} else {
- // If this is not an error and we are in a system header, we ignore it.
+ // If this is not an error and we are in a system header, we ignore it.
// Check the original Diag ID here, because we also want to ignore
// extensions and warnings in -Werror and -pedantic-errors modes, which
// *map* warnings/extensions to errors.
ShouldEmitInSystemHeader = DiagClass == CLASS_ERROR;
-
+
DiagLevel = getDiagnosticLevel(DiagID, DiagClass);
}
}
@@ -466,7 +466,7 @@ bool Diagnostic::ProcessDiag() {
FatalErrorOccurred = true;
LastDiagLevel = DiagLevel;
- }
+ }
// If a fatal error has already been emitted, silence all subsequent
// diagnostics.
@@ -493,7 +493,7 @@ bool Diagnostic::ProcessDiag() {
ErrorOccurred = true;
++NumErrors;
}
-
+
// Finally, report it.
Client->HandleDiagnostic(DiagLevel, Info);
if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
@@ -523,7 +523,7 @@ static void HandleSelectModifier(unsigned ValNo,
const char *Argument, unsigned ArgumentLen,
llvm::SmallVectorImpl<char> &OutStr) {
const char *ArgumentEnd = Argument+ArgumentLen;
-
+
// Skip over 'ValNo' |'s.
while (ValNo) {
const char *NextVal = std::find(Argument, ArgumentEnd, '|');
@@ -532,7 +532,7 @@ static void HandleSelectModifier(unsigned ValNo,
Argument = NextVal+1; // Skip this string.
--ValNo;
}
-
+
// Get the end of the value. This is either the } or the |.
const char *EndPtr = std::find(Argument, ArgumentEnd, '|');
// Add the value to the output string.
@@ -605,7 +605,7 @@ static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End) {
// Scan for next or-expr part.
Start = std::find(Start, End, ',');
- if(Start == End)
+ if (Start == End)
break;
++Start;
}
@@ -674,7 +674,7 @@ void DiagnosticInfo::
FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
const char *DiagStr = getDiags()->getDescription(getID());
const char *DiagEnd = DiagStr+strlen(DiagStr);
-
+
while (DiagStr != DiagEnd) {
if (DiagStr[0] != '%') {
// Append non-%0 substrings to Str if we have one.
@@ -687,10 +687,10 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
DiagStr += 2;
continue;
}
-
+
// Skip the %.
++DiagStr;
-
+
// This must be a placeholder for a diagnostic argument. The format for a
// placeholder is one of "%0", "%modifier0", or "%modifier{arguments}0".
// The digit is a number from 0-9 indicating which argument this comes from.
@@ -698,7 +698,7 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
// brace enclosed string.
const char *Modifier = 0, *Argument = 0;
unsigned ModifierLen = 0, ArgumentLen = 0;
-
+
// Check to see if we have a modifier. If so eat it.
if (!isdigit(DiagStr[0])) {
Modifier = DiagStr;
@@ -711,14 +711,14 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
if (DiagStr[0] == '{') {
++DiagStr; // Skip {.
Argument = DiagStr;
-
+
for (; DiagStr[0] != '}'; ++DiagStr)
assert(DiagStr[0] && "Mismatched {}'s in diagnostic string!");
ArgumentLen = DiagStr-Argument;
++DiagStr; // Skip }.
}
}
-
+
assert(isdigit(*DiagStr) && "Invalid format for argument in diagnostic");
unsigned ArgNo = *DiagStr++ - '0';
@@ -737,14 +737,14 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
// Don't crash if get passed a null pointer by accident.
if (!S)
S = "(null)";
-
+
OutStr.append(S, S + strlen(S));
break;
}
// ---- INTEGERS ----
case Diagnostic::ak_sint: {
int Val = getArgSInt(ArgNo);
-
+
if (ModifierIs(Modifier, ModifierLen, "select")) {
HandleSelectModifier((unsigned)Val, Argument, ArgumentLen, OutStr);
} else if (ModifierIs(Modifier, ModifierLen, "s")) {
@@ -761,7 +761,7 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
}
case Diagnostic::ak_uint: {
unsigned Val = getArgUInt(ArgNo);
-
+
if (ModifierIs(Modifier, ModifierLen, "select")) {
HandleSelectModifier(Val, Argument, ArgumentLen, OutStr);
} else if (ModifierIs(Modifier, ModifierLen, "s")) {
@@ -770,7 +770,7 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
HandlePluralModifier((unsigned)Val, Argument, ArgumentLen, OutStr);
} else {
assert(ModifierLen == 0 && "Unknown integer modifier");
-
+
// FIXME: Optimize
std::string S = llvm::utostr_32(Val);
OutStr.append(S.begin(), S.end());
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index aadafa5584..e0a7e65756 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -47,8 +47,7 @@ using namespace clang;
#define IS_DIR_SEPARATOR_CHAR(x) ((x) == '/' || (x) == '\\')
namespace {
- static std::string GetFullPath(const char *relPath)
- {
+ static std::string GetFullPath(const char *relPath) {
char *absPathStrPtr = _fullpath(NULL, relPath, 0);
assert(absPathStrPtr && "_fullpath() returned NULL!");
@@ -62,7 +61,7 @@ namespace {
class FileManager::UniqueDirContainer {
/// UniqueDirs - Cache from full path to existing directories/files.
///
- llvm::StringMap<DirectoryEntry> UniqueDirs;
+ llvm::StringMap<DirectoryEntry> UniqueDirs;
public:
DirectoryEntry &getDirectory(const char *Name, struct stat &StatBuf) {
@@ -72,7 +71,7 @@ public:
FullPath.c_str() + FullPath.size()
).getValue();
}
-
+
size_t size() { return UniqueDirs.size(); }
};
@@ -104,7 +103,7 @@ public:
class FileManager::UniqueDirContainer {
/// UniqueDirs - Cache from ID's to existing directories/files.
///
- std::map<std::pair<dev_t, ino_t>, DirectoryEntry> UniqueDirs;
+ std::map<std::pair<dev_t, ino_t>, DirectoryEntry> UniqueDirs;
public:
DirectoryEntry &getDirectory(const char *Name, struct stat &StatBuf) {
@@ -152,27 +151,27 @@ FileManager::~FileManager() {
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
-///
+///
const DirectoryEntry *FileManager::getDirectory(const char *NameStart,
const char *NameEnd) {
++NumDirLookups;
llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
DirEntries.GetOrCreateValue(NameStart, NameEnd);
-
+
// See if there is already an entry in the map.
if (NamedDirEnt.getValue())
return NamedDirEnt.getValue() == NON_EXISTENT_DIR
? 0 : NamedDirEnt.getValue();
-
+
++NumDirCacheMisses;
-
+
// By default, initialize it to invalid.
NamedDirEnt.setValue(NON_EXISTENT_DIR);
-
+
// Get the null-terminated directory name as stored as the key of the
// DirEntries map.
const char *InterndDirName = NamedDirEnt.getKeyData();
-
+
// Check to see if the directory exists.
struct stat StatBuf;
if (stat_cached(InterndDirName, &StatBuf) || // Error stat'ing.
@@ -180,13 +179,13 @@ const DirectoryEntry *FileManager::getDirectory(const char *NameStart,
return 0;
// It exists. See if we have already opened a directory with the same inode.
- // This occurs when one dir is symlinked to another, for example.
+ // This occurs when one dir is symlinked to another, for example.
DirectoryEntry &UDE = UniqueDirs.getDirectory(InterndDirName, StatBuf);
-
+
NamedDirEnt.setValue(&UDE);
if (UDE.getName()) // Already have an entry with this inode, return it.
return &UDE;
-
+
// Otherwise, we don't have this directory yet, add it. We use the string
// key from the DirEntries map as the string.
UDE.Name = InterndDirName;
@@ -199,11 +198,11 @@ const DirectoryEntry *FileManager::getDirectory(const char *NameStart,
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
-///
+///
const FileEntry *FileManager::getFile(const char *NameStart,
const char *NameEnd) {
++NumFileLookups;
-
+
// See if there is already an entry in the map.
llvm::StringMapEntry<FileEntry *> &NamedFileEnt =
FileEntries.GetOrCreateValue(NameStart, NameEnd);
@@ -212,7 +211,7 @@ const FileEntry *FileManager::getFile(const char *NameStart,
if (NamedFileEnt.getValue())
return NamedFileEnt.getValue() == NON_EXISTENT_FILE
? 0 : NamedFileEnt.getValue();
-
+
++NumFileCacheMisses;
// By default, initialize it to invalid.
@@ -227,7 +226,7 @@ const FileEntry *FileManager::getFile(const char *NameStart,
// Ignore duplicate //'s.
while (SlashPos > NameStart && IS_DIR_SEPARATOR_CHAR(SlashPos[-1]))
--SlashPos;
-
+
const DirectoryEntry *DirInfo;
if (SlashPos < NameStart) {
// Use the current directory if file has no path component.
@@ -237,17 +236,17 @@ const FileEntry *FileManager::getFile(const char *NameStart,
return 0; // If filename ends with a /, it's a directory.
else
DirInfo = getDirectory(NameStart, SlashPos);
-
+
if (DirInfo == 0) // Directory doesn't exist, file can't exist.
return 0;
-
+
// Get the null-terminated file name as stored as the key of the
// FileEntries map.
const char *InterndFileName = NamedFileEnt.getKeyData();
-
+
// FIXME: Use the directory info to prune this, before doing the stat syscall.
// FIXME: This will reduce the # syscalls.
-
+
// Nope, there isn't. Check to see if the file exists.
struct stat StatBuf;
//llvm::errs() << "STATING: " << Filename;
@@ -258,11 +257,11 @@ const FileEntry *FileManager::getFile(const char *NameStart,
return 0;
}
//llvm::errs() << ": exists\n";
-
+
// It exists. See if we have already opened a file with the same inode.
// This occurs when one dir is symlinked to another, for example.
FileEntry &UFE = UniqueFiles.getFile(InterndFileName, StatBuf);
-
+
NamedFileEnt.setValue(&UFE);
if (UFE.getName()) // Already have an entry with this inode, return it.
return &UFE;
@@ -286,14 +285,14 @@ void FileManager::PrintStats() const {
<< NumDirCacheMisses << " dir cache misses.\n";
llvm::errs() << NumFileLookups << " file lookups, "
<< NumFileCacheMisses << " file cache misses.\n";
-
+
//llvm::errs() << PagesMapped << BytesOfPagesMapped << FSLookups;
}
int MemorizeStatCalls::stat(const char *path, struct stat *buf) {
int result = ::stat(path, buf);
-
- if (result != 0) {
+
+ if (result != 0) {
// Cache failed 'stat' results.
struct stat empty;
StatCalls[path] = StatResult(result, empty);
@@ -303,6 +302,6 @@ int MemorizeStatCalls::stat(const char *path, struct stat *buf) {
// paths.
StatCalls[path] = StatResult(result, *buf);
}
-
- return result;
+
+ return result;
}
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index 3810c49f71..93c260fdbe 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -109,9 +109,9 @@ static void AddCXXOperatorKeyword(const char *Keyword, unsigned KWLen,
Info.setIsCPlusPlusOperatorKeyword();
}
-/// AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or
+/// AddObjCKeyword - Register an Objective-C @keyword like "class" "selector" or
/// "property".
-static void AddObjCKeyword(tok::ObjCKeywordKind ObjCID,
+static void AddObjCKeyword(tok::ObjCKeywordKind ObjCID,
const char *Name, unsigned NameLen,
IdentifierTable &Table) {
Table.get(Name, Name+NameLen).setObjCKeywordID(ObjCID);
@@ -144,13 +144,13 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
// the first and third character. For preprocessor ID's there are no
// collisions (if there were, the switch below would complain about duplicate
// case values). Note that this depends on 'if' being null terminated.
-
+
#define HASH(LEN, FIRST, THIRD) \
(LEN << 5) + (((FIRST-'a') + (THIRD-'a')) & 31)
#define CASE(LEN, FIRST, THIRD, NAME) \
case HASH(LEN, FIRST, THIRD): \
return memcmp(Name, #NAME, LEN) ? tok::pp_not_keyword : tok::pp_ ## NAME
-
+
unsigned Len = getLength();
if (Len < 2) return tok::pp_not_keyword;
const char *Name = getName();
@@ -179,7 +179,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
CASE( 8, 'u', 'a', unassert);
CASE(12, 'i', 'c', include_next);
-
+
CASE(16, '_', 'i', __include_macros);
#undef CASE
#undef HASH
@@ -198,7 +198,7 @@ void IdentifierTable::PrintStats() const {
unsigned NumEmptyBuckets = NumBuckets-NumIdentifiers;
unsigned AverageIdentifierSize = 0;
unsigned MaxIdentifierLength = 0;
-
+
// TODO: Figure out maximum times an identifier had to probe for -stats.
for (llvm::StringMap<IdentifierInfo*, llvm::BumpPtrAllocator>::const_iterator
I = HashTable.begin(), E = HashTable.end(); I != E; ++I) {
@@ -207,7 +207,7 @@ void IdentifierTable::PrintStats() const {
if (MaxIdentifierLength < IdLen)
MaxIdentifierLength = IdLen;
}
-
+
fprintf(stderr, "\n*** Identifier Table Stats:\n");
fprintf(stderr, "# Identifiers: %d\n", NumIdentifiers);
fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets);
@@ -216,7 +216,7 @@ void IdentifierTable::PrintStats() const {
fprintf(stderr, "Ave identifier length: %f\n",
(AverageIdentifierSize/(double)NumIdentifiers));
fprintf(stderr, "Max identifier length: %d\n", MaxIdentifierLength);
-
+
// Compute statistics about the memory allocated for identifiers.
HashTable.getAllocator().PrintStats();
}
@@ -232,42 +232,42 @@ unsigned llvm::DenseMapInfo<clang::Selector>::getHashValue(clang::Selector S) {
namespace clang {
/// MultiKeywordSelector - One of these variable length records is kept for each
/// selector containing more than one keyword. We use a folding set
-/// to unique aggregate names (keyword selectors in ObjC parlance). Access to
+/// to unique aggregate names (keyword selectors in ObjC parlance). Access to
/// this class is provided strictly through Selector.
-class MultiKeywordSelector
+class MultiKeywordSelector
: public DeclarationNameExtra, public llvm::FoldingSetNode {
MultiKeywordSelector(unsigned nKeys) {
ExtraKindOrNumArgs = NUM_EXTRA_KINDS + nKeys;
}
-public:
+public:
// Constructor for keyword selectors.
MultiKeywordSelector(unsigned nKeys, IdentifierInfo **IIV) {
assert((nKeys > 1) && "not a multi-keyword selector");
ExtraKindOrNumArgs = NUM_EXTRA_KINDS + nKeys;
-
+
// Fill in the trailing keyword array.
IdentifierInfo **KeyInfo = reinterpret_cast<IdentifierInfo **>(this+1);
for (unsigned i = 0; i != nKeys; ++i)
KeyInfo[i] = IIV[i];
- }
-
+ }
+
// getName - Derive the full selector name and return it.
std::string getName() const;
-
+
unsigned getNumArgs() const { return ExtraKindOrNumArgs - NUM_EXTRA_KINDS; }
-
+
typedef IdentifierInfo *const *keyword_iterator;
keyword_iterator keyword_begin() const {
return reinterpret_cast<keyword_iterator>(this+1);
}
- keyword_iterator keyword_end() const {
- return keyword_begin()+getNumArgs();
+ keyword_iterator keyword_end() const {
+ return keyword_begin()+getNumArgs();
}
IdentifierInfo *getIdentifierInfoForSlot(unsigned i) const {
assert(i < getNumArgs() && "getIdentifierInfoForSlot(): illegal index");
return keyword_begin()[i];
}
- static void Profile(llvm::FoldingSetNodeID &ID,
+ static void Profile(llvm::FoldingSetNodeID &ID,
keyword_iterator ArgTys, unsigned NumArgs) {
ID.AddInteger(NumArgs);
for (unsigned i = 0; i != NumArgs; ++i)
@@ -287,7 +287,7 @@ unsigned Selector::getNumArgs() const {
return 1;
// We point to a MultiKeywordSelector (pointer doesn't contain any flags).
MultiKeywordSelector *SI = reinterpret_cast<MultiKeywordSelector *>(InfoPtr);
- return SI->getNumArgs();
+ return SI->getNumArgs();
}
IdentifierInfo *Selector::getIdentifierInfoForSlot(unsigned argIndex) const {
@@ -308,16 +308,16 @@ std::string MultiKeywordSelector::getName() const {
Length += (*I)->getLength();
++Length; // :
}
-
+
Result.reserve(Length);
-
+
for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) {
if (*I)
Result.insert(Result.end(), (*I)->getName(),
(*I)->getName()+(*I)->getLength());
Result.push_back(':');
}
-
+
return Result;
}
@@ -327,7 +327,7 @@ std::string Selector::getAsString() const {
if (InfoPtr & ArgFlags) {
IdentifierInfo *II = getAsIdentifierInfo();
-
+
// If the number of arguments is 0 then II is guaranteed to not be null.
if (getNumArgs() == 0)
return II->getName();
@@ -336,7 +336,7 @@ std::string Selector::getAsString() const {
Res += ":";
return Res;
}
-
+
// We have a multiple keyword selector (no embedded flags).
return reinterpret_cast<MultiKeywordSelector *>(InfoPtr)->getName();
}
@@ -357,9 +357,9 @@ static SelectorTableImpl &getSelectorTableImpl(void *P) {
Selector SelectorTable::getSelector(unsigned nKeys, IdentifierInfo **IIV) {
if (nKeys < 2)
return Selector(IIV[0], nKeys);
-
+
SelectorTableImpl &SelTabImpl = getSelectorTableImpl(Impl);
-
+
// Unique selector, to guarantee there is one per name.
llvm::FoldingSetNodeID ID;
MultiKeywordSelector::Profile(ID, IIV, nKeys);
@@ -368,12 +368,12 @@ Selector SelectorTable::getSelector(unsigned nKeys, IdentifierInfo **IIV) {
if (MultiKeywordSelector *SI =
SelTabImpl.Table.FindNodeOrInsertPos(ID, InsertPos))
return Selector(SI);
-
+
// MultiKeywordSelector objects are not allocated with new because they have a
// variable size array (for parameter types) at the end of them.
unsigned Size = sizeof(MultiKeywordSelector) + nKeys*sizeof(IdentifierInfo *);
MultiKeywordSelector *SI =
- (MultiKeywordSelector*)SelTabImpl.Allocator.Allocate(Size,
+ (MultiKeywordSelector*)SelTabImpl.Allocator.Allocate(Size,
llvm::alignof<MultiKeywordSelector>());
new (SI) MultiKeywordSelector(nKeys, IIV);
SelTabImpl.Table.InsertNode(SI, InsertPos);
diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp
index f21ec8b1e9..578a4eb34b 100644
--- a/lib/Basic/SourceLocation.cpp
+++ b/lib/Basic/SourceLocation.cpp
@@ -40,7 +40,7 @@ void SourceLocation::print(llvm::raw_ostream &OS, const SourceManager &SM)const{
OS << "<invalid loc>";
return;
}
-
+
if (isFileID()) {
PresumedLoc PLoc = SM.getPresumedLoc(*this);
// The instantiation and spelling pos is identical for file locs.
@@ -48,7 +48,7 @@ void SourceLocation::print(llvm::raw_ostream &OS, const SourceManager &SM)const{
<< ':' << PLoc.getColumn();
return;
}
-
+
SM.getInstantiationLoc(*this).print(OS, SM);
OS << " <Spelling=";
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index fa1dc4ed58..d1c47095a2 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -46,7 +46,7 @@ unsigned ContentCache::getSize() const {
return Entry ? Entry->getSize() : Buffer->getBufferSize();
}
-const llvm::MemoryBuffer *ContentCache::getBuffer() const {
+const llvm::MemoryBuffer *ContentCache::getBuffer() const {
// Lazily create the Buffer for ContentCaches that wrap files.
if (!Buffer && Entry) {
// FIXME: Should we support a way to not have to do this check over
@@ -59,11 +59,11 @@ const llvm::MemoryBuffer *ContentCache::getBuffer() const {
unsigned LineTableInfo::getLineTableFilenameID(const char *Ptr, unsigned Len) {
// Look up the filename in the string table, returning the pre-existing value
// if it exists.
- llvm::StringMapEntry<unsigned> &Entry =
+ llvm::StringMapEntry<unsigned> &Entry =
FilenameIDs.GetOrCreateValue(Ptr, Ptr+Len, ~0U);
if (Entry.getValue() != ~0U)
return Entry.getValue();
-
+
// Otherwise, assign this the next available ID.
Entry.setValue(FilenamesByID.size());
FilenamesByID.push_back(&Entry);
@@ -76,25 +76,25 @@ unsigned LineTableInfo::getLineTableFilenameID(const char *Ptr, unsigned Len) {
void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
unsigned LineNo, int FilenameID) {
std::vector<LineEntry> &Entries = LineEntries[FID];
-
+
assert((Entries.empty() || Entries.back().FileOffset < Offset) &&
"Adding line entries out of order!");
-
+
SrcMgr::CharacteristicKind Kind = SrcMgr::C_User;
unsigned IncludeOffset = 0;
-
+
if (!Entries.empty()) {
// If this is a '#line 4' after '#line 42 "foo.h"', make sure to remember
// that we are still in "foo.h".
if (FilenameID == -1)
FilenameID = Entries.back().FilenameID;
-
+
// If we are after a line marker that switched us to system header mode, or
// that set #include information, preserve it.
Kind = Entries.back().FileKind;
IncludeOffset = Entries.back().IncludeOffset;
}
-
+
Entries.push_back(LineEntry::get(Offset, LineNo, FilenameID, Kind,
IncludeOffset));
}
@@ -109,9 +109,9 @@ void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
unsigned EntryExit,
SrcMgr::CharacteristicKind FileKind) {
assert(FilenameID != -1 && "Unspecified filename should use other accessor");
-
+
std::vector<LineEntry> &Entries = LineEntries[FID];
-
+
assert((Entries.empty() || Entries.back().FileOffset < Offset) &&
"Adding line entries out of order!");
@@ -123,14 +123,14 @@ void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
} else if (EntryExit == 2) {
assert(!Entries.empty() && Entries.back().IncludeOffset &&
"PPDirectives should have caught case when popping empty include stack");
-
+
// Get the include loc of the last entries' include loc as our include loc.
IncludeOffset = 0;
if (const LineEntry *PrevEntry =
FindNearestLineEntry(FID, Entries.back().IncludeOffset))
IncludeOffset = PrevEntry->IncludeOffset;
}
-
+
Entries.push_back(LineEntry::get(Offset, LineNo, FilenameID, FileKind,
IncludeOffset));
}
@@ -138,7 +138,7 @@ void LineTableInfo::AddLineNote(unsigned FID, unsigned Offset,
/// FindNearestLineEntry - Find the line entry nearest to FID that is before
/// it. If there is no line entry before Offset in FID, return null.
-const LineEntry *LineTableInfo::FindNearestLineEntry(unsigned FID,
+const LineEntry *LineTableInfo::FindNearestLineEntry(unsigned FID,
unsigned Offset) {
const std::vector<LineEntry> &Entries = LineEntries[FID];
assert(!Entries.empty() && "No #line entries for this FID after all!");
@@ -157,13 +157,13 @@ const LineEntry *LineTableInfo::FindNearestLineEntry(unsigned FID,
/// \brief Add a new line entry that has already been encoded into
/// the internal representation of the line table.
-void LineTableInfo::AddEntry(unsigned FID,
+void LineTableInfo::AddEntry(unsigned FID,
const std::vector<LineEntry> &Entries) {
LineEntries[FID] = Entries;
}
/// getLineTableFilenameID - Return the uniqued ID for the specified filename.
-///
+///
unsigned SourceManager::getLineTableFilenameID(const char *Ptr, unsigned Len) {
if (LineTable == 0)
LineTable = new LineTableInfo();
@@ -177,12 +177,12 @@ unsigned SourceManager::getLineTableFilenameID(const char *Ptr, unsigned Len) {
void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
int FilenameID) {
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
-
+
const SrcMgr::FileInfo &FileInfo = getSLocEntry(LocInfo.first).getFile();
// Remember that this file has #line directives now if it doesn't already.
const_cast<SrcMgr::FileInfo&>(FileInfo).setHasLineDirectives();
-
+
if (LineTable == 0)
LineTable = new LineTableInfo();
LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID);
@@ -200,16 +200,16 @@ void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
"Can't set flags without setting the filename!");
return AddLineNote(Loc, LineNo, FilenameID);
}
-
+
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
const SrcMgr::FileInfo &FileInfo = getSLocEntry(LocInfo.first).getFile();
-
+
// Remember that this file has #line directives now if it doesn't already.
const_cast<SrcMgr::FileInfo&>(FileInfo).setHasLineDirectives();
-
+
if (LineTable == 0)
LineTable = new LineTableInfo();
-
+
SrcMgr::CharacteristicKind FileKind;
if (IsExternCHeader)
FileKind = SrcMgr::C_ExternCSystem;
@@ -217,13 +217,13 @@ void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
FileKind = SrcMgr::C_System;
else
FileKind = SrcMgr::C_User;
-
+
unsigned EntryExit = 0;
if (IsFileEntry)
EntryExit = 1;
else if (IsFileExit)
EntryExit = 2;
-
+
LineTable->AddLineNote(LocInfo.first.ID, LocInfo.second, LineNo, FilenameID,
EntryExit, FileKind);
}
@@ -240,7 +240,7 @@ LineTableInfo &SourceManager::getLineTable() {
SourceManager::~SourceManager() {
delete LineTable;
-
+
// Delete FileEntry objects corresponding to content caches. Since the actual
// content cache objects are bump pointer allocated, we just have to run the
// dtors, but we call the deallocate method for completeness.
@@ -261,10 +261,10 @@ void SourceManager::clearIDTables() {
LastLineNoFileIDQuery = FileID();
LastLineNoContentCache = 0;
LastFileIDLookup = FileID();
-
+
if (LineTable)
LineTable->clear();
-
+
// Use up FileID #0 as an invalid instantiation.
NextOffset = 0;
createInstantiationLoc(SourceLocation(),SourceLocation(),SourceLocation(), 1);
@@ -275,11 +275,11 @@ void SourceManager::clearIDTables() {
const ContentCache *
SourceManager::getOrCreateContentCache(const FileEntry *FileEnt) {
assert(FileEnt && "Didn't specify a file entry to use?");
-
+
// Do we already have information about this file?
ContentCache *&Entry = FileInfos[FileEnt];
if (Entry) return Entry;
-
+
// Nope, create a new Cache entry. Make sure it is at least 8-byte aligned
// so that FileInfo can use the low 3 bits of the pointer for its own
// nefarious purposes.
@@ -349,12 +349,12 @@ FileID SourceManager::createFileID(const ContentCache *File,
if (PreallocatedID) {
// If we're filling in a preallocated ID, just load in the file
// entry and return.
- assert(PreallocatedID < SLocEntryLoaded.size() &&
+ assert(PreallocatedID < SLocEntryLoaded.size() &&
"Preallocate ID out-of-range");
- assert(!SLocEntryLoaded[PreallocatedID] &&
+ assert(!SLocEntryLoaded[PreallocatedID] &&
"Source location entry already loaded");
assert(Offset && "Preallocate source location cannot have zero offset");
- SLocEntryTable[PreallocatedID]
+ SLocEntryTable[PreallocatedID]
= SLocEntry::get(Offset, FileInfo::get(IncludePos, File, FileCharacter));
SLocEntryLoaded[PreallocatedID] = true;
FileID FID = FileID::get(PreallocatedID);
@@ -363,13 +363,13 @@ FileID SourceManager::createFileID(const ContentCache *File,
return LastFileIDLookup = FID;
}
- SLocEntryTable.push_back(SLocEntry::get(NextOffset,
+ SLocEntryTable.push_back(SLocEntry::get(NextOffset,
FileInfo::get(IncludePos, File,
FileCharacter)));
unsigned FileSize = File->getSize();
assert(NextOffset+FileSize+1 > NextOffset && "Ran out of source locations!");
NextOffset += FileSize+1;
-
+
// Set LastFileIDLookup to the newly created file. The next getFileID call is
// almost guaranteed to be from that file.
FileID FID = FileID::get(SLocEntryTable.size()-1);
@@ -391,9 +391,9 @@ SourceLocation SourceManager::createInstantiationLoc(SourceLocation SpellingLoc,
if (PreallocatedID) {
// If we're filling in a preallocated ID, just load in the
// instantiation entry and return.
- assert(PreallocatedID < SLocEntryLoaded.size() &&
+ assert(PreallocatedID < SLocEntryLoaded.size() &&
"Preallocate ID out-of-range");
- assert(!SLocEntryLoaded[PreallocatedID] &&
+ assert(!SLocEntryLoaded[PreallocatedID] &&
"Source location entry already loaded");
assert(Offset && "Preallocate source location cannot have zero offset");
SLocEntryTable[PreallocatedID] = SLocEntry::get(Offset, II);
@@ -426,7 +426,7 @@ SourceManager::getBufferData(FileID FID) const {
///
FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
assert(SLocOffset && "Invalid FileID");
-
+
// After the first and second level caches, I see two common sorts of
// behavior: 1) a lot of searched FileID's are "near" the cached file location
// or are "near" the cached instantiation location. 2) others are just
@@ -435,11 +435,11 @@ FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
// To handle this, we do a linear search for up to 8 steps to catch #1 quickly
// then we fall back to a less cache efficient, but more scalable, binary
// search to find the location.
-
+
// See if this is near the file point - worst case we start scanning from the
// most newly created FileID.
std::vector<SrcMgr::SLocEntry>::const_iterator I;
-
+
if (SLocEntryTable[LastFileIDLookup.ID].getOffset() < SLocOffset) {
// Neither loc prunes our search.
I = SLocEntryTable.end();
@@ -474,7 +474,7 @@ FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
if (++NumProbes == 8)
break;
}
-
+
// Convert "I" back into an index. We know that it is an entry whose index is
// larger than the offset we are looking for.
unsigned GreaterIndex = I-SLocEntryTable.begin();
@@ -486,16 +486,16 @@ FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
while (1) {
unsigned MiddleIndex = (GreaterIndex-LessIndex)/2+LessIndex;
unsigned MidOffset = getSLocEntry(FileID::get(MiddleIndex)).getOffset();
-
+
++NumProbes;
-
+
// If the offset of the midpoint is too large, chop the high side of the
// range to the midpoint.
if (MidOffset > SLocOffset) {
GreaterIndex = MiddleIndex;
continue;
}
-
+
// If the middle index contains the value, succeed and return.
if (isOffsetInFileID(FileID::get(MiddleIndex), SLocOffset)) {
#if 0
@@ -513,7 +513,7 @@ FileID SourceManager::getFileIDSlow(unsigned SLocOffset) const {
NumBinaryProbes += NumProbes;
return Res;
}
-
+
// Otherwise, move the low-side up to the middle index.
LessIndex = MiddleIndex;
}
@@ -550,12 +550,12 @@ SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E,
SourceLocation Loc;
do {
Loc = E->getInstantiation().getInstantiationLocStart();
-
+
FID = getFileID(Loc);
E = &getSLocEntry(FID);
Offset += Loc.getOffset()-E->getOffset();
} while (!Loc.isFileID());
-
+
return std::make_pair(FID, Offset);
}
@@ -568,12 +568,12 @@ SourceManager::getDecomposedSpellingLocSlowCase(const SrcMgr::SLocEntry *E,
SourceLocation Loc;
do {
Loc = E->getInstantiation().getSpellingLoc();
-
+
FID = getFileID(Loc);
E = &getSLocEntry(FID);
Offset += Loc.getOffset()-E->getOffset();
} while (!Loc.isFileID());
-
+
return std::make_pair(FID, Offset);
}
@@ -603,10 +603,10 @@ SourceManager::getImmediateInstantiationRange(SourceLocation Loc) const {
std::pair<SourceLocation,SourceLocation>
SourceManager::getInstantiationRange(SourceLocation Loc) const {
if (Loc.isFileID()) return std::make_pair(Loc, Loc);
-
+
std::pair<SourceLocation,SourceLocation> Res =
getImmediateInstantiationRange(Loc);
-
+
// Fully resolve the start and end locations to their ultimate instantiation
// points.
while (!Res.first.isFileID())
@@ -628,7 +628,7 @@ const char *SourceManager::getCharacterData(SourceLocation SL) const {
// Note that this is a hot function in the getSpelling() path, which is
// heavily used by -E mode.
std::pair<FileID, unsigned> LocInfo = getDecomposedSpellingLoc(SL);
-
+
// Note that calling 'getBuffer()' may lazily page in a source file.
return getSLocEntry(LocInfo.first).getFile().getContentCache()
->getBuffer()->getBufferStart() + LocInfo.second;
@@ -639,7 +639,7 @@ const char *SourceManager::getCharacterData(SourceLocation SL) const {
/// this is significantly cheaper to compute than the line number.
unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos) const {
const char *Buf = getBuffer(FID)->getBufferStart();
-
+
unsigned LineStart = FilePos;
while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r')
--LineStart;
@@ -662,17 +662,17 @@ unsigned SourceManager::getInstantiationColumnNumber(SourceLocation Loc) const {
static void ComputeLineNumbers(ContentCache* FI,
llvm::BumpPtrAllocator &Alloc) DISABLE_INLINE;
-static void ComputeLineNumbers(ContentCache* FI, llvm::BumpPtrAllocator &Alloc){
+static void ComputeLineNumbers(ContentCache* FI, llvm::BumpPtrAllocator &Alloc){
// Note that calling 'getBuffer()' may lazily page in the file.
const MemoryBuffer *Buffer = FI->getBuffer();
-
+
// Find the file offsets of all of the *physical* source lines. This does
// not look at trigraphs, escaped newlines, or anything else tricky.
std::vector<unsigned> LineOffsets;
-
+
// Line #1 starts at char 0.
LineOffsets.push_back(0);
-
+
const unsigned char *Buf = (const unsigned char *)Buffer->getBufferStart();
const unsigned char *End = (const unsigned char *)Buffer->getBufferEnd();
unsigned Offs = 0;
@@ -685,7 +685,7 @@ static void ComputeLineNumbers(ContentCache* FI, llvm::BumpPtrAllocator &Alloc){
++NextBuf;
Offs += NextBuf-Buf;
Buf = NextBuf;
-
+
if (Buf[0] == '\n' || Buf[0] == '\r') {
// If this is \n\r or \r\n, skip both characters.
if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1])
@@ -699,7 +699,7 @@ static void ComputeLineNumbers(ContentCache* FI, llvm::BumpPtrAllocator &Alloc){
++Offs, ++Buf;
}
}
-
+
// Copy the offsets into the FileInfo structure.
FI->NumLines = LineOffsets.size();
FI->SourceLineCache = Alloc.Allocate<unsigned>(LineOffsets.size());
@@ -717,7 +717,7 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
else
Content = const_cast<ContentCache*>(getSLocEntry(FID)
.getFile().getContentCache());
-
+
// If this is the first use of line information for this buffer, compute the
/// SourceLineCache for it on demand.
if (Content->SourceLineCache == 0)
@@ -728,11 +728,11 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
unsigned *SourceLineCache = Content->SourceLineCache;
unsigned *SourceLineCacheStart = SourceLineCache;
unsigned *SourceLineCacheEnd = SourceLineCache + Content->NumLines;
-
+
unsigned QueriedFilePos = FilePos+1;
// FIXME: I would like to be convinced that this code is worth being as
- // complicated as it is, binary search isn't that slow.
+ // complicated as it is, binary search isn't that slow.
//
// If it is worth being optimized, then in my opinion it could be more
// performant, simpler, and more obviously correct by just "galloping" outward
@@ -748,7 +748,7 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
if (QueriedFilePos >= LastLineNoFilePos) {
// FIXME: Potential overflow?
SourceLineCache = SourceLineCache+LastLineNoResult-1;
-
+
// The query is likely to be nearby the previous one. Here we check to
// see if it is within 5, 10 or 20 lines. It can be far away in cases
// where big comment blocks and vertical whitespace eat up lines but
@@ -770,17 +770,17 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
SourceLineCacheEnd = SourceLineCache+LastLineNoResult+1;
}
}
-
+
// If the spread is large, do a "radix" test as our initial guess, based on
// the assumption that lines average to approximately the same length.
// NOTE: This is currently disabled, as it does not appear to be profitable in
// initial measurements.
if (0 && SourceLineCacheEnd-SourceLineCache > 20) {
unsigned FileLen = Content->SourceLineCache[Content->NumLines-1];
-
+
// Take a stab at guessing where it is.
unsigned ApproxPos = Content->NumLines*QueriedFilePos / FileLen;
-
+
// Check for -10 and +10 lines.
unsigned LowerBound = std::max(int(ApproxPos-10), 0);
unsigned UpperBound = std::min(ApproxPos+10, FileLen);
@@ -789,17 +789,17 @@ unsigned SourceManager::getLineNumber(FileID FID, unsigned FilePos) const {
if (SourceLineCache < SourceLineCacheStart+LowerBound &&
SourceLineCacheStart[LowerBound] < QueriedFilePos)
SourceLineCache = SourceLineCacheStart+LowerBound;
-
+
// If the computed upper bound is greater than the query location, move it.
if (SourceLineCacheEnd > SourceLineCacheStart+UpperBound &&
SourceLineCacheStart[UpperBound] >= QueriedFilePos)
SourceLineCacheEnd = SourceLineCacheStart+UpperBound;
}
-
+
unsigned *Pos
= std::lower_bound(SourceLineCache, SourceLineCacheEnd, QueriedFilePos);
unsigned LineNo = Pos-SourceLineCacheStart;
-
+
LastLineNoFileIDQuery = FID;
LastLineNoContentCache = Content;
LastLineNoFilePos = QueriedFilePos;
@@ -819,14 +819,14 @@ unsigned SourceManager::getSpellingLineNumber(SourceLocation Loc) const {
}
/// getFileCharacteristic - return the file characteristic of the specified
-/// source location, indicating whether this is a normal file, a system
+/// source location, indicating whether this is a normal file, a system
/// header, or an "implicit extern C" system header.
///
/// This state can be modified with flags on GNU linemarker directives like:
/// # 4 "foo.h" 3
/// which changes all source locations in the current file after that to be
/// considered to be from a system header.
-SrcMgr::CharacteristicKind
+SrcMgr::CharacteristicKind
SourceManager::getFileCharacteristic(SourceLocation Loc) const {
assert(!Loc.isInvalid() && "Can't get file characteristic of invalid loc!");
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
@@ -836,12 +836,12 @@ SourceManager::getFileCharacteristic(SourceLocation Loc) const {
// state.
if (!FI.hasLineDirectives())
return FI.getFileCharacteristic();
-
+
assert(LineTable && "Can't have linetable entries without a LineTable!");
// See if there is a #line directive before the location.
const LineEntry *Entry =
LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second);
-
+
// If this is before the first line marker, use the file characteristic.
if (!Entry)
return FI.getFileCharacteristic();
@@ -854,7 +854,7 @@ SourceManager::getFileCharacteristic(SourceLocation Loc) const {
/// for normal clients.
const char *SourceManager::getBufferName(SourceLocation Loc) const {
if (Loc.isInvalid()) return "<invalid loc>";
-
+
return getBuffer(getFileID(Loc))->getBufferIdentifier();
}
@@ -868,22 +868,22 @@ const char *SourceManager::getBufferName(SourceLocation Loc) const {
/// of an instantiation location, not at the spelling location.
PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
if (Loc.isInvalid()) return PresumedLoc();
-
+
// Presumed locations are always for instantiation points.
std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
-
+
const SrcMgr::FileInfo &FI = getSLocEntry(LocInfo.first).getFile();
const SrcMgr::ContentCache *C = FI.getContentCache();
-
+
// To get the source name, first consult the FileEntry (if one exists)
// before the MemBuffer as this will avoid unnecessarily paging in the
// MemBuffer.
- const char *Filename =
+ const char *Filename =
C->Entry ? C->Entry->getName() : C->getBuffer()->getBufferIdentifier();
unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second);
unsigned ColNo = getColumnNumber(LocInfo.first, LocInfo.second);
SourceLocation IncludeLoc = FI.getIncludeLoc();
-
+
// If we have #line directives in this file, update and overwrite the physical
// location info if appropriate.
if (FI.hasLineDirectives()) {
@@ -901,9 +901,9 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
// total.
unsigned MarkerLineNo = getLineNumber(LocInfo.first, Entry->FileOffset);
LineNo = Entry->LineNo + (LineNo-MarkerLineNo-1);
-
+
// Note that column numbers are not molested by line markers.
-
+
// Handle virtual #include manipulation.
if (Entry->IncludeOffset) {
IncludeLoc = getLocForStartOfFile(LocInfo.first);
@@ -932,7 +932,7 @@ SourceLocation SourceManager::getLocation(const FileEntry *SourceFile,
if (FI == FileInfos.end())
return SourceLocation();
ContentCache *Content = FI->second;
-
+
// If this is the first use of line information for this buffer, compute the
/// SourceLineCache for it on demand.
if (Content->SourceLineCache == 0)
@@ -940,7 +940,7 @@ SourceLocation SourceManager::getLocation(const FileEntry *SourceFile,
if (Line > Content->NumLines)
return SourceLocation();
-
+
unsigned FilePos = Content->SourceLineCache[Line - 1];
const char *Buf = Content->getBuffer()->getBufferStart() + FilePos;
unsigned BufLength = Content->getBuffer()->getBufferEnd() - Buf;
@@ -951,7 +951,7 @@ SourceLocation SourceManager::getLocation(const FileEntry *SourceFile,
++i;
if (i < Col-1)
return SourceLocation();
-
+
return getLocForStartOfFile(Content->FirstFID).
getFileLocWithOffset(FilePos + Col - 1);
}
@@ -964,24 +964,24 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
assert(LHS.isValid() && RHS.isValid() && "Passed invalid source location!");
if (LHS == RHS)
return false;
-
+
std::pair<FileID, unsigned> LOffs = getDecomposedLoc(LHS);
std::pair<FileID, unsigned> ROffs = getDecomposedLoc(RHS);
-
+
// If the source locations are in the same file, just compare offsets.
if (LOffs.first == ROffs.first)
return LOffs.second < ROffs.second;
// If we are comparing a source location with multiple locations in the same
// file, we get a big win by caching the result.
-
+
if (LastLFIDForBeforeTUCheck == LOffs.first &&
LastRFIDForBeforeTUCheck == ROffs.first)
return LastResForBeforeTUCheck;
-
+
LastLFIDForBeforeTUCheck = LOffs.first;
LastRFIDForBeforeTUCheck = ROffs.first;
-
+
// "Traverse" the include/instantiation stacks of both locations and try to
// find a common "ancestor".
//
@@ -999,15 +999,15 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
UpperLoc = Entry.getInstantiation().getInstantiationLocStart();
else
UpperLoc = Entry.getFile().getIncludeLoc();
-
+
if (UpperLoc.isInvalid())
break; // We reached the top.
-
+
ROffs = getDecomposedLoc(UpperLoc);
-
+
if (LOffs.first == ROffs.first)
return LastResForBeforeTUCheck = LOffs.second < ROffs.second;
-
+
ROffsMap[ROffs.first] = ROffs.second;
}
@@ -1021,33 +1021,33 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
UpperLoc = Entry.getInstantiation().getInstantiationLocStart();
else
UpperLoc = Entry.getFile().getIncludeLoc();
-
+
if (UpperLoc.isInvalid())
break; // We reached the top.
-
+
LOffs = getDecomposedLoc(UpperLoc);
-
+
std::map<FileID, unsigned>::iterator I = ROffsMap.find(LOffs.first);
if (I != ROffsMap.end())
return LastResForBeforeTUCheck = LOffs.second < I->second;
}
-
+
// No common ancestor.
// Now we are getting into murky waters. Most probably this is because one
// location is in the predefines buffer.
-
+
const FileEntry *LEntry =
getSLocEntry(LOffs.first).getFile().getContentCache()->Entry;
const FileEntry *REntry =
getSLocEntry(ROffs.first).getFile().getContentCache()->Entry;
-
+
// If the locations are in two memory buffers we give up, we can't answer
// which one should be considered first.
// FIXME: Should there be a way to "include" memory buffers in the translation
// unit ?
assert((LEntry != 0 || REntry != 0) && "Locations in memory buffers.");
(void) REntry;
-
+
// Consider the memory buffer as coming before the file in the translation
// unit.
if (LEntry == 0)
@@ -1066,14 +1066,14 @@ void SourceManager::PrintStats() const {
<< " mem buffers mapped.\n";
llvm::errs() << SLocEntryTable.size() << " SLocEntry's allocated, "
<< NextOffset << "B of Sloc address space used.\n";
-
+
unsigned NumLineNumsComputed = 0;
unsigned NumFileBytesMapped = 0;
for (fileinfo_iterator I = fileinfo_begin(), E = fileinfo_end(); I != E; ++I){
NumLineNumsComputed += I->second->SourceLineCache != 0;
NumFileBytesMapped += I->second->getSizeBytesMapped();
}
-
+
llvm::errs() << NumFileBytesMapped << " bytes of files mapped, "
<< NumLineNumsComputed << " files with line #'s computed.\n";
llvm::errs() << "FileID scans: " << NumLinearScans << " linear, "
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index 5b2ffb7d16..35d9ccd401 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -87,17 +87,17 @@ static void removeGCCRegisterPrefix(const char *&Name) {
bool TargetInfo::isValidGCCRegisterName(const char *Name) const {
const char * const *Names;
unsigned NumNames;
-
+
// Get rid of any register prefix.
removeGCCRegisterPrefix(Name);
-
+
if (strcmp(Name, "memory") == 0 ||
strcmp(Name, "cc") == 0)
return true;
-
+
getGCCRegNames(Names, NumNames);
-
+
// If we have a number it maps to an entry in the register name array.
if (isdigit(Name[0])) {
char *End;
@@ -111,11 +111,11 @@ bool TargetInfo::isValidGCCRegisterName(const char *Name) const {
if (strcmp(Name, Names[i]) == 0)
return true;
}
-
+
// Now check aliases.
const GCCRegAlias *Aliases;
unsigned NumAliases;
-
+
getGCCRegAliases(Aliases, NumAliases);
for (unsigned i = 0; i < NumAliases; i++) {
for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
@@ -125,15 +125,15 @@ bool TargetInfo::isValidGCCRegisterName(const char *Name) const {
return true;
}
}
-
+
return false;
}
const char *TargetInfo::getNormalizedGCCRegisterName(const char *Name) const {
assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
-
+
removeGCCRegisterPrefix(Name);
-
+
const char * const *Names;
unsigned NumNames;
@@ -144,16 +144,16 @@ const char *TargetInfo::getNormalizedGCCRegisterName(const char *Name) const {
char *End;
int n = (int)strtol(Name, &End, 0);
if (*End == 0) {
- assert(n >= 0 && (unsigned)n < NumNames &&
+ assert(n >= 0 && (unsigned)n < NumNames &&
"Out of bounds register number!");
return Names[n];
}
}
-
+
// Now check aliases.
const GCCRegAlias *Aliases;
unsigned NumAliases;
-
+
getGCCRegAliases(Aliases, NumAliases);
for (unsigned i = 0; i < NumAliases; i++) {
for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
@@ -163,7 +163,7 @@ const char *TargetInfo::getNormalizedGCCRegisterName(const char *Name) const {
return Aliases[i].Register;
}
}
-
+
return Name;
}
@@ -200,10 +200,10 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
Info.setAllowsMemory();
break;
}
-
+
Name++;
}
-
+
return true;
}
@@ -216,14 +216,14 @@ bool TargetInfo::resolveSymbolicName(const char *&Name,
const char *Start = Name;
while (*Name && *Name != ']')
Name++;
-
+
if (!*Name) {
// Missing ']'
return false;
}
-
+
std::string SymbolicName(Start, Name - Start);
-
+
for (Index = 0; Index != NumOutputs; ++Index)
if (SymbolicName == OutputConstraints[Index].getName())
return true;
@@ -242,12 +242,12 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
// Check if we have a matching constraint
if (*Name >= '0' && *Name <= '9') {
unsigned i = *Name - '0';
-
+
// Check if matching constraint is out of bounds.
if (i >= NumOutputs)
return false;
-
- // The constraint should have the same info as the respective
+
+ // The constraint should have the same info as the respective
// output constraint.
Info.setTiedOperand(i, OutputConstraints[i]);
} else if (!validateAsmConstraint(Name, Info)) {
@@ -261,9 +261,9 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
unsigned Index = 0;
if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
return false;
-
+
break;
- }
+ }
case '%': // commutative
// FIXME: Fail if % is used with the last operand.
break;
@@ -291,9 +291,9 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
Info.setAllowsMemory();
break;
}
-
+
Name++;
}
-
+
return true;
}
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index d9cd42c323..4e63db6eaf 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -111,11 +111,11 @@ static void getDarwinOSXDefines(std::vector<char> &Defs,
const llvm::Triple &Triple) {
if (Triple.getOS() != llvm::Triple::Darwin)
return;
-
+
// Figure out which "darwin number" the target triple is. "darwin9" -> 10.5.
unsigned Maj, Min, Rev;
Triple.getDarwinNumber(Maj, Min, Rev);
-
+
char MacOSXStr[] = "1000";
if (Maj >= 4 && Maj <= 13) { // 10.0-10.9
// darwin7 -> 1030, darwin8 -> 1040, darwin9 -> 1050, etc.
@@ -132,11 +132,11 @@ static void getDarwinIPhoneOSDefines(std::vector<char> &Defs,
const llvm::Triple &Triple) {
if (Triple.getOS() != llvm::Triple::Darwin)
return;
-
+
// Figure out which "darwin number" the target triple is. "darwin9" -> 10.5.
unsigned Maj, Min, Rev;
Triple.getDarwinNumber(Maj, Min, Rev);
-
+
// When targetting iPhone OS, interpret the minor version and
// revision as the iPhone OS version
char iPhoneOSStr[] = "10000";
@@ -155,7 +155,7 @@ static void getDarwinIPhoneOSDefines(std::vector<char> &Defs,
static void GetDarwinLanguageOptions(LangOptions &Opts,
const llvm::Triple &Triple) {
Opts.NeXTRuntime = true;
-
+
if (Triple.getOS() != llvm::Triple::Darwin)
return;
@@ -183,7 +183,7 @@ protected:
getDarwinDefines(Defines, Opts);
getDarwinOSXDefines(Defines, Triple);
}
-
+
/// getDefaultLangOptions - Allow the target to specify default settings for
/// various language options. These may be overridden by command line
/// options.
@@ -204,7 +204,7 @@ public:
virtual const char *getUnicodeStringSection() const {
return "__TEXT,__ustring";
}
-
+
virtual std::string isValidSectionSpecifier(const llvm::StringRef &SR) const {
// Let MCSectionMachO validate this.
llvm::StringRef Segment, Section;
@@ -230,7 +230,7 @@ protected:
DefineStd(Defs, "unix", Opts);
}
public:
- DragonFlyBSDTargetInfo(const std::string &triple)
+ DragonFlyBSDTargetInfo(const std::string &triple)
: OSTargetInfo<Target>(triple) {}
};
@@ -258,7 +258,7 @@ protected:
Define(Defs, "__ELF__", "1");
}
public:
- FreeBSDTargetInfo(const std::string &triple)
+ FreeBSDTargetInfo(const std::string &triple)
: OSTargetInfo<Target>(triple) {
this->UserLabelPrefix = "";
}
@@ -279,7 +279,7 @@ protected:
Define(Defs, "_REENTRANT", "1");
}
public:
- LinuxTargetInfo(const std::string& triple)
+ LinuxTargetInfo(const std::string& triple)
: OSTargetInfo<Target>(triple) {
this->UserLabelPrefix = "";
}
@@ -299,7 +299,7 @@ protected:
Define(Defs, "_POSIX_THREADS", "1");
}
public:
- NetBSDTargetInfo(const std::string &triple)
+ NetBSDTargetInfo(const std::string &triple)
: OSTargetInfo<Target>(triple) {
this->UserLabelPrefix = "";
}
@@ -320,7 +320,7 @@ protected:
Define(Defs, "_POSIX_THREADS", "1");
}
public:
- OpenBSDTargetInfo(const std::string &triple)
+ OpenBSDTargetInfo(const std::string &triple)
: OSTargetInfo<Target>(triple) {}
};
@@ -337,14 +337,14 @@ protected:
Define(Defs, "__SVR4");
}
public:
- SolarisTargetInfo(const std::string& triple)
+ SolarisTargetInfo(const std::string& triple)
: OSTargetInfo<Target>(triple) {
this->UserLabelPrefix = "";
this->WCharType = this->SignedLong;
// FIXME: WIntType should be SignedLong
}
};
-} // end anonymous namespace.
+} // end anonymous namespace.
/// GetWindowsLanguageOptions - Set the default language options for Windows.
static void GetWindowsLanguageOptions(LangOptions &Opts,
@@ -609,12 +609,12 @@ public:
virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
const std::string &Name,
bool Enabled) const;
- virtual void getDefaultFeatures(const std::string &CPU,
+ virtual void getDefaultFeatures(const std::string &CPU,
llvm::StringMap<bool> &Features) const;
virtual void HandleTargetFeatures(const llvm::StringMap<bool> &Features);
};
-void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
+void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
llvm::StringMap<bool> &Features) const {
// FIXME: This should not be here.
Features["3dnow"] = false;
@@ -658,7 +658,7 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
setFeatureEnabled(Features, "sse4", true);
else if (CPU == "k6" || CPU == "winchip-c6")
setFeatureEnabled(Features, "mmx", true);
- else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" ||
+ else if (CPU == "k6-2" || CPU == "k6-3" || CPU == "athlon" ||
CPU == "athlon-tbird" || CPU == "winchip2" || CPU == "c3") {
setFeatureEnabled(Features, "mmx", true);
setFeatureEnabled(Features, "3dnow", true);
@@ -667,14 +667,14 @@ void X86TargetInfo::getDefaultFeatures(const std::string &CPU,
setFeatureEnabled(Features, "3dnowa", true);
} else if (CPU == "k8" || CPU == "opteron" || CPU == "athlon64" ||
CPU == "athlon-fx") {
- setFeatureEnabled(Features, "sse2", true);
+ setFeatureEnabled(Features, "sse2", true);
setFeatureEnabled(Features, "3dnowa", true);
} else if (CPU == "c3-2")
setFeatureEnabled(Features, "sse", true);
}
bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
- const std::string &Name,
+ const std::string &Name,
bool Enabled) const {
// FIXME: This *really* should not be here.
if (!Features.count(Name) && Name != "sse4")
@@ -688,13 +688,13 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
else if (Name == "sse2")
Features["mmx"] = Features["sse"] = Features["sse2"] = true;
else if (Name == "sse3")
- Features["mmx"] = Features["sse"] = Features["sse2"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] =
Features["sse3"] = true;
else if (Name == "ssse3")
- Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = true;
else if (Name == "sse4")
- Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = Features["sse42"] = true;
else if (Name == "3dnow")
Features["3dnowa"] = true;
@@ -702,16 +702,16 @@ bool X86TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
Features["3dnow"] = Features["3dnowa"] = true;
} else {
if (Name == "mmx")
- Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["mmx"] = Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
else if (Name == "sse")
- Features["sse"] = Features["sse2"] = Features["sse3"] =
+ Features["sse"] = Features["sse2"] = Features["sse3"] =
Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
else if (Name == "sse2")
- Features["sse2"] = Features["sse3"] = Features["ssse3"] =
+ Features["sse2"] = Features["sse3"] = Features["ssse3"] =
Features["sse41"] = Features["sse42"] = false;
else if (Name == "sse3")
- Features["sse3"] = Features["ssse3"] = Features["sse41"] =
+ Features["sse3"] = Features["ssse3"] = Features["sse41"] =
Features["sse42"] = false;
else if (Name == "ssse3")
Features["ssse3"] = Features["sse41"] = Features["sse42"] = false;
@@ -963,7 +963,7 @@ public:
namespace {
class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> {
public:
- DarwinX86_64TargetInfo(const std::string& triple)
+ DarwinX86_64TargetInfo(const std::string& triple)
: DarwinTargetInfo<X86_64TargetInfo>(triple) {
Int64Type = SignedLongLong;
}
@@ -973,7 +973,7 @@ public:
namespace {
class OpenBSDX86_64TargetInfo : public OpenBSDTargetInfo<X86_64TargetInfo> {
public:
- OpenBSDX86_64TargetInfo(const std::string& triple)
+ OpenBSDX86_64TargetInfo(const std::string& triple)
: OpenBSDTargetInfo<X86_64TargetInfo>(triple) {
IntMaxType = SignedLongLong;
UIntMaxType = UnsignedLongLong;
@@ -1089,7 +1089,7 @@ public:
namespace {
-class DarwinARMTargetInfo :
+class DarwinARMTargetInfo :
public DarwinTargetInfo<ARMTargetInfo> {
protected:
virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
@@ -1099,7 +1099,7 @@ protected:
}
public:
- DarwinARMTargetInfo(const std::string& triple)
+ DarwinARMTargetInfo(const std::string& triple)
: DarwinTargetInfo<ARMTargetInfo>(triple) {}
};
} // end anonymous namespace.
@@ -1244,7 +1244,7 @@ namespace {
Define(Defines, "__pic16");
Define(Defines, "rom", "__attribute__((address_space(1)))");
Define(Defines, "ram", "__attribute__((address_space(0)))");
- Define(Defines, "_section(SectName)",
+ Define(Defines, "_section(SectName)",
"__attribute__((section(SectName)))");
Define(Defines, "_address(Addr)",
"__attribute__((section(\"Address=\"#Addr)))");
@@ -1255,7 +1255,7 @@ namespace {
}
virtual void getTargetBuiltins(const Builtin::Info *&Records,
unsigned &NumRecords) const {}
- virtual const char *getVAListDeclaration() const {
+ virtual const char *getVAListDeclaration() const {
return "";
}
virtual const char *getClobbers() const {
@@ -1480,12 +1480,12 @@ namespace {
namespace {
- // LLVM and Clang cannot be used directly to output native binaries for
- // target, but is used to compile C code to llvm bitcode with correct
+ // LLVM and Clang cannot be used directly to output native binaries for
+ // target, but is used to compile C code to llvm bitcode with correct
// type and alignment information.
- //
- // TCE uses the llvm bitcode as input and uses it for generating customized
- // target processor and program binary. TCE co-design environment is
+ //
+ // TCE uses the llvm bitcode as input and uses it for generating customized
+ // target processor and program binary. TCE co-design environment is
// publicly available in http://tce.cs.tut.fi
class TCETargetInfo : public TargetInfo{
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 0c98c40866..43b098e021 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -60,14 +60,14 @@ BuildDescriptorBlockDecl(bool BlockHasCopyDispose, uint64_t Size,
llvm::Constant *BlockModule::getNSConcreteGlobalBlock() {
if (NSConcreteGlobalBlock == 0)
- NSConcreteGlobalBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
+ NSConcreteGlobalBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
"_NSConcreteGlobalBlock");
return NSConcreteGlobalBlock;
}
llvm::Constant *BlockModule::getNSConcreteStackBlock() {
if (NSConcreteStackBlock == 0)
- NSConcreteStackBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
+ NSConcreteStackBlock = CGM.CreateRuntimeVariable(PtrToInt8Ty,
"_NSConcreteStackBlock");
return NSConcreteStackBlock;
}
@@ -427,16 +427,16 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
QualType ResultType = FnType->getAsFunctionType()->getResultType();
- const CGFunctionInfo &FnInfo =
+ const CGFunctionInfo &FnInfo =
CGM.getTypes().getFunctionInfo(ResultType, Args);
-
+
// Cast the function pointer to the right type.
- const llvm::Type *BlockFTy =
+ const llvm::Type *BlockFTy =
CGM.getTypes().GetFunctionType(FnInfo, false);
-
+
const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
Func = Builder.CreateBitCast(Func, BlockFTyPtr);
-
+
// And call the block.
return EmitCall(FnInfo, Func, Args);
}
@@ -583,7 +583,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
// Check if we should generate debug info for this block.
if (CGM.getDebugInfo())
DebugInfo = CGM.getDebugInfo();
-
+
// Arrange for local static and local extern declarations to appear
// to be local to this function as well, as they are directly referenced
// in a block.
@@ -591,7 +591,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
i != ldm.end();
++i) {
const VarDecl *VD = dyn_cast<VarDecl>(i->first);
-
+
if (VD->getStorageClass() == VarDecl::Static || VD->hasExternalStorage())
LocalDeclMap[VD] = i->second;
}
@@ -609,7 +609,7 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr,
const FunctionType *BlockFunctionType = BExpr->getFunctionType();
QualType ResultType;
bool IsVariadic;
- if (const FunctionProtoType *FTy =
+ if (const FunctionProtoType *FTy =
dyn_cast<FunctionProtoType>(BlockFunctionType)) {
ResultType = FTy->getResultType();
IsVariadic = FTy->isVariadic();
@@ -721,7 +721,7 @@ GenerateCopyHelperFunction(bool BlockHasCopyDispose, const llvm::StructType *T,
ImplicitParamDecl::Create(getContext(), 0, SourceLocation(), 0,
getContext().getPointerType(getContext().VoidTy));
Args.push_back(std::make_pair(Src, Src->getType()));
-
+
const CGFunctionInfo &FI =
CGM.getTypes().getFunctionInfo(R, Args);
@@ -803,7 +803,7 @@ GenerateDestroyHelperFunction(bool BlockHasCopyDispose,
getContext().getPointerType(getContext().VoidTy));
Args.push_back(std::make_pair(Src, Src->getType()));
-
+
const CGFunctionInfo &FI =
CGM.getTypes().getFunctionInfo(R, Args);
@@ -887,7 +887,7 @@ GeneratebyrefCopyHelperFunction(const llvm::Type *T, int flag) {
ImplicitParamDecl::Create(getContext(), 0, SourceLocation(), 0,
getContext().getPointerType(getContext().VoidTy));
Args.push_back(std::make_pair(Src, Src->getType()));
-
+
const CGFunctionInfo &FI =
CGM.getTypes().getFunctionInfo(R, Args);
@@ -926,7 +926,7 @@ GeneratebyrefCopyHelperFunction(const llvm::Type *T, int flag) {
V = Builder.CreateStructGEP(V, 6, "x");
V = Builder.CreateBitCast(V, llvm::PointerType::get(PtrToInt8Ty, 0));
llvm::Value *SrcObj = Builder.CreateLoad(V);
-
+
flag |= BLOCK_BYREF_CALLER;
llvm::Value *N = llvm::ConstantInt::get(
@@ -951,7 +951,7 @@ BlockFunction::GeneratebyrefDestroyHelperFunction(const llvm::Type *T,
getContext().getPointerType(getContext().VoidTy));
Args.push_back(std::make_pair(Src, Src->getType()));
-
+
const CGFunctionInfo &FI =
CGM.getTypes().getFunctionInfo(R, Args);
diff --git a/lib/CodeGen/CGBlocks.h b/lib/CodeGen/CGBlocks.h
index 61415adc9b..6309e1d87d 100644
--- a/lib/CodeGen/CGBlocks.h
+++ b/lib/CodeGen/CGBlocks.h
@@ -66,7 +66,7 @@ class BlockModule : public BlockBase {
CodeGenTypes &Types;
CodeGenModule &CGM;
llvm::LLVMContext &VMContext;
-
+
ASTContext &getContext() const { return Context; }
llvm::Module &getModule() const { return TheModule; }
CodeGenTypes &getTypes() { return Types; }
@@ -89,7 +89,7 @@ public:
/// NSConcreteStackBlock - Cached reference to the class poinnter for stack
/// blocks.
llvm::Constant *NSConcreteStackBlock;
-
+
const llvm::Type *BlockDescriptorType;
const llvm::Type *GenericBlockLiteralType;
const llvm::Type *GenericExtendedBlockLiteralType;
@@ -157,11 +157,11 @@ public:
/// ByCopyDeclRefs - Variables from parent scopes that have been imported
/// into this block.
llvm::SmallVector<const BlockDeclRefExpr *, 8> ByCopyDeclRefs;
-
- // ByRefDeclRefs - __block variables from parent scopes that have been
+
+ // ByRefDeclRefs - __block variables from parent scopes that have been
// imported into this block.
llvm::SmallVector<const BlockDeclRefExpr *, 8> ByRefDeclRefs;
-
+
BlockInfo(const llvm::Type *blt, const char *n)
: BlockLiteralTy(blt), Name(n) {
// Skip asm prefix, if any.
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index bfb6be8b79..77c408a963 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -25,21 +25,21 @@ using namespace llvm;
/// Utility to insert an atomic instruction based on Instrinsic::ID
/// and the expression node.
-static RValue EmitBinaryAtomic(CodeGenFunction& CGF,
+static RValue EmitBinaryAtomic(CodeGenFunction& CGF,
Intrinsic::ID Id, const CallExpr *E) {
const llvm::Type *ResType[2];
ResType[0] = CGF.ConvertType(E->getType());
ResType[1] = CGF.ConvertType(E->getArg(0)->getType());
Value *AtomF = CGF.CGM.getIntrinsic(Id, ResType, 2);
- return RValue::get(CGF.Builder.CreateCall2(AtomF,
- CGF.EmitScalarExpr(E->getArg(0)),
+ return RValue::get(CGF.Builder.CreateCall2(AtomF,
+ CGF.EmitScalarExpr(E->getArg(0)),
CGF.EmitScalarExpr(E->getArg(1))));
}
/// Utility to insert an atomic instruction based Instrinsic::ID and
// the expression node, where the return value is the result of the
// operation.
-static RValue EmitBinaryAtomicPost(CodeGenFunction& CGF,
+static RValue EmitBinaryAtomicPost(CodeGenFunction& CGF,
Intrinsic::ID Id, const CallExpr *E,
Instruction::BinaryOps Op) {
const llvm::Type *ResType[2];
@@ -49,26 +49,26 @@ static RValue EmitBinaryAtomicPost(CodeGenFunction& CGF,
Value *Ptr = CGF.EmitScalarExpr(E->getArg(0));
Value *Operand = CGF.EmitScalarExpr(E->getArg(1));
Value *Result = CGF.Builder.CreateCall2(AtomF, Ptr, Operand);
-
+
if (Id == Intrinsic::atomic_load_nand)
Result = CGF.Builder.CreateNot(Result);
-
-
+
+
return RValue::get(CGF.Builder.CreateBinOp(Op, Result, Operand));
}
-RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
+RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
unsigned BuiltinID, const CallExpr *E) {
// See if we can constant fold this builtin. If so, don't emit it at all.
Expr::EvalResult Result;
if (E->Evaluate(Result, CGM.getContext())) {
if (Result.Val.isInt())
- return RValue::get(llvm::ConstantInt::get(VMContext,
+ return RValue::get(llvm::ConstantInt::get(VMContext,
Result.Val.getInt()));
else if (Result.Val.isFloat())
return RValue::get(ConstantFP::get(VMContext, Result.Val.getFloat()));
}
-
+
switch (BuiltinID) {
default: break; // Handle intrinsics and libm functions below.
case Builtin::BI__builtin___CFStringMakeConstantString:
@@ -77,13 +77,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_va_start:
case Builtin::BI__builtin_va_end: {
Value *ArgValue = EmitVAListRef(E->getArg(0));
- const llvm::Type *DestType =
+ const llvm::Type *DestType =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
if (ArgValue->getType() != DestType)
- ArgValue = Builder.CreateBitCast(ArgValue, DestType,
+ ArgValue = Builder.CreateBitCast(ArgValue, DestType,
ArgValue->getName().data());
- Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_end) ?
+ Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_end) ?
Intrinsic::vaend : Intrinsic::vastart;
return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue));
}
@@ -91,36 +91,36 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Value *DstPtr = EmitVAListRef(E->getArg(0));
Value *SrcPtr = EmitVAListRef(E->getArg(1));
- const llvm::Type *Type =
+ const llvm::Type *Type =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
DstPtr = Builder.CreateBitCast(DstPtr, Type);
SrcPtr = Builder.CreateBitCast(SrcPtr, Type);
- return RValue::get(Builder.CreateCall2(CGM.getIntrinsic(Intrinsic::vacopy),
+ return RValue::get(Builder.CreateCall2(CGM.getIntrinsic(Intrinsic::vacopy),
DstPtr, SrcPtr));
}
case Builtin::BI__builtin_abs: {
- Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+ Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
- Value *CmpResult =
- Builder.CreateICmpSGE(ArgValue,
+ Value *CmpResult =
+ Builder.CreateICmpSGE(ArgValue,
llvm::Constant::getNullValue(ArgValue->getType()),
"abscond");
- Value *Result =
+ Value *Result =
Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs");
-
+
return RValue::get(Result);
}
case Builtin::BI__builtin_ctz:
case Builtin::BI__builtin_ctzl:
case Builtin::BI__builtin_ctzll: {
Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::cttz, &ArgType, 1);
- const llvm::Type *ResultType = ConvertType(E->getType());
+ const llvm::Type *ResultType = ConvertType(E->getType());
Value *Result = Builder.CreateCall(F, ArgValue, "tmp");
if (Result->getType() != ResultType)
Result = Builder.CreateIntCast(Result, ResultType, "cast");
@@ -130,11 +130,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_clzl:
case Builtin::BI__builtin_clzll: {
Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::ctlz, &ArgType, 1);
- const llvm::Type *ResultType = ConvertType(E->getType());
+ const llvm::Type *ResultType = ConvertType(E->getType());
Value *Result = Builder.CreateCall(F, ArgValue, "tmp");
if (Result->getType() != ResultType)
Result = Builder.CreateIntCast(Result, ResultType, "cast");
@@ -145,12 +145,12 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_ffsll: {
// ffs(x) -> x ? cttz(x) + 1 : 0
Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::cttz, &ArgType, 1);
-
+
const llvm::Type *ResultType = ConvertType(E->getType());
- Value *Tmp = Builder.CreateAdd(Builder.CreateCall(F, ArgValue, "tmp"),
+ Value *Tmp = Builder.CreateAdd(Builder.CreateCall(F, ArgValue, "tmp"),
llvm::ConstantInt::get(ArgType, 1), "tmp");
Value *Zero = llvm::Constant::getNullValue(ArgType);
Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero");
@@ -164,13 +164,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_parityll: {
// parity(x) -> ctpop(x) & 1
Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::ctpop, &ArgType, 1);
-
+
const llvm::Type *ResultType = ConvertType(E->getType());
Value *Tmp = Builder.CreateCall(F, ArgValue, "tmp");
- Value *Result = Builder.CreateAnd(Tmp, llvm::ConstantInt::get(ArgType, 1),
+ Value *Result = Builder.CreateAnd(Tmp, llvm::ConstantInt::get(ArgType, 1),
"tmp");
if (Result->getType() != ResultType)
Result = Builder.CreateIntCast(Result, ResultType, "cast");
@@ -180,10 +180,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_popcountl:
case Builtin::BI__builtin_popcountll: {
Value *ArgValue = EmitScalarExpr(E->getArg(0));
-
+
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::ctpop, &ArgType, 1);
-
+
const llvm::Type *ResultType = ConvertType(E->getType());
Value *Result = Builder.CreateCall(F, ArgValue, "tmp");
if (Result->getType() != ResultType)
@@ -199,7 +199,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
const llvm::Type *ArgType = ArgValue->getType();
Value *F = CGM.getIntrinsic(Intrinsic::bswap, &ArgType, 1);
return RValue::get(Builder.CreateCall(F, ArgValue, "tmp"));
- }
+ }
case Builtin::BI__builtin_object_size: {
// FIXME: Implement. For now we just always fail and pretend we
// don't know the object size.
@@ -213,9 +213,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_prefetch: {
Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0));
// FIXME: Technically these constants should of type 'int', yes?
- RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) :
+ RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) :
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 0);
- Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) :
+ Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) :
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 3);
Value *F = CGM.getIntrinsic(Intrinsic::prefetch, 0, 0);
return RValue::get(Builder.CreateCall3(F, Address, RW, Locality));
@@ -243,9 +243,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_isunordered: {
// Ordered comparisons: we know the arguments to these are matching scalar
// floating point values.
- Value *LHS = EmitScalarExpr(E->getArg(0));
+ Value *LHS = EmitScalarExpr(E->getArg(0));
Value *RHS = EmitScalarExpr(E->getArg(1));
-
+
switch (BuiltinID) {
default: assert(0 && "Unknown ordered comparison");
case Builtin::BI__builtin_isgreater:
@@ -263,7 +263,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_islessgreater:
LHS = Builder.CreateFCmpONE(LHS, RHS, "cmp");
break;
- case Builtin::BI__builtin_isunordered:
+ case Builtin::BI__builtin_isunordered:
LHS = Builder.CreateFCmpUNO(LHS, RHS, "cmp");
break;
}
@@ -352,7 +352,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__builtin_longjmp: {
Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_longjmp, 0, 0);
Value *Buf = EmitScalarExpr(E->getArg(0));
- const llvm::Type *DestType =
+ const llvm::Type *DestType =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
Buf = Builder.CreateBitCast(Buf, DestType);
return RValue::get(Builder.CreateCall(F, Buf));
@@ -409,7 +409,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__sync_fetch_and_nand_8:
case Builtin::BI__sync_fetch_and_nand_16:
return EmitBinaryAtomic(*this, Intrinsic::atomic_load_nand, E);
-
+
// Clang extensions: not overloaded yet.
case Builtin::BI__sync_fetch_and_min:
return EmitBinaryAtomic(*this, Intrinsic::atomic_load_min, E);
@@ -425,7 +425,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__sync_add_and_fetch_4:
case Builtin::BI__sync_add_and_fetch_8:
case Builtin::BI__sync_add_and_fetch_16:
- return EmitBinaryAtomicPost(*this, Intrinsic::atomic_load_add, E,
+ return EmitBinaryAtomicPost(*this, Intrinsic::atomic_load_add, E,
llvm::Instruction::Add);
case Builtin::BI__sync_sub_and_fetch_1:
case Builtin::BI__sync_sub_and_fetch_2:
@@ -462,7 +462,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BI__sync_nand_and_fetch_16:
return EmitBinaryAtomicPost(*this, Intrinsic::atomic_load_nand, E,
llvm::Instruction::And);
-
+
case Builtin::BI__sync_val_compare_and_swap_1:
case Builtin::BI__sync_val_compare_and_swap_2:
case Builtin::BI__sync_val_compare_and_swap_4:
@@ -473,7 +473,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
ResType[0]= ConvertType(E->getType());
ResType[1] = ConvertType(E->getArg(0)->getType());
Value *AtomF = CGM.getIntrinsic(Intrinsic::atomic_cmp_swap, ResType, 2);
- return RValue::get(Builder.CreateCall3(AtomF,
+ return RValue::get(Builder.CreateCall3(AtomF,
EmitScalarExpr(E->getArg(0)),
EmitScalarExpr(E->getArg(1)),
EmitScalarExpr(E->getArg(2))));
@@ -490,7 +490,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
ResType[1] = llvm::PointerType::getUnqual(ResType[0]);
Value *AtomF = CGM.getIntrinsic(Intrinsic::atomic_cmp_swap, ResType, 2);
Value *OldVal = EmitScalarExpr(E->getArg(1));
- Value *PrevVal = Builder.CreateCall3(AtomF,
+ Value *PrevVal = Builder.CreateCall3(AtomF,
EmitScalarExpr(E->getArg(0)),
OldVal,
EmitScalarExpr(E->getArg(2)));
@@ -524,7 +524,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
Builder.CreateCall(CGM.getIntrinsic(Intrinsic::memory_barrier), C, C + 5);
return RValue::get(0);
}
-
+
// Library functions with special handling.
case Builtin::BIsqrt:
case Builtin::BIsqrtf:
@@ -551,31 +551,31 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
return RValue::get(Builder.CreateCall2(F, Base, Exponent, "tmp"));
}
}
-
+
// If this is an alias for a libm function (e.g. __builtin_sin) turn it into
// that function.
if (getContext().BuiltinInfo.isLibFunction(BuiltinID) ||
getContext().BuiltinInfo.isPredefinedLibFunction(BuiltinID))
- return EmitCall(CGM.getBuiltinLibFunction(BuiltinID),
+ return EmitCall(CGM.getBuiltinLibFunction(BuiltinID),
E->getCallee()->getType(), E->arg_begin(),
E->arg_end());
-
+
// See if we have a target specific intrinsic.
const char *Name = getContext().BuiltinInfo.GetName(BuiltinID);
Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic;
if (const char *Prefix =
- llvm::Triple::getArchTypePrefix(Target.getTriple().getArch()))
+ llvm::Triple::getArchTypePrefix(Target.getTriple().getArch()))
IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix, Name);
-
+
if (IntrinsicID != Intrinsic::not_intrinsic) {
SmallVector<Value*, 16> Args;
-
+
Function *F = CGM.getIntrinsic(IntrinsicID);
const llvm::FunctionType *FTy = F->getFunctionType();
-
+
for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
Value *ArgValue = EmitScalarExpr(E->getArg(i));
-
+
// If the intrinsic arg type is different from the builtin arg type
// we need to do a bit cast.
const llvm::Type *PTy = FTy->getParamType(i);
@@ -584,36 +584,36 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
"Must be able to losslessly bit cast to param");
ArgValue = Builder.CreateBitCast(ArgValue, PTy);
}
-
+
Args.push_back(ArgValue);
}
-
+
Value *V = Builder.CreateCall(F, Args.data(), Args.data() + Args.size());
QualType BuiltinRetType = E->getType();
-
+
const llvm::Type *RetTy = llvm::Type::getVoidTy(VMContext);
if (!BuiltinRetType->isVoidType()) RetTy = ConvertType(BuiltinRetType);
-
+
if (RetTy != V->getType()) {
assert(V->getType()->canLosslesslyBitCastTo(RetTy) &&
"Must be able to losslessly bit cast result type");
V = Builder.CreateBitCast(V, RetTy);
}
-
+
return RValue::get(V);
}
-
+
// See if we have a target specific builtin that needs to be lowered.
if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E))
return RValue::get(V);
-
+
ErrorUnsupported(E, "builtin function");
-
+
// Unknown builtin, for now just dump it out and return undef.
if (hasAggregateLLVMType(E->getType()))
return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType())));
return RValue::get(llvm::UndefValue::get(ConvertType(E->getType())));
-}
+}
Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
@@ -629,9 +629,9 @@ Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID,
}
}
-Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
+Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
-
+
llvm::SmallVector<Value*, 4> Ops;
for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
@@ -639,9 +639,9 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
switch (BuiltinID) {
default: return 0;
- case X86::BI__builtin_ia32_pslldi128:
+ case X86::BI__builtin_ia32_pslldi128:
case X86::BI__builtin_ia32_psllqi128:
- case X86::BI__builtin_ia32_psllwi128:
+ case X86::BI__builtin_ia32_psllwi128:
case X86::BI__builtin_ia32_psradi128:
case X86::BI__builtin_ia32_psrawi128:
case X86::BI__builtin_ia32_psrldi128:
@@ -655,7 +655,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast");
const char *name = 0;
Intrinsic::ID ID = Intrinsic::not_intrinsic;
-
+
switch (BuiltinID) {
default: assert(0 && "Unsupported shift intrinsic!");
case X86::BI__builtin_ia32_pslldi128:
@@ -692,11 +692,11 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
break;
}
llvm::Function *F = CGM.getIntrinsic(ID);
- return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name);
+ return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name);
}
- case X86::BI__builtin_ia32_pslldi:
+ case X86::BI__builtin_ia32_pslldi:
case X86::BI__builtin_ia32_psllqi:
- case X86::BI__builtin_ia32_psllwi:
+ case X86::BI__builtin_ia32_psllwi:
case X86::BI__builtin_ia32_psradi:
case X86::BI__builtin_ia32_psrawi:
case X86::BI__builtin_ia32_psrldi:
@@ -707,7 +707,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
Ops[1] = Builder.CreateBitCast(Ops[1], Ty, "bitcast");
const char *name = 0;
Intrinsic::ID ID = Intrinsic::not_intrinsic;
-
+
switch (BuiltinID) {
default: assert(0 && "Unsupported shift intrinsic!");
case X86::BI__builtin_ia32_pslldi:
@@ -744,7 +744,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
break;
}
llvm::Function *F = CGM.getIntrinsic(ID);
- return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name);
+ return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name);
}
case X86::BI__builtin_ia32_cmpps: {
llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse_cmp_ps);
@@ -783,10 +783,10 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
const llvm::Type *EltTy = llvm::Type::getInt64Ty(VMContext);
llvm::Type *PtrTy = llvm::PointerType::getUnqual(EltTy);
llvm::Type *VecTy = llvm::VectorType::get(EltTy, 2);
-
+
// cast val v2i64
Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast");
-
+
// extract (0, 1)
unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1;
llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), Index);
@@ -799,9 +799,9 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
}
}
-Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
+Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
switch (BuiltinID) {
default: return 0;
}
-}
+}
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index f610de8276..e311912d95 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-// We might split this into multiple files if it gets too unwieldy
+// We might split this into multiple files if it gets too unwieldy
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
@@ -25,54 +25,54 @@
using namespace clang;
using namespace CodeGen;
-void
+void
CodeGenFunction::EmitCXXGlobalDtorRegistration(const CXXDestructorDecl *Dtor,
llvm::Constant *DeclPtr) {
// FIXME: This is ABI dependent and we use the Itanium ABI.
-
- const llvm::Type *Int8PtrTy =
+
+ const llvm::Type *Int8PtrTy =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
-
+
std::vector<const llvm::Type *> Params;
Params.push_back(Int8PtrTy);
-
+
// Get the destructor function type
- const llvm::Type *DtorFnTy =
+ const llvm::Type *DtorFnTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false);
DtorFnTy = llvm::PointerType::getUnqual(DtorFnTy);
-
+
Params.clear();
Params.push_back(DtorFnTy);
Params.push_back(Int8PtrTy);
Params.push_back(Int8PtrTy);
-
+
// Get the __cxa_atexit function type
// extern "C" int __cxa_atexit ( void (*f)(void *), void *p, void *d );
- const llvm::FunctionType *AtExitFnTy =
+ const llvm::FunctionType *AtExitFnTy =
llvm::FunctionType::get(ConvertType(getContext().IntTy), Params, false);
-
+
llvm::Constant *AtExitFn = CGM.CreateRuntimeFunction(AtExitFnTy,
"__cxa_atexit");
-
+
llvm::Constant *Handle = CGM.CreateRuntimeVariable(Int8PtrTy,
"__dso_handle");
-
+
llvm::Constant *DtorFn = CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete);
-
+
llvm::Value *Args[3] = { llvm::ConstantExpr::getBitCast(DtorFn, DtorFnTy),
llvm::ConstantExpr::getBitCast(DeclPtr, Int8PtrTy),
llvm::ConstantExpr::getBitCast(Handle, Int8PtrTy) };
Builder.CreateCall(AtExitFn, &Args[0], llvm::array_endof(Args));
}
-void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
+void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
llvm::Constant *DeclPtr) {
assert(D.hasGlobalStorage() &&
"VarDecl must have global storage!");
-
+
const Expr *Init = D.getInit();
QualType T = D.getType();
-
+
if (T->isReferenceType()) {
ErrorUnsupported(Init, "global variable that binds to a reference");
} else if (!hasAggregateLLVMType(T)) {
@@ -82,7 +82,7 @@ void CodeGenFunction::EmitCXXGlobalVarDeclInit(const VarDecl &D,
EmitComplexExprIntoAddr(Init, DeclPtr, T.isVolatileQualified());
} else {
EmitAggExpr(Init, DeclPtr, T.isVolatileQualified());
-
+
if (const RecordType *RT = T->getAs<RecordType>()) {
CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
if (!RD->hasTrivialDestructor())
@@ -95,16 +95,16 @@ void
CodeGenModule::EmitCXXGlobalInitFunc() {
if (CXXGlobalInits.empty())
return;
-
+
const llvm::FunctionType *FTy = llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
false);
-
+
// Create our global initialization function.
// FIXME: Should this be tweakable by targets?
- llvm::Function *Fn =
+ llvm::Function *Fn =
llvm::Function::Create(FTy, llvm::GlobalValue::InternalLinkage,
"__cxx_global_initialization", &TheModule);
-
+
CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn,
&CXXGlobalInits[0],
CXXGlobalInits.size());
@@ -114,20 +114,20 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
void CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn,
const VarDecl **Decls,
unsigned NumDecls) {
- StartFunction(0, getContext().VoidTy, Fn, FunctionArgList(),
+ StartFunction(0, getContext().VoidTy, Fn, FunctionArgList(),
SourceLocation());
-
+
for (unsigned i = 0; i != NumDecls; ++i) {
const VarDecl *D = Decls[i];
-
+
llvm::Constant *DeclPtr = CGM.GetAddrOfGlobalVar(D);
EmitCXXGlobalVarDeclInit(*D, DeclPtr);
}
FinishFunction();
}
-void
-CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
+void
+CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
llvm::GlobalVariable *GV) {
// FIXME: This should use __cxa_guard_{acquire,release}?
@@ -137,36 +137,36 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
llvm::SmallString<256> GuardVName;
llvm::raw_svector_ostream GuardVOut(GuardVName);
mangleGuardVariable(&D, getContext(), GuardVOut);
-
+
// Create the guard variable.
- llvm::GlobalValue *GuardV =
+ llvm::GlobalValue *GuardV =
new llvm::GlobalVariable(CGM.getModule(), llvm::Type::getInt64Ty(VMContext), false,
GV->getLinkage(),
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext)),
GuardVName.str());
-
+
// Load the first byte of the guard variable.
const llvm::Type *PtrTy = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
- llvm::Value *V = Builder.CreateLoad(Builder.CreateBitCast(GuardV, PtrTy),
+ llvm::Value *V = Builder.CreateLoad(Builder.CreateBitCast(GuardV, PtrTy),
"tmp");
-
+
// Compare it against 0.
llvm::Value *nullValue = llvm::Constant::getNullValue(llvm::Type::getInt8Ty(VMContext));
llvm::Value *ICmp = Builder.CreateICmpEQ(V, nullValue , "tobool");
-
+
llvm::BasicBlock *InitBlock = createBasicBlock("init");
llvm::BasicBlock *EndBlock = createBasicBlock("init.end");
// If the guard variable is 0, jump to the initializer code.
Builder.CreateCondBr(ICmp, InitBlock, EndBlock);
-
+
EmitBlock(InitBlock);
EmitCXXGlobalVarDeclInit(D, GV);
Builder.CreateStore(llvm::ConstantInt::get(llvm::Type::getInt8Ty(VMContext), 1),
Builder.CreateBitCast(GuardV, PtrTy));
-
+
EmitBlock(EndBlock);
}
@@ -175,25 +175,25 @@ RValue CodeGenFunction::EmitCXXMemberCall(const CXXMethodDecl *MD,
llvm::Value *This,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd) {
- assert(MD->isInstance() &&
+ assert(MD->isInstance() &&
"Trying to emit a member call expr on a static method!");
// A call to a trivial destructor requires no code generation.
if (const CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(MD))
if (Destructor->isTrivial())
return RValue::get(0);
-
+
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
-
+
CallArgList Args;
-
+
// Push the this ptr.
Args.push_back(std::make_pair(RValue::get(This),
MD->getThisType(getContext())));
-
+
// And the rest of the call args
EmitCallArgs(Args, FPT, ArgBeg, ArgEnd);
-
+
QualType ResultType = MD->getType()->getAsFunctionType()->getResultType();
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
Callee, Args, MD);
@@ -205,11 +205,11 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
- const llvm::Type *Ty =
- CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Value *This;
-
+
if (ME->isArrow())
This = EmitScalarExpr(ME->getBase());
else {
@@ -218,27 +218,27 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
}
// C++ [class.virtual]p12:
- // Explicit qualification with the scope operator (5.1) suppresses the
+ // Explicit qualification with the scope operator (5.1) suppresses the
// virtual call mechanism.
llvm::Value *Callee;
if (MD->isVirtual() && !ME->hasQualifier())
Callee = BuildVirtualCall(MD, This, Ty);
- else if (const CXXDestructorDecl *Destructor
+ else if (const CXXDestructorDecl *Destructor
= dyn_cast<CXXDestructorDecl>(MD))
Callee = CGM.GetAddrOfFunction(GlobalDecl(Destructor, Dtor_Complete), Ty);
else
Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
-
- return EmitCXXMemberCall(MD, Callee, This,
+
+ return EmitCXXMemberCall(MD, Callee, This,
CE->arg_begin(), CE->arg_end());
}
-RValue
+RValue
CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD) {
- assert(MD->isInstance() &&
+ assert(MD->isInstance() &&
"Trying to emit a member call expr on a static method!");
-
+
if (MD->isCopyAssignment()) {
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(MD->getDeclContext());
if (ClassDecl->hasTrivialCopyAssignment()) {
@@ -251,15 +251,15 @@ CodeGenFunction::EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
return RValue::get(This);
}
}
-
+
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
- const llvm::Type *Ty =
- CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
-
+
llvm::Value *This = EmitLValue(E->getArg(0)).getAddress();
-
+
return EmitCXXMemberCall(MD, Callee, This,
E->arg_begin() + 1, E->arg_end());
}
@@ -268,30 +268,30 @@ RValue
CodeGenFunction::EmitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *E) {
assert((E->getCastKind() == CastExpr::CK_UserDefinedConversion) &&
"EmitCXXFunctionalCastExpr - called with wrong cast");
-
+
CXXMethodDecl *MD = E->getTypeConversionMethod();
assert(MD && "EmitCXXFunctionalCastExpr - null conversion method");
assert(isa<CXXConversionDecl>(MD) && "EmitCXXFunctionalCastExpr - not"
" method decl");
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
-
- const llvm::Type *Ty =
- CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
llvm::Value *This = EmitLValue(E->getSubExpr()).getAddress();
RValue RV = EmitCXXMemberCall(MD, Callee, This, 0, 0);
if (RV.isAggregate())
- RV = RValue::get(RV.getAggregateAddr());
+ RV = RValue::get(RV.getAggregateAddr());
return RV;
}
llvm::Value *CodeGenFunction::LoadCXXThis() {
- assert(isa<CXXMethodDecl>(CurFuncDecl) &&
+ assert(isa<CXXMethodDecl>(CurFuncDecl) &&
"Must be in a C++ member function decl to load 'this'");
assert(cast<CXXMethodDecl>(CurFuncDecl)->isInstance() &&
"Must be in a C++ member function decl to load 'this'");
-
+
// FIXME: What if we're inside a block?
// ans: See how CodeGenFunction::LoadObjCSelf() uses
// CodeGenFunction::BlockForwardSelf() for how to do this.
@@ -306,7 +306,7 @@ GetNestedPaths(llvm::SmallVectorImpl<const CXXRecordDecl *> &NestedBasePaths,
e = ClassDecl->bases_end(); i != e; ++i) {
if (i->isVirtual())
continue;
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base == BaseClassDecl) {
NestedBasePaths.push_back(BaseClassDecl);
@@ -318,7 +318,7 @@ GetNestedPaths(llvm::SmallVectorImpl<const CXXRecordDecl *> &NestedBasePaths,
e = ClassDecl->bases_end(); i != e; ++i) {
if (i->isVirtual())
continue;
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (GetNestedPaths(NestedBasePaths, Base, BaseClassDecl)) {
NestedBasePaths.push_back(Base);
@@ -329,34 +329,34 @@ GetNestedPaths(llvm::SmallVectorImpl<const CXXRecordDecl *> &NestedBasePaths,
}
llvm::Value *CodeGenFunction::AddressCXXOfBaseClass(llvm::Value *BaseValue,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl) {
if (ClassDecl == BaseClassDecl)
return BaseValue;
-
+
llvm::Type *I8Ptr = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
llvm::SmallVector<const CXXRecordDecl *, 16> NestedBasePaths;
GetNestedPaths(NestedBasePaths, ClassDecl, BaseClassDecl);
- assert(NestedBasePaths.size() > 0 &&
+ assert(NestedBasePaths.size() > 0 &&
"AddressCXXOfBaseClass - inheritence path failed");
NestedBasePaths.push_back(ClassDecl);
uint64_t Offset = 0;
-
+
// Accessing a member of the base class. Must add delata to
// the load of 'this'.
for (unsigned i = NestedBasePaths.size()-1; i > 0; i--) {
const CXXRecordDecl *DerivedClass = NestedBasePaths[i];
const CXXRecordDecl *BaseClass = NestedBasePaths[i-1];
- const ASTRecordLayout &Layout =
+ const ASTRecordLayout &Layout =
getContext().getASTRecordLayout(DerivedClass);
Offset += Layout.getBaseClassOffset(BaseClass) / 8;
}
- llvm::Value *OffsetVal =
+ llvm::Value *OffsetVal =
llvm::ConstantInt::get(
CGM.getTypes().ConvertType(CGM.getContext().LongTy), Offset);
BaseValue = Builder.CreateBitCast(BaseValue, I8Ptr);
BaseValue = Builder.CreateGEP(BaseValue, OffsetVal, "add.ptr");
- QualType BTy =
+ QualType BTy =
getContext().getCanonicalType(
getContext().getTypeDeclType(const_cast<CXXRecordDecl*>(BaseClassDecl)));
const llvm::Type *BasePtr = ConvertType(BTy);
@@ -377,52 +377,52 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
llvm::Value *This) {
const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
assert(CA && "Do we support VLA for construction ?");
-
+
// Create a temporary for the loop index and initialize it with 0.
llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext),
"loop.index");
- llvm::Value* zeroConstant =
+ llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
Builder.CreateStore(zeroConstant, IndexPtr, false);
-
+
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
-
+
EmitBlock(CondBlock);
-
+
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
-
+
// Generate: if (loop-index < number-of-elements fall to the loop body,
// otherwise, go to the block after the for-loop.
uint64_t NumElements = getContext().getConstantArrayElementCount(CA);
- llvm::Value * NumElementsPtr =
+ llvm::Value * NumElementsPtr =
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
- llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
+ llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
"isless");
// If the condition is true, execute the body.
Builder.CreateCondBr(IsLess, ForBody, AfterFor);
-
+
EmitBlock(ForBody);
-
+
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
// Inside the loop body, emit the constructor call on the array element.
Counter = Builder.CreateLoad(IndexPtr);
llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
EmitCXXConstructorCall(D, Ctor_Complete, Address, 0, 0);
-
+
EmitBlock(ContinueBlock);
-
+
// Emit the increment of the loop counter.
llvm::Value *NextVal = llvm::ConstantInt::get(Counter->getType(), 1);
Counter = Builder.CreateLoad(IndexPtr);
NextVal = Builder.CreateAdd(Counter, NextVal, "inc");
Builder.CreateStore(NextVal, IndexPtr, false);
-
+
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
-
+
// Emit the fall-through block.
EmitBlock(AfterFor, true);
}
@@ -435,7 +435,7 @@ CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
llvm::Value *This) {
const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
assert(CA && "Do we support VLA for destruction ?");
- llvm::Value *One = llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext),
+ llvm::Value *One = llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext),
1);
uint64_t ElementCount = getContext().getConstantArrayElementCount(CA);
// Create a temporary for the loop index and initialize it with count of
@@ -443,54 +443,54 @@ CodeGenFunction::EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext),
"loop.index");
// Index = ElementCount;
- llvm::Value* UpperCount =
+ llvm::Value* UpperCount =
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), ElementCount);
Builder.CreateStore(UpperCount, IndexPtr, false);
-
+
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
-
+
EmitBlock(CondBlock);
-
+
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
-
+
// Generate: if (loop-index != 0 fall to the loop body,
// otherwise, go to the block after the for-loop.
- llvm::Value* zeroConstant =
+ llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
llvm::Value *IsNE = Builder.CreateICmpNE(Counter, zeroConstant,
"isne");
// If the condition is true, execute the body.
Builder.CreateCondBr(IsNE, ForBody, AfterFor);
-
+
EmitBlock(ForBody);
-
+
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
// Inside the loop body, emit the constructor call on the array element.
Counter = Builder.CreateLoad(IndexPtr);
Counter = Builder.CreateSub(Counter, One);
llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
EmitCXXDestructorCall(D, Dtor_Complete, Address);
-
+
EmitBlock(ContinueBlock);
-
+
// Emit the decrement of the loop counter.
Counter = Builder.CreateLoad(IndexPtr);
Counter = Builder.CreateSub(Counter, One, "dec");
Builder.CreateStore(Counter, IndexPtr, false);
-
+
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
-
+
// Emit the fall-through block.
EmitBlock(AfterFor, true);
}
void
-CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
- CXXCtorType Type,
+CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
+ CXXCtorType Type,
llvm::Value *This,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd) {
@@ -506,31 +506,31 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
return;
}
}
-
+
llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(D, Type);
EmitCXXMemberCall(D, Callee, This, ArgBeg, ArgEnd);
}
-void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *D,
+void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *D,
CXXDtorType Type,
llvm::Value *This) {
llvm::Value *Callee = CGM.GetAddrOfCXXDestructor(D, Type);
-
+
EmitCXXMemberCall(D, Callee, This, 0, 0);
}
-void
-CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
+void
+CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
const CXXConstructExpr *E) {
assert(Dest && "Must have a destination!");
-
- const CXXRecordDecl *RD =
+
+ const CXXRecordDecl *RD =
cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
if (RD->hasTrivialConstructor())
return;
- // Code gen optimization to eliminate copy constructor and return
+ // Code gen optimization to eliminate copy constructor and return
// its first argument instead.
if (getContext().getLangOptions().ElideConstructors && E->isElidable()) {
CXXConstructExpr::const_arg_iterator i = E->arg_begin();
@@ -538,7 +538,7 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
return;
}
// Call the constructor.
- EmitCXXConstructorCall(E->getConstructor(), Ctor_Complete, Dest,
+ EmitCXXConstructorCall(E->getConstructor(), Ctor_Complete, Dest,
E->arg_begin(), E->arg_end());
}
@@ -547,21 +547,21 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
ErrorUnsupported(E, "new[] expression");
return llvm::UndefValue::get(ConvertType(E->getType()));
}
-
+
QualType AllocType = E->getAllocatedType();
FunctionDecl *NewFD = E->getOperatorNew();
const FunctionProtoType *NewFTy = NewFD->getType()->getAsFunctionProtoType();
-
+
CallArgList NewArgs;
// The allocation size is the first argument.
QualType SizeTy = getContext().getSizeType();
- llvm::Value *AllocSize =
- llvm::ConstantInt::get(ConvertType(SizeTy),
+ llvm::Value *AllocSize =
+ llvm::ConstantInt::get(ConvertType(SizeTy),
getContext().getTypeSize(AllocType) / 8);
NewArgs.push_back(std::make_pair(RValue::get(AllocSize), SizeTy));
-
+
// Emit the rest of the arguments.
// FIXME: Ideally, this should just use EmitCallArgs.
CXXNewExpr::const_arg_iterator NewArg = E->placement_arg_begin();
@@ -571,24 +571,24 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
// has already been emitted.
for (unsigned i = 1, e = NewFTy->getNumArgs(); i != e; ++i, ++NewArg) {
QualType ArgType = NewFTy->getArgType(i);
-
+
assert(getContext().getCanonicalType(ArgType.getNonReferenceType()).
- getTypePtr() ==
- getContext().getCanonicalType(NewArg->getType()).getTypePtr() &&
+ getTypePtr() ==
+ getContext().getCanonicalType(NewArg->getType()).getTypePtr() &&
"type mismatch in call argument!");
-
- NewArgs.push_back(std::make_pair(EmitCallArg(*NewArg, ArgType),
+
+ NewArgs.push_back(std::make_pair(EmitCallArg(*NewArg, ArgType),
ArgType));
-
+
}
-
- // Either we've emitted all the call args, or we have a call to a
+
+ // Either we've emitted all the call args, or we have a call to a
// variadic function.
- assert((NewArg == E->placement_arg_end() || NewFTy->isVariadic()) &&
+ assert((NewArg == E->placement_arg_end() || NewFTy->isVariadic()) &&
"Extra arguments in non-variadic function!");
-
+
// If we still have any arguments, emit them using the type of the argument.
- for (CXXNewExpr::const_arg_iterator NewArgEnd = E->placement_arg_end();
+ for (CXXNewExpr::const_arg_iterator NewArgEnd = E->placement_arg_end();
NewArg != NewArgEnd; ++NewArg) {
QualType ArgType = NewArg->getType();
NewArgs.push_back(std::make_pair(EmitCallArg(*NewArg, ArgType),
@@ -596,7 +596,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
}
// Emit the call to new.
- RValue RV =
+ RValue RV =
EmitCall(CGM.getTypes().getFunctionInfo(NewFTy->getResultType(), NewArgs),
CGM.GetAddrOfFunction(GlobalDecl(NewFD)),
NewArgs, NewFD);
@@ -618,26 +618,26 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
NewNull = createBasicBlock("new.null");
NewNotNull = createBasicBlock("new.notnull");
NewEnd = createBasicBlock("new.end");
-
- llvm::Value *IsNull =
- Builder.CreateICmpEQ(NewPtr,
+
+ llvm::Value *IsNull =
+ Builder.CreateICmpEQ(NewPtr,
llvm::Constant::getNullValue(NewPtr->getType()),
"isnull");
-
+
Builder.CreateCondBr(IsNull, NewNull, NewNotNull);
EmitBlock(NewNotNull);
}
-
+
NewPtr = Builder.CreateBitCast(NewPtr, ConvertType(E->getType()));
-
+
if (AllocType->isPODType()) {
if (E->getNumConstructorArgs() > 0) {
- assert(E->getNumConstructorArgs() == 1 &&
+ assert(E->getNumConstructorArgs() == 1 &&
"Can only have one argument to initializer of POD type.");
const Expr *Init = E->getConstructorArg(0);
-
- if (!hasAggregateLLVMType(AllocType))
+
+ if (!hasAggregateLLVMType(AllocType))
Builder.CreateStore(EmitScalarExpr(Init), NewPtr);
else if (AllocType->isAnyComplexType())
EmitComplexExprIntoAddr(Init, NewPtr, AllocType.isVolatileQualified());
@@ -645,11 +645,11 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
EmitAggExpr(Init, NewPtr, AllocType.isVolatileQualified());
}
} else {
- // Call the constructor.
+ // Call the constructor.
CXXConstructorDecl *Ctor = E->getConstructor();
-
- EmitCXXConstructorCall(Ctor, Ctor_Complete, NewPtr,
- E->constructor_arg_begin(),
+
+ EmitCXXConstructorCall(Ctor, Ctor_Complete, NewPtr,
+ E->constructor_arg_begin(),
E->constructor_arg_end());
}
@@ -658,15 +658,15 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
EmitBlock(NewNull);
Builder.CreateBr(NewEnd);
EmitBlock(NewEnd);
-
+
llvm::PHINode *PHI = Builder.CreatePHI(NewPtr->getType());
PHI->reserveOperandSpace(2);
PHI->addIncoming(NewPtr, NewNotNull);
PHI->addIncoming(llvm::Constant::getNullValue(NewPtr->getType()), NewNull);
-
+
NewPtr = PHI;
}
-
+
return NewPtr;
}
@@ -676,22 +676,22 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
return;
};
- QualType DeleteTy =
+ QualType DeleteTy =
E->getArgument()->getType()->getAs<PointerType>()->getPointeeType();
-
+
llvm::Value *Ptr = EmitScalarExpr(E->getArgument());
-
+
// Null check the pointer.
llvm::BasicBlock *DeleteNotNull = createBasicBlock("delete.notnull");
llvm::BasicBlock *DeleteEnd = createBasicBlock("delete.end");
- llvm::Value *IsNull =
+ llvm::Value *IsNull =
Builder.CreateICmpEQ(Ptr, llvm::Constant::getNullValue(Ptr->getType()),
"isnull");
-
+
Builder.CreateCondBr(IsNull, DeleteEnd, DeleteNotNull);
EmitBlock(DeleteNotNull);
-
+
// Call the destructor if necessary.
if (const RecordType *RT = DeleteTy->getAs<RecordType>()) {
if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
@@ -701,29 +701,29 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
ErrorUnsupported(E, "delete expression with virtual destructor");
return;
}
-
+
EmitCXXDestructorCall(Dtor, Dtor_Complete, Ptr);
}
}
}
-
+
// Call delete.
FunctionDecl *DeleteFD = E->getOperatorDelete();
- const FunctionProtoType *DeleteFTy =
+ const FunctionProtoType *DeleteFTy =
DeleteFD->getType()->getAsFunctionProtoType();
-
+
CallArgList DeleteArgs;
QualType ArgTy = DeleteFTy->getArgType(0);
llvm::Value *DeletePtr = Builder.CreateBitCast(Ptr, ConvertType(ArgTy));
DeleteArgs.push_back(std::make_pair(RValue::get(DeletePtr), ArgTy));
-
+
// Emit the call to delete.
- EmitCall(CGM.getTypes().getFunctionInfo(DeleteFTy->getResultType(),
+ EmitCall(CGM.getTypes().getFunctionInfo(DeleteFTy->getResultType(),
DeleteArgs),
CGM.GetAddrOfFunction(GlobalDecl(DeleteFD)),
DeleteArgs, DeleteFD);
-
+
EmitBlock(DeleteEnd);
}
@@ -732,34 +732,34 @@ void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {
EmitGlobal(GlobalDecl(D, Ctor_Base));
}
-void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *D,
+void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *D,
CXXCtorType Type) {
-
+
llvm::Function *Fn = GetAddrOfCXXConstructor(D, Type);
-
+
CodeGenFunction(*this).GenerateCode(D, Fn);
-
+
SetFunctionDefinitionAttributes(D, Fn);
SetLLVMFunctionAttributesForDefinition(D, Fn);
}
llvm::Function *
-CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
+CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
CXXCtorType Type) {
const llvm::FunctionType *FTy =
getTypes().GetFunctionType(getTypes().getFunctionInfo(D), false);
-
+
const char *Name = getMangledCXXCtorName(D, Type);
return cast<llvm::Function>(
GetOrCreateLLVMFunction(Name, FTy, GlobalDecl(D, Type)));
}
-const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D,
+const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D,
CXXCtorType Type) {
llvm::SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
mangleCXXCtor(D, Type, Context, Out);
-
+
Name += '\0';
return UniqueMangledName(Name.begin(), Name.end());
}
@@ -769,33 +769,33 @@ void CodeGenModule::EmitCXXDestructors(const CXXDestructorDecl *D) {
EmitCXXDestructor(D, Dtor_Base);
}
-void CodeGenModule::EmitCXXDestructor(const CXXDestructorDecl *D,
+void CodeGenModule::EmitCXXDestructor(const CXXDestructorDecl *D,
CXXDtorType Type) {
llvm::Function *Fn = GetAddrOfCXXDestructor(D, Type);
-
+
CodeGenFunction(*this).GenerateCode(D, Fn);
-
+
SetFunctionDefinitionAttributes(D, Fn);
SetLLVMFunctionAttributesForDefinition(D, Fn);
}
llvm::Function *
-CodeGenModule::GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
+CodeGenModule::GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
CXXDtorType Type) {
const llvm::FunctionType *FTy =
getTypes().GetFunctionType(getTypes().getFunctionInfo(D), false);
-
+
const char *Name = getMangledCXXDtorName(D, Type);
return cast<llvm::Function>(
GetOrCreateLLVMFunction(Name, FTy, GlobalDecl(D, Type)));
}
-const char *CodeGenModule::getMangledCXXDtorName(const CXXDestructorDecl *D,
+const char *CodeGenModule::getMangledCXXDtorName(const CXXDestructorDecl *D,
CXXDtorType Type) {
llvm::SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
mangleCXXDtor(D, Type, Context, Out);
-
+
Name += '\0';
return UniqueMangledName(Name.begin(), Name.end());
}
@@ -891,7 +891,7 @@ public:
const CXXRecordDecl *RD, uint64_t Offset) {
for (CXXRecordDecl::base_class_const_iterator i =RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (i->isVirtual() && !SeenVBase.count(Base)) {
SeenVBase.insert(Base);
@@ -998,7 +998,7 @@ public:
// If we can find a previously allocated slot for this, reuse it.
if (OverrideMethod(MD, m, MorallyVirtual, Offset))
return;
-
+
// else allocate a new slot.
Index[MD] = submethods.size();
submethods.push_back(m);
@@ -1029,7 +1029,7 @@ public:
e = RD->bases_end(); i != e; ++i) {
if (i->isVirtual())
continue;
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base != PrimaryBase || PrimaryBaseWasVirtual) {
uint64_t o = Offset + Layout.getBaseClassOffset(Base);
@@ -1090,7 +1090,7 @@ public:
return;
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
- const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
+ const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
const bool PrimaryBaseWasVirtual = Layout.getPrimaryBaseWasVirtual();
// vtables are composed from the chain of primaries.
@@ -1113,7 +1113,7 @@ public:
return 0;
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
- const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
+ const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
const bool PrimaryBaseWasVirtual = Layout.getPrimaryBaseWasVirtual();
std::vector<llvm::Constant *> offsets;
@@ -1154,7 +1154,7 @@ public:
Path->push_back(std::make_pair(RD, Offset));
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
+ const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (i->isVirtual() && !IndirectPrimary.count(Base)) {
// Mark it so we don't output it twice.
@@ -1306,7 +1306,7 @@ llvm::Value *
CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
const llvm::Type *Ty) {
// FIXME: If we know the dynamic type, we don't have to do a virtual dispatch.
-
+
// FIXME: move to Context
if (vtableinfo == 0)
vtableinfo = new VtableInfo(CGM);
@@ -1328,39 +1328,39 @@ CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
/// array of objects from SrcValue to DestValue. Copying can be either a bitwise
/// copy or via a copy constructor call.
// FIXME. Consolidate this with EmitCXXAggrConstructorCall.
-void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
+void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
llvm::Value *Src,
const ArrayType *Array,
- const CXXRecordDecl *BaseClassDecl,
+ const CXXRecordDecl *BaseClassDecl,
QualType Ty) {
const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
assert(CA && "VLA cannot be copied over");
bool BitwiseCopy = BaseClassDecl->hasTrivialCopyConstructor();
-
+
// Create a temporary for the loop index and initialize it with 0.
llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext),
"loop.index");
- llvm::Value* zeroConstant =
+ llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
Builder.CreateStore(zeroConstant, IndexPtr, false);
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
-
+
EmitBlock(CondBlock);
-
+
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
// Generate: if (loop-index < number-of-elements fall to the loop body,
// otherwise, go to the block after the for-loop.
uint64_t NumElements = getContext().getConstantArrayElementCount(CA);
- llvm::Value * NumElementsPtr =
+ llvm::Value * NumElementsPtr =
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
- llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
+ llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
"isless");
// If the condition is true, execute the body.
Builder.CreateCondBr(IsLess, ForBody, AfterFor);
-
+
EmitBlock(ForBody);
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
// Inside the loop body, emit the constructor call on the array element.
@@ -1369,75 +1369,75 @@ void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
Dest = Builder.CreateInBoundsGEP(Dest, Counter, "destaddress");
if (BitwiseCopy)
EmitAggregateCopy(Dest, Src, Ty);
- else if (CXXConstructorDecl *BaseCopyCtor =
+ else if (CXXConstructorDecl *BaseCopyCtor =
BaseClassDecl->getCopyConstructor(getContext(), 0)) {
- llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(BaseCopyCtor,
+ llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(BaseCopyCtor,
Ctor_Complete);
CallArgList CallArgs;
// Push the this (Dest) ptr.
CallArgs.push_back(std::make_pair(RValue::get(Dest),
BaseCopyCtor->getThisType(getContext())));
-
+
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
BaseCopyCtor->getParamDecl(0)->getType()));
- QualType ResultType =
+ QualType ResultType =
BaseCopyCtor->getType()->getAsFunctionType()->getResultType();
EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
Callee, CallArgs, BaseCopyCtor);
}
EmitBlock(ContinueBlock);
-
+
// Emit the increment of the loop counter.
llvm::Value *NextVal = llvm::ConstantInt::get(Counter->getType(), 1);
Counter = Builder.CreateLoad(IndexPtr);
NextVal = Builder.CreateAdd(Counter, NextVal, "inc");
Builder.CreateStore(NextVal, IndexPtr, false);
-
+
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
-
+
// Emit the fall-through block.
EmitBlock(AfterFor, true);
}
/// EmitClassAggrCopyAssignment - This routine generates code to assign a class
-/// array of objects from SrcValue to DestValue. Assignment can be either a
+/// array of objects from SrcValue to DestValue. Assignment can be either a
/// bitwise assignment or via a copy assignment operator function call.
/// FIXME. This can be consolidated with EmitClassAggrMemberwiseCopy
-void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
+void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
llvm::Value *Src,
const ArrayType *Array,
- const CXXRecordDecl *BaseClassDecl,
+ const CXXRecordDecl *BaseClassDecl,
QualType Ty) {
const ConstantArrayType *CA = dyn_cast<ConstantArrayType>(Array);
assert(CA && "VLA cannot be asssigned");
bool BitwiseAssign = BaseClassDecl->hasTrivialCopyAssignment();
-
+
// Create a temporary for the loop index and initialize it with 0.
llvm::Value *IndexPtr = CreateTempAlloca(llvm::Type::getInt64Ty(VMContext),
"loop.index");
- llvm::Value* zeroConstant =
+ llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
Builder.CreateStore(zeroConstant, IndexPtr, false);
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
-
+
EmitBlock(CondBlock);
-
+
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
// Generate: if (loop-index < number-of-elements fall to the loop body,
// otherwise, go to the block after the for-loop.
uint64_t NumElements = getContext().getConstantArrayElementCount(CA);
- llvm::Value * NumElementsPtr =
+ llvm::Value * NumElementsPtr =
llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
- llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
+ llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr,
"isless");
// If the condition is true, execute the body.
Builder.CreateCondBr(IsLess, ForBody, AfterFor);
-
+
EmitBlock(ForBody);
llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
// Inside the loop body, emit the assignment operator call on array element.
@@ -1457,12 +1457,12 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), LTy);
-
+
CallArgList CallArgs;
// Push the this (Dest) ptr.
CallArgs.push_back(std::make_pair(RValue::get(Dest),
MD->getThisType(getContext())));
-
+
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
MD->getParamDecl(0)->getType()));
@@ -1471,16 +1471,16 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
Callee, CallArgs, MD);
}
EmitBlock(ContinueBlock);
-
+
// Emit the increment of the loop counter.
llvm::Value *NextVal = llvm::ConstantInt::get(Counter->getType(), 1);
Counter = Builder.CreateLoad(IndexPtr);
NextVal = Builder.CreateAdd(Counter, NextVal, "inc");
Builder.CreateStore(NextVal, IndexPtr, false);
-
+
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
-
+
// Emit the fall-through block.
EmitBlock(AfterFor, true);
}
@@ -1490,7 +1490,7 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
/// or via a copy constructor call.
void CodeGenFunction::EmitClassMemberwiseCopy(
llvm::Value *Dest, llvm::Value *Src,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl, QualType Ty) {
if (ClassDecl) {
Dest = AddressCXXOfBaseClass(Dest, ClassDecl, BaseClassDecl);
@@ -1500,20 +1500,20 @@ void CodeGenFunction::EmitClassMemberwiseCopy(
EmitAggregateCopy(Dest, Src, Ty);
return;
}
-
- if (CXXConstructorDecl *BaseCopyCtor =
+
+ if (CXXConstructorDecl *BaseCopyCtor =
BaseClassDecl->getCopyConstructor(getContext(), 0)) {
- llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(BaseCopyCtor,
+ llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(BaseCopyCtor,
Ctor_Complete);
CallArgList CallArgs;
// Push the this (Dest) ptr.
CallArgs.push_back(std::make_pair(RValue::get(Dest),
BaseCopyCtor->getThisType(getContext())));
-
+
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
BaseCopyCtor->getParamDecl(0)->getType()));
- QualType ResultType =
+ QualType ResultType =
BaseCopyCtor->getType()->getAsFunctionType()->getResultType();
EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
Callee, CallArgs, BaseCopyCtor);
@@ -1521,13 +1521,13 @@ void CodeGenFunction::EmitClassMemberwiseCopy(
}
/// EmitClassCopyAssignment - This routine generates code to copy assign a class
-/// object from SrcValue to DestValue. Assignment can be either a bitwise
+/// object from SrcValue to DestValue. Assignment can be either a bitwise
/// assignment of via an assignment operator call.
// FIXME. Consolidate this with EmitClassMemberwiseCopy as they share a lot.
void CodeGenFunction::EmitClassCopyAssignment(
llvm::Value *Dest, llvm::Value *Src,
- const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl,
+ const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *BaseClassDecl,
QualType Ty) {
if (ClassDecl) {
Dest = AddressCXXOfBaseClass(Dest, ClassDecl, BaseClassDecl);
@@ -1537,35 +1537,35 @@ void CodeGenFunction::EmitClassCopyAssignment(
EmitAggregateCopy(Dest, Src, Ty);
return;
}
-
+
const CXXMethodDecl *MD = 0;
- bool ConstCopyAssignOp = BaseClassDecl->hasConstCopyAssignment(getContext(),
+ bool ConstCopyAssignOp = BaseClassDecl->hasConstCopyAssignment(getContext(),
MD);
assert(ConstCopyAssignOp && "EmitClassCopyAssignment - missing copy assign");
(void)ConstCopyAssignOp;
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
- const llvm::Type *LTy =
- CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ const llvm::Type *LTy =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Constant *Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), LTy);
-
+
CallArgList CallArgs;
// Push the this (Dest) ptr.
CallArgs.push_back(std::make_pair(RValue::get(Dest),
MD->getThisType(getContext())));
-
+
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
MD->getParamDecl(0)->getType()));
- QualType ResultType =
+ QualType ResultType =
MD->getType()->getAsFunctionType()->getResultType();
EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
Callee, CallArgs, MD);
}
/// SynthesizeDefaultConstructor - synthesize a default constructor
-void
+void
CodeGenFunction::SynthesizeDefaultConstructor(const CXXConstructorDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
@@ -1577,18 +1577,18 @@ CodeGenFunction::SynthesizeDefaultConstructor(const CXXConstructorDecl *CD,
/// SynthesizeCXXCopyConstructor - This routine implicitly defines body of a copy
/// constructor, in accordance with section 12.8 (p7 and p8) of C++03
-/// The implicitly-defined copy constructor for class X performs a memberwise
-/// copy of its subobjects. The order of copying is the same as the order
+/// The implicitly-defined copy constructor for class X performs a memberwise
+/// copy of its subobjects. The order of copying is the same as the order
/// of initialization of bases and members in a user-defined constructor
/// Each subobject is copied in the manner appropriate to its type:
-/// if the subobject is of class type, the copy constructor for the class is
+/// if the subobject is of class type, the copy constructor for the class is
/// used;
-/// if the subobject is an array, each element is copied, in the manner
+/// if the subobject is an array, each element is copied, in the manner
/// appropriate to the element type;
-/// if the subobject is of scalar type, the built-in assignment operator is
+/// if the subobject is of scalar type, the built-in assignment operator is
/// used.
-/// Virtual base class subobjects shall be copied only once by the
-/// implicitly-defined copy constructor
+/// Virtual base class subobjects shall be copied only once by the
+/// implicitly-defined copy constructor
void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
const FunctionDecl *FD,
@@ -1598,7 +1598,7 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
assert(!ClassDecl->hasUserDeclaredCopyConstructor() &&
"SynthesizeCXXCopyConstructor - copy constructor has definition already");
StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
-
+
FunctionArgList::const_iterator i = Args.begin();
const VarDecl *ThisArg = i->first;
llvm::Value *ThisObj = GetAddrOfLocalVar(ThisArg);
@@ -1606,28 +1606,28 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
const VarDecl *SrcArg = (i+1)->first;
llvm::Value *SrcObj = GetAddrOfLocalVar(SrcArg);
llvm::Value *LoadOfSrc = Builder.CreateLoad(SrcObj);
-
+
for (CXXRecordDecl::base_class_const_iterator Base = ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
// FIXME. copy constrution of virtual base NYI
if (Base->isVirtual())
continue;
-
+
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
EmitClassMemberwiseCopy(LoadOfThis, LoadOfSrc, ClassDecl, BaseClassDecl,
Base->getType());
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
QualType FieldType = getContext().getCanonicalType((*Field)->getType());
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
-
+
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
@@ -1636,15 +1636,15 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
if (Array) {
const llvm::Type *BasePtr = ConvertType(FieldType);
BasePtr = llvm::PointerType::getUnqual(BasePtr);
- llvm::Value *DestBaseAddrPtr =
+ llvm::Value *DestBaseAddrPtr =
Builder.CreateBitCast(LHS.getAddress(), BasePtr);
- llvm::Value *SrcBaseAddrPtr =
+ llvm::Value *SrcBaseAddrPtr =
Builder.CreateBitCast(RHS.getAddress(), BasePtr);
EmitClassAggrMemberwiseCopy(DestBaseAddrPtr, SrcBaseAddrPtr, Array,
FieldClassDecl, FieldType);
}
- else
- EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(),
+ else
+ EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(),
0 /*ClassDecl*/, FieldClassDecl, FieldType);
continue;
}
@@ -1655,27 +1655,27 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
EmitStoreThroughLValue(RVRHS, LHS, FieldType);
}
FinishFunction();
-}
+}
/// SynthesizeCXXCopyAssignment - Implicitly define copy assignment operator.
-/// Before the implicitly-declared copy assignment operator for a class is
-/// implicitly defined, all implicitly- declared copy assignment operators for
-/// its direct base classes and its nonstatic data members shall have been
+/// Before the implicitly-declared copy assignment operator for a class is
+/// implicitly defined, all implicitly- declared copy assignment operators for
+/// its direct base classes and its nonstatic data members shall have been
/// implicitly defined. [12.8-p12]
-/// The implicitly-defined copy assignment operator for class X performs
-/// memberwise assignment of its subob- jects. The direct base classes of X are
-/// assigned first, in the order of their declaration in
-/// the base-specifier-list, and then the immediate nonstatic data members of X
-/// are assigned, in the order in which they were declared in the class
+/// The implicitly-defined copy assignment operator for class X performs
+/// memberwise assignment of its subob- jects. The direct base classes of X are
+/// assigned first, in the order of their declaration in
+/// the base-specifier-list, and then the immediate nonstatic data members of X
+/// are assigned, in the order in which they were declared in the class
/// definition.Each subobject is assigned in the manner appropriate to its type:
-/// if the subobject is of class type, the copy assignment operator for the
-/// class is used (as if by explicit qualification; that is, ignoring any
+/// if the subobject is of class type, the copy assignment operator for the
+/// class is used (as if by explicit qualification; that is, ignoring any
/// possible virtual overriding functions in more derived classes);
///
-/// if the subobject is an array, each element is assigned, in the manner
+/// if the subobject is an array, each element is assigned, in the manner
/// appropriate to the element type;
///
-/// if the subobject is of scalar type, the built-in assignment operator is
+/// if the subobject is of scalar type, the built-in assignment operator is
/// used.
void CodeGenFunction::SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
const FunctionDecl *FD,
@@ -1686,7 +1686,7 @@ void CodeGenFunction::SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
assert(!ClassDecl->hasUserDeclaredCopyAssignment() &&
"SynthesizeCXXCopyAssignment - copy assignment has user declaration");
StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
-
+
FunctionArgList::const_iterator i = Args.begin();
const VarDecl *ThisArg = i->first;
llvm::Value *ThisObj = GetAddrOfLocalVar(ThisArg);
@@ -1694,28 +1694,28 @@ void CodeGenFunction::SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
const VarDecl *SrcArg = (i+1)->first;
llvm::Value *SrcObj = GetAddrOfLocalVar(SrcArg);
llvm::Value *LoadOfSrc = Builder.CreateLoad(SrcObj);
-
+
for (CXXRecordDecl::base_class_const_iterator Base = ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
// FIXME. copy assignment of virtual base NYI
if (Base->isVirtual())
continue;
-
+
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
EmitClassCopyAssignment(LoadOfThis, LoadOfSrc, ClassDecl, BaseClassDecl,
Base->getType());
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
QualType FieldType = getContext().getCanonicalType((*Field)->getType());
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
-
+
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
@@ -1732,7 +1732,7 @@ void CodeGenFunction::SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
FieldClassDecl, FieldType);
}
else
- EmitClassCopyAssignment(LHS.getAddress(), RHS.getAddress(),
+ EmitClassCopyAssignment(LHS.getAddress(), RHS.getAddress(),
0 /*ClassDecl*/, FieldClassDecl, FieldType);
continue;
}
@@ -1742,12 +1742,12 @@ void CodeGenFunction::SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
RValue RVRHS = EmitLoadOfLValue(RHS, FieldType);
EmitStoreThroughLValue(RVRHS, LHS, FieldType);
}
-
+
// return *this;
Builder.CreateStore(LoadOfThis, ReturnValue);
-
+
FinishFunction();
-}
+}
/// EmitCtorPrologue - This routine generates necessary code to initialize
/// base classes and non-static data members belonging to this constructor.
@@ -1756,7 +1756,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(CD->getDeclContext());
// FIXME: Add vbase initialization
llvm::Value *LoadOfThis = 0;
-
+
for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(),
E = CD->init_end();
B != E; ++B) {
@@ -1764,23 +1764,23 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
if (Member->isBaseInitializer()) {
LoadOfThis = LoadCXXThis();
Type *BaseType = Member->getBaseClass();
- CXXRecordDecl *BaseClassDecl =
+ CXXRecordDecl *BaseClassDecl =
cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
- llvm::Value *V = AddressCXXOfBaseClass(LoadOfThis, ClassDecl,
+ llvm::Value *V = AddressCXXOfBaseClass(LoadOfThis, ClassDecl,
BaseClassDecl);
EmitCXXConstructorCall(Member->getConstructor(),
Ctor_Complete, V,
- Member->const_arg_begin(),
+ Member->const_arg_begin(),
Member->const_arg_end());
} else {
// non-static data member initilaizers.
FieldDecl *Field = Member->getMember();
QualType FieldType = getContext().getCanonicalType((Field)->getType());
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
-
+
LoadOfThis = LoadCXXThis();
LValue LHS;
if (FieldType->isReferenceType()) {
@@ -1794,32 +1794,32 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
}
if (FieldType->getAs<RecordType>()) {
if (!Field->isAnonymousStructOrUnion()) {
- assert(Member->getConstructor() &&
+ assert(Member->getConstructor() &&
"EmitCtorPrologue - no constructor to initialize member");
if (Array) {
const llvm::Type *BasePtr = ConvertType(FieldType);
BasePtr = llvm::PointerType::getUnqual(BasePtr);
- llvm::Value *BaseAddrPtr =
+ llvm::Value *BaseAddrPtr =
Builder.CreateBitCast(LHS.getAddress(), BasePtr);
- EmitCXXAggrConstructorCall(Member->getConstructor(),
+ EmitCXXAggrConstructorCall(Member->getConstructor(),
Array, BaseAddrPtr);
}
else
EmitCXXConstructorCall(Member->getConstructor(),
Ctor_Complete, LHS.getAddress(),
- Member->const_arg_begin(),
+ Member->const_arg_begin(),
Member->const_arg_end());
continue;
}
else {
// Initializing an anonymous union data member.
FieldDecl *anonMember = Member->getAnonUnionMember();
- LHS = EmitLValueForField(LHS.getAddress(), anonMember,
+ LHS = EmitLValueForField(LHS.getAddress(), anonMember,
/*IsUnion=*/true, 0);
FieldType = anonMember->getType();
}
}
-
+
assert(Member->getNumArgs() == 1 && "Initializer count must be 1 only");
Expr *RhsExpr = *Member->arg_begin();
RValue RHS;
@@ -1834,20 +1834,20 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
if (!CD->getNumBaseOrMemberInitializers() && !CD->isTrivial()) {
// Nontrivial default constructor with no initializer list. It may still
- // have bases classes and/or contain non-static data members which require
+ // have bases classes and/or contain non-static data members which require
// construction.
- for (CXXRecordDecl::base_class_const_iterator Base =
+ for (CXXRecordDecl::base_class_const_iterator Base =
ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
// FIXME. copy assignment of virtual base NYI
if (Base->isVirtual())
continue;
-
+
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (BaseClassDecl->hasTrivialConstructor())
continue;
- if (CXXConstructorDecl *BaseCX =
+ if (CXXConstructorDecl *BaseCX =
BaseClassDecl->getDefaultConstructor(getContext())) {
LoadOfThis = LoadCXXThis();
llvm::Value *V = AddressCXXOfBaseClass(LoadOfThis, ClassDecl,
@@ -1855,40 +1855,40 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
EmitCXXConstructorCall(BaseCX, Ctor_Complete, V, 0, 0);
}
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
QualType FieldType = getContext().getCanonicalType((*Field)->getType());
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
if (!FieldType->getAs<RecordType>() || Field->isAnonymousStructOrUnion())
continue;
const RecordType *ClassRec = FieldType->getAs<RecordType>();
- CXXRecordDecl *MemberClassDecl =
+ CXXRecordDecl *MemberClassDecl =
dyn_cast<CXXRecordDecl>(ClassRec->getDecl());
if (!MemberClassDecl || MemberClassDecl->hasTrivialConstructor())
continue;
- if (CXXConstructorDecl *MamberCX =
+ if (CXXConstructorDecl *MamberCX =
MemberClassDecl->getDefaultConstructor(getContext())) {
LoadOfThis = LoadCXXThis();
LValue LHS = EmitLValueForField(LoadOfThis, *Field, false, 0);
if (Array) {
const llvm::Type *BasePtr = ConvertType(FieldType);
BasePtr = llvm::PointerType::getUnqual(BasePtr);
- llvm::Value *BaseAddrPtr =
+ llvm::Value *BaseAddrPtr =
Builder.CreateBitCast(LHS.getAddress(), BasePtr);
EmitCXXAggrConstructorCall(MamberCX, Array, BaseAddrPtr);
}
else
- EmitCXXConstructorCall(MamberCX, Ctor_Complete, LHS.getAddress(),
+ EmitCXXConstructorCall(MamberCX, Ctor_Complete, LHS.getAddress(),
0, 0);
}
}
}
-
+
// Initialize the vtable pointer
if (ClassDecl->isDynamicClass()) {
if (!LoadOfThis)
@@ -1904,7 +1904,7 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
}
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
-/// destructor. This is to call destructors on members and base classes
+/// destructor. This is to call destructors on members and base classes
/// in reverse order of their construction.
/// FIXME: This needs to take a CXXDtorType.
void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
@@ -1912,14 +1912,14 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
assert(!ClassDecl->getNumVBases() &&
"FIXME: Destruction of virtual bases not supported");
(void)ClassDecl; // prevent warning.
-
+
for (CXXDestructorDecl::destr_const_iterator *B = DD->destr_begin(),
*E = DD->destr_end(); B != E; ++B) {
uintptr_t BaseOrMember = (*B);
if (DD->isMemberToDestroy(BaseOrMember)) {
FieldDecl *FD = DD->getMemberToDestroy(BaseOrMember);
QualType FieldType = getContext().getCanonicalType((FD)->getType());
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
@@ -1932,9 +1932,9 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
if (Array) {
const llvm::Type *BasePtr = ConvertType(FieldType);
BasePtr = llvm::PointerType::getUnqual(BasePtr);
- llvm::Value *BaseAddrPtr =
+ llvm::Value *BaseAddrPtr =
Builder.CreateBitCast(LHS.getAddress(), BasePtr);
- EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()),
+ EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()),
Array, BaseAddrPtr);
}
else
@@ -1946,7 +1946,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(RT->getDecl());
if (BaseClassDecl->hasTrivialDestructor())
continue;
- llvm::Value *V = AddressCXXOfBaseClass(LoadCXXThis(),
+ llvm::Value *V = AddressCXXOfBaseClass(LoadCXXThis(),
ClassDecl,BaseClassDecl);
EmitCXXDestructorCall(BaseClassDecl->getDestructor(getContext()),
Dtor_Complete, V);
@@ -1955,10 +1955,10 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
if (DD->getNumBaseOrMemberDestructions() || DD->isTrivial())
return;
// Case of destructor synthesis with fields and base classes
- // which have non-trivial destructors. They must be destructed in
+ // which have non-trivial destructors. They must be destructed in
// reverse order of their construction.
llvm::SmallVector<FieldDecl *, 16> DestructedFields;
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -1976,7 +1976,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
for (int i = DestructedFields.size() -1; i >= 0; --i) {
FieldDecl *Field = DestructedFields[i];
QualType FieldType = Field->getType();
- const ConstantArrayType *Array =
+ const ConstantArrayType *Array =
getContext().getAsConstantArrayType(FieldType);
if (Array)
FieldType = getContext().getBaseElementType(FieldType);
@@ -1987,23 +1987,23 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
if (Array) {
const llvm::Type *BasePtr = ConvertType(FieldType);
BasePtr = llvm::PointerType::getUnqual(BasePtr);
- llvm::Value *BaseAddrPtr =
+ llvm::Value *BaseAddrPtr =
Builder.CreateBitCast(LHS.getAddress(), BasePtr);
- EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()),
+ EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()),
Array, BaseAddrPtr);
}
else
EmitCXXDestructorCall(FieldClassDecl->getDestructor(getContext()),
Dtor_Complete, LHS.getAddress());
}
-
+
llvm::SmallVector<CXXRecordDecl*, 4> DestructedBases;
for (CXXRecordDecl::base_class_const_iterator Base = ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
// FIXME. copy assignment of virtual base NYI
if (Base->isVirtual())
continue;
-
+
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (BaseClassDecl->hasTrivialDestructor())
@@ -2014,7 +2014,7 @@ void CodeGenFunction::EmitDtorEpilogue(const CXXDestructorDecl *DD) {
return;
for (int i = DestructedBases.size() -1; i >= 0; --i) {
CXXRecordDecl *BaseClassDecl = DestructedBases[i];
- llvm::Value *V = AddressCXXOfBaseClass(LoadCXXThis(),
+ llvm::Value *V = AddressCXXOfBaseClass(LoadCXXThis(),
ClassDecl,BaseClassDecl);
EmitCXXDestructorCall(BaseClassDecl->getDestructor(getContext()),
Dtor_Complete, V);
@@ -2025,13 +2025,13 @@ void CodeGenFunction::SynthesizeDefaultDestructor(const CXXDestructorDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
const FunctionArgList &Args) {
-
+
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(CD->getDeclContext());
assert(!ClassDecl->hasUserDeclaredDestructor() &&
"SynthesizeDefaultDestructor - destructor has user declaration");
(void) ClassDecl;
-
+
StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
EmitDtorEpilogue(CD);
FinishFunction();
-}
+}
diff --git a/lib/CodeGen/CGCXX.h b/lib/CodeGen/CGCXX.h
index 6051d9133c..1e6adb05a0 100644
--- a/lib/CodeGen/CGCXX.h
+++ b/lib/CodeGen/CGCXX.h
@@ -30,7 +30,7 @@ enum CXXDtorType {
Dtor_Complete, // Complete object dtor
Dtor_Base // Base object dtor
};
-
+
} // end namespace clang
#endif // CLANG_CODEGEN_CGCXX_H
diff --git a/lib/CodeGen/CGCXXTemp.cpp b/lib/CodeGen/CGCXXTemp.cpp
index 30de1115c0..fbb2b9f719 100644
--- a/lib/CodeGen/CGCXXTemp.cpp
+++ b/lib/CodeGen/CGCXXTemp.cpp
@@ -15,20 +15,20 @@
using namespace clang;
using namespace CodeGen;
-void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary,
+void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary,
llvm::Value *Ptr) {
llvm::BasicBlock *DtorBlock = createBasicBlock("temp.dtor");
-
+
llvm::Value *CondPtr = 0;
-
- // Check if temporaries need to be conditional. If so, we'll create a
- // condition boolean, initialize it to 0 and
+
+ // Check if temporaries need to be conditional. If so, we'll create a
+ // condition boolean, initialize it to 0 and
if (!ConditionalTempDestructionStack.empty()) {
CondPtr = CreateTempAlloca(llvm::Type::getInt1Ty(VMContext), "cond");
-
+
// Initialize it to false. This initialization takes place right after
// the alloca insert point.
- llvm::StoreInst *SI =
+ llvm::StoreInst *SI =
new llvm::StoreInst(llvm::ConstantInt::getFalse(VMContext), CondPtr);
llvm::BasicBlock *Block = AllocaInsertPt->getParent();
Block->getInstList().insertAfter((llvm::Instruction *)AllocaInsertPt, SI);
@@ -36,8 +36,8 @@ void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary,
// Now set it to true.
Builder.CreateStore(llvm::ConstantInt::getTrue(VMContext), CondPtr);
}
-
- LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, DtorBlock,
+
+ LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, DtorBlock,
CondPtr));
PushCleanupBlock(DtorBlock);
@@ -45,15 +45,15 @@ void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary,
void CodeGenFunction::PopCXXTemporary() {
const CXXLiveTemporaryInfo& Info = LiveTemporaries.back();
-
+
CleanupBlockInfo CleanupInfo = PopCleanupBlock();
- assert(CleanupInfo.CleanupBlock == Info.DtorBlock &&
+ assert(CleanupInfo.CleanupBlock == Info.DtorBlock &&
"Cleanup block mismatch!");
- assert(!CleanupInfo.SwitchBlock &&
+ assert(!CleanupInfo.SwitchBlock &&
"Should not have a switch block for temporary cleanup!");
- assert(!CleanupInfo.EndBlock &&
+ assert(!CleanupInfo.EndBlock &&
"Should not have an end block for temporary cleanup!");
-
+
EmitBlock(Info.DtorBlock);
llvm::BasicBlock *CondEnd = 0;
@@ -63,12 +63,12 @@ void CodeGenFunction::PopCXXTemporary() {
if (Info.CondPtr) {
llvm::BasicBlock *CondBlock = createBasicBlock("cond.dtor.call");
CondEnd = createBasicBlock("cond.dtor.end");
-
+
llvm::Value *Cond = Builder.CreateLoad(Info.CondPtr);
Builder.CreateCondBr(Cond, CondBlock, CondEnd);
EmitBlock(CondBlock);
}
-
+
EmitCXXDestructorCall(Info.Temporary->getDestructor(),
Dtor_Complete, Info.ThisPtr);
@@ -77,7 +77,7 @@ void CodeGenFunction::PopCXXTemporary() {
Builder.CreateStore(llvm::ConstantInt::getFalse(VMContext), Info.CondPtr);
EmitBlock(CondEnd);
}
-
+
LiveTemporaries.pop_back();
}
@@ -89,7 +89,7 @@ CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
// If we shouldn't destroy the temporaries, just emit the
// child expression.
if (!E->shouldDestroyTemporaries())
- return EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
+ return EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
/*IgnoreResult=*/false, IsInitializer);
// Keep track of the current cleanup stack depth.
@@ -97,21 +97,21 @@ CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
(void) CleanupStackDepth;
unsigned OldNumLiveTemporaries = LiveTemporaries.size();
-
- RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
+
+ RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, IsAggLocVolatile,
/*IgnoreResult=*/false, IsInitializer);
-
+
// Pop temporaries.
while (LiveTemporaries.size() > OldNumLiveTemporaries)
PopCXXTemporary();
-
+
assert(CleanupEntries.size() == CleanupStackDepth &&
"Cleanup size mismatch!");
-
+
return RV;
}
-void
+void
CodeGenFunction::PushConditionalTempDestruction() {
// Store the current number of live temporaries.
ConditionalTempDestructionStack.push_back(LiveTemporaries.size());
@@ -120,13 +120,13 @@ CodeGenFunction::PushConditionalTempDestruction() {
void CodeGenFunction::PopConditionalTempDestruction() {
size_t NumLiveTemporaries = ConditionalTempDestructionStack.back();
ConditionalTempDestructionStack.pop_back();
-
+
// Pop temporaries.
while (LiveTemporaries.size() > NumLiveTemporaries) {
- assert(LiveTemporaries.back().CondPtr &&
+ assert(LiveTemporaries.back().CondPtr &&
"Conditional temporary must have a cond ptr!");
PopCXXTemporary();
- }
+ }
}
-
+
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 0a187fca76..2da16a15ac 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -33,13 +33,13 @@ using namespace CodeGen;
// FIXME: Use iterator and sidestep silly type array creation.
-const
+const
CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionNoProtoType *FTNP) {
- return getFunctionInfo(FTNP->getResultType(),
+ return getFunctionInfo(FTNP->getResultType(),
llvm::SmallVector<QualType, 16>());
}
-const
+const
CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionProtoType *FTP) {
llvm::SmallVector<QualType, 16> ArgTys;
// FIXME: Kill copy.
@@ -53,7 +53,7 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
// Add the 'this' pointer unless this is a static method.
if (MD->isInstance())
ArgTys.push_back(MD->getThisType(Context));
-
+
const FunctionProtoType *FTP = MD->getType()->getAsFunctionProtoType();
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
ArgTys.push_back(FTP->getArgType(i));
@@ -64,7 +64,7 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
if (MD->isInstance())
return getFunctionInfo(MD);
-
+
const FunctionType *FTy = FD->getType()->getAsFunctionType();
if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FTy))
return getFunctionInfo(FTP);
@@ -82,21 +82,21 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const ObjCMethodDecl *MD) {
return getFunctionInfo(MD->getResultType(), ArgTys);
}
-const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
+const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
const CallArgList &Args) {
// FIXME: Kill copy.
llvm::SmallVector<QualType, 16> ArgTys;
- for (CallArgList::const_iterator i = Args.begin(), e = Args.end();
+ for (CallArgList::const_iterator i = Args.begin(), e = Args.end();
i != e; ++i)
ArgTys.push_back(i->second);
return getFunctionInfo(ResTy, ArgTys);
}
-const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
+const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
const FunctionArgList &Args) {
// FIXME: Kill copy.
llvm::SmallVector<QualType, 16> ArgTys;
- for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
+ for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
i != e; ++i)
ArgTys.push_back(i->second);
return getFunctionInfo(ResTy, ArgTys);
@@ -123,7 +123,7 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
return *FI;
}
-CGFunctionInfo::CGFunctionInfo(QualType ResTy,
+CGFunctionInfo::CGFunctionInfo(QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys) {
NumArgs = ArgTys.size();
Args = new ArgInfo[1 + NumArgs];
@@ -134,20 +134,20 @@ CGFunctionInfo::CGFunctionInfo(QualType ResTy,
/***/
-void CodeGenTypes::GetExpandedTypes(QualType Ty,
+void CodeGenTypes::GetExpandedTypes(QualType Ty,
std::vector<const llvm::Type*> &ArgTys) {
const RecordType *RT = Ty->getAsStructureType();
assert(RT && "Can only expand structure types.");
const RecordDecl *RD = RT->getDecl();
- assert(!RD->hasFlexibleArrayMember() &&
+ assert(!RD->hasFlexibleArrayMember() &&
"Cannot expand structure with flexible array.");
-
+
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
const FieldDecl *FD = *i;
- assert(!FD->isBitField() &&
+ assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
-
+
QualType FT = FD->getType();
if (CodeGenFunction::hasAggregateLLVMType(FT)) {
GetExpandedTypes(FT, ArgTys);
@@ -157,19 +157,19 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty,
}
}
-llvm::Function::arg_iterator
+llvm::Function::arg_iterator
CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV,
llvm::Function::arg_iterator AI) {
const RecordType *RT = Ty->getAsStructureType();
assert(RT && "Can only expand structure types.");
RecordDecl *RD = RT->getDecl();
- assert(LV.isSimple() &&
- "Unexpected non-simple lvalue during struct expansion.");
+ assert(LV.isSimple() &&
+ "Unexpected non-simple lvalue during struct expansion.");
llvm::Value *Addr = LV.getAddress();
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- FieldDecl *FD = *i;
+ FieldDecl *FD = *i;
QualType FT = FD->getType();
// FIXME: What are the right qualifiers here?
@@ -185,8 +185,8 @@ CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV,
return AI;
}
-void
-CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
+void
+CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
llvm::SmallVector<llvm::Value*, 16> &Args) {
const RecordType *RT = Ty->getAsStructureType();
assert(RT && "Can only expand structure types.");
@@ -196,16 +196,16 @@ CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
llvm::Value *Addr = RV.getAggregateAddr();
for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
i != e; ++i) {
- FieldDecl *FD = *i;
+ FieldDecl *FD = *i;
QualType FT = FD->getType();
-
+
// FIXME: What are the right qualifiers here?
LValue LV = EmitLValueForField(Addr, FD, false, 0);
if (CodeGenFunction::hasAggregateLLVMType(FT)) {
ExpandTypeToArgs(FT, RValue::getAggregate(LV.getAddress()), Args);
} else {
RValue RV = EmitLoadOfLValue(LV, FT);
- assert(RV.isScalar() &&
+ assert(RV.isScalar() &&
"Unexpected non-scalar rvalue during struct expansion.");
Args.push_back(RV.getScalarVal());
}
@@ -221,7 +221,7 @@ CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
static llvm::Value *CreateCoercedLoad(llvm::Value *SrcPtr,
const llvm::Type *Ty,
CodeGenFunction &CGF) {
- const llvm::Type *SrcTy =
+ const llvm::Type *SrcTy =
cast<llvm::PointerType>(SrcPtr->getType())->getElementType();
uint64_t SrcSize = CGF.CGM.getTargetData().getTypeAllocSize(SrcTy);
uint64_t DstSize = CGF.CGM.getTargetData().getTypeAllocSize(Ty);
@@ -244,9 +244,9 @@ static llvm::Value *CreateCoercedLoad(llvm::Value *SrcPtr,
// Otherwise do coercion through memory. This is stupid, but
// simple.
llvm::Value *Tmp = CGF.CreateTempAlloca(Ty);
- llvm::Value *Casted =
+ llvm::Value *Casted =
CGF.Builder.CreateBitCast(Tmp, llvm::PointerType::getUnqual(SrcTy));
- llvm::StoreInst *Store =
+ llvm::StoreInst *Store =
CGF.Builder.CreateStore(CGF.Builder.CreateLoad(SrcPtr), Casted);
// FIXME: Use better alignment / avoid requiring aligned store.
Store->setAlignment(1);
@@ -263,7 +263,7 @@ static void CreateCoercedStore(llvm::Value *Src,
llvm::Value *DstPtr,
CodeGenFunction &CGF) {
const llvm::Type *SrcTy = Src->getType();
- const llvm::Type *DstTy =
+ const llvm::Type *DstTy =
cast<llvm::PointerType>(DstPtr->getType())->getElementType();
uint64_t SrcSize = CGF.CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -287,7 +287,7 @@ static void CreateCoercedStore(llvm::Value *Src,
// to that information.
llvm::Value *Tmp = CGF.CreateTempAlloca(SrcTy);
CGF.Builder.CreateStore(Src, Tmp);
- llvm::Value *Casted =
+ llvm::Value *Casted =
CGF.Builder.CreateBitCast(Tmp, llvm::PointerType::getUnqual(DstTy));
llvm::LoadInst *Load = CGF.Builder.CreateLoad(Casted);
// FIXME: Use better alignment / avoid requiring aligned load.
@@ -335,11 +335,11 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) {
ResultType = RetAI.getCoerceToType();
break;
}
-
- for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
+
+ for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
ie = FI.arg_end(); it != ie; ++it) {
const ABIArgInfo &AI = it->info;
-
+
switch (AI.getKind()) {
case ABIArgInfo::Ignore:
break;
@@ -359,7 +359,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) {
case ABIArgInfo::Direct:
ArgTys.push_back(ConvertType(it->type));
break;
-
+
case ABIArgInfo::Expand:
GetExpandedTypes(it->type, ArgTys);
break;
@@ -414,7 +414,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
break;
case ABIArgInfo::Indirect:
- PAL.push_back(llvm::AttributeWithIndex::get(Index,
+ PAL.push_back(llvm::AttributeWithIndex::get(Index,
llvm::Attribute::StructRet |
llvm::Attribute::NoAlias));
++Index;
@@ -428,7 +428,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
break;
case ABIArgInfo::Expand:
- assert(0 && "Invalid ABI kind for return argument");
+ assert(0 && "Invalid ABI kind for return argument");
}
if (RetAttrs)
@@ -439,12 +439,12 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
// register variable.
signed RegParm = 0;
if (TargetDecl)
- if (const RegparmAttr *RegParmAttr
+ if (const RegparmAttr *RegParmAttr
= TargetDecl->getAttr<RegparmAttr>())
RegParm = RegParmAttr->getNumParams();
unsigned PointerWidth = getContext().Target.getPointerWidth(0);
- for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
+ for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
ie = FI.arg_end(); it != ie; ++it) {
QualType ParamType = it->type;
const ABIArgInfo &AI = it->info;
@@ -483,10 +483,10 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
case ABIArgInfo::Ignore:
// Skip increment, no matching LLVM parameter.
- continue;
+ continue;
case ABIArgInfo::Expand: {
- std::vector<const llvm::Type*> Tys;
+ std::vector<const llvm::Type*> Tys;
// FIXME: This is rather inefficient. Do we ever actually need to do
// anything here? The result should be just reconstructed on the other
// side, so extension should be a non-issue.
@@ -495,7 +495,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
continue;
}
}
-
+
if (Attributes)
PAL.push_back(llvm::AttributeWithIndex::get(Index, Attributes));
++Index;
@@ -525,13 +525,13 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
// Emit allocs for param decls. Give the LLVM Argument nodes names.
llvm::Function::arg_iterator AI = Fn->arg_begin();
-
+
// Name the struct return argument.
if (CGM.ReturnTypeUsesSret(FI)) {
AI->setName("agg.result");
++AI;
}
-
+
assert(FI.arg_size() == Args.size() &&
"Mismatch between function signature & arguments.");
CGFunctionInfo::const_arg_iterator info_it = FI.arg_begin();
@@ -556,7 +556,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
V = EmitScalarConversion(V, Ty, Arg->getType());
}
}
- EmitParmDecl(*Arg, V);
+ EmitParmDecl(*Arg, V);
break;
}
@@ -580,17 +580,17 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
EmitParmDecl(*Arg, V);
break;
}
-
+
case ABIArgInfo::Expand: {
// If this structure was expanded into multiple arguments then
// we need to create a temporary and reconstruct it from the
// arguments.
std::string Name = Arg->getNameAsString();
- llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(Ty),
+ llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(Ty),
(Name + ".addr").c_str());
// FIXME: What are the right qualifiers here?
- llvm::Function::arg_iterator End =
- ExpandTypeFromArgs(Ty, LValue::MakeAddr(Temp,0), AI);
+ llvm::Function::arg_iterator End =
+ ExpandTypeFromArgs(Ty, LValue::MakeAddr(Temp,0), AI);
EmitParmDecl(*Arg, Temp);
// Name the arguments used in expansion and increment AI.
@@ -602,14 +602,14 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
case ABIArgInfo::Ignore:
// Initialize the local variable appropriately.
- if (hasAggregateLLVMType(Ty)) {
+ if (hasAggregateLLVMType(Ty)) {
EmitParmDecl(*Arg, CreateTempAlloca(ConvertTypeForMem(Ty)));
} else {
EmitParmDecl(*Arg, llvm::UndefValue::get(ConvertType(Arg->getType())));
}
-
+
// Skip increment, no matching LLVM parameter.
- continue;
+ continue;
case ABIArgInfo::Coerce: {
assert(AI != Fn->arg_end() && "Argument mismatch!");
@@ -668,16 +668,16 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
case ABIArgInfo::Ignore:
break;
-
+
case ABIArgInfo::Coerce:
RV = CreateCoercedLoad(ReturnValue, RetAI.getCoerceToType(), *this);
break;
case ABIArgInfo::Expand:
- assert(0 && "Invalid ABI kind for return argument");
+ assert(0 && "Invalid ABI kind for return argument");
}
}
-
+
if (RV) {
Builder.CreateRet(RV);
} else {
@@ -688,12 +688,12 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
RValue CodeGenFunction::EmitCallArg(const Expr *E, QualType ArgType) {
if (ArgType->isReferenceType())
return EmitReferenceBindingToExpr(E, ArgType);
-
+
return EmitAnyExprToTemp(E);
}
RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
- llvm::Value *Callee,
+ llvm::Value *Callee,
const CallArgList &CallArgs,
const Decl *TargetDecl) {
// FIXME: We no longer need the types from CallArgs; lift up and simplify.
@@ -703,17 +703,17 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
// location that we would like to return into.
QualType RetTy = CallInfo.getReturnType();
const ABIArgInfo &RetAI = CallInfo.getReturnInfo();
-
-
+
+
// If the call returns a temporary with struct return, create a temporary
// alloca to hold the result.
if (CGM.ReturnTypeUsesSret(CallInfo))
Args.push_back(CreateTempAlloca(ConvertTypeForMem(RetTy)));
-
+
assert(CallInfo.arg_size() == CallArgs.size() &&
"Mismatch between function signature & arguments.");
CGFunctionInfo::const_arg_iterator info_it = CallInfo.arg_begin();
- for (CallArgList::const_iterator I = CallArgs.begin(), E = CallArgs.end();
+ for (CallArgList::const_iterator I = CallArgs.begin(), E = CallArgs.end();
I != E; ++I, ++info_it) {
const ABIArgInfo &ArgInfo = info_it->info;
RValue RV = I->first;
@@ -726,7 +726,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (RV.isScalar())
EmitStoreOfScalar(RV.getScalarVal(), Args.back(), false, I->second);
else
- StoreComplexToAddr(RV.getComplexVal(), Args.back(), false);
+ StoreComplexToAddr(RV.getComplexVal(), Args.back(), false);
} else {
Args.push_back(RV.getAggregateAddr());
}
@@ -745,7 +745,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
Args.push_back(Builder.CreateLoad(RV.getAggregateAddr()));
}
break;
-
+
case ABIArgInfo::Ignore:
break;
@@ -758,9 +758,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
} else if (RV.isComplex()) {
SrcPtr = CreateTempAlloca(ConvertTypeForMem(I->second), "coerce");
StoreComplexToAddr(RV.getComplexVal(), SrcPtr, false);
- } else
+ } else
SrcPtr = RV.getAggregateAddr();
- Args.push_back(CreateCoercedLoad(SrcPtr, ArgInfo.getCoerceToType(),
+ Args.push_back(CreateCoercedLoad(SrcPtr, ArgInfo.getCoerceToType(),
*this));
break;
}
@@ -770,7 +770,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
break;
}
}
-
+
// If the callee is a bitcast of a function to a varargs pointer to function
// type, check to see if we can remove the bitcast. This handles some cases
// with unprototyped functions.
@@ -780,7 +780,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
const llvm::FunctionType *CurFT =
cast<llvm::FunctionType>(CurPT->getElementType());
const llvm::FunctionType *ActualFT = CalleeF->getFunctionType();
-
+
if (CE->getOpcode() == llvm::Instruction::BitCast &&
ActualFT->getReturnType() == CurFT->getReturnType() &&
ActualFT->getNumParams() == CurFT->getNumParams() &&
@@ -791,7 +791,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
ArgsMatch = false;
break;
}
-
+
// Strip the cast if we can get away with it. This is a nice cleanup,
// but also allows us to inline the function at -O0 if it is marked
// always_inline.
@@ -799,20 +799,20 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
Callee = CalleeF;
}
}
-
+
llvm::BasicBlock *InvokeDest = getInvokeDest();
CodeGen::AttributeListType AttributeList;
CGM.ConstructAttributeList(CallInfo, TargetDecl, AttributeList);
llvm::AttrListPtr Attrs = llvm::AttrListPtr::get(AttributeList.begin(),
AttributeList.end());
-
+
llvm::CallSite CS;
if (!InvokeDest || (Attrs.getFnAttributes() & llvm::Attribute::NoUnwind)) {
CS = Builder.CreateCall(Callee, Args.data(), Args.data()+Args.size());
} else {
llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
- CS = Builder.CreateInvoke(Callee, Cont, InvokeDest,
+ CS = Builder.CreateInvoke(Callee, Cont, InvokeDest,
Args.data(), Args.data()+Args.size());
EmitBlock(Cont);
}
@@ -828,15 +828,15 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (CS.doesNotReturn()) {
Builder.CreateUnreachable();
Builder.ClearInsertionPoint();
-
+
// FIXME: For now, emit a dummy basic block because expr emitters in
// generally are not ready to handle emitting expressions at unreachable
// points.
EnsureInsertPoint();
-
+
// Return a reasonable RValue.
return GetUndefRValue(RetTy);
- }
+ }
llvm::Instruction *CI = CS.getInstruction();
if (Builder.isNamePreserving() &&
@@ -882,7 +882,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
}
case ABIArgInfo::Expand:
- assert(0 && "Invalid ABI kind for return argument");
+ assert(0 && "Invalid ABI kind for return argument");
}
assert(0 && "Unhandled ABIArgInfo::Kind");
diff --git a/lib/CodeGen/CGCall.h b/lib/CodeGen/CGCall.h
index daf6f00045..2c1048d935 100644
--- a/lib/CodeGen/CGCall.h
+++ b/lib/CodeGen/CGCall.h
@@ -49,9 +49,9 @@ namespace CodeGen {
/// FunctionArgList - Type for representing both the decl and type
/// of parameters to a function. The decl must be either a
/// ParmVarDecl or ImplicitParamDecl.
- typedef llvm::SmallVector<std::pair<const VarDecl*, QualType>,
+ typedef llvm::SmallVector<std::pair<const VarDecl*, QualType>,
16> FunctionArgList;
-
+
/// CGFunctionInfo - Class to encapsulate the information about a
/// function definition.
class CGFunctionInfo : public llvm::FoldingSetNode {
@@ -67,7 +67,7 @@ namespace CodeGen {
typedef const ArgInfo *const_arg_iterator;
typedef ArgInfo *arg_iterator;
- CGFunctionInfo(QualType ResTy,
+ CGFunctionInfo(QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys);
~CGFunctionInfo() { delete[] Args; }
@@ -89,7 +89,7 @@ namespace CodeGen {
it->type.Profile(ID);
}
template<class Iterator>
- static void Profile(llvm::FoldingSetNodeID &ID,
+ static void Profile(llvm::FoldingSetNodeID &ID,
QualType ResTy,
Iterator begin,
Iterator end) {
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index e53f1fa525..aaaa4d4fa5 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -59,7 +59,7 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
FileName = PLoc.getFilename();
FID = PLoc.getIncludeLoc().getRawEncoding();
}
-
+
// See if this compile unit has been used before.
llvm::DICompileUnit &Unit = CompileUnitCache[FID];
if (!Unit.isNull()) return Unit;
@@ -112,10 +112,10 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
unsigned RuntimeVers = 0;
if (LO.ObjC1)
RuntimeVers = LO.ObjCNonFragileABI ? 2 : 1;
-
+
// Create new compile unit.
return Unit = DebugFactory.CreateCompileUnit(LangTag, AbsFileName.getLast(),
- AbsFileName.getDirname(),
+ AbsFileName.getDirname(),
Producer, isMain, isOptimized,
Flags, RuntimeVers);
}
@@ -144,13 +144,13 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT,
case BuiltinType::Bool: Encoding = llvm::dwarf::DW_ATE_boolean; break;
case BuiltinType::Float:
case BuiltinType::Double: Encoding = llvm::dwarf::DW_ATE_float; break;
- }
+ }
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(BT);
uint64_t Align = M->getContext().getTypeAlign(BT);
uint64_t Offset = 0;
-
- return DebugFactory.CreateBasicType(Unit,
+
+ return DebugFactory.CreateBasicType(Unit,
BT->getName(M->getContext().getLangOptions()),
Unit, 0, Size, Align,
Offset, /*flags*/ 0, Encoding);
@@ -162,17 +162,17 @@ llvm::DIType CGDebugInfo::CreateType(const ComplexType *Ty,
unsigned Encoding = llvm::dwarf::DW_ATE_complex_float;
if (Ty->isComplexIntegerType())
Encoding = llvm::dwarf::DW_ATE_lo_user;
-
+
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
uint64_t Offset = 0;
-
+
return DebugFactory.CreateBasicType(Unit, "complex",
Unit, 0, Size, Align,
Offset, /*flags*/ 0, Encoding);
}
-/// getOrCreateCVRType - Get the CVR qualified type from the cache or create
+/// getOrCreateCVRType - Get the CVR qualified type from the cache or create
/// a new one if necessary.
llvm::DIType CGDebugInfo::CreateCVRType(QualType Ty, llvm::DICompileUnit Unit) {
// We will create one Derived type for one qualifier and recurse to handle any
@@ -181,19 +181,19 @@ llvm::DIType CGDebugInfo::CreateCVRType(QualType Ty, llvm::DICompileUnit Unit) {
unsigned Tag;
if (Ty.isConstQualified()) {
Tag = llvm::dwarf::DW_TAG_const_type;
- Ty.removeConst();
+ Ty.removeConst();
FromTy = getOrCreateType(Ty, Unit);
} else if (Ty.isVolatileQualified()) {
Tag = llvm::dwarf::DW_TAG_volatile_type;
- Ty.removeVolatile();
+ Ty.removeVolatile();
FromTy = getOrCreateType(Ty, Unit);
} else {
assert(Ty.isRestrictQualified() && "Unknown type qualifier for debug info");
Tag = llvm::dwarf::DW_TAG_restrict_type;
- Ty.removeRestrict();
+ Ty.removeRestrict();
FromTy = getOrCreateType(Ty, Unit);
}
-
+
// No need to fill in the Name, Line, Size, Alignment, Offset in case of
// CVR derived types.
return DebugFactory.CreateDerivedType(Tag, Unit, "", llvm::DICompileUnit(),
@@ -203,11 +203,11 @@ llvm::DIType CGDebugInfo::CreateCVRType(QualType Ty, llvm::DICompileUnit Unit) {
llvm::DIType CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
llvm::DICompileUnit Unit) {
llvm::DIType EltTy = getOrCreateType(Ty->getPointeeType(), Unit);
-
+
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
-
+
return DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type, Unit,
"", llvm::DICompileUnit(),
0, Size, Align, 0, 0, EltTy);
@@ -216,11 +216,11 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty,
llvm::DICompileUnit Unit) {
llvm::DIType EltTy = getOrCreateType(Ty->getPointeeType(), Unit);
-
+
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
-
+
return DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type, Unit,
"", llvm::DICompileUnit(),
0, Size, Align, 0, 0, EltTy);
@@ -274,11 +274,11 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty,
EltTy = DebugFactory.CreateCompositeType(Tag, Unit, "__block_descriptor",
DefUnit, 0, FieldOffset, 0, 0, 0,
llvm::DIType(), Elements);
-
+
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
-
+
DescTy = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
Unit, "", llvm::DICompileUnit(),
0, Size, Align, 0, 0, EltTy);
@@ -344,7 +344,7 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty,
EltTy = DebugFactory.CreateCompositeType(Tag, Unit, "__block_literal_generic",
DefUnit, 0, FieldOffset, 0, 0, 0,
llvm::DIType(), Elements);
-
+
BlockLiteralGenericSet = true;
BlockLiteralGeneric
= DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type, Unit,
@@ -358,7 +358,7 @@ llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty,
// Typedefs are derived from some other type. If we have a typedef of a
// typedef, make sure to emit the whole chain.
llvm::DIType Src = getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit);
-
+
// We don't set size information, but do specify where the typedef was
// declared.
std::string TyName = Ty->getDecl()->getNameAsString();
@@ -379,7 +379,7 @@ llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
// Add the result type at least.
EltTys.push_back(getOrCreateType(Ty->getResultType(), Unit));
-
+
// Set up remainder of arguments if there is a prototype.
// FIXME: IF NOT, HOW IS THIS REPRESENTED? llvm-gcc doesn't represent '...'!
if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(Ty)) {
@@ -391,7 +391,7 @@ llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
llvm::DIArray EltTypeArray =
DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
-
+
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
Unit, "", llvm::DICompileUnit(),
0, 0, 0, 0, 0,
@@ -402,7 +402,7 @@ llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
llvm::DICompileUnit Unit) {
RecordDecl *Decl = Ty->getDecl();
-
+
unsigned Tag;
if (Decl->isStruct())
Tag = llvm::dwarf::DW_TAG_structure_type;
@@ -425,7 +425,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
DefUnit = getOrCreateCompileUnit(Decl->getLocation());
Line = PLoc.getLine();
}
-
+
// Records and classes and unions can all be recursive. To handle them, we
// first generate a debug descriptor for the struct as a forward declaration.
// Then (if it is a definition) we go through and get debug info for all of
@@ -435,7 +435,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
llvm::DICompositeType FwdDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, 0, 0, 0, 0,
llvm::DIType(), llvm::DIArray());
-
+
// If this is just a forward declaration, return it.
if (!Decl->getDefinition(M->getContext()))
return FwdDecl;
@@ -451,7 +451,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
unsigned FieldNo = 0;
for (RecordDecl::field_iterator I = Decl->field_begin(),
- E = Decl->field_end();
+ E = Decl->field_end();
I != E; ++I, ++FieldNo) {
FieldDecl *Field = *I;
llvm::DIType FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -467,7 +467,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
PresumedLoc PLoc = SM.getPresumedLoc(FieldDefLoc);
llvm::DICompileUnit FieldDefUnit;
unsigned FieldLine = 0;
-
+
if (!PLoc.isInvalid()) {
FieldDefUnit = getOrCreateCompileUnit(FieldDefLoc);
FieldLine = PLoc.getLine();
@@ -477,18 +477,18 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
uint64_t FieldSize = 0;
unsigned FieldAlign = 0;
if (!FType->isIncompleteArrayType()) {
-
+
// Bit size, align and offset of the type.
FieldSize = M->getContext().getTypeSize(FType);
Expr *BitWidth = Field->getBitWidth();
if (BitWidth)
FieldSize = BitWidth->EvaluateAsInt(M->getContext()).getZExtValue();
-
+
FieldAlign = M->getContext().getTypeAlign(FType);
}
- uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
-
+ uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
+
// Create a DW_TAG_member node to remember the offset of this field in the
// struct. FIXME: This is an absolutely insane way to capture this
// information. When we gut debug info, this should be fixed.
@@ -498,14 +498,14 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
FieldOffset, 0, FieldTy);
EltTys.push_back(FieldTy);
}
-
+
llvm::DIArray Elements =
DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
-
+
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, Size,
Align, 0, 0, llvm::DIType(), Elements);
@@ -515,7 +515,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
FwdDecl.replaceAllUsesWith(RealDecl);
// Update TypeCache.
- TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
+ TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
return RealDecl;
}
@@ -523,7 +523,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
llvm::DICompileUnit Unit) {
ObjCInterfaceDecl *Decl = Ty->getDecl();
-
+
unsigned Tag = llvm::dwarf::DW_TAG_structure_type;
SourceManager &SM = M->getContext().getSourceManager();
@@ -534,7 +534,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation());
unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine();
-
+
unsigned RuntimeLang = DefUnit.getLanguage();
// To handle recursive interface, we
@@ -547,7 +547,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, 0, 0, 0, 0,
llvm::DIType(), llvm::DIArray(),
RuntimeLang);
-
+
// If this is just a forward declaration, return it.
if (Decl->isForwardDecl())
return FwdDecl;
@@ -561,9 +561,9 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
ObjCInterfaceDecl *SClass = Decl->getSuperClass();
if (SClass) {
- llvm::DIType SClassTy =
+ llvm::DIType SClassTy =
getOrCreateType(M->getContext().getObjCInterfaceType(SClass), Unit);
- llvm::DIType InhTag =
+ llvm::DIType InhTag =
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_inheritance,
Unit, "", llvm::DICompileUnit(), 0, 0, 0,
0 /* offset */, 0, SClassTy);
@@ -590,13 +590,13 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
PresumedLoc PLoc = SM.getPresumedLoc(FieldDefLoc);
unsigned FieldLine = PLoc.isInvalid() ? 0 : PLoc.getLine();
-
+
QualType FType = Field->getType();
uint64_t FieldSize = 0;
unsigned FieldAlign = 0;
if (!FType->isIncompleteArrayType()) {
-
+
// Bit size, align and offset of the type.
FieldSize = M->getContext().getTypeSize(FType);
Expr *BitWidth = Field->getBitWidth();
@@ -606,14 +606,14 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
FieldAlign = M->getContext().getTypeAlign(FType);
}
- uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
-
+ uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
+
unsigned Flags = 0;
if (Field->getAccessControl() == ObjCIvarDecl::Protected)
Flags = llvm::DIType::FlagProtected;
else if (Field->getAccessControl() == ObjCIvarDecl::Private)
Flags = llvm::DIType::FlagPrivate;
-
+
// Create a DW_TAG_member node to remember the offset of this field in the
// struct. FIXME: This is an absolutely insane way to capture this
// information. When we gut debug info, this should be fixed.
@@ -623,14 +623,14 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
FieldOffset, Flags, FieldTy);
EltTys.push_back(FieldTy);
}
-
+
llvm::DIArray Elements =
DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size());
// Bit size, align and offset of the type.
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
-
+
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, Size,
Align, 0, 0, llvm::DIType(), Elements,
@@ -641,7 +641,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
FwdDecl.replaceAllUsesWith(RealDecl);
// Update TypeCache.
- TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
+ TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;
return RealDecl;
}
@@ -652,13 +652,13 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty,
llvm::SmallVector<llvm::DIDescriptor, 32> Enumerators;
// Create DIEnumerator elements for each enumerator.
- for (EnumDecl::enumerator_iterator
+ for (EnumDecl::enumerator_iterator
Enum = Decl->enumerator_begin(), EnumEnd = Decl->enumerator_end();
Enum != EnumEnd; ++Enum) {
Enumerators.push_back(DebugFactory.CreateEnumerator(Enum->getNameAsString(),
Enum->getInitVal().getZExtValue()));
}
-
+
// Return a CompositeType for the enum itself.
llvm::DIArray EltArray =
DebugFactory.GetOrCreateArray(Enumerators.data(), Enumerators.size());
@@ -670,7 +670,7 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty,
PresumedLoc PLoc = SM.getPresumedLoc(DefLoc);
unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine();
-
+
// Size and align of the type.
uint64_t Size = 0;
unsigned Align = 0;
@@ -678,7 +678,7 @@ llvm::DIType CGDebugInfo::CreateType(const EnumType *Ty,
Size = M->getContext().getTypeSize(Ty);
Align = M->getContext().getTypeAlign(Ty);
}
-
+
return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
Unit, EnumName, DefUnit, Line,
Size, Align, 0, 0,
@@ -691,7 +691,7 @@ llvm::DIType CGDebugInfo::CreateType(const TagType *Ty,
return CreateType(RT, Unit);
else if (const EnumType *ET = dyn_cast<EnumType>(Ty))
return CreateType(ET, Unit);
-
+
return llvm::DIType();
}
@@ -699,8 +699,8 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
llvm::DICompileUnit Unit) {
uint64_t Size;
uint64_t Align;
-
-
+
+
// FIXME: make getTypeAlign() aware of VLAs and incomplete array types
if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(Ty)) {
Size = 0;
@@ -714,7 +714,7 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
Size = M->getContext().getTypeSize(Ty);
Align = M->getContext().getTypeAlign(Ty);
}
-
+
// Add the dimensions of the array. FIXME: This loses CV qualifiers from
// interior arrays, do we care? Why aren't nested arrays represented the
// obvious/recursive way?
@@ -722,14 +722,14 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
QualType EltTy(Ty, 0);
while ((Ty = dyn_cast<ArrayType>(EltTy))) {
uint64_t Upper = 0;
- if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
+ if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(Ty))
if (CAT->getSize().getZExtValue())
- Upper = CAT->getSize().getZExtValue() - 1;
+ Upper = CAT->getSize().getZExtValue() - 1;
// FIXME: Verify this is right for VLAs.
Subscripts.push_back(DebugFactory.GetOrCreateSubrange(0, Upper));
EltTy = Ty->getElementType();
}
-
+
llvm::DIArray SubscriptArray =
DebugFactory.GetOrCreateArray(Subscripts.data(), Subscripts.size());
@@ -747,7 +747,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
llvm::DICompileUnit Unit) {
if (Ty.isNull())
return llvm::DIType();
-
+
// Check TypeCache first.
llvm::DIType &Slot = TypeCache[Ty.getAsOpaquePtr()];
if (!Slot.isNull()) return Slot;
@@ -778,7 +778,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
return llvm::DIType();
case Type::ObjCObjectPointer:
return Slot = CreateType(cast<ObjCObjectPointerType>(Ty), Unit);
- case Type::ObjCInterface:
+ case Type::ObjCInterface:
return Slot = CreateType(cast<ObjCInterfaceType>(Ty), Unit);
case Type::Builtin: return Slot = CreateType(cast<BuiltinType>(Ty), Unit);
case Type::Complex: return Slot = CreateType(cast<ComplexType>(Ty), Unit);
@@ -788,14 +788,14 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
case Type::Typedef: return Slot = CreateType(cast<TypedefType>(Ty), Unit);
case Type::Record:
case Type::Enum:
- return Slot = CreateType(cast<TagType>(Ty), Unit);
+ return Slot = CreateType(cast<TagType>(Ty), Unit);
case Type::FunctionProto:
case Type::FunctionNoProto:
return Slot = CreateType(cast<FunctionType>(Ty), Unit);
case Type::Elaborated:
return Slot = getOrCreateType(cast<ElaboratedType>(Ty)->getUnderlyingType(),
Unit);
-
+
case Type::ConstantArray:
case Type::ConstantArrayWithExpr:
case Type::ConstantArrayWithoutExpr:
@@ -812,7 +812,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
return Slot = getOrCreateType(cast<DecltypeType>(Ty)->getUnderlyingType(),
Unit);
}
-
+
return Slot;
}
@@ -822,25 +822,25 @@ void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,
llvm::Function *Fn,
CGBuilderTy &Builder) {
const char *LinkageName = Name;
-
+
// Skip the asm prefix if it exists.
//
// FIXME: This should probably be the unmangled name?
if (Name[0] == '\01')
++Name;
-
+
// FIXME: Why is this using CurLoc???
llvm::DICompileUnit Unit = getOrCreateCompileUnit(CurLoc);
SourceManager &SM = M->getContext().getSourceManager();
unsigned LineNo = SM.getPresumedLoc(CurLoc).getLine();
-
+
llvm::DISubprogram SP =
DebugFactory.CreateSubprogram(Unit, Name, Name, LinkageName, Unit, LineNo,
getOrCreateType(ReturnType, Unit),
Fn->hasInternalLinkage(), true/*definition*/);
-
+
DebugFactory.InsertSubprogramStart(SP, Builder.GetInsertBlock());
-
+
// Push function on region stack.
RegionStack.push_back(SP);
}
@@ -848,10 +848,10 @@ void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,
void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
if (CurLoc.isInvalid() || CurLoc.isMacroID()) return;
-
+
// Don't bother if things are the same as last time.
SourceManager &SM = M->getContext().getSourceManager();
- if (CurLoc == PrevLoc
+ if (CurLoc == PrevLoc
|| (SM.getInstantiationLineNumber(CurLoc) ==
SM.getInstantiationLineNumber(PrevLoc)
&& SM.isFromSameFile(CurLoc, PrevLoc)))
@@ -864,7 +864,7 @@ void CGDebugInfo::EmitStopPoint(llvm::Function *Fn, CGBuilderTy &Builder) {
llvm::DICompileUnit Unit = getOrCreateCompileUnit(CurLoc);
PresumedLoc PLoc = SM.getPresumedLoc(CurLoc);
DebugFactory.InsertStopPoint(Unit, PLoc.getLine(), PLoc.getColumn(),
- Builder.GetInsertBlock());
+ Builder.GetInsertBlock());
}
/// EmitRegionStart- Constructs the debug code for entering a declarative
@@ -885,7 +885,7 @@ void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder) {
// Provide an region stop point.
EmitStopPoint(Fn, Builder);
-
+
DebugFactory.InsertRegionEnd(RegionStack.back(), Builder.GetInsertBlock());
RegionStack.pop_back();
}
@@ -914,9 +914,9 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag,
else
Unit = llvm::DICompileUnit();
-
+
// Create the descriptor for the variable.
- llvm::DIVariable D =
+ llvm::DIVariable D =
DebugFactory.CreateVariable(Tag, RegionStack.back(),Decl->getNameAsString(),
Unit, Line, Ty);
// Insert an llvm.dbg.declare into the current block.
@@ -939,7 +939,7 @@ void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
/// EmitGlobalVariable - Emit information about a global variable.
-void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
+void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
const VarDecl *Decl) {
// Do not emit variable debug information while generating optimized code.
@@ -959,14 +959,14 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
QualType T = Decl->getType();
if (T->isIncompleteArrayType()) {
-
+
// CodeGen turns int[] into int[1] so we'll do the same here.
llvm::APSInt ConstVal(32);
-
+
ConstVal = 1;
QualType ET = M->getContext().getAsArrayType(T)->getElementType();
-
- T = M->getContext().getConstantArrayType(ET, ConstVal,
+
+ T = M->getContext().getConstantArrayType(ET, ConstVal,
ArrayType::Normal, 0);
}
@@ -977,7 +977,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
}
/// EmitGlobalVariable - Emit information about an objective-c interface.
-void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
+void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
ObjCInterfaceDecl *Decl) {
// Create global variable debug descriptor.
llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
@@ -989,14 +989,14 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
QualType T = M->getContext().getObjCInterfaceType(Decl);
if (T->isIncompleteArrayType()) {
-
+
// CodeGen turns int[] into int[1] so we'll do the same here.
llvm::APSInt ConstVal(32);
-
+
ConstVal = 1;
QualType ET = M->getContext().getAsArrayType(T)->getElementType();
-
- T = M->getContext().getConstantArrayType(ET, ConstVal,
+
+ T = M->getContext().getConstantArrayType(ET, ConstVal,
ArrayType::Normal, 0);
}
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index ac28e5b879..682f7aedd8 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This is the source level debug info generator for llvm translation.
+// This is the source level debug info generator for llvm translation.
//
//===----------------------------------------------------------------------===//
@@ -29,14 +29,14 @@ namespace clang {
namespace CodeGen {
class CodeGenModule;
-/// CGDebugInfo - This class gathers all debug information during compilation
-/// and is responsible for emitting to llvm globals or pass directly to
+/// CGDebugInfo - This class gathers all debug information during compilation
+/// and is responsible for emitting to llvm globals or pass directly to
/// the backend.
class CGDebugInfo {
CodeGenModule *M;
bool isMainCompileUnitCreated;
llvm::DIFactory DebugFactory;
-
+
SourceLocation CurLoc, PrevLoc;
/// CompileUnitCache - Cache of previously constructed CompileUnits.
@@ -45,7 +45,7 @@ class CGDebugInfo {
/// TypeCache - Cache of previously constructed Types.
// FIXME: Eliminate this map. Be careful of iterator invalidation.
std::map<void *, llvm::DIType> TypeCache;
-
+
bool BlockLiteralGenericSet;
llvm::DIType BlockLiteralGeneric;
@@ -56,7 +56,7 @@ class CGDebugInfo {
llvm::DIType CreateType(const ComplexType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateCVRType(QualType Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const TypedefType *Ty, llvm::DICompileUnit U);
- llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
+ llvm::DIType CreateType(const ObjCObjectPointerType *Ty,
llvm::DICompileUnit Unit);
llvm::DIType CreateType(const PointerType *Ty, llvm::DICompileUnit U);
llvm::DIType CreateType(const BlockPointerType *Ty, llvm::DICompileUnit U);
@@ -83,12 +83,12 @@ public:
/// start of a new function.
void EmitFunctionStart(const char *Name, QualType ReturnType,
llvm::Function *Fn, CGBuilderTy &Builder);
-
+
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
- /// of a new block.
+ /// of a new block.
void EmitRegionStart(llvm::Function *Fn, CGBuilderTy &Builder);
-
- /// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
+
+ /// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
/// block.
void EmitRegionEnd(llvm::Function *Fn, CGBuilderTy &Builder);
@@ -101,19 +101,19 @@ public:
/// variable declaration.
void EmitDeclareOfArgVariable(const VarDecl *Decl, llvm::Value *AI,
CGBuilderTy &Builder);
-
+
/// EmitGlobalVariable - Emit information about a global variable.
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl);
/// EmitGlobalVariable - Emit information about an objective-c interface.
void EmitGlobalVariable(llvm::GlobalVariable *GV, ObjCInterfaceDecl *Decl);
-
+
private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
CGBuilderTy &Builder);
-
-
+
+
/// getOrCreateCompileUnit - Get the compile unit from the cache or create a
/// new one if necessary.
llvm::DICompileUnit getOrCreateCompileUnit(SourceLocation Loc);
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 2b8348eece..e637d40de0 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -35,22 +35,22 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
case Decl::Function: // void X();
case Decl::Record: // struct/union/class X;
case Decl::Enum: // enum X;
- case Decl::EnumConstant: // enum ? { X = ? }
+ case Decl::EnumConstant: // enum ? { X = ? }
case Decl::CXXRecord: // struct/union/class X; [C++]
// None of these decls require codegen support.
return;
-
+
case Decl::Var: {
const VarDecl &VD = cast<VarDecl>(D);
- assert(VD.isBlockVarDecl() &&
+ assert(VD.isBlockVarDecl() &&
"Should not see file-scope variables inside a function!");
return EmitBlockVarDecl(VD);
}
-
+
case Decl::Typedef: { // typedef int X;
const TypedefDecl &TD = cast<TypedefDecl>(D);
QualType Ty = TD.getUnderlyingType();
-
+
if (Ty->isVariablyModifiedType())
EmitVLASize(Ty);
}
@@ -62,7 +62,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) {
if (D.hasAttr<AsmLabelAttr>())
CGM.ErrorUnsupported(&D, "__asm__");
-
+
switch (D.getStorageClass()) {
case VarDecl::None:
case VarDecl::Auto:
@@ -98,22 +98,22 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D,
ContextName = CurFn->getName();
else
assert(0 && "Unknown context for block var decl");
-
+
Name = ContextName + Separator + D.getNameAsString();
}
const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
return new llvm::GlobalVariable(CGM.getModule(), LTy,
Ty.isConstant(getContext()), Linkage,
- CGM.EmitNullConstant(D.getType()), Name, 0,
+ CGM.EmitNullConstant(D.getType()), Name, 0,
D.isThreadSpecified(), Ty.getAddressSpace());
}
-void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
+void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");
-
- llvm::GlobalVariable *GV =
+
+ llvm::GlobalVariable *GV =
CreateStaticBlockVarDecl(D, ".", llvm::GlobalValue::InternalLinkage);
// Store into LocalDeclMap before generating initializer to handle
@@ -143,7 +143,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
// in the LLVM type system.)
if (GV->getType() != Init->getType()) {
llvm::GlobalVariable *OldGV = GV;
-
+
GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
OldGV->isConstant(),
OldGV->getLinkage(), Init, "",
@@ -154,13 +154,13 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
GV->takeName(OldGV);
// Replace all uses of the old global with the new global
- llvm::Constant *NewPtrForOldDecl =
+ llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
OldGV->replaceAllUsesWith(NewPtrForOldDecl);
// Erase the old global, since it is no longer used.
OldGV->eraseFromParent();
- }
+ }
GV->setInitializer(Init);
}
@@ -170,14 +170,14 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
if (const AnnotateAttr *AA = D.getAttr<AnnotateAttr>()) {
SourceManager &SM = CGM.getContext().getSourceManager();
llvm::Constant *Ann =
- CGM.EmitAnnotateAttr(GV, AA,
+ CGM.EmitAnnotateAttr(GV, AA,
SM.getInstantiationLineNumber(D.getLocation()));
CGM.AddAnnotation(Ann);
}
if (const SectionAttr *SA = D.getAttr<SectionAttr>())
GV->setSection(SA->getName());
-
+
if (D.hasAttr<UsedAttr>())
CGM.AddUsedGlobal(GV);
@@ -198,7 +198,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
}
}
-
+
/// BuildByRefType - This routine changes a __block variable declared as T x
/// into:
///
@@ -216,7 +216,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) {
QualType Ty = D->getType();
uint64_t Align = getContext().getDeclAlignInBytes(D);
-
+
const llvm::Type *LTy = ConvertType(Ty);
bool needsCopyDispose = BlockRequiresCopying(Ty);
std::vector<const llvm::Type *> Types(needsCopyDispose*2+5);
@@ -256,7 +256,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
LTy = BuildByRefType(&D);
llvm::AllocaInst *Alloc = CreateTempAlloca(LTy);
Alloc->setName(D.getNameAsString().c_str());
-
+
if (isByRef)
Align = std::max(Align, unsigned(Target.getPointerAlign(0) / 8));
Alloc->setAlignment(Align);
@@ -265,11 +265,11 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// Targets that don't support recursion emit locals as globals.
const char *Class =
D.getStorageClass() == VarDecl::Register ? ".reg." : ".auto.";
- DeclPtr = CreateStaticBlockVarDecl(D, Class,
+ DeclPtr = CreateStaticBlockVarDecl(D, Class,
llvm::GlobalValue
::InternalLinkage);
}
-
+
// FIXME: Can this happen?
if (Ty->isVariablyModifiedType())
EmitVLASize(Ty);
@@ -281,26 +281,26 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
const llvm::Type *LTy =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
llvm::Value *Stack = CreateTempAlloca(LTy, "saved_stack");
-
+
llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::stacksave);
llvm::Value *V = Builder.CreateCall(F);
-
+
Builder.CreateStore(V, Stack);
DidCallStackSave = true;
-
+
{
// Push a cleanup block and restore the stack there.
CleanupScope scope(*this);
-
+
V = Builder.CreateLoad(Stack, "tmp");
llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::stackrestore);
Builder.CreateCall(F, V);
}
}
-
+
// Get the element type.
- const llvm::Type *LElemTy = ConvertTypeForMem(Ty);
+ const llvm::Type *LElemTy = ConvertTypeForMem(Ty);
const llvm::Type *LElemPtrTy =
llvm::PointerType::get(LElemTy, D.getType().getAddressSpace());
@@ -309,7 +309,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// Downcast the VLA size expression
VLASize = Builder.CreateIntCast(VLASize, llvm::Type::getInt32Ty(VMContext),
false, "tmp");
-
+
// Allocate memory for the array.
llvm::Value *VLA = Builder.CreateAlloca(llvm::Type::getInt8Ty(VMContext),
VLASize, "vla");
@@ -323,16 +323,16 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// Emit debug info for local var declaration.
if (CGDebugInfo *DI = getDebugInfo()) {
assert(HaveInsertPoint() && "Unexpected unreachable point!");
-
+
DI->setLocation(D.getLocation());
if (Target.useGlobalsForAutomaticVariables()) {
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(DeclPtr), &D);
} else if (isByRef) {
- // FIXME: This code is broken and will not emit debug info for the
+ // FIXME: This code is broken and will not emit debug info for the
// variable. The right way to do this would be to tell LLVM that this is a
// byref pointer, and what the offset is. Unfortunately, right now it's
// not possible unless we create a DIType that corresponds to the byref
- // struct.
+ // struct.
/*
llvm::Value *Loc;
bool needsCopyDispose = BlockRequiresCopying(Ty);
@@ -369,7 +369,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
EmitStoreOfScalar(RV.getScalarVal(), Loc, false, Ty);
} else if (!hasAggregateLLVMType(Init->getType())) {
llvm::Value *V = EmitScalarExpr(Init);
- EmitStoreOfScalar(V, Loc, D.getType().isVolatileQualified(),
+ EmitStoreOfScalar(V, Loc, D.getType().isVolatileQualified(),
D.getType());
} else if (Init->getType()->isAnyComplexType()) {
EmitComplexExprIntoAddr(Init, Loc, D.getType().isVolatileQualified());
@@ -377,7 +377,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
EmitAggExpr(Init, Loc, D.getType().isVolatileQualified());
}
}
-
+
if (isByRef) {
const llvm::PointerType *PtrToInt8Ty
= llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
@@ -448,19 +448,19 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
const CXXDestructorDecl *D = ClassDecl->getDestructor(getContext());
assert(D && "EmitLocalBlockVarDecl - destructor is nul");
assert(!Ty->getAs<ArrayType>() && "FIXME - destruction of arrays NYI");
-
+
CleanupScope scope(*this);
EmitCXXDestructorCall(D, Dtor_Complete, DeclPtr);
}
}
-
+
// Handle the cleanup attribute
if (const CleanupAttr *CA = D.getAttr<CleanupAttr>()) {
const FunctionDecl *FD = CA->getFunctionDecl();
-
+
llvm::Constant* F = CGM.GetAddrOfFunction(GlobalDecl(FD));
assert(F && "Could not find function!");
-
+
CleanupScope scope(*this);
const CGFunctionInfo &Info = CGM.getTypes().getFunctionInfo(FD);
@@ -469,15 +469,15 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// the type of the pointer. An example of this is
// void f(void* arg);
// __attribute__((cleanup(f))) void *g;
- //
+ //
// To fix this we insert a bitcast here.
QualType ArgTy = Info.arg_begin()->type;
DeclPtr = Builder.CreateBitCast(DeclPtr, ConvertType(ArgTy));
-
+
CallArgList Args;
- Args.push_back(std::make_pair(RValue::get(DeclPtr),
+ Args.push_back(std::make_pair(RValue::get(DeclPtr),
getContext().getPointerType(D.getType())));
-
+
EmitCall(Info, F, Args);
}
@@ -489,14 +489,14 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
}
}
-/// Emit an alloca (or GlobalValue depending on target)
+/// Emit an alloca (or GlobalValue depending on target)
/// for the specified parameter and set up LocalDeclMap.
void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
// FIXME: Why isn't ImplicitParamDecl a ParmVarDecl?
assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
"Invalid argument to EmitParmDecl");
QualType Ty = D.getType();
-
+
llvm::Value *DeclPtr;
if (!Ty->isConstantSizeType()) {
// Variable sized values always are passed by-reference.
@@ -510,7 +510,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
Name += ".addr";
DeclPtr = CreateTempAlloca(LTy);
DeclPtr->setName(Name.c_str());
-
+
// Store the initial value into the alloca.
EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified(), Ty);
} else {
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 4a04bd3f20..969b789d51 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -847,7 +847,7 @@ LValue CodeGenFunction::EmitPredefinedFunctionName(unsigned Type) {
}
std::string FunctionName =
- PredefinedExpr::ComputeName(getContext(), (PredefinedExpr::IdentType)Type,
+ PredefinedExpr::ComputeName(getContext(), (PredefinedExpr::IdentType)Type,
CurCodeDecl);
GlobalVarName += FunctionName;
@@ -1073,8 +1073,7 @@ LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
FieldDecl* Field,
bool isUnion,
- unsigned CVRQualifiers)
-{
+ unsigned CVRQualifiers) {
if (Field->isBitField())
return EmitLValueForBitfield(BaseValue, Field, CVRQualifiers);
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index f8e9c56b18..8bda0f3e36 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -62,7 +62,7 @@ public:
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
-
+
void VisitStmt(Stmt *S) {
CGF.ErrorUnsupported(S, "aggregate expression");
}
@@ -75,18 +75,18 @@ public:
void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); }
void VisitStringLiteral(StringLiteral *E) { EmitAggLoadOfLValue(E); }
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
- EmitAggLoadOfLValue(E);
+ EmitAggLoadOfLValue(E);
}
void VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
EmitAggLoadOfLValue(E);
}
void VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) {
- EmitAggLoadOfLValue(E);
+ EmitAggLoadOfLValue(E);
}
void VisitPredefinedExpr(const PredefinedExpr *E) {
- EmitAggLoadOfLValue(E);
+ EmitAggLoadOfLValue(E);
}
-
+
// Operators.
void VisitCastExpr(CastExpr *E);
void VisitCallExpr(const CallExpr *E);
@@ -101,7 +101,7 @@ public:
}
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
void VisitObjCImplicitSetterGetterRefExpr(ObjCImplicitSetterGetterRefExpr *E);
-
+
void VisitConditionalOperator(const ConditionalOperator *CO);
void VisitChooseExpr(const ChooseExpr *CE);
void VisitInitListExpr(InitListExpr *E);
@@ -185,18 +185,18 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
return;
}
if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) {
- if (const CXXFunctionalCastExpr *CXXFExpr =
+ if (const CXXFunctionalCastExpr *CXXFExpr =
dyn_cast<CXXFunctionalCastExpr>(E))
CGF.EmitCXXFunctionalCastExpr(CXXFExpr);
- else
+ else
if (isa<CStyleCastExpr>(E))
Visit(E->getSubExpr());
return;
}
-
+
// FIXME: Remove the CK_Unknown check here.
- assert((E->getCastKind() == CastExpr::CK_NoOp ||
- E->getCastKind() == CastExpr::CK_Unknown) &&
+ assert((E->getCastKind() == CastExpr::CK_NoOp ||
+ E->getCastKind() == CastExpr::CK_Unknown) &&
"Only no-op casts allowed!");
assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(),
E->getType()) &&
@@ -209,7 +209,7 @@ void AggExprEmitter::VisitCallExpr(const CallExpr *E) {
EmitAggLoadOfLValue(E);
return;
}
-
+
RValue RV = CGF.EmitCallExpr(E);
EmitFinalDestCopy(E, RV);
}
@@ -259,21 +259,21 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
if (!AggLoc)
AggLoc = CGF.CreateTempAlloca(CGF.ConvertType(E->getRHS()->getType()));
CGF.EmitAggExpr(E->getRHS(), AggLoc, VolatileDest);
- CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(),
+ CGF.EmitObjCPropertySet(LHS.getPropertyRefExpr(),
RValue::getAggregate(AggLoc, VolatileDest));
} else if (LHS.isKVCRef()) {
llvm::Value *AggLoc = DestPtr;
if (!AggLoc)
AggLoc = CGF.CreateTempAlloca(CGF.ConvertType(E->getRHS()->getType()));
CGF.EmitAggExpr(E->getRHS(), AggLoc, VolatileDest);
- CGF.EmitObjCPropertySet(LHS.getKVCRefExpr(),
+ CGF.EmitObjCPropertySet(LHS.getKVCRefExpr(),
RValue::getAggregate(AggLoc, VolatileDest));
} else {
bool RequiresGCollection = false;
if (CGF.getContext().getLangOptions().NeXTRuntime) {
QualType LHSTy = E->getLHS()->getType();
if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAs<RecordType>())
- RequiresGCollection = FDTTy->getDecl()->hasObjectMember();
+ RequiresGCollection = FDTTy->getDecl()->hasObjectMember();
}
// Codegen the RHS so that it stores directly into the LHS.
CGF.EmitAggExpr(E->getRHS(), LHS.getAddress(), LHS.isVolatileQualified(),
@@ -286,27 +286,27 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) {
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.true");
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.false");
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.end");
-
+
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
-
+
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(LHSBlock);
-
+
// Handle the GNU extension for missing LHS.
assert(E->getLHS() && "Must have LHS for aggregate value");
Visit(E->getLHS());
CGF.PopConditionalTempDestruction();
CGF.EmitBranch(ContBlock);
-
+
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(RHSBlock);
-
+
Visit(E->getRHS());
CGF.PopConditionalTempDestruction();
CGF.EmitBranch(ContBlock);
-
+
CGF.EmitBlock(ContBlock);
}
@@ -328,16 +328,16 @@ void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
void AggExprEmitter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
llvm::Value *Val = DestPtr;
-
+
if (!Val) {
// Create a temporary variable.
Val = CGF.CreateTempAlloca(CGF.ConvertTypeForMem(E->getType()), "tmp");
// FIXME: volatile
CGF.EmitAggExpr(E->getSubExpr(), Val, false);
- } else
+ } else
Visit(E->getSubExpr());
-
+
// Don't make this a live temporary if we're emitting an initializer expr.
if (!IsInitializer)
CGF.PushCXXTemporary(E->getTemporary(), Val);
@@ -346,7 +346,7 @@ void AggExprEmitter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
void
AggExprEmitter::VisitCXXConstructExpr(const CXXConstructExpr *E) {
llvm::Value *Val = DestPtr;
-
+
if (!Val) {
// Create a temporary variable.
Val = CGF.CreateTempAlloca(CGF.ConvertTypeForMem(E->getType()), "tmp");
@@ -392,7 +392,7 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) {
void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
#if 0
- // FIXME: Disabled while we figure out what to do about
+ // FIXME: Disabled while we figure out what to do about
// test/CodeGen/bitfield.c
//
// If we can, prefer a copy from a global; this is a lot less code for long
@@ -420,7 +420,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
cast<llvm::PointerType>(DestPtr->getType());
const llvm::ArrayType *AType =
cast<llvm::ArrayType>(APType->getElementType());
-
+
uint64_t NumInitElements = E->getNumInits();
if (E->getNumInits() > 0) {
@@ -435,7 +435,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
uint64_t NumArrayElements = AType->getNumElements();
QualType ElementType = CGF.getContext().getCanonicalType(E->getType());
ElementType = CGF.getContext().getAsArrayType(ElementType)->getElementType();
-
+
unsigned CVRqualifier = ElementType.getCVRQualifiers();
for (uint64_t i = 0; i != NumArrayElements; ++i) {
@@ -449,9 +449,9 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
}
return;
}
-
+
assert(E->getType()->isRecordType() && "Only support structs/unions here!");
-
+
// Do struct initialization; this code just sets each individual member
// to the approprate value. This makes bitfield support automatic;
// the disadvantage is that the generated code is more difficult for
@@ -465,7 +465,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
// specified by the initializer list.
if (!E->getInitializedFieldInUnion()) {
// Empty union; we have nothing to do.
-
+
#ifndef NDEBUG
// Make sure that it's really an empty and not a failure of
// semantic analysis.
@@ -491,7 +491,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
return;
}
-
+
// Here we iterate over the fields; this makes it simpler to both
// default-initialize fields and skip over unnamed fields.
for (RecordDecl::field_iterator Field = SD->field_begin(),
@@ -528,13 +528,13 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
/// true, DestPtr cannot be 0.
void CodeGenFunction::EmitAggExpr(const Expr *E, llvm::Value *DestPtr,
bool VolatileDest, bool IgnoreResult,
- bool IsInitializer,
+ bool IsInitializer,
bool RequiresGCollection) {
assert(E && hasAggregateLLVMType(E->getType()) &&
"Invalid aggregate expression to emit");
assert ((DestPtr != 0 || VolatileDest == false)
&& "volatile aggregate can't be 0");
-
+
AggExprEmitter(*this, DestPtr, VolatileDest, IgnoreResult, IsInitializer,
RequiresGCollection)
.Visit(const_cast<Expr*>(E));
@@ -550,7 +550,7 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
llvm::Value *SrcPtr, QualType Ty,
bool isVolatile) {
assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex");
-
+
// Aggregate assignment turns into llvm.memcpy. This is almost valid per
// C99 6.5.16.1p3, which states "If the value being stored in an object is
// read from another object that overlaps in anyway the storage of the first
@@ -567,14 +567,14 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
if (SrcPtr->getType() != BP)
SrcPtr = Builder.CreateBitCast(SrcPtr, BP, "tmp");
-
+
// Get size and alignment info for this aggregate.
std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty);
-
+
// FIXME: Handle variable sized types.
const llvm::Type *IntPtr =
llvm::IntegerType::get(VMContext, LLVMPointerWidth);
-
+
// FIXME: If we have a volatile struct, the optimizer can remove what might
// appear to be `extra' memory ops:
//
@@ -591,6 +591,6 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
DestPtr, SrcPtr,
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
- llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
TypeInfo.second/8));
}
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp
index 593406f5d0..bea6d80b43 100644
--- a/lib/CodeGen/CGExprConstant.cpp
+++ b/lib/CodeGen/CGExprConstant.cpp
@@ -33,63 +33,63 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
CodeGenModule &CGM;
CodeGenFunction *CGF;
- bool Packed;
+ bool Packed;
unsigned NextFieldOffsetInBytes;
-
+
std::vector<llvm::Constant *> Elements;
ConstStructBuilder(CodeGenModule &CGM, CodeGenFunction *CGF)
: CGM(CGM), CGF(CGF), Packed(false), NextFieldOffsetInBytes(0) { }
- bool AppendField(const FieldDecl *Field, uint64_t FieldOffset,
+ bool AppendField(const FieldDecl *Field, uint64_t FieldOffset,
const Expr *InitExpr) {
uint64_t FieldOffsetInBytes = FieldOffset / 8;
-
- assert(NextFieldOffsetInBytes <= FieldOffsetInBytes
+
+ assert(NextFieldOffsetInBytes <= FieldOffsetInBytes
&& "Field offset mismatch!");
-
+
// Emit the field.
llvm::Constant *C = CGM.EmitConstantExpr(InitExpr, Field->getType(), CGF);
if (!C)
return false;
unsigned FieldAlignment = getAlignment(C);
-
+
// Round up the field offset to the alignment of the field type.
- uint64_t AlignedNextFieldOffsetInBytes =
+ uint64_t AlignedNextFieldOffsetInBytes =
llvm::RoundUpToAlignment(NextFieldOffsetInBytes, FieldAlignment);
-
+
if (AlignedNextFieldOffsetInBytes > FieldOffsetInBytes) {
std::vector<llvm::Constant *> PackedElements;
-
+
assert(!Packed && "Alignment is wrong even with a packed struct!");
-
+
// Convert the struct to a packed struct.
uint64_t ElementOffsetInBytes = 0;
-
+
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
llvm::Constant *C = Elements[i];
-
- unsigned ElementAlign =
+
+ unsigned ElementAlign =
CGM.getTargetData().getABITypeAlignment(C->getType());
- uint64_t AlignedElementOffsetInBytes =
+ uint64_t AlignedElementOffsetInBytes =
llvm::RoundUpToAlignment(ElementOffsetInBytes, ElementAlign);
-
+
if (AlignedElementOffsetInBytes > ElementOffsetInBytes) {
// We need some padding.
- uint64_t NumBytes =
+ uint64_t NumBytes =
AlignedElementOffsetInBytes - ElementOffsetInBytes;
-
+
const llvm::Type *Ty = llvm::Type::getInt8Ty(CGF->getLLVMContext());
- if (NumBytes > 1)
+ if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
-
+
llvm::Constant *Padding = llvm::Constant::getNullValue(Ty);
PackedElements.push_back(Padding);
ElementOffsetInBytes += getSizeInBytes(Padding);
}
-
+
PackedElements.push_back(C);
ElementOffsetInBytes += getSizeInBytes(C);
}
@@ -105,51 +105,51 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
// We need to append padding.
AppendPadding(FieldOffsetInBytes - NextFieldOffsetInBytes);
-
+
assert(NextFieldOffsetInBytes == FieldOffsetInBytes &&
"Did not add enough padding!");
-
+
AlignedNextFieldOffsetInBytes = NextFieldOffsetInBytes;
}
-
+
// Add the field.
Elements.push_back(C);
NextFieldOffsetInBytes = AlignedNextFieldOffsetInBytes + getSizeInBytes(C);
return true;
}
-
- bool AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
+
+ bool AppendBitField(const FieldDecl *Field, uint64_t FieldOffset,
const Expr *InitExpr) {
- llvm::ConstantInt *CI =
- cast_or_null<llvm::ConstantInt>(CGM.EmitConstantExpr(InitExpr,
- Field->getType(),
+ llvm::ConstantInt *CI =
+ cast_or_null<llvm::ConstantInt>(CGM.EmitConstantExpr(InitExpr,
+ Field->getType(),
CGF));
// FIXME: Can this ever happen?
if (!CI)
return false;
-
+
if (FieldOffset > NextFieldOffsetInBytes * 8) {
// We need to add padding.
- uint64_t NumBytes =
- llvm::RoundUpToAlignment(FieldOffset -
+ uint64_t NumBytes =
+ llvm::RoundUpToAlignment(FieldOffset -
NextFieldOffsetInBytes * 8, 8) / 8;
-
+
AppendPadding(NumBytes);
}
- uint64_t FieldSize =
+ uint64_t FieldSize =
Field->getBitWidth()->EvaluateAsInt(CGM.getContext()).getZExtValue();
llvm::APInt FieldValue = CI->getValue();
-
+
// Promote the size of FieldValue if necessary
// FIXME: This should never occur, but currently it can because initializer
// constants are cast to bool, and because clang is not enforcing bitfield
// width limits.
if (FieldSize > FieldValue.getBitWidth())
FieldValue.zext(FieldSize);
-
+
// Truncate the size of FieldValue to the bit field size.
if (FieldSize < FieldValue.getBitWidth())
FieldValue.trunc(FieldSize);
@@ -158,18 +158,18 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
// Either part of the field or the entire field can go into the previous
// byte.
assert(!Elements.empty() && "Elements can't be empty!");
-
- unsigned BitsInPreviousByte =
+
+ unsigned BitsInPreviousByte =
NextFieldOffsetInBytes * 8 - FieldOffset;
-
- bool FitsCompletelyInPreviousByte =
+
+ bool FitsCompletelyInPreviousByte =
BitsInPreviousByte >= FieldValue.getBitWidth();
-
+
llvm::APInt Tmp = FieldValue;
-
+
if (!FitsCompletelyInPreviousByte) {
unsigned NewFieldWidth = FieldSize - BitsInPreviousByte;
-
+
if (CGM.getTargetData().isBigEndian()) {
Tmp = Tmp.lshr(NewFieldWidth);
Tmp.trunc(BitsInPreviousByte);
@@ -184,7 +184,7 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
FieldValue.trunc(NewFieldWidth);
}
}
-
+
Tmp.zext(8);
if (CGM.getTargetData().isBigEndian()) {
if (FitsCompletelyInPreviousByte)
@@ -196,14 +196,14 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
// Or in the bits that go into the previous byte.
Tmp |= cast<llvm::ConstantInt>(Elements.back())->getValue();
Elements.back() = llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp);
-
+
if (FitsCompletelyInPreviousByte)
return true;
}
-
+
while (FieldValue.getBitWidth() > 8) {
llvm::APInt Tmp;
-
+
if (CGM.getTargetData().isBigEndian()) {
// We want the high bits.
Tmp = FieldValue;
@@ -213,13 +213,13 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
// We want the low bits.
Tmp = FieldValue;
Tmp.trunc(8);
-
+
FieldValue = FieldValue.lshr(8);
}
-
+
Elements.push_back(llvm::ConstantInt::get(CGM.getLLVMContext(), Tmp));
NextFieldOffsetInBytes++;
-
+
FieldValue.trunc(FieldValue.getBitWidth() - 8);
}
@@ -231,10 +231,10 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
if (FieldValue.getBitWidth() < 8) {
if (CGM.getTargetData().isBigEndian()) {
unsigned BitWidth = FieldValue.getBitWidth();
-
+
FieldValue.zext(8);
FieldValue = FieldValue << (8 - BitWidth);
- } else
+ } else
FieldValue.zext(8);
}
@@ -244,19 +244,19 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
NextFieldOffsetInBytes++;
return true;
}
-
+
void AppendPadding(uint64_t NumBytes) {
if (!NumBytes)
return;
const llvm::Type *Ty = llvm::Type::getInt8Ty(CGM.getLLVMContext());
- if (NumBytes > 1)
+ if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
llvm::Constant *C = llvm::Constant::getNullValue(Ty);
Elements.push_back(C);
assert(getAlignment(C) == 1 && "Padding must have 1 byte alignment!");
-
+
NextFieldOffsetInBytes += getSizeInBytes(C);
}
@@ -265,19 +265,19 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
uint64_t RecordSizeInBytes = RecordSize / 8;
assert(NextFieldOffsetInBytes <= RecordSizeInBytes && "Size mismatch!");
-
+
unsigned NumPadBytes = RecordSizeInBytes - NextFieldOffsetInBytes;
AppendPadding(NumPadBytes);
}
-
+
bool Build(InitListExpr *ILE) {
RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
-
+
unsigned FieldNo = 0;
unsigned ElementNo = 0;
- for (RecordDecl::field_iterator Field = RD->field_begin(),
- FieldEnd = RD->field_end();
+ for (RecordDecl::field_iterator Field = RD->field_begin(),
+ FieldEnd = RD->field_end();
ElementNo < ILE->getNumInits() && Field != FieldEnd;
++Field, ++FieldNo) {
if (RD->isUnion() && ILE->getInitializedFieldInUnion() != *Field)
@@ -286,7 +286,7 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
if (Field->isBitField()) {
if (!Field->getIdentifier())
continue;
-
+
if (!AppendBitField(*Field, Layout.getFieldOffset(FieldNo),
ILE->getInit(ElementNo)))
return false;
@@ -295,63 +295,63 @@ class VISIBILITY_HIDDEN ConstStructBuilder {
ILE->getInit(ElementNo)))
return false;
}
-
+
ElementNo++;
}
-
+
uint64_t LayoutSizeInBytes = Layout.getSize() / 8;
-
+
if (NextFieldOffsetInBytes > LayoutSizeInBytes) {
// If the struct is bigger than the size of the record type,
// we must have a flexible array member at the end.
assert(RD->hasFlexibleArrayMember() &&
"Must have flexible array member if struct is bigger than type!");
-
+
// No tail padding is necessary.
return true;
}
-
+
// Append tail padding if necessary.
AppendTailPadding(Layout.getSize());
-
- assert(Layout.getSize() / 8 == NextFieldOffsetInBytes &&
+
+ assert(Layout.getSize() / 8 == NextFieldOffsetInBytes &&
"Tail padding mismatch!");
-
+
return true;
}
-
+
unsigned getAlignment(const llvm::Constant *C) const {
if (Packed)
return 1;
-
+
return CGM.getTargetData().getABITypeAlignment(C->getType());
}
-
+
uint64_t getSizeInBytes(const llvm::Constant *C) const {
return CGM.getTargetData().getTypeAllocSize(C->getType());
}
-
+
public:
static llvm::Constant *BuildStruct(CodeGenModule &CGM, CodeGenFunction *CGF,
InitListExpr *ILE) {
ConstStructBuilder Builder(CGM, CGF);
-
+
if (!Builder.Build(ILE))
return 0;
-
- llvm::Constant *Result =
+
+ llvm::Constant *Result =
llvm::ConstantStruct::get(CGM.getLLVMContext(),
Builder.Elements, Builder.Packed);
assert(llvm::RoundUpToAlignment(Builder.NextFieldOffsetInBytes,
- Builder.getAlignment(Result)) ==
+ Builder.getAlignment(Result)) ==
Builder.getSizeInBytes(Result) && "Size mismatch!");
return Result;
}
};
-
-class VISIBILITY_HIDDEN ConstExprEmitter :
+
+class VISIBILITY_HIDDEN ConstExprEmitter :
public StmtVisitor<ConstExprEmitter, llvm::Constant*> {
CodeGenModule &CGM;
CodeGenFunction *CGF;
@@ -360,23 +360,23 @@ public:
ConstExprEmitter(CodeGenModule &cgm, CodeGenFunction *cgf)
: CGM(cgm), CGF(cgf), VMContext(cgm.getLLVMContext()) {
}
-
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
-
+
llvm::Constant *VisitStmt(Stmt *S) {
return 0;
}
-
- llvm::Constant *VisitParenExpr(ParenExpr *PE) {
- return Visit(PE->getSubExpr());
+
+ llvm::Constant *VisitParenExpr(ParenExpr *PE) {
+ return Visit(PE->getSubExpr());
}
-
+
llvm::Constant *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
return Visit(E->getInitializer());
}
-
+
llvm::Constant *VisitCastExpr(CastExpr* E) {
switch (E->getCastKind()) {
case CastExpr::CK_ToUnion: {
@@ -386,11 +386,11 @@ public:
const llvm::Type *Ty = ConvertType(E->getType());
Expr *SubExpr = E->getSubExpr();
- llvm::Constant *C =
+ llvm::Constant *C =
CGM.EmitConstantExpr(SubExpr, SubExpr->getType(), CGF);
if (!C)
return 0;
-
+
// Build a struct with the union sub-element as the first member,
// and padded to the appropriate size
std::vector<llvm::Constant*> Elts;
@@ -399,7 +399,7 @@ public:
Types.push_back(C->getType());
unsigned CurSize = CGM.getTargetData().getTypeAllocSize(C->getType());
unsigned TotalSize = CGM.getTargetData().getTypeAllocSize(Ty);
-
+
assert(CurSize <= TotalSize && "Union size mismatch!");
if (unsigned NumPadBytes = TotalSize - CurSize) {
const llvm::Type *Ty = llvm::Type::getInt8Ty(VMContext);
@@ -409,7 +409,7 @@ public:
Elts.push_back(llvm::Constant::getNullValue(Ty));
Types.push_back(Ty);
}
-
+
llvm::StructType* STy =
llvm::StructType::get(C->getType()->getContext(), Types, false);
return llvm::ConstantStruct::get(STy, Elts);
@@ -438,7 +438,7 @@ public:
unsigned NumInitElements = ILE->getNumInits();
// FIXME: Check for wide strings
// FIXME: Check for NumInitElements exactly equal to 1??
- if (NumInitElements > 0 &&
+ if (NumInitElements > 0 &&
(isa<StringLiteral>(ILE->getInit(0)) ||
isa<ObjCEncodeExpr>(ILE->getInit(0))) &&
ILE->getType()->getArrayElementTypeNoTypeQual()->isCharType())
@@ -446,7 +446,7 @@ public:
const llvm::Type *ElemTy = AType->getElementType();
unsigned NumElements = AType->getNumElements();
- // Initialising an array requires us to automatically
+ // Initialising an array requires us to automatically
// initialise any elements that have not been initialised explicitly
unsigned NumInitableElts = std::min(NumInitElements, NumElements);
@@ -472,18 +472,18 @@ public:
std::vector<const llvm::Type*> Types;
for (unsigned i = 0; i < Elts.size(); ++i)
Types.push_back(Elts[i]->getType());
- const llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
+ const llvm::StructType *SType = llvm::StructType::get(AType->getContext(),
Types, true);
return llvm::ConstantStruct::get(SType, Elts);
}
- return llvm::ConstantArray::get(AType, Elts);
+ return llvm::ConstantArray::get(AType, Elts);
}
llvm::Constant *EmitStructInitialization(InitListExpr *ILE) {
return ConstStructBuilder::BuildStruct(CGM, CGF, ILE);
}
-
+
llvm::Constant *EmitUnionInitialization(InitListExpr *ILE) {
return ConstStructBuilder::BuildStruct(CGM, CGF, ILE);
}
@@ -511,13 +511,13 @@ public:
for (; i < NumElements; ++i)
Elts.push_back(llvm::Constant::getNullValue(ElemTy));
- return llvm::ConstantVector::get(VType, Elts);
+ return llvm::ConstantVector::get(VType, Elts);
}
-
+
llvm::Constant *VisitImplicitValueInitExpr(ImplicitValueInitExpr* E) {
return CGM.EmitNullConstant(E->getType());
}
-
+
llvm::Constant *VisitInitListExpr(InitListExpr *ILE) {
if (ILE->getType()->isScalarType()) {
// We have a scalar in braces. Just use the first element.
@@ -527,7 +527,7 @@ public:
}
return CGM.EmitNullConstant(ILE->getType());
}
-
+
if (ILE->getType()->isArrayType())
return EmitArrayInitialization(ILE);
@@ -548,7 +548,7 @@ public:
llvm::Constant *VisitStringLiteral(StringLiteral *E) {
assert(!E->getType()->isPointerType() && "Strings are always arrays");
-
+
// This must be a string initializing an array in a static initializer.
// Don't emit it as the address of the string, emit the string data itself
// as an inline array.
@@ -563,13 +563,13 @@ public:
std::string Str;
CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
const ConstantArrayType *CAT = cast<ConstantArrayType>(E->getType());
-
+
// Resize the string to the right size, adding zeros at the end, or
// truncating as needed.
Str.resize(CAT->getSize().getZExtValue(), '\0');
return llvm::ConstantArray::get(VMContext, Str, false);
}
-
+
llvm::Constant *VisitUnaryExtension(const UnaryOperator *E) {
return Visit(E->getSubExpr());
}
@@ -597,14 +597,14 @@ public:
E->getType().getAddressSpace());
return C;
}
- case Expr::DeclRefExprClass:
+ case Expr::DeclRefExprClass:
case Expr::QualifiedDeclRefExprClass: {
NamedDecl *Decl = cast<DeclRefExpr>(E)->getDecl();
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
return CGM.GetAddrOfFunction(GlobalDecl(FD));
if (const VarDecl* VD = dyn_cast<VarDecl>(Decl)) {
// We can never refer to a variable with local storage.
- if (!VD->hasLocalStorage()) {
+ if (!VD->hasLocalStorage()) {
if (VD->isFileVarDecl() || VD->hasExternalStorage())
return CGM.GetAddrOfGlobalVar(VD);
else if (VD->isBlockVarDecl()) {
@@ -627,10 +627,10 @@ public:
case Expr::PredefinedExprClass: {
// __func__/__FUNCTION__ -> "". __PRETTY_FUNCTION__ -> "top level".
std::string Str;
- if (cast<PredefinedExpr>(E)->getIdentType() ==
+ if (cast<PredefinedExpr>(E)->getIdentType() ==
PredefinedExpr::PrettyFunction)
Str = "top level";
-
+
return CGM.GetAddrOfConstantCString(Str, ".tmp");
}
case Expr::AddrLabelExprClass: {
@@ -643,7 +643,7 @@ public:
}
case Expr::CallExprClass: {
CallExpr* CE = cast<CallExpr>(E);
- if (CE->isBuiltinCall(CGM.getContext()) !=
+ if (CE->isBuiltinCall(CGM.getContext()) !=
Builtin::BI__builtin___CFStringMakeConstantString)
break;
const Expr *Arg = CE->getArg(0)->IgnoreParenCasts();
@@ -665,23 +665,23 @@ public:
return 0;
}
};
-
+
} // end anonymous namespace.
llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
QualType DestType,
CodeGenFunction *CGF) {
Expr::EvalResult Result;
-
+
bool Success = false;
-
+
if (DestType->isReferenceType())
Success = E->EvaluateAsLValue(Result, Context);
- else
+ else
Success = E->Evaluate(Result, Context);
-
+
if (Success) {
- assert(!Result.HasSideEffects &&
+ assert(!Result.HasSideEffects &&
"Constant expr should not have any side effects!");
switch (Result.Val.getKind()) {
case APValue::Uninitialized:
@@ -689,17 +689,17 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
return 0;
case APValue::LValue: {
const llvm::Type *DestTy = getTypes().ConvertTypeForMem(DestType);
- llvm::Constant *Offset =
- llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext),
+ llvm::Constant *Offset =
+ llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext),
Result.Val.getLValueOffset());
-
+
llvm::Constant *C;
if (const Expr *LVBase = Result.Val.getLValueBase()) {
C = ConstExprEmitter(*this, CGF).EmitLValue(const_cast<Expr*>(LVBase));
// Apply offset if necessary.
if (!Offset->isNullValue()) {
- const llvm::Type *Type =
+ const llvm::Type *Type =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Type);
Casted = llvm::ConstantExpr::getGetElementPtr(Casted, &Offset, 1);
@@ -728,9 +728,9 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
}
}
case APValue::Int: {
- llvm::Constant *C = llvm::ConstantInt::get(VMContext,
+ llvm::Constant *C = llvm::ConstantInt::get(VMContext,
Result.Val.getInt());
-
+
if (C->getType() == llvm::Type::getInt1Ty(VMContext)) {
const llvm::Type *BoolTy = getTypes().ConvertTypeForMem(E->getType());
C = llvm::ConstantExpr::getZExt(C, BoolTy);
@@ -739,30 +739,30 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
}
case APValue::ComplexInt: {
llvm::Constant *Complex[2];
-
+
Complex[0] = llvm::ConstantInt::get(VMContext,
Result.Val.getComplexIntReal());
- Complex[1] = llvm::ConstantInt::get(VMContext,
+ Complex[1] = llvm::ConstantInt::get(VMContext,
Result.Val.getComplexIntImag());
-
+
return llvm::ConstantStruct::get(VMContext, Complex, 2);
}
case APValue::Float:
return llvm::ConstantFP::get(VMContext, Result.Val.getFloat());
case APValue::ComplexFloat: {
llvm::Constant *Complex[2];
-
- Complex[0] = llvm::ConstantFP::get(VMContext,
+
+ Complex[0] = llvm::ConstantFP::get(VMContext,
Result.Val.getComplexFloatReal());
Complex[1] = llvm::ConstantFP::get(VMContext,
Result.Val.getComplexFloatImag());
-
+
return llvm::ConstantStruct::get(VMContext, Complex, 2);
}
case APValue::Vector: {
llvm::SmallVector<llvm::Constant *, 4> Inits;
unsigned NumElts = Result.Val.getVectorLength();
-
+
for (unsigned i = 0; i != NumElts; ++i) {
APValue &Elt = Result.Val.getVectorElt(i);
if (Elt.isInt())
@@ -787,9 +787,9 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
// No need to check for member pointers when not compiling C++.
if (!getContext().getLangOptions().CPlusPlus)
return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
-
+
if (const ConstantArrayType *CAT = Context.getAsConstantArrayType(T)) {
-
+
QualType ElementTy = CAT->getElementType();
// FIXME: Handle arrays of structs that contain member pointers.
@@ -799,8 +799,8 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
std::vector<llvm::Constant *> Array(NumElements);
for (uint64_t i = 0; i != NumElements; ++i)
Array[i] = Element;
-
- const llvm::ArrayType *ATy =
+
+ const llvm::ArrayType *ATy =
cast<llvm::ArrayType>(getTypes().ConvertTypeForMem(T));
return llvm::ConstantArray::get(ATy, Array);
}
@@ -808,19 +808,19 @@ llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
if (const RecordType *RT = T->getAs<RecordType>()) {
const RecordDecl *RD = RT->getDecl();
- // FIXME: It would be better if there was a way to explicitly compute the
+ // FIXME: It would be better if there was a way to explicitly compute the
// record layout instead of converting to a type.
Types.ConvertTagDeclType(RD);
-
+
const CGRecordLayout &Layout = Types.getCGRecordLayout(RD);
if (Layout.containsMemberPointer()) {
assert(0 && "FIXME: No support for structs with member pointers yet!");
}
}
-
+
// FIXME: Handle structs that contain member pointers.
- if (T->isMemberPointerType())
+ if (T->isMemberPointerType())
return llvm::Constant::getAllOnesValue(getTypes().ConvertTypeForMem(T));
-
+
return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));
}
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 3dc95902af..b4ce838af3 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -889,8 +889,7 @@ Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) {
return llvm::Constant::getNullValue(ConvertType(E->getType()));
}
-Value *ScalarExprEmitter::VisitUnaryOffsetOf(const UnaryOperator *E)
-{
+Value *ScalarExprEmitter::VisitUnaryOffsetOf(const UnaryOperator *E) {
Value* ResultAsPtr = EmitLValue(E->getSubExpr()).getAddress();
const llvm::Type* ResultType = ConvertType(E->getType());
return Builder.CreatePtrToInt(ResultAsPtr, ResultType, "offsetof");
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 5899912981..d437df484b 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -24,7 +24,7 @@ using namespace clang;
using namespace CodeGen;
/// Emits an instance of NSConstantString representing the object.
-llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E)
+llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E)
{
llvm::Constant *C = CGM.getObjCRuntime().GenerateConstantString(E);
// FIXME: This bitcast should just be made an invariant on the Runtime.
@@ -50,7 +50,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) {
// Only the lookup mechanism and first two arguments of the method
// implementation vary between runtimes. We can get the receiver and
// arguments in generic code.
-
+
CGObjCRuntime &Runtime = CGM.getObjCRuntime();
const Expr *ReceiverExpr = E->getReceiver();
bool isSuperMessage = false;
@@ -70,7 +70,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) {
} else {
Receiver = Runtime.GetClass(Builder, OID);
}
-
+
isClassMessage = true;
} else if (isa<ObjCSuperExpr>(E->getReceiver())) {
isSuperMessage = true;
@@ -81,7 +81,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) {
CallArgList Args;
EmitCallArgs(Args, E->getMethodDecl(), E->arg_begin(), E->arg_end());
-
+
if (isSuperMessage) {
// super is only valid in an Objective-C method
const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
@@ -94,7 +94,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) {
isClassMessage,
Args);
}
- return Runtime.GenerateMessageSend(*this, E->getType(), E->getSelector(),
+ return Runtime.GenerateMessageSend(*this, E->getType(), E->getSelector(),
Receiver, isClassMessage, Args,
E->getMethodDecl());
}
@@ -110,7 +110,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(OMD);
CGM.SetInternalFunctionAttributes(OMD, Fn, FI);
- Args.push_back(std::make_pair(OMD->getSelfDecl(),
+ Args.push_back(std::make_pair(OMD->getSelfDecl(),
OMD->getSelfDecl()->getType()));
Args.push_back(std::make_pair(OMD->getCmdDecl(),
OMD->getCmdDecl()->getType()));
@@ -123,7 +123,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
}
/// Generate an Objective-C method. An Objective-C method is a C function with
-/// its pointer, name, and types registered in the class struture.
+/// its pointer, name, and types registered in the class struture.
void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
// Check if we should generate debug info for this method.
if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
@@ -159,9 +159,9 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic) &&
(PD->getSetterKind() == ObjCPropertyDecl::Copy ||
PD->getSetterKind() == ObjCPropertyDecl::Retain)) {
- llvm::Value *GetPropertyFn =
+ llvm::Value *GetPropertyFn =
CGM.getObjCRuntime().GetPropertyGetFunction();
-
+
if (!GetPropertyFn) {
CGM.ErrorUnsupported(PID, "Obj-C getter requiring atomic copy");
FinishFunction();
@@ -175,7 +175,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
ValueDecl *Cmd = OMD->getCmdDecl();
llvm::Value *CmdVal = Builder.CreateLoad(LocalDeclMap[Cmd], "cmd");
QualType IdTy = getContext().getObjCIdType();
- llvm::Value *SelfAsId =
+ llvm::Value *SelfAsId =
Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
llvm::Value *True =
@@ -187,12 +187,12 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
Args.push_back(std::make_pair(RValue::get(True), getContext().BoolTy));
// FIXME: We shouldn't need to get the function info here, the
// runtime already should have computed it to build the function.
- RValue RV = EmitCall(Types.getFunctionInfo(PD->getType(), Args),
+ RValue RV = EmitCall(Types.getFunctionInfo(PD->getType(), Args),
GetPropertyFn, Args);
// We need to fix the type here. Ivars with copy & retain are
// always objects so we don't need to worry about complex or
// aggregates.
- RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
+ RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
Types.ConvertType(PD->getType())));
EmitReturnOfRValue(RV, PD->getType());
} else {
@@ -203,7 +203,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
CodeGenTypes &Types = CGM.getTypes();
RValue RV = EmitLoadOfLValue(LV, Ivar->getType());
RV = RValue::get(Builder.CreateBitCast(RV.getScalarVal(),
- Types.ConvertType(PD->getType())));
+ Types.ConvertType(PD->getType())));
EmitReturnOfRValue(RV, PD->getType());
}
}
@@ -226,7 +226,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
StartObjCMethod(OMD, IMP->getClassInterface());
bool IsCopy = PD->getSetterKind() == ObjCPropertyDecl::Copy;
- bool IsAtomic =
+ bool IsAtomic =
!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic);
// Determine if we should use an objc_setProperty call for
@@ -236,16 +236,16 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
if (IsCopy ||
(CGM.getLangOptions().getGCMode() != LangOptions::GCOnly &&
PD->getSetterKind() == ObjCPropertyDecl::Retain)) {
- llvm::Value *SetPropertyFn =
+ llvm::Value *SetPropertyFn =
CGM.getObjCRuntime().GetPropertySetFunction();
-
+
if (!SetPropertyFn) {
CGM.ErrorUnsupported(PID, "Obj-C getter requiring atomic copy");
FinishFunction();
return;
}
-
- // Emit objc_setProperty((id) self, _cmd, offset, arg,
+
+ // Emit objc_setProperty((id) self, _cmd, offset, arg,
// <is-atomic>, <is-copy>).
// FIXME: Can't this be simpler? This might even be worse than the
// corresponding gcc code.
@@ -253,11 +253,11 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
ValueDecl *Cmd = OMD->getCmdDecl();
llvm::Value *CmdVal = Builder.CreateLoad(LocalDeclMap[Cmd], "cmd");
QualType IdTy = getContext().getObjCIdType();
- llvm::Value *SelfAsId =
+ llvm::Value *SelfAsId =
Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy));
llvm::Value *Offset = EmitIvarOffset(IMP->getClassInterface(), Ivar);
llvm::Value *Arg = LocalDeclMap[*OMD->param_begin()];
- llvm::Value *ArgAsId =
+ llvm::Value *ArgAsId =
Builder.CreateBitCast(Builder.CreateLoad(Arg, "arg"),
Types.ConvertType(IdTy));
llvm::Value *True =
@@ -269,13 +269,13 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
Args.push_back(std::make_pair(RValue::get(CmdVal), Cmd->getType()));
Args.push_back(std::make_pair(RValue::get(Offset), getContext().LongTy));
Args.push_back(std::make_pair(RValue::get(ArgAsId), IdTy));
- Args.push_back(std::make_pair(RValue::get(IsAtomic ? True : False),
+ Args.push_back(std::make_pair(RValue::get(IsAtomic ? True : False),
getContext().BoolTy));
- Args.push_back(std::make_pair(RValue::get(IsCopy ? True : False),
+ Args.push_back(std::make_pair(RValue::get(IsCopy ? True : False),
getContext().BoolTy));
// FIXME: We shouldn't need to get the function info here, the runtime
// already should have computed it to build the function.
- EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args),
+ EmitCall(Types.getFunctionInfo(getContext().VoidTy, Args),
SetPropertyFn, Args);
} else {
SourceLocation Loc = PD->getLocation();
@@ -309,13 +309,13 @@ QualType CodeGenFunction::TypeOfSelfObject() {
return PTy->getPointeeType();
}
-RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp,
+RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp,
const Selector &S) {
llvm::Value *Receiver = LoadObjCSelf();
const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
bool isClassMessage = OMD->isClassMethod();
bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext());
- return CGM.getObjCRuntime().GenerateMessageSendSuper(*this,
+ return CGM.getObjCRuntime().GenerateMessageSendSuper(*this,
Exp->getType(),
S,
OMD->getClassInterface(),
@@ -323,7 +323,7 @@ RValue CodeGenFunction::EmitObjCSuperPropertyGet(const Expr *Exp,
Receiver,
isClassMessage,
CallArgList());
-
+
}
RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) {
@@ -334,11 +334,11 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) {
if (isa<ObjCSuperExpr>(E->getBase()))
return EmitObjCSuperPropertyGet(E, S);
return CGM.getObjCRuntime().
- GenerateMessageSend(*this, Exp->getType(), S,
- EmitScalarExpr(E->getBase()),
+ GenerateMessageSend(*this, Exp->getType(), S,
+ EmitScalarExpr(E->getBase()),
false, CallArgList());
} else {
- const ObjCImplicitSetterGetterRefExpr *KE =
+ const ObjCImplicitSetterGetterRefExpr *KE =
cast<ObjCImplicitSetterGetterRefExpr>(Exp);
Selector S = KE->getGetterMethod()->getSelector();
llvm::Value *Receiver;
@@ -347,11 +347,11 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) {
Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
} else if (isa<ObjCSuperExpr>(KE->getBase()))
return EmitObjCSuperPropertyGet(KE, S);
- else
+ else
Receiver = EmitScalarExpr(KE->getBase());
return CGM.getObjCRuntime().
- GenerateMessageSend(*this, Exp->getType(), S,
- Receiver,
+ GenerateMessageSend(*this, Exp->getType(), S,
+ Receiver,
KE->getInterfaceDecl() != 0, CallArgList());
}
}
@@ -365,7 +365,7 @@ void CodeGenFunction::EmitObjCSuperPropertySet(const Expr *Exp,
bool isClassMessage = OMD->isClassMethod();
bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext());
Args.push_back(std::make_pair(Src, Exp->getType()));
- CGM.getObjCRuntime().GenerateMessageSendSuper(*this,
+ CGM.getObjCRuntime().GenerateMessageSendSuper(*this,
Exp->getType(),
S,
OMD->getClassInterface(),
@@ -384,13 +384,13 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp,
if (isa<ObjCSuperExpr>(E->getBase())) {
EmitObjCSuperPropertySet(E, S, Src);
return;
- }
+ }
CallArgList Args;
Args.push_back(std::make_pair(Src, E->getType()));
- CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
- EmitScalarExpr(E->getBase()),
+ CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
+ EmitScalarExpr(E->getBase()),
false, Args);
- } else if (const ObjCImplicitSetterGetterRefExpr *E =
+ } else if (const ObjCImplicitSetterGetterRefExpr *E =
dyn_cast<ObjCImplicitSetterGetterRefExpr>(Exp)) {
Selector S = E->getSetterMethod()->getSelector();
CallArgList Args;
@@ -404,19 +404,19 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp,
} else
Receiver = EmitScalarExpr(E->getBase());
Args.push_back(std::make_pair(Src, E->getType()));
- CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
- Receiver,
+ CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
+ Receiver,
E->getInterfaceDecl() != 0, Args);
} else
assert (0 && "bad expression node in EmitObjCPropertySet");
}
void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
- llvm::Constant *EnumerationMutationFn =
+ llvm::Constant *EnumerationMutationFn =
CGM.getObjCRuntime().EnumerationMutationFunction();
llvm::Value *DeclAddress;
QualType ElementTy;
-
+
if (!EnumerationMutationFn) {
CGM.ErrorUnsupported(&S, "Obj-C fast enumeration for this runtime");
return;
@@ -427,62 +427,62 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
assert(HaveInsertPoint() && "DeclStmt destroyed insert point!");
const Decl* D = SD->getSingleDecl();
ElementTy = cast<ValueDecl>(D)->getType();
- DeclAddress = LocalDeclMap[D];
+ DeclAddress = LocalDeclMap[D];
} else {
ElementTy = cast<Expr>(S.getElement())->getType();
DeclAddress = 0;
}
-
+
// Fast enumeration state.
QualType StateTy = getContext().getObjCFastEnumerationStateType();
- llvm::AllocaInst *StatePtr = CreateTempAlloca(ConvertType(StateTy),
+ llvm::AllocaInst *StatePtr = CreateTempAlloca(ConvertType(StateTy),
"state.ptr");
- StatePtr->setAlignment(getContext().getTypeAlign(StateTy) >> 3);
+ StatePtr->setAlignment(getContext().getTypeAlign(StateTy) >> 3);
EmitMemSetToZero(StatePtr, StateTy);
-
+
// Number of elements in the items array.
static const unsigned NumItems = 16;
-
+
// Get selector
llvm::SmallVector<IdentifierInfo*, 3> II;
II.push_back(&CGM.getContext().Idents.get("countByEnumeratingWithState"));
II.push_back(&CGM.getContext().Idents.get("objects"));
II.push_back(&CGM.getContext().Idents.get("count"));
- Selector FastEnumSel = CGM.getContext().Selectors.getSelector(II.size(),
+ Selector FastEnumSel = CGM.getContext().Selectors.getSelector(II.size(),
&II[0]);
QualType ItemsTy =
getContext().getConstantArrayType(getContext().getObjCIdType(),
- llvm::APInt(32, NumItems),
+ llvm::APInt(32, NumItems),
ArrayType::Normal, 0);
llvm::Value *ItemsPtr = CreateTempAlloca(ConvertType(ItemsTy), "items.ptr");
-
+
llvm::Value *Collection = EmitScalarExpr(S.getCollection());
-
+
CallArgList Args;
- Args.push_back(std::make_pair(RValue::get(StatePtr),
+ Args.push_back(std::make_pair(RValue::get(StatePtr),
getContext().getPointerType(StateTy)));
-
- Args.push_back(std::make_pair(RValue::get(ItemsPtr),
+
+ Args.push_back(std::make_pair(RValue::get(ItemsPtr),
getContext().getPointerType(ItemsTy)));
-
+
const llvm::Type *UnsignedLongLTy = ConvertType(getContext().UnsignedLongTy);
llvm::Constant *Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems);
- Args.push_back(std::make_pair(RValue::get(Count),
+ Args.push_back(std::make_pair(RValue::get(Count),
getContext().UnsignedLongTy));
-
- RValue CountRV =
- CGM.getObjCRuntime().GenerateMessageSend(*this,
+
+ RValue CountRV =
+ CGM.getObjCRuntime().GenerateMessageSend(*this,
getContext().UnsignedLongTy,
FastEnumSel,
Collection, false, Args);
llvm::Value *LimitPtr = CreateTempAlloca(UnsignedLongLTy, "limit.ptr");
Builder.CreateStore(CountRV.getScalarVal(), LimitPtr);
-
+
llvm::BasicBlock *NoElements = createBasicBlock("noelements");
llvm::BasicBlock *SetStartMutations = createBasicBlock("setstartmutations");
-
+
llvm::Value *Limit = Builder.CreateLoad(LimitPtr);
llvm::Value *Zero = llvm::Constant::getNullValue(UnsignedLongLTy);
@@ -490,60 +490,60 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
Builder.CreateCondBr(IsZero, NoElements, SetStartMutations);
EmitBlock(SetStartMutations);
-
- llvm::Value *StartMutationsPtr =
+
+ llvm::Value *StartMutationsPtr =
CreateTempAlloca(UnsignedLongLTy);
-
- llvm::Value *StateMutationsPtrPtr =
+
+ llvm::Value *StateMutationsPtrPtr =
Builder.CreateStructGEP(StatePtr, 2, "mutationsptr.ptr");
- llvm::Value *StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr,
+ llvm::Value *StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr,
"mutationsptr");
-
- llvm::Value *StateMutations = Builder.CreateLoad(StateMutationsPtr,
+
+ llvm::Value *StateMutations = Builder.CreateLoad(StateMutationsPtr,
"mutations");
-
+
Builder.CreateStore(StateMutations, StartMutationsPtr);
-
+
llvm::BasicBlock *LoopStart = createBasicBlock("loopstart");
EmitBlock(LoopStart);
llvm::Value *CounterPtr = CreateTempAlloca(UnsignedLongLTy, "counter.ptr");
Builder.CreateStore(Zero, CounterPtr);
-
- llvm::BasicBlock *LoopBody = createBasicBlock("loopbody");
+
+ llvm::BasicBlock *LoopBody = createBasicBlock("loopbody");
EmitBlock(LoopBody);
StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr");
StateMutations = Builder.CreateLoad(StateMutationsPtr, "statemutations");
- llvm::Value *StartMutations = Builder.CreateLoad(StartMutationsPtr,
+ llvm::Value *StartMutations = Builder.CreateLoad(StartMutationsPtr,
"mutations");
- llvm::Value *MutationsEqual = Builder.CreateICmpEQ(StateMutations,
+ llvm::Value *MutationsEqual = Builder.CreateICmpEQ(StateMutations,
StartMutations,
"tobool");
-
-
+
+
llvm::BasicBlock *WasMutated = createBasicBlock("wasmutated");
llvm::BasicBlock *WasNotMutated = createBasicBlock("wasnotmutated");
-
+
Builder.CreateCondBr(MutationsEqual, WasNotMutated, WasMutated);
-
+
EmitBlock(WasMutated);
llvm::Value *V =
- Builder.CreateBitCast(Collection,
+ Builder.CreateBitCast(Collection,
ConvertType(getContext().getObjCIdType()),
"tmp");
CallArgList Args2;
- Args2.push_back(std::make_pair(RValue::get(V),
+ Args2.push_back(std::make_pair(RValue::get(V),
getContext().getObjCIdType()));
// FIXME: We shouldn't need to get the function info here, the runtime already
// should have computed it to build the function.
- EmitCall(CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args2),
+ EmitCall(CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args2),
EnumerationMutationFn, Args2);
-
+
EmitBlock(WasNotMutated);
-
- llvm::Value *StateItemsPtr =
+
+ llvm::Value *StateItemsPtr =
Builder.CreateStructGEP(StatePtr, 1, "stateitems.ptr");
llvm::Value *Counter = Builder.CreateLoad(CounterPtr, "counter");
@@ -551,39 +551,39 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
llvm::Value *EnumStateItems = Builder.CreateLoad(StateItemsPtr,
"stateitems");
- llvm::Value *CurrentItemPtr =
+ llvm::Value *CurrentItemPtr =
Builder.CreateGEP(EnumStateItems, Counter, "currentitem.ptr");
-
+
llvm::Value *CurrentItem = Builder.CreateLoad(CurrentItemPtr, "currentitem");
-
+
// Cast the item to the right type.
CurrentItem = Builder.CreateBitCast(CurrentItem,
ConvertType(ElementTy), "tmp");
-
+
if (!DeclAddress) {
LValue LV = EmitLValue(cast<Expr>(S.getElement()));
-
+
// Set the value to null.
Builder.CreateStore(CurrentItem, LV.getAddress());
} else
Builder.CreateStore(CurrentItem, DeclAddress);
-
+
// Increment the counter.
- Counter = Builder.CreateAdd(Counter,
+ Counter = Builder.CreateAdd(Counter,
llvm::ConstantInt::get(UnsignedLongLTy, 1));
Builder.CreateStore(Counter, CounterPtr);
-
+
llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");
llvm::BasicBlock *AfterBody = createBasicBlock("afterbody");
-
+
BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
EmitStmt(S.getBody());
-
+
BreakContinueStack.pop_back();
-
+
EmitBlock(AfterBody);
-
+
llvm::BasicBlock *FetchMore = createBasicBlock("fetchmore");
Counter = Builder.CreateLoad(CounterPtr);
@@ -593,18 +593,18 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
// Fetch more elements.
EmitBlock(FetchMore);
-
- CountRV =
- CGM.getObjCRuntime().GenerateMessageSend(*this,
+
+ CountRV =
+ CGM.getObjCRuntime().GenerateMessageSend(*this,
getContext().UnsignedLongTy,
- FastEnumSel,
+ FastEnumSel,
Collection, false, Args);
Builder.CreateStore(CountRV.getScalarVal(), LimitPtr);
Limit = Builder.CreateLoad(LimitPtr);
-
+
IsZero = Builder.CreateICmpEQ(Limit, Zero, "iszero");
Builder.CreateCondBr(IsZero, NoElements, LoopStart);
-
+
// No more elements.
EmitBlock(NoElements);
@@ -612,7 +612,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
// If the element was not a declaration, set it to be null.
LValue LV = EmitLValue(cast<Expr>(S.getElement()));
-
+
// Set the value to null.
Builder.CreateStore(llvm::Constant::getNullValue(ConvertType(ElementTy)),
LV.getAddress());
@@ -621,19 +621,16 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
EmitBlock(LoopEnd);
}
-void CodeGenFunction::EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
-{
+void CodeGenFunction::EmitObjCAtTryStmt(const ObjCAtTryStmt &S) {
CGM.getObjCRuntime().EmitTryOrSynchronizedStmt(*this, S);
}
-void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
-{
+void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S) {
CGM.getObjCRuntime().EmitThrowStmt(*this, S);
}
void CodeGenFunction::EmitObjCAtSynchronizedStmt(
- const ObjCAtSynchronizedStmt &S)
-{
+ const ObjCAtSynchronizedStmt &S) {
CGM.getObjCRuntime().EmitTryOrSynchronizedStmt(*this, S);
}
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 63d45e9bd7..264e9d0215 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -79,8 +79,8 @@ private:
const llvm::SmallVectorImpl<llvm::Constant *> &IvarOffsets);
llvm::Constant *GenerateMethodList(const std::string &ClassName,
const std::string &CategoryName,
- const llvm::SmallVectorImpl<Selector> &MethodSels,
- const llvm::SmallVectorImpl<llvm::Constant *> &MethodTypes,
+ const llvm::SmallVectorImpl<Selector> &MethodSels,
+ const llvm::SmallVectorImpl<llvm::Constant *> &MethodTypes,
bool isClassMethodList);
llvm::Constant *GenerateEmptyProtocol(const std::string &ProtocolName);
llvm::Constant *GenerateProtocolList(
@@ -110,7 +110,7 @@ private:
public:
CGObjCGNU(CodeGen::CodeGenModule &cgm);
virtual llvm::Constant *GenerateConstantString(const ObjCStringLiteral *);
- virtual CodeGen::RValue
+ virtual CodeGen::RValue
GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
QualType ResultType,
Selector Sel,
@@ -118,7 +118,7 @@ public:
bool IsClassMessage,
const CallArgList &CallArgs,
const ObjCMethodDecl *Method);
- virtual CodeGen::RValue
+ virtual CodeGen::RValue
GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
QualType ResultType,
Selector Sel,
@@ -132,8 +132,8 @@ public:
virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel);
virtual llvm::Value *GetSelector(CGBuilderTy &Builder, const ObjCMethodDecl
*Method);
-
- virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
+
+ virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD);
virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
@@ -144,7 +144,7 @@ public:
virtual llvm::Function *GetPropertyGetFunction();
virtual llvm::Function *GetPropertySetFunction();
virtual llvm::Constant *EnumerationMutationFunction();
-
+
virtual void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
const Stmt &S);
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
@@ -160,7 +160,7 @@ public:
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest);
virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- llvm::Value *DestPtr,
+ llvm::Value *DestPtr,
llvm::Value *SrcPtr,
QualType Ty);
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
@@ -197,9 +197,10 @@ static std::string SymbolNameForClass(const std::string &ClassName) {
return "_OBJC_CLASS_" + ClassName;
}
-static std::string SymbolNameForMethod(const std::string &ClassName, const
- std::string &CategoryName, const std::string &MethodName, bool isClassMethod)
-{
+static std::string SymbolNameForMethod(const std::string &ClassName,
+ const std::string &CategoryName,
+ const std::string &MethodName,
+ bool isClassMethod) {
return "_OBJC_METHOD_" + ClassName + "("+CategoryName+")"+
(isClassMethod ? "+" : "-") + MethodName;
}
@@ -211,13 +212,13 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
CGM.getTypes().ConvertType(CGM.getContext().IntTy));
LongTy = cast<llvm::IntegerType>(
CGM.getTypes().ConvertType(CGM.getContext().LongTy));
-
+
Zeros[0] = llvm::ConstantInt::get(LongTy, 0);
Zeros[1] = Zeros[0];
NULLPtr = llvm::ConstantPointerNull::get(
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)));
// C string type. Used in lots of places.
- PtrToInt8Ty =
+ PtrToInt8Ty =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
// Get the selector Type.
SelectorTy = cast<llvm::PointerType>(
@@ -225,11 +226,11 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
PtrToIntTy = llvm::PointerType::getUnqual(IntTy);
PtrTy = PtrToInt8Ty;
-
+
// Object type
ASTIdTy = CGM.getContext().getObjCIdType();
IdTy = cast<llvm::PointerType>(CGM.getTypes().ConvertType(ASTIdTy));
-
+
// IMP type
std::vector<const llvm::Type*> IMPArgs;
IMPArgs.push_back(IdTy);
@@ -261,7 +262,7 @@ llvm::Value *CGObjCGNU::GetSelector(CGBuilderTy &Builder, Selector Sel) {
llvm::GlobalValue::PrivateLinkage,
".objc_untyped_selector_alias"+Sel.getAsString(),
NULL, &TheModule);
-
+
return Builder.CreateLoad(US);
}
@@ -315,7 +316,7 @@ llvm::Constant *CGObjCGNU::MakeGlobal(const llvm::ArrayType *Ty,
//an OpenStep implementation, this should let them select their own class for
//constant strings.
llvm::Constant *CGObjCGNU::GenerateConstantString(const ObjCStringLiteral *SL) {
- std::string Str(SL->getString()->getStrData(),
+ std::string Str(SL->getString()->getStrData(),
SL->getString()->getByteLength());
std::vector<llvm::Constant*> Ivars;
Ivars.push_back(NULLPtr);
@@ -393,7 +394,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
}
}
// Cast the pointer to a simplified version of the class structure
- ReceiverClass = CGF.Builder.CreateBitCast(ReceiverClass,
+ ReceiverClass = CGF.Builder.CreateBitCast(ReceiverClass,
llvm::PointerType::getUnqual(
llvm::StructType::get(VMContext, IdTy, IdTy, NULL)));
// Get the superclass pointer
@@ -413,7 +414,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
std::vector<const llvm::Type*> Params;
Params.push_back(llvm::PointerType::getUnqual(ObjCSuperTy));
Params.push_back(SelectorTy);
- llvm::Constant *lookupFunction =
+ llvm::Constant *lookupFunction =
CGM.CreateRuntimeFunction(llvm::FunctionType::get(
llvm::PointerType::getUnqual(impType), Params, true),
"objc_msg_lookup_super");
@@ -425,7 +426,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
return CGF.EmitCall(FnInfo, imp, ActualArgs);
}
-/// Generate code for a message send expression.
+/// Generate code for a message send expression.
CodeGen::RValue
CGObjCGNU::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
QualType ResultType,
@@ -468,14 +469,14 @@ CGObjCGNU::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
self = llvm::ConstantPointerNull::get(IdTy);
}
Params.push_back(self->getType());
- llvm::Constant *lookupFunction =
+ llvm::Constant *lookupFunction =
CGM.CreateRuntimeFunction(llvm::FunctionType::get(
llvm::PointerType::getUnqual(impType), Params, true),
"objc_msg_lookup_sender");
imp = CGF.Builder.CreateCall3(lookupFunction, Receiver, cmd, self);
} else {
- llvm::Constant *lookupFunction =
+ llvm::Constant *lookupFunction =
CGM.CreateRuntimeFunction(llvm::FunctionType::get(
llvm::PointerType::getUnqual(impType), Params, true),
"objc_msg_lookup");
@@ -486,16 +487,16 @@ CGObjCGNU::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
return CGF.EmitCall(FnInfo, imp, ActualArgs);
}
-/// Generates a MethodList. Used in construction of a objc_class and
+/// Generates a MethodList. Used in construction of a objc_class and
/// objc_category structures.
llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName,
- const std::string &CategoryName,
- const llvm::SmallVectorImpl<Selector> &MethodSels,
- const llvm::SmallVectorImpl<llvm::Constant *> &MethodTypes,
+ const std::string &CategoryName,
+ const llvm::SmallVectorImpl<Selector> &MethodSels,
+ const llvm::SmallVectorImpl<llvm::Constant *> &MethodTypes,
bool isClassMethodList) {
if (MethodSels.empty())
return NULLPtr;
- // Get the method structure type.
+ // Get the method structure type.
llvm::StructType *ObjCMethodTy = llvm::StructType::get(VMContext,
PtrToInt8Ty, // Really a selector, but the runtime creates it us.
PtrToInt8Ty, // Method types
@@ -530,8 +531,8 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName,
llvm::PATypeHolder OpaqueNextTy = llvm::OpaqueType::get(VMContext);
llvm::Type *NextPtrTy = llvm::PointerType::getUnqual(OpaqueNextTy);
llvm::StructType *ObjCMethodListTy = llvm::StructType::get(VMContext,
- NextPtrTy,
- IntTy,
+ NextPtrTy,
+ IntTy,
ObjCMethodArrayTy,
NULL);
// Refine next pointer type to concrete type
@@ -545,7 +546,7 @@ llvm::Constant *CGObjCGNU::GenerateMethodList(const std::string &ClassName,
Methods.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
MethodTypes.size()));
Methods.push_back(MethodArray);
-
+
// Create an instance of the structure
return MakeGlobal(ObjCMethodListTy, Methods, ".objc_method_list");
}
@@ -555,7 +556,7 @@ llvm::Constant *CGObjCGNU::GenerateIvarList(
const llvm::SmallVectorImpl<llvm::Constant *> &IvarNames,
const llvm::SmallVectorImpl<llvm::Constant *> &IvarTypes,
const llvm::SmallVectorImpl<llvm::Constant *> &IvarOffsets) {
- // Get the method structure type.
+ // Get the method structure type.
llvm::StructType *ObjCIvarTy = llvm::StructType::get(VMContext,
PtrToInt8Ty,
PtrToInt8Ty,
@@ -575,7 +576,7 @@ llvm::Constant *CGObjCGNU::GenerateIvarList(
llvm::ArrayType *ObjCIvarArrayTy = llvm::ArrayType::get(ObjCIvarTy,
IvarNames.size());
-
+
Elements.clear();
Elements.push_back(llvm::ConstantInt::get(IntTy, (int)IvarNames.size()));
Elements.push_back(llvm::ConstantArray::get(ObjCIvarArrayTy, Ivars));
@@ -611,7 +612,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
LongTy, // instance_size
IVars->getType(), // ivars
Methods->getType(), // methods
- // These are all filled in by the runtime, so we pretend
+ // These are all filled in by the runtime, so we pretend
PtrTy, // dtable
PtrTy, // subclass_list
PtrTy, // sibling_class
@@ -643,7 +644,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
llvm::Constant *CGObjCGNU::GenerateProtocolMethodList(
const llvm::SmallVectorImpl<llvm::Constant *> &MethodNames,
const llvm::SmallVectorImpl<llvm::Constant *> &MethodTypes) {
- // Get the method structure type.
+ // Get the method structure type.
llvm::StructType *ObjCMethodDescTy = llvm::StructType::get(VMContext,
PtrToInt8Ty, // Really a selector, but the runtime does the casting for us.
PtrToInt8Ty,
@@ -652,7 +653,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolMethodList(
std::vector<llvm::Constant*> Elements;
for (unsigned int i = 0, e = MethodTypes.size() ; i < e ; i++) {
Elements.clear();
- Elements.push_back(MethodNames[i]);
+ Elements.push_back(MethodNames[i]);
Elements.push_back(MethodTypes[i]);
Methods.push_back(llvm::ConstantStruct::get(ObjCMethodDescTy, Elements));
}
@@ -678,7 +679,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(
LongTy,//FIXME: Should be size_t
ProtocolArrayTy,
NULL);
- std::vector<llvm::Constant*> Elements;
+ std::vector<llvm::Constant*> Elements;
for (const std::string *iter = Protocols.begin(), *endIter = Protocols.end();
iter != endIter ; iter++) {
llvm::Constant *protocol = ExistingProtocols[*iter];
@@ -697,10 +698,10 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList(
return MakeGlobal(ProtocolListTy, Elements, ".objc_protocol_list");
}
-llvm::Value *CGObjCGNU::GenerateProtocolRef(CGBuilderTy &Builder,
+llvm::Value *CGObjCGNU::GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD) {
llvm::Value *protocol = ExistingProtocols[PD->getNameAsString()];
- const llvm::Type *T =
+ const llvm::Type *T =
CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType());
return Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T));
}
@@ -723,7 +724,7 @@ llvm::Constant *CGObjCGNU::GenerateEmptyProtocol(
InstanceMethodList->getType(),
ClassMethodList->getType(),
NULL);
- std::vector<llvm::Constant*> Elements;
+ std::vector<llvm::Constant*> Elements;
// The isa pointer must be set to a magic number so the runtime knows it's
// the correct layout.
Elements.push_back(llvm::ConstantExpr::getIntToPtr(
@@ -755,7 +756,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
// Collect information about class methods:
llvm::SmallVector<llvm::Constant*, 16> ClassMethodNames;
llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes;
- for (ObjCProtocolDecl::classmeth_iterator
+ for (ObjCProtocolDecl::classmeth_iterator
iter = PD->classmeth_begin(), endIter = PD->classmeth_end();
iter != endIter ; iter++) {
std::string TypeStr;
@@ -778,7 +779,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
InstanceMethodList->getType(),
ClassMethodList->getType(),
NULL);
- std::vector<llvm::Constant*> Elements;
+ std::vector<llvm::Constant*> Elements;
// The isa pointer must be set to a magic number so the runtime knows it's
// the correct layout.
Elements.push_back(llvm::ConstantExpr::getIntToPtr(
@@ -787,7 +788,7 @@ void CGObjCGNU::GenerateProtocol(const ObjCProtocolDecl *PD) {
Elements.push_back(ProtocolList);
Elements.push_back(InstanceMethodList);
Elements.push_back(ClassMethodList);
- ExistingProtocols[ProtocolName] =
+ ExistingProtocols[ProtocolName] =
llvm::ConstantExpr::getBitCast(MakeGlobal(ProtocolTy, Elements,
".objc_protocol"), IdTy);
}
@@ -810,7 +811,7 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
// Collect information about class methods
llvm::SmallVector<Selector, 16> ClassMethodSels;
llvm::SmallVector<llvm::Constant*, 16> ClassMethodTypes;
- for (ObjCCategoryImplDecl::classmeth_iterator
+ for (ObjCCategoryImplDecl::classmeth_iterator
iter = OCD->classmeth_begin(), endIter = OCD->classmeth_end();
iter != endIter ; iter++) {
ClassMethodSels.push_back((*iter)->getSelector());
@@ -830,7 +831,7 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
std::vector<llvm::Constant*> Elements;
Elements.push_back(MakeConstantString(CategoryName));
Elements.push_back(MakeConstantString(ClassName));
- // Instance method list
+ // Instance method list
Elements.push_back(llvm::ConstantExpr::getBitCast(GenerateMethodList(
ClassName, CategoryName, InstanceMethodSels, InstanceMethodTypes,
false), PtrTy));
@@ -842,7 +843,7 @@ void CGObjCGNU::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
Elements.push_back(llvm::ConstantExpr::getBitCast(
GenerateProtocolList(Protocols), PtrTy));
Categories.push_back(llvm::ConstantExpr::getBitCast(
- MakeGlobal(llvm::StructType::get(VMContext, PtrToInt8Ty, PtrToInt8Ty,
+ MakeGlobal(llvm::StructType::get(VMContext, PtrToInt8Ty, PtrToInt8Ty,
PtrTy, PtrTy, PtrTy, NULL), Elements), PtrTy));
}
@@ -850,7 +851,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
ASTContext &Context = CGM.getContext();
// Get the superclass name.
- const ObjCInterfaceDecl * SuperClassDecl =
+ const ObjCInterfaceDecl * SuperClassDecl =
OID->getClassInterface()->getSuperClass();
std::string SuperClassName;
if (SuperClassDecl) {
@@ -865,7 +866,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
// Emit the symbol that is used to generate linker errors if this class is
// referenced in other modules but not declared.
std::string classSymbolName = "__objc_class_name_" + ClassName;
- if (llvm::GlobalVariable *symbol =
+ if (llvm::GlobalVariable *symbol =
TheModule.getGlobalVariable(classSymbolName)) {
symbol->setInitializer(llvm::ConstantInt::get(LongTy, 0));
} else {
@@ -873,7 +874,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(LongTy, 0),
classSymbolName);
}
-
+
// Get the size of instances.
int instanceSize = Context.getASTObjCImplementationLayout(OID).getSize() / 8;
@@ -881,8 +882,8 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
llvm::SmallVector<llvm::Constant*, 16> IvarNames;
llvm::SmallVector<llvm::Constant*, 16> IvarTypes;
llvm::SmallVector<llvm::Constant*, 16> IvarOffsets;
-
- int superInstanceSize = !SuperClassDecl ? 0 :
+
+ int superInstanceSize = !SuperClassDecl ? 0 :
Context.getASTObjCInterfaceLayout(SuperClassDecl).getSize() / 8;
// For non-fragile ivars, set the instance size to 0 - {the size of just this
// class}. The runtime will then set this to the correct value on load.
@@ -912,7 +913,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
// Collect information about instance methods
llvm::SmallVector<Selector, 16> InstanceMethodSels;
llvm::SmallVector<llvm::Constant*, 16> InstanceMethodTypes;
- for (ObjCImplementationDecl::instmeth_iterator
+ for (ObjCImplementationDecl::instmeth_iterator
iter = OID->instmeth_begin(), endIter = OID->instmeth_end();
iter != endIter ; iter++) {
InstanceMethodSels.push_back((*iter)->getSelector());
@@ -920,7 +921,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
Context.getObjCEncodingForMethodDecl((*iter),TypeStr);
InstanceMethodTypes.push_back(MakeConstantString(TypeStr));
}
- for (ObjCImplDecl::propimpl_iterator
+ for (ObjCImplDecl::propimpl_iterator
iter = OID->propimpl_begin(), endIter = OID->propimpl_end();
iter != endIter ; iter++) {
ObjCPropertyDecl *property = (*iter)->getPropertyDecl();
@@ -974,7 +975,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
ClassMethodSels, ClassMethodTypes, true);
llvm::Constant *IvarList = GenerateIvarList(IvarNames, IvarTypes,
IvarOffsets);
- // Irrespective of whether we are compiling for a fragile or non-fragile ABI,
+ // Irrespective of whether we are compiling for a fragile or non-fragile ABI,
// we emit a symbol containing the offset for each ivar in the class. This
// allows code compiled for the non-Fragile ABI to inherit from code compiled
// for the legacy ABI, without causing problems. The converse is also
@@ -986,7 +987,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
// the offset (third field in ivar structure)
const llvm::Type *IndexTy = llvm::Type::getInt32Ty(VMContext);
llvm::Constant *offsetPointerIndexes[] = {Zeros[0],
- llvm::ConstantInt::get(IndexTy, 1), 0,
+ llvm::ConstantInt::get(IndexTy, 1), 0,
llvm::ConstantInt::get(IndexTy, 2) };
for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
@@ -1041,7 +1042,7 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
}
-llvm::Function *CGObjCGNU::ModuleInitFunction() {
+llvm::Function *CGObjCGNU::ModuleInitFunction() {
// Only emit an ObjC load function if no Objective-C stuff has been called
if (Classes.empty() && Categories.empty() && ConstantStrings.empty() &&
ExistingProtocols.empty() && TypedSelectors.empty() &&
@@ -1078,12 +1079,12 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
".objc_static_class_name"));
Elements.push_back(llvm::ConstantArray::get(StaticsArrayTy,
ConstantStrings));
- llvm::StructType *StaticsListTy =
+ llvm::StructType *StaticsListTy =
llvm::StructType::get(VMContext, PtrToInt8Ty, StaticsArrayTy, NULL);
llvm::Type *StaticsListPtrTy =
llvm::PointerType::getUnqual(StaticsListTy);
Statics = MakeGlobal(StaticsListTy, Elements, ".objc_statics");
- llvm::ArrayType *StaticsListArrayTy =
+ llvm::ArrayType *StaticsListArrayTy =
llvm::ArrayType::get(StaticsListPtrTy, 2);
Elements.clear();
Elements.push_back(Statics);
@@ -1094,7 +1095,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
// Array of classes, categories, and constant objects
llvm::ArrayType *ClassListTy = llvm::ArrayType::get(PtrToInt8Ty,
Classes.size() + Categories.size() + 2);
- llvm::StructType *SymTabTy = llvm::StructType::get(VMContext,
+ llvm::StructType *SymTabTy = llvm::StructType::get(VMContext,
LongTy, SelStructPtrTy,
llvm::Type::getInt16Ty(VMContext),
llvm::Type::getInt16Ty(VMContext),
@@ -1130,7 +1131,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
llvm::Constant *SelectorList = MakeGlobal(
llvm::ArrayType::get(SelStructTy, Selectors.size()), Selectors,
".objc_selector_list");
- Elements.push_back(llvm::ConstantExpr::getBitCast(SelectorList,
+ Elements.push_back(llvm::ConstantExpr::getBitCast(SelectorList,
SelStructPtrTy));
// Now that all of the static selectors exist, create pointers to them.
@@ -1158,7 +1159,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
llvm::Constant *Idxs[] = {Zeros[0],
llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), index++), Zeros[0]};
llvm::Constant *SelPtr = new llvm::GlobalVariable
- (TheModule, SelStructPtrTy,
+ (TheModule, SelStructPtrTy,
true, llvm::GlobalValue::InternalLinkage,
llvm::ConstantExpr::getGetElementPtr(SelectorList, Idxs, 2),
".objc_sel_ptr");
@@ -1171,10 +1172,10 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
(*iter).second->setAliasee(SelPtr);
}
// Number of classes defined.
- Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
+ Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
Classes.size()));
// Number of categories defined
- Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
+ Elements.push_back(llvm::ConstantInt::get(llvm::Type::getInt16Ty(VMContext),
Categories.size()));
// Create an array of classes, then categories, then static object instances
Classes.insert(Classes.end(), Categories.begin(), Categories.end());
@@ -1183,7 +1184,7 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
Classes.push_back(NULLPtr);
llvm::Constant *ClassList = llvm::ConstantArray::get(ClassListTy, Classes);
Elements.push_back(ClassList);
- // Construct the symbol table
+ // Construct the symbol table
llvm::Constant *SymTab= MakeGlobal(SymTabTy, Elements);
// The symbol table is contained in a module which has some version-checking
@@ -1193,8 +1194,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
Elements.clear();
// Runtime version used for compatibility checking.
if (CGM.getContext().getLangOptions().ObjCNonFragileABI) {
- Elements.push_back(llvm::ConstantInt::get(LongTy,
- NonFragileRuntimeVersion));
+ Elements.push_back(llvm::ConstantInt::get(LongTy,
+ NonFragileRuntimeVersion));
} else {
Elements.push_back(llvm::ConstantInt::get(LongTy, RuntimeVersion));
}
@@ -1229,8 +1230,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
}
llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD,
- const ObjCContainerDecl *CD) {
- const ObjCCategoryImplDecl *OCD =
+ const ObjCContainerDecl *CD) {
+ const ObjCCategoryImplDecl *OCD =
dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext());
std::string CategoryName = OCD ? OCD->getNameAsString() : "";
std::string ClassName = OMD->getClassInterface()->getNameAsString();
@@ -1238,50 +1239,51 @@ llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD,
bool isClassMethod = !OMD->isInstanceMethod();
CodeGenTypes &Types = CGM.getTypes();
- const llvm::FunctionType *MethodTy =
+ const llvm::FunctionType *MethodTy =
Types.GetFunctionType(Types.getFunctionInfo(OMD), OMD->isVariadic());
std::string FunctionName = SymbolNameForMethod(ClassName, CategoryName,
MethodName, isClassMethod);
- llvm::Function *Method = llvm::Function::Create(MethodTy,
- llvm::GlobalValue::InternalLinkage,
- FunctionName,
- &TheModule);
+ llvm::Function *Method
+ = llvm::Function::Create(MethodTy,
+ llvm::GlobalValue::InternalLinkage,
+ FunctionName,
+ &TheModule);
return Method;
}
llvm::Function *CGObjCGNU::GetPropertyGetFunction() {
- std::vector<const llvm::Type*> Params;
- const llvm::Type *BoolTy =
- CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
- Params.push_back(IdTy);
- Params.push_back(SelectorTy);
- // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
- Params.push_back(LongTy);
- Params.push_back(BoolTy);
- // void objc_getProperty (id, SEL, ptrdiff_t, bool)
- const llvm::FunctionType *FTy =
- llvm::FunctionType::get(IdTy, Params, false);
- return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
- "objc_getProperty"));
+ std::vector<const llvm::Type*> Params;
+ const llvm::Type *BoolTy =
+ CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
+ Params.push_back(IdTy);
+ Params.push_back(SelectorTy);
+ // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
+ Params.push_back(LongTy);
+ Params.push_back(BoolTy);
+ // void objc_getProperty (id, SEL, ptrdiff_t, bool)
+ const llvm::FunctionType *FTy =
+ llvm::FunctionType::get(IdTy, Params, false);
+ return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
+ "objc_getProperty"));
}
llvm::Function *CGObjCGNU::GetPropertySetFunction() {
- std::vector<const llvm::Type*> Params;
- const llvm::Type *BoolTy =
- CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
- Params.push_back(IdTy);
- Params.push_back(SelectorTy);
- // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
- Params.push_back(LongTy);
- Params.push_back(IdTy);
- Params.push_back(BoolTy);
- Params.push_back(BoolTy);
- // void objc_setProperty (id, SEL, ptrdiff_t, id, bool, bool)
- const llvm::FunctionType *FTy =
- llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false);
- return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
- "objc_setProperty"));
+ std::vector<const llvm::Type*> Params;
+ const llvm::Type *BoolTy =
+ CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
+ Params.push_back(IdTy);
+ Params.push_back(SelectorTy);
+ // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
+ Params.push_back(LongTy);
+ Params.push_back(IdTy);
+ Params.push_back(BoolTy);
+ Params.push_back(BoolTy);
+ // void objc_setProperty (id, SEL, ptrdiff_t, id, bool, bool)
+ const llvm::FunctionType *FTy =
+ llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false);
+ return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
+ "objc_setProperty"));
}
llvm::Constant *CGObjCGNU::EnumerationMutationFunction() {
@@ -1324,7 +1326,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
llvm::FunctionType *FTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, false);
llvm::Value *SyncEnter = CGM.CreateRuntimeFunction(FTy, "objc_sync_enter");
- llvm::Value *SyncArg =
+ llvm::Value *SyncArg =
CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr());
SyncArg = CGF.Builder.CreateBitCast(SyncArg, IdTy);
CGF.Builder.CreateCall(SyncEnter, SyncArg);
@@ -1339,7 +1341,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGF.setInvokeDest(TryHandler);
CGF.EmitBlock(TryBlock);
- CGF.EmitStmt(isTry ? cast<ObjCAtTryStmt>(S).getTryBody()
+ CGF.EmitStmt(isTry ? cast<ObjCAtTryStmt>(S).getTryBody()
: cast<ObjCAtSynchronizedStmt>(S).getSynchBody());
// Jump to @finally if there is no exception
@@ -1353,7 +1355,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
int PointerWidth = td.getTypeSizeInBits(PtrTy);
assert((PointerWidth == 32 || PointerWidth == 64) &&
"Can't yet handle exceptions if pointers are not 32 or 64 bits");
- llvm::Value *llvm_eh_exception =
+ llvm::Value *llvm_eh_exception =
CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_exception);
llvm::Value *llvm_eh_selector = PointerWidth == 32 ?
CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_selector_i32) :
@@ -1392,13 +1394,13 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
HasCatchAll = true;
// No further catches after this one will ever by reached
break;
- }
+ }
// All other types should be Objective-C interface pointer types.
- const ObjCObjectPointerType *OPT =
+ const ObjCObjectPointerType *OPT =
CatchDecl->getType()->getAsObjCObjectPointerType();
assert(OPT && "Invalid @catch type.");
- const ObjCInterfaceType *IT =
+ const ObjCInterfaceType *IT =
OPT->getPointeeType()->getAsObjCInterfaceType();
assert(IT && "Invalid @catch type.");
llvm::Value *EHType =
@@ -1439,11 +1441,11 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGF.EmitBlock(Match);
}
-
+
if (CatchBody) {
llvm::Value *ExcObject = CGF.Builder.CreateBitCast(Exc,
CGF.ConvertType(CatchParam->getType()));
-
+
// Bind the catch parameter if it exists.
if (CatchParam) {
// CatchParam is a ParmVarDecl because of the grammar
@@ -1491,7 +1493,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
if (isTry) {
- if (const ObjCAtFinallyStmt* FinallyStmt =
+ if (const ObjCAtFinallyStmt* FinallyStmt =
cast<ObjCAtTryStmt>(S).getFinallyStmt())
CGF.EmitStmt(FinallyStmt->getFinallyBody());
} else {
@@ -1501,7 +1503,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
llvm::FunctionType *FTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, false);
llvm::Value *SyncExit = CGM.CreateRuntimeFunction(FTy, "objc_sync_exit");
- llvm::Value *SyncArg =
+ llvm::Value *SyncArg =
CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr());
SyncArg = CGF.Builder.CreateBitCast(SyncArg, IdTy);
CGF.Builder.CreateCall(SyncExit, SyncArg);
@@ -1518,7 +1520,7 @@ void CGObjCGNU::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGF.EmitBlock(FinallyRethrow);
CGF.Builder.CreateCall(RethrowFn, CGF.Builder.CreateLoad(RethrowPtr));
CGF.Builder.CreateUnreachable();
-
+
CGF.EmitBlock(FinallyEnd);
}
@@ -1530,20 +1532,20 @@ void CGObjCGNU::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
std::vector<const llvm::Type*> Args(1, IdTy);
llvm::FunctionType *FTy =
llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Args, false);
- llvm::Value *ThrowFn =
+ llvm::Value *ThrowFn =
CGM.CreateRuntimeFunction(FTy, "objc_exception_throw");
-
+
if (const Expr *ThrowExpr = S.getThrowExpr()) {
llvm::Value *Exception = CGF.EmitScalarExpr(ThrowExpr);
ExceptionAsObject = Exception;
} else {
- assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) &&
+ assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) &&
"Unexpected rethrow outside @catch block.");
ExceptionAsObject = CGF.ObjCEHValueStack.back();
}
ExceptionAsObject =
CGF.Builder.CreateBitCast(ExceptionAsObject, IdTy, "tmp");
-
+
// Note: This may have to be an invoke, if we want to support constructs like:
// @try {
// @throw(obj);
@@ -1566,37 +1568,32 @@ void CGObjCGNU::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
}
llvm::Value * CGObjCGNU::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- llvm::Value *AddrWeakObj)
-{
+ llvm::Value *AddrWeakObj) {
return 0;
}
void CGObjCGNU::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
return;
}
void CGObjCGNU::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
return;
}
void CGObjCGNU::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
return;
}
void CGObjCGNU::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
return;
}
void CGObjCGNU::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- llvm::Value *DestPtr,
+ llvm::Value *DestPtr,
llvm::Value *SrcPtr,
QualType Ty) {
return;
@@ -1618,7 +1615,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
// Don't emit the guess in non-PIC code because the linker will not be able
// to replace it with the real version for a library. In non-PIC code you
// must compile with the fragile ABI if you want to use ivars from a
- // GCC-compiled class.
+ // GCC-compiled class.
if (CGM.getLangOptions().PICLevel) {
llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule,
llvm::Type::getInt32Ty(VMContext), false,
@@ -1654,11 +1651,11 @@ static const ObjCInterfaceDecl *FindIvarInterface(ASTContext &Context,
if (OIVD == Ivars[k])
return OID;
}
-
+
// Otherwise check in the super class.
if (const ObjCInterfaceDecl *Super = OID->getSuperClass())
return FindIvarInterface(Context, Super, OIVD);
-
+
return 0;
}
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 03c4f47a8c..e685385426 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -104,7 +104,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
unsigned CVRQualifiers,
llvm::Value *Offset) {
// Compute (type*) ( (char *) BaseValue + Offset)
- llvm::Type *I8Ptr =
+ llvm::Type *I8Ptr =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
QualType IvarTy = Ivar->getType();
const llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
@@ -939,8 +939,7 @@ protected:
public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) :
- CGM(cgm), VMContext(cgm.getLLVMContext())
- { }
+ CGM(cgm), VMContext(cgm.getLLVMContext()) { }
virtual llvm::Constant *GenerateConstantString(const ObjCStringLiteral *SL);
@@ -1402,8 +1401,7 @@ static bool hasObjCExceptionAttribute(ASTContext &Context,
/* *** CGObjCMac Public Interface *** */
CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm) : CGObjCCommonMac(cgm),
- ObjCTypes(cgm)
-{
+ ObjCTypes(cgm) {
ObjCABI = 1;
EmitImageInfo();
}
@@ -2689,8 +2687,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
/// object: objc_read_weak (id *src)
///
llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- llvm::Value *AddrWeakObj)
-{
+ llvm::Value *AddrWeakObj) {
const llvm::Type* DestTy =
cast<llvm::PointerType>(AddrWeakObj->getType())->getElementType();
AddrWeakObj = CGF.Builder.CreateBitCast(AddrWeakObj,
@@ -2705,8 +2702,7 @@ llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
/// objc_assign_weak (id src, id *dst)
///
void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -2726,8 +2722,7 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
/// objc_assign_global (id src, id *dst)
///
void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -2747,8 +2742,7 @@ void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
/// objc_assign_ivar (id src, id *dst)
///
void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -2768,8 +2762,7 @@ void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
/// objc_assign_strongCast (id src, id *dst)
///
void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -3055,10 +3048,10 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI,
if (RD) {
if (Field->isBitField()) {
CodeGenTypes::BitFieldInfo Info = CGM.getTypes().getBitFieldInfo(Field);
-
- const llvm::Type *Ty =
+
+ const llvm::Type *Ty =
CGM.getTypes().ConvertTypeForMemRecursive(Field->getType());
- uint64_t TypeSize =
+ uint64_t TypeSize =
CGM.getTypes().getTargetData().getTypeAllocSize(Ty);
FieldOffset = Info.FieldNo * TypeSize;
} else
@@ -3516,8 +3509,7 @@ void CGObjCMac::FinishModule() {
CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm)
: CGObjCCommonMac(cgm),
- ObjCTypes(cgm)
-{
+ ObjCTypes(cgm) {
ObjCEmptyCacheVar = ObjCEmptyVtableVar = NULL;
ObjCABI = 2;
}
@@ -3525,8 +3517,7 @@ CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm)
/* *** */
ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
- : VMContext(cgm.getLLVMContext()), CGM(cgm)
-{
+ : VMContext(cgm.getLLVMContext()), CGM(cgm) {
CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext();
@@ -3612,8 +3603,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
}
ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
- : ObjCCommonTypesHelper(cgm)
-{
+ : ObjCCommonTypesHelper(cgm) {
// struct _objc_method_description {
// SEL name;
// char *types;
@@ -3666,7 +3656,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
llvm::PATypeHolder ProtocolListTyHolder = llvm::OpaqueType::get(VMContext);
const llvm::Type *T =
- llvm::StructType::get(VMContext,
+ llvm::StructType::get(VMContext,
llvm::PointerType::getUnqual(ProtocolListTyHolder),
LongTy,
llvm::ArrayType::get(ProtocolTyHolder, 0),
@@ -3835,8 +3825,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
}
ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModule &cgm)
- : ObjCCommonTypesHelper(cgm)
-{
+ : ObjCCommonTypesHelper(cgm) {
// struct _method_list_t {
// uint32_t entsize; // sizeof(struct _objc_method)
// uint32_t method_count;
@@ -3908,7 +3897,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// uint32_t alignment;
// uint32_t size;
// }
- IvarnfABITy = llvm::StructType::get(VMContext,
+ IvarnfABITy = llvm::StructType::get(VMContext,
llvm::PointerType::getUnqual(LongTy),
Int8PtrTy,
Int8PtrTy,
@@ -5056,7 +5045,7 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
Name += '_';
std::string SelName(Sel.getAsString());
// Replace all ':' in selector name with '_' ouch!
- for(unsigned i = 0; i < SelName.size(); i++)
+ for (unsigned i = 0; i < SelName.size(); i++)
if (SelName[i] == ':')
SelName[i] = '_';
Name += SelName;
@@ -5277,8 +5266,8 @@ llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CGBuilderTy &Builder,
/// objc_assign_ivar (id src, id *dst)
///
void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src,
+ llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -5299,8 +5288,7 @@ void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
///
void CGObjCNonFragileABIMac::EmitObjCStrongCastAssign(
CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -5337,8 +5325,7 @@ void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable(
///
llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead(
CodeGen::CodeGenFunction &CGF,
- llvm::Value *AddrWeakObj)
-{
+ llvm::Value *AddrWeakObj) {
const llvm::Type* DestTy =
cast<llvm::PointerType>(AddrWeakObj->getType())->getElementType();
AddrWeakObj = CGF.Builder.CreateBitCast(AddrWeakObj, ObjCTypes.PtrObjectPtrTy);
@@ -5352,8 +5339,7 @@ llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead(
/// objc_assign_weak (id src, id *dst)
///
void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
@@ -5373,8 +5359,7 @@ void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
/// objc_assign_global (id src, id *dst)
///
void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, llvm::Value *dst)
-{
+ llvm::Value *src, llvm::Value *dst) {
const llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getTargetData().getTypeAllocSize(SrcTy);
diff --git a/lib/CodeGen/CGObjCRuntime.h b/lib/CodeGen/CGObjCRuntime.h
index d82df9d881..8951ab6d32 100644
--- a/lib/CodeGen/CGObjCRuntime.h
+++ b/lib/CodeGen/CGObjCRuntime.h
@@ -86,7 +86,7 @@ protected:
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
unsigned CVRQualifiers,
- llvm::Value *Offset);
+ llvm::Value *Offset);
public:
virtual ~CGObjCRuntime();
@@ -101,7 +101,7 @@ public:
virtual llvm::Value *GetSelector(CGBuilderTy &Builder,
Selector Sel) = 0;
- /// Get a typed selector.
+ /// Get a typed selector.
virtual llvm::Value *GetSelector(CGBuilderTy &Builder,
const ObjCMethodDecl *Method) = 0;
@@ -114,9 +114,9 @@ public:
/// Generate a class stucture for this class.
virtual void GenerateClass(const ObjCImplementationDecl *OID) = 0;
-
- /// Generate an Objective-C message send operation.
- virtual CodeGen::RValue
+
+ /// Generate an Objective-C message send operation.
+ virtual CodeGen::RValue
GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
QualType ResultType,
Selector Sel,
@@ -143,34 +143,34 @@ public:
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *OPD) = 0;
- /// Generate the named protocol. Protocols contain method metadata but no
- /// implementations.
+ /// Generate the named protocol. Protocols contain method metadata but no
+ /// implementations.
virtual void GenerateProtocol(const ObjCProtocolDecl *OPD) = 0;
/// Generate a function preamble for a method with the specified
- /// types.
+ /// types.
// FIXME: Current this just generates the Function definition, but really this
// should also be generating the loads of the parameters, as the runtime
// should have full control over how parameters are passed.
- virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
+ virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD) = 0;
/// Return the runtime function for getting properties.
virtual llvm::Constant *GetPropertyGetFunction() = 0;
-
+
/// Return the runtime function for setting properties.
virtual llvm::Constant *GetPropertySetFunction() = 0;
/// GetClass - Return a reference to the class for the given
/// interface decl.
- virtual llvm::Value *GetClass(CGBuilderTy &Builder,
+ virtual llvm::Value *GetClass(CGBuilderTy &Builder,
const ObjCInterfaceDecl *OID) = 0;
/// EnumerationMutationFunction - Return the function that's called by the
/// compiler when a mutation is detected during foreach iteration.
virtual llvm::Constant *EnumerationMutationFunction() = 0;
-
+
virtual void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
const Stmt &S) = 0;
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
@@ -185,7 +185,7 @@ public:
llvm::Value *src, llvm::Value *dest) = 0;
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest) = 0;
-
+
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
QualType ObjectTy,
llvm::Value *BaseValue,
@@ -195,12 +195,12 @@ public:
const ObjCInterfaceDecl *Interface,
const ObjCIvarDecl *Ivar) = 0;
virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- llvm::Value *DestPtr,
+ llvm::Value *DestPtr,
llvm::Value *SrcPtr,
QualType Ty) = 0;
};
-/// Creates an instance of an Objective-C runtime class.
+/// Creates an instance of an Objective-C runtime class.
//TODO: This should include some way of selecting which runtime to target.
CGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM);
CGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM);
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index f2fd885ee4..d26c7721da 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -37,7 +37,7 @@ void CGRecordLayoutBuilder::Layout(const RecordDecl *D) {
if (LayoutFields(D))
return;
-
+
// We weren't able to layout the struct. Try again with a packed struct
Packed = true;
AlignmentAsLLVMStruct = 1;
@@ -45,52 +45,52 @@ void CGRecordLayoutBuilder::Layout(const RecordDecl *D) {
FieldTypes.clear();
LLVMFields.clear();
LLVMBitFields.clear();
-
+
LayoutFields(D);
}
void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D,
uint64_t FieldOffset) {
- uint64_t FieldSize =
+ uint64_t FieldSize =
D->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue();
-
+
if (FieldSize == 0)
return;
uint64_t NextFieldOffset = NextFieldOffsetInBytes * 8;
unsigned NumBytesToAppend;
-
+
if (FieldOffset < NextFieldOffset) {
assert(BitsAvailableInLastField && "Bitfield size mismatch!");
assert(NextFieldOffsetInBytes && "Must have laid out at least one byte!");
-
+
// The bitfield begins in the previous bit-field.
- NumBytesToAppend =
+ NumBytesToAppend =
llvm::RoundUpToAlignment(FieldSize - BitsAvailableInLastField, 8) / 8;
} else {
assert(FieldOffset % 8 == 0 && "Field offset not aligned correctly");
// Append padding if necessary.
AppendBytes((FieldOffset - NextFieldOffset) / 8);
-
- NumBytesToAppend =
+
+ NumBytesToAppend =
llvm::RoundUpToAlignment(FieldSize, 8) / 8;
-
+
assert(NumBytesToAppend && "No bytes to append!");
}
const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType());
uint64_t TypeSizeInBits = getTypeSizeInBytes(Ty) * 8;
-
+
LLVMBitFields.push_back(LLVMBitFieldInfo(D, FieldOffset / TypeSizeInBits,
- FieldOffset % TypeSizeInBits,
+ FieldOffset % TypeSizeInBits,
FieldSize));
-
+
AppendBytes(NumBytesToAppend);
-
+
AlignmentAsLLVMStruct = std::max(AlignmentAsLLVMStruct, getTypeAlignment(Ty));
- BitsAvailableInLastField =
+ BitsAvailableInLastField =
NextFieldOffsetInBytes * 8 - (FieldOffset + FieldSize);
}
@@ -105,14 +105,14 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
// don't affect the struct alignment.
if (!Packed && !D->getDeclName())
return false;
-
+
LayoutBitField(D, FieldOffset);
return true;
}
-
+
assert(FieldOffset % 8 == 0 && "FieldOffset is not on a byte boundary!");
uint64_t FieldOffsetInBytes = FieldOffset / 8;
-
+
const llvm::Type *Ty = Types.ConvertTypeForMemRecursive(D->getType());
unsigned TypeAlignment = getTypeAlignment(Ty);
@@ -122,7 +122,7 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
assert(!Packed && "Alignment is wrong even with packed struct!");
return false;
}
-
+
if (const RecordType *RT = D->getType()->getAs<RecordType>()) {
const RecordDecl *RD = cast<RecordDecl>(RT->getDecl());
if (const PragmaPackAttr *PPA = RD->getAttr<PragmaPackAttr>()) {
@@ -132,72 +132,72 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
}
// Round up the field offset to the alignment of the field type.
- uint64_t AlignedNextFieldOffsetInBytes =
+ uint64_t AlignedNextFieldOffsetInBytes =
llvm::RoundUpToAlignment(NextFieldOffsetInBytes, TypeAlignment);
if (FieldOffsetInBytes < AlignedNextFieldOffsetInBytes) {
assert(!Packed && "Could not place field even with packed struct!");
return false;
}
-
+
if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
// Even with alignment, the field offset is not at the right place,
// insert padding.
uint64_t PaddingInBytes = FieldOffsetInBytes - NextFieldOffsetInBytes;
-
+
AppendBytes(PaddingInBytes);
}
-
+
// Now append the field.
LLVMFields.push_back(LLVMFieldInfo(D, FieldTypes.size()));
AppendField(FieldOffsetInBytes, Ty);
-
+
return true;
}
void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
assert(D->isUnion() && "Can't call LayoutUnion on a non-union record!");
-
+
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
-
+
const llvm::Type *Ty = 0;
uint64_t Size = 0;
unsigned Align = 0;
-
+
unsigned FieldNo = 0;
- for (RecordDecl::field_iterator Field = D->field_begin(),
+ for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
- assert(Layout.getFieldOffset(FieldNo) == 0 &&
+ assert(Layout.getFieldOffset(FieldNo) == 0 &&
"Union field offset did not start at the beginning of record!");
if (Field->isBitField()) {
- uint64_t FieldSize =
+ uint64_t FieldSize =
Field->getBitWidth()->EvaluateAsInt(Types.getContext()).getZExtValue();
-
+
// Ignore zero sized bit fields.
if (FieldSize == 0)
continue;
-
+
// Add the bit field info.
Types.addBitFieldInfo(*Field, 0, 0, FieldSize);
} else
Types.addFieldInfo(*Field, 0);
-
- const llvm::Type *FieldTy =
+
+ const llvm::Type *FieldTy =
Types.ConvertTypeForMemRecursive(Field->getType());
unsigned FieldAlign = Types.getTargetData().getABITypeAlignment(FieldTy);
uint64_t FieldSize = Types.getTargetData().getTypeAllocSize(FieldTy);
-
+
if (FieldAlign < Align)
continue;
-
+
if (FieldAlign > Align || FieldSize > Size) {
Ty = FieldTy;
Align = FieldAlign;
Size = FieldSize;
}
}
-
+
// Now add our field.
if (Ty) {
AppendField(0, Ty);
@@ -208,7 +208,7 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
Align = 1;
}
}
-
+
// Append tail padding.
if (Layout.getSize() / 8 > Size)
AppendPadding(Layout.getSize() / 8, Align);
@@ -217,15 +217,15 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) {
bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
assert(!D->isUnion() && "Can't call LayoutFields on a union!");
assert(Alignment && "Did not set alignment!");
-
+
const ASTRecordLayout &Layout = Types.getContext().getASTRecordLayout(D);
-
+
unsigned FieldNo = 0;
- for (RecordDecl::field_iterator Field = D->field_begin(),
+ for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
if (!LayoutField(*Field, Layout.getFieldOffset(FieldNo))) {
- assert(!Packed &&
+ assert(!Packed &&
"Could not layout fields even with a packed LLVM struct!");
return false;
}
@@ -233,21 +233,21 @@ bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) {
// Append tail padding if necessary.
AppendTailPadding(Layout.getSize());
-
+
return true;
}
void CGRecordLayoutBuilder::AppendTailPadding(uint64_t RecordSize) {
assert(RecordSize % 8 == 0 && "Invalid record size!");
-
+
uint64_t RecordSizeInBytes = RecordSize / 8;
assert(NextFieldOffsetInBytes <= RecordSizeInBytes && "Size mismatch!");
-
+
unsigned NumPadBytes = RecordSizeInBytes - NextFieldOffsetInBytes;
AppendBytes(NumPadBytes);
}
-void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes,
+void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes,
const llvm::Type *FieldTy) {
AlignmentAsLLVMStruct = std::max(AlignmentAsLLVMStruct,
getTypeAlignment(FieldTy));
@@ -260,19 +260,19 @@ void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes,
BitsAvailableInLastField = 0;
}
-void
+void
CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
const llvm::Type *FieldTy) {
AppendPadding(FieldOffsetInBytes, getTypeAlignment(FieldTy));
}
-void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
+void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
unsigned FieldAlignment) {
assert(NextFieldOffsetInBytes <= FieldOffsetInBytes &&
"Incorrect field layout!");
-
+
// Round up the field offset to the alignment of the field type.
- uint64_t AlignedNextFieldOffsetInBytes =
+ uint64_t AlignedNextFieldOffsetInBytes =
llvm::RoundUpToAlignment(NextFieldOffsetInBytes, FieldAlignment);
if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
@@ -287,11 +287,11 @@ void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
void CGRecordLayoutBuilder::AppendBytes(uint64_t NumBytes) {
if (NumBytes == 0)
return;
-
+
const llvm::Type *Ty = llvm::Type::getInt8Ty(Types.getLLVMContext());
if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
-
+
// Append the padding field
AppendField(NextFieldOffsetInBytes, Ty);
}
@@ -299,7 +299,7 @@ void CGRecordLayoutBuilder::AppendBytes(uint64_t NumBytes) {
unsigned CGRecordLayoutBuilder::getTypeAlignment(const llvm::Type *Ty) const {
if (Packed)
return 1;
-
+
return Types.getTargetData().getABITypeAlignment(Ty);
}
@@ -311,26 +311,26 @@ void CGRecordLayoutBuilder::CheckForMemberPointer(const FieldDecl *FD) {
// This record already contains a member pointer.
if (ContainsMemberPointer)
return;
-
+
// Can only have member pointers if we're compiling C++.
if (!Types.getContext().getLangOptions().CPlusPlus)
return;
-
+
QualType Ty = FD->getType();
-
+
if (Ty->isMemberPointerType()) {
// We have a member pointer!
ContainsMemberPointer = true;
return;
}
-
+
}
CGRecordLayout *
CGRecordLayoutBuilder::ComputeLayout(CodeGenTypes &Types,
const RecordDecl *D) {
CGRecordLayoutBuilder Builder(Types);
-
+
Builder.Layout(D);
const llvm::Type *Ty = llvm::StructType::get(Types.getLLVMContext(),
@@ -339,7 +339,7 @@ CGRecordLayoutBuilder::ComputeLayout(CodeGenTypes &Types,
assert(Types.getContext().getASTRecordLayout(D).getSize() / 8 ==
Types.getTargetData().getTypeAllocSize(Ty) &&
"Type size mismatch!");
-
+
// Add all the field numbers.
for (unsigned i = 0, e = Builder.LLVMFields.size(); i != e; ++i) {
const FieldDecl *FD = Builder.LLVMFields[i].first;
@@ -351,9 +351,9 @@ CGRecordLayoutBuilder::ComputeLayout(CodeGenTypes &Types,
// Add bitfield info.
for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i) {
const LLVMBitFieldInfo &Info = Builder.LLVMBitFields[i];
-
+
Types.addBitFieldInfo(Info.FD, Info.FieldNo, Info.Start, Info.Size);
}
-
+
return new CGRecordLayout(Ty, Builder.ContainsMemberPointer);
}
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.h b/lib/CodeGen/CGRecordLayoutBuilder.h
index 63ddc10df5..d1a13aa297 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.h
+++ b/lib/CodeGen/CGRecordLayoutBuilder.h
@@ -25,57 +25,57 @@ namespace llvm {
namespace clang {
class FieldDecl;
class RecordDecl;
-
+
namespace CodeGen {
class CGRecordLayout;
class CodeGenTypes;
-class CGRecordLayoutBuilder {
+class CGRecordLayoutBuilder {
CodeGenTypes &Types;
-
+
/// Packed - Whether the resulting LLVM struct will be packed or not.
bool Packed;
/// ContainsMemberPointer - Whether one of the fields is a member pointer
/// or is a struct that contains a member pointer.
bool ContainsMemberPointer;
-
+
/// Alignment - Contains the alignment of the RecordDecl.
unsigned Alignment;
/// AlignmentAsLLVMStruct - Will contain the maximum alignment of all the
/// LLVM types.
unsigned AlignmentAsLLVMStruct;
-
+
/// BitsAvailableInLastField - If a bit field spans only part of a LLVM field,
/// this will have the number of bits still available in the field.
char BitsAvailableInLastField;
/// NextFieldOffsetInBytes - Holds the next field offset in bytes.
uint64_t NextFieldOffsetInBytes;
-
+
/// FieldTypes - Holds the LLVM types that the struct is created from.
std::vector<const llvm::Type *> FieldTypes;
-
+
/// LLVMFieldInfo - Holds a field and its corresponding LLVM field number.
typedef std::pair<const FieldDecl *, unsigned> LLVMFieldInfo;
llvm::SmallVector<LLVMFieldInfo, 16> LLVMFields;
/// LLVMBitFieldInfo - Holds location and size information about a bit field.
struct LLVMBitFieldInfo {
- LLVMBitFieldInfo(const FieldDecl *FD, unsigned FieldNo, unsigned Start,
+ LLVMBitFieldInfo(const FieldDecl *FD, unsigned FieldNo, unsigned Start,
unsigned Size)
: FD(FD), FieldNo(FieldNo), Start(Start), Size(Size) { }
-
+
const FieldDecl *FD;
-
+
unsigned FieldNo;
unsigned Start;
unsigned Size;
};
llvm::SmallVector<LLVMBitFieldInfo, 16> LLVMBitFields;
-
- CGRecordLayoutBuilder(CodeGenTypes &Types)
+
+ CGRecordLayoutBuilder(CodeGenTypes &Types)
: Types(Types), Packed(false), ContainsMemberPointer(false)
, Alignment(0), AlignmentAsLLVMStruct(1)
, BitsAvailableInLastField(0), NextFieldOffsetInBytes(0) { }
@@ -85,15 +85,15 @@ class CGRecordLayoutBuilder {
/// LayoutUnion - Will layout a union RecordDecl.
void LayoutUnion(const RecordDecl *D);
-
+
/// LayoutField - try to layout all fields in the record decl.
/// Returns false if the operation failed because the struct is not packed.
bool LayoutFields(const RecordDecl *D);
-
+
/// LayoutField - layout a single field. Returns false if the operation failed
/// because the current struct is not packed.
bool LayoutField(const FieldDecl *D, uint64_t FieldOffset);
-
+
/// LayoutBitField - layout a single bit field.
void LayoutBitField(const FieldDecl *D, uint64_t FieldOffset);
@@ -107,28 +107,28 @@ class CGRecordLayoutBuilder {
/// AppendPadding - Appends enough padding bytes so that the total
/// struct size is a multiple of the field alignment.
void AppendPadding(uint64_t FieldOffsetInBytes, unsigned FieldAlignment);
-
+
/// AppendBytes - Append a given number of bytes to the record.
void AppendBytes(uint64_t NumBytes);
/// AppendTailPadding - Append enough tail padding so that the type will have
/// the passed size.
void AppendTailPadding(uint64_t RecordSize);
-
+
unsigned getTypeAlignment(const llvm::Type *Ty) const;
uint64_t getTypeSizeInBytes(const llvm::Type *Ty) const;
/// CheckForMemberPointer - Check if the field contains a member pointer.
void CheckForMemberPointer(const FieldDecl *FD);
-
+
public:
/// ComputeLayout - Return the right record layout for a given record decl.
- static CGRecordLayout *ComputeLayout(CodeGenTypes &Types,
+ static CGRecordLayout *ComputeLayout(CodeGenTypes &Types,
const RecordDecl *D);
};
-
+
} // end namespace CodeGen
} // end namespace clang
-
-#endif
+
+#endif
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 12e3a95373..26d1c3b8a4 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -72,7 +72,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
ErrorUnsupported(S, "statement");
EmitAnyExpr(cast<Expr>(S), 0, false, true);
-
+
// Expression emitters don't handle unreachable blocks yet, so look for one
// explicitly here. This handles the common case of a call to a noreturn
// function.
@@ -83,14 +83,14 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
}
}
break;
- case Stmt::IndirectGotoStmtClass:
+ case Stmt::IndirectGotoStmtClass:
EmitIndirectGotoStmt(cast<IndirectGotoStmt>(*S)); break;
case Stmt::IfStmtClass: EmitIfStmt(cast<IfStmt>(*S)); break;
case Stmt::WhileStmtClass: EmitWhileStmt(cast<WhileStmt>(*S)); break;
case Stmt::DoStmtClass: EmitDoStmt(cast<DoStmt>(*S)); break;
case Stmt::ForStmtClass: EmitForStmt(cast<ForStmt>(*S)); break;
-
+
case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break;
case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break;
@@ -98,7 +98,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
case Stmt::ObjCAtTryStmtClass:
EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
- break;
+ break;
case Stmt::ObjCAtCatchStmtClass:
assert(0 && "@catch statements should be handled by EmitObjCAtTryStmt");
break;
@@ -111,7 +111,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
case Stmt::ObjCAtSynchronizedStmtClass:
EmitObjCAtSynchronizedStmt(cast<ObjCAtSynchronizedStmt>(*S));
break;
- case Stmt::ObjCForCollectionStmtClass:
+ case Stmt::ObjCForCollectionStmtClass:
EmitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(*S));
break;
}
@@ -141,7 +141,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
llvm::Value *AggLoc, bool isAggVol) {
PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(),S.getLBracLoc(),
"LLVM IR generation of compound statement ('{}')");
-
+
CGDebugInfo *DI = getDebugInfo();
if (DI) {
EnsureInsertPoint();
@@ -156,7 +156,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
size_t CleanupStackDepth = CleanupEntries.size();
bool OldDidCallStackSave = DidCallStackSave;
DidCallStackSave = false;
-
+
for (CompoundStmt::const_body_iterator I = S.body_begin(),
E = S.body_end()-GetLast; I != E; ++I)
EmitStmt(*I);
@@ -164,7 +164,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
if (DI) {
EnsureInsertPoint();
DI->setLocation(S.getRBracLoc());
-
+
// FIXME: The llvm backend is currently not ready to deal with region_end
// for block scoping. In the presence of always_inline functions it gets so
// confused that it doesn't emit any debug info. Just disable this for now.
@@ -172,10 +172,10 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
}
RValue RV;
- if (!GetLast)
+ if (!GetLast)
RV = RValue::get(0);
else {
- // We have to special case labels here. They are statements, but when put
+ // We have to special case labels here. They are statements, but when put
// at the end of a statement expression, they yield the value of their
// subexpression. Handle this by walking through all labels we encounter,
// emitting them before we evaluate the subexpr.
@@ -184,22 +184,22 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
EmitLabel(*LS);
LastStmt = LS->getSubStmt();
}
-
+
EnsureInsertPoint();
-
+
RV = EmitAnyExpr(cast<Expr>(LastStmt), AggLoc);
}
DidCallStackSave = OldDidCallStackSave;
-
+
EmitCleanupBlocks(CleanupStackDepth);
-
+
return RV;
}
void CodeGenFunction::SimplifyForwardingBlocks(llvm::BasicBlock *BB) {
llvm::BranchInst *BI = dyn_cast<llvm::BranchInst>(BB->getTerminator());
-
+
// If there is a cleanup stack, then we it isn't worth trying to
// simplify this block (we would need to remove it from the scope map
// and cleanup entry).
@@ -235,7 +235,7 @@ void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
CleanupEntries.back().Blocks.push_back(BB);
}
}
-
+
CurFn->getBasicBlockList().push_back(BB);
Builder.SetInsertPoint(BB);
}
@@ -282,7 +282,7 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
// EmitIndirectSwitches(). We need a default dest, so we use the
// current BB, but this is overwritten.
llvm::Value *V = Builder.CreatePtrToInt(EmitScalarExpr(S.getTarget()),
- llvm::Type::getInt32Ty(VMContext),
+ llvm::Type::getInt32Ty(VMContext),
"addr");
llvm::SwitchInst *I = Builder.CreateSwitch(V, Builder.GetInsertBlock());
IndirectSwitches.push_back(I);
@@ -294,7 +294,7 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
// C99 6.8.4.1: The first substatement is executed if the expression compares
// unequal to 0. The condition must be a scalar type.
-
+
// If the condition constant folds and can be elided, try to avoid emitting
// the condition and the dead arm of the if/else.
if (int Cond = ConstantFoldsToSimpleInteger(S.getCond())) {
@@ -302,7 +302,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
const Stmt *Executed = S.getThen(), *Skipped = S.getElse();
if (Cond == -1) // Condition false?
std::swap(Executed, Skipped);
-
+
// If the skipped block has no labels in it, just emit the executed block.
// This avoids emitting dead code and simplifies the CFG substantially.
if (!ContainsLabel(Skipped)) {
@@ -320,19 +320,19 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
if (S.getElse())
ElseBlock = createBasicBlock("if.else");
EmitBranchOnBoolExpr(S.getCond(), ThenBlock, ElseBlock);
-
+
// Emit the 'then' code.
EmitBlock(ThenBlock);
EmitStmt(S.getThen());
EmitBranch(ContBlock);
-
+
// Emit the 'else' code if present.
if (const Stmt *Else = S.getElse()) {
EmitBlock(ElseBlock);
EmitStmt(Else);
EmitBranch(ContBlock);
}
-
+
// Emit the continuation block for code after the if.
EmitBlock(ContBlock, true);
}
@@ -350,7 +350,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(ExitBlock, LoopHeader));
-
+
// Evaluate the conditional in the while header. C99 6.8.5.1: The
// evaluation of the controlling expression takes place before each
// execution of the loop body.
@@ -359,23 +359,23 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
// while(1) is common, avoid extra exit blocks. Be sure
// to correctly handle break/continue though.
bool EmitBoolCondBranch = true;
- if (llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
+ if (llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
if (C->isOne())
EmitBoolCondBranch = false;
-
+
// As long as the condition is true, go to the loop body.
if (EmitBoolCondBranch)
Builder.CreateCondBr(BoolCondVal, LoopBody, ExitBlock);
-
+
// Emit the loop body.
EmitBlock(LoopBody);
EmitStmt(S.getBody());
- BreakContinueStack.pop_back();
-
+ BreakContinueStack.pop_back();
+
// Cycle to the condition.
EmitBranch(LoopHeader);
-
+
// Emit the exit block.
EmitBlock(ExitBlock, true);
@@ -393,20 +393,20 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
EmitBlock(LoopBody);
llvm::BasicBlock *DoCond = createBasicBlock("do.cond");
-
+
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(AfterDo, DoCond));
-
+
// Emit the body of the loop into the block.
EmitStmt(S.getBody());
-
+
BreakContinueStack.pop_back();
-
+
EmitBlock(DoCond);
-
+
// C99 6.8.5.2: "The evaluation of the controlling expression takes place
// after each execution of the loop body."
-
+
// Evaluate the conditional in the while header.
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
@@ -415,14 +415,14 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
// "do {} while (0)" is common in macros, avoid extra blocks. Be sure
// to correctly handle break/continue though.
bool EmitBoolCondBranch = true;
- if (llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
+ if (llvm::ConstantInt *C = dyn_cast<llvm::ConstantInt>(BoolCondVal))
if (C->isZero())
EmitBoolCondBranch = false;
// As long as the condition is true, iterate the loop.
if (EmitBoolCondBranch)
Builder.CreateCondBr(BoolCondVal, LoopBody, AfterDo);
-
+
// Emit the exit block.
EmitBlock(AfterDo);
@@ -451,25 +451,25 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
if (S.getCond()) {
// As long as the condition is true, iterate the loop.
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
-
+
// C99 6.8.5p2/p4: The first substatement is executed if the expression
// compares unequal to 0. The condition must be a scalar type.
EmitBranchOnBoolExpr(S.getCond(), ForBody, AfterFor);
-
- EmitBlock(ForBody);
+
+ EmitBlock(ForBody);
} else {
// Treat it as a non-zero constant. Don't even create a new block for the
// body, just fall into it.
}
- // If the for loop doesn't have an increment we can just use the
+ // If the for loop doesn't have an increment we can just use the
// condition as the continue block.
llvm::BasicBlock *ContinueBlock;
if (S.getInc())
ContinueBlock = createBasicBlock("for.inc");
else
- ContinueBlock = CondBlock;
-
+ ContinueBlock = CondBlock;
+
// Store the blocks to use for break and continue.
BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
@@ -477,13 +477,13 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
EmitStmt(S.getBody());
BreakContinueStack.pop_back();
-
+
// If there is an increment, emit it next.
if (S.getInc()) {
EmitBlock(ContinueBlock);
EmitStmt(S.getInc());
}
-
+
// Finally, branch back up to the condition for the next iteration.
EmitBranch(CondBlock);
@@ -508,7 +508,7 @@ void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// Emit the result value, even if unused, to evalute the side effects.
const Expr *RV = S.getRetValue();
-
+
// FIXME: Clean this up by using an LValue for ReturnTemp,
// EmitStoreThroughLValue, and EmitAnyExpr.
if (!ReturnValue) {
@@ -601,8 +601,8 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
LHS++;
}
return;
- }
-
+ }
+
// The range is too big. Emit "if" condition into a new block,
// making sure to save and restore the current insertion point.
llvm::BasicBlock *RestoreBB = Builder.GetInsertBlock();
@@ -617,10 +617,10 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
Builder.SetInsertPoint(CaseRangeBlock);
// Emit range check.
- llvm::Value *Diff =
- Builder.CreateSub(SwitchInsn->getCondition(),
+ llvm::Value *Diff =
+ Builder.CreateSub(SwitchInsn->getCondition(),
llvm::ConstantInt::get(VMContext, LHS), "tmp");
- llvm::Value *Cond =
+ llvm::Value *Cond =
Builder.CreateICmpULE(Diff,
llvm::ConstantInt::get(VMContext, Range), "tmp");
Builder.CreateCondBr(Cond, CaseDest, FalseDest);
@@ -637,12 +637,12 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
EmitCaseStmtRange(S);
return;
}
-
+
EmitBlock(createBasicBlock("sw.bb"));
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
llvm::APSInt CaseVal = S.getLHS()->EvaluateAsInt(getContext());
SwitchInsn->addCase(llvm::ConstantInt::get(VMContext, CaseVal), CaseDest);
-
+
// Recursively emitting the statement is acceptable, but is not wonderful for
// code where we have many case statements nested together, i.e.:
// case 1:
@@ -663,14 +663,14 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
NextCase = dyn_cast<CaseStmt>(CurCase->getSubStmt());
}
-
+
// Normal default recursion for non-cases.
EmitStmt(CurCase->getSubStmt());
}
void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
- assert(DefaultBlock->empty() &&
+ assert(DefaultBlock->empty() &&
"EmitDefaultStmt: Default block already defined?");
EmitBlock(DefaultBlock);
EmitStmt(S.getSubStmt());
@@ -706,13 +706,13 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
// Emit switch body.
EmitStmt(S.getBody());
-
+
BreakContinueStack.pop_back();
// Update the default block in case explicit case range tests have
// been chained on top.
SwitchInsn->setSuccessor(0, CaseRangeBlock);
-
+
// If a default was never emitted then reroute any jumps to it and
// discard.
if (!DefaultBlock->getParent()) {
@@ -731,7 +731,7 @@ static std::string
SimplifyConstraint(const char *Constraint, TargetInfo &Target,
llvm::SmallVectorImpl<TargetInfo::ConstraintInfo> *OutCons=0) {
std::string Result;
-
+
while (*Constraint) {
switch (*Constraint) {
default:
@@ -749,7 +749,7 @@ SimplifyConstraint(const char *Constraint, TargetInfo &Target,
assert(OutCons &&
"Must pass output names to constraints with a symbolic name");
unsigned Index;
- bool result = Target.resolveSymbolicName(Constraint,
+ bool result = Target.resolveSymbolicName(Constraint,
&(*OutCons)[0],
OutCons->size(), Index);
assert(result && "Could not resolve symbolic name"); result=result;
@@ -757,10 +757,10 @@ SimplifyConstraint(const char *Constraint, TargetInfo &Target,
break;
}
}
-
+
Constraint++;
}
-
+
return Result;
}
@@ -769,9 +769,9 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
const Expr *InputExpr,
std::string &ConstraintStr) {
llvm::Value *Arg;
- if (Info.allowsRegister() || !Info.allowsMemory()) {
+ if (Info.allowsRegister() || !Info.allowsMemory()) {
const llvm::Type *Ty = ConvertType(InputExpr->getType());
-
+
if (Ty->isSingleValueType()) {
Arg = EmitScalarExpr(InputExpr);
} else {
@@ -782,7 +782,7 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
if (Size <= 64 && llvm::isPowerOf2_64(Size)) {
Ty = llvm::IntegerType::get(VMContext, Size);
Ty = llvm::PointerType::getUnqual(Ty);
-
+
Arg = Builder.CreateLoad(Builder.CreateBitCast(Dest.getAddress(), Ty));
} else {
Arg = Dest.getAddress();
@@ -795,7 +795,7 @@ llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
Arg = Dest.getAddress();
ConstraintStr += '*';
}
-
+
return Arg;
}
@@ -805,7 +805,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
llvm::SmallVector<AsmStmt::AsmStringPiece, 4> Pieces;
unsigned DiagOffs;
S.AnalyzeAsmString(Pieces, getContext(), DiagOffs);
-
+
// Assemble the pieces into the final asm string.
std::string AsmString;
for (unsigned i = 0, e = Pieces.size(); i != e; ++i) {
@@ -817,19 +817,19 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
AsmString += "${" + llvm::utostr(Pieces[i].getOperandNo()) + ':' +
Pieces[i].getModifier() + '}';
}
-
+
// Get all the output and input constraints together.
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> InputConstraintInfos;
- for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
+ for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
TargetInfo::ConstraintInfo Info(S.getOutputConstraint(i),
S.getOutputName(i));
bool result = Target.validateOutputConstraint(Info);
assert(result && "Failed to parse output constraint"); result=result;
OutputConstraintInfos.push_back(Info);
- }
-
+ }
+
for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
TargetInfo::ConstraintInfo Info(S.getInputConstraint(i),
S.getInputName(i));
@@ -839,9 +839,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
assert(result && "Failed to parse input constraint");
InputConstraintInfos.push_back(Info);
}
-
+
std::string Constraints;
-
+
std::vector<LValue> ResultRegDests;
std::vector<QualType> ResultRegQualTys;
std::vector<const llvm::Type *> ResultRegTypes;
@@ -854,16 +854,16 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
std::vector<llvm::Value*> InOutArgs;
std::vector<const llvm::Type*> InOutArgTypes;
- for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
+ for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
TargetInfo::ConstraintInfo &Info = OutputConstraintInfos[i];
// Simplify the output constraint.
std::string OutputConstraint(S.getOutputConstraint(i));
OutputConstraint = SimplifyConstraint(OutputConstraint.c_str() + 1, Target);
-
+
const Expr *OutExpr = S.getOutputExpr(i);
OutExpr = OutExpr->IgnoreParenNoopCasts(getContext());
-
+
LValue Dest = EmitLValue(OutExpr);
if (!Constraints.empty())
Constraints += ',';
@@ -876,7 +876,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
ResultRegDests.push_back(Dest);
ResultRegTypes.push_back(ConvertTypeForMem(OutExpr->getType()));
ResultTruncRegTypes.push_back(ResultRegTypes.back());
-
+
// If this output is tied to an input, and if the input is larger, then
// we need to set the actual result type of the inline asm node to be the
// same as the input type.
@@ -889,10 +889,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
break;
}
assert(InputNo != S.getNumInputs() && "Didn't find matching input!");
-
+
QualType InputTy = S.getInputExpr(InputNo)->getType();
QualType OutputTy = OutExpr->getType();
-
+
uint64_t InputSize = getContext().getTypeSize(InputTy);
if (getContext().getTypeSize(OutputTy) < InputSize) {
// Form the asm to return the value as a larger integer type.
@@ -905,13 +905,13 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
Constraints += "=*";
Constraints += OutputConstraint;
}
-
+
if (Info.isReadWrite()) {
InOutConstraints += ',';
const Expr *InputExpr = S.getOutputExpr(i);
llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, InOutConstraints);
-
+
if (Info.allowsRegister())
InOutConstraints += llvm::utostr(i);
else
@@ -921,9 +921,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
InOutArgs.push_back(Arg);
}
}
-
+
unsigned NumConstraints = S.getNumOutputs() + S.getNumInputs();
-
+
for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
const Expr *InputExpr = S.getInputExpr(i);
@@ -931,14 +931,14 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
if (!Constraints.empty())
Constraints += ',';
-
+
// Simplify the input constraint.
std::string InputConstraint(S.getInputConstraint(i));
InputConstraint = SimplifyConstraint(InputConstraint.c_str(), Target,
&OutputConstraintInfos);
llvm::Value *Arg = EmitAsmInput(S, Info, InputExpr, Constraints);
-
+
// If this input argument is tied to a larger output result, extend the
// input to be the same size as the output. The LLVM backend wants to see
// the input and output of a matching constraint be the same size. Note
@@ -948,7 +948,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
unsigned Output = Info.getTiedOperand();
QualType OutputTy = S.getOutputExpr(Output)->getType();
QualType InputTy = InputExpr->getType();
-
+
if (getContext().getTypeSize(OutputTy) >
getContext().getTypeSize(InputTy)) {
// Use ptrtoint as appropriate so that we can do our extension.
@@ -959,35 +959,35 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
Arg = Builder.CreateZExt(Arg, llvm::IntegerType::get(VMContext, OutputSize));
}
}
-
-
+
+
ArgTypes.push_back(Arg->getType());
Args.push_back(Arg);
Constraints += InputConstraint;
}
-
+
// Append the "input" part of inout constraints last.
for (unsigned i = 0, e = InOutArgs.size(); i != e; i++) {
ArgTypes.push_back(InOutArgTypes[i]);
Args.push_back(InOutArgs[i]);
}
Constraints += InOutConstraints;
-
+
// Clobbers
for (unsigned i = 0, e = S.getNumClobbers(); i != e; i++) {
std::string Clobber(S.getClobber(i)->getStrData(),
S.getClobber(i)->getByteLength());
Clobber = Target.getNormalizedGCCRegisterName(Clobber.c_str());
-
+
if (i != 0 || NumConstraints != 0)
Constraints += ',';
-
+
Constraints += "~{";
Constraints += Clobber;
Constraints += '}';
}
-
+
// Add machine specific clobbers
std::string MachineClobbers = Target.getClobbers();
if (!MachineClobbers.empty()) {
@@ -1003,17 +1003,17 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
ResultType = ResultRegTypes[0];
else
ResultType = llvm::StructType::get(VMContext, ResultRegTypes);
-
- const llvm::FunctionType *FTy =
+
+ const llvm::FunctionType *FTy =
llvm::FunctionType::get(ResultType, ArgTypes, false);
-
- llvm::InlineAsm *IA =
- llvm::InlineAsm::get(FTy, AsmString, Constraints,
+
+ llvm::InlineAsm *IA =
+ llvm::InlineAsm::get(FTy, AsmString, Constraints,
S.isVolatile() || S.getNumOutputs() == 0);
llvm::CallInst *Result = Builder.CreateCall(IA, Args.begin(), Args.end());
Result->addAttribute(~0, llvm::Attribute::NoUnwind);
-
-
+
+
// Extract all of the register value results from the asm.
std::vector<llvm::Value*> RegResults;
if (ResultRegTypes.size() == 1) {
@@ -1024,10 +1024,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
RegResults.push_back(Tmp);
}
}
-
+
for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
llvm::Value *Tmp = RegResults[i];
-
+
// If the result type of the LLVM IR asm doesn't match the result type of
// the expression, do the conversion.
if (ResultRegTypes[i] != ResultTruncRegTypes[i]) {
@@ -1036,13 +1036,13 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
// ResultTruncRegTypes can be a pointer.
uint64_t ResSize = CGM.getTargetData().getTypeSizeInBits(TruncTy);
Tmp = Builder.CreateTrunc(Tmp, llvm::IntegerType::get(VMContext, (unsigned)ResSize));
-
+
if (Tmp->getType() != TruncTy) {
assert(isa<llvm::PointerType>(TruncTy));
Tmp = Builder.CreateIntToPtr(Tmp, TruncTy);
}
}
-
+
EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i],
ResultRegQualTys[i]);
}
diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h
index 5aaf951a54..fe97afad6e 100644
--- a/lib/CodeGen/CGValue.h
+++ b/lib/CodeGen/CGValue.h
@@ -37,14 +37,14 @@ class RValue {
// TODO: Encode this into the low bit of pointer for more efficient
// return-by-value.
enum { Scalar, Complex, Aggregate } Flavor;
-
+
bool Volatile:1;
public:
-
+
bool isScalar() const { return Flavor == Scalar; }
bool isComplex() const { return Flavor == Complex; }
bool isAggregate() const { return Flavor == Aggregate; }
-
+
bool isVolatileQualified() const { return Volatile; }
/// getScalar() - Return the Value* of this scalar value.
@@ -58,13 +58,13 @@ public:
std::pair<llvm::Value *, llvm::Value *> getComplexVal() const {
return std::pair<llvm::Value *, llvm::Value *>(V1, V2);
}
-
+
/// getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value *getAggregateAddr() const {
assert(isAggregate() && "Not an aggregate!");
return V1;
}
-
+
static RValue get(llvm::Value *V) {
RValue ER;
ER.V1 = V;
@@ -106,7 +106,7 @@ public:
/// bitrange.
class LValue {
// FIXME: alignment?
-
+
enum {
Simple, // This is a normal l-value, use getAddress().
VectorElt, // This is a vector element l-value (V[i]), use getVector*
@@ -123,16 +123,16 @@ class LValue {
Weak, // __weak object expression
Strong // __strong object expression
};
-
+
llvm::Value *V;
-
+
union {
// Index into a vector subscript: V[i]
llvm::Value *VectorIdx;
// ExtVector element subset: V.xyx
llvm::Constant *VectorElts;
-
+
// BitField start bit and size
struct {
unsigned short StartBit;
@@ -152,7 +152,7 @@ class LValue {
// objective-c's ivar
bool Ivar:1;
-
+
// LValue is non-gc'able for any reason, including being a parameter or local
// variable.
bool NonGC: 1;
@@ -161,7 +161,7 @@ class LValue {
bool GlobalObjCRef : 1;
// objective-c's gc attributes
- unsigned ObjCType : 2;
+ unsigned ObjCType : 2;
// address space
unsigned AddressSpace;
@@ -175,7 +175,7 @@ private:
R.ObjCType = None;
R.Ivar = R.NonGC = R.GlobalObjCRef = false;
}
-
+
public:
bool isSimple() const { return LVType == Simple; }
bool isVectorElt() const { return LVType == VectorElt; }
@@ -187,10 +187,10 @@ public:
bool isVolatileQualified() const { return Volatile; }
bool isRestrictQualified() const { return Restrict; }
unsigned getQualifiers() const {
- return (Volatile ? QualType::Volatile : 0) |
+ return (Volatile ? QualType::Volatile : 0) |
(Restrict ? QualType::Restrict : 0);
}
-
+
bool isObjCIvar() const { return Ivar; }
bool isNonGC () const { return NonGC; }
bool isGlobalObjCRef() const { return GlobalObjCRef; }
@@ -206,7 +206,7 @@ public:
static void SetGlobalObjCRef(LValue& R, bool iValue) {
R.GlobalObjCRef = iValue;
}
-
+
static void SetObjCNonGC(LValue& R, bool iValue) {
R.NonGC = iValue;
}
@@ -218,7 +218,7 @@ public:
else
R.ObjCType = None;
}
-
+
// simple lvalue
llvm::Value *getAddress() const { assert(isSimple()); return V; }
// vector elt lvalue
@@ -267,7 +267,7 @@ public:
SetObjCType(GCAttrs, R);
return R;
}
-
+
static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx,
unsigned Qualifiers) {
LValue R;
@@ -277,7 +277,7 @@ public:
SetQualifiers(Qualifiers,R);
return R;
}
-
+
static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts,
unsigned Qualifiers) {
LValue R;
@@ -312,8 +312,8 @@ public:
SetQualifiers(Qualifiers,R);
return R;
}
-
- static LValue MakeKVCRef(const ObjCImplicitSetterGetterRefExpr *E,
+
+ static LValue MakeKVCRef(const ObjCImplicitSetterGetterRefExpr *E,
unsigned Qualifiers) {
LValue R;
R.LVType = KVCRef;
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index e3511edd2b..be2406d063 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -23,11 +23,11 @@
using namespace clang;
using namespace CodeGen;
-CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
+CodeGenFunction::CodeGenFunction(CodeGenModule &cgm)
: BlockFunction(cgm, *this, Builder), CGM(cgm),
Target(CGM.getContext().Target),
Builder(cgm.getModule().getContext()),
- DebugInfo(0), SwitchInsn(0), CaseRangeBlock(0), InvokeDest(0),
+ DebugInfo(0), SwitchInsn(0), CaseRangeBlock(0), InvokeDest(0),
CXXThisDecl(0) {
LLVMIntTy = ConvertType(getContext().IntTy);
LLVMPointerWidth = Target.getPointerWidth(0);
@@ -41,7 +41,7 @@ ASTContext &CodeGenFunction::getContext() const {
llvm::BasicBlock *CodeGenFunction::getBasicBlockForLabel(const LabelStmt *S) {
llvm::BasicBlock *&BB = LabelMap[S];
if (BB) return BB;
-
+
// Create, but don't insert, the new block.
return BB = createBasicBlock(S->getName());
}
@@ -69,7 +69,7 @@ bool CodeGenFunction::hasAggregateLLVMType(QualType T) {
// FIXME: Use positive checks instead of negative ones to be more robust in
// the face of extension.
return !T->hasPointerRepresentation() && !T->isRealType() &&
- !T->isVoidType() && !T->isVectorType() && !T->isFunctionType() &&
+ !T->isVoidType() && !T->isVectorType() && !T->isFunctionType() &&
!T->isBlockPointerType() && !T->isMemberPointerType();
}
@@ -95,7 +95,7 @@ void CodeGenFunction::EmitReturnBlock() {
// branch then we can just put the code in that block instead. This
// cleans up functions which started with a unified return block.
if (ReturnBlock->hasOneUse()) {
- llvm::BranchInst *BI =
+ llvm::BranchInst *BI =
dyn_cast<llvm::BranchInst>(*ReturnBlock->use_begin());
if (BI && BI->isUnconditional() && BI->getSuccessor(0) == ReturnBlock) {
// Reset insertion point and delete the branch.
@@ -123,8 +123,8 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
"did not remove all blocks from block scope map!");
assert(CleanupEntries.empty() &&
"mismatched push/pop in cleanup stack!");
-
- // Emit function epilog (to return).
+
+ // Emit function epilog (to return).
EmitReturnBlock();
// Emit debug descriptor for function end.
@@ -141,7 +141,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
Ptr->eraseFromParent();
}
-void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
+void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
llvm::Function *Fn,
const FunctionArgList &Args,
SourceLocation StartLoc) {
@@ -161,14 +161,14 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
EntryBB);
if (Builder.isNamePreserving())
AllocaInsertPt->setName("allocapt");
-
+
ReturnBlock = createBasicBlock("return");
ReturnValue = 0;
if (!RetTy->isVoidType())
ReturnValue = CreateTempAlloca(ConvertType(RetTy), "retval");
-
+
Builder.SetInsertPoint(EntryBB);
-
+
// Emit subprogram debug descriptor.
// FIXME: The cast here is a huge hack.
if (CGDebugInfo *DI = getDebugInfo()) {
@@ -177,9 +177,9 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
DI->EmitFunctionStart(CGM.getMangledName(FD), RetTy, CurFn, Builder);
} else {
// Just use LLVM function name.
-
+
// FIXME: Remove unnecessary conversion to std::string when API settles.
- DI->EmitFunctionStart(std::string(Fn->getName()).c_str(),
+ DI->EmitFunctionStart(std::string(Fn->getName()).c_str(),
RetTy, CurFn, Builder);
}
}
@@ -187,7 +187,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
// FIXME: Leaked.
CurFnInfo = &CGM.getTypes().getFunctionInfo(FnRetTy, Args);
EmitFunctionProlog(*CurFnInfo, CurFn, Args);
-
+
// If any of the arguments have a variably modified type, make sure to
// emit the type size.
for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
@@ -204,27 +204,27 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
// Check if we should generate debug info for this function.
if (CGM.getDebugInfo() && !FD->hasAttr<NoDebugAttr>())
DebugInfo = CGM.getDebugInfo();
-
+
FunctionArgList Args;
-
+
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
if (MD->isInstance()) {
// Create the implicit 'this' decl.
// FIXME: I'm not entirely sure I like using a fake decl just for code
// generation. Maybe we can come up with a better way?
CXXThisDecl = ImplicitParamDecl::Create(getContext(), 0, SourceLocation(),
- &getContext().Idents.get("this"),
+ &getContext().Idents.get("this"),
MD->getThisType(getContext()));
Args.push_back(std::make_pair(CXXThisDecl, CXXThisDecl->getType()));
}
}
-
+
if (FD->getNumParams()) {
const FunctionProtoType* FProto = FD->getType()->getAsFunctionProtoType();
assert(FProto && "Function def must have prototype!");
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i)
- Args.push_back(std::make_pair(FD->getParamDecl(i),
+ Args.push_back(std::make_pair(FD->getParamDecl(i),
FProto->getArgType(i)));
}
@@ -238,9 +238,9 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
EmitDtorEpilogue(DD);
FinishFunction(S->getRBracLoc());
}
- else
+ else
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- const CXXRecordDecl *ClassDecl =
+ const CXXRecordDecl *ClassDecl =
cast<CXXRecordDecl>(CD->getDeclContext());
(void) ClassDecl;
if (CD->isCopyConstructor(getContext())) {
@@ -259,7 +259,7 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
else if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
if (MD->isCopyAssignment())
SynthesizeCXXCopyAssignment(MD, FD, Fn, Args);
-
+
// Destroy the 'this' declaration.
if (CXXThisDecl)
CXXThisDecl->Destroy(getContext());
@@ -271,27 +271,27 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) {
// Null statement, not a label!
if (S == 0) return false;
-
+
// If this is a label, we have to emit the code, consider something like:
// if (0) { ... foo: bar(); } goto foo;
if (isa<LabelStmt>(S))
return true;
-
+
// If this is a case/default statement, and we haven't seen a switch, we have
// to emit the code.
if (isa<SwitchCase>(S) && !IgnoreCaseStmts)
return true;
-
+
// If this is a switch statement, we want to ignore cases below it.
if (isa<SwitchStmt>(S))
IgnoreCaseStmts = true;
-
+
// Scan subexpressions for verboten labels.
for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
I != E; ++I)
if (ContainsLabel(*I, IgnoreCaseStmts))
return true;
-
+
return false;
}
@@ -304,13 +304,13 @@ int CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond) {
// FIXME: Rename and handle conversion of other evaluatable things
// to bool.
Expr::EvalResult Result;
- if (!Cond->Evaluate(Result, getContext()) || !Result.Val.isInt() ||
+ if (!Cond->Evaluate(Result, getContext()) || !Result.Val.isInt() ||
Result.HasSideEffects)
return 0; // Not foldable, not integer or not fully evaluatable.
-
+
if (CodeGenFunction::ContainsLabel(Cond))
return 0; // Contains a label.
-
+
return Result.Val.getInt().getBoolValue() ? 1 : -1;
}
@@ -326,7 +326,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
return EmitBranchOnBoolExpr(PE->getSubExpr(), TrueBlock, FalseBlock);
if (const CastExpr *E = dyn_cast<CastExpr>(Cond))
if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) {
- if (const CXXFunctionalCastExpr *CXXFExpr =
+ if (const CXXFunctionalCastExpr *CXXFExpr =
dyn_cast<CXXFunctionalCastExpr>(E)) {
EmitCXXFunctionalCastExpr(CXXFExpr);
return;
@@ -335,7 +335,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
return EmitBranchOnBoolExpr(E->getSubExpr(), TrueBlock, FalseBlock);
assert(false && "EmitBranchOnBoolExpr - Expected CStyleCastExpr");
}
-
+
if (const BinaryOperator *CondBOp = dyn_cast<BinaryOperator>(Cond)) {
// Handle X && Y in a condition.
if (CondBOp->getOpcode() == BinaryOperator::LAnd) {
@@ -345,20 +345,20 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
// br(1 && X) -> br(X).
return EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock);
}
-
+
// If we have "X && 1", simplify the code to use an uncond branch.
// "X && 0" would have been constant folded to 0.
if (ConstantFoldsToSimpleInteger(CondBOp->getRHS()) == 1) {
// br(X && 1) -> br(X).
return EmitBranchOnBoolExpr(CondBOp->getLHS(), TrueBlock, FalseBlock);
}
-
+
// Emit the LHS as a conditional. If the LHS conditional is false, we
// want to jump to the FalseBlock.
llvm::BasicBlock *LHSTrue = createBasicBlock("land.lhs.true");
EmitBranchOnBoolExpr(CondBOp->getLHS(), LHSTrue, FalseBlock);
EmitBlock(LHSTrue);
-
+
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock);
return;
} else if (CondBOp->getOpcode() == BinaryOperator::LOr) {
@@ -368,31 +368,31 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond,
// br(0 || X) -> br(X).
return EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock);
}
-
+
// If we have "X || 0", simplify the code to use an uncond branch.
// "X || 1" would have been constant folded to 1.
if (ConstantFoldsToSimpleInteger(CondBOp->getRHS()) == -1) {
// br(X || 0) -> br(X).
return EmitBranchOnBoolExpr(CondBOp->getLHS(), TrueBlock, FalseBlock);
}
-
+
// Emit the LHS as a conditional. If the LHS conditional is true, we
// want to jump to the TrueBlock.
llvm::BasicBlock *LHSFalse = createBasicBlock("lor.lhs.false");
EmitBranchOnBoolExpr(CondBOp->getLHS(), TrueBlock, LHSFalse);
EmitBlock(LHSFalse);
-
+
EmitBranchOnBoolExpr(CondBOp->getRHS(), TrueBlock, FalseBlock);
return;
}
}
-
+
if (const UnaryOperator *CondUOp = dyn_cast<UnaryOperator>(Cond)) {
// br(!x, t, f) -> br(x, f, t)
if (CondUOp->getOpcode() == UnaryOperator::LNot)
return EmitBranchOnBoolExpr(CondUOp->getSubExpr(), FalseBlock, TrueBlock);
}
-
+
if (const ConditionalOperator *CondOp = dyn_cast<ConditionalOperator>(Cond)) {
// Handle ?: operator.
@@ -438,25 +438,25 @@ void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) {
// Don't bother emitting a zero-byte memset.
if (TypeInfo.first == 0)
return;
-
+
// FIXME: Handle variable sized types.
- const llvm::Type *IntPtr = llvm::IntegerType::get(VMContext,
+ const llvm::Type *IntPtr = llvm::IntegerType::get(VMContext,
LLVMPointerWidth);
Builder.CreateCall4(CGM.getMemSetFn(), DestPtr,
llvm::Constant::getNullValue(llvm::Type::getInt8Ty(VMContext)),
// TypeInfo.first describes size in bits.
llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
- llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
TypeInfo.second/8));
}
void CodeGenFunction::EmitIndirectSwitches() {
llvm::BasicBlock *Default;
-
+
if (IndirectSwitches.empty())
return;
-
+
if (!LabelIDs.empty()) {
Default = getBasicBlockForLabel(LabelIDs.begin()->first);
} else {
@@ -469,20 +469,20 @@ void CodeGenFunction::EmitIndirectSwitches() {
for (std::vector<llvm::SwitchInst*>::iterator i = IndirectSwitches.begin(),
e = IndirectSwitches.end(); i != e; ++i) {
llvm::SwitchInst *I = *i;
-
+
I->setSuccessor(0, Default);
- for (std::map<const LabelStmt*,unsigned>::iterator LI = LabelIDs.begin(),
+ for (std::map<const LabelStmt*,unsigned>::iterator LI = LabelIDs.begin(),
LE = LabelIDs.end(); LI != LE; ++LI) {
I->addCase(llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
- LI->second),
+ LI->second),
getBasicBlockForLabel(LI->first));
}
- }
+ }
}
llvm::Value *CodeGenFunction::GetVLASize(const VariableArrayType *VAT) {
llvm::Value *&SizeEntry = VLASizeMap[VAT->getSizeExpr()];
-
+
assert(SizeEntry && "Did not emit size for type");
return SizeEntry;
}
@@ -490,15 +490,15 @@ llvm::Value *CodeGenFunction::GetVLASize(const VariableArrayType *VAT) {
llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
assert(Ty->isVariablyModifiedType() &&
"Must pass variably modified type to EmitVLASizes!");
-
+
EnsureInsertPoint();
-
+
if (const VariableArrayType *VAT = getContext().getAsVariableArrayType(Ty)) {
llvm::Value *&SizeEntry = VLASizeMap[VAT->getSizeExpr()];
-
+
if (!SizeEntry) {
const llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
-
+
// Get the element size;
QualType ElemTy = VAT->getElementType();
llvm::Value *ElemSize;
@@ -507,21 +507,21 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
else
ElemSize = llvm::ConstantInt::get(SizeTy,
getContext().getTypeSize(ElemTy) / 8);
-
+
llvm::Value *NumElements = EmitScalarExpr(VAT->getSizeExpr());
NumElements = Builder.CreateIntCast(NumElements, SizeTy, false, "tmp");
-
+
SizeEntry = Builder.CreateMul(ElemSize, NumElements);
}
-
+
return SizeEntry;
}
-
+
if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
EmitVLASize(AT->getElementType());
return 0;
- }
-
+ }
+
const PointerType *PT = Ty->getAs<PointerType>();
assert(PT && "unknown VM type!");
EmitVLASize(PT->getPointeeType());
@@ -535,32 +535,29 @@ llvm::Value* CodeGenFunction::EmitVAListRef(const Expr* E) {
return EmitLValue(E).getAddress();
}
-void CodeGenFunction::PushCleanupBlock(llvm::BasicBlock *CleanupBlock)
-{
+void CodeGenFunction::PushCleanupBlock(llvm::BasicBlock *CleanupBlock) {
CleanupEntries.push_back(CleanupEntry(CleanupBlock));
}
-void CodeGenFunction::EmitCleanupBlocks(size_t OldCleanupStackSize)
-{
- assert(CleanupEntries.size() >= OldCleanupStackSize &&
+void CodeGenFunction::EmitCleanupBlocks(size_t OldCleanupStackSize) {
+ assert(CleanupEntries.size() >= OldCleanupStackSize &&
"Cleanup stack mismatch!");
-
+
while (CleanupEntries.size() > OldCleanupStackSize)
EmitCleanupBlock();
}
-CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
-{
+CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock() {
CleanupEntry &CE = CleanupEntries.back();
-
+
llvm::BasicBlock *CleanupBlock = CE.CleanupBlock;
-
+
std::vector<llvm::BasicBlock *> Blocks;
std::swap(Blocks, CE.Blocks);
-
+
std::vector<llvm::BranchInst *> BranchFixups;
std::swap(BranchFixups, CE.BranchFixups);
-
+
CleanupEntries.pop_back();
// Check if any branch fixups pointed to the scope we just popped. If so,
@@ -568,12 +565,12 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
for (size_t i = 0, e = BranchFixups.size(); i != e; ++i) {
llvm::BasicBlock *Dest = BranchFixups[i]->getSuccessor(0);
BlockScopeMap::iterator I = BlockScopes.find(Dest);
-
+
if (I == BlockScopes.end())
continue;
-
+
assert(I->second <= CleanupEntries.size() && "Invalid branch fixup!");
-
+
if (I->second == CleanupEntries.size()) {
// We don't need to do this branch fixup.
BranchFixups[i] = BranchFixups.back();
@@ -583,29 +580,29 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
continue;
}
}
-
+
llvm::BasicBlock *SwitchBlock = 0;
llvm::BasicBlock *EndBlock = 0;
if (!BranchFixups.empty()) {
SwitchBlock = createBasicBlock("cleanup.switch");
EndBlock = createBasicBlock("cleanup.end");
-
+
llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
-
+
Builder.SetInsertPoint(SwitchBlock);
- llvm::Value *DestCodePtr = CreateTempAlloca(llvm::Type::getInt32Ty(VMContext),
+ llvm::Value *DestCodePtr = CreateTempAlloca(llvm::Type::getInt32Ty(VMContext),
"cleanup.dst");
llvm::Value *DestCode = Builder.CreateLoad(DestCodePtr, "tmp");
-
+
// Create a switch instruction to determine where to jump next.
- llvm::SwitchInst *SI = Builder.CreateSwitch(DestCode, EndBlock,
+ llvm::SwitchInst *SI = Builder.CreateSwitch(DestCode, EndBlock,
BranchFixups.size());
// Restore the current basic block (if any)
if (CurBB) {
Builder.SetInsertPoint(CurBB);
-
+
// If we had a current basic block, we also need to emit an instruction
// to initialize the cleanup destination.
Builder.CreateStore(llvm::Constant::getNullValue(llvm::Type::getInt32Ty(VMContext)),
@@ -616,13 +613,13 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
for (size_t i = 0, e = BranchFixups.size(); i != e; ++i) {
llvm::BranchInst *BI = BranchFixups[i];
llvm::BasicBlock *Dest = BI->getSuccessor(0);
-
+
// Fixup the branch instruction to point to the cleanup block.
BI->setSuccessor(0, CleanupBlock);
-
+
if (CleanupEntries.empty()) {
llvm::ConstantInt *ID;
-
+
// Check if we already have a destination for this block.
if (Dest == SI->getDefaultDest())
ID = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 0);
@@ -631,24 +628,24 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
if (!ID) {
// No code found, get a new unique one by using the number of
// switch successors.
- ID = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
+ ID = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
SI->getNumSuccessors());
SI->addCase(ID, Dest);
}
}
-
+
// Store the jump destination before the branch instruction.
new llvm::StoreInst(ID, DestCodePtr, BI);
} else {
// We need to jump through another cleanup block. Create a pad block
// with a branch instruction that jumps to the final destination and
// add it as a branch fixup to the current cleanup scope.
-
+
// Create the pad block.
llvm::BasicBlock *CleanupPad = createBasicBlock("cleanup.pad", CurFn);
// Create a unique case ID.
- llvm::ConstantInt *ID = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
+ llvm::ConstantInt *ID = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
SI->getNumSuccessors());
// Store the jump destination before the branch instruction.
@@ -656,89 +653,86 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
// Add it as the destination.
SI->addCase(ID, CleanupPad);
-
+
// Create the branch to the final destination.
llvm::BranchInst *BI = llvm::BranchInst::Create(Dest);
CleanupPad->getInstList().push_back(BI);
-
+
// And add it as a branch fixup.
CleanupEntries.back().BranchFixups.push_back(BI);
}
}
}
-
+
// Remove all blocks from the block scope map.
for (size_t i = 0, e = Blocks.size(); i != e; ++i) {
assert(BlockScopes.count(Blocks[i]) &&
"Did not find block in scope map!");
-
+
BlockScopes.erase(Blocks[i]);
}
-
+
return CleanupBlockInfo(CleanupBlock, SwitchBlock, EndBlock);
}
-void CodeGenFunction::EmitCleanupBlock()
-{
+void CodeGenFunction::EmitCleanupBlock() {
CleanupBlockInfo Info = PopCleanupBlock();
-
+
llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
- if (CurBB && !CurBB->getTerminator() &&
+ if (CurBB && !CurBB->getTerminator() &&
Info.CleanupBlock->getNumUses() == 0) {
CurBB->getInstList().splice(CurBB->end(), Info.CleanupBlock->getInstList());
delete Info.CleanupBlock;
- } else
+ } else
EmitBlock(Info.CleanupBlock);
-
+
if (Info.SwitchBlock)
EmitBlock(Info.SwitchBlock);
if (Info.EndBlock)
EmitBlock(Info.EndBlock);
}
-void CodeGenFunction::AddBranchFixup(llvm::BranchInst *BI)
-{
- assert(!CleanupEntries.empty() &&
+void CodeGenFunction::AddBranchFixup(llvm::BranchInst *BI) {
+ assert(!CleanupEntries.empty() &&
"Trying to add branch fixup without cleanup block!");
-
+
// FIXME: We could be more clever here and check if there's already a branch
// fixup for this destination and recycle it.
CleanupEntries.back().BranchFixups.push_back(BI);
}
-void CodeGenFunction::EmitBranchThroughCleanup(llvm::BasicBlock *Dest)
-{
+void CodeGenFunction::EmitBranchThroughCleanup(llvm::BasicBlock *Dest) {
if (!HaveInsertPoint())
return;
-
+
llvm::BranchInst* BI = Builder.CreateBr(Dest);
-
+
Builder.ClearInsertionPoint();
-
+
// The stack is empty, no need to do any cleanup.
if (CleanupEntries.empty())
return;
-
+
if (!Dest->getParent()) {
// We are trying to branch to a block that hasn't been inserted yet.
AddBranchFixup(BI);
return;
}
-
+
BlockScopeMap::iterator I = BlockScopes.find(Dest);
if (I == BlockScopes.end()) {
// We are trying to jump to a block that is outside of any cleanup scope.
AddBranchFixup(BI);
return;
}
-
+
assert(I->second < CleanupEntries.size() &&
"Trying to branch into cleanup region");
-
+
if (I->second == CleanupEntries.size() - 1) {
// We have a branch to a block in the same scope.
return;
}
-
+
AddBranchFixup(BI);
}
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 063ebf92de..0fac947efe 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -166,20 +166,20 @@ public:
/// this behavior for branches?
void EmitBranchThroughCleanup(llvm::BasicBlock *Dest);
- /// PushConditionalTempDestruction - Should be called before a conditional
+ /// PushConditionalTempDestruction - Should be called before a conditional
/// part of an expression is emitted. For example, before the RHS of the
/// expression below is emitted:
- ///
+ ///
/// b && f(T());
///
/// This is used to make sure that any temporaryes created in the conditional
/// branch are only destroyed if the branch is taken.
void PushConditionalTempDestruction();
-
- /// PopConditionalTempDestruction - Should be called after a conditional
+
+ /// PopConditionalTempDestruction - Should be called after a conditional
/// part of an expression has been emitted.
void PopConditionalTempDestruction();
-
+
private:
CGDebugInfo* DebugInfo;
@@ -261,37 +261,37 @@ private:
/// CXXThisDecl - When parsing an C++ function, this will hold the implicit
/// 'this' declaration.
ImplicitParamDecl *CXXThisDecl;
-
+
/// CXXLiveTemporaryInfo - Holds information about a live C++ temporary.
struct CXXLiveTemporaryInfo {
/// Temporary - The live temporary.
const CXXTemporary *Temporary;
-
+
/// ThisPtr - The pointer to the temporary.
llvm::Value *ThisPtr;
-
+
/// DtorBlock - The destructor block.
llvm::BasicBlock *DtorBlock;
-
+
/// CondPtr - If this is a conditional temporary, this is the pointer to
/// the condition variable that states whether the destructor should be
/// called or not.
llvm::Value *CondPtr;
-
+
CXXLiveTemporaryInfo(const CXXTemporary *temporary,
llvm::Value *thisptr, llvm::BasicBlock *dtorblock,
llvm::Value *condptr)
- : Temporary(temporary), ThisPtr(thisptr), DtorBlock(dtorblock),
+ : Temporary(temporary), ThisPtr(thisptr), DtorBlock(dtorblock),
CondPtr(condptr) { }
};
-
+
llvm::SmallVector<CXXLiveTemporaryInfo, 4> LiveTemporaries;
- /// ConditionalTempDestructionStack - Contains the number of live temporaries
+ /// ConditionalTempDestructionStack - Contains the number of live temporaries
/// when PushConditionalTempDestruction was called. This is used so that
/// we know how many temporaries were created by a certain expression.
llvm::SmallVector<size_t, 4> ConditionalTempDestructionStack;
-
+
public:
CodeGenFunction(CodeGenModule &cgm);
@@ -368,32 +368,32 @@ public:
bool Extern, int64_t nv, int64_t v);
void EmitCtorPrologue(const CXXConstructorDecl *CD);
-
+
void SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
const FunctionArgList &Args);
-
+
void SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
const FunctionArgList &Args);
-
+
void SynthesizeDefaultConstructor(const CXXConstructorDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
const FunctionArgList &Args);
-
+
void SynthesizeDefaultDestructor(const CXXDestructorDecl *CD,
const FunctionDecl *FD,
llvm::Function *Fn,
const FunctionArgList &Args);
-
+
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
- /// destructor. This is to call destructors on members and base classes
+ /// destructor. This is to call destructors on members and base classes
/// in reverse order of their construction.
void EmitDtorEpilogue(const CXXDestructorDecl *DD);
-
+
/// EmitFunctionProlog - Emit the target specific LLVM code to load the
/// arguments for the given function. This is also responsible for naming the
/// LLVM function arguments.
@@ -559,42 +559,42 @@ public:
/// LoadCXXThis - Load the value of 'this'. This function is only valid while
/// generating code for an C++ member function.
llvm::Value *LoadCXXThis();
-
+
/// AddressCXXOfBaseClass - This function will add the necessary delta
/// to the load of 'this' and returns address of the base class.
- // FIXME. This currently only does a derived to non-virtual base conversion.
+ // FIXME. This currently only does a derived to non-virtual base conversion.
// Other kinds of conversions will come later.
llvm::Value *AddressCXXOfBaseClass(llvm::Value *ThisValue,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl);
-
- void EmitClassAggrMemberwiseCopy(llvm::Value *DestValue,
+
+ void EmitClassAggrMemberwiseCopy(llvm::Value *DestValue,
llvm::Value *SrcValue,
const ArrayType *Array,
const CXXRecordDecl *BaseClassDecl,
QualType Ty);
- void EmitClassAggrCopyAssignment(llvm::Value *DestValue,
+ void EmitClassAggrCopyAssignment(llvm::Value *DestValue,
llvm::Value *SrcValue,
const ArrayType *Array,
const CXXRecordDecl *BaseClassDecl,
QualType Ty);
void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl,
QualType Ty);
-
+
void EmitClassCopyAssignment(llvm::Value *DestValue, llvm::Value *SrcValue,
- const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl,
QualType Ty);
-
- void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type,
+
+ void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type,
llvm::Value *This,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd);
-
+
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
const ArrayType *Array,
llvm::Value *This);
@@ -602,16 +602,16 @@ public:
void EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
const ArrayType *Array,
llvm::Value *This);
-
+
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
llvm::Value *This);
-
+
void PushCXXTemporary(const CXXTemporary *Temporary, llvm::Value *Ptr);
void PopCXXTemporary();
-
+
llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
-
+
//===--------------------------------------------------------------------===//
// Declaration Emission
//===--------------------------------------------------------------------===//
@@ -621,7 +621,7 @@ public:
/// This function can be called with a null (unreachable) insert point.
void EmitDecl(const Decl &D);
- /// EmitBlockVarDecl - Emit a block variable declaration.
+ /// EmitBlockVarDecl - Emit a block variable declaration.
///
/// This function can be called with a null (unreachable) insert point.
void EmitBlockVarDecl(const VarDecl &D);
@@ -799,7 +799,7 @@ public:
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
-
+
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E);
@@ -822,13 +822,13 @@ public:
llvm::Value *Callee,
const CallArgList &Args,
const Decl *TargetDecl = 0);
-
+
RValue EmitCall(llvm::Value *Callee, QualType FnType,
CallExpr::const_arg_iterator ArgBeg,
CallExpr::const_arg_iterator ArgEnd,
const Decl *TargetDecl = 0);
RValue EmitCallExpr(const CallExpr *E);
-
+
llvm::Value *BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
const llvm::Type *Ty);
RValue EmitCXXMemberCall(const CXXMethodDecl *MD,
@@ -840,10 +840,10 @@ public:
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
const CXXMethodDecl *MD);
-
+
RValue EmitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *E);
-
- RValue EmitBuiltinExpr(const FunctionDecl *FD,
+
+ RValue EmitBuiltinExpr(const FunctionDecl *FD,
unsigned BuiltinID, const CallExpr *E);
RValue EmitBlockCallExpr(const CallExpr *E);
@@ -873,7 +873,7 @@ public:
/// expression. Will emit a temporary variable if E is not an LValue.
RValue EmitReferenceBindingToExpr(const Expr* E, QualType DestType,
bool IsInitializer = false);
-
+
//===--------------------------------------------------------------------===//
// Expression Emission
//===--------------------------------------------------------------------===//
@@ -946,20 +946,20 @@ public:
/// with the C++ runtime so that its destructor will be called at exit.
void EmitCXXGlobalDtorRegistration(const CXXDestructorDecl *Dtor,
llvm::Constant *DeclPtr);
-
- /// GenerateCXXGlobalInitFunc - Generates code for initializing global
+
+ /// GenerateCXXGlobalInitFunc - Generates code for initializing global
/// variables.
void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
const VarDecl **Decls,
unsigned NumDecls);
-
+
void EmitCXXConstructExpr(llvm::Value *Dest, const CXXConstructExpr *E);
-
+
RValue EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
- llvm::Value *AggLoc = 0,
+ llvm::Value *AggLoc = 0,
bool IsAggLocVolatile = false,
bool IsInitializer = false);
-
+
//===--------------------------------------------------------------------===//
// Internal Helpers
//===--------------------------------------------------------------------===//
@@ -1004,7 +1004,7 @@ private:
void ExpandTypeToArgs(QualType Ty, RValue Src,
llvm::SmallVector<llvm::Value*, 16> &Args);
- llvm::Value* EmitAsmInput(const AsmStmt &S,
+ llvm::Value* EmitAsmInput(const AsmStmt &S,
const TargetInfo::ConstraintInfo &Info,
const Expr *InputExpr, std::string &ConstraintStr);
@@ -1017,9 +1017,9 @@ private:
/// EmitCallArg - Emit a single call argument.
RValue EmitCallArg(const Expr *E, QualType ArgType);
-
+
/// EmitCallArgs - Emit call arguments for a function.
- /// The CallArgTypeInfo parameter is used for iterating over the known
+ /// The CallArgTypeInfo parameter is used for iterating over the known
/// argument types of the function being called.
template<typename T>
void EmitCallArgs(CallArgList& Args, const T* CallArgTypeInfo,
@@ -1034,21 +1034,21 @@ private:
QualType ArgType = *I;
assert(getContext().getCanonicalType(ArgType.getNonReferenceType()).
- getTypePtr() ==
- getContext().getCanonicalType(Arg->getType()).getTypePtr() &&
+ getTypePtr() ==
+ getContext().getCanonicalType(Arg->getType()).getTypePtr() &&
"type mismatch in call argument!");
-
- Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
+
+ Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
ArgType));
}
-
- // Either we've emitted all the call args, or we have a call to a
+
+ // Either we've emitted all the call args, or we have a call to a
// variadic function.
- assert((Arg == ArgEnd || CallArgTypeInfo->isVariadic()) &&
+ assert((Arg == ArgEnd || CallArgTypeInfo->isVariadic()) &&
"Extra arguments in non-variadic function!");
-
+
}
-
+
// If we still have any arguments, emit them using the type of the argument.
for (; Arg != ArgEnd; ++Arg) {
QualType ArgType = Arg->getType();
@@ -1057,7 +1057,7 @@ private:
}
}
};
-
+
} // end namespace CodeGen
} // end namespace clang
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 180a68659d..fbd8521e19 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -81,7 +81,7 @@ void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type,
bool OmitOnError) {
if (OmitOnError && getDiags().hasErrorOccurred())
return;
- unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error,
+ unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error,
"cannot compile this %0 yet");
std::string Msg = Type;
getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID)
@@ -94,13 +94,13 @@ void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type,
bool OmitOnError) {
if (OmitOnError && getDiags().hasErrorOccurred())
return;
- unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error,
+ unsigned DiagID = getDiags().getCustomDiagID(Diagnostic::Error,
"cannot compile this %0 yet");
std::string Msg = Type;
getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID) << Msg;
}
-LangOptions::VisibilityMode
+LangOptions::VisibilityMode
CodeGenModule::getDeclVisibilityMode(const Decl *D) const {
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
if (VD->getStorageClass() == VarDecl::PrivateExtern)
@@ -109,7 +109,7 @@ CodeGenModule::getDeclVisibilityMode(const Decl *D) const {
if (const VisibilityAttr *attr = D->getAttr<VisibilityAttr>()) {
switch (attr->getVisibility()) {
default: assert(0 && "Unknown visibility!");
- case VisibilityAttr::DefaultVisibility:
+ case VisibilityAttr::DefaultVisibility:
return LangOptions::Default;
case VisibilityAttr::HiddenVisibility:
return LangOptions::Hidden;
@@ -121,7 +121,7 @@ CodeGenModule::getDeclVisibilityMode(const Decl *D) const {
return getLangOptions().getVisibilityMode();
}
-void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
+void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
const Decl *D) const {
// Internal definitions always have default visibility.
if (GV->hasLocalLinkage()) {
@@ -142,12 +142,12 @@ void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
const char *CodeGenModule::getMangledName(const GlobalDecl &GD) {
const NamedDecl *ND = GD.getDecl();
-
+
if (const CXXConstructorDecl *D = dyn_cast<CXXConstructorDecl>(ND))
return getMangledCXXCtorName(D, GD.getCtorType());
if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))
return getMangledCXXDtorName(D, GD.getDtorType());
-
+
return getMangledName(ND);
}
@@ -163,7 +163,7 @@ const char *CodeGenModule::getMangledName(const NamedDecl *ND) {
assert(ND->getIdentifier() && "Attempt to mangle unnamed decl.");
return ND->getNameAsCString();
}
-
+
llvm::SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
if (!mangleName(ND, Context, Out)) {
@@ -178,7 +178,7 @@ const char *CodeGenModule::getMangledName(const NamedDecl *ND) {
const char *CodeGenModule::UniqueMangledName(const char *NameStart,
const char *NameEnd) {
assert(*(NameEnd - 1) == '\0' && "Mangled name must be null terminated!");
-
+
return MangledNames.GetOrCreateValue(NameStart, NameEnd).getKeyData();
}
@@ -199,21 +199,21 @@ void CodeGenModule::AddGlobalDtor(llvm::Function * Dtor, int Priority) {
void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) {
// Ctor function type is void()*.
llvm::FunctionType* CtorFTy =
- llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
+ llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext),
std::vector<const llvm::Type*>(),
false);
llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy);
// Get the type of a ctor entry, { i32, void ()* }.
- llvm::StructType* CtorStructTy =
- llvm::StructType::get(VMContext, llvm::Type::getInt32Ty(VMContext),
+ llvm::StructType* CtorStructTy =
+ llvm::StructType::get(VMContext, llvm::Type::getInt32Ty(VMContext),
llvm::PointerType::getUnqual(CtorFTy), NULL);
// Construct the constructor and destructor arrays.
std::vector<llvm::Constant*> Ctors;
for (CtorList::const_iterator I = Fns.begin(), E = Fns.end(); I != E; ++I) {
std::vector<llvm::Constant*> S;
- S.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
+ S.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext),
I->second, false));
S.push_back(llvm::ConstantExpr::getBitCast(I->first, CtorPFTy));
Ctors.push_back(llvm::ConstantStruct::get(CtorStructTy, S));
@@ -237,38 +237,38 @@ void CodeGenModule::EmitAnnotations() {
llvm::ConstantArray::get(llvm::ArrayType::get(Annotations[0]->getType(),
Annotations.size()),
Annotations);
- llvm::GlobalValue *gv =
- new llvm::GlobalVariable(TheModule, Array->getType(), false,
- llvm::GlobalValue::AppendingLinkage, Array,
+ llvm::GlobalValue *gv =
+ new llvm::GlobalVariable(TheModule, Array->getType(), false,
+ llvm::GlobalValue::AppendingLinkage, Array,
"llvm.global.annotations");
gv->setSection("llvm.metadata");
}
static CodeGenModule::GVALinkage
-GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
+GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
const LangOptions &Features) {
// The kind of external linkage this function will have, if it is not
// inline or static.
CodeGenModule::GVALinkage External = CodeGenModule::GVA_StrongExternal;
- if (Context.getLangOptions().CPlusPlus &&
+ if (Context.getLangOptions().CPlusPlus &&
FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
External = CodeGenModule::GVA_TemplateInstantiation;
-
+
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
// C++ member functions defined inside the class are always inline.
if (MD->isInline() || !MD->isOutOfLine())
return CodeGenModule::GVA_CXXInline;
-
+
return External;
}
-
+
// "static" functions get internal linkage.
if (FD->getStorageClass() == FunctionDecl::Static)
return CodeGenModule::GVA_Internal;
if (!FD->isInline())
return External;
-
+
// If the inline function explicitly has the GNU inline attribute on it, or if
// this is C89 mode, we use to GNU semantics.
if (!Features.C99 && !Features.CPlusPlus) {
@@ -291,7 +291,7 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,
// have already handled "static inline" above, with the GVA_Internal case.
if (Features.CPlusPlus) // inline and extern inline.
return CodeGenModule::GVA_CXXInline;
-
+
assert(Features.C99 && "Must be in C99 mode if not in C89 or C++ mode");
if (FD->isC99InlineDefinition())
return CodeGenModule::GVA_C99Inline;
@@ -335,7 +335,7 @@ void CodeGenModule::SetFunctionDefinitionAttributes(const FunctionDecl *D,
}
void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
- const CGFunctionInfo &Info,
+ const CGFunctionInfo &Info,
llvm::Function *F) {
AttributeListType AttributeList;
ConstructAttributeList(Info, D, AttributeList);
@@ -354,16 +354,16 @@ void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
if (!Features.Exceptions && !Features.ObjCNonFragileABI)
- F->addFnAttr(llvm::Attribute::NoUnwind);
+ F->addFnAttr(llvm::Attribute::NoUnwind);
if (D->hasAttr<AlwaysInlineAttr>())
F->addFnAttr(llvm::Attribute::AlwaysInline);
-
+
if (D->hasAttr<NoInlineAttr>())
F->addFnAttr(llvm::Attribute::NoInline);
}
-void CodeGenModule::SetCommonAttributes(const Decl *D,
+void CodeGenModule::SetCommonAttributes(const Decl *D,
llvm::GlobalValue *GV) {
setGlobalVisibility(GV, D);
@@ -390,19 +390,19 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD,
bool IsIncompleteFunction) {
if (!IsIncompleteFunction)
SetLLVMFunctionAttributes(FD, getTypes().getFunctionInfo(FD), F);
-
+
// Only a few attributes are set on declarations; these may later be
// overridden by a definition.
-
+
if (FD->hasAttr<DLLImportAttr>()) {
F->setLinkage(llvm::Function::DLLImportLinkage);
- } else if (FD->hasAttr<WeakAttr>() ||
+ } else if (FD->hasAttr<WeakAttr>() ||
FD->hasAttr<WeakImportAttr>()) {
// "extern_weak" is overloaded in LLVM; we probably should have
- // separate linkage types for this.
+ // separate linkage types for this.
F->setLinkage(llvm::Function::ExternalWeakLinkage);
} else {
- F->setLinkage(llvm::Function::ExternalLinkage);
+ F->setLinkage(llvm::Function::ExternalLinkage);
}
if (const SectionAttr *SA = FD->getAttr<SectionAttr>())
@@ -410,7 +410,7 @@ void CodeGenModule::SetFunctionAttributes(const FunctionDecl *FD,
}
void CodeGenModule::AddUsedGlobal(llvm::GlobalValue *GV) {
- assert(!GV->isDeclaration() &&
+ assert(!GV->isDeclaration() &&
"Only globals with definition can force usage.");
LLVMUsed.push_back(GV);
}
@@ -422,22 +422,22 @@ void CodeGenModule::EmitLLVMUsed() {
llvm::Type *i8PTy =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
-
+
// Convert LLVMUsed to what ConstantArray needs.
std::vector<llvm::Constant*> UsedArray;
UsedArray.resize(LLVMUsed.size());
for (unsigned i = 0, e = LLVMUsed.size(); i != e; ++i) {
- UsedArray[i] =
- llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(&*LLVMUsed[i]),
+ UsedArray[i] =
+ llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(&*LLVMUsed[i]),
i8PTy);
}
-
+
if (UsedArray.empty())
return;
llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, UsedArray.size());
-
- llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(getModule(), ATy, false,
+
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(getModule(), ATy, false,
llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(ATy, UsedArray),
"llvm.used");
@@ -459,27 +459,27 @@ void CodeGenModule::EmitDeferred() {
// just ignore the deferred decl.
llvm::GlobalValue *CGRef = GlobalDeclMap[getMangledName(D)];
assert(CGRef && "Deferred decl wasn't referenced?");
-
+
if (!CGRef->isDeclaration())
continue;
-
+
// Otherwise, emit the definition and move on to the next one.
EmitGlobalDefinition(D);
}
}
-/// EmitAnnotateAttr - Generate the llvm::ConstantStruct which contains the
+/// EmitAnnotateAttr - Generate the llvm::ConstantStruct which contains the
/// annotation information for a given GlobalValue. The annotation struct is
-/// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
-/// GlobalValue being annotated. The second field is the constant string
-/// created from the AnnotateAttr's annotation. The third field is a constant
+/// {i8 *, i8 *, i8 *, i32}. The first field is a constant expression, the
+/// GlobalValue being annotated. The second field is the constant string
+/// created from the AnnotateAttr's annotation. The third field is a constant
/// string containing the name of the translation unit. The fourth field is
/// the line number in the file of the annotated value declaration.
///
/// FIXME: this does not unique the annotation string constants, as llvm-gcc
/// appears to.
///
-llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
+llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
const AnnotateAttr *AA,
unsigned LineNo) {
llvm::Module *M = &getModule();
@@ -488,7 +488,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
// which are the 2nd and 3rd elements of the global annotation structure.
const llvm::Type *SBP =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
- llvm::Constant *anno = llvm::ConstantArray::get(VMContext,
+ llvm::Constant *anno = llvm::ConstantArray::get(VMContext,
AA->getAnnotation(), true);
llvm::Constant *unit = llvm::ConstantArray::get(VMContext,
M->getModuleIdentifier(),
@@ -496,14 +496,14 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
// Get the two global values corresponding to the ConstantArrays we just
// created to hold the bytes of the strings.
- llvm::GlobalValue *annoGV =
+ llvm::GlobalValue *annoGV =
new llvm::GlobalVariable(*M, anno->getType(), false,
llvm::GlobalValue::PrivateLinkage, anno,
GV->getName());
// translation unit name string, emitted into the llvm.metadata section.
llvm::GlobalValue *unitGV =
new llvm::GlobalVariable(*M, unit->getType(), false,
- llvm::GlobalValue::PrivateLinkage, unit,
+ llvm::GlobalValue::PrivateLinkage, unit,
".str");
// Create the ConstantStruct for the global annotation.
@@ -524,12 +524,12 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Global)) {
// Constructors and destructors should never be deferred.
- if (FD->hasAttr<ConstructorAttr>() ||
+ if (FD->hasAttr<ConstructorAttr>() ||
FD->hasAttr<DestructorAttr>())
return false;
GVALinkage Linkage = GetLinkageForFunction(getContext(), FD, Features);
-
+
// static, static inline, always_inline, and extern inline functions can
// always be deferred. Normal inline functions can be deferred in C99/C++.
if (Linkage == GVA_Internal || Linkage == GVA_C99Inline ||
@@ -537,7 +537,7 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
return true;
return false;
}
-
+
const VarDecl *VD = cast<VarDecl>(Global);
assert(VD->isFileVarDecl() && "Invalid decl");
@@ -546,7 +546,7 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {
void CodeGenModule::EmitGlobal(GlobalDecl GD) {
const ValueDecl *Global = GD.getDecl();
-
+
// If this is an alias definition (which otherwise looks like a declaration)
// emit it now.
if (Global->hasAttr<AliasAttr>())
@@ -563,7 +563,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
// In C++, if this is marked "extern", defer code generation.
if (getLangOptions().CPlusPlus && !VD->getInit() &&
- (VD->getStorageClass() == VarDecl::Extern ||
+ (VD->getStorageClass() == VarDecl::Extern ||
VD->isExternC(getContext())))
return;
@@ -595,7 +595,7 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
const ValueDecl *D = GD.getDecl();
-
+
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
EmitCXXConstructor(CD, GD.getCtorType());
else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
@@ -624,16 +624,16 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
if (Entry) {
if (Entry->getType()->getElementType() == Ty)
return Entry;
-
+
// Make sure the result is of the correct type.
const llvm::Type *PTy = llvm::PointerType::getUnqual(Ty);
return llvm::ConstantExpr::getBitCast(Entry, PTy);
}
-
+
// This is the first use or definition of a mangled name. If there is a
// deferred decl with this name, remember that we need to emit it at the end
// of the file.
- llvm::DenseMap<const char*, GlobalDecl>::iterator DDI =
+ llvm::DenseMap<const char*, GlobalDecl>::iterator DDI =
DeferredDecls.find(MangledName);
if (DDI != DeferredDecls.end()) {
// Move the potentially referenced deferred decl to the DeferredDeclsToEmit
@@ -649,20 +649,20 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
// A called constructor which has no definition or declaration need be
// synthesized.
else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- const CXXRecordDecl *ClassDecl =
+ const CXXRecordDecl *ClassDecl =
cast<CXXRecordDecl>(CD->getDeclContext());
if (CD->isCopyConstructor(getContext()))
DeferredCopyConstructorToEmit(D);
else if (!ClassDecl->hasUserDeclaredConstructor())
DeferredDeclsToEmit.push_back(D);
}
- else if (isa<CXXDestructorDecl>(FD))
+ else if (isa<CXXDestructorDecl>(FD))
DeferredDestructorToEmit(D);
else if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD))
if (MD->isCopyAssignment())
DeferredCopyAssignmentToEmit(D);
}
-
+
// This function doesn't have a complete type (for example, the return
// type is an incomplete struct). Use a fake type instead, and make
// sure not to try to set attributes.
@@ -672,7 +672,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
std::vector<const llvm::Type*>(), false);
IsIncompleteFunction = true;
}
- llvm::Function *F = llvm::Function::Create(cast<llvm::FunctionType>(Ty),
+ llvm::Function *F = llvm::Function::Create(cast<llvm::FunctionType>(Ty),
llvm::Function::ExternalLinkage,
"", &getModule());
F->setName(MangledName);
@@ -685,13 +685,13 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(const char *MangledName,
/// Defer definition of copy constructor(s) which need be implicitly defined.
void CodeGenModule::DeferredCopyConstructorToEmit(GlobalDecl CopyCtorDecl) {
- const CXXConstructorDecl *CD =
+ const CXXConstructorDecl *CD =
cast<CXXConstructorDecl>(CopyCtorDecl.getDecl());
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(CD->getDeclContext());
if (ClassDecl->hasTrivialCopyConstructor() ||
ClassDecl->hasUserDeclaredCopyConstructor())
return;
-
+
// First make sure all direct base classes and virtual bases and non-static
// data mebers which need to have their copy constructors implicitly defined
// are defined. 12.8.p7
@@ -699,11 +699,11 @@ void CodeGenModule::DeferredCopyConstructorToEmit(GlobalDecl CopyCtorDecl) {
Base != ClassDecl->bases_end(); ++Base) {
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (CXXConstructorDecl *BaseCopyCtor =
+ if (CXXConstructorDecl *BaseCopyCtor =
BaseClassDecl->getCopyConstructor(Context, 0))
GetAddrOfCXXConstructor(BaseCopyCtor, Ctor_Complete);
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -715,7 +715,7 @@ void CodeGenModule::DeferredCopyConstructorToEmit(GlobalDecl CopyCtorDecl) {
continue;
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- if (CXXConstructorDecl *FieldCopyCtor =
+ if (CXXConstructorDecl *FieldCopyCtor =
FieldClassDecl->getCopyConstructor(Context, 0))
GetAddrOfCXXConstructor(FieldCopyCtor, Ctor_Complete);
}
@@ -727,11 +727,11 @@ void CodeGenModule::DeferredCopyConstructorToEmit(GlobalDecl CopyCtorDecl) {
void CodeGenModule::DeferredCopyAssignmentToEmit(GlobalDecl CopyAssignDecl) {
const CXXMethodDecl *CD = cast<CXXMethodDecl>(CopyAssignDecl.getDecl());
const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(CD->getDeclContext());
-
+
if (ClassDecl->hasTrivialCopyAssignment() ||
ClassDecl->hasUserDeclaredCopyAssignment())
return;
-
+
// First make sure all direct base classes and virtual bases and non-static
// data mebers which need to have their copy assignments implicitly defined
// are defined. 12.8.p12
@@ -745,7 +745,7 @@ void CodeGenModule::DeferredCopyAssignmentToEmit(GlobalDecl CopyAssignDecl) {
BaseClassDecl->hasConstCopyAssignment(getContext(), MD))
GetAddrOfFunction(GlobalDecl(MD), 0);
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -764,7 +764,7 @@ void CodeGenModule::DeferredCopyAssignmentToEmit(GlobalDecl CopyAssignDecl) {
GetAddrOfFunction(GlobalDecl(MD), 0);
}
}
- DeferredDeclsToEmit.push_back(CopyAssignDecl);
+ DeferredDeclsToEmit.push_back(CopyAssignDecl);
}
void CodeGenModule::DeferredDestructorToEmit(GlobalDecl DtorDecl) {
@@ -778,11 +778,11 @@ void CodeGenModule::DeferredDestructorToEmit(GlobalDecl DtorDecl) {
Base != ClassDecl->bases_end(); ++Base) {
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (const CXXDestructorDecl *BaseDtor =
+ if (const CXXDestructorDecl *BaseDtor =
BaseClassDecl->getDestructor(Context))
GetAddrOfCXXDestructor(BaseDtor, Dtor_Complete);
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -794,7 +794,7 @@ void CodeGenModule::DeferredDestructorToEmit(GlobalDecl DtorDecl) {
continue;
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- if (const CXXDestructorDecl *FieldDtor =
+ if (const CXXDestructorDecl *FieldDtor =
FieldClassDecl->getDestructor(Context))
GetAddrOfCXXDestructor(FieldDtor, Dtor_Complete);
}
@@ -839,15 +839,15 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName,
if (Entry) {
if (Entry->getType() == Ty)
return Entry;
-
+
// Make sure the result is of the correct type.
return llvm::ConstantExpr::getBitCast(Entry, Ty);
}
-
+
// This is the first use or definition of a mangled name. If there is a
// deferred decl with this name, remember that we need to emit it at the end
// of the file.
- llvm::DenseMap<const char*, GlobalDecl>::iterator DDI =
+ llvm::DenseMap<const char*, GlobalDecl>::iterator DDI =
DeferredDecls.find(MangledName);
if (DDI != DeferredDecls.end()) {
// Move the potentially referenced deferred decl to the DeferredDeclsToEmit
@@ -855,11 +855,11 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName,
DeferredDeclsToEmit.push_back(DDI->second);
DeferredDecls.erase(DDI);
}
-
- llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(getModule(), Ty->getElementType(), false,
+
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(getModule(), Ty->getElementType(), false,
llvm::GlobalValue::ExternalLinkage,
- 0, "", 0,
+ 0, "", 0,
false, Ty->getAddressSpace());
GV->setName(MangledName);
@@ -873,13 +873,13 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMGlobal(const char *MangledName,
if (D->getStorageClass() == VarDecl::PrivateExtern)
GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
- if (D->hasAttr<WeakAttr>() ||
+ if (D->hasAttr<WeakAttr>() ||
D->hasAttr<WeakImportAttr>())
GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
GV->setThreadLocal(D->isThreadSpecified());
}
-
+
return Entry = GV;
}
@@ -894,8 +894,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
QualType ASTTy = D->getType();
if (Ty == 0)
Ty = getTypes().ConvertTypeForMem(ASTTy);
-
- const llvm::PointerType *PTy =
+
+ const llvm::PointerType *PTy =
llvm::PointerType::get(Ty, ASTTy.getAddressSpace());
return GetOrCreateLLVMGlobal(getMangledName(D), PTy, D);
}
@@ -931,7 +931,7 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
llvm::Constant *Init = 0;
QualType ASTTy = D->getType();
-
+
if (D->getInit() == 0) {
// This is a tentative definition; tentative definitions are
// implicitly initialized with { 0 }.
@@ -946,7 +946,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
Init = EmitNullConstant(D->getType());
} else {
Init = EmitConstantExpr(D->getInit(), D->getType());
-
+
if (!Init) {
QualType T = D->getInit()->getType();
if (getLangOptions().CPlusPlus) {
@@ -961,7 +961,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
const llvm::Type* InitType = Init->getType();
llvm::Constant *Entry = GetAddrOfGlobalVar(D, InitType);
-
+
// Strip off a bitcast if we got one back.
if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
assert(CE->getOpcode() == llvm::Instruction::BitCast ||
@@ -969,10 +969,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
CE->getOpcode() == llvm::Instruction::GetElementPtr);
Entry = CE->getOperand(0);
}
-
+
// Entry is now either a Function or GlobalVariable.
llvm::GlobalVariable *GV = dyn_cast<llvm::GlobalVariable>(Entry);
-
+
// We have a definition after a declaration with the wrong type.
// We must make a new GlobalVariable* and update everything that used OldGV
// (a declaration or tentative definition) with the new GlobalVariable*
@@ -985,7 +985,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
if (GV == 0 ||
GV->getType()->getElementType() != InitType ||
GV->getType()->getAddressSpace() != ASTTy.getAddressSpace()) {
-
+
// Remove the old entry from GlobalDeclMap so that we'll create a new one.
GlobalDeclMap.erase(getMangledName(D));
@@ -994,7 +994,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
GV->takeName(cast<llvm::GlobalValue>(Entry));
// Replace all uses of the old global with the new global
- llvm::Constant *NewPtrForOldDecl =
+ llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(GV, Entry->getType());
Entry->replaceAllUsesWith(NewPtrForOldDecl);
@@ -1017,7 +1017,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
// members, it cannot be declared "LLVM const".
GV->setConstant(true);
}
-
+
GV->setAlignment(getContext().getDeclAlignInBytes(D));
// Set the llvm linkage type as appropriate.
@@ -1064,7 +1064,7 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
// If we're redefining a global as a function, don't transform it.
llvm::Function *OldFn = dyn_cast<llvm::Function>(Old);
if (OldFn == 0) return;
-
+
const llvm::Type *NewRetTy = NewFn->getReturnType();
llvm::SmallVector<llvm::Value*, 4> ArgList;
@@ -1074,7 +1074,7 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
unsigned OpNo = UI.getOperandNo();
llvm::CallInst *CI = dyn_cast<llvm::CallInst>(*UI++);
if (!CI || OpNo != 0) continue;
-
+
// If the return types don't match exactly, and if the call isn't dead, then
// we can't transform this call.
if (CI->getType() != NewRetTy && !CI->use_empty())
@@ -1095,7 +1095,7 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
}
if (DontTransform)
continue;
-
+
// Okay, we can transform this. Create the new call instruction and copy
// over the required information.
ArgList.append(CI->op_begin()+1, CI->op_begin()+1+ArgNo);
@@ -1118,21 +1118,21 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
const llvm::FunctionType *Ty;
const FunctionDecl *D = cast<FunctionDecl>(GD.getDecl());
-
+
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
bool isVariadic = D->getType()->getAsFunctionProtoType()->isVariadic();
-
+
Ty = getTypes().GetFunctionType(getTypes().getFunctionInfo(MD), isVariadic);
} else {
Ty = cast<llvm::FunctionType>(getTypes().ConvertType(D->getType()));
-
+
// As a special case, make sure that definitions of K&R function
// "type foo()" aren't declared as varargs (which forces the backend
// to do unnecessary work).
if (D->getType()->isFunctionNoProtoType()) {
assert(Ty->isVarArg() && "Didn't lower type as expected");
- // Due to stret, the lowered function could have arguments.
- // Just create the same type as was lowered by ConvertType
+ // Due to stret, the lowered function could have arguments.
+ // Just create the same type as was lowered by ConvertType
// but strip off the varargs bit.
std::vector<const llvm::Type*> Args(Ty->param_begin(), Ty->param_end());
Ty = llvm::FunctionType::get(Ty->getReturnType(), Args, false);
@@ -1141,17 +1141,17 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
// Get or create the prototype for the function.
llvm::Constant *Entry = GetAddrOfFunction(GD, Ty);
-
+
// Strip off a bitcast if we got one back.
if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
assert(CE->getOpcode() == llvm::Instruction::BitCast);
Entry = CE->getOperand(0);
}
-
-
+
+
if (cast<llvm::GlobalValue>(Entry)->getType()->getElementType() != Ty) {
llvm::GlobalValue *OldFn = cast<llvm::GlobalValue>(Entry);
-
+
// If the types mismatch then we have to rewrite the definition.
assert(OldFn->isDeclaration() &&
"Shouldn't replace non-declaration");
@@ -1167,7 +1167,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
GlobalDeclMap.erase(getMangledName(D));
llvm::Function *NewFn = cast<llvm::Function>(GetAddrOfFunction(GD, Ty));
NewFn->takeName(OldFn);
-
+
// If this is an implementation of a function without a prototype, try to
// replace any existing uses of the function (which may be calls) with uses
// of the new function
@@ -1175,27 +1175,27 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
ReplaceUsesOfNonProtoTypeWithRealFunction(OldFn, NewFn);
OldFn->removeDeadConstantUsers();
}
-
+
// Replace uses of F with the Function we will endow with a body.
if (!Entry->use_empty()) {
- llvm::Constant *NewPtrForOldDecl =
+ llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(NewFn, Entry->getType());
Entry->replaceAllUsesWith(NewPtrForOldDecl);
}
-
+
// Ok, delete the old function now, which is dead.
OldFn->eraseFromParent();
-
+
Entry = NewFn;
}
-
+
llvm::Function *Fn = cast<llvm::Function>(Entry);
CodeGenFunction(*this).GenerateCode(D, Fn);
SetFunctionDefinitionAttributes(D, Fn);
SetLLVMFunctionAttributesForDefinition(D, Fn);
-
+
if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>())
AddGlobalCtor(Fn, CA->getPriority());
if (const DestructorAttr *DA = D->getAttr<DestructorAttr>())
@@ -1207,7 +1207,7 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
assert(AA && "Not an alias?");
const llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
-
+
// Unique the name through the identifier table.
const char *AliaseeName = AA->getAliasee().c_str();
AliaseeName = getContext().Idents.get(AliaseeName).getName();
@@ -1222,22 +1222,22 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
llvm::PointerType::getUnqual(DeclTy), 0);
// Create the new alias itself, but don't set a name yet.
- llvm::GlobalValue *GA =
+ llvm::GlobalValue *GA =
new llvm::GlobalAlias(Aliasee->getType(),
llvm::Function::ExternalLinkage,
"", Aliasee, &getModule());
-
+
// See if there is already something with the alias' name in the module.
const char *MangledName = getMangledName(D);
llvm::GlobalValue *&Entry = GlobalDeclMap[MangledName];
-
+
if (Entry && !Entry->isDeclaration()) {
// If there is a definition in the module, then it wins over the alias.
// This is dubious, but allow it to be safe. Just ignore the alias.
GA->eraseFromParent();
return;
}
-
+
if (Entry) {
// If there is a declaration in the module, then we had an extern followed
// by the alias, as in:
@@ -1246,12 +1246,12 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
// int test6() __attribute__((alias("test7")));
//
// Remove it and replace uses of it with the alias.
-
+
Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GA,
Entry->getType()));
Entry->eraseFromParent();
}
-
+
// Now we know that there is no conflict, set the name.
Entry = GA;
GA->setName(MangledName);
@@ -1267,7 +1267,7 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
} else {
GA->setLinkage(llvm::Function::DLLExportLinkage);
}
- } else if (D->hasAttr<WeakAttr>() ||
+ } else if (D->hasAttr<WeakAttr>() ||
D->hasAttr<WeakImportAttr>()) {
GA->setLinkage(llvm::Function::WeakAnyLinkage);
}
@@ -1279,20 +1279,20 @@ void CodeGenModule::EmitAliasDefinition(const ValueDecl *D) {
/// "__builtin_fabsf", return a Function* for "fabsf".
llvm::Value *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) {
assert((Context.BuiltinInfo.isLibFunction(BuiltinID) ||
- Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) &&
+ Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) &&
"isn't a lib fn");
-
+
// Get the name, skip over the __builtin_ prefix (if necessary).
const char *Name = Context.BuiltinInfo.GetName(BuiltinID);
if (Context.BuiltinInfo.isLibFunction(BuiltinID))
Name += 10;
-
+
// Get the type for the builtin.
ASTContext::GetBuiltinTypeError Error;
QualType Type = Context.GetBuiltinType(BuiltinID, Error);
assert(Error == ASTContext::GE_None && "Can't get builtin type");
- const llvm::FunctionType *Ty =
+ const llvm::FunctionType *Ty =
cast<llvm::FunctionType>(getTypes().ConvertType(Type));
// Unique the name through the identifier table.
@@ -1336,7 +1336,7 @@ GetConstantCFStringEntry(llvm::StringMap<llvm::Constant*> &Map,
// Check for simple case.
if (!Literal->containsNonAsciiOrNull()) {
StringLength = NumBytes;
- return Map.GetOrCreateValue(llvm::StringRef(Literal->getStrData(),
+ return Map.GetOrCreateValue(llvm::StringRef(Literal->getStrData(),
StringLength));
}
@@ -1344,18 +1344,18 @@ GetConstantCFStringEntry(llvm::StringMap<llvm::Constant*> &Map,
llvm::SmallVector<UTF16, 128> ToBuf(NumBytes);
const UTF8 *FromPtr = (UTF8 *)Literal->getStrData();
UTF16 *ToPtr = &ToBuf[0];
-
- ConversionResult Result = ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes,
+
+ ConversionResult Result = ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes,
&ToPtr, ToPtr + NumBytes,
strictConversion);
-
+
// Check for conversion failure.
if (Result != conversionOK) {
// FIXME: Have Sema::CheckObjCString() validate the UTF-8 string and remove
// this duplicate code.
assert(Result == sourceIllegal && "UTF-8 to UTF-16 conversion failed");
StringLength = NumBytes;
- return Map.GetOrCreateValue(llvm::StringRef(Literal->getStrData(),
+ return Map.GetOrCreateValue(llvm::StringRef(Literal->getStrData(),
StringLength));
}
@@ -1391,41 +1391,41 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
unsigned StringLength = 0;
bool isUTF16 = false;
llvm::StringMapEntry<llvm::Constant*> &Entry =
- GetConstantCFStringEntry(CFConstantStringMap, Literal,
+ GetConstantCFStringEntry(CFConstantStringMap, Literal,
getTargetData().isLittleEndian(),
isUTF16, StringLength);
-
+
if (llvm::Constant *C = Entry.getValue())
return C;
-
+
llvm::Constant *Zero =
llvm::Constant::getNullValue(llvm::Type::getInt32Ty(VMContext));
llvm::Constant *Zeros[] = { Zero, Zero };
-
+
// If we don't already have it, get __CFConstantStringClassReference.
if (!CFConstantStringClassRef) {
const llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = llvm::ArrayType::get(Ty, 0);
- llvm::Constant *GV = CreateRuntimeVariable(Ty,
+ llvm::Constant *GV = CreateRuntimeVariable(Ty,
"__CFConstantStringClassReference");
// Decay array -> ptr
CFConstantStringClassRef =
llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2);
}
-
+
QualType CFTy = getContext().getCFConstantStringType();
- const llvm::StructType *STy =
+ const llvm::StructType *STy =
cast<llvm::StructType>(getTypes().ConvertType(CFTy));
std::vector<llvm::Constant*> Fields(4);
// Class pointer.
Fields[0] = CFConstantStringClassRef;
-
+
// Flags.
const llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy);
- Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) :
+ Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) :
llvm::ConstantInt::get(Ty, 0x07C8);
// String pointer.
@@ -1449,30 +1449,30 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
// are following gcc here.
isConstant = true;
}
- llvm::GlobalVariable *GV =
- new llvm::GlobalVariable(getModule(), C->getType(), isConstant,
+ llvm::GlobalVariable *GV =
+ new llvm::GlobalVariable(getModule(), C->getType(), isConstant,
Linkage, C, Prefix);
if (Sect)
GV->setSection(Sect);
if (isUTF16) {
unsigned Align = getContext().getTypeAlign(getContext().ShortTy)/8;
- GV->setAlignment(Align);
+ GV->setAlignment(Align);
}
Fields[2] = llvm::ConstantExpr::getGetElementPtr(GV, Zeros, 2);
// String length.
Ty = getTypes().ConvertType(getContext().LongTy);
Fields[3] = llvm::ConstantInt::get(Ty, StringLength);
-
+
// The struct.
C = llvm::ConstantStruct::get(STy, Fields);
- GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
- llvm::GlobalVariable::PrivateLinkage, C,
+ GV = new llvm::GlobalVariable(getModule(), C->getType(), true,
+ llvm::GlobalVariable::PrivateLinkage, C,
"_unnamed_cfstring_");
if (const char *Sect = getContext().Target.getCFStringSection())
GV->setSection(Sect);
Entry.setValue(GV);
-
+
return GV;
}
@@ -1485,16 +1485,16 @@ std::string CodeGenModule::GetStringForStringLiteral(const StringLiteral *E) {
const ConstantArrayType *CAT =
getContext().getAsConstantArrayType(E->getType());
assert(CAT && "String isn't pointer or array!");
-
+
// Resize the string to the right size.
std::string Str(StrData, StrData+Len);
uint64_t RealLen = CAT->getSize().getZExtValue();
-
+
if (E->isWide())
RealLen *= getContext().Target.getWCharWidth()/8;
-
+
Str.resize(RealLen, '\0');
-
+
return Str;
}
@@ -1518,16 +1518,16 @@ CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) {
/// GenerateWritableString -- Creates storage for a string literal.
-static llvm::Constant *GenerateStringLiteral(const std::string &str,
+static llvm::Constant *GenerateStringLiteral(const std::string &str,
bool constant,
CodeGenModule &CGM,
const char *GlobalName) {
// Create Constant for this string literal. Don't add a '\0'.
llvm::Constant *C =
llvm::ConstantArray::get(CGM.getLLVMContext(), str, false);
-
+
// Create a global variable for this string
- return new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
+ return new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
llvm::GlobalValue::PrivateLinkage,
C, GlobalName);
}
@@ -1551,8 +1551,8 @@ llvm::Constant *CodeGenModule::GetAddrOfConstantString(const std::string &str,
// Don't share any string literals if strings aren't constant.
if (!IsConstant)
return GenerateStringLiteral(str, false, *this, GlobalName);
-
- llvm::StringMapEntry<llvm::Constant *> &Entry =
+
+ llvm::StringMapEntry<llvm::Constant *> &Entry =
ConstantStringMap.GetOrCreateValue(&str[0], &str[str.length()]);
if (Entry.getValue())
@@ -1574,12 +1574,12 @@ llvm::Constant *CodeGenModule::GetAddrOfConstantCString(const std::string &str,
/// EmitObjCPropertyImplementations - Emit information for synthesized
/// properties for an implementation.
-void CodeGenModule::EmitObjCPropertyImplementations(const
+void CodeGenModule::EmitObjCPropertyImplementations(const
ObjCImplementationDecl *D) {
- for (ObjCImplementationDecl::propimpl_iterator
+ for (ObjCImplementationDecl::propimpl_iterator
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
ObjCPropertyImplDecl *PID = *i;
-
+
// Dynamic is just for type-checking.
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
ObjCPropertyDecl *PD = PID->getPropertyDecl();
@@ -1631,7 +1631,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
// Ignore dependent declarations.
if (D->getDeclContext() && D->getDeclContext()->isDependentContext())
return;
-
+
switch (D->getKind()) {
case Decl::CXXConversion:
case Decl::CXXMethod:
@@ -1639,9 +1639,9 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
// Skip function templates
if (cast<FunctionDecl>(D)->getDescribedFunctionTemplate())
return;
-
+
// Fall through
-
+
case Decl::Var:
EmitGlobal(GlobalDecl(cast<ValueDecl>(D)));
break;
@@ -1668,7 +1668,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
break;
// Objective-C Decls
-
+
// Forward declarations, no (immediate) code generation.
case Decl::ObjCClass:
case Decl::ObjCForwardProtocol:
@@ -1691,7 +1691,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
EmitObjCPropertyImplementations(OMD);
Runtime->GenerateClass(OMD);
break;
- }
+ }
case Decl::ObjCMethod: {
ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(D);
// If this is not a prototype, emit the body.
@@ -1699,7 +1699,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
CodeGenFunction(*this).GenerateObjCMethod(OMD);
break;
}
- case Decl::ObjCCompatibleAlias:
+ case Decl::ObjCCompatibleAlias:
// compatibility-alias is a directive and has no code gen.
break;
@@ -1711,7 +1711,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
FileScopeAsmDecl *AD = cast<FileScopeAsmDecl>(D);
std::string AsmString(AD->getAsmString()->getStrData(),
AD->getAsmString()->getByteLength());
-
+
const std::string &S = getModule().getModuleInlineAsm();
if (S.empty())
getModule().setModuleInlineAsm(AsmString);
@@ -1719,8 +1719,8 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
getModule().setModuleInlineAsm(S + '\n' + AsmString);
break;
}
-
- default:
+
+ default:
// Make sure we handled everything we should, every other kind is a
// non-top-level decl. FIXME: Would be nice to have an isTopLevelDeclKind
// function. Need to recode Decl::Kind to do that easily.
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h
index 2aa97de2b0..607f2a172c 100644
--- a/lib/CodeGen/CodeGenModule.h
+++ b/lib/CodeGen/CodeGenModule.h
@@ -73,32 +73,32 @@ namespace CodeGen {
// a regular VarDecl or a FunctionDecl.
class GlobalDecl {
llvm::PointerIntPair<const ValueDecl*, 2> Value;
-
+
public:
GlobalDecl() {}
-
+
explicit GlobalDecl(const ValueDecl *VD) : Value(VD, 0) {
assert(!isa<CXXConstructorDecl>(VD) && "Use other ctor with ctor decls!");
assert(!isa<CXXDestructorDecl>(VD) && "Use other ctor with dtor decls!");
}
- GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
+ GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type)
: Value(D, Type) {}
GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type)
: Value(D, Type) {}
-
+
const ValueDecl *getDecl() const { return Value.getPointer(); }
-
+
CXXCtorType getCtorType() const {
assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!");
return static_cast<CXXCtorType>(Value.getInt());
}
-
+
CXXDtorType getDtorType() const {
assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!");
return static_cast<CXXDtorType>(Value.getInt());
}
};
-
+
/// CodeGenModule - This class organizes the cross-function state that is used
/// while generating LLVM code.
class CodeGenModule : public BlockModule {
@@ -176,11 +176,11 @@ class CodeGenModule : public BlockModule {
/// CXXGlobalInits - Variables with global initializers that need to run
/// before main.
std::vector<const VarDecl*> CXXGlobalInits;
-
+
/// CFConstantStringClassRef - Cached reference to the class for constant
/// strings. This value has type int * but is actually an Obj-C class pointer.
llvm::Constant *CFConstantStringClassRef;
-
+
llvm::LLVMContext &VMContext;
public:
CodeGenModule(ASTContext &C, const CompileOptions &CompileOpts,
@@ -255,7 +255,7 @@ public:
/// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
/// array for the given ObjCEncodeExpr node.
llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
-
+
/// GetAddrOfConstantString - Returns a pointer to a character array
/// containing the literal. This contents are exactly that of the given
/// string, i.e. it will not be null terminated automatically; see
@@ -280,14 +280,14 @@ public:
/// GetAddrOfCXXConstructor - Return the address of the constructor of the
/// given type.
- llvm::Function *GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
+ llvm::Function *GetAddrOfCXXConstructor(const CXXConstructorDecl *D,
CXXCtorType Type);
/// GetAddrOfCXXDestructor - Return the address of the constructor of the
/// given type.
- llvm::Function *GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
+ llvm::Function *GetAddrOfCXXDestructor(const CXXDestructorDecl *D,
CXXDtorType Type);
-
+
/// getBuiltinLibFunction - Given a builtin id for a function like
/// "__builtin_fabsf", return a Function* for "fabsf".
llvm::Value *getBuiltinLibFunction(unsigned BuiltinID);
@@ -378,9 +378,9 @@ public:
const char *getMangledName(const GlobalDecl &D);
const char *getMangledName(const NamedDecl *ND);
- const char *getMangledCXXCtorName(const CXXConstructorDecl *D,
+ const char *getMangledCXXCtorName(const CXXConstructorDecl *D,
CXXCtorType Type);
- const char *getMangledCXXDtorName(const CXXDestructorDecl *D,
+ const char *getMangledCXXDtorName(const CXXDestructorDecl *D,
CXXDtorType Type);
void EmitTentativeDefinition(const VarDecl *D);
@@ -392,12 +392,12 @@ public:
GVA_StrongExternal,
GVA_TemplateInstantiation
};
-
+
private:
/// UniqueMangledName - Unique a name by (if necessary) inserting it into the
/// MangledNames string map.
const char *UniqueMangledName(const char *NameStart, const char *NameEnd);
-
+
llvm::Constant *GetOrCreateLLVMFunction(const char *MangledName,
const llvm::Type *Ty,
GlobalDecl D);
@@ -407,7 +407,7 @@ private:
void DeferredCopyConstructorToEmit(GlobalDecl D);
void DeferredCopyAssignmentToEmit(GlobalDecl D);
void DeferredDestructorToEmit(GlobalDecl D);
-
+
/// SetCommonAttributes - Set attributes which are common to any
/// form of a global definition (alias, Objective-C method,
/// function, global variable).
@@ -416,9 +416,9 @@ private:
void SetCommonAttributes(const Decl *D, llvm::GlobalValue *GV);
/// SetFunctionDefinitionAttributes - Set attributes for a global definition.
- void SetFunctionDefinitionAttributes(const FunctionDecl *D,
+ void SetFunctionDefinitionAttributes(const FunctionDecl *D,
llvm::GlobalValue *GV);
-
+
/// SetFunctionAttributes - Set function attributes for a function
/// declaration.
void SetFunctionAttributes(const FunctionDecl *FD,
@@ -437,29 +437,29 @@ private:
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
// C++ related functions.
-
+
void EmitNamespace(const NamespaceDecl *D);
void EmitLinkageSpec(const LinkageSpecDecl *D);
/// EmitCXXConstructors - Emit constructors (base, complete) from a
/// C++ constructor Decl.
void EmitCXXConstructors(const CXXConstructorDecl *D);
-
+
/// EmitCXXConstructor - Emit a single constructor with the given type from
/// a C++ constructor Decl.
void EmitCXXConstructor(const CXXConstructorDecl *D, CXXCtorType Type);
-
- /// EmitCXXDestructors - Emit destructors (base, complete) from a
+
+ /// EmitCXXDestructors - Emit destructors (base, complete) from a
/// C++ destructor Decl.
void EmitCXXDestructors(const CXXDestructorDecl *D);
-
+
/// EmitCXXDestructor - Emit a single destructor with the given type from
/// a C++ destructor Decl.
void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type);
-
+
/// EmitCXXGlobalInitFunc - Emit a function that initializes C++ globals.
void EmitCXXGlobalInitFunc();
-
+
// FIXME: Hardcoding priority here is gross.
void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535);
void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535);
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 48f8192094..94db836665 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This is the code that handles AST -> LLVM type lowering.
+// This is the code that handles AST -> LLVM type lowering.
//
//===----------------------------------------------------------------------===//
@@ -34,8 +34,8 @@ CodeGenTypes::CodeGenTypes(ASTContext &Ctx, llvm::Module& M,
}
CodeGenTypes::~CodeGenTypes() {
- for(llvm::DenseMap<const Type *, CGRecordLayout *>::iterator
- I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
+ for (llvm::DenseMap<const Type *, CGRecordLayout *>::iterator
+ I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
I != E; ++I)
delete I->second;
CGRecordLayouts.clear();
@@ -65,7 +65,7 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
const llvm::Type *CodeGenTypes::ConvertTypeRecursive(QualType T) {
T = Context.getCanonicalType(T);
-
+
// See if type is already cached.
llvm::DenseMap<Type *, llvm::PATypeHolder>::iterator
I = TypeCache.find(T.getTypePtr());
@@ -75,7 +75,7 @@ const llvm::Type *CodeGenTypes::ConvertTypeRecursive(QualType T) {
return I->second.get();
const llvm::Type *ResultType = ConvertNewType(T);
- TypeCache.insert(std::make_pair(T.getTypePtr(),
+ TypeCache.insert(std::make_pair(T.getTypePtr(),
llvm::PATypeHolder(ResultType)));
return ResultType;
}
@@ -94,15 +94,15 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMemRecursive(QualType T) {
/// memory representation is usually i8 or i32, depending on the target.
const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) {
const llvm::Type *R = ConvertType(T);
-
+
// If this is a non-bool type, don't map it.
if (R != llvm::Type::getInt1Ty(getLLVMContext()))
return R;
-
+
// Otherwise, return an integer of the target-specified size.
return llvm::IntegerType::get(getLLVMContext(),
(unsigned)Context.getTypeSize(T));
-
+
}
// Code to verify a given function type is complete, i.e. the return type
@@ -124,15 +124,15 @@ static const TagType *VerifyFuncTypeComplete(const Type* T) {
/// replace the 'opaque' type we previously made for it if applicable.
void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
const Type *Key = Context.getTagDeclType(TD).getTypePtr();
- llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
+ llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
TagDeclTypes.find(Key);
if (TDTI == TagDeclTypes.end()) return;
-
+
// Remember the opaque LLVM type for this tagdecl.
llvm::PATypeHolder OpaqueHolder = TDTI->second;
assert(isa<llvm::OpaqueType>(OpaqueHolder.get()) &&
"Updating compilation of an already non-opaque type?");
-
+
// Remove it from TagDeclTypes so that it will be regenerated.
TagDeclTypes.erase(TDTI);
@@ -163,7 +163,7 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
}
}
-static const llvm::Type* getTypeForFormat(llvm::LLVMContext &VMContext,
+static const llvm::Type* getTypeForFormat(llvm::LLVMContext &VMContext,
const llvm::fltSemantics &format) {
if (&format == &llvm::APFloat::IEEEsingle)
return llvm::Type::getFloatTy(VMContext);
@@ -181,7 +181,7 @@ static const llvm::Type* getTypeForFormat(llvm::LLVMContext &VMContext,
const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
const clang::Type &Ty = *Context.getCanonicalType(T);
-
+
switch (Ty.getTypeClass()) {
#define TYPE(Class, Base)
#define ABSTRACT_TYPE(Class, Base)
@@ -204,7 +204,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case BuiltinType::Bool:
// Note that we always return bool as i1 for use as a scalar type.
return llvm::Type::getInt1Ty(getLLVMContext());
-
+
case BuiltinType::Char_S:
case BuiltinType::Char_U:
case BuiltinType::SChar:
@@ -222,13 +222,13 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case BuiltinType::Char32:
return llvm::IntegerType::get(getLLVMContext(),
static_cast<unsigned>(Context.getTypeSize(T)));
-
+
case BuiltinType::Float:
case BuiltinType::Double:
case BuiltinType::LongDouble:
- return getTypeForFormat(getLLVMContext(),
+ return getTypeForFormat(getLLVMContext(),
Context.getFloatTypeSemantics(T));
-
+
case BuiltinType::UInt128:
case BuiltinType::Int128:
return llvm::IntegerType::get(getLLVMContext(), 128);
@@ -236,10 +236,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
break;
}
case Type::FixedWidthInt:
- return llvm::IntegerType::get(getLLVMContext(),
+ return llvm::IntegerType::get(getLLVMContext(),
cast<FixedWidthIntType>(T)->getWidth());
case Type::Complex: {
- const llvm::Type *EltTy =
+ const llvm::Type *EltTy =
ConvertTypeRecursive(cast<ComplexType>(Ty).getElementType());
return llvm::StructType::get(TheModule.getContext(), EltTy, EltTy, NULL);
}
@@ -258,7 +258,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
PointersToResolve.push_back(std::make_pair(ETy, PointeeType));
return llvm::PointerType::get(PointeeType, ETy.getAddressSpace());
}
-
+
case Type::VariableArray: {
const VariableArrayType &A = cast<VariableArrayType>(Ty);
assert(A.getIndexTypeQualifier() == 0 &&
@@ -305,7 +305,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
const FunctionNoProtoType *FNPT = cast<FunctionNoProtoType>(&Ty);
return GetFunctionType(getFunctionInfo(FNPT), true);
}
-
+
case Type::ExtQual:
return
ConvertTypeRecursive(QualType(cast<ExtQualType>(Ty).getBaseType(), 0));
@@ -319,12 +319,12 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
T = llvm::OpaqueType::get(getLLVMContext());
return T;
}
-
+
case Type::ObjCObjectPointer: {
// Protocol qualifications do not influence the LLVM type, we just return a
// pointer to the underlying interface type. We don't need to worry about
// recursive conversion.
- const llvm::Type *T =
+ const llvm::Type *T =
ConvertTypeRecursive(cast<ObjCObjectPointerType>(Ty).getPointeeType());
return llvm::PointerType::getUnqual(T);
}
@@ -333,10 +333,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case Type::Enum: {
const TagDecl *TD = cast<TagType>(Ty).getDecl();
const llvm::Type *Res = ConvertTagDeclType(TD);
-
+
std::string TypeName(TD->getKindName());
TypeName += '.';
-
+
// Name the codegen type after the typedef name
// if there is no tag type name available
if (TD->getIdentifier())
@@ -345,8 +345,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
TypeName += TdT->getDecl()->getNameAsString();
else
TypeName += "anon";
-
- TheModule.addTypeName(TypeName, Res);
+
+ TheModule.addTypeName(TypeName, Res);
return Res;
}
@@ -365,7 +365,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
QualType ETy = cast<MemberPointerType>(Ty).getPointeeType();
if (ETy->isFunctionType()) {
return llvm::StructType::get(TheModule.getContext(),
- ConvertType(Context.getPointerDiffType()),
+ ConvertType(Context.getPointerDiffType()),
ConvertType(Context.getPointerDiffType()),
NULL);
} else
@@ -375,7 +375,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case Type::TemplateSpecialization:
assert(false && "Dependent types can't get here");
}
-
+
// FIXME: implement.
return llvm::OpaqueType::get(getLLVMContext());
}
@@ -395,18 +395,18 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
}
}
}
-
+
// TagDecl's are not necessarily unique, instead use the (clang)
// type connected to the decl.
- const Type *Key =
+ const Type *Key =
Context.getTagDeclType(TD).getTypePtr();
- llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
+ llvm::DenseMap<const Type*, llvm::PATypeHolder>::iterator TDTI =
TagDeclTypes.find(Key);
-
+
// If we've already compiled this tag type, use the previous definition.
if (TDTI != TagDeclTypes.end())
return TDTI->second;
-
+
// If this is still a forward definition, just define an opaque type to use
// for this tagged decl.
if (!TD->isDefinition()) {
@@ -414,14 +414,14 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
TagDeclTypes.insert(std::make_pair(Key, ResultType));
return ResultType;
}
-
+
// Okay, this is a definition of a type. Compile the implementation now.
-
+
if (TD->isEnum()) {
// Don't bother storing enums in TagDeclTypes.
return ConvertTypeRecursive(cast<EnumDecl>(TD)->getIntegerType());
}
-
+
// This decl could well be recursive. In this case, insert an opaque
// definition of this type, which the recursive uses will get. We will then
// refine this opaque version later.
@@ -430,30 +430,30 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
// type. This will later be refined to the actual type.
llvm::PATypeHolder ResultHolder = llvm::OpaqueType::get(getLLVMContext());
TagDeclTypes.insert(std::make_pair(Key, ResultHolder));
-
+
const llvm::Type *ResultType;
const RecordDecl *RD = cast<const RecordDecl>(TD);
// Layout fields.
- CGRecordLayout *Layout =
+ CGRecordLayout *Layout =
CGRecordLayoutBuilder::ComputeLayout(*this, RD);
-
+
CGRecordLayouts[Key] = Layout;
ResultType = Layout->getLLVMType();
-
+
// Refine our Opaque type to ResultType. This can invalidate ResultType, so
// make sure to read the result out of the holder.
cast<llvm::OpaqueType>(ResultHolder.get())
->refineAbstractTypeTo(ResultType);
-
+
return ResultHolder.get();
-}
+}
/// getLLVMFieldNo - Return llvm::StructType element number
/// that corresponds to the field FD.
unsigned CodeGenTypes::getLLVMFieldNo(const FieldDecl *FD) {
assert(!FD->isBitField() && "Don't use getLLVMFieldNo on bit fields!");
-
+
llvm::DenseMap<const FieldDecl*, unsigned>::iterator I = FieldInfo.find(FD);
assert (I != FieldInfo.end() && "Unable to find field info");
return I->second;
@@ -481,11 +481,11 @@ void CodeGenTypes::addBitFieldInfo(const FieldDecl *FD, unsigned FieldNo,
/// getCGRecordLayout - Return record layout info for the given llvm::Type.
const CGRecordLayout &
CodeGenTypes::getCGRecordLayout(const TagDecl *TD) const {
- const Type *Key =
+ const Type *Key =
Context.getTagDeclType(TD).getTypePtr();
llvm::DenseMap<const Type*, CGRecordLayout *>::iterator I
= CGRecordLayouts.find(Key);
- assert (I != CGRecordLayouts.end()
+ assert (I != CGRecordLayouts.end()
&& "Unable to find record layout information for type");
return *I->second;
}
diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h
index f8df1b429b..0e73d481cd 100644
--- a/lib/CodeGen/CodeGenTypes.h
+++ b/lib/CodeGen/CodeGenTypes.h
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This is the code that handles AST -> LLVM type lowering.
+// This is the code that handles AST -> LLVM type lowering.
//
//===----------------------------------------------------------------------===//
@@ -49,20 +49,20 @@ namespace clang {
namespace CodeGen {
class CodeGenTypes;
- /// CGRecordLayout - This class handles struct and union layout info while
+ /// CGRecordLayout - This class handles struct and union layout info while
/// lowering AST types to LLVM types.
class CGRecordLayout {
CGRecordLayout(); // DO NOT IMPLEMENT
-
+
/// LLVMType - The LLVMType corresponding to this record layout.
const llvm::Type *LLVMType;
-
+
/// ContainsMemberPointer - Whether one of the fields in this record layout
/// is a member pointer, or a struct that contains a member pointer.
bool ContainsMemberPointer;
-
+
public:
- CGRecordLayout(const llvm::Type *T, bool ContainsMemberPointer)
+ CGRecordLayout(const llvm::Type *T, bool ContainsMemberPointer)
: LLVMType(T), ContainsMemberPointer(ContainsMemberPointer) { }
/// getLLVMType - Return llvm type associated with this record.
@@ -73,9 +73,9 @@ namespace CodeGen {
bool containsMemberPointer() const {
return ContainsMemberPointer;
}
-
+
};
-
+
/// CodeGenTypes - This class organizes the cross-module state that is used
/// while lowering AST types to LLVM types.
class CodeGenTypes {
@@ -84,7 +84,7 @@ class CodeGenTypes {
llvm::Module& TheModule;
const llvm::TargetData& TheTargetData;
mutable const ABIInfo* TheABIInfo;
-
+
llvm::SmallVector<std::pair<QualType,
llvm::OpaqueType *>, 8> PointersToResolve;
@@ -98,9 +98,9 @@ class CodeGenTypes {
/// types are never refined.
llvm::DenseMap<const ObjCInterfaceType*, const llvm::Type *> InterfaceTypes;
- /// CGRecordLayouts - This maps llvm struct type with corresponding
- /// record layout info.
- /// FIXME : If CGRecordLayout is less than 16 bytes then use
+ /// CGRecordLayouts - This maps llvm struct type with corresponding
+ /// record layout info.
+ /// FIXME : If CGRecordLayout is less than 16 bytes then use
/// inline it in the map.
llvm::DenseMap<const Type*, CGRecordLayout *> CGRecordLayouts;
@@ -113,8 +113,8 @@ class CodeGenTypes {
public:
struct BitFieldInfo {
- BitFieldInfo(unsigned FieldNo,
- unsigned Start,
+ BitFieldInfo(unsigned FieldNo,
+ unsigned Start,
unsigned Size)
: FieldNo(FieldNo), Start(Start), Size(Size) {}
@@ -128,7 +128,7 @@ private:
/// TypeCache - This map keeps cache of llvm::Types (through PATypeHolder)
/// and maps llvm::Types to corresponding clang::Type. llvm::PATypeHolder is
- /// used instead of llvm::Type because it allows us to bypass potential
+ /// used instead of llvm::Type because it allows us to bypass potential
/// dangling type pointers due to type refinement on llvm side.
llvm::DenseMap<Type *, llvm::PATypeHolder> TypeCache;
@@ -140,17 +140,17 @@ private:
public:
CodeGenTypes(ASTContext &Ctx, llvm::Module &M, const llvm::TargetData &TD);
~CodeGenTypes();
-
+
const llvm::TargetData &getTargetData() const { return TheTargetData; }
TargetInfo &getTarget() const { return Target; }
ASTContext &getContext() const { return Context; }
const ABIInfo &getABIInfo() const;
llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); }
- /// ConvertType - Convert type T into a llvm::Type.
+ /// ConvertType - Convert type T into a llvm::Type.
const llvm::Type *ConvertType(QualType T);
const llvm::Type *ConvertTypeRecursive(QualType T);
-
+
/// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from
/// ConvertType in that it is used to convert to the memory representation for
/// a type. For example, the scalar representation for _Bool is i1, but the
@@ -161,20 +161,20 @@ public:
/// GetFunctionType - Get the LLVM function type for \arg Info.
const llvm::FunctionType *GetFunctionType(const CGFunctionInfo &Info,
bool IsVariadic);
-
+
const CGRecordLayout &getCGRecordLayout(const TagDecl*) const;
-
+
/// getLLVMFieldNo - Return llvm::StructType element number
/// that corresponds to the field FD.
unsigned getLLVMFieldNo(const FieldDecl *FD);
-
+
/// UpdateCompletedType - When we find the full definition for a TagDecl,
/// replace the 'opaque' type we previously made for it if applicable.
void UpdateCompletedType(const TagDecl *TD);
/// getFunctionInfo - Get the CGFunctionInfo for this function signature.
- const CGFunctionInfo &getFunctionInfo(QualType RetTy,
- const llvm::SmallVector<QualType,16>
+ const CGFunctionInfo &getFunctionInfo(QualType RetTy,
+ const llvm::SmallVector<QualType,16>
&ArgTys);
const CGFunctionInfo &getFunctionInfo(const FunctionNoProtoType *FTNP);
@@ -182,12 +182,12 @@ public:
const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
const CGFunctionInfo &getFunctionInfo(const CXXMethodDecl *MD);
const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);
- const CGFunctionInfo &getFunctionInfo(QualType ResTy,
+ const CGFunctionInfo &getFunctionInfo(QualType ResTy,
const CallArgList &Args);
public:
- const CGFunctionInfo &getFunctionInfo(QualType ResTy,
+ const CGFunctionInfo &getFunctionInfo(QualType ResTy,
const FunctionArgList &Args);
-
+
public: // These are internal details of CGT that shouldn't be used externally.
/// addFieldInfo - Assign field number to field FD.
void addFieldInfo(const FieldDecl *FD, unsigned FieldNo);
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 04bd52b8d4..f9495b81b3 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -34,7 +34,7 @@ namespace {
const CXXMethodDecl *Structor;
unsigned StructorType;
CXXCtorType CtorType;
-
+
public:
CXXNameMangler(ASTContext &C, llvm::raw_ostream &os)
: Context(C), Out(os), Structor(0), StructorType(0) { }
@@ -46,7 +46,7 @@ namespace {
int64_t nv_t, int64_t v_t,
int64_t nv_r, int64_t v_r);
void mangleGuardVariable(const VarDecl *D);
-
+
void mangleCXXVtable(QualType Type);
void mangleCXXRtti(QualType Type);
void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type);
@@ -54,7 +54,7 @@ namespace {
private:
bool mangleFunctionDecl(const FunctionDecl *FD);
-
+
void mangleFunctionEncoding(const FunctionDecl *FD);
void mangleName(const NamedDecl *ND);
void mangleUnqualifiedName(const NamedDecl *ND);
@@ -78,19 +78,19 @@ namespace {
void mangleExpression(Expr *E);
void mangleCXXCtorType(CXXCtorType T);
void mangleCXXDtorType(CXXDtorType T);
-
+
void mangleTemplateArgumentList(const TemplateArgumentList &L);
void mangleTemplateArgument(const TemplateArgument &A);
};
}
static bool isInCLinkageSpecification(const Decl *D) {
- for (const DeclContext *DC = D->getDeclContext();
+ for (const DeclContext *DC = D->getDeclContext();
!DC->isTranslationUnit(); DC = DC->getParent()) {
- if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC))
+ if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC))
return Linkage->getLanguage() == LinkageSpecDecl::lang_c;
}
-
+
return false;
}
@@ -101,12 +101,12 @@ bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) {
// C functions are not mangled, and "main" is never mangled.
if (!Context.getLangOptions().CPlusPlus || FD->isMain(Context))
return false;
-
- // No mangling in an "implicit extern C" header.
+
+ // No mangling in an "implicit extern C" header.
if (FD->getLocation().isValid() &&
Context.getSourceManager().isInExternCSystemHeader(FD->getLocation()))
return false;
-
+
// No name mangling in a C linkage specification.
if (isInCLinkageSpecification(FD))
return false;
@@ -127,7 +127,7 @@ bool CXXNameMangler::mangle(const NamedDecl *D) {
Out << ALA->getLabel();
return true;
}
-
+
// <mangled-name> ::= _Z <encoding>
// ::= <data name>
// ::= <special-name>
@@ -135,36 +135,36 @@ bool CXXNameMangler::mangle(const NamedDecl *D) {
// FIXME: Actually use a visitor to decode these?
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
return mangleFunctionDecl(FD);
-
+
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (!Context.getLangOptions().CPlusPlus ||
isInCLinkageSpecification(D) ||
D->getDeclContext()->isTranslationUnit())
return false;
-
+
Out << "_Z";
mangleName(VD);
return true;
}
-
+
return false;
}
-void CXXNameMangler::mangleCXXCtor(const CXXConstructorDecl *D,
+void CXXNameMangler::mangleCXXCtor(const CXXConstructorDecl *D,
CXXCtorType Type) {
assert(!Structor && "Structor already set!");
Structor = D;
StructorType = Type;
-
+
mangle(D);
}
-void CXXNameMangler::mangleCXXDtor(const CXXDestructorDecl *D,
+void CXXNameMangler::mangleCXXDtor(const CXXDestructorDecl *D,
CXXDtorType Type) {
assert(!Structor && "Structor already set!");
Structor = D;
StructorType = Type;
-
+
mangle(D);
}
@@ -180,9 +180,8 @@ void CXXNameMangler::mangleCXXRtti(QualType T) {
mangleType(T);
}
-void CXXNameMangler::mangleGuardVariable(const VarDecl *D)
-{
- // <special-name> ::= GV <object name> # Guard variable for one-time
+void CXXNameMangler::mangleGuardVariable(const VarDecl *D) {
+ // <special-name> ::= GV <object name> # Guard variable for one-time
// # initialization
Out << "_ZGV";
@@ -192,14 +191,14 @@ void CXXNameMangler::mangleGuardVariable(const VarDecl *D)
void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
// <encoding> ::= <function name> <bare-function-type>
mangleName(FD);
-
+
// Whether the mangling of a function type includes the return type depends on
// the context and the nature of the function. The rules for deciding whether
// the return type is included are:
- //
+ //
// 1. Template functions (names or types) have return types encoded, with
// the exceptions listed below.
- // 2. Function types not appearing as part of a function name mangling,
+ // 2. Function types not appearing as part of a function name mangling,
// e.g. parameters, pointer types, etc., have return type encoded, with the
// exceptions listed below.
// 3. Non-template function names do not have return types encoded.
@@ -233,7 +232,7 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
//
// <unscoped-name> ::= <unqualified-name>
// ::= St <unqualified-name> # ::std::
- if (ND->getDeclContext()->isTranslationUnit())
+ if (ND->getDeclContext()->isTranslationUnit())
mangleUnqualifiedName(ND);
else if (isStdNamespace(ND->getDeclContext())) {
Out << "St";
@@ -298,8 +297,8 @@ void CXXNameMangler::mangleThunk(const FunctionDecl *FD, int64_t nv,
void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
// <unqualified-name> ::= <operator-name>
- // ::= <ctor-dtor-name>
- // ::= <source-name>
+ // ::= <ctor-dtor-name>
+ // ::= <source-name>
DeclarationName Name = ND->getDeclName();
switch (Name.getNameKind()) {
case DeclarationName::Identifier:
@@ -335,7 +334,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
break;
case DeclarationName::CXXConversionFunctionName:
- // <operator-name> ::= cv <type> # (cast)
+ // <operator-name> ::= cv <type> # (cast)
Out << "cv";
mangleType(Context.getCanonicalType(Name.getCXXNameType()));
break;
@@ -349,9 +348,9 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND) {
assert(false && "Can't mangle a using directive name!");
break;
}
-
+
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
- if (const TemplateArgumentList *TemplateArgs
+ if (const TemplateArgumentList *TemplateArgs
= Function->getTemplateSpecializationArgs())
mangleTemplateArgumentList(*TemplateArgs);
}
@@ -379,7 +378,7 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND) {
void CXXNameMangler::mangleLocalName(const NamedDecl *ND) {
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
// := Z <function encoding> E s [<discriminator>]
- // <discriminator> := _ <non-negative number>
+ // <discriminator> := _ <non-negative number>
Out << 'Z';
mangleFunctionEncoding(cast<FunctionDecl>(ND->getDeclContext()));
Out << 'E';
@@ -399,7 +398,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) {
if (const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(DC))
mangleSourceName(Namespace->getIdentifier());
else if (const RecordDecl *Record = dyn_cast<RecordDecl>(DC)) {
- if (const ClassTemplateSpecializationDecl *D =
+ if (const ClassTemplateSpecializationDecl *D =
dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
mangleType(QualType(D->getTypeForDecl(), 0));
} else
@@ -407,7 +406,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) {
}
}
-void
+void
CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
switch (OO) {
// <operator-name> ::= nw # new
@@ -503,13 +502,13 @@ CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
case OO_None:
case OO_Conditional:
case NUM_OVERLOADED_OPERATORS:
- assert(false && "Not an overloaded operator");
+ assert(false && "Not an overloaded operator");
break;
}
}
void CXXNameMangler::mangleCVQualifiers(unsigned Quals) {
- // <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, const
+ // <CV-qualifiers> ::= [r] [V] [K] # restrict (C99), volatile, const
if (Quals & QualType::Restrict)
Out << 'r';
if (Quals & QualType::Volatile)
@@ -595,7 +594,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
case BuiltinType::Overload:
case BuiltinType::Dependent:
- assert(false &&
+ assert(false &&
"Overloaded and dependent types shouldn't get to name mangling");
break;
case BuiltinType::UndeducedAuto:
@@ -631,9 +630,9 @@ void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
Out << 'v';
return;
}
-
+
for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
- ArgEnd = Proto->arg_type_end();
+ ArgEnd = Proto->arg_type_end();
Arg != ArgEnd; ++Arg)
mangleType(*Arg);
@@ -643,7 +642,7 @@ void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
}
// <type> ::= <class-enum-type>
-// <class-enum-type> ::= <name>
+// <class-enum-type> ::= <name>
void CXXNameMangler::mangleType(const EnumType *T) {
mangleType(static_cast<const TagType*>(T));
}
@@ -655,9 +654,9 @@ void CXXNameMangler::mangleType(const TagType *T) {
mangleName(T->getDecl()->getTypedefForAnonDecl());
else
mangleName(T->getDecl());
-
+
// If this is a class template specialization, mangle the template arguments.
- if (ClassTemplateSpecializationDecl *Spec
+ if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(T->getDecl()))
mangleTemplateArgumentList(Spec->getTemplateArgs());
}
@@ -695,7 +694,7 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
mangleCVQualifiers(FPT->getTypeQuals());
mangleType(FPT);
- } else
+ } else
mangleType(PointeeType);
}
@@ -825,18 +824,18 @@ void CXXNameMangler::mangleCXXDtorType(CXXDtorType T) {
void CXXNameMangler::mangleTemplateArgumentList(const TemplateArgumentList &L) {
// <template-args> ::= I <template-arg>+ E
Out << "I";
-
+
for (unsigned i = 0, e = L.size(); i != e; ++i) {
const TemplateArgument &A = L[i];
-
+
mangleTemplateArgument(A);
}
-
+
Out << "E";
}
void CXXNameMangler::mangleTemplateArgument(const TemplateArgument &A) {
- // <template-arg> ::= <type> # type or template
+ // <template-arg> ::= <type> # type or template
// ::= X <expression> E # expression
// ::= <expr-primary> # simple expressions
// ::= I <template-arg>* E # argument pack
@@ -851,9 +850,9 @@ void CXXNameMangler::mangleTemplateArgument(const TemplateArgument &A) {
// <expr-primary> ::= L <type> <value number> E # integer literal
Out << 'L';
-
+
mangleType(A.getIntegralType());
-
+
const llvm::APSInt *Integral = A.getAsIntegral();
if (A.getIntegralType()->isBooleanType()) {
// Boolean values are encoded as 0/1.
@@ -863,7 +862,7 @@ void CXXNameMangler::mangleTemplateArgument(const TemplateArgument &A) {
Out << 'n';
Integral->abs().print(Out, false);
}
-
+
Out << 'E';
break;
}
@@ -878,21 +877,21 @@ namespace clang {
/// and this routine will return false. In this case, the caller should just
/// emit the identifier of the declaration (\c D->getIdentifier()) as its
/// name.
- bool mangleName(const NamedDecl *D, ASTContext &Context,
+ bool mangleName(const NamedDecl *D, ASTContext &Context,
llvm::raw_ostream &os) {
assert(!isa<CXXConstructorDecl>(D) &&
"Use mangleCXXCtor for constructor decls!");
assert(!isa<CXXDestructorDecl>(D) &&
"Use mangleCXXDtor for destructor decls!");
-
+
CXXNameMangler Mangler(Context, os);
if (!Mangler.mangle(D))
return false;
-
+
os.flush();
return true;
}
-
+
/// \brief Mangles the a thunk with the offset n for the declaration D and
/// emits that name to the given output stream.
void mangleThunk(const FunctionDecl *FD, int64_t nv, int64_t v,
@@ -902,12 +901,12 @@ namespace clang {
"Use mangleCXXCtor for constructor decls!");
assert(!isa<CXXDestructorDecl>(FD) &&
"Use mangleCXXDtor for destructor decls!");
-
+
CXXNameMangler Mangler(Context, os);
Mangler.mangleThunk(FD, nv, v);
os.flush();
}
-
+
/// \brief Mangles the a covariant thunk for the declaration D and emits that
/// name to the given output stream.
void mangleCovariantThunk(const FunctionDecl *FD, int64_t nv_t, int64_t v_t,
@@ -918,12 +917,12 @@ namespace clang {
"Use mangleCXXCtor for constructor decls!");
assert(!isa<CXXDestructorDecl>(FD) &&
"Use mangleCXXDtor for destructor decls!");
-
+
CXXNameMangler Mangler(Context, os);
Mangler.mangleCovariantThunk(FD, nv_t, v_t, nv_r, v_r);
os.flush();
}
-
+
/// mangleGuardVariable - Returns the mangled name for a guard variable
/// for the passed in VarDecl.
void mangleGuardVariable(const VarDecl *D, ASTContext &Context,
@@ -933,20 +932,20 @@ namespace clang {
os.flush();
}
-
+
void mangleCXXCtor(const CXXConstructorDecl *D, CXXCtorType Type,
ASTContext &Context, llvm::raw_ostream &os) {
CXXNameMangler Mangler(Context, os);
Mangler.mangleCXXCtor(D, Type);
-
+
os.flush();
}
-
+
void mangleCXXDtor(const CXXDestructorDecl *D, CXXDtorType Type,
ASTContext &Context, llvm::raw_ostream &os) {
CXXNameMangler Mangler(Context, os);
Mangler.mangleCXXDtor(D, Type);
-
+
os.flush();
}
diff --git a/lib/CodeGen/Mangle.h b/lib/CodeGen/Mangle.h
index 855839170e..16f1ae6d3f 100644
--- a/lib/CodeGen/Mangle.h
+++ b/lib/CodeGen/Mangle.h
@@ -32,8 +32,8 @@ namespace clang {
class FunctionDecl;
class NamedDecl;
class VarDecl;
-
- bool mangleName(const NamedDecl *D, ASTContext &Context,
+
+ bool mangleName(const NamedDecl *D, ASTContext &Context,
llvm::raw_ostream &os);
void mangleThunk(const FunctionDecl *FD, int64_t n, int64_t vn,
ASTContext &Context, llvm::raw_ostream &os);
@@ -51,4 +51,4 @@ namespace clang {
ASTContext &Context, llvm::raw_ostream &os);
}
-#endif
+#endif
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp
index 600271f7d8..c8f686a06f 100644
--- a/lib/CodeGen/ModuleBuilder.cpp
+++ b/lib/CodeGen/ModuleBuilder.cpp
@@ -40,27 +40,27 @@ namespace {
CodeGeneratorImpl(Diagnostic &diags, const std::string& ModuleName,
const CompileOptions &CO, llvm::LLVMContext& C)
: Diags(diags), CompileOpts(CO), M(new llvm::Module(ModuleName, C)) {}
-
+
virtual ~CodeGeneratorImpl() {}
-
+
virtual llvm::Module* GetModule() {
return M.get();
}
-
+
virtual llvm::Module* ReleaseModule() {
return M.take();
}
-
+
virtual void Initialize(ASTContext &Context) {
Ctx = &Context;
-
+
M->setTargetTriple(Ctx->Target.getTriple().getTriple());
M->setDataLayout(Ctx->Target.getTargetDescription());
TD.reset(new llvm::TargetData(Ctx->Target.getTargetDescription()));
Builder.reset(new CodeGen::CodeGenModule(Context, CompileOpts,
*M, *TD, Diags));
}
-
+
virtual void HandleTopLevelDecl(DeclGroupRef DG) {
// Make sure to emit all elements of a Decl.
for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
@@ -94,7 +94,7 @@ namespace {
};
}
-CodeGenerator *clang::CreateLLVMCodeGen(Diagnostic &Diags,
+CodeGenerator *clang::CreateLLVMCodeGen(Diagnostic &Diags,
const std::string& ModuleName,
const CompileOptions &CO,
llvm::LLVMContext& C) {
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index 9525a8ecf5..daeec0a31c 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -242,7 +242,7 @@ public:
CodeGenFunction &CGF) const;
X86_32ABIInfo(ASTContext &Context, bool d, bool p)
- : ABIInfo(), Context(Context), IsDarwinVectorABI(d),
+ : ABIInfo(), Context(Context), IsDarwinVectorABI(d),
IsSmallStructInRegABI(p) {}
};
}
@@ -402,7 +402,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
// Structures with flexible arrays are always indirect.
if (const RecordType *RT = Ty->getAsStructureType())
if (RT->getDecl()->hasFlexibleArrayMember())
- return ABIArgInfo::getIndirect(getIndirectArgumentAlignment(Ty,
+ return ABIArgInfo::getIndirect(getIndirectArgumentAlignment(Ty,
Context));
// Ignore empty structs.
@@ -1035,7 +1035,7 @@ void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
it != ie; ++it) {
unsigned neededInt, neededSSE;
- it->info = classifyArgumentType(it->type, Context, VMContext,
+ it->info = classifyArgumentType(it->type, Context, VMContext,
neededInt, neededSSE);
// AMD64-ABI 3.2.3p3: If there are no registers available for any
@@ -1107,7 +1107,7 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr,
llvm::Value *X86_64ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CGF) const {
llvm::LLVMContext &VMContext = CGF.getLLVMContext();
-
+
// Assume that va_list type is correct; should be pointer to LLVM type:
// struct {
// i32 gp_offset;
@@ -1338,7 +1338,7 @@ class ARMABIInfo : public ABIInfo {
void ARMABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
llvm::LLVMContext &VMContext) const {
- FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
+ FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
VMContext);
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
it != ie; ++it) {
@@ -1392,7 +1392,7 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
llvm::Value *ARMABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
CodeGenFunction &CGF) const {
// FIXME: Need to handle alignment
- const llvm::Type *BP =
+ const llvm::Type *BP =
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
const llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp
index cabc33eaec..62434893f9 100644
--- a/lib/Driver/Action.cpp
+++ b/lib/Driver/Action.cpp
@@ -29,16 +29,16 @@ const char *Action::getClassName(ActionClass AC) {
case LinkJobClass: return "linker";
case LipoJobClass: return "lipo";
}
-
+
assert(0 && "invalid class");
return 0;
}
-InputAction::InputAction(const Arg &_Input, types::ID _Type)
+InputAction::InputAction(const Arg &_Input, types::ID _Type)
: Action(InputClass, _Type), Input(_Input) {
}
-BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
+BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
: Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) {
}
@@ -46,7 +46,7 @@ JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
: Action(Kind, Input, Type) {
}
-JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
+JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
: Action(Kind, Inputs, Type) {
}
@@ -70,10 +70,10 @@ AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
: JobAction(AssembleJobClass, Input, OutputType) {
}
-LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
+LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
: JobAction(LinkJobClass, Inputs, Type) {
}
-LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
+LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
: JobAction(LipoJobClass, Inputs, Type) {
}
diff --git a/lib/Driver/Arg.cpp b/lib/Driver/Arg.cpp
index e227d7e2ea..a09ba095f1 100644
--- a/lib/Driver/Arg.cpp
+++ b/lib/Driver/Arg.cpp
@@ -14,10 +14,9 @@
using namespace clang::driver;
-Arg::Arg(ArgClass _Kind, const Option *_Opt, unsigned _Index,
- const Arg *_BaseArg)
- : Kind(_Kind), Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false)
-{
+Arg::Arg(ArgClass _Kind, const Option *_Opt, unsigned _Index,
+ const Arg *_BaseArg)
+ : Kind(_Kind), Opt(_Opt), BaseArg(_BaseArg), Index(_Index), Claimed(false) {
}
Arg::~Arg() { }
@@ -54,7 +53,7 @@ std::string Arg::getAsString(const ArgList &Args) const {
ArgStringList ASL;
render(Args, ASL);
- for (ArgStringList::iterator
+ for (ArgStringList::iterator
it = ASL.begin(), ie = ASL.end(); it != ie; ++it) {
if (it != ASL.begin())
OS << ' ';
@@ -87,7 +86,7 @@ const char *FlagArg::getValue(const ArgList &Args, unsigned N) const {
return 0;
}
-PositionalArg::PositionalArg(const Option *Opt, unsigned Index,
+PositionalArg::PositionalArg(const Option *Opt, unsigned Index,
const Arg *BaseArg)
: Arg(PositionalClass, Opt, Index, BaseArg) {
}
@@ -120,10 +119,10 @@ const char *JoinedArg::getValue(const ArgList &Args, unsigned N) const {
return Args.getArgString(getIndex()) + strlen(getOption().getName());
}
-CommaJoinedArg::CommaJoinedArg(const Option *Opt, unsigned Index,
+CommaJoinedArg::CommaJoinedArg(const Option *Opt, unsigned Index,
const char *Str, const Arg *BaseArg)
: Arg(CommaJoinedClass, Opt, Index, BaseArg) {
- const char *Prev = Str;
+ const char *Prev = Str;
for (;; ++Str) {
char c = *Str;
@@ -167,23 +166,23 @@ void SeparateArg::render(const ArgList &Args, ArgStringList &Output) const {
}
}
-const char *SeparateArg::getValue(const ArgList &Args, unsigned N) const {
+const char *SeparateArg::getValue(const ArgList &Args, unsigned N) const {
assert(N < getNumValues() && "Invalid index.");
return Args.getArgString(getIndex() + 1 + N);
}
-JoinedAndSeparateArg::JoinedAndSeparateArg(const Option *Opt, unsigned Index,
+JoinedAndSeparateArg::JoinedAndSeparateArg(const Option *Opt, unsigned Index,
const Arg *BaseArg)
: Arg(JoinedAndSeparateClass, Opt, Index, BaseArg) {
}
-void JoinedAndSeparateArg::render(const ArgList &Args,
+void JoinedAndSeparateArg::render(const ArgList &Args,
ArgStringList &Output) const {
Output.push_back(Args.getArgString(getIndex()));
Output.push_back(Args.getArgString(getIndex() + 1));
}
-const char *JoinedAndSeparateArg::getValue(const ArgList &Args,
+const char *JoinedAndSeparateArg::getValue(const ArgList &Args,
unsigned N) const {
assert(N < getNumValues() && "Invalid index.");
if (N == 0)
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 54dd4bb775..be7109f3f6 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -31,13 +31,13 @@ Arg *ArgList::getLastArg(options::ID Id, bool Claim) const {
return *it;
}
}
-
+
return 0;
}
Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, bool Claim) const {
Arg *Res, *A0 = getLastArg(Id0, false), *A1 = getLastArg(Id1, false);
-
+
if (A0 && A1)
Res = A0->getIndex() > A1->getIndex() ? A0 : A1;
else
@@ -102,7 +102,7 @@ void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0) const {
}
}
-void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0,
+void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0,
options::ID Id1) const {
// FIXME: Make fast.
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -114,7 +114,7 @@ void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0,
}
}
-void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0,
+void ArgList::AddAllArgs(ArgStringList &Output, options::ID Id0,
options::ID Id1, options::ID Id2) const {
// FIXME: Make fast.
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -139,7 +139,7 @@ void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0) const {
}
}
-void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0,
+void ArgList::AddAllArgValues(ArgStringList &Output, options::ID Id0,
options::ID Id1) const {
// FIXME: Make fast.
for (const_iterator it = begin(), ie = end(); it != ie; ++it) {
@@ -184,9 +184,8 @@ void ArgList::ClaimAllArgs(options::ID Id0) const {
//
-InputArgList::InputArgList(const char **ArgBegin, const char **ArgEnd)
- : ArgList(ActualArgs), NumInputArgStrings(ArgEnd - ArgBegin)
-{
+InputArgList::InputArgList(const char **ArgBegin, const char **ArgEnd)
+ : ArgList(ActualArgs), NumInputArgStrings(ArgEnd - ArgBegin) {
ArgStrings.append(ArgBegin, ArgEnd);
}
@@ -206,7 +205,7 @@ unsigned InputArgList::MakeIndex(const char *String0) const {
return Index;
}
-unsigned InputArgList::MakeIndex(const char *String0,
+unsigned InputArgList::MakeIndex(const char *String0,
const char *String1) const {
unsigned Index0 = MakeIndex(String0);
unsigned Index1 = MakeIndex(String1);
@@ -223,13 +222,12 @@ const char *InputArgList::MakeArgString(const char *Str) const {
DerivedArgList::DerivedArgList(InputArgList &_BaseArgs, bool _OnlyProxy)
: ArgList(_OnlyProxy ? _BaseArgs.getArgs() : ActualArgs),
- BaseArgs(_BaseArgs), OnlyProxy(_OnlyProxy)
-{
+ BaseArgs(_BaseArgs), OnlyProxy(_OnlyProxy) {
}
DerivedArgList::~DerivedArgList() {
// We only own the arguments we explicitly synthesized.
- for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end();
+ for (iterator it = SynthesizedArgs.begin(), ie = SynthesizedArgs.end();
it != ie; ++it)
delete *it;
}
@@ -242,18 +240,18 @@ Arg *DerivedArgList::MakeFlagArg(const Arg *BaseArg, const Option *Opt) const {
return new FlagArg(Opt, BaseArgs.MakeIndex(Opt->getName()), BaseArg);
}
-Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt,
+Arg *DerivedArgList::MakePositionalArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const {
return new PositionalArg(Opt, BaseArgs.MakeIndex(Value), BaseArg);
}
-Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
+Arg *DerivedArgList::MakeSeparateArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const {
- return new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1,
+ return new SeparateArg(Opt, BaseArgs.MakeIndex(Opt->getName(), Value), 1,
BaseArg);
}
-Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
+Arg *DerivedArgList::MakeJoinedArg(const Arg *BaseArg, const Option *Opt,
const char *Value) const {
std::string Joined(Opt->getName());
Joined += Value;
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index 7e29b67769..ad3cb8dbe1 100644
--- a/lib/Driver/Compilation.cpp
+++ b/lib/Driver/Compilation.cpp
@@ -23,20 +23,20 @@ using namespace clang::driver;
Compilation::Compilation(const Driver &D,
const ToolChain &_DefaultToolChain,
- InputArgList *_Args)
+ InputArgList *_Args)
: TheDriver(D), DefaultToolChain(_DefaultToolChain), Args(_Args) {
}
-Compilation::~Compilation() {
+Compilation::~Compilation() {
delete Args;
-
+
// Free any derived arg lists.
- for (llvm::DenseMap<const ToolChain*, DerivedArgList*>::iterator
+ for (llvm::DenseMap<const ToolChain*, DerivedArgList*>::iterator
it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it)
delete it->second;
// Free the actions, if built.
- for (ActionList::iterator it = Actions.begin(), ie = Actions.end();
+ for (ActionList::iterator it = Actions.begin(), ie = Actions.end();
it != ie; ++it)
delete *it;
}
@@ -52,7 +52,7 @@ const DerivedArgList &Compilation::getArgsForToolChain(const ToolChain *TC) {
return *Entry;
}
-void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J,
+void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J,
const char *Terminator, bool Quote) const {
if (const Command *C = dyn_cast<Command>(&J)) {
OS << " \"" << C->getExecutable() << '"';
@@ -65,22 +65,22 @@ void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J,
}
OS << Terminator;
} else if (const PipedJob *PJ = dyn_cast<PipedJob>(&J)) {
- for (PipedJob::const_iterator
+ for (PipedJob::const_iterator
it = PJ->begin(), ie = PJ->end(); it != ie; ++it)
PrintJob(OS, **it, (it + 1 != PJ->end()) ? " |\n" : "\n", Quote);
} else {
const JobList *Jobs = cast<JobList>(&J);
- for (JobList::const_iterator
+ for (JobList::const_iterator
it = Jobs->begin(), ie = Jobs->end(); it != ie; ++it)
PrintJob(OS, **it, Terminator, Quote);
}
}
-bool Compilation::CleanupFileList(const ArgStringList &Files,
+bool Compilation::CleanupFileList(const ArgStringList &Files,
bool IssueErrors) const {
bool Success = true;
- for (ArgStringList::const_iterator
+ for (ArgStringList::const_iterator
it = Files.begin(), ie = Files.end(); it != ie; ++it) {
llvm::sys::Path P(*it);
std::string Error;
@@ -92,7 +92,7 @@ bool Compilation::CleanupFileList(const ArgStringList &Files,
// FIXME: Grumble, P.exists() is broken. PR3837.
struct stat buf;
- if (::stat(P.c_str(), &buf) == 0
+ if (::stat(P.c_str(), &buf) == 0
|| errno != ENOENT) {
if (IssueErrors)
getDriver().Diag(clang::diag::err_drv_unable_to_remove_file)
@@ -112,12 +112,12 @@ int Compilation::ExecuteCommand(const Command &C,
Argv[0] = C.getExecutable();
std::copy(C.getArguments().begin(), C.getArguments().end(), Argv+1);
Argv[C.getArguments().size() + 1] = 0;
-
+
if (getDriver().CCCEcho || getArgs().hasArg(options::OPT_v))
PrintJob(llvm::errs(), C, "\n", false);
-
+
std::string Error;
- int Res =
+ int Res =
llvm::sys::Program::ExecuteAndWait(Prog, Argv,
/*env*/0, /*redirects*/0,
/*secondsToWait*/0, /*memoryLimit*/0,
@@ -126,7 +126,7 @@ int Compilation::ExecuteCommand(const Command &C,
assert(Res && "Error string set with 0 result code!");
getDriver().Diag(clang::diag::err_drv_command_failure) << Error;
}
-
+
if (Res)
FailingCommand = &C;
@@ -134,7 +134,7 @@ int Compilation::ExecuteCommand(const Command &C,
return Res;
}
-int Compilation::ExecuteJob(const Job &J,
+int Compilation::ExecuteJob(const Job &J,
const Command *&FailingCommand) const {
if (const Command *C = dyn_cast<Command>(&J)) {
return ExecuteCommand(*C, FailingCommand);
@@ -142,13 +142,13 @@ int Compilation::ExecuteJob(const Job &J,
// Piped commands with a single job are easy.
if (PJ->size() == 1)
return ExecuteCommand(**PJ->begin(), FailingCommand);
-
+
FailingCommand = *PJ->begin();
getDriver().Diag(clang::diag::err_drv_unsupported_opt) << "-pipe";
return 1;
} else {
const JobList *Jobs = cast<JobList>(&J);
- for (JobList::const_iterator
+ for (JobList::const_iterator
it = Jobs->begin(), ie = Jobs->end(); it != ie; ++it)
if (int Res = ExecuteJob(**it, FailingCommand))
return Res;
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 59099a33e6..24f462f18f 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -56,8 +56,7 @@ Driver::Driver(const char *_Name, const char *_Dir,
CCCUseClangCXX(true),
#endif
CCCUseClangCPP(true), CCCUsePCH(true),
- SuppressMissingInputWarning(false)
-{
+ SuppressMissingInputWarning(false) {
#ifdef USE_PRODUCTION_CLANG
// In a "production" build, only use clang on architectures we expect to work.
CCCClangArchs.insert(llvm::Triple::x86);
diff --git a/lib/Driver/HostInfo.cpp b/lib/Driver/HostInfo.cpp
index ceb4ed1023..e950b4a08e 100644
--- a/lib/Driver/HostInfo.cpp
+++ b/lib/Driver/HostInfo.cpp
@@ -26,9 +26,7 @@
using namespace clang::driver;
HostInfo::HostInfo(const Driver &D, const llvm::Triple &_Triple)
- : TheDriver(D), Triple(_Triple)
-{
-
+ : TheDriver(D), Triple(_Triple) {
}
HostInfo::~HostInfo() {
diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp
index 1b0ea18453..280e7c4a5a 100644
--- a/lib/Driver/Job.cpp
+++ b/lib/Driver/Job.cpp
@@ -14,9 +14,9 @@ using namespace clang::driver;
Job::~Job() {}
-Command::Command(const Action &_Source, const char *_Executable,
+Command::Command(const Action &_Source, const char *_Executable,
const ArgStringList &_Arguments)
- : Job(CommandClass), Source(_Source), Executable(_Executable),
+ : Job(CommandClass), Source(_Source), Executable(_Executable),
Arguments(_Arguments) {
}
@@ -30,4 +30,4 @@ void Job::addCommand(Command *C) {
else
cast<JobList>(this)->addJob(C);
}
-
+
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
index 8c88575764..affd1c5aa9 100644
--- a/lib/Driver/OptTable.cpp
+++ b/lib/Driver/OptTable.cpp
@@ -77,7 +77,7 @@ static Info OptionInfos[] = {
{ "<input>", "d", 0, 0, Option::InputClass, OPT_INVALID, OPT_INVALID, 0 },
// The UnknownOption info
{ "<unknown>", "", 0, 0, Option::UnknownClass, OPT_INVALID, OPT_INVALID, 0 },
-
+
#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
HELPTEXT, METAVAR) \
{ NAME, FLAGS, HELPTEXT, METAVAR, \
@@ -124,10 +124,10 @@ OptTable::OptTable() : Options(new Option*[numOptions]) {
assert(0 && "Options are not in order!");
}
}
-#endif
+#endif
}
-OptTable::~OptTable() {
+OptTable::~OptTable() {
for (unsigned i = 0; i < numOptions; ++i)
delete Options[i];
delete[] Options;
@@ -168,7 +168,7 @@ const Option *OptTable::getOption(options::ID id) const {
Option *OptTable::constructOption(options::ID id) const {
Info &info = getInfo(id);
- const OptionGroup *Group =
+ const OptionGroup *Group =
cast_or_null<OptionGroup>(getOption((options::ID) info.GroupID));
const Option *Alias = getOption((options::ID) info.AliasID);
@@ -199,10 +199,10 @@ Option *OptTable::constructOption(options::ID id) const {
for (const char *s = info.Flags; *s; ++s) {
switch (*s) {
default: assert(0 && "Invalid option flag.");
- case 'J':
+ case 'J':
assert(info.Kind == Option::SeparateClass && "Invalid option.");
Opt->setForceJoinedRender(true); break;
- case 'S':
+ case 'S':
assert(info.Kind == Option::JoinedClass && "Invalid option.");
Opt->setForceSeparateRender(true); break;
case 'd': Opt->setDriverOption(true); break;
diff --git a/lib/Driver/Option.cpp b/lib/Driver/Option.cpp
index cad2bbf2b7..c2ace05aa4 100644
--- a/lib/Driver/Option.cpp
+++ b/lib/Driver/Option.cpp
@@ -17,18 +17,17 @@
using namespace clang::driver;
Option::Option(OptionClass _Kind, options::ID _ID, const char *_Name,
- const OptionGroup *_Group, const Option *_Alias)
+ const OptionGroup *_Group, const Option *_Alias)
: Kind(_Kind), ID(_ID), Name(_Name), Group(_Group), Alias(_Alias),
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
ForceSeparateRender(false), ForceJoinedRender(false),
- DriverOption(false), NoArgumentUnused(false)
-{
+ DriverOption(false), NoArgumentUnused(false) {
// Multi-level aliases are not supported, and alias options cannot
// have groups. This just simplifies option tracking, it is not an
// inherent limitation.
assert((!Alias || (!Alias->Alias && !Group)) &&
- "Multi-level aliases and aliases with groups are unsupported.");
+ "Multi-level aliases and aliases with groups are unsupported.");
}
Option::~Option() {
@@ -59,12 +58,12 @@ void Option::dump() const {
llvm::errs() << " Group:";
Group->dump();
}
-
+
if (Alias) {
llvm::errs() << " Alias:";
Alias->dump();
}
-
+
if (const MultiArgOption *MOA = dyn_cast<MultiArgOption>(this))
llvm::errs() << " NumArgs:" << MOA->getNumArgs();
@@ -77,10 +76,10 @@ bool Option::matches(const Option *Opt) const {
return matches(Opt->getAlias());
if (Alias)
return Alias->matches(Opt);
-
+
if (this == Opt)
return true;
-
+
if (Group)
return Group->matches(Opt);
return false;
@@ -93,16 +92,16 @@ bool Option::matches(options::ID Id) const {
// the option table).
if (Alias)
return Alias->matches(Id);
-
+
if (ID == Id)
return true;
-
+
if (Group)
return Group->matches(Id);
return false;
}
-OptionGroup::OptionGroup(options::ID ID, const char *Name,
+OptionGroup::OptionGroup(options::ID ID, const char *Name,
const OptionGroup *Group)
: Option(Option::GroupClass, ID, Name, Group, 0) {
}
@@ -130,13 +129,13 @@ Arg *UnknownOption::accept(const InputArgList &Args, unsigned &Index) const {
return 0;
}
-FlagOption::FlagOption(options::ID ID, const char *Name,
+FlagOption::FlagOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias)
: Option(Option::FlagClass, ID, Name, Group, Alias) {
}
Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const {
- // Matches iff this is an exact match.
+ // Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (strlen(getName()) != strlen(Args.getArgString(Index)))
return 0;
@@ -144,7 +143,7 @@ Arg *FlagOption::accept(const InputArgList &Args, unsigned &Index) const {
return new FlagArg(this, Index++);
}
-JoinedOption::JoinedOption(options::ID ID, const char *Name,
+JoinedOption::JoinedOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias)
: Option(Option::JoinedClass, ID, Name, Group, Alias) {
}
@@ -154,30 +153,30 @@ Arg *JoinedOption::accept(const InputArgList &Args, unsigned &Index) const {
return new JoinedArg(this, Index++);
}
-CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name,
- const OptionGroup *Group,
+CommaJoinedOption::CommaJoinedOption(options::ID ID, const char *Name,
+ const OptionGroup *Group,
const Option *Alias)
: Option(Option::CommaJoinedClass, ID, Name, Group, Alias) {
}
-Arg *CommaJoinedOption::accept(const InputArgList &Args,
+Arg *CommaJoinedOption::accept(const InputArgList &Args,
unsigned &Index) const {
// Always matches. We count the commas now so we can answer
// getNumValues easily.
-
+
// Get the suffix string.
// FIXME: Avoid strlen, and move to helper method?
const char *Suffix = Args.getArgString(Index) + strlen(getName());
return new CommaJoinedArg(this, Index++, Suffix);
}
-SeparateOption::SeparateOption(options::ID ID, const char *Name,
+SeparateOption::SeparateOption(options::ID ID, const char *Name,
const OptionGroup *Group, const Option *Alias)
: Option(Option::SeparateClass, ID, Name, Group, Alias) {
}
Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const {
- // Matches iff this is an exact match.
+ // Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (strlen(getName()) != strlen(Args.getArgString(Index)))
return 0;
@@ -189,15 +188,15 @@ Arg *SeparateOption::accept(const InputArgList &Args, unsigned &Index) const {
return new SeparateArg(this, Index - 2, 1);
}
-MultiArgOption::MultiArgOption(options::ID ID, const char *Name,
- const OptionGroup *Group, const Option *Alias,
+MultiArgOption::MultiArgOption(options::ID ID, const char *Name,
+ const OptionGroup *Group, const Option *Alias,
unsigned _NumArgs)
: Option(Option::MultiArgClass, ID, Name, Group, Alias), NumArgs(_NumArgs) {
assert(NumArgs > 1 && "Invalid MultiArgOption!");
}
Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const {
- // Matches iff this is an exact match.
+ // Matches iff this is an exact match.
// FIXME: Avoid strlen.
if (strlen(getName()) != strlen(Args.getArgString(Index)))
return 0;
@@ -210,12 +209,12 @@ Arg *MultiArgOption::accept(const InputArgList &Args, unsigned &Index) const {
}
JoinedOrSeparateOption::JoinedOrSeparateOption(options::ID ID, const char *Name,
- const OptionGroup *Group,
+ const OptionGroup *Group,
const Option *Alias)
: Option(Option::JoinedOrSeparateClass, ID, Name, Group, Alias) {
}
-Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
+Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
unsigned &Index) const {
// If this is not an exact match, it is a joined arg.
// FIXME: Avoid strlen.
@@ -227,17 +226,17 @@ Arg *JoinedOrSeparateOption::accept(const InputArgList &Args,
if (Index > Args.getNumInputArgStrings())
return 0;
- return new SeparateArg(this, Index - 2, 1);
+ return new SeparateArg(this, Index - 2, 1);
}
JoinedAndSeparateOption::JoinedAndSeparateOption(options::ID ID,
- const char *Name,
- const OptionGroup *Group,
+ const char *Name,
+ const OptionGroup *Group,
const Option *Alias)
: Option(Option::JoinedAndSeparateClass, ID, Name, Group, Alias) {
}
-Arg *JoinedAndSeparateOption::accept(const InputArgList &Args,
+Arg *JoinedAndSeparateOption::accept(const InputArgList &Args,
unsigned &Index) const {
// Always matches.
diff --git a/lib/Driver/Tool.cpp b/lib/Driver/Tool.cpp
index 6f6589ab13..781e0a7020 100644
--- a/lib/Driver/Tool.cpp
+++ b/lib/Driver/Tool.cpp
@@ -11,7 +11,7 @@
using namespace clang::driver;
-Tool::Tool(const char *_Name, const ToolChain &TC) : Name(_Name),
+Tool::Tool(const char *_Name, const ToolChain &TC) : Name(_Name),
TheToolChain(TC) {
}
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 20ed31bd6e..46b460381f 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -22,13 +22,13 @@ ToolChain::ToolChain(const HostInfo &_Host, const llvm::Triple &_Triple)
ToolChain::~ToolChain() {
}
-llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
+llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
const char *Name) const {
return Host.getDriver().GetFilePath(Name, *this);
-
+
}
-llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
+llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
const char *Name,
bool WantFile) const {
return Host.getDriver().GetProgramPath(Name, *this, WantFile);
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 6512203d09..fb6217d3ed 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -68,7 +68,7 @@ Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
Path += "/x86_64";
getFilePaths().push_back(Path);
}
-
+
Path = getHost().getDriver().Dir;
Path += "/../lib/gcc/";
Path += getToolChainDir();
@@ -142,16 +142,16 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
// more opaque. For now, we follow gcc closely solely for the
// purpose of easily achieving feature parity & testability. Once we
// have something that works, we should reevaluate each translation
- // and try to push it down into tool specific logic.
+ // and try to push it down into tool specific logic.
- Arg *OSXVersion =
+ Arg *OSXVersion =
Args.getLastArg(options::OPT_mmacosx_version_min_EQ, false);
Arg *iPhoneVersion =
- Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false);
+ Args.getLastArg(options::OPT_miphoneos_version_min_EQ, false);
if (OSXVersion && iPhoneVersion) {
getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with)
<< OSXVersion->getAsString(Args)
- << iPhoneVersion->getAsString(Args);
+ << iPhoneVersion->getAsString(Args);
} else if (!OSXVersion && !iPhoneVersion) {
// Chose the default version based on the arch.
//
@@ -171,7 +171,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
DAL->append(DAL->MakeJoinedArg(0, O, Version));
}
}
-
+
for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) {
Arg *A = *it;
@@ -184,7 +184,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
// interface for this.
unsigned Prev, Index = Prev = A->getIndex() + 1;
Arg *XarchArg = Opts.ParseOneArg(Args, Index);
-
+
// If the argument parsing failed or more than one argument was
// consumed, the -Xarch_ argument's parameter tried to consume
// extra arguments. Emit an error and ignore.
@@ -193,7 +193,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
// driver behavior; that isn't going to work in our model. We
// use isDriverOption() as an approximation, although things
// like -O4 are going to slip through.
- if (!XarchArg || Index > Prev + 1 ||
+ if (!XarchArg || Index > Prev + 1 ||
XarchArg->getOption().isDriverOption()) {
getHost().getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument)
<< A->getAsString(Args);
@@ -202,7 +202,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
XarchArg->setBaseArg(A);
A = XarchArg;
- }
+ }
// Sob. These is strictly gcc compatible for the time being. Apple
// gcc translates options twice, which means that self-expanding
@@ -219,7 +219,7 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static)));
DAL->append(DAL->MakeFlagArg(A, Opts.getOption(options::OPT_static)));
break;
-
+
case options::OPT_dependency_file:
DAL->append(DAL->MakeSeparateArg(A, Opts.getOption(options::OPT_MF),
A->getValue(Args)));
@@ -292,10 +292,10 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args) const {
"core2"));
return DAL;
-}
+}
bool Darwin::IsMathErrnoDefault() const {
- return false;
+ return false;
}
bool Darwin::IsUnwindTablesDefault() const {
@@ -319,13 +319,12 @@ const char *Darwin::GetForcedPicModel() const {
/// command line options.
Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
- : ToolChain(Host, Triple)
-{
+ : ToolChain(Host, Triple) {
std::string Path(getHost().getDriver().Dir);
Path += "/../libexec";
getProgramPaths().push_back(Path);
- getProgramPaths().push_back(getHost().getDriver().Dir);
+ getProgramPaths().push_back(getHost().getDriver().Dir);
}
Generic_GCC::~Generic_GCC() {
@@ -335,7 +334,7 @@ Generic_GCC::~Generic_GCC() {
delete it->second;
}
-Tool &Generic_GCC::SelectTool(const Compilation &C,
+Tool &Generic_GCC::SelectTool(const Compilation &C,
const JobAction &JA) const {
Action::ActionClass Key;
if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
@@ -361,7 +360,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C,
T = new tools::gcc::Assemble(*this); break;
case Action::LinkJobClass:
T = new tools::gcc::Link(*this); break;
-
+
// This is a bit ungeneric, but the only platform using a driver
// driver is Darwin.
case Action::LipoJobClass:
@@ -373,7 +372,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C,
}
bool Generic_GCC::IsMathErrnoDefault() const {
- return true;
+ return true;
}
bool Generic_GCC::IsUnwindTablesDefault() const {
@@ -469,7 +468,7 @@ AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple)
Path += "/../libexec";
getProgramPaths().push_back(Path);
- getProgramPaths().push_back(getHost().getDriver().Dir);
+ getProgramPaths().push_back(getHost().getDriver().Dir);
getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
getFilePaths().push_back("/usr/lib");
@@ -536,7 +535,7 @@ DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple)
Path += "/../libexec";
getProgramPaths().push_back(Path);
- getProgramPaths().push_back(getHost().getDriver().Dir);
+ getProgramPaths().push_back(getHost().getDriver().Dir);
getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
getFilePaths().push_back("/usr/lib");
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index b0cc9cbecd..6a3ce37975 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -69,7 +69,7 @@ class VISIBILITY_HIDDEN Darwin : public ToolChain {
const char *getMacosxVersionMin() const;
public:
- Darwin(const HostInfo &Host, const llvm::Triple& Triple,
+ Darwin(const HostInfo &Host, const llvm::Triple& Triple,
const unsigned (&DarwinVersion)[3],
const unsigned (&GCCVersion)[3],
bool IsIPhone);
@@ -95,7 +95,7 @@ public:
return IPhoneOSVersionMin.c_str();
}
- const std::string &getToolChainDir() const {
+ const std::string &getToolChainDir() const {
return ToolChainDir;
}
@@ -114,7 +114,7 @@ public:
/// Darwin_GCC - Generic Darwin tool chain using gcc.
class VISIBILITY_HIDDEN Darwin_GCC : public Generic_GCC {
public:
- Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
+ Darwin_GCC(const HostInfo &Host, const llvm::Triple& Triple)
: Generic_GCC(Host, Triple) {}
virtual const char *GetDefaultRelocationModel() const { return "pic"; }
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index d7bf8b72bd..7cd57b92fc 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -38,7 +38,7 @@ static const char *MakeFormattedString(const ArgList &Args,
return Args.MakeArgString(Str.c_str());
}
-void Clang::AddPreprocessingOptions(const Driver &D,
+void Clang::AddPreprocessingOptions(const Driver &D,
const ArgList &Args,
ArgStringList &CmdArgs,
const InputInfo &Output,
@@ -131,25 +131,25 @@ void Clang::AddPreprocessingOptions(const Driver &D,
P.appendSuffix("pch");
if (P.exists())
FoundPCH = true;
- else
+ else
P.eraseSuffix();
}
if (!FoundPCH) {
P.appendSuffix("pth");
- if (P.exists())
+ if (P.exists())
FoundPTH = true;
else
P.eraseSuffix();
- }
-
+ }
+
if (!FoundPCH && !FoundPTH) {
P.appendSuffix("gch");
if (P.exists()) {
FoundPCH = D.CCCUsePCH;
FoundPTH = !D.CCCUsePCH;
}
- else
+ else
P.eraseSuffix();
}
@@ -266,8 +266,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Add -Xanalyzer arguments when running as analyzer.
Args.AddAllArgValues(CmdArgs, options::OPT_Xanalyzer);
- }
-
+ }
+
// Perform argument translation for LLVM backend. This
// takes some care in reconciling with llvm-gcc. The
// issue is that llvm-gcc translates these options based on
@@ -358,7 +358,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(A->getValue(Args));
} else {
// Select default CPU.
-
+
// FIXME: Need target hooks.
if (memcmp(getToolChain().getOS().c_str(), "darwin", 6) == 0) {
if (getToolChain().getArchName() == "x86_64")
@@ -388,7 +388,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Skip over "-m".
assert(Name[0] == '-' && Name[1] == 'm' && "Invalid feature name.");
Name += 2;
-
+
bool IsNegative = memcmp(Name, "no-", 3) == 0;
if (IsNegative)
Name += 3;
@@ -396,7 +396,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
A->claim();
CmdArgs.push_back("-target-feature");
CmdArgs.push_back(MakeFormattedString(Args,
- llvm::format("%c%s",
+ llvm::format("%c%s",
IsNegative ? '-' : '+',
Name)));
}
@@ -428,7 +428,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_P);
Args.AddLastArg(CmdArgs, options::OPT_mmacosx_version_min_EQ);
Args.AddLastArg(CmdArgs, options::OPT_miphoneos_version_min_EQ);
- Args.AddLastArg(CmdArgs, options::OPT_print_ivar_layout);
+ Args.AddLastArg(CmdArgs, options::OPT_print_ivar_layout);
// Special case debug options to only pass -g to clang. This is
// wrong.
@@ -489,7 +489,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT__relocatable_pch, true))
CmdArgs.push_back("--relocatable-pch");
-
+
if (Arg *A = Args.getLastArg(options::OPT_fconstant_string_class_EQ)) {
CmdArgs.push_back("-fconstant-string-class");
CmdArgs.push_back(A->getValue(Args));
@@ -592,18 +592,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -fsigned-bitfields is default, and clang doesn't yet support
// --funsigned-bitfields.
- if (!Args.hasFlag(options::OPT_fsigned_bitfields,
+ if (!Args.hasFlag(options::OPT_fsigned_bitfields,
options::OPT_funsigned_bitfields))
D.Diag(clang::diag::warn_drv_clang_unsupported)
<< Args.getLastArg(options::OPT_funsigned_bitfields)->getAsString(Args);
// -fdiagnostics-fixit-info is default, only pass non-default.
- if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info,
+ if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info,
options::OPT_fno_diagnostics_fixit_info))
CmdArgs.push_back("-fno-diagnostics-fixit-info");
// Enable -fdiagnostics-show-option by default.
- if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
+ if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
options::OPT_fno_diagnostics_show_option))
CmdArgs.push_back("-fdiagnostics-show-option");
if (!Args.hasFlag(options::OPT_fcolor_diagnostics,
@@ -615,7 +615,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -fdollars-in-identifiers default varies depending on platform and
// language; only pass if specified.
- if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
+ if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
options::OPT_fno_dollars_in_identifiers)) {
if (A->getOption().matches(options::OPT_fdollars_in_identifiers))
CmdArgs.push_back("-fdollars-in-identifiers=1");
@@ -625,13 +625,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -funit-at-a-time is default, and we don't support -fno-unit-at-a-time for
// practical purposes.
- if (Arg *A = Args.getLastArg(options::OPT_funit_at_a_time,
+ if (Arg *A = Args.getLastArg(options::OPT_funit_at_a_time,
options::OPT_fno_unit_at_a_time)) {
if (A->getOption().matches(options::OPT_fno_unit_at_a_time))
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
}
- if (Arg *A = Args.getLastArg(options::OPT_traditional,
+ if (Arg *A = Args.getLastArg(options::OPT_traditional,
options::OPT_traditional_cpp))
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
@@ -1027,8 +1027,7 @@ void darwin::CC1::AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
ArgStringList &CmdArgs,
- const InputInfoList &Inputs) const
-{
+ const InputInfoList &Inputs) const {
const Driver &D = getToolChain().getHost().getDriver();
// Derived from cpp_unique_options.
@@ -1877,8 +1876,7 @@ void auroraux::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
- const char *LinkingOutput) const
-{
+ const char *LinkingOutput) const {
ArgStringList CmdArgs;
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@@ -2006,8 +2004,7 @@ void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
- const char *LinkingOutput) const
-{
+ const char *LinkingOutput) const {
ArgStringList CmdArgs;
Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
@@ -2135,8 +2132,7 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest, const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
- const char *LinkingOutput) const
-{
+ const char *LinkingOutput) const {
ArgStringList CmdArgs;
// When building 32-bit code on FreeBSD/amd64, we have to explicitly
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index 4821c548b1..c584b5ef05 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -42,9 +42,9 @@ namespace tools {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
@@ -56,9 +56,9 @@ namespace gcc {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
/// RenderExtraToolArgs - Render any arguments necessary to force
@@ -66,7 +66,7 @@ namespace gcc {
virtual void RenderExtraToolArgs(ArgStringList &CmdArgs) const = 0;
};
-
+
class VISIBILITY_HIDDEN Preprocess : public Common {
public:
Preprocess(const ToolChain &TC) : Common("gcc::Preprocess", TC) {}
@@ -126,11 +126,11 @@ namespace gcc {
namespace darwin {
class VISIBILITY_HIDDEN CC1 : public Tool {
public:
- static const char *getBaseInputName(const ArgList &Args,
+ static const char *getBaseInputName(const ArgList &Args,
const InputInfoList &Input);
- static const char *getBaseInputStem(const ArgList &Args,
+ static const char *getBaseInputStem(const ArgList &Args,
const InputInfoList &Input);
- static const char *getDependencyFileName(const ArgList &Args,
+ static const char *getDependencyFileName(const ArgList &Args,
const InputInfoList &Inputs);
protected:
@@ -143,7 +143,7 @@ namespace darwin {
void AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
const InputInfoList &Inputs,
const ArgStringList &OutputArgs) const;
- void AddCPPUniqueOptionsArgs(const ArgList &Args,
+ void AddCPPUniqueOptionsArgs(const ArgList &Args,
ArgStringList &CmdArgs,
const InputInfoList &Inputs) const;
void AddCPPArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
@@ -162,9 +162,9 @@ namespace darwin {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
@@ -174,9 +174,9 @@ namespace darwin {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
@@ -190,9 +190,9 @@ namespace darwin {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
@@ -216,9 +216,9 @@ namespace darwin {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
@@ -232,9 +232,9 @@ namespace darwin {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
}
@@ -251,9 +251,9 @@ namespace openbsd {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
class VISIBILITY_HIDDEN Link : public Tool {
@@ -266,9 +266,9 @@ namespace openbsd {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
} // end namespace openbsd
@@ -285,9 +285,9 @@ namespace freebsd {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
class VISIBILITY_HIDDEN Link : public Tool {
@@ -300,9 +300,9 @@ namespace freebsd {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
} // end namespace freebsd
@@ -319,9 +319,9 @@ namespace auroraux {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
class VISIBILITY_HIDDEN Link : public Tool {
@@ -334,9 +334,9 @@ namespace auroraux {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
} // end namespace auroraux
@@ -353,9 +353,9 @@ namespace dragonfly {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
class VISIBILITY_HIDDEN Link : public Tool {
@@ -368,9 +368,9 @@ namespace dragonfly {
virtual void ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
const char *LinkingOutput) const;
};
} // end namespace dragonfly
diff --git a/lib/Driver/Types.cpp b/lib/Driver/Types.cpp
index 60248a17c7..eee8c19c27 100644
--- a/lib/Driver/Types.cpp
+++ b/lib/Driver/Types.cpp
@@ -35,38 +35,38 @@ static Info &getInfo(unsigned id) {
return TypeInfos[id - 1];
}
-const char *types::getTypeName(ID Id) {
- return getInfo(Id).Name;
+const char *types::getTypeName(ID Id) {
+ return getInfo(Id).Name;
}
-types::ID types::getPreprocessedType(ID Id) {
- return getInfo(Id).PreprocessedType;
+types::ID types::getPreprocessedType(ID Id) {
+ return getInfo(Id).PreprocessedType;
}
-const char *types::getTypeTempSuffix(ID Id) {
- return getInfo(Id).TempSuffix;
+const char *types::getTypeTempSuffix(ID Id) {
+ return getInfo(Id).TempSuffix;
}
-bool types::onlyAssembleType(ID Id) {
- return strchr(getInfo(Id).Flags, 'a');
+bool types::onlyAssembleType(ID Id) {
+ return strchr(getInfo(Id).Flags, 'a');
}
-bool types::onlyPrecompileType(ID Id) {
- return strchr(getInfo(Id).Flags, 'p');
+bool types::onlyPrecompileType(ID Id) {
+ return strchr(getInfo(Id).Flags, 'p');
}
-bool types::canTypeBeUserSpecified(ID Id) {
- return strchr(getInfo(Id).Flags, 'u');
+bool types::canTypeBeUserSpecified(ID Id) {
+ return strchr(getInfo(Id).Flags, 'u');
}
-bool types::appendSuffixForType(ID Id) {
- return strchr(getInfo(Id).Flags, 'A');
+bool types::appendSuffixForType(ID Id) {
+ return strchr(getInfo(Id).Flags, 'A');
}
-bool types::canLipoType(ID Id) {
+bool types::canLipoType(ID Id) {
return (Id == TY_Nothing ||
Id == TY_Image ||
- Id == TY_Object);
+ Id == TY_Object);
}
bool types::isAcceptedByClang(ID Id) {
@@ -154,7 +154,7 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
for (unsigned i=0; i<numTypes; ++i) {
types::ID Id = (types::ID) (i + 1);
- if (canTypeBeUserSpecified(Id) &&
+ if (canTypeBeUserSpecified(Id) &&
memcmp(Name, getInfo(Id).Name, N + 1) == 0)
return Id;
}
@@ -164,25 +164,25 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
// FIXME: Why don't we just put this list in the defs file, eh.
-unsigned types::getNumCompilationPhases(ID Id) {
+unsigned types::getNumCompilationPhases(ID Id) {
if (Id == TY_Object)
return 1;
-
+
unsigned N = 0;
if (getPreprocessedType(Id) != TY_INVALID)
N += 1;
-
+
if (onlyAssembleType(Id))
return N + 2; // assemble, link
if (onlyPrecompileType(Id))
return N + 1; // precompile
-
+
return N + 3; // compile, assemble, link
}
phases::ID types::getCompilationPhase(ID Id, unsigned N) {
assert(N < getNumCompilationPhases(Id) && "Invalid index.");
-
+
if (Id == TY_Object)
return phases::Link;
@@ -202,6 +202,6 @@ phases::ID types::getCompilationPhase(ID Id, unsigned N) {
return phases::Compile;
if (N == 1)
return phases::Assemble;
-
+
return phases::Link;
}
diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp
index 178f1bf8e1..954ebd6997 100644
--- a/lib/Frontend/ASTConsumers.cpp
+++ b/lib/Frontend/ASTConsumers.cpp
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/ASTConsumers.h"
-#include "clang/Frontend/DocumentXML.h"
+#include "clang/Frontend/DocumentXML.h"
#include "clang/Frontend/PathDiagnosticClients.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
@@ -37,11 +37,11 @@ namespace {
class ASTPrinter : public ASTConsumer {
llvm::raw_ostream &Out;
bool Dump;
-
+
public:
- ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false)
+ ASTPrinter(llvm::raw_ostream* o = NULL, bool Dump = false)
: Out(o? *o : llvm::errs()), Dump(Dump) { }
-
+
virtual void HandleTranslationUnit(ASTContext &Context) {
PrintingPolicy Policy = Context.PrintingPolicy;
Policy.Dump = Dump;
@@ -63,21 +63,19 @@ namespace {
public:
ASTPrinterXML(llvm::raw_ostream& o) : Doc("CLANG_XML", o) {}
-
+
void Initialize(ASTContext &Context) {
Doc.initialize(Context);
}
virtual void HandleTranslationUnit(ASTContext &Ctx) {
Doc.addSubNode("TranslationUnit");
- for (DeclContext::decl_iterator
+ for (DeclContext::decl_iterator
D = Ctx.getTranslationUnitDecl()->decls_begin(),
DEnd = Ctx.getTranslationUnitDecl()->decls_end();
- D != DEnd;
+ D != DEnd;
++D)
- {
Doc.PrintDecl(*D);
- }
Doc.toParent();
Doc.finalize();
}
@@ -88,9 +86,9 @@ namespace {
ASTConsumer *clang::CreateASTPrinterXML(llvm::raw_ostream* out) {
return new ASTPrinterXML(out ? *out : llvm::outs());
}
-
-ASTConsumer *clang::CreateASTDumper() {
- return new ASTPrinter(0, true);
+
+ASTConsumer *clang::CreateASTDumper() {
+ return new ASTPrinter(0, true);
}
//===----------------------------------------------------------------------===//
@@ -108,7 +106,7 @@ namespace {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
HandleTopLevelSingleDecl(*I);
}
-
+
void HandleTopLevelSingleDecl(Decl *D);
};
}
@@ -116,7 +114,7 @@ namespace {
void ASTViewer::HandleTopLevelSingleDecl(Decl *D) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
FD->print(llvm::errs());
-
+
if (FD->getBodyIfAvailable()) {
llvm::errs() << '\n';
FD->getBodyIfAvailable()->viewAST();
@@ -124,10 +122,10 @@ void ASTViewer::HandleTopLevelSingleDecl(Decl *D) {
}
return;
}
-
+
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
MD->print(llvm::errs());
-
+
if (MD->getBody()) {
llvm::errs() << '\n';
MD->getBody()->viewAST();
@@ -157,7 +155,7 @@ public:
};
} // end anonymous namespace
-void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
+void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
unsigned Indentation) {
// Print DeclContext name.
switch (DC->getDeclKind()) {
@@ -231,7 +229,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
// Print the parameters.
Out << "(";
bool PrintComma = false;
- for (FunctionDecl::param_const_iterator I = FD->param_begin(),
+ for (FunctionDecl::param_const_iterator I = FD->param_begin(),
E = FD->param_end(); I != E; ++I) {
if (PrintComma)
Out << ", ";
@@ -254,7 +252,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
// Print the parameters.
Out << "(";
bool PrintComma = false;
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
+ for (FunctionDecl::param_const_iterator I = D->param_begin(),
E = D->param_end(); I != E; ++I) {
if (PrintComma)
Out << ", ";
@@ -284,7 +282,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
// Print the parameters.
Out << "(";
bool PrintComma = false;
- for (FunctionDecl::param_const_iterator I = D->param_begin(),
+ for (FunctionDecl::param_const_iterator I = D->param_begin(),
E = D->param_end(); I != E; ++I) {
if (PrintComma)
Out << ", ";
@@ -354,7 +352,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
case Decl::CXXRecord:
case Decl::ObjCMethod:
case Decl::ObjCInterface:
- case Decl::ObjCCategory:
+ case Decl::ObjCCategory:
case Decl::ObjCProtocol:
case Decl::ObjCImplementation:
case Decl::ObjCCategoryImpl:
@@ -416,8 +414,8 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
}
}
}
-ASTConsumer *clang::CreateDeclContextPrinter() {
- return new DeclContextPrinter();
+ASTConsumer *clang::CreateDeclContextPrinter() {
+ return new DeclContextPrinter();
}
//===----------------------------------------------------------------------===//
@@ -428,7 +426,7 @@ class InheritanceViewer : public ASTConsumer {
const std::string clsname;
public:
InheritanceViewer(const std::string& cname) : clsname(cname) {}
-
+
void HandleTranslationUnit(ASTContext &C) {
for (ASTContext::type_iterator I=C.types_begin(),E=C.types_end(); I!=E; ++I)
if (RecordType *T = dyn_cast<RecordType>(*I)) {
@@ -436,12 +434,12 @@ public:
// FIXME: This lookup needs to be generalized to handle namespaces and
// (when we support them) templates.
if (D->getNameAsString() == clsname) {
- D->viewInheritance(C);
+ D->viewInheritance(C);
}
}
}
}
-};
+};
}
ASTConsumer *clang::CreateInheritanceViewer(const std::string& clsname) {
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 4cd92808f5..609889aad9 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -38,38 +38,38 @@ class VISIBILITY_HIDDEN PCHInfoCollector : public PCHReaderListener {
std::string &TargetTriple;
std::string &Predefines;
unsigned &Counter;
-
+
unsigned NumHeaderInfos;
-
+
public:
PCHInfoCollector(LangOptions &LangOpt, HeaderSearch &HSI,
std::string &TargetTriple, std::string &Predefines,
unsigned &Counter)
: LangOpt(LangOpt), HSI(HSI), TargetTriple(TargetTriple),
Predefines(Predefines), Counter(Counter), NumHeaderInfos(0) {}
-
+
virtual bool ReadLanguageOptions(const LangOptions &LangOpts) {
LangOpt = LangOpts;
return false;
}
-
+
virtual bool ReadTargetTriple(const std::string &Triple) {
TargetTriple = Triple;
return false;
}
-
- virtual bool ReadPredefinesBuffer(const char *PCHPredef,
+
+ virtual bool ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines) {
Predefines = PCHPredef;
return false;
}
-
+
virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI) {
HSI.setHeaderFileInfoForUID(HFI, NumHeaderInfos++);
}
-
+
virtual void ReadCounter(unsigned Value) {
Counter = Value;
}
@@ -88,7 +88,7 @@ FileManager &ASTUnit::getFileManager() {
ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
FileManager &FileMgr,
std::string *ErrMsg) {
-
+
llvm::OwningPtr<ASTUnit> AST(new ASTUnit());
AST->DiagClient.reset(new TextDiagnosticBuffer());
@@ -96,12 +96,12 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
AST->HeaderInfo.reset(new HeaderSearch(FileMgr));
AST->SourceMgr.reset(new SourceManager());
-
+
Diagnostic &Diags = *AST->Diags.get();
SourceManager &SourceMgr = *AST->SourceMgr.get();
// Gather Info for preprocessor construction later on.
-
+
LangOptions LangInfo;
HeaderSearch &HeaderInfo = *AST->HeaderInfo.get();
std::string TargetTriple;
@@ -118,16 +118,16 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
switch (Reader->ReadPCH(Filename)) {
case PCHReader::Success:
break;
-
+
case PCHReader::Failure:
case PCHReader::IgnorePCH:
if (ErrMsg)
*ErrMsg = "Could not load PCH file";
return NULL;
}
-
+
// PCH loaded successfully. Now create the preprocessor.
-
+
// Get information about the target being compiled for.
AST->Target.reset(TargetInfo::CreateTargetInfo(TargetTriple));
AST->PP.reset(new Preprocessor(Diags, LangInfo, *AST->Target.get(),
@@ -137,7 +137,7 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
PP.setPredefines(Predefines);
PP.setCounterValue(Counter);
Reader->setPreprocessor(PP);
-
+
// Create and initialize the ASTContext.
AST->Ctx.reset(new ASTContext(LangInfo,
@@ -149,14 +149,14 @@ ASTUnit *ASTUnit::LoadFromPCHFile(const std::string &Filename,
/* FreeMemory = */ true,
/* size_reserve = */0));
ASTContext &Context = *AST->Ctx.get();
-
+
Reader->InitializeContext(Context);
-
+
// Attach the PCH reader to the AST context as an external AST
// source, so that declarations will be deserialized from the
// PCH file as needed.
Source.reset(Reader.take());
Context.setExternalSource(Source);
- return AST.take();
+ return AST.take();
}
diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp
index a633a62df2..2d07d89e04 100644
--- a/lib/Frontend/AnalysisConsumer.cpp
+++ b/lib/Frontend/AnalysisConsumer.cpp
@@ -44,7 +44,7 @@ static ExplodedNode::Auditor* CreateUbiViz();
// Basic type definitions.
//===----------------------------------------------------------------------===//
-namespace {
+namespace {
typedef void (*CodeAction)(AnalysisManager& Mgr);
} // end anonymous namespace
@@ -55,8 +55,8 @@ namespace {
static PathDiagnosticClient*
CreatePlistHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP,
PreprocessorFactory* PPF) {
- llvm::sys::Path F(prefix);
- PathDiagnosticClientFactory *PF =
+ llvm::sys::Path F(prefix);
+ PathDiagnosticClientFactory *PF =
CreateHTMLDiagnosticClientFactory(F.getDirname(), PP, PPF);
return CreatePlistDiagnosticClient(prefix, PP, PPF, PF);
}
@@ -73,9 +73,9 @@ namespace {
Actions ObjCMethodActions;
Actions ObjCImplementationActions;
Actions TranslationUnitActions;
-
+
public:
- const LangOptions& LOpts;
+ const LangOptions& LOpts;
Diagnostic &Diags;
ASTContext* Ctx;
Preprocessor* PP;
@@ -127,7 +127,7 @@ namespace {
#include "clang/Frontend/Analyses.def"
}
}
-
+
if (ManagerRegistry::ConstraintMgrCreator != 0)
CreateConstraintMgr = ManagerRegistry::ConstraintMgrCreator;
else {
@@ -140,42 +140,42 @@ namespace {
}
}
}
-
+
void addCodeAction(CodeAction action) {
FunctionActions.push_back(action);
ObjCMethodActions.push_back(action);
}
-
+
void addObjCImplementationAction(CodeAction action) {
ObjCImplementationActions.push_back(action);
}
-
+
void addTranslationUnitAction(CodeAction action) {
TranslationUnitActions.push_back(action);
}
-
+
virtual void Initialize(ASTContext &Context) {
Ctx = &Context;
- Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD,
+ Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD,
CreateStoreMgr, CreateConstraintMgr,
- Opts.AnalyzerDisplayProgress,
- Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
+ Opts.AnalyzerDisplayProgress,
+ Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
Opts.PurgeDead, Opts.EagerlyAssume,
Opts.TrimGraph));
}
-
+
virtual void HandleTopLevelDecl(DeclGroupRef D) {
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
HandleTopLevelSingleDecl(*I);
}
-
+
void HandleTopLevelSingleDecl(Decl *D);
virtual void HandleTranslationUnit(ASTContext &C);
-
+
void HandleCode(Decl* D, Stmt* Body, Actions& actions);
};
-
-
+
+
} // end anonymous namespace
@@ -184,54 +184,54 @@ namespace llvm {
static inline void Profile(CodeAction X, FoldingSetNodeID& ID) {
ID.AddPointer(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(X)));
}
- };
+ };
}
//===----------------------------------------------------------------------===//
// AnalysisConsumer implementation.
//===----------------------------------------------------------------------===//
-void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
+void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
switch (D->getKind()) {
case Decl::Function: {
FunctionDecl* FD = cast<FunctionDecl>(D);
- if (Opts.AnalyzeSpecificFunction.size() > 0 &&
+ if (Opts.AnalyzeSpecificFunction.size() > 0 &&
Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName())
break;
-
+
Stmt* Body = FD->getBody();
if (Body) HandleCode(FD, Body, FunctionActions);
break;
}
-
+
case Decl::ObjCMethod: {
ObjCMethodDecl* MD = cast<ObjCMethodDecl>(D);
-
+
if (Opts.AnalyzeSpecificFunction.size() > 0 &&
Opts.AnalyzeSpecificFunction != MD->getSelector().getAsString())
return;
-
+
Stmt* Body = MD->getBody();
if (Body) HandleCode(MD, Body, ObjCMethodActions);
break;
}
-
+
default:
break;
}
}
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
- if(!TranslationUnitActions.empty()) {
- for (Actions::iterator I = TranslationUnitActions.begin(),
+ if (!TranslationUnitActions.empty()) {
+ for (Actions::iterator I = TranslationUnitActions.begin(),
E = TranslationUnitActions.end(); I != E; ++I)
- (*I)(*Mgr);
+ (*I)(*Mgr);
}
if (!ObjCImplementationActions.empty()) {
TranslationUnitDecl *TUD = C.getTranslationUnitDecl();
-
+
for (DeclContext::decl_iterator I = TUD->decls_begin(),
E = TUD->decls_end();
I != E; ++I)
@@ -246,7 +246,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
}
void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
-
+
// Don't run the actions if an error has occured with parsing the file.
if (Diags.hasErrorOccurred())
return;
@@ -255,13 +255,13 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
// otherwise specified.
if (!Opts.AnalyzeAll &&
!Ctx->getSourceManager().isFromMainFile(D->getLocation()))
- return;
+ return;
Mgr->setEntryContext(D);
-
- // Dispatch on the actions.
+
+ // Dispatch on the actions.
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)
- (*I)(*Mgr);
+ (*I)(*Mgr);
}
//===----------------------------------------------------------------------===//
@@ -283,8 +283,8 @@ static void ActionWarnUninitVals(AnalysisManager& mgr) {
static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf,
bool StandardWarnings = true) {
-
-
+
+
llvm::OwningPtr<GRTransferFuncs> TF(tf);
// Display progress.
@@ -297,7 +297,7 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf,
GRExprEngine Eng(mgr);
Eng.setTransferFunctions(tf);
-
+
if (StandardWarnings) {
Eng.RegisterInternalChecks();
RegisterAppleChecks(Eng, *mgr.getCodeDecl());
@@ -309,10 +309,10 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf,
Auditor.reset(CreateUbiViz());
ExplodedNode::SetAuditor(Auditor.get());
}
-
+
// Execute the worklist algorithm.
Eng.ExecuteWorkList(mgr.getEntryStackFrame());
-
+
// Release the auditor (if any) so that it doesn't monitor the graph
// created BugReporter.
ExplodedNode::SetAuditor(0);
@@ -320,34 +320,34 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf,
// Visualize the exploded graph.
if (mgr.shouldVisualizeGraphviz())
Eng.ViewGraph(mgr.shouldTrimGraph());
-
+
// Display warnings.
Eng.getBugReporter().FlushReports();
}
static void ActionCheckerCFRefAux(AnalysisManager& mgr, bool GCEnabled,
bool StandardWarnings) {
-
+
GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getASTContext(),
GCEnabled,
mgr.getLangOptions());
-
+
ActionGRExprEngine(mgr, TF, StandardWarnings);
}
static void ActionCheckerCFRef(AnalysisManager& mgr) {
-
+
switch (mgr.getLangOptions().getGCMode()) {
default:
assert (false && "Invalid GC mode.");
case LangOptions::NonGC:
ActionCheckerCFRefAux(mgr, false, true);
break;
-
+
case LangOptions::GCOnly:
ActionCheckerCFRefAux(mgr, true, true);
break;
-
+
case LangOptions::HybridGC:
ActionCheckerCFRefAux(mgr, false, true);
ActionCheckerCFRefAux(mgr, true, false);
@@ -357,7 +357,7 @@ static void ActionCheckerCFRef(AnalysisManager& mgr) {
static void ActionDisplayLiveVariables(AnalysisManager& mgr) {
if (LiveVariables* L = mgr.getLiveVariables()) {
- mgr.DisplayFunction();
+ mgr.DisplayFunction();
L->dumpBlockLiveness(mgr.getSourceManager());
}
}
@@ -377,28 +377,28 @@ static void ActionCFGView(AnalysisManager& mgr) {
}
static void ActionSecuritySyntacticChecks(AnalysisManager &mgr) {
- BugReporter BR(mgr);
+ BugReporter BR(mgr);
CheckSecuritySyntaxOnly(mgr.getCodeDecl(), BR);
}
static void ActionWarnObjCDealloc(AnalysisManager& mgr) {
if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly)
return;
-
+
BugReporter BR(mgr);
-
- CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()),
- mgr.getLangOptions(), BR);
+
+ CheckObjCDealloc(cast<ObjCImplementationDecl>(mgr.getCodeDecl()),
+ mgr.getLangOptions(), BR);
}
static void ActionWarnObjCUnusedIvars(AnalysisManager& mgr) {
BugReporter BR(mgr);
- CheckObjCUnusedIvar(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR);
+ CheckObjCUnusedIvar(cast<ObjCImplementationDecl>(mgr.getCodeDecl()), BR);
}
static void ActionWarnObjCMethSigs(AnalysisManager& mgr) {
BugReporter BR(mgr);
-
+
CheckObjCInstMethSignature(cast<ObjCImplementationDecl>(mgr.getCodeDecl()),
BR);
}
@@ -426,7 +426,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
#include "clang/Frontend/Analyses.def"
default: break;
}
-
+
// Last, disable the effects of '-Werror' when using the AnalysisConsumer.
diags.setWarningsAsErrors(false);
@@ -438,7 +438,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
//===----------------------------------------------------------------------===//
namespace {
-
+
class UbigraphViz : public ExplodedNode::Auditor {
llvm::OwningPtr<llvm::raw_ostream> Out;
llvm::sys::Path Dir, Filename;
@@ -446,21 +446,21 @@ class UbigraphViz : public ExplodedNode::Auditor {
typedef llvm::DenseMap<void*,unsigned> VMap;
VMap M;
-
+
public:
UbigraphViz(llvm::raw_ostream* out, llvm::sys::Path& dir,
llvm::sys::Path& filename);
-
+
~UbigraphViz();
-
- virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst);
+
+ virtual void AddEdge(ExplodedNode* Src, ExplodedNode* Dst);
};
-
+
} // end anonymous namespace
static ExplodedNode::Auditor* CreateUbiViz() {
std::string ErrMsg;
-
+
llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg);
if (!ErrMsg.empty())
return 0;
@@ -473,31 +473,31 @@ static ExplodedNode::Auditor* CreateUbiViz() {
return 0;
llvm::errs() << "Writing '" << Filename.str() << "'.\n";
-
+
llvm::OwningPtr<llvm::raw_fd_ostream> Stream;
Stream.reset(new llvm::raw_fd_ostream(Filename.c_str(), ErrMsg));
if (!ErrMsg.empty())
return 0;
-
+
return new UbigraphViz(Stream.take(), Dir, Filename);
}
void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) {
-
+
assert (Src != Dst && "Self-edges are not allowed.");
-
+
// Lookup the Src. If it is a new node, it's a root.
VMap::iterator SrcI= M.find(Src);
unsigned SrcID;
-
+
if (SrcI == M.end()) {
M[Src] = SrcID = Cntr++;
*Out << "('vertex', " << SrcID << ", ('color','#00ff00'))\n";
}
else
SrcID = SrcI->second;
-
+
// Lookup the Dst.
VMap::iterator DstI= M.find(Dst);
unsigned DstID;
@@ -513,7 +513,7 @@ void UbigraphViz::AddEdge(ExplodedNode* Src, ExplodedNode* Dst) {
}
// Add the edge.
- *Out << "('edge', " << SrcID << ", " << DstID
+ *Out << "('edge', " << SrcID << ", " << DstID
<< ", ('arrow','true'), ('oriented', 'true'))\n";
}
@@ -535,11 +535,11 @@ UbigraphViz::~UbigraphViz() {
args.push_back(Ubiviz.c_str());
args.push_back(Filename.c_str());
args.push_back(0);
-
+
if (llvm::sys::Program::ExecuteAndWait(Ubiviz, &args[0],0,0,0,0,&ErrMsg)) {
llvm::errs() << "Error viewing graph: " << ErrMsg << "\n";
}
-
+
// Delete the directory.
- Dir.eraseFromDisk(true);
+ Dir.eraseFromDisk(true);
}
diff --git a/lib/Frontend/Backend.cpp b/lib/Frontend/Backend.cpp
index 964b4700fe..d7097b7f06 100644
--- a/lib/Frontend/Backend.cpp
+++ b/lib/Frontend/Backend.cpp
@@ -47,9 +47,9 @@ namespace {
Timer LLVMIRGeneration;
Timer CodeGenerationTime;
-
+
llvm::OwningPtr<CodeGenerator> Gen;
-
+
llvm::Module *TheModule;
llvm::TargetData *TheTargetData;
@@ -72,13 +72,13 @@ namespace {
bool AddEmitPasses(std::string &Error);
void EmitAssembly();
-
- public:
- BackendConsumer(BackendAction action, Diagnostic &Diags,
+
+ public:
+ BackendConsumer(BackendAction action, Diagnostic &Diags,
const LangOptions &langopts, const CompileOptions &compopts,
const std::string &infile, llvm::raw_ostream* OS,
LLVMContext& C) :
- Action(action),
+ Action(action),
CompileOpts(compopts),
AsmOutStream(OS),
LLVMIRGeneration("LLVM IR Generation Time"),
@@ -86,11 +86,11 @@ namespace {
Gen(CreateLLVMCodeGen(Diags, infile, compopts, C)),
TheModule(0), TheTargetData(0), ModuleProvider(0),
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
-
+
if (AsmOutStream)
FormattedOutStream.setStream(*AsmOutStream,
formatted_raw_ostream::PRESERVE_STREAM);
-
+
// Enable -time-passes if -ftime-report is enabled.
llvm::TimePassesIsEnabled = CompileOpts.TimePasses;
}
@@ -105,25 +105,25 @@ namespace {
virtual void Initialize(ASTContext &Ctx) {
Context = &Ctx;
-
+
if (CompileOpts.TimePasses)
LLVMIRGeneration.startTimer();
-
+
Gen->Initialize(Ctx);
TheModule = Gen->GetModule();
ModuleProvider = new ExistingModuleProvider(TheModule);
TheTargetData = new llvm::TargetData(Ctx.Target.getTargetDescription());
-
+
if (CompileOpts.TimePasses)
LLVMIRGeneration.stopTimer();
}
-
+
virtual void HandleTopLevelDecl(DeclGroupRef D) {
PrettyStackTraceDecl CrashInfo(*D.begin(), SourceLocation(),
Context->getSourceManager(),
"LLVM IR generation of declaration");
-
+
if (CompileOpts.TimePasses)
LLVMIRGeneration.startTimer();
@@ -132,7 +132,7 @@ namespace {
if (CompileOpts.TimePasses)
LLVMIRGeneration.stopTimer();
}
-
+
virtual void HandleTranslationUnit(ASTContext &C) {
{
PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
@@ -147,12 +147,12 @@ namespace {
// EmitAssembly times and registers crash info itself.
EmitAssembly();
-
+
// Force a flush here in case we never get released.
if (AsmOutStream)
FormattedOutStream.flush();
}
-
+
virtual void HandleTagDeclDefinition(TagDecl *D) {
PrettyStackTraceDecl CrashInfo(D, SourceLocation(),
Context->getSourceManager(),
@@ -163,7 +163,7 @@ namespace {
virtual void CompleteTentativeDefinition(VarDecl *D) {
Gen->CompleteTentativeDefinition(D);
}
- };
+ };
}
FunctionPassManager *BackendConsumer::getCodeGenPasses() const {
@@ -216,18 +216,18 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) {
if (CompileOpts.CPU.size() || CompileOpts.Features.size()) {
SubtargetFeatures Features;
Features.setCPU(CompileOpts.CPU);
- for (std::vector<std::string>::iterator
+ for (std::vector<std::string>::iterator
it = CompileOpts.Features.begin(),
ie = CompileOpts.Features.end(); it != ie; ++it)
Features.AddFeature(*it);
FeaturesStr = Features.getString();
}
TargetMachine *TM = TheTarget->createTargetMachine(Triple, FeaturesStr);
-
+
// Set register scheduler & allocation policy.
RegisterScheduler::setDefault(createDefaultScheduler);
- RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator :
- createLinearScanRegisterAllocator);
+ RegisterRegAlloc::setDefault(Fast ? createLocalRegisterAllocator :
+ createLinearScanRegisterAllocator);
// From llvm-gcc:
// If there are passes we have to run on the entire module, we do codegen
@@ -254,7 +254,7 @@ bool BackendConsumer::AddEmitPasses(std::string &Error) {
case FileModel::AsmFile:
break;
}
-
+
if (TM->addPassesToEmitFileFinish(*CodeGenPasses, (MachineCodeEmitter *)0,
OptLevel)) {
Error = "Unable to interface with target machine!\n";
@@ -292,8 +292,8 @@ void BackendConsumer::CreatePasses() {
// For now we always create per module passes.
PassManager *PM = getPerModulePasses();
- llvm::createStandardModulePasses(PM, CompileOpts.OptimizationLevel,
- CompileOpts.OptimizeSize,
+ llvm::createStandardModulePasses(PM, CompileOpts.OptimizationLevel,
+ CompileOpts.OptimizeSize,
CompileOpts.UnitAtATime,
CompileOpts.UnrollLoops,
CompileOpts.SimplifyLibCalls,
@@ -302,12 +302,12 @@ void BackendConsumer::CreatePasses() {
}
/// EmitAssembly - Handle interaction with LLVM backend to generate
-/// actual machine code.
+/// actual machine code.
void BackendConsumer::EmitAssembly() {
// Silently ignore if we weren't initialized for some reason.
if (!TheModule || !TheTargetData)
return;
-
+
TimeRegion Region(CompileOpts.TimePasses ? &CodeGenerationTime : 0);
// Make sure IR generation is happy with the module. This is
@@ -337,19 +337,19 @@ void BackendConsumer::EmitAssembly() {
if (PerFunctionPasses) {
PrettyStackTraceString CrashInfo("Per-function optimization");
-
+
PerFunctionPasses->doInitialization();
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
if (!I->isDeclaration())
PerFunctionPasses->run(*I);
PerFunctionPasses->doFinalization();
}
-
+
if (PerModulePasses) {
PrettyStackTraceString CrashInfo("Per-module optimization passes");
PerModulePasses->run(*M);
}
-
+
if (CodeGenPasses) {
PrettyStackTraceString CrashInfo("Code generation");
CodeGenPasses->doInitialization();
diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp
index 7365882eb8..e7fc5660ad 100644
--- a/lib/Frontend/CacheTokens.cpp
+++ b/lib/Frontend/CacheTokens.cpp
@@ -40,19 +40,19 @@ using namespace clang::io;
namespace {
class VISIBILITY_HIDDEN PTHEntry {
- Offset TokenData, PPCondData;
+ Offset TokenData, PPCondData;
-public:
+public:
PTHEntry() {}
PTHEntry(Offset td, Offset ppcd)
: TokenData(td), PPCondData(ppcd) {}
-
- Offset getTokenOffset() const { return TokenData; }
+
+ Offset getTokenOffset() const { return TokenData; }
Offset getPPCondTableOffset() const { return PPCondData; }
};
-
-
+
+
class VISIBILITY_HIDDEN PTHEntryKeyVariant {
union { const FileEntry* FE; const char* Path; };
enum { IsFE = 0x1, IsDE = 0x2, IsNoExist = 0x0 } Kind;
@@ -66,15 +66,15 @@ public:
PTHEntryKeyVariant(const char* path)
: Path(path), Kind(IsNoExist), StatBuf(0) {}
-
+
bool isFile() const { return Kind == IsFE; }
-
+
const char* getCString() const {
return Kind == IsFE ? FE->getName() : Path;
}
-
+
unsigned getKind() const { return (unsigned) Kind; }
-
+
void EmitData(llvm::raw_ostream& Out) {
switch (Kind) {
case IsFE:
@@ -98,45 +98,45 @@ public:
break;
}
}
-
+
unsigned getRepresentationLength() const {
return Kind == IsNoExist ? 0 : 4 + 4 + 2 + 8 + 8;
}
};
-
+
class VISIBILITY_HIDDEN FileEntryPTHEntryInfo {
public:
typedef PTHEntryKeyVariant key_type;
typedef key_type key_type_ref;
-
+
typedef PTHEntry data_type;
typedef const PTHEntry& data_type_ref;
-
+
static unsigned ComputeHash(PTHEntryKeyVariant V) {
return BernsteinHash(V.getCString());
}
-
- static std::pair<unsigned,unsigned>
+
+ static std::pair<unsigned,unsigned>
EmitKeyDataLength(llvm::raw_ostream& Out, PTHEntryKeyVariant V,
const PTHEntry& E) {
unsigned n = strlen(V.getCString()) + 1 + 1;
::Emit16(Out, n);
-
+
unsigned m = V.getRepresentationLength() + (V.isFile() ? 4 + 4 : 0);
::Emit8(Out, m);
return std::make_pair(n, m);
}
-
+
static void EmitKey(llvm::raw_ostream& Out, PTHEntryKeyVariant V, unsigned n){
// Emit the entry kind.
::Emit8(Out, (unsigned) V.getKind());
// Emit the string.
Out.write(V.getCString(), n - 1);
}
-
- static void EmitData(llvm::raw_ostream& Out, PTHEntryKeyVariant V,
+
+ static void EmitData(llvm::raw_ostream& Out, PTHEntryKeyVariant V,
const PTHEntry& E, unsigned) {
@@ -146,12 +146,12 @@ public:
::Emit32(Out, E.getTokenOffset());
::Emit32(Out, E.getPPCondTableOffset());
}
-
+
// Emit any other data associated with the key (i.e., stat information).
V.EmitData(Out);
- }
+ }
};
-
+
class OffsetOpt {
bool valid;
Offset off;
@@ -180,16 +180,16 @@ class VISIBILITY_HIDDEN PTHWriter {
//// Get the persistent id for the given IdentifierInfo*.
uint32_t ResolveID(const IdentifierInfo* II);
-
+
/// Emit a token to the PTH file.
void EmitToken(const Token& T);
void Emit8(uint32_t V) {
Out << (unsigned char)(V);
}
-
+
void Emit16(uint32_t V) { ::Emit16(Out, V); }
-
+
void Emit24(uint32_t V) {
Out << (unsigned char)(V);
Out << (unsigned char)(V >> 8);
@@ -202,13 +202,13 @@ class VISIBILITY_HIDDEN PTHWriter {
void EmitBuf(const char *Ptr, unsigned NumBytes) {
Out.write(Ptr, NumBytes);
}
-
+
/// EmitIdentifierTable - Emits two tables to the PTH file. The first is
/// a hashtable mapping from identifier strings to persistent IDs.
/// The second is a straight table mapping from persistent IDs to string data
/// (the keys of the first table).
std::pair<Offset, Offset> EmitIdentifierTable();
-
+
/// EmitFileTable - Emit a table mapping from file name strings to PTH
/// token data.
Offset EmitFileTable() { return PM.Emit(Out); }
@@ -217,23 +217,23 @@ class VISIBILITY_HIDDEN PTHWriter {
Offset EmitCachedSpellings();
public:
- PTHWriter(llvm::raw_fd_ostream& out, Preprocessor& pp)
+ PTHWriter(llvm::raw_fd_ostream& out, Preprocessor& pp)
: Out(out), PP(pp), idcount(0), CurStrOffset(0) {}
-
+
PTHMap &getPM() { return PM; }
void GeneratePTH(const std::string *MainFile = 0);
};
} // end anonymous namespace
-
-uint32_t PTHWriter::ResolveID(const IdentifierInfo* II) {
+
+uint32_t PTHWriter::ResolveID(const IdentifierInfo* II) {
// Null IdentifierInfo's map to the persistent ID 0.
if (!II)
return 0;
-
+
IDMap::iterator I = IM.find(II);
if (I != IM.end())
return I->second; // We've already added 1.
-
+
IM[II] = ++idcount; // Pre-increment since '0' is reserved for NULL.
return idcount;
}
@@ -242,7 +242,7 @@ void PTHWriter::EmitToken(const Token& T) {
// Emit the token kind, flags, and length.
Emit32(((uint32_t) T.getKind()) | ((((uint32_t) T.getFlags())) << 8)|
(((uint32_t) T.getLength()) << 16));
-
+
if (!T.isLiteral()) {
Emit32(ResolveID(T.getIdentifierInfo()));
} else {
@@ -253,18 +253,18 @@ void PTHWriter::EmitToken(const Token& T) {
// Get the string entry.
llvm::StringMapEntry<OffsetOpt> *E = &CachedStrs.GetOrCreateValue(s, s+len);
-
+
// If this is a new string entry, bump the PTH offset.
if (!E->getValue().hasOffset()) {
E->getValue().setOffset(CurStrOffset);
StrEntries.push_back(E);
CurStrOffset += len + 1;
}
-
+
// Emit the relative offset into the PTH file for the spelling string.
Emit32(E->getValue().getOffset());
}
-
+
// Emit the offset into the original source file of this token so that we
// can reconstruct its SourceLocation.
Emit32(PP.getSourceManager().getFileOffset(T.getLocation()));
@@ -275,14 +275,14 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
// This speed up reading them back in.
Pad(Out, 4);
Offset off = (Offset) Out.tell();
-
+
// Keep track of matching '#if' ... '#endif'.
typedef std::vector<std::pair<Offset, unsigned> > PPCondTable;
PPCondTable PPCond;
std::vector<unsigned> PPStartCond;
bool ParsingPreprocessorDirective = false;
Token Tok;
-
+
do {
L.LexFromRawLexer(Tok);
NextToken:
@@ -300,7 +300,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
EmitToken(Tmp);
ParsingPreprocessorDirective = false;
}
-
+
if (Tok.is(tok::identifier)) {
Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok));
EmitToken(Tok);
@@ -320,39 +320,39 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
// If we see the start of line, then we had a null directive "#".
if (Tok.isAtStartOfLine())
goto NextToken;
-
+
// Did we see 'include'/'import'/'include_next'?
if (Tok.isNot(tok::identifier)) {
EmitToken(Tok);
continue;
}
-
+
IdentifierInfo* II = PP.LookUpIdentifierInfo(Tok);
Tok.setIdentifierInfo(II);
tok::PPKeywordKind K = II->getPPKeywordID();
-
+
ParsingPreprocessorDirective = true;
-
+
switch (K) {
case tok::pp_not_keyword:
// Invalid directives "#foo" can occur in #if 0 blocks etc, just pass
// them through.
default:
break;
-
+
case tok::pp_include:
case tok::pp_import:
- case tok::pp_include_next: {
+ case tok::pp_include_next: {
// Save the 'include' token.
EmitToken(Tok);
// Lex the next token as an include string.
L.setParsingPreprocessorDirective(true);
- L.LexIncludeFilename(Tok);
+ L.LexIncludeFilename(Tok);
L.setParsingPreprocessorDirective(false);
assert(!Tok.isAtStartOfLine());
if (Tok.is(tok::identifier))
Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok));
-
+
break;
}
case tok::pp_if:
@@ -374,11 +374,11 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
assert(PPCond.size() > PPStartCond.back());
assert(PPCond[PPStartCond.back()].second == 0);
PPCond[PPStartCond.back()].second = index;
- PPStartCond.pop_back();
- // Add the new entry to PPCond.
+ PPStartCond.pop_back();
+ // Add the new entry to PPCond.
PPCond.push_back(std::make_pair(HashOff, index));
EmitToken(Tok);
-
+
// Some files have gibberish on the same line as '#endif'.
// Discard these tokens.
do
@@ -386,7 +386,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
while (Tok.isNot(tok::eof) && !Tok.isAtStartOfLine());
// We have the next token in hand.
// Don't immediately lex the next one.
- goto NextToken;
+ goto NextToken;
}
case tok::pp_elif:
case tok::pp_else: {
@@ -407,7 +407,7 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
}
}
}
-
+
EmitToken(Tok);
}
while (Tok.isNot(tok::eof));
@@ -435,11 +435,11 @@ PTHEntry PTHWriter::LexTokens(Lexer& L) {
Offset PTHWriter::EmitCachedSpellings() {
// Write each cached strings to the PTH file.
Offset SpellingsOff = Out.tell();
-
+
for (std::vector<llvm::StringMapEntry<OffsetOpt>*>::iterator
I = StrEntries.begin(), E = StrEntries.end(); I!=E; ++I)
EmitBuf((*I)->getKeyData(), (*I)->getKeyLength()+1 /*nul included*/);
-
+
return SpellingsOff;
}
@@ -447,12 +447,12 @@ void PTHWriter::GeneratePTH(const std::string *MainFile) {
// Generate the prologue.
Out << "cfe-pth";
Emit32(PTHManager::Version);
-
+
// Leave 4 words for the prologue.
Offset PrologueOffset = Out.tell();
for (unsigned i = 0; i < 4; ++i)
Emit32(0);
-
+
// Write the name of the MainFile.
if (MainFile && !MainFile->empty()) {
Emit16(MainFile->length());
@@ -462,17 +462,17 @@ void PTHWriter::GeneratePTH(const std::string *MainFile) {
Emit16(0);
}
Emit8(0);
-
+
// Iterate over all the files in SourceManager. Create a lexer
// for each file and cache the tokens.
SourceManager &SM = PP.getSourceManager();
const LangOptions &LOpts = PP.getLangOptions();
-
+
for (SourceManager::fileinfo_iterator I = SM.fileinfo_begin(),
E = SM.fileinfo_end(); I != E; ++I) {
const SrcMgr::ContentCache &C = *I->second;
const FileEntry *FE = C.Entry;
-
+
// FIXME: Handle files with non-absolute paths.
llvm::sys::Path P(FE->getName());
if (!P.isAbsolute())
@@ -488,13 +488,13 @@ void PTHWriter::GeneratePTH(const std::string *MainFile) {
// Write out the identifier table.
const std::pair<Offset,Offset> &IdTableOff = EmitIdentifierTable();
-
+
// Write out the cached strings table.
Offset SpellingOff = EmitCachedSpellings();
-
+
// Write out the file table.
- Offset FileTableOff = EmitFileTable();
-
+ Offset FileTableOff = EmitFileTable();
+
// Finally, write the prologue.
Out.seek(PrologueOffset);
Emit32(IdTableOff.first);
@@ -514,20 +514,20 @@ class StatListener : public StatSysCallCache {
public:
StatListener(PTHMap &pm) : PM(pm) {}
~StatListener() {}
-
+
int stat(const char *path, struct stat *buf) {
int result = ::stat(path, buf);
-
+
if (result != 0) // Failed 'stat'.
PM.insert(path, PTHEntry());
else if (S_ISDIR(buf->st_mode)) {
// Only cache directories with absolute paths.
if (!llvm::sys::Path(path).isAbsolute())
return result;
-
+
PM.insert(PTHEntryKeyVariant(buf, path), PTHEntry());
}
-
+
return result;
}
};
@@ -540,7 +540,7 @@ void clang::CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS) {
const FileEntry *MainFile = SrcMgr.getFileEntryForID(SrcMgr.getMainFileID());
llvm::sys::Path MainFilePath(MainFile->getName());
std::string MainFileName;
-
+
if (!MainFilePath.isAbsolute()) {
llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory();
P.appendComponent(MainFilePath.str());
@@ -551,16 +551,16 @@ void clang::CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS) {
// Create the PTHWriter.
PTHWriter PW(*OS, PP);
-
+
// Install the 'stat' system call listener in the FileManager.
PP.getFileManager().setStatCache(new StatListener(PW.getPM()));
-
+
// Lex through the entire file. This will populate SourceManager with
// all of the header information.
Token Tok;
PP.EnterMainSourceFile();
do { PP.Lex(Tok); } while (Tok.isNot(tok::eof));
-
+
// Generate the PTH file.
PP.getFileManager().setStatCache(0);
PW.GeneratePTH(&MainFileName);
@@ -579,32 +579,32 @@ class VISIBILITY_HIDDEN PTHIdentifierTableTrait {
public:
typedef PTHIdKey* key_type;
typedef key_type key_type_ref;
-
+
typedef uint32_t data_type;
typedef data_type data_type_ref;
-
+
static unsigned ComputeHash(PTHIdKey* key) {
return BernsteinHash(key->II->getName());
}
-
- static std::pair<unsigned,unsigned>
- EmitKeyDataLength(llvm::raw_ostream& Out, const PTHIdKey* key, uint32_t) {
+
+ static std::pair<unsigned,unsigned>
+ EmitKeyDataLength(llvm::raw_ostream& Out, const PTHIdKey* key, uint32_t) {
unsigned n = strlen(key->II->getName()) + 1;
::Emit16(Out, n);
return std::make_pair(n, sizeof(uint32_t));
}
-
+
static void EmitKey(llvm::raw_ostream& Out, PTHIdKey* key, unsigned n) {
// Record the location of the key data. This is used when generating
// the mapping from persistent IDs to strings.
key->FileOffset = Out.tell();
Out.write(key->II->getName(), n);
}
-
+
static void EmitData(llvm::raw_ostream& Out, PTHIdKey*, uint32_t pID,
unsigned) {
::Emit32(Out, pID);
- }
+ }
};
} // end anonymous namespace
@@ -623,7 +623,7 @@ std::pair<Offset,Offset> PTHWriter::EmitIdentifierTable() {
// Create the hashtable.
OnDiskChainedHashTableGenerator<PTHIdentifierTableTrait> IIOffMap;
-
+
// Generate mapping from persistent IDs -> IdentifierInfo*.
for (IDMap::iterator I = IM.begin(), E = IM.end(); I != E; ++I) {
// Decrement by 1 because we are using a vector for the lookup and
@@ -631,27 +631,27 @@ std::pair<Offset,Offset> PTHWriter::EmitIdentifierTable() {
assert(I->second > 0);
assert(I->second-1 < idcount);
unsigned idx = I->second-1;
-
+
// Store the mapping from persistent ID to IdentifierInfo*
IIDMap[idx].II = I->first;
-
+
// Store the reverse mapping in a hashtable.
IIOffMap.insert(&IIDMap[idx], I->second);
}
-
+
// Write out the inverse map first. This causes the PCIDKey entries to
// record PTH file offsets for the string data. This is used to write
// the second table.
Offset StringTableOffset = IIOffMap.Emit(Out);
-
- // Now emit the table mapping from persistent IDs to PTH file offsets.
+
+ // Now emit the table mapping from persistent IDs to PTH file offsets.
Offset IDOff = Out.tell();
Emit32(idcount); // Emit the number of identifiers.
for (unsigned i = 0 ; i < idcount; ++i)
Emit32(IIDMap[i].FileOffset);
-
+
// Finally, release the inverse map.
free(IIDMap);
-
+
return std::make_pair(IDOff, StringTableOffset);
}
diff --git a/lib/Frontend/DeclXML.cpp b/lib/Frontend/DeclXML.cpp
index 68f931fb6c..b981fc41da 100644
--- a/lib/Frontend/DeclXML.cpp
+++ b/lib/Frontend/DeclXML.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the XML document class, which provides the means to
+// This file implements the XML document class, which provides the means to
// dump out the AST in a XML form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
@@ -18,22 +18,18 @@
namespace clang {
-//---------------------------------------------------------
-class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter>
-{
+//---------------------------------------------------------
+class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter> {
DocumentXML& Doc;
- void addSubNodes(FunctionDecl* FD)
- {
- for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i)
- {
+ void addSubNodes(FunctionDecl* FD) {
+ for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
Visit(FD->getParamDecl(i));
Doc.toParent();
}
}
- void addSubNodes(RecordDecl* RD)
- {
+ void addSubNodes(RecordDecl* RD) {
for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
Visit(*i);
@@ -41,8 +37,7 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter>
}
}
- void addSubNodes(EnumDecl* ED)
- {
+ void addSubNodes(EnumDecl* ED) {
for (EnumDecl::enumerator_iterator i = ED->enumerator_begin(),
e = ED->enumerator_end(); i != e; ++i) {
Visit(*i);
@@ -50,54 +45,37 @@ class DocumentXML::DeclPrinter : public DeclVisitor<DocumentXML::DeclPrinter>
}
}
- void addSubNodes(EnumConstantDecl* ECD)
- {
- if (ECD->getInitExpr())
- {
+ void addSubNodes(EnumConstantDecl* ECD) {
+ if (ECD->getInitExpr())
Doc.PrintStmt(ECD->getInitExpr());
- }
}
- void addSubNodes(FieldDecl* FdD)
- {
+ void addSubNodes(FieldDecl* FdD) {
if (FdD->isBitField())
- {
Doc.PrintStmt(FdD->getBitWidth());
- }
}
- void addSubNodes(VarDecl* V)
- {
- if (V->getInit())
- {
+ void addSubNodes(VarDecl* V) {
+ if (V->getInit())
Doc.PrintStmt(V->getInit());
- }
}
- void addSubNodes(ParmVarDecl* argDecl)
- {
+ void addSubNodes(ParmVarDecl* argDecl) {
if (argDecl->getDefaultArg())
- {
Doc.PrintStmt(argDecl->getDefaultArg());
- }
}
- void addSpecialAttribute(const char* pName, EnumDecl* ED)
- {
+ void addSpecialAttribute(const char* pName, EnumDecl* ED) {
const QualType& enumType = ED->getIntegerType();
if (!enumType.isNull())
- {
Doc.addAttribute(pName, enumType);
- }
}
- void addIdAttribute(LinkageSpecDecl* ED)
- {
+ void addIdAttribute(LinkageSpecDecl* ED) {
Doc.addAttribute("id", ED);
}
- void addIdAttribute(NamedDecl* ND)
- {
+ void addIdAttribute(NamedDecl* ND) {
Doc.addAttribute("id", ND);
}
@@ -107,11 +85,11 @@ public:
#define NODE_XML( CLASS, NAME ) \
void Visit##CLASS(CLASS* T) \
{ \
- Doc.addSubNode(NAME);
+ Doc.addSubNode(NAME);
#define ID_ATTRIBUTE_XML addIdAttribute(T);
-#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, T->FN);
-#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, T->FN);
+#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, T->FN);
+#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, T->FN);
#define ATTRIBUTE_FILE_LOCATION_XML Doc.addLocation(T->getLocation());
#define ATTRIBUTE_SPECIAL_XML( FN, NAME ) addSpecialAttribute(NAME, T);
@@ -120,14 +98,14 @@ public:
const char* pAttributeName = NAME; \
const bool optional = false; \
switch (T->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME ) \
{ \
const char* pAttributeName = NAME; \
const bool optional = true; \
switch (T->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ENUM_XML( VALUE, NAME ) case VALUE: if ((!optional) || NAME[0]) Doc.addAttribute(pAttributeName, NAME); break;
#define END_ENUM_XML } }
@@ -141,12 +119,10 @@ public:
};
-//---------------------------------------------------------
-void DocumentXML::writeDeclToXML(Decl *D)
-{
+//---------------------------------------------------------
+void DocumentXML::writeDeclToXML(Decl *D) {
DeclPrinter(*this).Visit(D);
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
- {
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (Stmt *Body = FD->getBody()) {
addSubNode("Body");
PrintStmt(Body);
@@ -156,6 +132,6 @@ void DocumentXML::writeDeclToXML(Decl *D)
toParent();
}
-//---------------------------------------------------------
+//---------------------------------------------------------
} // NS clang
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index c8a654cff2..81d1179f28 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -40,8 +40,8 @@ private:
void OutputDependencyFile();
public:
- DependencyFileCallback(const Preprocessor *_PP,
- llvm::raw_ostream *_OS,
+ DependencyFileCallback(const Preprocessor *_PP,
+ llvm::raw_ostream *_OS,
const std::vector<std::string> &_Targets,
bool _IncludeSystemHeaders,
bool _PhonyTarget)
@@ -67,8 +67,8 @@ void clang::AttachDependencyFileGen(Preprocessor *PP, llvm::raw_ostream *OS,
bool PhonyTarget) {
assert(!Targets.empty() && "Target required for dependency generation");
- DependencyFileCallback *PPDep =
- new DependencyFileCallback(PP, OS, Targets, IncludeSystemHeaders,
+ DependencyFileCallback *PPDep =
+ new DependencyFileCallback(PP, OS, Targets, IncludeSystemHeaders,
PhonyTarget);
PP->setPPCallbacks(PPDep);
}
@@ -91,16 +91,16 @@ void DependencyFileCallback::FileChanged(SourceLocation Loc,
SrcMgr::CharacteristicKind FileType) {
if (Reason != PPCallbacks::EnterFile)
return;
-
+
// Dependency generation really does want to go all the way to the
// file entry for a source location to find out what is depended on.
// We do not want #line markers to affect dependency generation!
SourceManager &SM = PP->getSourceManager();
-
+
const FileEntry *FE =
SM.getFileEntryForID(SM.getFileID(SM.getInstantiationLoc(Loc)));
if (FE == 0) return;
-
+
const char *Filename = FE->getName();
if (!FileMatchesDepCriteria(Filename, FileType))
return;
@@ -138,7 +138,7 @@ void DependencyFileCallback::OutputDependencyFile() {
*OS << ':';
Columns += 1;
-
+
// Now add each dependency in the order it was seen, but avoiding
// duplicates.
for (std::vector<std::string>::iterator I = Files.begin(),
diff --git a/lib/Frontend/DiagChecker.cpp b/lib/Frontend/DiagChecker.cpp
index c0f5d141be..26bb6ccfa7 100644
--- a/lib/Frontend/DiagChecker.cpp
+++ b/lib/Frontend/DiagChecker.cpp
@@ -55,33 +55,33 @@ static void EmitError(Preprocessor &PP, SourceLocation Pos, const char *String){
/// FindDiagnostics - Go through the comment and see if it indicates expected
/// diagnostics. If so, then put them in a diagnostic list.
-///
+///
static void FindDiagnostics(const char *CommentStart, unsigned CommentLen,
DiagList &ExpectedDiags,
Preprocessor &PP, SourceLocation Pos,
const char *ExpectedStr) {
const char *CommentEnd = CommentStart+CommentLen;
unsigned ExpectedStrLen = strlen(ExpectedStr);
-
+
// Find all expected-foo diagnostics in the string and add them to
// ExpectedDiags.
while (CommentStart != CommentEnd) {
CommentStart = std::find(CommentStart, CommentEnd, 'e');
if (unsigned(CommentEnd-CommentStart) < ExpectedStrLen) return;
-
+
// If this isn't expected-foo, ignore it.
if (memcmp(CommentStart, ExpectedStr, ExpectedStrLen)) {
++CommentStart;
continue;
}
-
+
CommentStart += ExpectedStrLen;
-
+
// Skip whitespace.
while (CommentStart != CommentEnd &&
isspace(CommentStart[0]))
++CommentStart;
-
+
// Default, if we find the '{' now, is 1 time.
int Times = 1;
int Temp = 0;
@@ -94,12 +94,12 @@ static void FindDiagnostics(const char *CommentStart, unsigned CommentLen,
}
if (Temp > 0)
Times = Temp;
-
+
// Skip whitespace again.
while (CommentStart != CommentEnd &&
isspace(CommentStart[0]))
++CommentStart;
-
+
// We should have a {{ now.
if (CommentEnd-CommentStart < 2 ||
CommentStart[0] != '{' || CommentStart[1] != '{') {
@@ -119,7 +119,7 @@ static void FindDiagnostics(const char *CommentStart, unsigned CommentLen,
EmitError(PP, Pos, "cannot find end ('}}') of expected string");
return;
}
-
+
if (ExpectedEnd[1] == '}')
break;
@@ -147,10 +147,10 @@ static void FindExpectedDiags(Preprocessor &PP,
// Create a raw lexer to pull all the comments out of the main file. We don't
// want to look in #include'd headers for expected-error strings.
FileID FID = PP.getSourceManager().getMainFileID();
-
+
// Create a lexer to lex all the tokens of the main file in raw mode.
Lexer RawLex(FID, PP.getSourceManager(), PP.getLangOptions());
-
+
// Return comments as tokens, this is how we find expected diagnostics.
RawLex.SetCommentRetentionState(true);
@@ -159,11 +159,11 @@ static void FindExpectedDiags(Preprocessor &PP,
while (Tok.isNot(tok::eof)) {
RawLex.Lex(Tok);
if (!Tok.is(tok::comment)) continue;
-
+
std::string Comment = PP.getSpelling(Tok);
if (Comment.empty()) continue;
-
+
// Find all expected errors.
FindDiagnostics(&Comment[0], Comment.size(), ExpectedErrors, PP,
Tok.getLocation(), "expected-error");
@@ -182,7 +182,7 @@ static void FindExpectedDiags(Preprocessor &PP,
/// seen diagnostics. If there's anything in it, then something unexpected
/// happened. Print the map out in a nice format and return "true". If the map
/// is empty and we're not going to print things, then return "false".
-///
+///
static bool PrintProblem(SourceManager &SourceMgr,
const_diag_iterator diag_begin,
const_diag_iterator diag_end,
@@ -201,7 +201,7 @@ static bool PrintProblem(SourceManager &SourceMgr,
/// CompareDiagLists - Compare two diagnostic lists and return the difference
/// between them.
-///
+///
static bool CompareDiagLists(SourceManager &SourceMgr,
const_diag_iterator d1_begin,
const_diag_iterator d1_end,
@@ -245,7 +245,7 @@ static bool CompareDiagLists(SourceManager &SourceMgr,
/// CheckResults - This compares the expected results to those that
/// were actually reported. It emits any discrepencies. Return "true" if there
/// were problems. Return "false" otherwise.
-///
+///
static bool CheckResults(Preprocessor &PP,
const DiagList &ExpectedErrors,
const DiagList &ExpectedWarnings,
diff --git a/lib/Frontend/DocumentXML.cpp b/lib/Frontend/DocumentXML.cpp
index 19a757303f..776fa6dcda 100644
--- a/lib/Frontend/DocumentXML.cpp
+++ b/lib/Frontend/DocumentXML.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the XML document class, which provides the means to
+// This file implements the XML document class, which provides the means to
// dump out the AST in a XML form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
@@ -20,23 +20,19 @@
namespace clang {
-//---------------------------------------------------------
+//---------------------------------------------------------
DocumentXML::DocumentXML(const std::string& rootName, llvm::raw_ostream& out) :
Out(out),
Ctx(0),
- HasCurrentNodeSubNodes(false)
-{
+ HasCurrentNodeSubNodes(false) {
NodeStack.push(rootName);
Out << "<?xml version=\"1.0\"?>\n<" << rootName;
}
-//---------------------------------------------------------
-DocumentXML& DocumentXML::addSubNode(const std::string& name)
-{
+//---------------------------------------------------------
+DocumentXML& DocumentXML::addSubNode(const std::string& name) {
if (!HasCurrentNodeSubNodes)
- {
Out << ">\n";
- }
NodeStack.push(name);
HasCurrentNodeSubNodes = false;
Indent();
@@ -44,46 +40,38 @@ DocumentXML& DocumentXML::addSubNode(const std::string& name)
return *this;
}
-//---------------------------------------------------------
-void DocumentXML::Indent()
-{
+//---------------------------------------------------------
+void DocumentXML::Indent() {
for (size_t i = 0, e = (NodeStack.size() - 1) * 2; i < e; ++i)
Out << ' ';
}
-//---------------------------------------------------------
-DocumentXML& DocumentXML::toParent()
-{
+//---------------------------------------------------------
+DocumentXML& DocumentXML::toParent() {
assert(NodeStack.size() > 1 && "to much backtracking");
- if (HasCurrentNodeSubNodes)
- {
+ if (HasCurrentNodeSubNodes) {
Indent();
Out << "</" << NodeStack.top() << ">\n";
- }
- else
- {
+ } else
Out << "/>\n";
- }
NodeStack.pop();
HasCurrentNodeSubNodes = true;
- return *this;
+ return *this;
}
-//---------------------------------------------------------
+//---------------------------------------------------------
namespace {
enum tIdType { ID_NORMAL, ID_FILE, ID_LABEL, ID_LAST };
-unsigned getNewId(tIdType idType)
-{
+unsigned getNewId(tIdType idType) {
static unsigned int idCounts[ID_LAST] = { 0 };
return ++idCounts[idType];
}
-//---------------------------------------------------------
-inline std::string getPrefixedId(unsigned uId, tIdType idType)
-{
+//---------------------------------------------------------
+inline std::string getPrefixedId(unsigned uId, tIdType idType) {
static const char idPrefix[ID_LAST] = { '_', 'f', 'l' };
char buffer[20];
char* BufPtr = llvm::utohex_buffer(uId, buffer + 20);
@@ -91,25 +79,22 @@ inline std::string getPrefixedId(unsigned uId, tIdType idType)
return BufPtr;
}
-//---------------------------------------------------------
+//---------------------------------------------------------
template<class T, class V>
-bool addToMap(T& idMap, const V& value, tIdType idType = ID_NORMAL)
-{
+bool addToMap(T& idMap, const V& value, tIdType idType = ID_NORMAL) {
typename T::iterator i = idMap.find(value);
bool toAdd = i == idMap.end();
- if (toAdd)
- {
+ if (toAdd)
idMap.insert(typename T::value_type(value, getNewId(idType)));
- }
return toAdd;
}
} // anon NS
-//---------------------------------------------------------
-std::string DocumentXML::escapeString(const char* pStr, std::string::size_type len)
-{
+//---------------------------------------------------------
+std::string DocumentXML::escapeString(const char* pStr,
+ std::string::size_type len) {
std::string value;
value.reserve(len + 1);
char buffer[16];
@@ -118,8 +103,7 @@ std::string DocumentXML::escapeString(const char* pStr, std::string::size_type l
default:
if (isprint(C))
value += C;
- else
- {
+ else {
sprintf(buffer, "\\%03o", C);
value += buffer;
}
@@ -142,26 +126,24 @@ std::string DocumentXML::escapeString(const char* pStr, std::string::size_type l
return value;
}
-//---------------------------------------------------------
-void DocumentXML::finalize()
-{
+//---------------------------------------------------------
+void DocumentXML::finalize() {
assert(NodeStack.size() == 1 && "not completely backtracked");
addSubNode("ReferenceSection");
addSubNode("Types");
- for (XML::IdMap<QualType>::iterator i = Types.begin(), e = Types.end(); i != e; ++i)
- {
- if (i->first.getCVRQualifiers() != 0)
- {
+ for (XML::IdMap<QualType>::iterator i = Types.begin(), e = Types.end();
+ i != e; ++i) {
+ if (i->first.getCVRQualifiers() != 0) {
writeTypeToXML(i->first);
addAttribute("id", getPrefixedId(i->second, ID_NORMAL));
toParent();
}
}
- for (XML::IdMap<const Type*>::iterator i = BasicTypes.begin(), e = BasicTypes.end(); i != e; ++i)
- {
+ for (XML::IdMap<const Type*>::iterator i = BasicTypes.begin(),
+ e = BasicTypes.end(); i != e; ++i) {
writeTypeToXML(i->first);
addAttribute("id", getPrefixedId(i->second, ID_NORMAL));
toParent();
@@ -170,31 +152,26 @@ void DocumentXML::finalize()
toParent().addSubNode("Contexts");
- for (XML::IdMap<const DeclContext*>::iterator i = Contexts.begin(), e = Contexts.end(); i != e; ++i)
- {
+ for (XML::IdMap<const DeclContext*>::iterator i = Contexts.begin(),
+ e = Contexts.end(); i != e; ++i) {
addSubNode(i->first->getDeclKindName());
addAttribute("id", getPrefixedId(i->second, ID_NORMAL));
- if (const NamedDecl *ND = dyn_cast<NamedDecl>(i->first)) {
+ if (const NamedDecl *ND = dyn_cast<NamedDecl>(i->first))
addAttribute("name", ND->getNameAsString());
- }
- if (const TagDecl *TD = dyn_cast<TagDecl>(i->first)) {
+ if (const TagDecl *TD = dyn_cast<TagDecl>(i->first))
addAttribute("type", getPrefixedId(BasicTypes[TD->getTypeForDecl()], ID_NORMAL));
- }
- else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(i->first)) {
+ else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(i->first))
addAttribute("type", getPrefixedId(BasicTypes[FD->getType()->getAsFunctionType()], ID_NORMAL));
- }
if (const DeclContext* parent = i->first->getParent())
- {
addAttribute("context", parent);
- }
toParent();
}
toParent().addSubNode("Files");
- for (XML::IdMap<std::string>::iterator i = SourceFiles.begin(), e = SourceFiles.end(); i != e; ++i)
- {
+ for (XML::IdMap<std::string>::iterator i = SourceFiles.begin(),
+ e = SourceFiles.end(); i != e; ++i) {
addSubNode("File");
addAttribute("id", getPrefixedId(i->second, ID_FILE));
addAttribute("name", escapeString(i->first.c_str(), i->first.size()));
@@ -202,26 +179,26 @@ void DocumentXML::finalize()
}
toParent().toParent();
-
+
// write the root closing node (which has always subnodes)
Out << "</" << NodeStack.top() << ">\n";
}
-//---------------------------------------------------------
-void DocumentXML::addAttribute(const char* pAttributeName, const QualType& pType)
-{
+//---------------------------------------------------------
+void DocumentXML::addAttribute(const char* pAttributeName,
+ const QualType& pType) {
addTypeRecursively(pType);
addAttribute(pAttributeName, getPrefixedId(Types[pType], ID_NORMAL));
}
-//---------------------------------------------------------
-void DocumentXML::addPtrAttribute(const char* pAttributeName, const Type* pType)
-{
+//---------------------------------------------------------
+void DocumentXML::addPtrAttribute(const char* pAttributeName,
+ const Type* pType) {
addTypeRecursively(pType);
addAttribute(pAttributeName, getPrefixedId(BasicTypes[pType], ID_NORMAL));
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addTypeRecursively(const QualType& pType)
{
if (addToMap(Types, pType))
@@ -230,12 +207,12 @@ void DocumentXML::addTypeRecursively(const QualType& pType)
// beautifier: a non-qualified type shall be transparent
if (pType.getCVRQualifiers() == 0)
{
- Types[pType] = BasicTypes[pType.getTypePtr()];
+ Types[pType] = BasicTypes[pType.getTypePtr()];
}
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addTypeRecursively(const Type* pType)
{
if (addToMap(BasicTypes, pType))
@@ -243,7 +220,7 @@ void DocumentXML::addTypeRecursively(const Type* pType)
addParentTypes(pType);
/*
// FIXME: doesn't work in the immediate streaming approach
- if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(pType))
+ if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(pType))
{
addSubNode("VariableArraySizeExpression");
PrintStmt(VAT->getSizeExpr());
@@ -253,14 +230,14 @@ void DocumentXML::addTypeRecursively(const Type* pType)
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addPtrAttribute(const char* pName, const DeclContext* DC)
{
addContextsRecursively(DC);
addAttribute(pName, getPrefixedId(Contexts[DC], ID_NORMAL));
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addPtrAttribute(const char* pAttributeName, const NamedDecl* D)
{
if (const DeclContext* DC = dyn_cast<DeclContext>(D))
@@ -275,22 +252,22 @@ void DocumentXML::addPtrAttribute(const char* pAttributeName, const NamedDecl* D
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addPtrAttribute(const char* pName, const NamespaceDecl* D)
{
addPtrAttribute(pName, static_cast<const DeclContext*>(D));
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addContextsRecursively(const DeclContext *DC)
{
if (DC != 0 && addToMap(Contexts, DC))
{
addContextsRecursively(DC->getParent());
- }
+ }
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addSourceFileAttribute(const std::string& fileName)
{
addToMap(SourceFiles, fileName, ID_FILE);
@@ -298,7 +275,7 @@ void DocumentXML::addSourceFileAttribute(const std::string& fileName)
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addPtrAttribute(const char* pName, const LabelStmt* L)
{
addToMap(Labels, L, ID_LABEL);
@@ -306,13 +283,13 @@ void DocumentXML::addPtrAttribute(const char* pName, const LabelStmt* L)
}
-//---------------------------------------------------------
+//---------------------------------------------------------
PresumedLoc DocumentXML::addLocation(const SourceLocation& Loc)
{
SourceManager& SM = Ctx->getSourceManager();
SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
PresumedLoc PLoc;
- if (!SpellingLoc.isInvalid())
+ if (!SpellingLoc.isInvalid())
{
PLoc = SM.getPresumedLoc(SpellingLoc);
addSourceFileAttribute(PLoc.getFilename());
@@ -323,18 +300,18 @@ PresumedLoc DocumentXML::addLocation(const SourceLocation& Loc)
return PLoc;
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::addLocationRange(const SourceRange& R)
{
PresumedLoc PStartLoc = addLocation(R.getBegin());
- if (R.getBegin() != R.getEnd())
+ if (R.getBegin() != R.getEnd())
{
SourceManager& SM = Ctx->getSourceManager();
SourceLocation SpellingLoc = SM.getSpellingLoc(R.getEnd());
- if (!SpellingLoc.isInvalid())
+ if (!SpellingLoc.isInvalid())
{
PresumedLoc PLoc = SM.getPresumedLoc(SpellingLoc);
- if (PStartLoc.isInvalid() ||
+ if (PStartLoc.isInvalid() ||
strcmp(PLoc.getFilename(), PStartLoc.getFilename()) != 0) {
addToMap(SourceFiles, PLoc.getFilename(), ID_FILE);
addAttribute("endfile", PLoc.getFilename());
@@ -345,17 +322,17 @@ void DocumentXML::addLocationRange(const SourceRange& R)
addAttribute("endcol", PLoc.getColumn());
} else {
addAttribute("endcol", PLoc.getColumn());
- }
+ }
}
}
}
-//---------------------------------------------------------
+//---------------------------------------------------------
void DocumentXML::PrintDecl(Decl *D)
{
writeDeclToXML(D);
}
-//---------------------------------------------------------
+//---------------------------------------------------------
} // NS clang
diff --git a/lib/Frontend/FixItRewriter.cpp b/lib/Frontend/FixItRewriter.cpp
index ba58df5d83..dddcaa97e2 100644
--- a/lib/Frontend/FixItRewriter.cpp
+++ b/lib/Frontend/FixItRewriter.cpp
@@ -34,7 +34,7 @@ FixItRewriter::~FixItRewriter() {
Diags.setClient(Client);
}
-bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
+bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
const std::string &OutFileName) {
if (NumFailures > 0) {
Diag(FullSourceLoc(), diag::warn_fixit_no_changes);
@@ -59,10 +59,10 @@ bool FixItRewriter::WriteFixedFile(const std::string &InFileName,
OutFile = new llvm::raw_fd_ostream(Path.c_str(), Err,
llvm::raw_fd_ostream::F_Binary);
OwnedStream.reset(OutFile);
- }
+ }
FileID MainFileID = Rewrite.getSourceMgr().getMainFileID();
- if (const RewriteBuffer *RewriteBuf =
+ if (const RewriteBuffer *RewriteBuf =
Rewrite.getRewriteBufferFor(MainFileID)) {
*OutFile << std::string(RewriteBuf->begin(), RewriteBuf->end());
} else {
@@ -99,7 +99,7 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
// See if the location of the error is one that matches what the
// user requested.
bool AcceptableLocation = false;
- const FileEntry *File
+ const FileEntry *File
= Rewrite.getSourceMgr().getFileEntryForID(
Info.getLocation().getFileID());
unsigned Line = Info.getLocation().getSpellingLineNumber();
@@ -129,14 +129,14 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
break;
}
- if (Hint.InsertionLoc.isValid() &&
+ if (Hint.InsertionLoc.isValid() &&
!Rewrite.isRewritable(Hint.InsertionLoc)) {
CanRewrite = false;
break;
}
}
- if (!CanRewrite) {
+ if (!CanRewrite) {
if (Info.getNumCodeModificationHints() > 0)
Diag(Info.getLocation(), diag::note_fixit_in_macro);
@@ -149,7 +149,7 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
}
bool Failed = false;
- for (unsigned Idx = 0, Last = Info.getNumCodeModificationHints();
+ for (unsigned Idx = 0, Last = Info.getNumCodeModificationHints();
Idx < Last; ++Idx) {
const CodeModificationHint &Hint = Info.getCodeModificationHint(Idx);
if (!Hint.RemoveRange.isValid()) {
@@ -158,15 +158,15 @@ void FixItRewriter::HandleDiagnostic(Diagnostic::Level DiagLevel,
Failed = true;
continue;
}
-
+
if (Hint.CodeToInsert.empty()) {
// We're removing code.
if (Rewrite.RemoveText(Hint.RemoveRange.getBegin(),
Rewrite.getRangeSize(Hint.RemoveRange)))
Failed = true;
continue;
- }
-
+ }
+
// We're replacing code.
if (Rewrite.ReplaceText(Hint.RemoveRange.getBegin(),
Rewrite.getRangeSize(Hint.RemoveRange),
@@ -191,5 +191,5 @@ void FixItRewriter::Diag(FullSourceLoc Loc, unsigned DiagID) {
Diags.setClient(Client);
Diags.Clear();
Diags.Report(Loc, DiagID);
- Diags.setClient(this);
+ Diags.setClient(this);
}
diff --git a/lib/Frontend/GeneratePCH.cpp b/lib/Frontend/GeneratePCH.cpp
index 43a3a6cbc0..bc45cc4225 100644
--- a/lib/Frontend/GeneratePCH.cpp
+++ b/lib/Frontend/GeneratePCH.cpp
@@ -35,9 +35,9 @@ namespace {
llvm::raw_ostream *Out;
Sema *SemaPtr;
MemorizeStatCalls *StatCalls; // owned by the FileManager
-
+
public:
- explicit PCHGenerator(const Preprocessor &PP,
+ explicit PCHGenerator(const Preprocessor &PP,
const char *isysroot,
llvm::raw_ostream *Out);
virtual void InitializeSema(Sema &S) { SemaPtr = &S; }
@@ -45,10 +45,10 @@ namespace {
};
}
-PCHGenerator::PCHGenerator(const Preprocessor &PP,
+PCHGenerator::PCHGenerator(const Preprocessor &PP,
const char *isysroot,
llvm::raw_ostream *OS)
- : PP(PP), isysroot(isysroot), Out(OS), SemaPtr(0), StatCalls(0) {
+ : PP(PP), isysroot(isysroot), Out(OS), SemaPtr(0), StatCalls(0) {
// Install a stat() listener to keep track of all of the stat()
// calls.
diff --git a/lib/Frontend/HTMLDiagnostics.cpp b/lib/Frontend/HTMLDiagnostics.cpp
index 4c84548ad3..f8bca235bd 100644
--- a/lib/Frontend/HTMLDiagnostics.cpp
+++ b/lib/Frontend/HTMLDiagnostics.cpp
@@ -39,39 +39,39 @@ class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient {
bool createdDir, noDir;
Preprocessor* PP;
std::vector<const PathDiagnostic*> BatchedDiags;
- llvm::SmallVectorImpl<std::string> *FilesMade;
+ llvm::SmallVectorImpl<std::string> *FilesMade;
public:
HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
llvm::SmallVectorImpl<std::string> *filesMade = 0);
virtual ~HTMLDiagnostics();
-
+
virtual void SetPreprocessor(Preprocessor *pp) { PP = pp; }
-
+
virtual void HandlePathDiagnostic(const PathDiagnostic* D);
-
+
unsigned ProcessMacroPiece(llvm::raw_ostream& os,
const PathDiagnosticMacroPiece& P,
unsigned num);
-
+
void HandlePiece(Rewriter& R, FileID BugFileID,
const PathDiagnosticPiece& P, unsigned num, unsigned max);
-
+
void HighlightRange(Rewriter& R, FileID BugFileID, SourceRange Range,
const char *HighlightStart = "<span class=\"mrange\">",
const char *HighlightEnd = "</span>");
void ReportDiag(const PathDiagnostic& D);
};
-
+
} // end anonymous namespace
HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
llvm::SmallVectorImpl<std::string>* filesMade)
: Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
PP(pp), FilesMade(filesMade) {
-
- // All html files begin with "report"
+
+ // All html files begin with "report"
FilePrefix.appendComponent("report");
}
@@ -98,9 +98,9 @@ public:
: Prefix(prefix), PP(pp) {}
virtual ~HTMLDiagnosticsFactory() {}
-
+
const char *getName() const { return "HTMLDiagnostics"; }
-
+
PathDiagnosticClient*
createPathDiagnosticClient(llvm::SmallVectorImpl<std::string> *FilesMade) {
@@ -123,12 +123,12 @@ clang::CreateHTMLDiagnosticClientFactory(const std::string& prefix,
void HTMLDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
if (!D)
return;
-
+
if (D->empty()) {
delete D;
return;
}
-
+
const_cast<PathDiagnostic*>(D)->flattenLocations();
BatchedDiags.push_back(D);
}
@@ -139,7 +139,7 @@ HTMLDiagnostics::~HTMLDiagnostics() {
BatchedDiags.pop_back();
ReportDiag(*D);
delete D;
- }
+ }
}
void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
@@ -148,73 +148,73 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
createdDir = true;
std::string ErrorMsg;
Directory.createDirectoryOnDisk(true, &ErrorMsg);
-
+
if (!Directory.isDirectory()) {
llvm::errs() << "warning: could not create directory '"
<< Directory.str() << "'\n"
- << "reason: " << ErrorMsg << '\n';
-
+ << "reason: " << ErrorMsg << '\n';
+
noDir = true;
-
+
return;
}
}
-
+
if (noDir)
return;
-
+
const SourceManager &SMgr = D.begin()->getLocation().getManager();
FileID FID;
-
+
// Verify that the entire path is from the same FileID.
for (PathDiagnostic::const_iterator I = D.begin(), E = D.end(); I != E; ++I) {
FullSourceLoc L = I->getLocation().asLocation().getInstantiationLoc();
-
+
if (FID.isInvalid()) {
FID = SMgr.getFileID(L);
} else if (SMgr.getFileID(L) != FID)
return; // FIXME: Emit a warning?
-
+
// Check the source ranges.
for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(),
RE=I->ranges_end(); RI!=RE; ++RI) {
-
+
SourceLocation L = SMgr.getInstantiationLoc(RI->getBegin());
if (!L.isFileID() || SMgr.getFileID(L) != FID)
return; // FIXME: Emit a warning?
-
+
L = SMgr.getInstantiationLoc(RI->getEnd());
-
+
if (!L.isFileID() || SMgr.getFileID(L) != FID)
- return; // FIXME: Emit a warning?
+ return; // FIXME: Emit a warning?
}
}
-
+
if (FID.isInvalid())
return; // FIXME: Emit a warning?
-
+
// Create a new rewriter to generate HTML.
Rewriter R(const_cast<SourceManager&>(SMgr), PP->getLangOptions());
-
- // Process the path.
+
+ // Process the path.
unsigned n = D.size();
unsigned max = n;
-
+
for (PathDiagnostic::const_reverse_iterator I=D.rbegin(), E=D.rend();
I!=E; ++I, --n)
HandlePiece(R, FID, *I, n, max);
-
+
// Add line numbers, header, footer, etc.
-
+
// unsigned FID = R.getSourceMgr().getMainFileID();
html::EscapeText(R, FID);
html::AddLineNumbers(R, FID);
-
+
// If we have a preprocessor, relex the file and syntax highlight.
// We might not have a preprocessor if we come from a deserialized AST file,
// for example.
-
+
if (PP) html::SyntaxHighlight(R, FID, *PP);
// FIXME: We eventually want to use PPF to create a fresh Preprocessor,
@@ -223,69 +223,69 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
// if (PPF) html::HighlightMacros(R, FID, *PPF);
//
if (PP) html::HighlightMacros(R, FID, *PP);
-
+
// Get the full directory name of the analyzed file.
const FileEntry* Entry = SMgr.getFileEntryForID(FID);
-
+
// This is a cludge; basically we want to append either the full
// working directory if we have no directory information. This is
// a work in progress.
std::string DirName = "";
-
+
if (!llvm::sys::Path(Entry->getName()).isAbsolute()) {
llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory();
DirName = P.str() + "/";
}
-
- // Add the name of the file as an <h1> tag.
-
+
+ // Add the name of the file as an <h1> tag.
+
{
std::string s;
llvm::raw_string_ostream os(s);
-
+
os << "<!-- REPORTHEADER -->\n"
<< "<h3>Bug Summary</h3>\n<table class=\"simpletable\">\n"
"<tr><td class=\"rowname\">File:</td><td>"
<< html::EscapeText(DirName)
<< html::EscapeText(Entry->getName())
<< "</td></tr>\n<tr><td class=\"rowname\">Location:</td><td>"
- "<a href=\"#EndPath\">line "
+ "<a href=\"#EndPath\">line "
<< (*D.rbegin()).getLocation().asLocation().getInstantiationLineNumber()
<< ", column "
<< (*D.rbegin()).getLocation().asLocation().getInstantiationColumnNumber()
<< "</a></td></tr>\n"
"<tr><td class=\"rowname\">Description:</td><td>"
<< D.getDescription() << "</td></tr>\n";
-
+
// Output any other meta data.
-
+
for (PathDiagnostic::meta_iterator I=D.meta_begin(), E=D.meta_end();
I!=E; ++I) {
os << "<tr><td></td><td>" << html::EscapeText(*I) << "</td></tr>\n";
}
-
+
os << "</table>\n<!-- REPORTSUMMARYEXTRA -->\n"
- "<h3>Annotated Source Code</h3>\n";
-
+ "<h3>Annotated Source Code</h3>\n";
+
R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
}
-
+
// Embed meta-data tags.
{
std::string s;
llvm::raw_string_ostream os(s);
-
- const std::string& BugDesc = D.getDescription();
+
+ const std::string& BugDesc = D.getDescription();
if (!BugDesc.empty())
os << "\n<!-- BUGDESC " << BugDesc << " -->\n";
-
+
const std::string& BugType = D.getBugType();
if (!BugType.empty())
os << "\n<!-- BUGTYPE " << BugType << " -->\n";
-
- const std::string& BugCategory = D.getCategory();
+
+ const std::string& BugCategory = D.getCategory();
if (!BugCategory.empty())
os << "\n<!-- BUGCATEGORY " << BugCategory << " -->\n";
@@ -296,21 +296,21 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
<< " -->\n";
os << "\n<!-- BUGPATHLENGTH " << D.size() << " -->\n";
-
+
// Mark the end of the tags.
os << "\n<!-- BUGMETAEND -->\n";
-
+
// Insert the text.
R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
}
-
+
// Add CSS, header, and footer.
-
+
html::AddHeaderFooterInternalBuiltinCSS(R, FID, Entry->getName());
-
+
// Get the rewrite buffer.
const RewriteBuffer *Buf = R.getRewriteBufferFor(FID);
-
+
if (!Buf) {
llvm::errs() << "warning: no diagnostics generated for main file.\n";
return;
@@ -318,19 +318,19 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
// Create the stream to write out the HTML.
std::ofstream os;
-
+
{
// Create a path for the target HTML file.
llvm::sys::Path F(FilePrefix);
F.makeUnique(false, NULL);
-
+
// Rename the file with an HTML extension.
llvm::sys::Path H(F);
H.appendSuffix("html");
F.renamePathOnDisk(H, NULL);
-
+
os.open(H.c_str());
-
+
if (!os) {
llvm::errs() << "warning: could not create file '" << F.str() << "'\n";
return;
@@ -339,33 +339,33 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
if (FilesMade)
FilesMade->push_back(H.getLast());
}
-
+
// Emit the HTML to disk.
for (RewriteBuffer::iterator I = Buf->begin(), E = Buf->end(); I!=E; ++I)
- os << *I;
+ os << *I;
}
void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
const PathDiagnosticPiece& P,
unsigned num, unsigned max) {
-
+
// For now, just draw a box above the line in question, and emit the
// warning.
FullSourceLoc Pos = P.getLocation().asLocation();
-
+
if (!Pos.isValid())
- return;
-
+ return;
+
SourceManager &SM = R.getSourceMgr();
assert(&Pos.getManager() == &SM && "SourceManagers are different!");
std::pair<FileID, unsigned> LPosInfo = SM.getDecomposedInstantiationLoc(Pos);
-
+
if (LPosInfo.first != BugFileID)
return;
-
+
const llvm::MemoryBuffer *Buf = SM.getBuffer(LPosInfo.first);
- const char* FileStart = Buf->getBufferStart();
-
+ const char* FileStart = Buf->getBufferStart();
+
// Compute the column number. Rewind from the current position to the start
// of the line.
unsigned ColNo = SM.getColumnNumber(LPosInfo.first, LPosInfo.second);
@@ -377,12 +377,12 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
const char* FileEnd = Buf->getBufferEnd();
while (*LineEnd != '\n' && LineEnd != FileEnd)
++LineEnd;
-
+
// Compute the margin offset by counting tabs and non-tabs.
- unsigned PosNo = 0;
+ unsigned PosNo = 0;
for (const char* c = LineStart; c != TokInstantiationPtr; ++c)
PosNo += *c == '\t' ? 8 : 1;
-
+
// Create the html for the message.
const char *Kind = 0;
@@ -392,22 +392,22 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
// Setting Kind to "Control" is intentional.
case PathDiagnosticPiece::Macro: Kind = "Control"; break;
}
-
+
std::string sbuf;
llvm::raw_string_ostream os(sbuf);
-
+
os << "\n<tr><td class=\"num\"></td><td class=\"line\"><div id=\"";
-
+
if (num == max)
os << "EndPath";
else
os << "Path" << num;
-
+
os << "\" class=\"msg";
if (Kind)
- os << " msg" << Kind;
+ os << " msg" << Kind;
os << "\" style=\"margin-left:" << PosNo << "ex";
-
+
// Output a maximum size.
if (!isa<PathDiagnosticMacroPiece>(P)) {
// Get the string and determining its maximum substring.
@@ -415,32 +415,32 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
unsigned max_token = 0;
unsigned cnt = 0;
unsigned len = Msg.size();
-
+
for (std::string::const_iterator I=Msg.begin(), E=Msg.end(); I!=E; ++I)
switch (*I) {
default:
++cnt;
- continue;
+ continue;
case ' ':
case '\t':
case '\n':
if (cnt > max_token) max_token = cnt;
cnt = 0;
}
-
+
if (cnt > max_token)
max_token = cnt;
-
+
// Determine the approximate size of the message bubble in em.
unsigned em;
const unsigned max_line = 120;
-
+
if (max_token >= max_line)
em = max_token / 2;
else {
unsigned characters = max_line;
unsigned lines = len / max_line;
-
+
if (lines > 0) {
for (; characters > max_token; --characters)
if (len / characters > lines) {
@@ -448,18 +448,18 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
break;
}
}
-
+
em = characters / 2;
}
-
+
if (em < max_line/2)
- os << "; max-width:" << em << "em";
+ os << "; max-width:" << em << "em";
}
else
os << "; max-width:100em";
-
+
os << "\">";
-
+
if (max > 1) {
os << "<table class=\"msgT\"><tr><td valign=\"top\">";
os << "<div class=\"PathIndex";
@@ -469,10 +469,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
}
if (const PathDiagnosticMacroPiece *MP =
- dyn_cast<PathDiagnosticMacroPiece>(&P)) {
+ dyn_cast<PathDiagnosticMacroPiece>(&P)) {
os << "Within the expansion of the macro '";
-
+
// Get the name of the macro by relexing it.
{
FullSourceLoc L = MP->getLocation().asLocation().getInstantiationLoc();
@@ -481,15 +481,15 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
const char* MacroName = L.getDecomposedLoc().second + BufferInfo.first;
Lexer rawLexer(L, PP->getLangOptions(), BufferInfo.first,
MacroName, BufferInfo.second);
-
+
Token TheTok;
rawLexer.LexFromRawLexer(TheTok);
for (unsigned i = 0, n = TheTok.getLength(); i < n; ++i)
os << MacroName[i];
}
-
+
os << "':\n";
-
+
if (max > 1)
os << "</td></tr></table>";
@@ -498,21 +498,21 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
}
else {
os << html::EscapeText(P.getString());
-
+
if (max > 1)
os << "</td></tr></table>";
}
-
+
os << "</div></td></tr>";
// Insert the new html.
- unsigned DisplayPos = LineEnd - FileStart;
- SourceLocation Loc =
+ unsigned DisplayPos = LineEnd - FileStart;
+ SourceLocation Loc =
SM.getLocForStartOfFile(LPosInfo.first).getFileLocWithOffset(DisplayPos);
R.InsertTextBefore(Loc, os.str());
- // Now highlight the ranges.
+ // Now highlight the ranges.
for (const SourceRange *I = P.ranges_begin(), *E = P.ranges_end();
I != E; ++I)
HighlightRange(R, LPosInfo.first, *I);
@@ -547,9 +547,9 @@ static void EmitAlphaCounter(llvm::raw_ostream& os, unsigned n) {
buf.push_back('a' + x);
n = n / ('z' - 'a');
} while (n);
-
+
assert(!buf.empty());
-
+
for (llvm::SmallVectorImpl<char>::reverse_iterator I=buf.rbegin(),
E=buf.rend(); I!=E; ++I)
os << *I;
@@ -558,10 +558,10 @@ static void EmitAlphaCounter(llvm::raw_ostream& os, unsigned n) {
unsigned HTMLDiagnostics::ProcessMacroPiece(llvm::raw_ostream& os,
const PathDiagnosticMacroPiece& P,
unsigned num) {
-
+
for (PathDiagnosticMacroPiece::const_iterator I=P.begin(), E=P.end();
I!=E; ++I) {
-
+
if (const PathDiagnosticMacroPiece *MP =
dyn_cast<PathDiagnosticMacroPiece>(*I)) {
num = ProcessMacroPiece(os, *MP, num);
@@ -579,7 +579,7 @@ unsigned HTMLDiagnostics::ProcessMacroPiece(llvm::raw_ostream& os,
<< "</td></tr></table></div>\n";
}
}
-
+
return num;
}
@@ -589,20 +589,20 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID,
const char *HighlightEnd) {
SourceManager &SM = R.getSourceMgr();
const LangOptions &LangOpts = R.getLangOpts();
-
+
SourceLocation InstantiationStart = SM.getInstantiationLoc(Range.getBegin());
unsigned StartLineNo = SM.getInstantiationLineNumber(InstantiationStart);
-
+
SourceLocation InstantiationEnd = SM.getInstantiationLoc(Range.getEnd());
unsigned EndLineNo = SM.getInstantiationLineNumber(InstantiationEnd);
-
+
if (EndLineNo < StartLineNo)
return;
-
+
if (SM.getFileID(InstantiationStart) != BugFileID ||
SM.getFileID(InstantiationEnd) != BugFileID)
return;
-
+
// Compute the column number of the end.
unsigned EndColNo = SM.getInstantiationColumnNumber(InstantiationEnd);
unsigned OldEndColNo = EndColNo;
@@ -611,12 +611,12 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, FileID BugFileID,
// Add in the length of the token, so that we cover multi-char tokens.
EndColNo += Lexer::MeasureTokenLength(Range.getEnd(), SM, LangOpts)-1;
}
-
+
// Highlight the range. Make the span tag the outermost tag for the
// selected range.
-
+
SourceLocation E =
InstantiationEnd.getFileLocWithOffset(EndColNo - OldEndColNo);
-
+
html::HighlightRange(R, InstantiationStart, E, HighlightStart, HighlightEnd);
}
diff --git a/lib/Frontend/HTMLPrint.cpp b/lib/Frontend/HTMLPrint.cpp
index f434bcc0c7..8d93d70e83 100644
--- a/lib/Frontend/HTMLPrint.cpp
+++ b/lib/Frontend/HTMLPrint.cpp
@@ -26,7 +26,7 @@ using namespace clang;
//===----------------------------------------------------------------------===//
// Functional HTML pretty-printing.
-//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
namespace {
class HTMLPrinter : public ASTConsumer {
@@ -40,7 +40,7 @@ namespace {
PreprocessorFactory* ppf)
: Out(OS), Diags(D), PP(pp), PPF(ppf) {}
virtual ~HTMLPrinter();
-
+
void Initialize(ASTContext &context);
};
}
@@ -48,7 +48,7 @@ namespace {
ASTConsumer* clang::CreateHTMLPrinter(llvm::raw_ostream *OS,
Diagnostic &D, Preprocessor *PP,
PreprocessorFactory* PPF) {
-
+
return new HTMLPrinter(OS, D, PP, PPF);
}
@@ -78,7 +78,7 @@ HTMLPrinter::~HTMLPrinter() {
// If we have a preprocessor, relex the file and syntax highlight.
// We might not have a preprocessor if we come from a deserialized AST file,
// for example.
-
+
if (PP) html::SyntaxHighlight(R, FID, *PP);
if (PPF) html::HighlightMacros(R, FID, *PP);
html::EscapeText(R, FID, false, true);
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp
index 8674261570..da45bcca97 100644
--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -29,10 +29,10 @@ void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
bool IgnoreSysRoot) {
assert(!Path.empty() && "can't handle empty path here");
FileManager &FM = Headers.getFileMgr();
-
+
// Compute the actual path, taking into consideration -isysroot.
llvm::SmallString<256> MappedPath;
-
+
// Handle isysroot.
if (Group == System && !IgnoreSysRoot) {
// FIXME: Portability. This should be a sys::Path interface, this doesn't
@@ -40,7 +40,7 @@ void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
if (isysroot.size() != 1 || isysroot[0] != '/') // Add isysroot if present.
MappedPath.append(isysroot.begin(), isysroot.end());
}
-
+
MappedPath.append(Path.begin(), Path.end());
// Compute the DirectoryLookup type.
@@ -51,15 +51,15 @@ void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
Type = SrcMgr::C_System;
else
Type = SrcMgr::C_ExternCSystem;
-
-
+
+
// If the directory exists, add it.
if (const DirectoryEntry *DE = FM.getDirectory(MappedPath.str())) {
IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied,
isFramework));
return;
}
-
+
// Check to see if this is an apple-style headermap (which are not allowed to
// be frameworks).
if (!isFramework) {
@@ -71,7 +71,7 @@ void InitHeaderSearch::AddPath(const llvm::StringRef &Path,
}
}
}
-
+
if (Verbose)
llvm::errs() << "ignoring nonexistent directory \""
<< MappedPath.str() << "\"\n";
@@ -251,9 +251,9 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
for (unsigned i = 0; i != SearchList.size(); ++i) {
unsigned DirToRemove = i;
-
+
const DirectoryLookup &CurEntry = SearchList[i];
-
+
if (CurEntry.isNormalDir()) {
// If this isn't the first time we've seen this dir, remove it.
if (SeenDirs.insert(CurEntry.getDir()))
@@ -268,7 +268,7 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
if (SeenHeaderMaps.insert(CurEntry.getHeaderMap()))
continue;
}
-
+
// If we have a normal #include dir/framework/headermap that is shadowed
// later in the chain by a system include location, we actually want to
// ignore the user's request and drop the user dir... keeping the system
@@ -281,13 +281,13 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
unsigned FirstDir;
for (FirstDir = 0; ; ++FirstDir) {
assert(FirstDir != i && "Didn't find dupe?");
-
+
const DirectoryLookup &SearchEntry = SearchList[FirstDir];
// If these are different lookup types, then they can't be the dupe.
if (SearchEntry.getLookupType() != CurEntry.getLookupType())
continue;
-
+
bool isSame;
if (CurEntry.isNormalDir())
isSame = SearchEntry.getDir() == CurEntry.getDir();
@@ -297,11 +297,11 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
assert(CurEntry.isHeaderMap() && "Not a headermap or normal dir?");
isSame = SearchEntry.getHeaderMap() == CurEntry.getHeaderMap();
}
-
+
if (isSame)
break;
}
-
+
// If the first dir in the search path is a non-system dir, zap it
// instead of the system one.
if (SearchList[FirstDir].getDirCharacteristic() == SrcMgr::C_User)
@@ -315,7 +315,7 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList,
fprintf(stderr, " as it is a non-system directory that duplicates"
" a system directory\n");
}
-
+
// This is reached if the current entry is a duplicate. Remove the
// DirToRemove (usually the current dir).
SearchList.erase(SearchList.begin()+DirToRemove);
@@ -334,11 +334,11 @@ void InitHeaderSearch::Realize() {
IncludeGroup[After].end());
RemoveDuplicates(SearchList, Verbose);
RemoveDuplicates(IncludeGroup[Quoted], Verbose);
-
+
// Prepend QUOTED list on the search list.
- SearchList.insert(SearchList.begin(), IncludeGroup[Quoted].begin(),
+ SearchList.insert(SearchList.begin(), IncludeGroup[Quoted].begin(),
IncludeGroup[Quoted].end());
-
+
bool DontSearchCurDir = false; // TODO: set to true if -I- is set?
Headers.SetSearchPaths(SearchList, IncludeGroup[Quoted].size(),
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index 90e5bdec55..14657f02d5 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -30,7 +30,7 @@ static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) {
// Turn the = into ' '.
Buf.insert(Buf.end(), Macro, Equal);
Buf.push_back(' ');
-
+
// Per GCC -D semantics, the macro ends at \n if it exists.
const char *End = strpbrk(Equal, "\n\r");
if (End) {
@@ -40,7 +40,7 @@ static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) {
} else {
End = Equal+strlen(Equal);
}
-
+
Buf.insert(Buf.end(), Equal+1, End);
} else {
// Push "macroname 1".
@@ -62,7 +62,7 @@ static void UndefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) {
}
/// Add the quoted name of an implicit include file.
-static void AddQuotedIncludePath(std::vector<char> &Buf,
+static void AddQuotedIncludePath(std::vector<char> &Buf,
const std::string &File) {
// Implicit include paths should be resolved relative to the current
// working directory first, and then use the regular header search
@@ -75,7 +75,7 @@ static void AddQuotedIncludePath(std::vector<char> &Buf,
Path.makeAbsolute();
if (!Path.exists())
Path = File;
-
+
// Escape double quotes etc.
Buf.push_back('"');
std::string EscapedFile = Lexer::Stringify(Path.str());
@@ -85,7 +85,7 @@ static void AddQuotedIncludePath(std::vector<char> &Buf,
/// AddImplicitInclude - Add an implicit #include of the specified file to the
/// predefines buffer.
-static void AddImplicitInclude(std::vector<char> &Buf,
+static void AddImplicitInclude(std::vector<char> &Buf,
const std::string &File) {
const char *Inc = "#include ";
Buf.insert(Buf.end(), Inc, Inc+strlen(Inc));
@@ -106,12 +106,12 @@ static void AddImplicitIncludeMacros(std::vector<char> &Buf,
/// AddImplicitIncludePTH - Add an implicit #include using the original file
/// used to generate a PTH cache.
-static void AddImplicitIncludePTH(std::vector<char> &Buf, Preprocessor &PP,
+static void AddImplicitIncludePTH(std::vector<char> &Buf, Preprocessor &PP,
const std::string& ImplicitIncludePTH) {
PTHManager *P = PP.getPTHManager();
assert(P && "No PTHManager.");
const char *OriginalFile = P->getOriginalSourceFile();
-
+
if (!OriginalFile) {
assert(!ImplicitIncludePTH.empty());
fprintf(stderr, "error: PTH file '%s' does not designate an original "
@@ -119,7 +119,7 @@ static void AddImplicitIncludePTH(std::vector<char> &Buf, Preprocessor &PP,
ImplicitIncludePTH.c_str());
exit (1);
}
-
+
AddImplicitInclude(Buf, OriginalFile);
}
@@ -144,7 +144,7 @@ static T PickFP(const llvm::fltSemantics *Sem, T IEEESingleVal,
static void DefineFloatMacros(std::vector<char> &Buf, const char *Prefix,
const llvm::fltSemantics *Sem) {
const char *DenormMin, *Epsilon, *Max, *Min;
- DenormMin = PickFP(Sem, "1.40129846e-45F", "4.9406564584124654e-324",
+ DenormMin = PickFP(Sem, "1.40129846e-45F", "4.9406564584124654e-324",
"3.64519953188247460253e-4951L",
"4.94065645841246544176568792868221e-324L",
"6.47517511943802511092443895822764655e-4966L");
@@ -167,7 +167,7 @@ static void DefineFloatMacros(std::vector<char> &Buf, const char *Prefix,
"1.18973149535723176502e+4932L",
"1.79769313486231580793728971405301e+308L",
"1.18973149535723176508575932662800702e+4932L");
-
+
char MacroBuf[100];
sprintf(MacroBuf, "__%s_DENORM_MIN__=%s", Prefix, DenormMin);
DefineBuiltinMacro(Buf, MacroBuf);
@@ -210,7 +210,7 @@ static void DefineTypeSize(const char *MacroName, unsigned TypeWidth,
MaxVal = (1LL << (TypeWidth - 1)) - 1;
else
MaxVal = ~0LL >> (64-TypeWidth);
-
+
// FIXME: Switch to using raw_ostream and avoid utostr().
sprintf(MacroBuf, "%s=%s%s", MacroName, llvm::utostr(MaxVal).c_str(),
ValSuffix);
@@ -232,17 +232,17 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// Compiler version introspection macros.
DefineBuiltinMacro(Buf, "__llvm__=1"); // LLVM Backend
DefineBuiltinMacro(Buf, "__clang__=1"); // Clang Frontend
-
+
// Currently claim to be compatible with GCC 4.2.1-5621.
DefineBuiltinMacro(Buf, "__GNUC_MINOR__=2");
DefineBuiltinMacro(Buf, "__GNUC_PATCHLEVEL__=1");
DefineBuiltinMacro(Buf, "__GNUC__=4");
DefineBuiltinMacro(Buf, "__GXX_ABI_VERSION=1002");
DefineBuiltinMacro(Buf, "__VERSION__=\"4.2.1 Compatible Clang Compiler\"");
-
-
+
+
// Initialize language-specific preprocessor defines.
-
+
// These should all be defined in the preprocessor according to the
// current language configuration.
if (!LangOpts.Microsoft)
@@ -260,7 +260,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// Standard conforming mode?
if (!LangOpts.GNUMode)
DefineBuiltinMacro(Buf, "__STRICT_ANSI__=1");
-
+
if (LangOpts.CPlusPlus0x)
DefineBuiltinMacro(Buf, "__GXX_EXPERIMENTAL_CXX0X__");
@@ -268,7 +268,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineBuiltinMacro(Buf, "__STDC_HOSTED__=0");
else
DefineBuiltinMacro(Buf, "__STDC_HOSTED__=1");
-
+
if (LangOpts.ObjC1) {
DefineBuiltinMacro(Buf, "__OBJC__=1");
if (LangOpts.ObjCNonFragileABI) {
@@ -279,15 +279,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.getGCMode() != LangOptions::NonGC)
DefineBuiltinMacro(Buf, "__OBJC_GC__=1");
-
+
if (LangOpts.NeXTRuntime)
DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
}
-
+
// darwin_constant_cfstrings controls this. This is also dependent
// on other things like the runtime I believe. This is set even for C code.
DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");
-
+
if (LangOpts.ObjC2)
DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");
@@ -301,7 +301,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineBuiltinMacro(Buf, "__block=__attribute__((__blocks__(byref)))");
DefineBuiltinMacro(Buf, "__BLOCKS__=1");
}
-
+
if (LangOpts.CPlusPlus) {
DefineBuiltinMacro(Buf, "__DEPRECATED=1");
DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
@@ -309,32 +309,32 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineBuiltinMacro(Buf, "__GXX_WEAK__=1");
if (LangOpts.GNUMode)
DefineBuiltinMacro(Buf, "__cplusplus=1");
- else
+ else
// C++ [cpp.predefined]p1:
- // The name_ _cplusplusis defined to the value199711Lwhen compiling a
+ // The name_ _cplusplusis defined to the value199711Lwhen compiling a
// C++ translation unit.
DefineBuiltinMacro(Buf, "__cplusplus=199711L");
DefineBuiltinMacro(Buf, "__private_extern__=extern");
// Ugly hack to work with GNU libstdc++.
DefineBuiltinMacro(Buf, "_GNU_SOURCE=1");
}
-
+
// Filter out some microsoft extensions when trying to parse in ms-compat
- // mode.
+ // mode.
if (LangOpts.Microsoft) {
DefineBuiltinMacro(Buf, "__int8=__INT8_TYPE__");
DefineBuiltinMacro(Buf, "__int16=__INT16_TYPE__");
DefineBuiltinMacro(Buf, "__int32=__INT32_TYPE__");
DefineBuiltinMacro(Buf, "__int64=__INT64_TYPE__");
}
-
+
if (LangOpts.Optimize)
DefineBuiltinMacro(Buf, "__OPTIMIZE__=1");
if (LangOpts.OptimizeSize)
DefineBuiltinMacro(Buf, "__OPTIMIZE_SIZE__=1");
-
+
// Initialize target-specific preprocessor defines.
-
+
// Define type sizing macros based on the target properties.
assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");
@@ -352,7 +352,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
IntMaxWidth = TI.getIntWidth();
IntMaxSuffix = "";
}
-
+
DefineTypeSize("__SCHAR_MAX__", TI.getCharWidth(), "", true, Buf);
DefineTypeSize("__SHRT_MAX__", TI.getShortWidth(), "", true, Buf);
DefineTypeSize("__INT_MAX__", TI.getIntWidth(), "", true, Buf);
@@ -369,7 +369,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf);
// FIXME: TargetInfo hookize __WINT_TYPE__.
DefineBuiltinMacro(Buf, "__WINT_TYPE__=int");
-
+
DefineFloatMacros(Buf, "FLT", &TI.getFloatFormat());
DefineFloatMacros(Buf, "DBL", &TI.getDoubleFormat());
DefineFloatMacros(Buf, "LDBL", &TI.getLongDoubleFormat());
@@ -377,39 +377,39 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
// Define a __POINTER_WIDTH__ macro for stdint.h.
sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
DefineBuiltinMacro(Buf, MacroBuf);
-
+
if (!LangOpts.CharIsSigned)
- DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
+ DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");
// Define fixed-sized integer types for stdint.h
assert(TI.getCharWidth() == 8 && "unsupported target types");
assert(TI.getShortWidth() == 16 && "unsupported target types");
DefineBuiltinMacro(Buf, "__INT8_TYPE__=char");
DefineBuiltinMacro(Buf, "__INT16_TYPE__=short");
-
+
if (TI.getIntWidth() == 32)
DefineBuiltinMacro(Buf, "__INT32_TYPE__=int");
else {
assert(TI.getLongLongWidth() == 32 && "unsupported target types");
DefineBuiltinMacro(Buf, "__INT32_TYPE__=long long");
}
-
+
// 16-bit targets doesn't necessarily have a 64-bit type.
if (TI.getLongLongWidth() == 64)
DefineType("__INT64_TYPE__", TI.getInt64Type(), Buf);
-
+
// Add __builtin_va_list typedef.
{
const char *VAList = TI.getVAListDeclaration();
Buf.insert(Buf.end(), VAList, VAList+strlen(VAList));
Buf.push_back('\n');
}
-
+
if (const char *Prefix = TI.getUserLabelPrefix()) {
sprintf(MacroBuf, "__USER_LABEL_PREFIX__=%s", Prefix);
DefineBuiltinMacro(Buf, MacroBuf);
}
-
+
// Build configuration options. FIXME: these should be controlled by
// command line options or something.
DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
@@ -452,15 +452,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
bool InitializePreprocessor(Preprocessor &PP,
const PreprocessorInitOptions& InitOpts) {
std::vector<char> PredefineBuffer;
-
+
const char *LineDirective = "# 1 \"<built-in>\" 3\n";
PredefineBuffer.insert(PredefineBuffer.end(),
LineDirective, LineDirective+strlen(LineDirective));
-
+
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
PredefineBuffer);
-
+
// Add on the predefines from the driver. Wrap in a #line directive to report
// that they come from the command line.
LineDirective = "# 1 \"<command line>\" 1\n";
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index f4d06c068b..e7321bf6fa 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -69,21 +69,21 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) {
PARSE_LANGOPT_IMPORTANT(ObjCNonFragileABI, diag::warn_pch_nonfragile_abi);
PARSE_LANGOPT_BENIGN(PascalStrings);
PARSE_LANGOPT_BENIGN(WritableStrings);
- PARSE_LANGOPT_IMPORTANT(LaxVectorConversions,
+ PARSE_LANGOPT_IMPORTANT(LaxVectorConversions,
diag::warn_pch_lax_vector_conversions);
PARSE_LANGOPT_IMPORTANT(AltiVec, diag::warn_pch_altivec);
PARSE_LANGOPT_IMPORTANT(Exceptions, diag::warn_pch_exceptions);
PARSE_LANGOPT_IMPORTANT(NeXTRuntime, diag::warn_pch_objc_runtime);
PARSE_LANGOPT_IMPORTANT(Freestanding, diag::warn_pch_freestanding);
PARSE_LANGOPT_IMPORTANT(NoBuiltin, diag::warn_pch_builtins);
- PARSE_LANGOPT_IMPORTANT(ThreadsafeStatics,
+ PARSE_LANGOPT_IMPORTANT(ThreadsafeStatics,
diag::warn_pch_thread_safe_statics);
PARSE_LANGOPT_IMPORTANT(POSIXThreads, diag::warn_pch_posix_threads);
PARSE_LANGOPT_IMPORTANT(Blocks, diag::warn_pch_blocks);
PARSE_LANGOPT_BENIGN(EmitAllDecls);
PARSE_LANGOPT_IMPORTANT(MathErrno, diag::warn_pch_math_errno);
PARSE_LANGOPT_IMPORTANT(OverflowChecking, diag::warn_pch_overflow_checking);
- PARSE_LANGOPT_IMPORTANT(HeinousExtensions,
+ PARSE_LANGOPT_IMPORTANT(HeinousExtensions,
diag::warn_pch_heinous_extensions);
// FIXME: Most of the options below are benign if the macro wasn't
// used. Unfortunately, this means that a PCH compiled without
@@ -101,7 +101,7 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) {
PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control);
PARSE_LANGOPT_IMPORTANT(CharIsSigned, diag::warn_pch_char_signed);
if ((PPLangOpts.getGCMode() != 0) != (LangOpts.getGCMode() != 0)) {
- Reader.Diag(diag::warn_pch_gc_mode)
+ Reader.Diag(diag::warn_pch_gc_mode)
<< LangOpts.getGCMode() << PPLangOpts.getGCMode();
return true;
}
@@ -165,7 +165,7 @@ static inline bool startsWith(const std::string &Haystack,
return startsWith(Haystack, Needle.c_str());
}
-bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
+bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID,
std::string &SuggestedPredefines) {
@@ -173,19 +173,19 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
unsigned PredefLen = PP.getPredefines().size();
// If the two predefines buffers compare equal, we're done!
- if (PredefLen == PCHPredefLen &&
+ if (PredefLen == PCHPredefLen &&
strncmp(Predef, PCHPredef, PCHPredefLen) == 0)
return false;
SourceManager &SourceMgr = PP.getSourceManager();
-
+
// The predefines buffers are different. Determine what the
// differences are, and whether they require us to reject the PCH
// file.
std::vector<std::string> CmdLineLines = splitLines(Predef, PredefLen);
std::vector<std::string> PCHLines = splitLines(PCHPredef, PCHPredefLen);
- // Sort both sets of predefined buffer lines, since
+ // Sort both sets of predefined buffer lines, since
std::sort(CmdLineLines.begin(), CmdLineLines.end());
std::sort(PCHLines.begin(), PCHLines.end());
@@ -204,11 +204,11 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
Reader.Diag(diag::warn_pch_compiler_options_mismatch);
return true;
}
-
+
// This is a macro definition. Determine the name of the macro
// we're defining.
std::string::size_type StartOfMacroName = strlen("#define ");
- std::string::size_type EndOfMacroName
+ std::string::size_type EndOfMacroName
= Missing.find_first_of("( \n\r", StartOfMacroName);
assert(EndOfMacroName != std::string::npos &&
"Couldn't find the end of the macro name");
@@ -226,19 +226,19 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
if (!startsWith(*ConflictPos, MacroDefStart)) {
// Different macro; we're done.
ConflictPos = CmdLineLines.end();
- break;
+ break;
}
-
- assert(ConflictPos->size() > MacroDefLen &&
+
+ assert(ConflictPos->size() > MacroDefLen &&
"Invalid #define in predefines buffer?");
- if ((*ConflictPos)[MacroDefLen] != ' ' &&
+ if ((*ConflictPos)[MacroDefLen] != ' ' &&
(*ConflictPos)[MacroDefLen] != '(')
continue; // Longer macro name; keep trying.
-
+
// We found a conflicting macro definition.
break;
}
-
+
if (ConflictPos != CmdLineLines.end()) {
Reader.Diag(diag::warn_cmdline_conflicting_macro_def)
<< MacroName;
@@ -255,13 +255,13 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
ConflictingDefines = true;
continue;
}
-
+
// If the macro doesn't conflict, then we'll just pick up the
// macro definition from the PCH file. Warn the user that they
// made a mistake.
if (ConflictingDefines)
continue; // Don't complain if there are already conflicting defs
-
+
if (!MissingDefines) {
Reader.Diag(diag::warn_cmdline_missing_macro_defs);
MissingDefines = true;
@@ -275,10 +275,10 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
.getFileLocWithOffset(Offset);
Reader.Diag(PCHMissingLoc, diag::note_using_macro_def_from_pch);
}
-
+
if (ConflictingDefines)
return true;
-
+
// Determine what predefines were introduced based on command-line
// parameters that were not present when building the PCH
// file. Extra #defines are okay, so long as the identifiers being
@@ -286,7 +286,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
std::vector<std::string> ExtraPredefines;
std::set_difference(CmdLineLines.begin(), CmdLineLines.end(),
PCHLines.begin(), PCHLines.end(),
- std::back_inserter(ExtraPredefines));
+ std::back_inserter(ExtraPredefines));
for (unsigned I = 0, N = ExtraPredefines.size(); I != N; ++I) {
const std::string &Extra = ExtraPredefines[I];
if (!startsWith(Extra, "#define ") != 0) {
@@ -297,7 +297,7 @@ bool PCHValidator::ReadPredefinesBuffer(const char *PCHPredef,
// This is an extra macro definition. Determine the name of the
// macro we're defining.
std::string::size_type StartOfMacroName = strlen("#define ");
- std::string::size_type EndOfMacroName
+ std::string::size_type EndOfMacroName
= Extra.find_first_of("( \n\r", StartOfMacroName);
assert(EndOfMacroName != std::string::npos &&
"Couldn't find the end of the macro name");
@@ -338,8 +338,8 @@ void PCHValidator::ReadCounter(unsigned Value) {
// PCH reader implementation
//===----------------------------------------------------------------------===//
-PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context,
- const char *isysroot)
+PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context,
+ const char *isysroot)
: Listener(new PCHValidator(PP, *this)), SourceMgr(PP.getSourceManager()),
FileMgr(PP.getFileManager()), Diags(PP.getDiagnostics()),
SemaObj(0), PP(&PP), Context(Context), Consumer(0),
@@ -348,16 +348,16 @@ PCHReader::PCHReader(Preprocessor &PP, ASTContext *Context,
MethodPoolLookupTable(0), MethodPoolLookupTableData(0),
TotalSelectorsInMethodPool(0), SelectorOffsets(0),
TotalNumSelectors(0), Comments(0), NumComments(0), isysroot(isysroot),
- NumStatHits(0), NumStatMisses(0),
- NumSLocEntriesRead(0), NumStatementsRead(0),
+ NumStatHits(0), NumStatMisses(0),
+ NumSLocEntriesRead(0), NumStatementsRead(0),
NumMacrosRead(0), NumMethodPoolSelectorsRead(0), NumMethodPoolMisses(0),
NumLexicalDeclContextsRead(0), NumVisibleDeclContextsRead(0),
- CurrentlyLoadingTypeOrDecl(0) {
+ CurrentlyLoadingTypeOrDecl(0) {
RelocatablePCH = false;
}
PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
- Diagnostic &Diags, const char *isysroot)
+ Diagnostic &Diags, const char *isysroot)
: SourceMgr(SourceMgr), FileMgr(FileMgr), Diags(Diags),
SemaObj(0), PP(0), Context(0), Consumer(0),
IdentifierTableData(0), IdentifierLookupTable(0),
@@ -365,11 +365,11 @@ PCHReader::PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
MethodPoolLookupTable(0), MethodPoolLookupTableData(0),
TotalSelectorsInMethodPool(0), SelectorOffsets(0),
TotalNumSelectors(0), Comments(0), NumComments(0), isysroot(isysroot),
- NumStatHits(0), NumStatMisses(0),
- NumSLocEntriesRead(0), NumStatementsRead(0),
+ NumStatHits(0), NumStatMisses(0),
+ NumSLocEntriesRead(0), NumStatementsRead(0),
NumMacrosRead(0), NumMethodPoolSelectorsRead(0), NumMethodPoolMisses(0),
NumLexicalDeclContextsRead(0), NumVisibleDeclContextsRead(0),
- CurrentlyLoadingTypeOrDecl(0) {
+ CurrentlyLoadingTypeOrDecl(0) {
RelocatablePCH = false;
}
@@ -395,12 +395,12 @@ public:
typedef external_key_type internal_key_type;
explicit PCHMethodPoolLookupTrait(PCHReader &Reader) : Reader(Reader) { }
-
+
static bool EqualKey(const internal_key_type& a,
const internal_key_type& b) {
return a == b;
}
-
+
static unsigned ComputeHash(Selector Sel) {
unsigned N = Sel.getNumArgs();
if (N == 0)
@@ -411,11 +411,11 @@ public:
R = clang::BernsteinHashPartial(II->getName(), II->getLength(), R);
return R;
}
-
+
// This hopefully will just get inlined and removed by the optimizer.
static const internal_key_type&
GetInternalKey(const external_key_type& x) { return x; }
-
+
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
using namespace clang::io;
@@ -423,12 +423,12 @@ public:
unsigned DataLen = ReadUnalignedLE16(d);
return std::make_pair(KeyLen, DataLen);
}
-
+
internal_key_type ReadKey(const unsigned char* d, unsigned) {
using namespace clang::io;
SelectorTable &SelTable = Reader.getContext()->Selectors;
unsigned N = ReadUnalignedLE16(d);
- IdentifierInfo *FirstII
+ IdentifierInfo *FirstII
= Reader.DecodeIdentifierInfo(ReadUnalignedLE32(d));
if (N == 0)
return SelTable.getNullarySelector(FirstII);
@@ -442,7 +442,7 @@ public:
return SelTable.getSelector(N, Args.data());
}
-
+
data_type ReadData(Selector, const unsigned char* d, unsigned DataLen) {
using namespace clang::io;
unsigned NumInstanceMethods = ReadUnalignedLE16(d);
@@ -453,7 +453,7 @@ public:
// Load instance methods
ObjCMethodList *Prev = 0;
for (unsigned I = 0; I != NumInstanceMethods; ++I) {
- ObjCMethodDecl *Method
+ ObjCMethodDecl *Method
= cast<ObjCMethodDecl>(Reader.GetDecl(ReadUnalignedLE32(d)));
if (!Result.first.Method) {
// This is the first method, which is the easy case.
@@ -469,7 +469,7 @@ public:
// Load factory methods
Prev = 0;
for (unsigned I = 0; I != NumFactoryMethods; ++I) {
- ObjCMethodDecl *Method
+ ObjCMethodDecl *Method
= cast<ObjCMethodDecl>(Reader.GetDecl(ReadUnalignedLE32(d)));
if (!Result.second.Method) {
// This is the first method, which is the easy case.
@@ -485,11 +485,11 @@ public:
return Result;
}
};
-
-} // end anonymous namespace
+
+} // end anonymous namespace
/// \brief The on-disk hash table used for the global method pool.
-typedef OnDiskChainedHashTable<PCHMethodPoolLookupTrait>
+typedef OnDiskChainedHashTable<PCHMethodPoolLookupTrait>
PCHMethodPoolLookupTable;
namespace {
@@ -508,23 +508,23 @@ public:
typedef external_key_type internal_key_type;
- explicit PCHIdentifierLookupTrait(PCHReader &Reader, IdentifierInfo *II = 0)
+ explicit PCHIdentifierLookupTrait(PCHReader &Reader, IdentifierInfo *II = 0)
: Reader(Reader), KnownII(II) { }
-
+
static bool EqualKey(const internal_key_type& a,
const internal_key_type& b) {
return (a.second == b.second) ? memcmp(a.first, b.first, a.second) == 0
: false;
}
-
+
static unsigned ComputeHash(const internal_key_type& a) {
return BernsteinHash(a.first, a.second);
}
-
+
// This hopefully will just get inlined and removed by the optimizer.
static const internal_key_type&
GetInternalKey(const external_key_type& x) { return x; }
-
+
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
using namespace clang::io;
@@ -532,14 +532,14 @@ public:
unsigned KeyLen = ReadUnalignedLE16(d);
return std::make_pair(KeyLen, DataLen);
}
-
+
static std::pair<const char*, unsigned>
ReadKey(const unsigned char* d, unsigned n) {
assert(n >= 2 && d[n-1] == '\0');
return std::make_pair((const char*) d, n-1);
}
-
- IdentifierInfo *ReadData(const internal_key_type& k,
+
+ IdentifierInfo *ReadData(const internal_key_type& k,
const unsigned char* d,
unsigned DataLen) {
using namespace clang::io;
@@ -571,7 +571,7 @@ public:
Bits >>= 1;
unsigned ObjCOrBuiltinID = Bits & 0x3FF;
Bits >>= 10;
-
+
assert(Bits == 0 && "Extra bits in the identifier?");
DataLen -= 6;
@@ -586,7 +586,7 @@ public:
// Set or check the various bits in the IdentifierInfo structure.
// FIXME: Load token IDs lazily, too?
II->setObjCOrBuiltinID(ObjCOrBuiltinID);
- assert(II->isExtensionToken() == ExtensionToken &&
+ assert(II->isExtensionToken() == ExtensionToken &&
"Incorrect extension token flag");
(void)ExtensionToken;
II->setIsPoisoned(Poisoned);
@@ -611,16 +611,16 @@ public:
DeclIDs.push_back(ReadUnalignedLE32(d));
Reader.SetGloballyVisibleDecls(II, DeclIDs);
}
-
+
return II;
}
};
-
-} // end anonymous namespace
+
+} // end anonymous namespace
/// \brief The on-disk hash table used to contain information about
/// all of the identifiers in the program.
-typedef OnDiskChainedHashTable<PCHIdentifierLookupTrait>
+typedef OnDiskChainedHashTable<PCHIdentifierLookupTrait>
PCHIdentifierLookupTable;
bool PCHReader::Error(const char *Msg) {
@@ -646,7 +646,7 @@ bool PCHReader::Error(const char *Msg) {
///
/// \returns true if there was a mismatch (in which case the PCH file
/// should be ignored), or false otherwise.
-bool PCHReader::CheckPredefinesBuffer(const char *PCHPredef,
+bool PCHReader::CheckPredefinesBuffer(const char *PCHPredef,
unsigned PCHPredefLen,
FileID PCHBufferID) {
if (Listener)
@@ -673,7 +673,7 @@ bool PCHReader::ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record) {
std::string Filename(&Record[Idx], &Record[Idx] + FilenameLen);
Idx += FilenameLen;
MaybeAddSystemRootToFilename(Filename);
- FileIDs[I] = LineTable.getLineTableFilenameID(Filename.c_str(),
+ FileIDs[I] = LineTable.getLineTableFilenameID(Filename.c_str(),
Filename.size());
}
@@ -690,7 +690,7 @@ bool PCHReader::ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record) {
unsigned FileOffset = Record[Idx++];
unsigned LineNo = Record[Idx++];
int FilenameID = Record[Idx++];
- SrcMgr::CharacteristicKind FileKind
+ SrcMgr::CharacteristicKind FileKind
= (SrcMgr::CharacteristicKind)Record[Idx++];
unsigned IncludeOffset = Record[Idx++];
Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
@@ -712,10 +712,10 @@ public:
const mode_t mode;
const time_t mtime;
const off_t size;
-
+
PCHStatData(ino_t i, dev_t d, mode_t mo, time_t m, off_t s)
- : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
-
+ : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
+
PCHStatData()
: hasStat(false), ino(0), dev(0), mode(0), mtime(0), size(0) {}
};
@@ -758,7 +758,7 @@ class VISIBILITY_HIDDEN PCHStatLookupTrait {
ino_t ino = (ino_t) ReadUnalignedLE32(d);
dev_t dev = (dev_t) ReadUnalignedLE32(d);
mode_t mode = (mode_t) ReadUnalignedLE16(d);
- time_t mtime = (time_t) ReadUnalignedLE64(d);
+ time_t mtime = (time_t) ReadUnalignedLE64(d);
off_t size = (off_t) ReadUnalignedLE64(d);
return data_type(ino, dev, mode, mtime, size);
}
@@ -773,17 +773,17 @@ class VISIBILITY_HIDDEN PCHStatCache : public StatSysCallCache {
CacheTy *Cache;
unsigned &NumStatHits, &NumStatMisses;
-public:
+public:
PCHStatCache(const unsigned char *Buckets,
const unsigned char *Base,
unsigned &NumStatHits,
- unsigned &NumStatMisses)
+ unsigned &NumStatMisses)
: Cache(0), NumStatHits(NumStatHits), NumStatMisses(NumStatMisses) {
Cache = CacheTy::Create(Buckets, Base);
}
~PCHStatCache() { delete Cache; }
-
+
int stat(const char *path, struct stat *buf) {
// Do the lookup for the file's data in the PCH file.
CacheTy::iterator I = Cache->find(path);
@@ -793,10 +793,10 @@ public:
++NumStatMisses;
return ::stat(path, buf);
}
-
+
++NumStatHits;
PCHStatData Data = *I;
-
+
if (!Data.hasStat)
return 1;
@@ -843,7 +843,7 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock() {
}
return Success;
}
-
+
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
// No known subblocks, always skip them.
SLocEntryCursor.ReadSubBlockID();
@@ -853,12 +853,12 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock() {
}
continue;
}
-
+
if (Code == llvm::bitc::DEFINE_ABBREV) {
SLocEntryCursor.ReadAbbrevRecord();
continue;
}
-
+
// Read a record.
const char *BlobStart;
unsigned BlobLen;
@@ -931,7 +931,7 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
Error(ErrorStr.c_str());
return Failure;
}
-
+
FileID FID = SourceMgr.createFileID(File,
SourceLocation::getFromRawEncoding(Record[1]),
(SrcMgr::CharacteristicKind)Record[2],
@@ -948,16 +948,16 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
unsigned Offset = Record[0];
unsigned Code = SLocEntryCursor.ReadCode();
Record.clear();
- unsigned RecCode
+ unsigned RecCode
= SLocEntryCursor.ReadRecord(Code, Record, &BlobStart, &BlobLen);
assert(RecCode == pch::SM_SLOC_BUFFER_BLOB && "Ill-formed PCH file");
(void)RecCode;
llvm::MemoryBuffer *Buffer
- = llvm::MemoryBuffer::getMemBuffer(BlobStart,
+ = llvm::MemoryBuffer::getMemBuffer(BlobStart,
BlobStart + BlobLen - 1,
Name);
FileID BufferID = SourceMgr.createFileIDForMemBuffer(Buffer, ID, Offset);
-
+
if (strcmp(Name, "<built-in>") == 0) {
PCHPredefinesBufferID = BufferID;
PCHPredefines = BlobStart;
@@ -968,7 +968,7 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
}
case pch::SM_SLOC_INSTANTIATION_ENTRY: {
- SourceLocation SpellingLoc
+ SourceLocation SpellingLoc
= SourceLocation::getFromRawEncoding(Record[1]);
SourceMgr.createInstantiationLoc(SpellingLoc,
SourceLocation::getFromRawEncoding(Record[2]),
@@ -977,7 +977,7 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
ID,
Record[0]);
break;
- }
+ }
}
return Success;
@@ -992,10 +992,10 @@ bool PCHReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
Error("malformed block record in PCH file");
return Failure;
}
-
+
while (true) {
unsigned Code = Cursor.ReadCode();
-
+
// We expect all abbrevs to be at the start of the block.
if (Code != llvm::bitc::DEFINE_ABBREV)
return false;
@@ -1005,7 +1005,7 @@ bool PCHReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
void PCHReader::ReadMacroRecord(uint64_t Offset) {
assert(PP && "Forgot to set Preprocessor ?");
-
+
// Keep track of where we are in the stream, then jump back there
// after reading this macro.
SavedStreamPosition SavedPosition(Stream);
@@ -1014,7 +1014,7 @@ void PCHReader::ReadMacroRecord(uint64_t Offset) {
RecordData Record;
llvm::SmallVector<IdentifierInfo*, 16> MacroArgs;
MacroInfo *Macro = 0;
-
+
while (true) {
unsigned Code = Stream.ReadCode();
switch (Code) {
@@ -1029,7 +1029,7 @@ void PCHReader::ReadMacroRecord(uint64_t Offset) {
return;
}
continue;
-
+
case llvm::bitc::DEFINE_ABBREV:
Stream.ReadAbbrevRecord();
continue;
@@ -1056,10 +1056,10 @@ void PCHReader::ReadMacroRecord(uint64_t Offset) {
}
SourceLocation Loc = SourceLocation::getFromRawEncoding(Record[1]);
bool isUsed = Record[2];
-
+
MacroInfo *MI = PP->AllocateMacroInfo(Loc);
MI->setIsUsed(isUsed);
-
+
if (RecType == pch::PP_MACRO_FUNCTION_LIKE) {
// Decode function-like macro info.
bool isC99VarArgs = Record[3];
@@ -1086,12 +1086,12 @@ void PCHReader::ReadMacroRecord(uint64_t Offset) {
++NumMacrosRead;
break;
}
-
+
case pch::PP_TOKEN: {
// If we see a TOKEN before a PP_MACRO_*, then the file is
// erroneous, just pretend we didn't see this.
if (Macro == 0) break;
-
+
Token Tok;
Tok.startToken();
Tok.setLocation(SourceLocation::getFromRawEncoding(Record[0]));
@@ -1114,26 +1114,26 @@ void PCHReader::MaybeAddSystemRootToFilename(std::string &Filename) {
// If this is not a relocatable PCH file, there's nothing to do.
if (!RelocatablePCH)
return;
-
+
if (Filename.empty() || Filename[0] == '/' || Filename[0] == '<')
return;
std::string FIXME = Filename;
-
+
if (isysroot == 0) {
// If no system root was given, default to '/'
Filename.insert(Filename.begin(), '/');
return;
}
-
+
unsigned Length = strlen(isysroot);
if (isysroot[Length - 1] != '/')
Filename.insert(Filename.begin(), '/');
-
+
Filename.insert(Filename.begin(), isysroot, isysroot + Length);
}
-PCHReader::PCHReadResult
+PCHReader::PCHReadResult
PCHReader::ReadPCHBlock() {
if (Stream.EnterSubBlock(pch::PCH_BLOCK_ID)) {
Error("malformed block record in PCH file");
@@ -1176,7 +1176,7 @@ PCHReader::ReadPCHBlock() {
return Failure;
}
break;
-
+
case pch::PREPROCESSOR_BLOCK_ID:
if (Stream.SkipBlock()) {
Error("malformed block record in PCH file");
@@ -1210,7 +1210,7 @@ PCHReader::ReadPCHBlock() {
Record.clear();
const char *BlobStart = 0;
unsigned BlobLen = 0;
- switch ((pch::PCHRecordTypes)Stream.ReadRecord(Code, Record,
+ switch ((pch::PCHRecordTypes)Stream.ReadRecord(Code, Record,
&BlobStart, &BlobLen)) {
default: // Default behavior: ignore.
break;
@@ -1257,10 +1257,10 @@ PCHReader::ReadPCHBlock() {
case pch::IDENTIFIER_TABLE:
IdentifierTableData = BlobStart;
if (Record[0]) {
- IdentifierLookupTable
+ IdentifierLookupTable
= PCHIdentifierLookupTable::Create(
(const unsigned char *)IdentifierTableData + Record[0],
- (const unsigned char *)IdentifierTableData,
+ (const unsigned char *)IdentifierTableData,
PCHIdentifierLookupTrait(*this));
if (PP)
PP->getIdentifierTable().setExternalIdentifierLookup(this);
@@ -1322,10 +1322,10 @@ PCHReader::ReadPCHBlock() {
case pch::METHOD_POOL:
MethodPoolLookupTableData = (const unsigned char *)BlobStart;
if (Record[0])
- MethodPoolLookupTable
+ MethodPoolLookupTable
= PCHMethodPoolLookupTable::Create(
MethodPoolLookupTableData + Record[0],
- MethodPoolLookupTableData,
+ MethodPoolLookupTableData,
PCHMethodPoolLookupTrait(*this));
TotalSelectorsInMethodPool = Record[1];
break;
@@ -1338,8 +1338,8 @@ PCHReader::ReadPCHBlock() {
case pch::SOURCE_LOCATION_OFFSETS:
SLocOffsets = (const uint32_t *)BlobStart;
TotalNumSLocEntries = Record[0];
- SourceMgr.PreallocateSLocEntries(this,
- TotalNumSLocEntries,
+ SourceMgr.PreallocateSLocEntries(this,
+ TotalNumSLocEntries,
Record[1]);
break;
@@ -1370,7 +1370,7 @@ PCHReader::ReadPCHBlock() {
OriginalFileName.assign(BlobStart, BlobLen);
MaybeAddSystemRootToFilename(OriginalFileName);
break;
-
+
case pch::COMMENT_RANGES:
Comments = (SourceRange *)BlobStart;
NumComments = BlobLen / sizeof(SourceRange);
@@ -1394,7 +1394,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
}
// Initialize the stream
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
+ StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd());
Stream.init(StreamFile);
@@ -1409,7 +1409,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
while (!Stream.AtEndOfStream()) {
unsigned Code = Stream.ReadCode();
-
+
if (Code != llvm::bitc::ENTER_SUBBLOCK) {
Error("invalid record at top-level of PCH file");
return Failure;
@@ -1455,13 +1455,13 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
}
break;
}
- }
-
+ }
+
// Check the predefines buffer.
- if (CheckPredefinesBuffer(PCHPredefines, PCHPredefinesLen,
+ if (CheckPredefinesBuffer(PCHPredefines, PCHPredefinesLen,
PCHPredefinesBufferID))
return IgnorePCH;
-
+
if (PP) {
// Initialization of keywords and pragmas occurs before the
// PCH file is read, so there may be some identifiers that were
@@ -1480,7 +1480,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
IdEnd = PP->getIdentifierTable().end();
Id != IdEnd; ++Id)
Identifiers.push_back(Id->second);
- PCHIdentifierLookupTable *IdTable
+ PCHIdentifierLookupTable *IdTable
= (PCHIdentifierLookupTable *)IdentifierLookupTable;
for (unsigned I = 0, N = Identifiers.size(); I != N; ++I) {
IdentifierInfo *II = Identifiers[I];
@@ -1490,7 +1490,7 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
PCHIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Info);
if (Pos == IdTable->end())
continue;
-
+
// Dereferencing the iterator has the effect of populating the
// IdentifierInfo node with the various declarations it needs.
(void)*Pos;
@@ -1510,7 +1510,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
assert(PP && "Forgot to set Preprocessor ?");
PP->getIdentifierTable().setExternalIdentifierLookup(this);
PP->getHeaderSearchInfo().SetExternalLookup(this);
-
+
// Load the translation unit declaration
ReadDeclRecord(DeclOffsets[0], 0);
@@ -1528,7 +1528,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
if (unsigned String = SpecialTypes[pch::SPECIAL_TYPE_CF_CONSTANT_STRING])
Context->setCFConstantStringType(GetType(String));
- if (unsigned FastEnum
+ if (unsigned FastEnum
= SpecialTypes[pch::SPECIAL_TYPE_OBJC_FAST_ENUMERATION_STATE])
Context->setObjCFastEnumerationStateType(GetType(FastEnum));
if (unsigned File = SpecialTypes[pch::SPECIAL_TYPE_FILE]) {
@@ -1564,10 +1564,10 @@ void PCHReader::InitializeContext(ASTContext &Ctx) {
Context->setsigjmp_bufDecl(Tag->getDecl());
}
}
- if (unsigned ObjCIdRedef
+ if (unsigned ObjCIdRedef
= SpecialTypes[pch::SPECIAL_TYPE_OBJC_ID_REDEFINITION])
Context->ObjCIdRedefinitionType = GetType(ObjCIdRedef);
- if (unsigned ObjCClassRedef
+ if (unsigned ObjCClassRedef
= SpecialTypes[pch::SPECIAL_TYPE_OBJC_CLASS_REDEFINITION])
Context->ObjCClassRedefinitionType = GetType(ObjCClassRedef);
}
@@ -1588,7 +1588,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) {
// Initialize the stream
llvm::BitstreamReader StreamFile;
llvm::BitstreamCursor Stream;
- StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
+ StreamFile.init((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd());
Stream.init(StreamFile);
@@ -1597,7 +1597,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) {
Stream.Read(8) != 'P' ||
Stream.Read(8) != 'C' ||
Stream.Read(8) != 'H') {
- fprintf(stderr,
+ fprintf(stderr,
"error: '%s' does not appear to be a precompiled header file\n",
PCHFileName.c_str());
return std::string();
@@ -1606,10 +1606,10 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) {
RecordData Record;
while (!Stream.AtEndOfStream()) {
unsigned Code = Stream.ReadCode();
-
+
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
unsigned BlockID = Stream.ReadSubBlockID();
-
+
// We only know the PCH subblock ID.
switch (BlockID) {
case pch::PCH_BLOCK_ID:
@@ -1618,7 +1618,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) {
return std::string();
}
break;
-
+
default:
if (Stream.SkipBlock()) {
fprintf(stderr, "error: malformed block record in PCH file\n");
@@ -1645,10 +1645,10 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) {
Record.clear();
const char *BlobStart = 0;
unsigned BlobLen = 0;
- if (Stream.ReadRecord(Code, Record, &BlobStart, &BlobLen)
+ if (Stream.ReadRecord(Code, Record, &BlobStart, &BlobLen)
== pch::ORIGINAL_FILE_NAME)
return std::string(BlobStart, BlobLen);
- }
+ }
return std::string();
}
@@ -1671,11 +1671,11 @@ bool PCHReader::ParseLanguageOptions(
const llvm::SmallVectorImpl<uint64_t> &Record) {
if (Listener) {
LangOptions LangOpts;
-
+
#define PARSE_LANGOPT(Option) \
LangOpts.Option = Record[Idx]; \
++Idx
-
+
unsigned Idx = 0;
PARSE_LANGOPT(Trigraphs);
PARSE_LANGOPT(BCPLComment);
@@ -1748,18 +1748,18 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
// Note that we are loading a type record.
LoadingTypeOrDecl Loading(*this);
-
+
Stream.JumpToBit(Offset);
RecordData Record;
unsigned Code = Stream.ReadCode();
switch ((pch::TypeCode)Stream.ReadRecord(Code, Record)) {
case pch::TYPE_EXT_QUAL: {
- assert(Record.size() == 3 &&
+ assert(Record.size() == 3 &&
"Incorrect encoding of extended qualifier type");
QualType Base = GetType(Record[0]);
QualType::GCAttrTypes GCAttr = (QualType::GCAttrTypes)Record[1];
unsigned AddressSpace = Record[2];
-
+
QualType T = Base;
if (GCAttr != QualType::GCNone)
T = Context->getObjCGCQualType(T, GCAttr);
@@ -1929,7 +1929,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
QualType UnderlyingType = GetType(Record[0]);
return Context->getTypeOfType(UnderlyingType);
}
-
+
case pch::TYPE_DECLTYPE:
return Context->getDecltypeType(ReadTypeExpr());
@@ -1974,7 +1974,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) {
QualType PCHReader::GetType(pch::TypeID ID) {
- unsigned Quals = ID & 0x07;
+ unsigned Quals = ID & 0x07;
unsigned Index = ID >> 3;
if (Index < pch::NUM_PREDEF_TYPE_IDS) {
@@ -2023,7 +2023,7 @@ QualType PCHReader::GetType(pch::TypeID ID) {
//assert(Index < TypesLoaded.size() && "Type index out-of-range");
if (!TypesLoaded[Index])
TypesLoaded[Index] = ReadTypeRecord(TypeOffsets[Index]).getTypePtr();
-
+
return QualType(TypesLoaded[Index], Quals);
}
@@ -2057,7 +2057,7 @@ Stmt *PCHReader::GetDeclStmt(uint64_t Offset) {
bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC,
llvm::SmallVectorImpl<pch::DeclID> &Decls) {
- assert(DC->hasExternalLexicalStorage() &&
+ assert(DC->hasExternalLexicalStorage() &&
"DeclContext has no lexical decls in storage");
uint64_t Offset = DeclContextOffsets[DC].first;
assert(Offset && "DeclContext has no lexical decls in storage");
@@ -2084,7 +2084,7 @@ bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC,
bool PCHReader::ReadDeclsVisibleInContext(DeclContext *DC,
llvm::SmallVectorImpl<VisibleDeclaration> &Decls) {
- assert(DC->hasExternalVisibleStorage() &&
+ assert(DC->hasExternalVisibleStorage() &&
"DeclContext has no visible decls in storage");
uint64_t Offset = DeclContextOffsets[DC].second;
assert(Offset && "DeclContext has no visible decls in storage");
@@ -2102,7 +2102,7 @@ bool PCHReader::ReadDeclsVisibleInContext(DeclContext *DC,
(void)RecCode;
assert(RecCode == pch::DECL_CONTEXT_VISIBLE && "Expected visible block");
if (Record.size() == 0)
- return false;
+ return false;
Decls.clear();
@@ -2143,7 +2143,7 @@ void PCHReader::StartTranslationUnit(ASTConsumer *Consumer) {
void PCHReader::PrintStats() {
std::fprintf(stderr, "*** PCH Statistics:\n");
- unsigned NumTypesLoaded
+ unsigned NumTypesLoaded
= TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
(Type *)0);
unsigned NumDeclsLoaded
@@ -2153,7 +2153,7 @@ void PCHReader::PrintStats() {
= IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
IdentifiersLoaded.end(),
(IdentifierInfo *)0);
- unsigned NumSelectorsLoaded
+ unsigned NumSelectorsLoaded
= SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
SelectorsLoaded.end(),
Selector());
@@ -2245,7 +2245,7 @@ void PCHReader::InitializeSema(Sema &S) {
IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
// Try to find this name within our on-disk hash table
- PCHIdentifierLookupTable *IdTable
+ PCHIdentifierLookupTable *IdTable
= (PCHIdentifierLookupTable *)IdentifierLookupTable;
std::pair<const char*, unsigned> Key(NameStart, NameEnd - NameStart);
PCHIdentifierLookupTable::iterator Pos = IdTable->find(Key);
@@ -2258,7 +2258,7 @@ IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
return *Pos;
}
-std::pair<ObjCMethodList, ObjCMethodList>
+std::pair<ObjCMethodList, ObjCMethodList>
PCHReader::ReadMethodPool(Selector Sel) {
if (!MethodPoolLookupTable)
return std::pair<ObjCMethodList, ObjCMethodList>();
@@ -2286,7 +2286,7 @@ void PCHReader::SetIdentifierInfo(unsigned ID, IdentifierInfo *II) {
/// identifier.
///
/// If the PCH reader is currently in a state where the given declaration IDs
-/// cannot safely be resolved, they are queued until it is safe to resolve
+/// cannot safely be resolved, they are queued until it is safe to resolve
/// them.
///
/// \param II an IdentifierInfo that refers to one or more globally-visible
@@ -2298,8 +2298,8 @@ void PCHReader::SetIdentifierInfo(unsigned ID, IdentifierInfo *II) {
/// \param Nonrecursive should be true to indicate that the caller knows that
/// this call is non-recursive, and therefore the globally-visible declarations
/// will not be placed onto the pending queue.
-void
-PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II,
+void
+PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II,
const llvm::SmallVectorImpl<uint32_t> &DeclIDs,
bool Nonrecursive) {
if (CurrentlyLoadingTypeOrDecl && !Nonrecursive) {
@@ -2310,7 +2310,7 @@ PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II,
PII.DeclIDs.push_back(DeclIDs[I]);
return;
}
-
+
for (unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
if (SemaObj) {
@@ -2331,12 +2331,12 @@ PCHReader::SetGloballyVisibleDecls(IdentifierInfo *II,
IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) {
if (ID == 0)
return 0;
-
+
if (!IdentifierTableData || IdentifiersLoaded.empty()) {
Error("no identifier table in PCH file");
return 0;
}
-
+
assert(PP && "Forgot to set Preprocessor ?");
if (!IdentifiersLoaded[ID - 1]) {
uint32_t Offset = IdentifierOffsets[ID - 1];
@@ -2348,10 +2348,10 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) {
const char *StrLenPtr = Str - 2;
unsigned StrLen = (((unsigned) StrLenPtr[0])
| (((unsigned) StrLenPtr[1]) << 8)) - 1;
- IdentifiersLoaded[ID - 1]
+ IdentifiersLoaded[ID - 1]
= &PP->getIdentifierTable().get(Str, Str + StrLen);
}
-
+
return IdentifiersLoaded[ID - 1];
}
@@ -2362,7 +2362,7 @@ void PCHReader::ReadSLocEntry(unsigned ID) {
Selector PCHReader::DecodeSelector(unsigned ID) {
if (ID == 0)
return Selector();
-
+
if (!MethodPoolLookupTableData)
return Selector();
@@ -2376,14 +2376,14 @@ Selector PCHReader::DecodeSelector(unsigned ID) {
// Load this selector from the selector table.
// FIXME: endianness portability issues with SelectorOffsets table
PCHMethodPoolLookupTrait Trait(*this);
- SelectorsLoaded[Index]
+ SelectorsLoaded[Index]
= Trait.ReadKey(MethodPoolLookupTableData + SelectorOffsets[Index], 0);
}
return SelectorsLoaded[Index];
}
-DeclarationName
+DeclarationName
PCHReader::ReadDeclarationName(const RecordData &Record, unsigned &Idx) {
DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++];
switch (Kind) {
@@ -2478,7 +2478,7 @@ SwitchCase *PCHReader::getSwitchCaseWithID(unsigned ID) {
/// \brief Record that the given label statement has been
/// deserialized and has the given ID.
void PCHReader::RecordLabelStmt(LabelStmt *S, unsigned ID) {
- assert(LabelStmts.find(ID) == LabelStmts.end() &&
+ assert(LabelStmts.find(ID) == LabelStmts.end() &&
"Deserialized label twice");
LabelStmts[ID] = S;
@@ -2493,9 +2493,9 @@ void PCHReader::RecordLabelStmt(LabelStmt *S, unsigned ID) {
// If we've already seen any address-label statements that point to
// this label, resolve them now.
typedef std::multimap<unsigned, AddrLabelExpr *>::iterator AddrLabelIter;
- std::pair<AddrLabelIter, AddrLabelIter> AddrLabels
+ std::pair<AddrLabelIter, AddrLabelIter> AddrLabels
= UnresolvedAddrLabelExprs.equal_range(ID);
- for (AddrLabelIter AddrLabel = AddrLabels.first;
+ for (AddrLabelIter AddrLabel = AddrLabels.first;
AddrLabel != AddrLabels.second; ++AddrLabel)
AddrLabel->second->setLabel(S);
UnresolvedAddrLabelExprs.erase(AddrLabels.first, AddrLabels.second);
@@ -2542,7 +2542,7 @@ void PCHReader::SetLabelOf(AddrLabelExpr *S, unsigned ID) {
}
-PCHReader::LoadingTypeOrDecl::LoadingTypeOrDecl(PCHReader &Reader)
+PCHReader::LoadingTypeOrDecl::LoadingTypeOrDecl(PCHReader &Reader)
: Reader(Reader), Parent(Reader.CurrentlyLoadingTypeOrDecl) {
Reader.CurrentlyLoadingTypeOrDecl = this;
}
@@ -2559,5 +2559,5 @@ PCHReader::LoadingTypeOrDecl::~LoadingTypeOrDecl() {
}
}
- Reader.CurrentlyLoadingTypeOrDecl = Parent;
+ Reader.CurrentlyLoadingTypeOrDecl = Parent;
}
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index cc8712acd0..03ac3aad22 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -94,7 +94,7 @@ void PCHDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
void PCHDeclReader::VisitNamedDecl(NamedDecl *ND) {
VisitDecl(ND);
- ND->setDeclName(Reader.ReadDeclarationName(Record, Idx));
+ ND->setDeclName(Reader.ReadDeclarationName(Record, Idx));
}
void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) {
@@ -163,9 +163,9 @@ public:
#define ABSTRACT_TYPELOC(CLASS)
#define TYPELOC(CLASS, PARENT, TYPE) \
- void Visit##CLASS(CLASS TyLoc);
+ void Visit##CLASS(CLASS TyLoc);
#include "clang/AST/TypeLocNodes.def"
-
+
void VisitTypeLoc(TypeLoc TyLoc) {
assert(0 && "A type loc wrapper was not handled!");
}
@@ -447,10 +447,10 @@ void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) {
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
- BD->setParams(*Reader.getContext(), Params.data(), NumParams);
+ BD->setParams(*Reader.getContext(), Params.data(), NumParams);
}
-std::pair<uint64_t, uint64_t>
+std::pair<uint64_t, uint64_t>
PCHDeclReader::VisitDeclContext(DeclContext *DC) {
uint64_t LexicalOffset = Record[Idx++];
uint64_t VisibleOffset = Record[Idx++];
@@ -464,13 +464,13 @@ PCHDeclReader::VisitDeclContext(DeclContext *DC) {
/// \brief Reads attributes from the current stream position.
Attr *PCHReader::ReadAttributes() {
unsigned Code = DeclsCursor.ReadCode();
- assert(Code == llvm::bitc::UNABBREV_RECORD &&
+ assert(Code == llvm::bitc::UNABBREV_RECORD &&
"Expected unabbreviated record"); (void)Code;
-
+
RecordData Record;
unsigned Idx = 0;
unsigned RecCode = DeclsCursor.ReadRecord(Code, Record);
- assert(RecCode == pch::DECL_ATTR && "Expected attribute record");
+ assert(RecCode == pch::DECL_ATTR && "Expected attribute record");
(void)RecCode;
#define SIMPLE_ATTR(Name) \
@@ -501,12 +501,12 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(AnalyzerNoReturn);
STRING_ATTR(Annotate);
STRING_ATTR(AsmLabel);
-
+
case Attr::Blocks:
New = ::new (*Context) BlocksAttr(
(BlocksAttr::BlocksAttrTypes)Record[Idx++]);
break;
-
+
case Attr::Cleanup:
New = ::new (*Context) CleanupAttr(
cast<FunctionDecl>(GetDecl(Record[Idx++])));
@@ -519,7 +519,7 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(Deprecated);
UNSIGNED_ATTR(Destructor);
SIMPLE_ATTR(FastCall);
-
+
case Attr::Format: {
std::string Type = ReadString(Record, Idx);
unsigned FormatIdx = Record[Idx++];
@@ -527,13 +527,13 @@ Attr *PCHReader::ReadAttributes() {
New = ::new (*Context) FormatAttr(Type, FormatIdx, FirstArg);
break;
}
-
+
case Attr::FormatArg: {
unsigned FormatIdx = Record[Idx++];
New = ::new (*Context) FormatArgAttr(FormatIdx);
break;
}
-
+
case Attr::Sentinel: {
int sentinel = Record[Idx++];
int nullPos = Record[Idx++];
@@ -542,7 +542,7 @@ Attr *PCHReader::ReadAttributes() {
}
SIMPLE_ATTR(GNUInline);
-
+
case Attr::IBOutletKind:
New = ::new (*Context) IBOutletAttr();
break;
@@ -552,7 +552,7 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(NoInline);
SIMPLE_ATTR(NoReturn);
SIMPLE_ATTR(NoThrow);
-
+
case Attr::NonNull: {
unsigned Size = Record[Idx++];
llvm::SmallVector<unsigned, 16> ArgNums;
@@ -561,7 +561,7 @@ Attr *PCHReader::ReadAttributes() {
New = ::new (*Context) NonNullAttr(ArgNums.data(), Size);
break;
}
-
+
case Attr::ReqdWorkGroupSize: {
unsigned X = Record[Idx++];
unsigned Y = Record[Idx++];
@@ -585,7 +585,7 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(Unavailable);
SIMPLE_ATTR(Unused);
SIMPLE_ATTR(Used);
-
+
case Attr::Visibility:
New = ::new (*Context) VisibilityAttr(
(VisibilityAttr::VisibilityTypes)Record[Idx++]);
@@ -624,7 +624,7 @@ Attr *PCHReader::ReadAttributes() {
/// \brief Note that we have loaded the declaration with the given
/// Index.
-///
+///
/// This routine notes that this declaration has already been loaded,
/// so that future GetDecl calls will return this declaration rather
/// than trying to load a new declaration.
@@ -656,7 +656,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
// Note that we are loading a declaration record.
LoadingTypeOrDecl Loading(*this);
-
+
DeclsCursor.JumpToBit(Offset);
RecordData Record;
unsigned Code = DeclsCursor.ReadCode();
@@ -689,11 +689,11 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
0, llvm::APSInt());
break;
case pch::DECL_FUNCTION:
- D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
+ D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
QualType(), 0);
break;
case pch::DECL_OBJC_METHOD:
- D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
+ D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
Selector(), QualType(), 0);
break;
case pch::DECL_OBJC_INTERFACE:
@@ -707,7 +707,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0);
break;
case pch::DECL_OBJC_AT_DEFS_FIELD:
- D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0,
+ D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0,
QualType(), 0);
break;
case pch::DECL_OBJC_CLASS:
@@ -733,11 +733,11 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
break;
case pch::DECL_OBJC_PROPERTY_IMPL:
D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(),
- SourceLocation(), 0,
+ SourceLocation(), 0,
ObjCPropertyImplDecl::Dynamic, 0);
break;
case pch::DECL_FIELD:
- D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0,
+ D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0,
false);
break;
case pch::DECL_VAR:
@@ -750,7 +750,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
break;
case pch::DECL_PARM_VAR:
- D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
+ D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
VarDecl::None, 0);
break;
case pch::DECL_ORIGINAL_PARM_VAR:
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index dfcc794a5d..45e2bfb179 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -106,7 +106,7 @@ namespace {
unsigned VisitObjCMessageExpr(ObjCMessageExpr *E);
unsigned VisitObjCSuperExpr(ObjCSuperExpr *E);
unsigned VisitObjCIsaExpr(ObjCIsaExpr *E);
-
+
unsigned VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
unsigned VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
unsigned VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
@@ -132,7 +132,7 @@ unsigned PCHStmtReader::VisitNullStmt(NullStmt *S) {
unsigned PCHStmtReader::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
unsigned NumStmts = Record[Idx++];
- S->setStmts(*Reader.getContext(),
+ S->setStmts(*Reader.getContext(),
StmtStack.data() + StmtStack.size() - NumStmts, NumStmts);
S->setLBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setRBracLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -195,7 +195,7 @@ unsigned PCHStmtReader::VisitSwitchStmt(SwitchStmt *S) {
PrevSC->setNextSwitchCase(SC);
else
S->setSwitchCaseList(SC);
-
+
// Retain this SwitchCase, since SwitchStmt::addSwitchCase() would
// normally retain it (but we aren't calling addSwitchCase).
SC->Retain();
@@ -298,8 +298,8 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
S->setVolatile(Record[Idx++]);
S->setSimple(Record[Idx++]);
-
- unsigned StackIdx
+
+ unsigned StackIdx
= StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1);
S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
@@ -372,12 +372,12 @@ unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
unsigned PCHStmtReader::VisitStringLiteral(StringLiteral *E) {
VisitExpr(E);
unsigned Len = Record[Idx++];
- assert(Record[Idx] == E->getNumConcatenated() &&
+ assert(Record[Idx] == E->getNumConcatenated() &&
"Wrong number of concatenated tokens!");
++Idx;
E->setWide(Record[Idx++]);
- // Read string data
+ // Read string data
llvm::SmallVector<char, 16> Str(&Record[Idx], &Record[Idx] + Len);
E->setStrData(*Reader.getContext(), Str.data(), Len);
Idx += Len;
@@ -536,7 +536,7 @@ unsigned PCHStmtReader::VisitInitListExpr(InitListExpr *E) {
unsigned NumInits = Record[Idx++];
E->reserveInits(NumInits);
for (unsigned I = 0; I != NumInits; ++I)
- E->updateInit(I,
+ E->updateInit(I,
cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I]));
E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back()));
E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -563,11 +563,11 @@ unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
switch ((pch::DesignatorTypes)Record[Idx++]) {
case pch::DESIG_FIELD_DECL: {
FieldDecl *Field = cast<FieldDecl>(Reader.GetDecl(Record[Idx++]));
- SourceLocation DotLoc
+ SourceLocation DotLoc
= SourceLocation::getFromRawEncoding(Record[Idx++]);
- SourceLocation FieldLoc
+ SourceLocation FieldLoc
= SourceLocation::getFromRawEncoding(Record[Idx++]);
- Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
+ Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
FieldLoc));
Designators.back().setField(Field);
break;
@@ -575,14 +575,14 @@ unsigned PCHStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
case pch::DESIG_FIELD_NAME: {
const IdentifierInfo *Name = Reader.GetIdentifierInfo(Record, Idx);
- SourceLocation DotLoc
+ SourceLocation DotLoc
= SourceLocation::getFromRawEncoding(Record[Idx++]);
- SourceLocation FieldLoc
+ SourceLocation FieldLoc
= SourceLocation::getFromRawEncoding(Record[Idx++]);
Designators.push_back(Designator(Name, DotLoc, FieldLoc));
break;
}
-
+
case pch::DESIG_ARRAY: {
unsigned Index = Record[Idx++];
SourceLocation LBracketLoc
@@ -669,7 +669,7 @@ unsigned PCHStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
unsigned NumExprs = Record[Idx++];
- E->setExprs(*Reader.getContext(),
+ E->setExprs(*Reader.getContext(),
(Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs);
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
@@ -766,7 +766,7 @@ unsigned PCHStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
E->setRightLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setSelector(Reader.GetSelector(Record, Idx));
E->setMethodDecl(cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
-
+
E->setReceiver(
cast_or_null<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
if (!E->getReceiver()) {
@@ -896,8 +896,8 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
Finished = true;
break;
- case pch::STMT_NULL_PTR:
- S = 0;
+ case pch::STMT_NULL_PTR:
+ S = 0;
break;
case pch::STMT_NULL:
@@ -935,7 +935,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::STMT_DO:
S = new (Context) DoStmt(Empty);
break;
-
+
case pch::STMT_FOR:
S = new (Context) ForStmt(Empty);
break;
@@ -943,7 +943,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::STMT_GOTO:
S = new (Context) GotoStmt(Empty);
break;
-
+
case pch::STMT_INDIRECT_GOTO:
S = new (Context) IndirectGotoStmt(Empty);
break;
@@ -971,25 +971,25 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_PREDEFINED:
S = new (Context) PredefinedExpr(Empty);
break;
-
- case pch::EXPR_DECL_REF:
- S = new (Context) DeclRefExpr(Empty);
+
+ case pch::EXPR_DECL_REF:
+ S = new (Context) DeclRefExpr(Empty);
break;
-
- case pch::EXPR_INTEGER_LITERAL:
+
+ case pch::EXPR_INTEGER_LITERAL:
S = new (Context) IntegerLiteral(Empty);
break;
-
+
case pch::EXPR_FLOATING_LITERAL:
S = new (Context) FloatingLiteral(Empty);
break;
-
+
case pch::EXPR_IMAGINARY_LITERAL:
S = new (Context) ImaginaryLiteral(Empty);
break;
case pch::EXPR_STRING_LITERAL:
- S = StringLiteral::CreateEmpty(*Context,
+ S = StringLiteral::CreateEmpty(*Context,
Record[PCHStmtReader::NumExprFields + 1]);
break;
@@ -1056,7 +1056,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_DESIGNATED_INIT:
S = DesignatedInitExpr::CreateEmpty(*Context,
Record[PCHStmtReader::NumExprFields] - 1);
-
+
break;
case pch::EXPR_IMPLICIT_VALUE_INIT:
@@ -1090,7 +1090,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_SHUFFLE_VECTOR:
S = new (Context) ShuffleVectorExpr(Empty);
break;
-
+
case pch::EXPR_BLOCK:
S = new (Context) BlockExpr(Empty);
break;
@@ -1098,7 +1098,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::EXPR_BLOCK_DECL_REF:
S = new (Context) BlockDeclRefExpr(Empty);
break;
-
+
case pch::EXPR_OBJC_STRING_LITERAL:
S = new (Context) ObjCStringLiteral(Empty);
break;
@@ -1147,7 +1147,7 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
case pch::STMT_OBJC_AT_THROW:
S = new (Context) ObjCAtThrowStmt(Empty);
break;
-
+
case pch::EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(*Context, Empty);
break;
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 86a52fcf52..a6918e4c85 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -13,7 +13,7 @@
#include "clang/Frontend/PCHWriter.h"
#include "../Sema/Sema.h" // FIXME: move header into include/clang/Sema
-#include "../Sema/IdentifierResolver.h" // FIXME: move header
+#include "../Sema/IdentifierResolver.h" // FIXME: move header
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclContextInternals.h"
@@ -50,7 +50,7 @@ namespace {
/// \brief Type code that corresponds to the record generated.
pch::TypeCode Code;
- PCHTypeWriter(PCHWriter &Writer, PCHWriter::RecordData &Record)
+ PCHTypeWriter(PCHWriter &Writer, PCHWriter::RecordData &Record)
: Writer(Writer), Record(Record), Code(pch::TYPE_EXT_QUAL) { }
void VisitArrayType(const ArrayType *T);
@@ -92,7 +92,7 @@ void PCHTypeWriter::VisitPointerType(const PointerType *T) {
}
void PCHTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Writer.AddTypeRef(T->getPointeeType(), Record);
Code = pch::TYPE_BLOCK_POINTER;
}
@@ -107,8 +107,8 @@ void PCHTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
}
void PCHTypeWriter::VisitMemberPointerType(const MemberPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
- Writer.AddTypeRef(QualType(T->getClass(), 0), Record);
+ Writer.AddTypeRef(T->getPointeeType(), Record);
+ Writer.AddTypeRef(QualType(T->getClass(), 0), Record);
Code = pch::TYPE_MEMBER_POINTER;
}
@@ -211,7 +211,7 @@ void PCHTypeWriter::VisitDecltypeType(const DecltypeType *T) {
void PCHTypeWriter::VisitTagType(const TagType *T) {
Writer.AddDeclRef(T->getDecl(), Record);
- assert(!T->isBeingDefined() &&
+ assert(!T->isBeingDefined() &&
"Cannot serialize in the middle of a type definition");
}
@@ -231,7 +231,7 @@ void PCHTypeWriter::VisitElaboratedType(const ElaboratedType *T) {
Code = pch::TYPE_ELABORATED;
}
-void
+void
PCHTypeWriter::VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
// FIXME: Serialize this type (C++ only)
@@ -254,7 +254,7 @@ void PCHTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
void
PCHTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Writer.AddTypeRef(T->getPointeeType(), Record);
Record.push_back(T->getNumProtocols());
for (ObjCInterfaceType::qual_iterator I = T->qual_begin(),
E = T->qual_end(); I != E; ++I)
@@ -362,14 +362,14 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
RECORD(STMT_OBJC_AT_THROW);
#undef RECORD
}
-
+
void PCHWriter::WriteBlockInfoBlock() {
RecordData Record;
Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
-
+
#define BLOCK(X) EmitBlockID(pch::X ## _ID, #X, Stream, Record)
#define RECORD(X) EmitRecordID(pch::X, #X, Stream, Record)
-
+
// PCH Top-Level Block.
BLOCK(PCH_BLOCK);
RECORD(ORIGINAL_FILE_NAME);
@@ -392,7 +392,7 @@ void PCHWriter::WriteBlockInfoBlock() {
RECORD(STAT_CACHE);
RECORD(EXT_VECTOR_DECLS);
RECORD(COMMENT_RANGES);
-
+
// SourceManager Block.
BLOCK(SOURCE_MANAGER_BLOCK);
RECORD(SM_SLOC_FILE_ENTRY);
@@ -401,7 +401,7 @@ void PCHWriter::WriteBlockInfoBlock() {
RECORD(SM_SLOC_INSTANTIATION_ENTRY);
RECORD(SM_LINE_TABLE);
RECORD(SM_HEADER_FILE_INFO);
-
+
// Preprocessor Block.
BLOCK(PREPROCESSOR_BLOCK);
RECORD(PP_MACRO_OBJECT_LIKE);
@@ -475,7 +475,7 @@ void PCHWriter::WriteBlockInfoBlock() {
/// \brief Adjusts the given filename to only write out the portion of the
/// filename that is not part of the system root directory.
-///
+///
/// \param Filename the file name to adjust.
///
/// \param isysroot When non-NULL, the PCH file is a relocatable PCH file and
@@ -483,29 +483,29 @@ void PCHWriter::WriteBlockInfoBlock() {
///
/// \returns either the original filename (if it needs no adjustment) or the
/// adjusted filename (which points into the @p Filename parameter).
-static const char *
+static const char *
adjustFilenameForRelocatablePCH(const char *Filename, const char *isysroot) {
assert(Filename && "No file name to adjust?");
-
+
if (!isysroot)
return Filename;
-
+
// Verify that the filename and the system root have the same prefix.
unsigned Pos = 0;
for (; Filename[Pos] && isysroot[Pos]; ++Pos)
if (Filename[Pos] != isysroot[Pos])
return Filename; // Prefixes don't match.
-
+
// We hit the end of the filename before we hit the end of the system root.
if (!Filename[Pos])
return Filename;
-
+
// If the file name has a '/' at the current position, skip over the '/'.
// We distinguish sysroot-based includes from absolute includes by the
// absence of '/' at the beginning of sysroot-based includes.
if (Filename[Pos] == '/')
++Pos;
-
+
return Filename + Pos;
}
@@ -524,7 +524,7 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
MetaAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Target triple
unsigned MetaAbbrevCode = Stream.EmitAbbrev(MetaAbbrev);
-
+
RecordData Record;
Record.push_back(pch::METADATA);
Record.push_back(pch::VERSION_MAJOR);
@@ -534,7 +534,7 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
Record.push_back(isysroot != 0);
const std::string &TripleStr = Target.getTriple().getTriple();
Stream.EmitRecordWithBlob(MetaAbbrevCode, Record, TripleStr);
-
+
// Original file name
SourceManager &SM = Context.getSourceManager();
if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
@@ -545,7 +545,7 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
llvm::sys::Path MainFilePath(MainFile->getName());
std::string MainFileName;
-
+
if (!MainFilePath.isAbsolute()) {
llvm::sys::Path P = llvm::sys::Path::GetCurrentDirectory();
P.appendComponent(MainFilePath.str());
@@ -555,7 +555,7 @@ void PCHWriter::WriteMetadata(ASTContext &Context, const char *isysroot) {
}
const char *MainFileNameStr = MainFileName.c_str();
- MainFileNameStr = adjustFilenameForRelocatablePCH(MainFileNameStr,
+ MainFileNameStr = adjustFilenameForRelocatablePCH(MainFileNameStr,
isysroot);
RecordData Record;
Record.push_back(pch::ORIGINAL_FILE_NAME);
@@ -579,11 +579,11 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
Record.push_back(LangOpts.CPlusPlus); // C++ Support
Record.push_back(LangOpts.CPlusPlus0x); // C++0x Support
Record.push_back(LangOpts.CXXOperatorNames); // Treat C++ operator names as keywords.
-
+
Record.push_back(LangOpts.ObjC1); // Objective-C 1 support enabled.
Record.push_back(LangOpts.ObjC2); // Objective-C 2 support enabled.
Record.push_back(LangOpts.ObjCNonFragileABI); // Objective-C modern abi enabled
-
+
Record.push_back(LangOpts.PascalStrings); // Allow Pascal strings
Record.push_back(LangOpts.WritableStrings); // Allow writable strings
Record.push_back(LangOpts.LaxVectorConversions);
@@ -610,7 +610,7 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
// may be ripped out at any time.
Record.push_back(LangOpts.Optimize); // Whether __OPTIMIZE__ should be defined.
- Record.push_back(LangOpts.OptimizeSize); // Whether __OPTIMIZE_SIZE__ should be
+ Record.push_back(LangOpts.OptimizeSize); // Whether __OPTIMIZE_SIZE__ should be
// defined.
Record.push_back(LangOpts.Static); // Should __STATIC__ be defined (as
// opposed to __DYNAMIC__).
@@ -641,15 +641,15 @@ class VISIBILITY_HIDDEN PCHStatCacheTrait {
public:
typedef const char * key_type;
typedef key_type key_type_ref;
-
+
typedef std::pair<int, struct stat> data_type;
typedef const data_type& data_type_ref;
static unsigned ComputeHash(const char *path) {
return BernsteinHash(path);
}
-
- std::pair<unsigned,unsigned>
+
+ std::pair<unsigned,unsigned>
EmitKeyDataLength(llvm::raw_ostream& Out, const char *path,
data_type_ref Data) {
unsigned StrLen = strlen(path);
@@ -660,19 +660,19 @@ public:
clang::io::Emit8(Out, DataLen);
return std::make_pair(StrLen + 1, DataLen);
}
-
+
void EmitKey(llvm::raw_ostream& Out, const char *path, unsigned KeyLen) {
Out.write(path, KeyLen);
}
-
+
void EmitData(llvm::raw_ostream& Out, key_type_ref,
data_type_ref Data, unsigned DataLen) {
using namespace clang::io;
uint64_t Start = Out.tell(); (void)Start;
-
+
// Result of stat()
Emit8(Out, Data.first? 1 : 0);
-
+
if (Data.first == 0) {
Emit32(Out, (uint32_t) Data.second.st_ino);
Emit32(Out, (uint32_t) Data.second.st_dev);
@@ -693,16 +693,16 @@ void PCHWriter::WriteStatCache(MemorizeStatCalls &StatCalls,
// stat() call.
OnDiskChainedHashTableGenerator<PCHStatCacheTrait> Generator;
unsigned NumStatEntries = 0;
- for (MemorizeStatCalls::iterator Stat = StatCalls.begin(),
+ for (MemorizeStatCalls::iterator Stat = StatCalls.begin(),
StatEnd = StatCalls.end();
Stat != StatEnd; ++Stat, ++NumStatEntries) {
const char *Filename = Stat->first();
Filename = adjustFilenameForRelocatablePCH(Filename, isysroot);
Generator.insert(Filename, Stat->second);
}
-
+
// Create the on-disk hash table in a buffer.
- llvm::SmallString<4096> StatCacheData;
+ llvm::SmallString<4096> StatCacheData;
uint32_t BucketOffset;
{
llvm::raw_svector_ostream Out(StatCacheData);
@@ -821,16 +821,16 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
if (FilenameLen)
Record.insert(Record.end(), Filename, Filename + FilenameLen);
}
-
+
// Emit the line entries
for (LineTableInfo::iterator L = LineTable.begin(), LEnd = LineTable.end();
L != LEnd; ++L) {
// Emit the file ID
Record.push_back(L->first);
-
+
// Emit the line entries
Record.push_back(L->second.size());
- for (std::vector<LineEntry>::iterator LE = L->second.begin(),
+ for (std::vector<LineEntry>::iterator LE = L->second.begin(),
LEEnd = L->second.end();
LE != LEEnd; ++LE) {
Record.push_back(LE->FileOffset);
@@ -844,9 +844,9 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
}
// Write out entries for all of the header files we know about.
- HeaderSearch &HS = PP.getHeaderSearchInfo();
+ HeaderSearch &HS = PP.getHeaderSearchInfo();
Record.clear();
- for (HeaderSearch::header_file_iterator I = HS.header_file_begin(),
+ for (HeaderSearch::header_file_iterator I = HS.header_file_begin(),
E = HS.header_file_end();
I != E; ++I) {
Record.push_back(I->isImport);
@@ -862,7 +862,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
std::vector<uint32_t> SLocEntryOffsets;
RecordData PreloadSLocs;
SLocEntryOffsets.reserve(SourceMgr.sloc_entry_size() - 1);
- for (SourceManager::sloc_entry_iterator
+ for (SourceManager::sloc_entry_iterator
SLoc = SourceMgr.sloc_entry_begin() + 1,
SLocEnd = SourceMgr.sloc_entry_end();
SLoc != SLocEnd; ++SLoc) {
@@ -892,7 +892,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
if (Content->Entry) {
// The source location entry is a file. The blob associated
// with this entry is the file name.
-
+
// Turn the file name into an absolute path, if it isn't already.
const char *Filename = Content->Entry->getName();
llvm::sys::Path FilePath(Filename, strlen(Filename));
@@ -903,7 +903,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
FilenameStr = P.str();
Filename = FilenameStr.c_str();
}
-
+
Filename = adjustFilenameForRelocatablePCH(Filename, isysroot);
Stream.EmitRecordWithBlob(SLocFileAbbrv, Record, Filename);
@@ -962,13 +962,13 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // next offset
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(Abbrev);
-
+
Record.clear();
Record.push_back(pch::SOURCE_LOCATION_OFFSETS);
Record.push_back(SLocEntryOffsets.size());
Record.push_back(SourceMgr.getNextOffset());
Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
- (const char *)&SLocEntryOffsets.front(),
+ (const char *)&SLocEntryOffsets.front(),
SLocEntryOffsets.size()*sizeof(SLocEntryOffsets[0]));
// Write the source location entry preloads array, telling the PCH
@@ -995,12 +995,12 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
// Enter the preprocessor block.
Stream.EnterSubblock(pch::PREPROCESSOR_BLOCK_ID, 2);
-
+
// If the PCH file contains __DATE__ or __TIME__ emit a warning about this.
// FIXME: use diagnostics subsystem for localization etc.
if (PP.SawDateOrTime())
fprintf(stderr, "warning: precompiled header used __DATE__ or __TIME__.\n");
-
+
// Loop over all the macro definitions that are live at the end of the file,
// emitting each to the PP section.
for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();
@@ -1019,13 +1019,13 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
MacroOffsets[I->first] = Stream.GetCurrentBitNo();
Record.push_back(MI->getDefinitionLoc().getRawEncoding());
Record.push_back(MI->isUsed());
-
+
unsigned Code;
if (MI->isObjectLike()) {
Code = pch::PP_MACRO_OBJECT_LIKE;
} else {
Code = pch::PP_MACRO_FUNCTION_LIKE;
-
+
Record.push_back(MI->isC99Varargs());
Record.push_back(MI->isGNUVarargs());
Record.push_back(MI->getNumArgs());
@@ -1042,19 +1042,19 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
// tokens in it because they are created by the parser, and thus can't be
// in a macro definition.
const Token &Tok = MI->getReplacementToken(TokNo);
-
+
Record.push_back(Tok.getLocation().getRawEncoding());
Record.push_back(Tok.getLength());
// FIXME: When reading literal tokens, reconstruct the literal pointer if
// it is needed.
AddIdentifierRef(Tok.getIdentifierInfo(), Record);
-
+
// FIXME: Should translate token kind to a stable encoding.
Record.push_back(Tok.getKind());
// FIXME: Should translate token flags to a stable encoding.
Record.push_back(Tok.getFlags());
-
+
Stream.EmitRecord(pch::PP_TOKEN, Record);
Record.clear();
}
@@ -1065,18 +1065,18 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
void PCHWriter::WriteComments(ASTContext &Context) {
using namespace llvm;
-
+
if (Context.Comments.empty())
return;
-
+
BitCodeAbbrev *CommentAbbrev = new BitCodeAbbrev();
CommentAbbrev->Add(BitCodeAbbrevOp(pch::COMMENT_RANGES));
CommentAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned CommentCode = Stream.EmitAbbrev(CommentAbbrev);
-
+
RecordData Record;
Record.push_back(pch::COMMENT_RANGES);
- Stream.EmitRecordWithBlob(CommentCode, Record,
+ Stream.EmitRecordWithBlob(CommentCode, Record,
(const char*)&Context.Comments[0],
Context.Comments.size() * sizeof(SourceRange));
}
@@ -1090,7 +1090,7 @@ void PCHWriter::WriteType(const Type *T) {
pch::TypeID &ID = TypeIDs[T];
if (ID == 0) // we haven't seen this type before.
ID = NextTypeID++;
-
+
// Record the offset for this type.
if (TypeOffsets.size() == ID - pch::NUM_PREDEF_TYPE_IDS)
TypeOffsets.push_back(Stream.GetCurrentBitNo());
@@ -1100,7 +1100,7 @@ void PCHWriter::WriteType(const Type *T) {
}
RecordData Record;
-
+
// Emit the type's representation.
PCHTypeWriter W(*this, Record);
switch (T->getTypeClass()) {
@@ -1154,7 +1154,7 @@ void PCHWriter::WriteTypesBlock(ASTContext &Context) {
///
/// \returns the offset of the DECL_CONTEXT_LEXICAL block within the
/// bistream, or 0 if no block was written.
-uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
+uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
DeclContext *DC) {
if (DC->decls_empty())
return 0;
@@ -1206,7 +1206,7 @@ uint64_t PCHWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
AddDeclarationName(D->first, Record);
DeclContext::lookup_result Result = D->second.getLookupResult(Context);
Record.push_back(Result.second - Result.first);
- for(; Result.first != Result.second; ++Result.first)
+ for (; Result.first != Result.second; ++Result.first)
AddDeclRef(*Result.first, Record);
}
@@ -1230,12 +1230,12 @@ class VISIBILITY_HIDDEN PCHMethodPoolTrait {
public:
typedef Selector key_type;
typedef key_type key_type_ref;
-
+
typedef std::pair<ObjCMethodList, ObjCMethodList> data_type;
typedef const data_type& data_type_ref;
explicit PCHMethodPoolTrait(PCHWriter &Writer) : Writer(Writer) { }
-
+
static unsigned ComputeHash(Selector Sel) {
unsigned N = Sel.getNumArgs();
if (N == 0)
@@ -1246,27 +1246,27 @@ public:
R = clang::BernsteinHashPartial(II->getName(), II->getLength(), R);
return R;
}
-
- std::pair<unsigned,unsigned>
+
+ std::pair<unsigned,unsigned>
EmitKeyDataLength(llvm::raw_ostream& Out, Selector Sel,
data_type_ref Methods) {
unsigned KeyLen = 2 + (Sel.getNumArgs()? Sel.getNumArgs() * 4 : 4);
clang::io::Emit16(Out, KeyLen);
unsigned DataLen = 2 + 2; // 2 bytes for each of the method counts
- for (const ObjCMethodList *Method = &Methods.first; Method;
+ for (const ObjCMethodList *Method = &Methods.first; Method;
Method = Method->Next)
if (Method->Method)
DataLen += 4;
- for (const ObjCMethodList *Method = &Methods.second; Method;
+ for (const ObjCMethodList *Method = &Methods.second; Method;
Method = Method->Next)
if (Method->Method)
DataLen += 4;
clang::io::Emit16(Out, DataLen);
return std::make_pair(KeyLen, DataLen);
}
-
+
void EmitKey(llvm::raw_ostream& Out, Selector Sel, unsigned) {
- uint64_t Start = Out.tell();
+ uint64_t Start = Out.tell();
assert((Start >> 32) == 0 && "Selector key offset too large");
Writer.SetSelectorOffset(Sel, Start);
unsigned N = Sel.getNumArgs();
@@ -1274,32 +1274,32 @@ public:
if (N == 0)
N = 1;
for (unsigned I = 0; I != N; ++I)
- clang::io::Emit32(Out,
+ clang::io::Emit32(Out,
Writer.getIdentifierRef(Sel.getIdentifierInfoForSlot(I)));
}
-
+
void EmitData(llvm::raw_ostream& Out, key_type_ref,
data_type_ref Methods, unsigned DataLen) {
uint64_t Start = Out.tell(); (void)Start;
unsigned NumInstanceMethods = 0;
- for (const ObjCMethodList *Method = &Methods.first; Method;
+ for (const ObjCMethodList *Method = &Methods.first; Method;
Method = Method->Next)
if (Method->Method)
++NumInstanceMethods;
unsigned NumFactoryMethods = 0;
- for (const ObjCMethodList *Method = &Methods.second; Method;
+ for (const ObjCMethodList *Method = &Methods.second; Method;
Method = Method->Next)
if (Method->Method)
++NumFactoryMethods;
clang::io::Emit16(Out, NumInstanceMethods);
clang::io::Emit16(Out, NumFactoryMethods);
- for (const ObjCMethodList *Method = &Methods.first; Method;
+ for (const ObjCMethodList *Method = &Methods.first; Method;
Method = Method->Next)
if (Method->Method)
clang::io::Emit32(Out, Writer.getDeclID(Method->Method));
- for (const ObjCMethodList *Method = &Methods.second; Method;
+ for (const ObjCMethodList *Method = &Methods.second; Method;
Method = Method->Next)
if (Method->Method)
clang::io::Emit32(Out, Writer.getDeclID(Method->Method));
@@ -1321,13 +1321,13 @@ void PCHWriter::WriteMethodPool(Sema &SemaRef) {
bool Empty = true;
{
OnDiskChainedHashTableGenerator<PCHMethodPoolTrait> Generator;
-
+
// Create the on-disk hash table representation. Start by
// iterating through the instance method pool.
PCHMethodPoolTrait::key_type Key;
unsigned NumSelectorsInMethodPool = 0;
for (llvm::DenseMap<Selector, ObjCMethodList>::iterator
- Instance = SemaRef.InstanceMethodPool.begin(),
+ Instance = SemaRef.InstanceMethodPool.begin(),
InstanceEnd = SemaRef.InstanceMethodPool.end();
Instance != InstanceEnd; ++Instance) {
// Check whether there is a factory method with the same
@@ -1337,7 +1337,7 @@ void PCHWriter::WriteMethodPool(Sema &SemaRef) {
if (Factory == SemaRef.FactoryMethodPool.end())
Generator.insert(Instance->first,
- std::make_pair(Instance->second,
+ std::make_pair(Instance->second,
ObjCMethodList()));
else
Generator.insert(Instance->first,
@@ -1350,7 +1350,7 @@ void PCHWriter::WriteMethodPool(Sema &SemaRef) {
// Now iterate through the factory method pool, to pick up any
// selectors that weren't already in the instance method pool.
for (llvm::DenseMap<Selector, ObjCMethodList>::iterator
- Factory = SemaRef.FactoryMethodPool.begin(),
+ Factory = SemaRef.FactoryMethodPool.begin(),
FactoryEnd = SemaRef.FactoryMethodPool.end();
Factory != FactoryEnd; ++Factory) {
// Check whether there is an instance method with the same
@@ -1371,7 +1371,7 @@ void PCHWriter::WriteMethodPool(Sema &SemaRef) {
return;
// Create the on-disk hash table in a buffer.
- llvm::SmallString<4096> MethodPool;
+ llvm::SmallString<4096> MethodPool;
uint32_t BucketOffset;
SelectorOffsets.resize(SelVector.size());
{
@@ -1444,25 +1444,25 @@ class VISIBILITY_HIDDEN PCHIdentifierTableTrait {
public:
typedef const IdentifierInfo* key_type;
typedef key_type key_type_ref;
-
+
typedef pch::IdentID data_type;
typedef data_type data_type_ref;
-
- PCHIdentifierTableTrait(PCHWriter &Writer, Preprocessor &PP)
+
+ PCHIdentifierTableTrait(PCHWriter &Writer, Preprocessor &PP)
: Writer(Writer), PP(PP) { }
static unsigned ComputeHash(const IdentifierInfo* II) {
return clang::BernsteinHash(II->getName());
}
-
- std::pair<unsigned,unsigned>
- EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II,
+
+ std::pair<unsigned,unsigned>
+ EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II,
pch::IdentID ID) {
unsigned KeyLen = strlen(II->getName()) + 1;
unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
if (isInterestingIdentifier(II)) {
DataLen += 2; // 2 bytes for builtin ID, flags
- if (II->hasMacroDefinition() &&
+ if (II->hasMacroDefinition() &&
!PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
DataLen += 4;
for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
@@ -1477,16 +1477,16 @@ public:
clang::io::Emit16(Out, KeyLen);
return std::make_pair(KeyLen, DataLen);
}
-
- void EmitKey(llvm::raw_ostream& Out, const IdentifierInfo* II,
+
+ void EmitKey(llvm::raw_ostream& Out, const IdentifierInfo* II,
unsigned KeyLen) {
// Record the location of the key data. This is used when generating
// the mapping from persistent IDs to strings.
Writer.SetIdentifierOffset(II, Out.tell());
Out.write(II->getName(), KeyLen);
}
-
- void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II,
+
+ void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II,
pch::IdentID ID, unsigned) {
if (!isInterestingIdentifier(II)) {
clang::io::Emit32(Out, ID << 1);
@@ -1495,8 +1495,8 @@ public:
clang::io::Emit32(Out, (ID << 1) | 0x01);
uint32_t Bits = 0;
- bool hasMacroDefinition =
- II->hasMacroDefinition() &&
+ bool hasMacroDefinition =
+ II->hasMacroDefinition() &&
!PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro();
Bits = (uint32_t)II->getObjCOrBuiltinID();
Bits = (Bits << 1) | hasMacroDefinition;
@@ -1514,7 +1514,7 @@ public:
// "stat"), but IdentifierResolver::AddDeclToIdentifierChain()
// adds declarations to the end of the list (so we need to see the
// struct "status" before the function "status").
- llvm::SmallVector<Decl *, 16> Decls(IdentifierResolver::begin(II),
+ llvm::SmallVector<Decl *, 16> Decls(IdentifierResolver::begin(II),
IdentifierResolver::end());
for (llvm::SmallVector<Decl *, 16>::reverse_iterator D = Decls.rbegin(),
DEnd = Decls.rend();
@@ -1536,7 +1536,7 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) {
// strings.
{
OnDiskChainedHashTableGenerator<PCHIdentifierTableTrait> Generator;
-
+
// Look for any identifiers that were named while processing the
// headers, but are otherwise not needed. We add these to the hash
// table to enable checking of the predefines buffer in the case
@@ -1557,7 +1557,7 @@ void PCHWriter::WriteIdentifierTable(Preprocessor &PP) {
}
// Create the on-disk hash table in a buffer.
- llvm::SmallString<4096> IdentifierTable;
+ llvm::SmallString<4096> IdentifierTable;
uint32_t BucketOffset;
{
PCHIdentifierTableTrait Trait(*this, PP);
@@ -1617,7 +1617,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::AlwaysInline:
break;
-
+
case Attr::AnalyzerNoReturn:
break;
@@ -1676,7 +1676,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
Record.push_back(Sentinel->getNullPos());
break;
}
-
+
case Attr::GNUInline:
case Attr::IBOutletKind:
case Attr::Malloc:
@@ -1706,14 +1706,14 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::Packed:
break;
-
+
case Attr::Pure:
break;
case Attr::Regparm:
Record.push_back(cast<RegparmAttr>(Attr)->getNumParams());
break;
-
+
case Attr::ReqdWorkGroupSize:
Record.push_back(cast<ReqdWorkGroupSizeAttr>(Attr)->getXDim());
Record.push_back(cast<ReqdWorkGroupSizeAttr>(Attr)->getYDim());
@@ -1733,7 +1733,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::Visibility:
// FIXME: stable encoding
- Record.push_back(cast<VisibilityAttr>(Attr)->getVisibility());
+ Record.push_back(cast<VisibilityAttr>(Attr)->getVisibility());
break;
case Attr::WarnUnusedResult:
@@ -1765,8 +1765,8 @@ void PCHWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
SelectorOffsets[ID - 1] = Offset;
}
-PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
- : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS),
+PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
+ : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS),
NumStatements(0), NumMacros(0), NumLexicalDeclContexts(0),
NumVisibleDeclContexts(0) { }
@@ -1782,7 +1782,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
Stream.Emit((unsigned)'P', 8);
Stream.Emit((unsigned)'C', 8);
Stream.Emit((unsigned)'H', 8);
-
+
WriteBlockInfoBlock();
// The translation unit is the first declaration we'll emit.
@@ -1816,7 +1816,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
RecordData LocallyScopedExternalDecls;
// FIXME: This is filling in the PCH file in densemap order which is
// nondeterminstic!
- for (llvm::DenseMap<DeclarationName, NamedDecl *>::iterator
+ for (llvm::DenseMap<DeclarationName, NamedDecl *>::iterator
TD = SemaRef.LocallyScopedExternalDecls.begin(),
TDEnd = SemaRef.LocallyScopedExternalDecls.end();
TD != TDEnd; ++TD)
@@ -1836,10 +1836,10 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
WriteStatCache(*StatCalls, isysroot);
WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot);
WritePreprocessor(PP);
- WriteComments(Context);
+ WriteComments(Context);
// Write the record of special types.
Record.clear();
-
+
AddTypeRef(Context.getBuiltinVaListType(), Record);
AddTypeRef(Context.getObjCIdType(), Record);
AddTypeRef(Context.getObjCSelType(), Record);
@@ -1853,7 +1853,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
AddTypeRef(Context.ObjCIdRedefinitionType, Record);
AddTypeRef(Context.ObjCClassRedefinitionType, Record);
Stream.EmitRecord(pch::SPECIAL_TYPES, Record);
-
+
// Keep writing types and declarations until all types and
// declarations have been written.
do {
@@ -1876,9 +1876,9 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
Record.push_back(pch::TYPE_OFFSET);
Record.push_back(TypeOffsets.size());
Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record,
- (const char *)&TypeOffsets.front(),
+ (const char *)&TypeOffsets.front(),
TypeOffsets.size() * sizeof(TypeOffsets[0]));
-
+
// Write the declaration offsets array
Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::DECL_OFFSET));
@@ -1889,7 +1889,7 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
Record.push_back(pch::DECL_OFFSET);
Record.push_back(DeclOffsets.size());
Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record,
- (const char *)&DeclOffsets.front(),
+ (const char *)&DeclOffsets.front(),
DeclOffsets.size() * sizeof(DeclOffsets[0]));
// Write the record containing external, unnamed definitions.
@@ -1902,13 +1902,13 @@ void PCHWriter::WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
// Write the record containing locally-scoped external definitions.
if (!LocallyScopedExternalDecls.empty())
- Stream.EmitRecord(pch::LOCALLY_SCOPED_EXTERNAL_DECLS,
+ Stream.EmitRecord(pch::LOCALLY_SCOPED_EXTERNAL_DECLS,
LocallyScopedExternalDecls);
// Write the record containing ext_vector type names.
if (!ExtVectorDecls.empty())
Stream.EmitRecord(pch::EXT_VECTOR_DECLS, ExtVectorDecls);
-
+
// Some simple statistics
Record.clear();
Record.push_back(NumStatements);
@@ -2032,7 +2032,7 @@ void PCHWriter::AddDeclRef(const Decl *D, RecordData &Record) {
}
pch::DeclID &ID = DeclIDs[D];
- if (ID == 0) {
+ if (ID == 0) {
// We haven't seen this declaration before. Give it a new ID and
// enqueue it in the list of declarations to emit.
ID = DeclIDs.size();
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index eed888382a..7a15abf0a0 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -35,8 +35,8 @@ namespace {
pch::DeclCode Code;
unsigned AbbrevToUse;
- PCHDeclWriter(PCHWriter &Writer, ASTContext &Context,
- PCHWriter::RecordData &Record)
+ PCHDeclWriter(PCHWriter &Writer, ASTContext &Context,
+ PCHWriter::RecordData &Record)
: Writer(Writer), Context(Context), Record(Record) {
}
@@ -59,7 +59,7 @@ namespace {
void VisitOriginalParmVarDecl(OriginalParmVarDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
void VisitBlockDecl(BlockDecl *D);
- void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
+ void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
uint64_t VisibleOffset);
void VisitObjCMethodDecl(ObjCMethodDecl *D);
void VisitObjCContainerDecl(ObjCContainerDecl *D);
@@ -161,9 +161,9 @@ public:
#define ABSTRACT_TYPELOC(CLASS)
#define TYPELOC(CLASS, PARENT, TYPE) \
- void Visit##CLASS(CLASS TyLoc);
+ void Visit##CLASS(CLASS TyLoc);
#include "clang/AST/TypeLocNodes.def"
-
+
void VisitTypeLoc(TypeLoc TyLoc) {
assert(0 && "A type loc wrapper was not handled!");
}
@@ -210,7 +210,7 @@ void PCHDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
Writer.AddTypeRef(QualType(), Record);
return;
}
-
+
Writer.AddTypeRef(DInfo->getTypeLoc().getSourceType(), Record);
TypeLocWriter TLW(Writer, Record);
for (TypeLoc TL = DInfo->getTypeLoc(); !TL.isNull(); TL = TL.getNextTypeLoc())
@@ -243,7 +243,7 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
VisitNamedDecl(D);
// FIXME: convert to LazyStmtPtr?
- // Unlike C/C++, method bodies will never be in header files.
+ // Unlike C/C++, method bodies will never be in header files.
Record.push_back(D->getBody() != 0);
if (D->getBody() != 0) {
Writer.AddStmt(D->getBody());
@@ -254,13 +254,13 @@ void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Record.push_back(D->isVariadic());
Record.push_back(D->isSynthesized());
// FIXME: stable encoding for @required/@optional
- Record.push_back(D->getImplementationControl());
+ Record.push_back(D->getImplementationControl());
// FIXME: stable encoding for in/out/inout/bycopy/byref/oneway
- Record.push_back(D->getObjCDeclQualifier());
+ Record.push_back(D->getObjCDeclQualifier());
Writer.AddTypeRef(D->getResultType(), Record);
Writer.AddSourceLocation(D->getLocEnd(), Record);
Record.push_back(D->param_size());
- for (ObjCMethodDecl::param_iterator P = D->param_begin(),
+ for (ObjCMethodDecl::param_iterator P = D->param_begin(),
PEnd = D->param_end(); P != PEnd; ++P)
Writer.AddDeclRef(*P, Record);
Code = pch::DECL_OBJC_METHOD;
@@ -277,12 +277,12 @@ void PCHDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
Writer.AddDeclRef(D->getSuperClass(), Record);
Record.push_back(D->protocol_size());
- for (ObjCInterfaceDecl::protocol_iterator P = D->protocol_begin(),
+ for (ObjCInterfaceDecl::protocol_iterator P = D->protocol_begin(),
PEnd = D->protocol_end();
P != PEnd; ++P)
Writer.AddDeclRef(*P, Record);
Record.push_back(D->ivar_size());
- for (ObjCInterfaceDecl::ivar_iterator I = D->ivar_begin(),
+ for (ObjCInterfaceDecl::ivar_iterator I = D->ivar_begin(),
IEnd = D->ivar_end(); I != IEnd; ++I)
Writer.AddDeclRef(*I, Record);
Writer.AddDeclRef(D->getCategoryList(), Record);
@@ -297,7 +297,7 @@ void PCHDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
void PCHDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) {
VisitFieldDecl(D);
// FIXME: stable encoding for @public/@private/@protected/@package
- Record.push_back(D->getAccessControl());
+ Record.push_back(D->getAccessControl());
Code = pch::DECL_OBJC_IVAR;
}
@@ -306,7 +306,7 @@ void PCHDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
Record.push_back(D->isForwardDecl());
Writer.AddSourceLocation(D->getLocEnd(), Record);
Record.push_back(D->protocol_size());
- for (ObjCProtocolDecl::protocol_iterator
+ for (ObjCProtocolDecl::protocol_iterator
I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I)
Writer.AddDeclRef(*I, Record);
Code = pch::DECL_OBJC_PROTOCOL;
@@ -328,7 +328,7 @@ void PCHDeclWriter::VisitObjCClassDecl(ObjCClassDecl *D) {
void PCHDeclWriter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
VisitDecl(D);
Record.push_back(D->protocol_size());
- for (ObjCProtocolDecl::protocol_iterator
+ for (ObjCProtocolDecl::protocol_iterator
I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I)
Writer.AddDeclRef(*I, Record);
Code = pch::DECL_OBJC_FORWARD_PROTOCOL;
@@ -338,7 +338,7 @@ void PCHDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
VisitObjCContainerDecl(D);
Writer.AddDeclRef(D->getClassInterface(), Record);
Record.push_back(D->protocol_size());
- for (ObjCProtocolDecl::protocol_iterator
+ for (ObjCProtocolDecl::protocol_iterator
I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I)
Writer.AddDeclRef(*I, Record);
Writer.AddDeclRef(D->getNextClassCategory(), Record);
@@ -424,8 +424,8 @@ void PCHDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
VisitVarDecl(D);
Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding
Code = pch::DECL_PARM_VAR;
-
-
+
+
// If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
// we dynamically check for the properties that we optimize for, but don't
// know are true of all PARM_VAR_DECLs.
@@ -483,7 +483,7 @@ void PCHDeclWriter::VisitBlockDecl(BlockDecl *D) {
/// that there are no declarations visible from this context. Note
/// that this value will not be emitted for non-primary declaration
/// contexts.
-void PCHDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
+void PCHDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
uint64_t VisibleOffset) {
Record.push_back(LexicalOffset);
Record.push_back(VisibleOffset);
@@ -509,7 +509,7 @@ void PCHWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isImplicit
Abv->Add(BitCodeAbbrevOp(0)); // isUsed
Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier
-
+
// NamedDecl
Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name
@@ -526,7 +526,7 @@ void PCHWriter::WriteDeclsBlockAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // HasInit
// ParmVarDecl
Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier
-
+
ParmVarDeclAbbrev = Stream.EmitAbbrev(Abv);
}
@@ -537,7 +537,7 @@ void PCHWriter::WriteDeclsBlock(ASTContext &Context) {
// Output the abbreviations that we will use in this block.
WriteDeclsBlockAbbrevs();
-
+
// Emit all of the declarations.
RecordData Record;
PCHDeclWriter W(*this, Context, Record);
@@ -588,14 +588,14 @@ void PCHWriter::WriteDeclsBlock(ASTContext &Context) {
exit(-1);
}
Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
-
+
// If the declaration had any attributes, write them now.
if (D->hasAttrs())
WriteAttributeRecord(D->getAttrs());
// Flush any expressions that were written as part of this declaration.
FlushStmts();
-
+
// Note external declarations so that we can add them to a record
// in the PCH file later.
if (isa<FileScopeAsmDecl>(D))
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index 1f81529135..a34c9923fc 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -86,7 +86,7 @@ namespace {
void VisitShuffleVectorExpr(ShuffleVectorExpr *E);
void VisitBlockExpr(BlockExpr *E);
void VisitBlockDeclRefExpr(BlockDeclRefExpr *E);
-
+
// Objective-C Expressions
void VisitObjCStringLiteral(ObjCStringLiteral *E);
void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
@@ -99,8 +99,8 @@ namespace {
void VisitObjCMessageExpr(ObjCMessageExpr *E);
void VisitObjCSuperExpr(ObjCSuperExpr *E);
void VisitObjCIsaExpr(ObjCIsaExpr *E);
-
- // Objective-C Statements
+
+ // Objective-C Statements
void VisitObjCForCollectionStmt(ObjCForCollectionStmt *);
void VisitObjCAtCatchStmt(ObjCAtCatchStmt *);
void VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *);
@@ -108,12 +108,12 @@ namespace {
void VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *);
void VisitObjCAtThrowStmt(ObjCAtThrowStmt *);
- // C++ Statements
+ // C++ Statements
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
};
}
-void PCHStmtWriter::VisitStmt(Stmt *S) {
+void PCHStmtWriter::VisitStmt(Stmt *S) {
}
void PCHStmtWriter::VisitNullStmt(NullStmt *S) {
@@ -181,7 +181,7 @@ void PCHStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
Writer.WriteSubStmt(S->getCond());
Writer.WriteSubStmt(S->getBody());
Writer.AddSourceLocation(S->getSwitchLoc(), Record);
- for (SwitchCase *SC = S->getSwitchCaseList(); SC;
+ for (SwitchCase *SC = S->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase())
Record.push_back(Writer.getSwitchCaseID(SC));
Code = pch::STMT_SWITCH;
@@ -345,7 +345,7 @@ void PCHStmtWriter::VisitStringLiteral(StringLiteral *E) {
// StringLiteral. However, we can't do so now because we have no
// provision for coping with abbreviations when we're jumping around
// the PCH file during deserialization.
- Record.insert(Record.end(),
+ Record.insert(Record.end(),
E->getStrData(), E->getStrData() + E->getByteLength());
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
@@ -376,7 +376,7 @@ void PCHStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
Code = pch::EXPR_UNARY_OPERATOR;
}
-void PCHStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
+void PCHStmtWriter::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
VisitExpr(E);
Record.push_back(E->isSizeOf());
if (E->isArgumentType())
@@ -635,7 +635,7 @@ void PCHStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
Code = pch::EXPR_OBJC_STRING_LITERAL;
}
-void PCHStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
+void PCHStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
Writer.AddTypeRef(E->getEncodedType(), Record);
Writer.AddSourceLocation(E->getAtLoc(), Record);
@@ -682,7 +682,7 @@ void PCHStmtWriter::VisitObjCImplicitSetterGetterRefExpr(
VisitExpr(E);
Writer.AddDeclRef(E->getGetterMethod(), Record);
Writer.AddDeclRef(E->getSetterMethod(), Record);
-
+
// NOTE: InterfaceDecl and Base are mutually exclusive.
Writer.AddDeclRef(E->getInterfaceDecl(), Record);
Writer.WriteSubStmt(E->getBase());
@@ -779,7 +779,7 @@ void PCHStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
//===----------------------------------------------------------------------===//
unsigned PCHWriter::RecordSwitchCaseID(SwitchCase *S) {
- assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
+ assert(SwitchCaseIDs.find(S) == SwitchCaseIDs.end() &&
"SwitchCase recorded twice");
unsigned NextID = SwitchCaseIDs.size();
SwitchCaseIDs[S] = NextID;
@@ -787,7 +787,7 @@ unsigned PCHWriter::RecordSwitchCaseID(SwitchCase *S) {
}
unsigned PCHWriter::getSwitchCaseID(SwitchCase *S) {
- assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
+ assert(SwitchCaseIDs.find(S) != SwitchCaseIDs.end() &&
"SwitchCase hasn't been seen yet");
return SwitchCaseIDs[S];
}
@@ -798,7 +798,7 @@ unsigned PCHWriter::GetLabelID(LabelStmt *S) {
std::map<LabelStmt *, unsigned>::iterator Pos = LabelIDs.find(S);
if (Pos != LabelIDs.end())
return Pos->second;
-
+
unsigned NextID = LabelIDs.size();
LabelIDs[S] = NextID;
return NextID;
@@ -810,17 +810,17 @@ void PCHWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
++NumStatements;
-
+
if (!S) {
Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
return;
}
-
+
Writer.Code = pch::STMT_NULL_PTR;
Writer.Visit(S);
- assert(Writer.Code != pch::STMT_NULL_PTR &&
+ assert(Writer.Code != pch::STMT_NULL_PTR &&
"Unhandled expression writing PCH file");
- Stream.EmitRecord(Writer.Code, Record);
+ Stream.EmitRecord(Writer.Code, Record);
}
/// \brief Flush all of the statements that have been added to the
@@ -828,31 +828,31 @@ void PCHWriter::WriteSubStmt(Stmt *S) {
void PCHWriter::FlushStmts() {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
-
+
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
++NumStatements;
Stmt *S = StmtsToEmit[I];
-
+
if (!S) {
Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
continue;
}
-
+
Writer.Code = pch::STMT_NULL_PTR;
Writer.Visit(S);
- assert(Writer.Code != pch::STMT_NULL_PTR &&
+ assert(Writer.Code != pch::STMT_NULL_PTR &&
"Unhandled expression writing PCH file");
- Stream.EmitRecord(Writer.Code, Record);
-
- assert(N == StmtsToEmit.size() &&
+ Stream.EmitRecord(Writer.Code, Record);
+
+ assert(N == StmtsToEmit.size() &&
"Substatement writen via AddStmt rather than WriteSubStmt!");
-
+
// Note that we are at the end of a full expression. Any
// expression records that follow this one are part of a different
// expression.
Record.clear();
Stream.EmitRecord(pch::STMT_STOP, Record);
}
-
+
StmtsToEmit.clear();
}
diff --git a/lib/Frontend/PlistDiagnostics.cpp b/lib/Frontend/PlistDiagnostics.cpp
index 26fc08019d..a83dca0a5f 100644
--- a/lib/Frontend/PlistDiagnostics.cpp
+++ b/lib/Frontend/PlistDiagnostics.cpp
@@ -45,19 +45,19 @@ namespace {
PathDiagnosticClientFactory *pf);
~PlistDiagnostics();
void HandlePathDiagnostic(const PathDiagnostic* D);
-
+
PathGenerationScheme getGenerationScheme() const;
bool supportsLogicalOpControlFlow() const { return true; }
bool supportsAllBlockEdges() const { return true; }
virtual bool useVerboseDescription() const { return false; }
- };
+ };
} // end anonymous namespace
PlistDiagnostics::PlistDiagnostics(const std::string& output,
const LangOptions &LO,
PathDiagnosticClientFactory *pf)
: OutputFile(output), LangOpts(LO), PF(pf) {
-
+
if (PF)
SubPDC.reset(PF->createPathDiagnosticClient(&FilesMade));
}
@@ -73,7 +73,7 @@ PathDiagnosticClient::PathGenerationScheme
PlistDiagnostics::getGenerationScheme() const {
if (const PathDiagnosticClient *PD = SubPDC.get())
return PD->getGenerationScheme();
-
+
return Extensive;
}
@@ -110,7 +110,7 @@ static void EmitLocation(llvm::raw_ostream& o, const SourceManager &SM,
// Add in the length of the token, so that we cover multi-char tokens.
unsigned offset =
extend ? Lexer::MeasureTokenLength(Loc, SM, LangOpts) - 1 : 0;
-
+
Indent(o, indent) << "<dict>\n";
Indent(o, indent) << " <key>line</key><integer>"
<< Loc.getInstantiationLineNumber() << "</integer>\n";
@@ -133,7 +133,7 @@ static void EmitRange(llvm::raw_ostream& o, const SourceManager &SM,
PathDiagnosticRange R, const FIDMap &FM,
unsigned indent) {
Indent(o, indent) << "<array>\n";
- EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1);
+ EmitLocation(o, SM, LangOpts, R.getBegin(), FM, indent+1);
EmitLocation(o, SM, LangOpts, R.getEnd(), FM, indent+1, !R.isPoint);
Indent(o, indent) << "</array>\n";
}
@@ -162,12 +162,12 @@ static void ReportControlFlow(llvm::raw_ostream& o,
const SourceManager &SM,
const LangOptions &LangOpts,
unsigned indent) {
-
+
Indent(o, indent) << "<dict>\n";
++indent;
-
+
Indent(o, indent) << "<key>kind</key><string>control</string>\n";
-
+
// Emit edges.
Indent(o, indent) << "<key>edges</key>\n";
++indent;
@@ -187,39 +187,39 @@ static void ReportControlFlow(llvm::raw_ostream& o,
--indent;
Indent(o, indent) << "</array>\n";
--indent;
-
+
// Output any helper text.
const std::string& s = P.getString();
if (!s.empty()) {
Indent(o, indent) << "<key>alternate</key>";
EmitString(o, s) << '\n';
}
-
+
--indent;
- Indent(o, indent) << "</dict>\n";
+ Indent(o, indent) << "</dict>\n";
}
-static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
+static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
const FIDMap& FM,
const SourceManager &SM,
const LangOptions &LangOpts,
unsigned indent) {
-
+
Indent(o, indent) << "<dict>\n";
++indent;
Indent(o, indent) << "<key>kind</key><string>event</string>\n";
-
+
// Output the location.
FullSourceLoc L = P.getLocation().asLocation();
-
+
Indent(o, indent) << "<key>location</key>\n";
EmitLocation(o, SM, LangOpts, L, FM, indent);
-
+
// Output the ranges (if any).
PathDiagnosticPiece::range_iterator RI = P.ranges_begin(),
RE = P.ranges_end();
-
+
if (RI != RE) {
Indent(o, indent) << "<key>ranges</key>\n";
Indent(o, indent) << "<array>\n";
@@ -229,13 +229,13 @@ static void ReportEvent(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
--indent;
Indent(o, indent) << "</array>\n";
}
-
+
// Output the text.
assert(!P.getString().empty());
Indent(o, indent) << "<key>extended_message</key>\n";
Indent(o, indent);
EmitString(o, P.getString()) << '\n';
-
+
// Output the short text.
// FIXME: Really use a short string.
Indent(o, indent) << "<key>message</key>\n";
@@ -251,10 +251,10 @@ static void ReportMacro(llvm::raw_ostream& o,
const FIDMap& FM, const SourceManager &SM,
const LangOptions &LangOpts,
unsigned indent) {
-
+
for (PathDiagnosticMacroPiece::const_iterator I=P.begin(), E=P.end();
I!=E; ++I) {
-
+
switch ((*I)->getKind()) {
default:
break;
@@ -266,16 +266,16 @@ static void ReportMacro(llvm::raw_ostream& o,
ReportMacro(o, cast<PathDiagnosticMacroPiece>(**I), FM, SM, LangOpts,
indent);
break;
- }
- }
+ }
+ }
}
-static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
+static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
const FIDMap& FM, const SourceManager &SM,
const LangOptions &LangOpts) {
unsigned indent = 4;
-
+
switch (P.getKind()) {
case PathDiagnosticPiece::ControlFlow:
ReportControlFlow(o, cast<PathDiagnosticControlFlowPiece>(P), FM, SM,
@@ -295,38 +295,38 @@ static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
void PlistDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
if (!D)
return;
-
+
if (D->empty()) {
delete D;
return;
}
-
+
// We need to flatten the locations (convert Stmt* to locations) because
// the referenced statements may be freed by the time the diagnostics
// are emitted.
- const_cast<PathDiagnostic*>(D)->flattenLocations();
+ const_cast<PathDiagnostic*>(D)->flattenLocations();
BatchedDiags.push_back(D);
}
-PlistDiagnostics::~PlistDiagnostics() {
+PlistDiagnostics::~PlistDiagnostics() {
// Build up a set of FIDs that we use by scanning the locations and
// ranges of the diagnostics.
FIDMap FM;
llvm::SmallVector<FileID, 10> Fids;
const SourceManager* SM = 0;
-
- if (!BatchedDiags.empty())
+
+ if (!BatchedDiags.empty())
SM = &(*BatchedDiags.begin())->begin()->getLocation().getManager();
for (std::vector<const PathDiagnostic*>::iterator DI = BatchedDiags.begin(),
DE = BatchedDiags.end(); DI != DE; ++DI) {
-
+
const PathDiagnostic *D = *DI;
-
+
for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I!=E; ++I) {
AddFID(FM, Fids, SM, I->getLocation().asLocation());
-
+
for (PathDiagnosticPiece::range_iterator RI=I->ranges_begin(),
RE=I->ranges_end(); RI!=RE; ++RI) {
AddFID(FM, Fids, SM, RI->getBegin());
@@ -342,84 +342,84 @@ PlistDiagnostics::~PlistDiagnostics() {
llvm::errs() << "warning: could not creat file: " << OutputFile << '\n';
return;
}
-
+
// Write the plist header.
o << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" "
"\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
"<plist version=\"1.0\">\n";
-
+
// Write the root object: a <dict> containing...
// - "files", an <array> mapping from FIDs to file names
- // - "diagnostics", an <array> containing the path diagnostics
+ // - "diagnostics", an <array> containing the path diagnostics
o << "<dict>\n"
" <key>files</key>\n"
" <array>\n";
-
+
for (llvm::SmallVectorImpl<FileID>::iterator I=Fids.begin(), E=Fids.end();
I!=E; ++I) {
o << " ";
EmitString(o, SM->getFileEntryForID(*I)->getName()) << '\n';
}
-
+
o << " </array>\n"
" <key>diagnostics</key>\n"
" <array>\n";
-
+
for (std::vector<const PathDiagnostic*>::iterator DI=BatchedDiags.begin(),
DE = BatchedDiags.end(); DI!=DE; ++DI) {
-
+
o << " <dict>\n"
" <key>path</key>\n";
-
+
const PathDiagnostic *D = *DI;
// Create an owning smart pointer for 'D' just so that we auto-free it
// when we exit this method.
llvm::OwningPtr<PathDiagnostic> OwnedD(const_cast<PathDiagnostic*>(D));
-
+
o << " <array>\n";
for (PathDiagnostic::const_iterator I=D->begin(), E=D->end(); I != E; ++I)
ReportDiag(o, *I, FM, *SM, LangOpts);
-
+
o << " </array>\n";
-
- // Output the bug type and bug category.
+
+ // Output the bug type and bug category.
o << " <key>description</key>";
EmitString(o, D->getDescription()) << '\n';
o << " <key>category</key>";
EmitString(o, D->getCategory()) << '\n';
o << " <key>type</key>";
EmitString(o, D->getBugType()) << '\n';
-
+
// Output the location of the bug.
o << " <key>location</key>\n";
EmitLocation(o, *SM, LangOpts, D->getLocation(), FM, 2);
-
+
// Output the diagnostic to the sub-diagnostic client, if any.
if (PF) {
if (!SubPDC.get())
SubPDC.reset(PF->createPathDiagnosticClient(&FilesMade));
-
+
FilesMade.clear();
- SubPDC->HandlePathDiagnostic(OwnedD.take());
+ SubPDC->HandlePathDiagnostic(OwnedD.take());
SubPDC.reset(0);
-
+
if (!FilesMade.empty()) {
o << " <key>" << PF->getName() << "_files</key>\n";
o << " <array>\n";
for (size_t i = 0, n = FilesMade.size(); i < n ; ++i)
o << " <string>" << FilesMade[i] << "</string>\n";
- o << " </array>\n";
+ o << " </array>\n";
}
}
-
+
// Close up the entry.
o << " </dict>\n";
}
o << " </array>\n";
-
+
// Finish.
o << "</dict>\n</plist>";
}
diff --git a/lib/Frontend/PrintParserCallbacks.cpp b/lib/Frontend/PrintParserCallbacks.cpp
index 126cdd3fdd..b537025aec 100644
--- a/lib/Frontend/PrintParserCallbacks.cpp
+++ b/lib/Frontend/PrintParserCallbacks.cpp
@@ -39,7 +39,7 @@ namespace {
Out << "<anon>";
}
Out << "\n";
-
+
// Pass up to EmptyActions so that the symbol table is maintained right.
return MinimalAction::ActOnDeclarator(S, D);
}
@@ -69,16 +69,16 @@ namespace {
AttributeList *AttrList) {
Out << __FUNCTION__ << "\n";
return MinimalAction::ActOnStartClassInterface(AtInterfaceLoc,
- ClassName, ClassLoc,
+ ClassName, ClassLoc,
SuperName, SuperLoc,
ProtoRefs, NumProtocols,
EndProtoLoc, AttrList);
}
- /// ActOnForwardClassDeclaration -
- /// Scope will always be top level file scope.
+ /// ActOnForwardClassDeclaration -
+ /// Scope will always be top level file scope.
Action::DeclPtrTy ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
- IdentifierInfo **IdentList,
+ IdentifierInfo **IdentList,
unsigned NumElts) {
Out << __FUNCTION__ << "\n";
return MinimalAction::ActOnForwardClassDeclaration(AtClassLoc, IdentList,
@@ -101,13 +101,13 @@ namespace {
Out << "\n";
return DeclPtrTy();
}
-
- /// AddInitializerToDecl - This action is called immediately after
- /// ParseDeclarator (when an initializer is present). The code is factored
+
+ /// AddInitializerToDecl - This action is called immediately after
+ /// ParseDeclarator (when an initializer is present). The code is factored
/// this way to make sure we are able to handle the following:
/// void func() { int xx = xx; }
/// This allows ActOnDeclarator to register "xx" prior to parsing the
- /// initializer. The declaration above should still result in a warning,
+ /// initializer. The declaration above should still result in a warning,
/// since the reference to "xx" is uninitialized.
virtual void AddInitializerToDecl(DeclPtrTy Dcl, ExprArg Init) {
Out << __FUNCTION__ << "\n";
@@ -142,7 +142,7 @@ namespace {
virtual void ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
Out << __FUNCTION__ << "\n";
}
-
+
/// ActOnFunctionDefBody - This is called when a function body has completed
/// parsing. Decl is the DeclTy returned by ParseStartOfFunctionDef.
virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body) {
@@ -155,14 +155,14 @@ namespace {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
/// ActOnLinkageSpec - Parsed a C++ linkage-specification that
/// contained braces. Lang/StrSize contains the language string that
/// was parsed at location Loc. Decls/NumDecls provides the
@@ -170,12 +170,12 @@ namespace {
virtual DeclPtrTy ActOnLinkageSpec(SourceLocation Loc,
SourceLocation LBrace,
SourceLocation RBrace, const char *Lang,
- unsigned StrSize,
+ unsigned StrSize,
DeclPtrTy *Decls, unsigned NumDecls) {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
/// ActOnLinkageSpec - Parsed a C++ linkage-specification without
/// braces. Lang/StrSize contains the language string that was
/// parsed at location Loc. D is the declaration parsed.
@@ -183,16 +183,16 @@ namespace {
unsigned StrSize, DeclPtrTy D) {
return DeclPtrTy();
}
-
+
//===------------------------------------------------------------------===//
// Type Parsing Callbacks.
//===------------------------------------------------------------------===//
-
+
virtual TypeResult ActOnTypeName(Scope *S, Declarator &D) {
Out << __FUNCTION__ << "\n";
return TypeResult();
}
-
+
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagType, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
@@ -204,22 +204,22 @@ namespace {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
/// Act on @defs() element found when parsing a structure. ClassName is the
- /// name of the referenced class.
+ /// name of the referenced class.
virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
IdentifierInfo *ClassName,
llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
Out << __FUNCTION__ << "\n";
}
- virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
+ virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
SourceLocation DeclStart,
Declarator &D, ExprTy *BitfieldWidth) {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
DeclPtrTy IntfDecl,
Declarator &D, ExprTy *BitfieldWidth,
@@ -227,14 +227,14 @@ namespace {
Out << __FUNCTION__ << "\n";
return DeclPtrTy();
}
-
+
virtual void ActOnFields(Scope* S, SourceLocation RecLoc, DeclPtrTy TagDecl,
- DeclPtrTy *Fields, unsigned NumFields,
+ DeclPtrTy *Fields, unsigned NumFields,
SourceLocation LBrac, SourceLocation RBrac,
AttributeList *AttrList) {
Out << __FUNCTION__ << "\n";
}
-
+
virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
DeclPtrTy LastEnumConstant,
SourceLocation IdLoc,IdentifierInfo *Id,
@@ -272,12 +272,12 @@ namespace {
Out << __FUNCTION__ << "\n";
return StmtEmpty();
}
-
+
virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) {
Out << __FUNCTION__ << "\n";
return OwningStmtResult(*this, Expr->release());
}
-
+
/// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,
/// which can specify an RHS value.
virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc,
@@ -303,7 +303,7 @@ namespace {
return StmtEmpty();
}
- virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
+ virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
FullExprArg CondVal, StmtArg ThenVal,
SourceLocation ElseLoc,
StmtArg ElseVal) {
@@ -329,7 +329,7 @@ namespace {
return StmtEmpty();
}
virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
- SourceLocation WhileLoc,
+ SourceLocation WhileLoc,
SourceLocation LPLoc, ExprArg Cond,
SourceLocation RPLoc){
Out << __FUNCTION__ << "\n";
@@ -490,12 +490,12 @@ namespace {
return ExprEmpty();
}
- virtual OwningExprResult ActOnCharacterConstant(const Token &) {
+ virtual OwningExprResult ActOnCharacterConstant(const Token &) {
Out << __FUNCTION__ << "\n";
return ExprEmpty();
}
- virtual OwningExprResult ActOnNumericConstant(const Token &) {
+ virtual OwningExprResult ActOnNumericConstant(const Token &) {
Out << __FUNCTION__ << "\n";
return ExprEmpty();
}
@@ -515,7 +515,7 @@ namespace {
}
// Postfix Expressions.
- virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
+ virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
tok::TokenKind Kind,
ExprArg Input) {
Out << __FUNCTION__ << "\n";
@@ -574,7 +574,7 @@ namespace {
Out << __FUNCTION__ << "\n";
return ExprEmpty();
}
- virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
+ virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
TypeTy *Ty, SourceLocation RParenLoc,
ExprArg Op) {
Out << __FUNCTION__ << "\n";
@@ -726,8 +726,7 @@ namespace {
}
virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
- DeclPtrTy Method)
- {
+ DeclPtrTy Method) {
Out << __FUNCTION__ << "\n";
}
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index d63d9cbba9..492b31a0ec 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -32,12 +32,12 @@ using namespace clang;
static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
Preprocessor &PP, llvm::raw_ostream &OS) {
OS << "#define " << II.getName();
-
+
if (MI.isFunctionLike()) {
OS << '(';
if (MI.arg_empty())
;
- else if (MI.getNumArgs() == 1)
+ else if (MI.getNumArgs() == 1)
OS << (*MI.arg_begin())->getName();
else {
MacroInfo::arg_iterator AI = MI.arg_begin(), E = MI.arg_end();
@@ -45,7 +45,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
while (AI != E)
OS << ',' << (*AI++)->getName();
}
-
+
if (MI.isVariadic()) {
if (!MI.arg_empty())
OS << ',';
@@ -53,18 +53,18 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
}
OS << ')';
}
-
+
// GCC always emits a space, even if the macro body is empty. However, do not
// want to emit two spaces if the first token has a leading space.
if (MI.tokens_empty() || !MI.tokens_begin()->hasLeadingSpace())
OS << ' ';
-
+
llvm::SmallVector<char, 128> SpellingBuffer;
for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end();
I != E; ++I) {
if (I->hasLeadingSpace())
OS << ' ';
-
+
// Make sure we have enough space in the spelling buffer.
if (I->getLength() < SpellingBuffer.size())
SpellingBuffer.resize(I->getLength());
@@ -105,14 +105,14 @@ public:
FileType = SrcMgr::C_User;
Initialized = false;
}
-
+
void SetEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
bool hasEmittedTokensOnThisLine() const { return EmittedTokensOnThisLine; }
-
+
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType);
virtual void Ident(SourceLocation Loc, const std::string &str);
- virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
+ virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str);
@@ -122,12 +122,12 @@ public:
return ConcatInfo.AvoidConcat(PrevTok, Tok);
}
void WriteLineInfo(unsigned LineNo, const char *Extra=0, unsigned ExtraLen=0);
-
+
void HandleNewlinesInToken(const char *TokStr, unsigned Len);
-
+
/// MacroDefined - This hook is called whenever a macro definition is seen.
void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
-
+
};
} // end anonymous namespace
@@ -143,7 +143,7 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
OS << '#' << ' ' << LineNo << ' ' << '"';
OS.write(&CurFilename[0], CurFilename.size());
OS << '"';
-
+
if (ExtraLen)
OS.write(Extra, ExtraLen);
@@ -163,12 +163,12 @@ bool PrintPPOutputPPCallbacks::MoveToLine(SourceLocation Loc) {
if (DisableLineMarkers) {
if (LineNo == CurLine) return false;
-
+
CurLine = LineNo;
-
+
if (!EmittedTokensOnThisLine && !EmittedMacroOnThisLine)
return true;
-
+
OS << '\n';
EmittedTokensOnThisLine = false;
EmittedMacroOnThisLine = false;
@@ -188,9 +188,9 @@ bool PrintPPOutputPPCallbacks::MoveToLine(SourceLocation Loc) {
}
} else {
WriteLineInfo(LineNo, 0, 0);
- }
+ }
- CurLine = LineNo;
+ CurLine = LineNo;
return true;
}
@@ -210,12 +210,12 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
MoveToLine(IncludeLoc);
} else if (Reason == PPCallbacks::SystemHeaderPragma) {
MoveToLine(Loc);
-
+
// TODO GCC emits the # directive for this directive on the line AFTER the
// directive and emits a bunch of spaces that aren't needed. Emulate this
// strange behavior.
}
-
+
Loc = SourceMgr.getInstantiationLoc(Loc);
// FIXME: Should use presumed line #!
CurLine = SourceMgr.getInstantiationLineNumber(Loc);
@@ -239,8 +239,8 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
case PPCallbacks::ExitFile:
WriteLineInfo(CurLine, " 2", 2);
break;
- case PPCallbacks::SystemHeaderPragma:
- case PPCallbacks::RenameFile:
+ case PPCallbacks::SystemHeaderPragma:
+ case PPCallbacks::RenameFile:
WriteLineInfo(CurLine);
break;
}
@@ -250,7 +250,7 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
///
void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
MoveToLine(Loc);
-
+
OS.write("#ident ", strlen("#ident "));
OS.write(&S[0], S.size());
EmittedTokensOnThisLine = true;
@@ -263,7 +263,7 @@ void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II,
if (!DumpDefines ||
// Ignore __FILE__ etc.
MI->isBuiltinMacro()) return;
-
+
MoveToLine(MI->getDefinitionLoc());
PrintMacroDefinition(*II, *MI, PP, OS);
EmittedMacroOnThisLine = true;
@@ -271,14 +271,14 @@ void PrintPPOutputPPCallbacks::MacroDefined(const IdentifierInfo *II,
void PrintPPOutputPPCallbacks::PragmaComment(SourceLocation Loc,
- const IdentifierInfo *Kind,
+ const IdentifierInfo *Kind,
const std::string &Str) {
MoveToLine(Loc);
OS << "#pragma comment(" << Kind->getName();
-
+
if (!Str.empty()) {
OS << ", \"";
-
+
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
unsigned char Char = Str[i];
if (isprint(Char) && Char != '\\' && Char != '"')
@@ -291,7 +291,7 @@ void PrintPPOutputPPCallbacks::PragmaComment(SourceLocation Loc,
}
OS << '"';
}
-
+
OS << ')';
EmittedTokensOnThisLine = true;
}
@@ -307,12 +307,12 @@ bool PrintPPOutputPPCallbacks::HandleFirstTokOnLine(Token &Tok) {
// newline characters.
if (!MoveToLine(Tok.getLocation()))
return false;
-
+
// Print out space characters so that the first token on a line is
// indented for easy reading.
const SourceManager &SourceMgr = PP.getSourceManager();
unsigned ColNo = SourceMgr.getInstantiationColumnNumber(Tok.getLocation());
-
+
// This hack prevents stuff like:
// #define HASH #
// HASH define foo bar
@@ -321,11 +321,11 @@ bool PrintPPOutputPPCallbacks::HandleFirstTokOnLine(Token &Tok) {
// -fpreprocessed mode.
if (ColNo <= 1 && Tok.is(tok::hash))
OS << ' ';
-
+
// Otherwise, indent the appropriate number of spaces.
for (; ColNo > 1; --ColNo)
OS << ' ';
-
+
return true;
}
@@ -336,18 +336,18 @@ void PrintPPOutputPPCallbacks::HandleNewlinesInToken(const char *TokStr,
if (*TokStr != '\n' &&
*TokStr != '\r')
continue;
-
+
++NumNewlines;
-
+
// If we have \n\r or \r\n, skip both and count as one line.
if (Len != 1 &&
(TokStr[1] == '\n' || TokStr[1] == '\r') &&
TokStr[0] != TokStr[1])
++TokStr, --Len;
}
-
+
if (NumNewlines == 0) return;
-
+
CurLine += NumNewlines;
}
@@ -356,7 +356,7 @@ namespace {
struct UnknownPragmaHandler : public PragmaHandler {
const char *Prefix;
PrintPPOutputPPCallbacks *Callbacks;
-
+
UnknownPragmaHandler(const char *prefix, PrintPPOutputPPCallbacks *callbacks)
: PragmaHandler(0), Prefix(prefix), Callbacks(callbacks) {}
virtual void HandlePragma(Preprocessor &PP, Token &PragmaTok) {
@@ -364,7 +364,7 @@ struct UnknownPragmaHandler : public PragmaHandler {
// newline characters.
Callbacks->MoveToLine(PragmaTok.getLocation());
Callbacks->OS.write(Prefix, strlen(Prefix));
-
+
// Read and print all of the pragma tokens.
while (PragmaTok.isNot(tok::eom)) {
if (PragmaTok.hasLeadingSpace())
@@ -385,11 +385,11 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
char Buffer[256];
Token PrevTok;
while (1) {
-
+
// If this token is at the start of a line, emit newlines if needed.
if (Tok.isAtStartOfLine() && Callbacks->HandleFirstTokOnLine(Tok)) {
// done.
- } else if (Tok.hasLeadingSpace() ||
+ } else if (Tok.hasLeadingSpace() ||
// If we haven't emitted a token on this line yet, PrevTok isn't
// useful to look at and no concatenation could happen anyway.
(Callbacks->hasEmittedTokensOnThisLine() &&
@@ -397,7 +397,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
Callbacks->AvoidConcat(PrevTok, Tok))) {
OS << ' ';
}
-
+
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
OS.write(II->getName(), II->getLength());
} else if (Tok.isLiteral() && !Tok.needsCleaning() &&
@@ -407,24 +407,24 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
const char *TokPtr = Buffer;
unsigned Len = PP.getSpelling(Tok, TokPtr);
OS.write(TokPtr, Len);
-
+
// Tokens that can contain embedded newlines need to adjust our current
- // line number.
+ // line number.
if (Tok.getKind() == tok::comment)
Callbacks->HandleNewlinesInToken(TokPtr, Len);
} else {
std::string S = PP.getSpelling(Tok);
OS.write(&S[0], S.size());
-
+
// Tokens that can contain embedded newlines need to adjust our current
- // line number.
+ // line number.
if (Tok.getKind() == tok::comment)
Callbacks->HandleNewlinesInToken(&S[0], S.size());
}
Callbacks->SetEmittedTokensOnThisLine();
-
+
if (Tok.is(tok::eof)) break;
-
+
PrevTok = Tok;
PP.Lex(Tok);
}
@@ -456,7 +456,7 @@ void clang::DoPrintMacros(Preprocessor &PP, llvm::raw_ostream *OS) {
for (unsigned i = 0, e = MacrosByID.size(); i != e; ++i) {
MacroInfo &MI = *MacrosByID[i].second;
- // Ignore computed macros like __LINE__ and friends.
+ // Ignore computed macros like __LINE__ and friends.
if (MI.isBuiltinMacro()) continue;
PrintMacroDefinition(*MacrosByID[i].first, MI, PP, *OS);
diff --git a/lib/Frontend/RewriteBlocks.cpp b/lib/Frontend/RewriteBlocks.cpp
index b927d18b3e..b29f9eac49 100644
--- a/lib/Frontend/RewriteBlocks.cpp
+++ b/lib/Frontend/RewriteBlocks.cpp
@@ -43,28 +43,28 @@ class RewriteBlocks : public ASTConsumer {
llvm::SmallVector<BlockExpr *, 32> Blocks;
llvm::SmallVector<BlockDeclRefExpr *, 32> BlockDeclRefs;
llvm::DenseMap<BlockDeclRefExpr *, CallExpr *> BlockCallExprs;
-
+
// Block related declarations.
llvm::SmallPtrSet<ValueDecl *, 8> BlockByCopyDecls;
llvm::SmallPtrSet<ValueDecl *, 8> BlockByRefDecls;
llvm::SmallPtrSet<ValueDecl *, 8> ImportedBlockDecls;
llvm::DenseMap<BlockExpr *, std::string> RewrittenBlockExprs;
-
+
// The function/method we are rewriting.
FunctionDecl *CurFunctionDef;
ObjCMethodDecl *CurMethodDef;
-
+
bool IsHeader;
-
+
std::string Preamble;
public:
- RewriteBlocks(std::string inFile, Diagnostic &D,
+ RewriteBlocks(std::string inFile, Diagnostic &D,
const LangOptions &LOpts);
~RewriteBlocks() {
- // Get the buffer corresponding to MainFileID.
+ // Get the buffer corresponding to MainFileID.
// If we haven't changed it, then we are done.
- if (const RewriteBuffer *RewriteBuf =
+ if (const RewriteBuffer *RewriteBuf =
Rewrite.getRewriteBufferFor(MainFileID)) {
std::string S(RewriteBuf->begin(), RewriteBuf->end());
printf("%s\n", S.c_str());
@@ -72,7 +72,7 @@ public:
printf("No changes\n");
}
}
-
+
void Initialize(ASTContext &context);
void InsertText(SourceLocation Loc, const char *StrData, unsigned StrLen);
@@ -86,51 +86,51 @@ public:
}
void HandleTopLevelSingleDecl(Decl *D);
void HandleDeclInMainFile(Decl *D);
-
- // Top level
+
+ // Top level
Stmt *RewriteFunctionBody(Stmt *S);
void InsertBlockLiteralsWithinFunction(FunctionDecl *FD);
void InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD);
-
+
// Block specific rewrite rules.
std::string SynthesizeBlockInitExpr(BlockExpr *Exp, VarDecl *VD=0);
-
+
void RewriteBlockCall(CallExpr *Exp);
void RewriteBlockPointerDecl(NamedDecl *VD);
void RewriteBlockDeclRefExpr(BlockDeclRefExpr *VD);
void RewriteBlockPointerFunctionArgs(FunctionDecl *FD);
-
- std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
+
+ std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
const char *funcName, std::string Tag);
- std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
+ std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
const char *funcName, std::string Tag);
- std::string SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
+ std::string SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
bool hasCopyDisposeHelpers);
std::string SynthesizeBlockCall(CallExpr *Exp);
void SynthesizeBlockLiterals(SourceLocation FunLocStart,
const char *FunName);
-
+
void CollectBlockDeclRefInfo(BlockExpr *Exp);
void GetBlockCallExprs(Stmt *S);
void GetBlockDeclRefExprs(Stmt *S);
-
+
// We avoid calling Type::isBlockPointerType(), since it operates on the
// canonical type. We only care if the top-level type is a closure pointer.
bool isBlockPointerType(QualType T) { return isa<BlockPointerType>(T); }
-
+
// FIXME: This predicate seems like it would be useful to add to ASTContext.
bool isObjCType(QualType T) {
if (!LangOpts.ObjC1 && !LangOpts.ObjC2)
return false;
-
+
QualType OCT = Context->getCanonicalType(T).getUnqualifiedType();
-
+
if (OCT == Context->getCanonicalType(Context->getObjCIdType()) ||
OCT == Context->getCanonicalType(Context->getObjCClassType()))
return true;
-
+
if (const PointerType *PT = OCT->getAs<PointerType>()) {
- if (isa<ObjCInterfaceType>(PT->getPointeeType()) ||
+ if (isa<ObjCInterfaceType>(PT->getPointeeType()) ||
PT->getPointeeType()->isObjCQualifiedIdType())
return true;
}
@@ -145,34 +145,34 @@ public:
void RewriteFunctionProtoType(QualType funcType, NamedDecl *D);
void CheckFunctionPointerDecl(QualType dType, NamedDecl *ND);
void RewriteCastExpr(CastExpr *CE);
-
+
bool PointerTypeTakesAnyBlockArguments(QualType QT);
void GetExtentOfArgList(const char *Name, const char *&LParen, const char *&RParen);
};
-
+
}
static bool IsHeaderFile(const std::string &Filename) {
std::string::size_type DotPos = Filename.rfind('.');
-
+
if (DotPos == std::string::npos) {
// no file extension
- return false;
+ return false;
}
-
+
std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
// C header: .h
// C++ header: .hh or .H;
return Ext == "h" || Ext == "hh" || Ext == "H";
-}
+}
RewriteBlocks::RewriteBlocks(std::string inFile,
- Diagnostic &D, const LangOptions &LOpts) :
+ Diagnostic &D, const LangOptions &LOpts) :
Diags(D), LangOpts(LOpts) {
IsHeader = IsHeaderFile(inFile);
CurFunctionDef = 0;
CurMethodDef = 0;
- RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
+ RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
"rewriting failed");
}
@@ -185,15 +185,15 @@ ASTConsumer *clang::CreateBlockRewriter(const std::string& InFile,
void RewriteBlocks::Initialize(ASTContext &context) {
Context = &context;
SM = &Context->getSourceManager();
-
+
// Get the ID and start/end of the main file.
MainFileID = SM->getMainFileID();
const llvm::MemoryBuffer *MainBuf = SM->getBuffer(MainFileID);
MainFileStart = MainBuf->getBufferStart();
MainFileEnd = MainBuf->getBufferEnd();
-
+
Rewrite.setSourceMgr(Context->getSourceManager(), LangOpts);
-
+
if (IsHeader)
Preamble = "#pragma once\n";
Preamble += "#ifndef BLOCK_IMPL\n";
@@ -208,7 +208,7 @@ void RewriteBlocks::Initialize(ASTContext &context) {
Preamble += " BLOCK_HAS_COPY_DISPOSE = (1<<25),\n";
Preamble += " BLOCK_IS_GLOBAL = (1<<28)\n";
Preamble += "};\n";
- if (LangOpts.Microsoft)
+ if (LangOpts.Microsoft)
Preamble += "#define __OBJC_RW_EXTERN extern \"C\" __declspec(dllimport)\n";
else
Preamble += "#define __OBJC_RW_EXTERN extern\n";
@@ -220,14 +220,13 @@ void RewriteBlocks::Initialize(ASTContext &context) {
Preamble += "__OBJC_RW_EXTERN void *_NSConcreteGlobalBlock;\n";
Preamble += "__OBJC_RW_EXTERN void *_NSConcreteStackBlock;\n";
Preamble += "#endif\n";
-
- InsertText(SM->getLocForStartOfFile(MainFileID),
+
+ InsertText(SM->getLocForStartOfFile(MainFileID),
Preamble.c_str(), Preamble.size());
}
-void RewriteBlocks::InsertText(SourceLocation Loc, const char *StrData,
- unsigned StrLen)
-{
+void RewriteBlocks::InsertText(SourceLocation Loc, const char *StrData,
+ unsigned StrLen) {
if (!Rewrite.InsertText(Loc, StrData, StrLen))
return;
Diags.Report(Context->getFullLoc(Loc), RewriteFailedDiag);
@@ -243,14 +242,14 @@ void RewriteBlocks::ReplaceText(SourceLocation Start, unsigned OrigLength,
void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
bool haveBlockPtrs = false;
- for (ObjCMethodDecl::param_iterator I = Method->param_begin(),
+ for (ObjCMethodDecl::param_iterator I = Method->param_begin(),
E = Method->param_end(); I != E; ++I)
if (isBlockPointerType((*I)->getType()))
haveBlockPtrs = true;
-
+
if (!haveBlockPtrs)
return;
-
+
// Do a fuzzy rewrite.
// We have 1 or more arguments that have closure pointers.
SourceLocation Loc = Method->getLocStart();
@@ -260,7 +259,7 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
const char *methodPtr = startBuf;
std::string Tag = "struct __block_impl *";
-
+
while (*methodPtr++ && (methodPtr != endBuf)) {
switch (*methodPtr) {
case ':':
@@ -269,13 +268,13 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
const char *scanType = ++methodPtr;
bool foundBlockPointer = false;
unsigned parenCount = 1;
-
+
while (parenCount) {
switch (*scanType) {
- case '(':
- parenCount++;
+ case '(':
+ parenCount++;
break;
- case ')':
+ case ')':
parenCount--;
break;
case '^':
@@ -289,7 +288,7 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
Loc = Loc.getFileLocWithOffset(methodPtr-startBuf);
assert((Loc.isValid()) && "Invalid Loc");
ReplaceText(Loc, scanType-methodPtr-1, Tag.c_str(), Tag.size());
-
+
// Advance startBuf. Since the underlying buffer has changed,
// it's very important to advance startBuf (so we can correctly
// compute a relative Loc the next time around).
@@ -305,34 +304,34 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) {
}
void RewriteBlocks::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
- for (ObjCInterfaceDecl::instmeth_iterator
- I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
+ for (ObjCInterfaceDecl::instmeth_iterator
+ I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
- for (ObjCInterfaceDecl::classmeth_iterator
+ for (ObjCInterfaceDecl::classmeth_iterator
I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
}
void RewriteBlocks::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
- for (ObjCCategoryDecl::instmeth_iterator
- I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
+ for (ObjCCategoryDecl::instmeth_iterator
+ I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
- for (ObjCCategoryDecl::classmeth_iterator
+ for (ObjCCategoryDecl::classmeth_iterator
I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
}
void RewriteBlocks::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
- for (ObjCProtocolDecl::instmeth_iterator
- I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
+ for (ObjCProtocolDecl::instmeth_iterator
+ I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
- for (ObjCProtocolDecl::classmeth_iterator
- I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
+ for (ObjCProtocolDecl::classmeth_iterator
+ I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
I != E; ++I)
RewriteMethodDecl(*I);
}
@@ -347,10 +346,10 @@ void RewriteBlocks::HandleTopLevelSingleDecl(Decl *D) {
// if we rewrote the #include/#import.
SourceLocation Loc = D->getLocation();
Loc = SM->getInstantiationLoc(Loc);
-
+
// If this is for a builtin, ignore it.
if (Loc.isInvalid()) return;
-
+
if (ObjCInterfaceDecl *MD = dyn_cast<ObjCInterfaceDecl>(D))
RewriteInterfaceDecl(MD);
else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(D))
@@ -374,7 +373,7 @@ std::string RewriteBlocks::SynthesizeBlockFunc(BlockExpr *CE, int i,
funcName + "_" + "block_func_" + utostr(i);
BlockDecl *BD = CE->getBlockDecl();
-
+
if (isa<FunctionNoProtoType>(AFT)) {
S += "()";
} else if (BD->param_empty()) {
@@ -400,19 +399,19 @@ std::string RewriteBlocks::SynthesizeBlockFunc(BlockExpr *CE, int i,
S += ')';
}
S += " {\n";
-
+
// Create local declarations to avoid rewriting all closure decl ref exprs.
// First, emit a declaration for all "by ref" decls.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
Context->getPointerType((*I)->getType()).getAsStringInternal(Name,
Context->PrintingPolicy);
S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by ref\n";
- }
+ }
// Next, emit a declaration for all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
@@ -420,7 +419,7 @@ std::string RewriteBlocks::SynthesizeBlockFunc(BlockExpr *CE, int i,
//
// void (^myImportedClosure)(void);
// myImportedClosure = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherClosure)(void);
// anotherClosure = ^(void) {
// myImportedClosure(); // import and invoke the closure
@@ -445,13 +444,13 @@ std::string RewriteBlocks::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
std::string Tag) {
std::string StructRef = "struct " + Tag;
std::string S = "static void __";
-
+
S += funcName;
S += "_block_copy_" + utostr(i);
S += "(" + StructRef;
S += "*dst, " + StructRef;
S += "*src) {";
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
E = ImportedBlockDecls.end(); I != E; ++I) {
S += "_Block_copy_assign(&dst->";
S += (*I)->getNameAsString();
@@ -464,13 +463,13 @@ std::string RewriteBlocks::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
S += "_block_dispose_" + utostr(i);
S += "(" + StructRef;
S += "*src) {";
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
E = ImportedBlockDecls.end(); I != E; ++I) {
S += "_Block_destroy(src->";
S += (*I)->getNameAsString();
S += ");";
}
- S += "}\n";
+ S += "}\n";
return S;
}
@@ -478,20 +477,20 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
bool hasCopyDisposeHelpers) {
std::string S = "struct " + Tag;
std::string Constructor = " " + Tag;
-
+
S += " {\n struct __block_impl impl;\n";
-
+
if (hasCopyDisposeHelpers)
S += " void *copy;\n void *dispose;\n";
-
+
Constructor += "(void *fp";
-
+
if (hasCopyDisposeHelpers)
Constructor += ", void *copyHelp, void *disposeHelp";
-
+
if (BlockDeclRefs.size()) {
// Output all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
@@ -500,7 +499,7 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
//
// void (^myImportedBlock)(void);
// myImportedBlock = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherBlock)(void);
// anotherBlock = ^(void) {
// myImportedBlock(); // import and invoke the closure
@@ -517,7 +516,7 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
S += FieldName + ";\n";
}
// Output all "by ref" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
@@ -526,7 +525,7 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
//
// void (^myImportedBlock)(void);
// myImportedBlock = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherBlock)(void);
// anotherBlock = ^(void) {
// myImportedBlock(); // import and invoke the closure
@@ -549,12 +548,12 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += ", int flags=0) {\n";
Constructor += " impl.isa = 0/*&_NSConcreteStackBlock*/;\n impl.Size = sizeof(";
Constructor += Tag + ");\n impl.Flags = flags;\n impl.FuncPtr = fp;\n";
-
+
if (hasCopyDisposeHelpers)
Constructor += " copy = copyHelp;\n dispose = disposeHelp;\n";
-
+
// Initialize all "by copy" arguments.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
Constructor += " ";
@@ -565,7 +564,7 @@ std::string RewriteBlocks::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += Name + ";\n";
}
// Initialize all "by ref" arguments.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
Constructor += " ";
@@ -599,21 +598,21 @@ void RewriteBlocks::SynthesizeBlockLiterals(SourceLocation FunLocStart,
CollectBlockDeclRefInfo(Blocks[i]);
std::string Tag = "__" + std::string(FunName) + "_block_impl_" + utostr(i);
-
- std::string CI = SynthesizeBlockImpl(Blocks[i], Tag,
+
+ std::string CI = SynthesizeBlockImpl(Blocks[i], Tag,
ImportedBlockDecls.size() > 0);
InsertText(FunLocStart, CI.c_str(), CI.size());
std::string CF = SynthesizeBlockFunc(Blocks[i], i, FunName, Tag);
-
+
InsertText(FunLocStart, CF.c_str(), CF.size());
if (ImportedBlockDecls.size()) {
std::string HF = SynthesizeBlockHelperFuncs(Blocks[i], i, FunName, Tag);
InsertText(FunLocStart, HF.c_str(), HF.size());
}
-
+
BlockDeclRefs.clear();
BlockByRefDecls.clear();
BlockByCopyDecls.clear();
@@ -627,7 +626,7 @@ void RewriteBlocks::SynthesizeBlockLiterals(SourceLocation FunLocStart,
void RewriteBlocks::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
const char *FuncName = FD->getNameAsCString();
-
+
SynthesizeBlockLiterals(FunLocStart, FuncName);
}
@@ -638,7 +637,7 @@ void RewriteBlocks::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
std::string::size_type loc = 0;
while ((loc = FuncName.find(":", loc)) != std::string::npos)
FuncName.replace(loc, 1, "_");
-
+
SynthesizeBlockLiterals(FunLocStart, FuncName.c_str());
}
@@ -668,7 +667,7 @@ void RewriteBlocks::GetBlockCallExprs(Stmt *S) {
else
GetBlockCallExprs(*CI);
}
-
+
if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
if (CE->getCallee()->getType()->isBlockPointerType()) {
BlockCallExprs[dyn_cast<BlockDeclRefExpr>(CE->getCallee())] = CE;
@@ -681,7 +680,7 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
// Navigate to relevant type information.
const char *closureName = 0;
const BlockPointerType *CPT = 0;
-
+
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
closureName = DRE->getDecl()->getNameAsCString();
CPT = DRE->getType()->getAs<BlockPointerType>();
@@ -699,20 +698,20 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
assert(FT && "RewriteBlockClass: Bad type");
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
-
+
// Build a closure call - start with a paren expr to enforce precedence.
std::string BlockCall = "(";
- // Synthesize the cast.
+ // Synthesize the cast.
BlockCall += "(" + Exp->getType().getAsString() + "(*)";
BlockCall += "(struct __block_impl *";
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
E = FTP->arg_type_end(); I && (I != E); ++I)
BlockCall += ", " + (*I).getAsString();
}
BlockCall += "))"; // close the argument list and paren expression.
-
+
// Invoke the closure. We need to cast it since the declaration type is
// bogus (it's a function pointer type)
BlockCall += "((struct __block_impl *)";
@@ -722,11 +721,11 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
PrintingPolicy(LangOpts));
BlockCall += closureExprBuf.str();
BlockCall += ")->FuncPtr)";
-
+
// Add the arguments.
BlockCall += "((struct __block_impl *)";
BlockCall += closureExprBuf.str();
- for (CallExpr::arg_iterator I = Exp->arg_begin(),
+ for (CallExpr::arg_iterator I = Exp->arg_begin(),
E = Exp->arg_end(); I != E; ++I) {
std::string syncExprBufS;
llvm::raw_string_ostream Buf(syncExprBufS);
@@ -738,11 +737,11 @@ std::string RewriteBlocks::SynthesizeBlockCall(CallExpr *Exp) {
void RewriteBlocks::RewriteBlockCall(CallExpr *Exp) {
std::string BlockCall = SynthesizeBlockCall(Exp);
-
+
const char *startBuf = SM->getCharacterData(Exp->getLocStart());
const char *endBuf = SM->getCharacterData(Exp->getLocEnd());
- ReplaceText(Exp->getLocStart(), endBuf-startBuf,
+ ReplaceText(Exp->getLocStart(), endBuf-startBuf,
BlockCall.c_str(), BlockCall.size());
}
@@ -754,19 +753,19 @@ void RewriteBlocks::RewriteBlockDeclRefExpr(BlockDeclRefExpr *BDRE) {
void RewriteBlocks::RewriteCastExpr(CastExpr *CE) {
SourceLocation LocStart = CE->getLocStart();
SourceLocation LocEnd = CE->getLocEnd();
-
+
if (!Rewriter::isRewritable(LocStart) || !Rewriter::isRewritable(LocEnd))
return;
-
+
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
-
+
// advance the location to startArgList.
const char *argPtr = startBuf;
-
+
while (*argPtr++ && (argPtr < endBuf)) {
switch (*argPtr) {
- case '^':
+ case '^':
// Replace the '^' with '*'.
LocStart = LocStart.getFileLocWithOffset(argPtr-startBuf);
ReplaceText(LocStart, 1, "*", 1);
@@ -779,31 +778,31 @@ void RewriteBlocks::RewriteCastExpr(CastExpr *CE) {
void RewriteBlocks::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
SourceLocation DeclLoc = FD->getLocation();
unsigned parenCount = 0;
-
+
// We have 1 or more arguments that have closure pointers.
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *startArgList = strchr(startBuf, '(');
-
+
assert((*startArgList == '(') && "Rewriter fuzzy parser confused");
-
+
parenCount++;
// advance the location to startArgList.
DeclLoc = DeclLoc.getFileLocWithOffset(startArgList-startBuf);
assert((DeclLoc.isValid()) && "Invalid DeclLoc");
-
+
const char *argPtr = startArgList;
-
+
while (*argPtr++ && parenCount) {
switch (*argPtr) {
- case '^':
+ case '^':
// Replace the '^' with '*'.
DeclLoc = DeclLoc.getFileLocWithOffset(argPtr-startArgList);
ReplaceText(DeclLoc, 1, "*", 1);
break;
- case '(':
- parenCount++;
+ case '(':
+ parenCount++;
break;
- case ')':
+ case ')':
parenCount--;
break;
}
@@ -822,7 +821,7 @@ bool RewriteBlocks::PointerTypeTakesAnyBlockArguments(QualType QT) {
FTP = BPT->getPointeeType()->getAsFunctionProtoType();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
E = FTP->arg_type_end(); I != E; ++I)
if (isBlockPointerType(*I))
return true;
@@ -830,15 +829,15 @@ bool RewriteBlocks::PointerTypeTakesAnyBlockArguments(QualType QT) {
return false;
}
-void RewriteBlocks::GetExtentOfArgList(const char *Name,
+void RewriteBlocks::GetExtentOfArgList(const char *Name,
const char *&LParen, const char *&RParen) {
const char *argPtr = strchr(Name, '(');
assert((*argPtr == '(') && "Rewriter fuzzy parser confused");
-
+
LParen = argPtr; // output the start.
argPtr++; // skip past the left paren.
unsigned parenCount = 1;
-
+
while (*argPtr && parenCount) {
switch (*argPtr) {
case '(': parenCount++; break;
@@ -855,7 +854,7 @@ void RewriteBlocks::RewriteBlockPointerDecl(NamedDecl *ND) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
RewriteBlockPointerFunctionArgs(FD);
return;
- }
+ }
// Handle Variables and Typedefs.
SourceLocation DeclLoc = ND->getLocation();
QualType DeclT;
@@ -865,15 +864,15 @@ void RewriteBlocks::RewriteBlockPointerDecl(NamedDecl *ND) {
DeclT = TDD->getUnderlyingType();
else if (FieldDecl *FD = dyn_cast<FieldDecl>(ND))
DeclT = FD->getType();
- else
+ else
assert(0 && "RewriteBlockPointerDecl(): Decl type not yet handled");
-
+
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *endBuf = startBuf;
// scan backward (from the decl location) for the end of the previous decl.
while (*startBuf != '^' && *startBuf != ';' && startBuf != MainFileStart)
startBuf--;
-
+
// *startBuf != '^' if we are dealing with a pointer to function that
// may take block argument types (which will be handled below).
if (*startBuf == '^') {
@@ -898,7 +897,7 @@ void RewriteBlocks::RewriteBlockPointerDecl(NamedDecl *ND) {
return;
}
-void RewriteBlocks::CollectBlockDeclRefInfo(BlockExpr *Exp) {
+void RewriteBlocks::CollectBlockDeclRefInfo(BlockExpr *Exp) {
// Add initializers for any closure decl refs.
GetBlockDeclRefExprs(Exp->getBody());
if (BlockDeclRefs.size()) {
@@ -925,7 +924,7 @@ std::string RewriteBlocks::SynthesizeBlockInitExpr(BlockExpr *Exp, VarDecl *VD)
CollectBlockDeclRefInfo(Exp);
std::string FuncName;
-
+
if (CurFunctionDef)
FuncName = std::string(CurFunctionDef->getNameAsString());
else if (CurMethodDef) {
@@ -936,27 +935,27 @@ std::string RewriteBlocks::SynthesizeBlockInitExpr(BlockExpr *Exp, VarDecl *VD)
FuncName.replace(loc, 1, "_");
} else if (VD)
FuncName = std::string(VD->getNameAsString());
-
+
std::string BlockNumber = utostr(Blocks.size()-1);
-
+
std::string Tag = "__" + FuncName + "_block_impl_" + BlockNumber;
std::string Func = "__" + FuncName + "_block_func_" + BlockNumber;
-
+
std::string FunkTypeStr;
-
+
// Get a pointer to the function type so we can cast appropriately.
Context->getPointerType(QualType(Exp->getFunctionType(),0))
.getAsStringInternal(FunkTypeStr, Context->PrintingPolicy);
-
+
// Rewrite the closure block with a compound literal. The first cast is
// to prevent warnings from the C compiler.
std::string Init = "(" + FunkTypeStr;
-
+
Init += ")&" + Tag;
-
+
// Initialize the block function.
Init += "((void*)" + Func;
-
+
if (ImportedBlockDecls.size()) {
std::string Buf = "__" + FuncName + "_block_copy_" + BlockNumber;
Init += ",(void*)" + Buf;
@@ -966,7 +965,7 @@ std::string RewriteBlocks::SynthesizeBlockInitExpr(BlockExpr *Exp, VarDecl *VD)
// Add initializers for any closure decl refs.
if (BlockDeclRefs.size()) {
// Output all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
Init += ",";
if (isObjCType((*I)->getType())) {
@@ -981,7 +980,7 @@ std::string RewriteBlocks::SynthesizeBlockInitExpr(BlockExpr *Exp, VarDecl *VD)
}
}
// Output all "by ref" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
Init += ",&";
Init += (*I)->getNameAsString();
@@ -1007,7 +1006,7 @@ Stmt *RewriteBlocks::RewriteFunctionBody(Stmt *S) {
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
RewriteFunctionBody(CBE->getBody());
-
+
// We've just rewritten the block body in place.
// Now we snarf the rewritten text and stash it away for later use.
std::string S = Rewrite.getRewritenText(CBE->getSourceRange());
@@ -1030,18 +1029,18 @@ Stmt *RewriteBlocks::RewriteFunctionBody(Stmt *S) {
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
-
+
Decl *SD = *DI;
if (ValueDecl *ND = dyn_cast<ValueDecl>(SD)) {
if (isBlockPointerType(ND->getType()))
RewriteBlockPointerDecl(ND);
- else if (ND->getType()->isFunctionPointerType())
+ else if (ND->getType()->isFunctionPointerType())
CheckFunctionPointerDecl(ND->getType(), ND);
}
if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) {
if (isBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
- else if (TD->getUnderlyingType()->isFunctionPointerType())
+ else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
}
}
@@ -1055,9 +1054,9 @@ Stmt *RewriteBlocks::RewriteFunctionBody(Stmt *S) {
return S;
}
-void RewriteBlocks::RewriteFunctionProtoType(QualType funcType, NamedDecl *D) {
+void RewriteBlocks::RewriteFunctionProtoType(QualType funcType, NamedDecl *D) {
if (FunctionProtoType *fproto = dyn_cast<FunctionProtoType>(funcType)) {
- for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
E = fproto->arg_type_end(); I && (I != E); ++I)
if (isBlockPointerType(*I)) {
// All the args are checked/rewritten. Don't call twice!
@@ -1090,7 +1089,7 @@ void RewriteBlocks::HandleDeclInMainFile(Decl *D) {
// and any copy/dispose helper functions.
InsertBlockLiteralsWithinFunction(FD);
CurFunctionDef = 0;
- }
+ }
return;
}
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
@@ -1116,7 +1115,7 @@ void RewriteBlocks::HandleDeclInMainFile(Decl *D) {
std::string Init = SynthesizeBlockInitExpr(CBE, VD);
// Do the rewrite, using S.size() which contains the rewritten size.
ReplaceText(CBE->getLocStart(), S.size(), Init.c_str(), Init.size());
- SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(),
+ SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(),
VD->getNameAsCString());
} else if (CastExpr *CE = dyn_cast<CastExpr>(VD->getInit())) {
RewriteCastExpr(CE);
@@ -1135,13 +1134,13 @@ void RewriteBlocks::HandleDeclInMainFile(Decl *D) {
if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
if (isBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
- else if (TD->getUnderlyingType()->isFunctionPointerType())
+ else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
return;
}
if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
if (RD->isDefinition()) {
- for (RecordDecl::field_iterator i = RD->field_begin(),
+ for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
FieldDecl *FD = *i;
if (isBlockPointerType(FD->getType()))
diff --git a/lib/Frontend/RewriteMacros.cpp b/lib/Frontend/RewriteMacros.cpp
index 30cd6ff494..d92f5c78e6 100644
--- a/lib/Frontend/RewriteMacros.cpp
+++ b/lib/Frontend/RewriteMacros.cpp
@@ -31,14 +31,14 @@ static bool isSameToken(Token &RawTok, Token &PPTok) {
if (PPTok.getKind() == RawTok.getKind() &&
PPTok.getIdentifierInfo() == RawTok.getIdentifierInfo())
return true;
-
+
// Otherwise, if they are different but have the same identifier info, they
// are also considered to be the same. This allows keywords and raw lexed
// identifiers with the same name to be treated the same.
if (PPTok.getIdentifierInfo() &&
PPTok.getIdentifierInfo() == RawTok.getIdentifierInfo())
return true;
-
+
return false;
}
@@ -48,11 +48,11 @@ static bool isSameToken(Token &RawTok, Token &PPTok) {
static const Token &GetNextRawTok(const std::vector<Token> &RawTokens,
unsigned &CurTok, bool ReturnComment) {
assert(CurTok < RawTokens.size() && "Overran eof!");
-
+
// If the client doesn't want comments and we have one, skip it.
if (!ReturnComment && RawTokens[CurTok].is(tok::comment))
++CurTok;
-
+
return RawTokens[CurTok++];
}
@@ -62,24 +62,24 @@ static const Token &GetNextRawTok(const std::vector<Token> &RawTokens,
static void LexRawTokensFromMainFile(Preprocessor &PP,
std::vector<Token> &RawTokens) {
SourceManager &SM = PP.getSourceManager();
-
+
// Create a lexer to lex all the tokens of the main file in raw mode. Even
// though it is in raw mode, it will not return comments.
Lexer RawLex(SM.getMainFileID(), SM, PP.getLangOptions());
// Switch on comment lexing because we really do want them.
RawLex.SetCommentRetentionState(true);
-
+
Token RawTok;
do {
RawLex.LexFromRawLexer(RawTok);
-
+
// If we have an identifier with no identifier info for our raw token, look
// up the indentifier info. This is important for equality comparison of
// identifier tokens.
if (RawTok.is(tok::identifier) && !RawTok.getIdentifierInfo())
RawTok.setIdentifierInfo(PP.LookUpIdentifierInfo(RawTok));
-
+
RawTokens.push_back(RawTok);
} while (RawTok.isNot(tok::eof));
}
@@ -88,7 +88,7 @@ static void LexRawTokensFromMainFile(Preprocessor &PP,
/// RewriteMacrosInInput - Implement -rewrite-macros mode.
void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
SourceManager &SM = PP.getSourceManager();
-
+
Rewriter Rewrite;
Rewrite.setSourceMgr(SM, PP.getLangOptions());
RewriteBuffer &RB = Rewrite.getEditBuffer(SM.getMainFileID());
@@ -98,12 +98,12 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
unsigned CurRawTok = 0;
Token RawTok = GetNextRawTok(RawTokens, CurRawTok, false);
-
+
// Get the first preprocessing token.
PP.EnterMainSourceFile();
Token PPTok;
PP.Lex(PPTok);
-
+
// Preprocess the input file in parallel with raw lexing the main file. Ignore
// all tokens that are preprocessed from a file other than the main file (e.g.
// a header). If we see tokens that are in the preprocessed file but not the
@@ -118,7 +118,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
PP.Lex(PPTok);
continue;
}
-
+
// If the raw file hits a preprocessor directive, they will be extra tokens
// in the raw file that don't exist in the preprocsesed file. However, we
// choose to preserve them in the output file and otherwise handle them
@@ -139,7 +139,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");
}
}
-
+
// Otherwise, if this is a #include or some other directive, just leave it
// in the file by skipping over the line.
RawTok = GetNextRawTok(RawTokens, CurRawTok, false);
@@ -147,7 +147,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
RawTok = GetNextRawTok(RawTokens, CurRawTok, false);
continue;
}
-
+
// Okay, both tokens are from the same file. Get their offsets from the
// start of the file.
unsigned PPOffs = SM.getFileOffset(PPLoc);
@@ -174,20 +174,20 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
RawTok = GetNextRawTok(RawTokens, CurRawTok, true);
RawOffs = SM.getFileOffset(RawTok.getLocation());
-
+
if (RawTok.is(tok::comment)) {
// Skip past the comment.
RawTok = GetNextRawTok(RawTokens, CurRawTok, false);
break;
}
-
+
} while (RawOffs <= PPOffs && !RawTok.isAtStartOfLine() &&
(PPOffs != RawOffs || !isSameToken(RawTok, PPTok)));
RB.InsertTextBefore(EndPos, "*/");
continue;
}
-
+
// Otherwise, there was a replacement an expansion. Insert the new token
// in the output buffer. Insert the whole run of new tokens at once to get
// them in the right order.
@@ -205,7 +205,7 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
// Get the buffer corresponding to MainFileID. If we haven't changed it, then
// we are done.
- if (const RewriteBuffer *RewriteBuf =
+ if (const RewriteBuffer *RewriteBuf =
Rewrite.getRewriteBufferFor(SM.getMainFileID())) {
//printf("Changed:\n");
*OS << std::string(RewriteBuf->begin(), RewriteBuf->end());
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 8d5f4992ae..323804744d 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -35,14 +35,14 @@ namespace {
const LangOptions &LangOpts;
unsigned RewriteFailedDiag;
unsigned TryFinallyContainsReturnDiag;
-
+
ASTContext *Context;
SourceManager *SM;
TranslationUnitDecl *TUDecl;
FileID MainFileID;
const char *MainFileStart, *MainFileEnd;
SourceLocation LastIncLoc;
-
+
llvm::SmallVector<ObjCImplementationDecl *, 8> ClassImplementation;
llvm::SmallVector<ObjCCategoryImplDecl *, 8> CategoryImplementation;
llvm::SmallPtrSet<ObjCInterfaceDecl*, 8> ObjCSynthesizedStructs;
@@ -53,9 +53,9 @@ namespace {
llvm::SmallVector<int, 8> ObjCBcLabelNo;
// Remember all the @protocol(<expr>) expressions.
llvm::SmallPtrSet<ObjCProtocolDecl *, 32> ProtocolExprDecls;
-
+
unsigned NumObjCStringLiterals;
-
+
FunctionDecl *MsgSendFunctionDecl;
FunctionDecl *MsgSendSuperFunctionDecl;
FunctionDecl *MsgSendStretFunctionDecl;
@@ -66,25 +66,25 @@ namespace {
FunctionDecl *SelGetUidFunctionDecl;
FunctionDecl *CFStringFunctionDecl;
FunctionDecl *SuperContructorFunctionDecl;
-
+
// ObjC string constant support.
VarDecl *ConstantStringClassReference;
RecordDecl *NSStringRecord;
-
+
// ObjC foreach break/continue generation support.
int BcLabelCount;
-
+
// Needed for super.
ObjCMethodDecl *CurMethodDef;
RecordDecl *SuperStructDecl;
RecordDecl *ConstantStringDecl;
-
+
TypeDecl *ProtocolTypeDecl;
QualType getProtocolType();
-
+
// Needed for header files being rewritten
bool IsHeader;
-
+
std::string InFileName;
llvm::raw_ostream* OutFile;
@@ -96,7 +96,7 @@ namespace {
llvm::SmallVector<BlockExpr *, 32> Blocks;
llvm::SmallVector<BlockDeclRefExpr *, 32> BlockDeclRefs;
llvm::DenseMap<BlockDeclRefExpr *, CallExpr *> BlockCallExprs;
-
+
// Block related declarations.
llvm::SmallPtrSet<ValueDecl *, 8> BlockByCopyDecls;
llvm::SmallPtrSet<ValueDecl *, 8> BlockByRefDecls;
@@ -109,7 +109,7 @@ namespace {
// This maps a property to it's synthesied message expression.
// This allows us to rewrite chained getters (e.g. o.a.b.c).
llvm::DenseMap<ObjCPropertyRefExpr *, Stmt *> PropGetters;
-
+
// This maps an original source AST to it's rewritten form. This allows
// us to avoid rewriting the same node twice (which is very uncommon).
// This is needed to support some of the exotic property rewriting.
@@ -117,9 +117,9 @@ namespace {
FunctionDecl *CurFunctionDef;
VarDecl *GlobalVarDecl;
-
+
bool DisableReplaceStmt;
-
+
static const int OBJC_ABI_VERSION =7 ;
public:
virtual void Initialize(ASTContext &context);
@@ -136,12 +136,12 @@ namespace {
bool silenceMacroWarn);
~RewriteObjC() {}
-
+
virtual void HandleTranslationUnit(ASTContext &C);
-
+
void ReplaceStmt(Stmt *Old, Stmt *New) {
Stmt *ReplacingStmt = ReplacedNodes[Old];
-
+
if (ReplacingStmt)
return; // We can't rewrite the same node twice.
@@ -191,15 +191,15 @@ namespace {
InsertAfter) ||
SilenceRewriteMacroWarning)
return;
-
+
Diags.Report(Context->getFullLoc(Loc), RewriteFailedDiag);
}
-
+
void RemoveText(SourceLocation Loc, unsigned StrLen) {
// If removal succeeded or warning disabled return with no warning.
if (!Rewrite.RemoveText(Loc, StrLen) || SilenceRewriteMacroWarning)
return;
-
+
Diags.Report(Context->getFullLoc(Loc), RewriteFailedDiag);
}
@@ -210,10 +210,10 @@ namespace {
llvm::StringRef(NewStr, NewLength)) ||
SilenceRewriteMacroWarning)
return;
-
+
Diags.Report(Context->getFullLoc(Start), RewriteFailedDiag);
}
-
+
// Syntactic Rewriting.
void RewritePrologue(SourceLocation Loc);
void RewriteInclude();
@@ -238,18 +238,18 @@ namespace {
QualType getSuperStructType();
QualType getConstantStringStructType();
bool BufferContainsPPDirectives(const char *startBuf, const char *endBuf);
-
+
// Expression Rewriting.
Stmt *RewriteFunctionBodyOrGlobalInitializer(Stmt *S);
void CollectPropertySetters(Stmt *S);
-
+
Stmt *CurrentBody;
ParentMap *PropParentMap; // created lazily.
-
+
Stmt *RewriteAtEncode(ObjCEncodeExpr *Exp);
Stmt *RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV, SourceLocation OrigStart);
Stmt *RewritePropertyGetter(ObjCPropertyRefExpr *PropRefExpr);
- Stmt *RewritePropertySetter(BinaryOperator *BinOp, Expr *newStmt,
+ Stmt *RewritePropertySetter(BinaryOperator *BinOp, Expr *newStmt,
SourceRange SrcRange);
Stmt *RewriteAtSelector(ObjCSelectorExpr *Exp);
Stmt *RewriteMessageExpr(ObjCMessageExpr *Exp);
@@ -263,13 +263,13 @@ namespace {
Stmt *RewriteObjCThrowStmt(ObjCAtThrowStmt *S);
Stmt *RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
SourceLocation OrigEnd);
- CallExpr *SynthesizeCallToFunctionDecl(FunctionDecl *FD,
+ CallExpr *SynthesizeCallToFunctionDecl(FunctionDecl *FD,
Expr **args, unsigned nargs);
Stmt *SynthMessageExpr(ObjCMessageExpr *Exp);
Stmt *RewriteBreakStmt(BreakStmt *S);
Stmt *RewriteContinueStmt(ContinueStmt *S);
void SynthCountByEnumWithState(std::string &buf);
-
+
void SynthMsgSendFunctionDecl();
void SynthMsgSendSuperFunctionDecl();
void SynthMsgSendStretFunctionDecl();
@@ -279,14 +279,14 @@ namespace {
void SynthGetMetaClassFunctionDecl();
void SynthSelGetUidFunctionDecl();
void SynthSuperContructorFunctionDecl();
-
+
// Metadata emission.
void RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
std::string &Result);
-
+
void RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *CDecl,
std::string &Result);
-
+
template<typename MethodIterator>
void RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
MethodIterator MethodEnd,
@@ -294,69 +294,69 @@ namespace {
const char *prefix,
const char *ClassName,
std::string &Result);
-
+
void RewriteObjCProtocolMetaData(ObjCProtocolDecl *Protocol,
const char *prefix,
const char *ClassName,
std::string &Result);
void RewriteObjCProtocolListMetaData(const ObjCList<ObjCProtocolDecl> &Prots,
- const char *prefix,
+ const char *prefix,
const char *ClassName,
std::string &Result);
void SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result);
- void SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
- ObjCIvarDecl *ivar,
+ void SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
+ ObjCIvarDecl *ivar,
std::string &Result);
void RewriteImplementations();
void SynthesizeMetaDataIntoBuffer(std::string &Result);
-
+
// Block rewriting.
- void RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D);
+ void RewriteBlocksInFunctionProtoType(QualType funcType, NamedDecl *D);
void CheckFunctionPointerDecl(QualType dType, NamedDecl *ND);
-
+
void InsertBlockLiteralsWithinFunction(FunctionDecl *FD);
void InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD);
-
- // Block specific rewrite rules.
+
+ // Block specific rewrite rules.
void RewriteBlockCall(CallExpr *Exp);
void RewriteBlockPointerDecl(NamedDecl *VD);
Stmt *RewriteBlockDeclRefExpr(BlockDeclRefExpr *VD);
void RewriteBlockPointerFunctionArgs(FunctionDecl *FD);
-
- std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
+
+ std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
const char *funcName, std::string Tag);
- std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
+ std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
const char *funcName, std::string Tag);
- std::string SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
+ std::string SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
bool hasCopyDisposeHelpers);
Stmt *SynthesizeBlockCall(CallExpr *Exp);
void SynthesizeBlockLiterals(SourceLocation FunLocStart,
const char *FunName);
-
+
void CollectBlockDeclRefInfo(BlockExpr *Exp);
void GetBlockCallExprs(Stmt *S);
void GetBlockDeclRefExprs(Stmt *S);
-
+
// We avoid calling Type::isBlockPointerType(), since it operates on the
// canonical type. We only care if the top-level type is a closure pointer.
bool isTopLevelBlockPointerType(QualType T) {
return isa<BlockPointerType>(T);
}
-
+
// FIXME: This predicate seems like it would be useful to add to ASTContext.
bool isObjCType(QualType T) {
if (!LangOpts.ObjC1 && !LangOpts.ObjC2)
return false;
-
+
QualType OCT = Context->getCanonicalType(T).getUnqualifiedType();
-
+
if (OCT == Context->getCanonicalType(Context->getObjCIdType()) ||
OCT == Context->getCanonicalType(Context->getObjCClassType()))
return true;
-
+
if (const PointerType *PT = OCT->getAs<PointerType>()) {
- if (isa<ObjCInterfaceType>(PT->getPointeeType()) ||
+ if (isa<ObjCInterfaceType>(PT->getPointeeType()) ||
PT->getPointeeType()->isObjCQualifiedIdType())
return true;
}
@@ -366,12 +366,12 @@ namespace {
void GetExtentOfArgList(const char *Name, const char *&LParen,
const char *&RParen);
void RewriteCastExpr(CStyleCastExpr *CE);
-
+
FunctionDecl *SynthBlockInitFunctionDecl(const char *name);
Stmt *SynthBlockInitExpr(BlockExpr *Exp);
-
+
void QuoteDoublequotes(std::string &From, std::string &To) {
- for(unsigned i = 0; i < From.length(); i++) {
+ for (unsigned i = 0; i < From.length(); i++) {
if (From[i] == '"')
To += "\\\"";
else
@@ -381,10 +381,10 @@ namespace {
};
}
-void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
- NamedDecl *D) {
+void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
+ NamedDecl *D) {
if (FunctionProtoType *fproto = dyn_cast<FunctionProtoType>(funcType)) {
- for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
E = fproto->arg_type_end(); I && (I != E); ++I)
if (isTopLevelBlockPointerType(*I)) {
// All the args are checked/rewritten. Don't call twice!
@@ -402,17 +402,17 @@ void RewriteObjC::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) {
static bool IsHeaderFile(const std::string &Filename) {
std::string::size_type DotPos = Filename.rfind('.');
-
+
if (DotPos == std::string::npos) {
// no file extension
- return false;
+ return false;
}
-
+
std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
// C header: .h
// C++ header: .hh or .H;
return Ext == "h" || Ext == "hh" || Ext == "H";
-}
+}
RewriteObjC::RewriteObjC(std::string inFile, llvm::raw_ostream* OS,
Diagnostic &D, const LangOptions &LOpts,
@@ -420,16 +420,16 @@ RewriteObjC::RewriteObjC(std::string inFile, llvm::raw_ostream* OS,
: Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
SilenceRewriteMacroWarning(silenceMacroWarn) {
IsHeader = IsHeaderFile(inFile);
- RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
+ RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
"rewriting sub-expression within a macro (may not be correct)");
- TryFinallyContainsReturnDiag = Diags.getCustomDiagID(Diagnostic::Warning,
+ TryFinallyContainsReturnDiag = Diags.getCustomDiagID(Diagnostic::Warning,
"rewriter doesn't support user-specified control flow semantics "
"for @try/@finally (code may not execute properly)");
}
ASTConsumer *clang::CreateObjCRewriter(const std::string& InFile,
llvm::raw_ostream* OS,
- Diagnostic &Diags,
+ Diagnostic &Diags,
const LangOptions &LOpts,
bool SilenceRewriteMacroWarning) {
return new RewriteObjC(InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning);
@@ -462,15 +462,15 @@ void RewriteObjC::Initialize(ASTContext &context) {
PropParentMap = 0;
CurrentBody = 0;
DisableReplaceStmt = false;
-
+
// Get the ID and start/end of the main file.
MainFileID = SM->getMainFileID();
const llvm::MemoryBuffer *MainBuf = SM->getBuffer(MainFileID);
MainFileStart = MainBuf->getBufferStart();
MainFileEnd = MainBuf->getBufferEnd();
-
+
Rewrite.setSourceMgr(Context->getSourceManager(), Context->getLangOptions());
-
+
// declaring objc_selector outside the parameter list removes a silly
// scope related warning...
if (IsHeader)
@@ -574,7 +574,7 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) {
// if we rewrote the #include/#import.
SourceLocation Loc = D->getLocation();
Loc = SM->getInstantiationLoc(Loc);
-
+
// If this is for a builtin, ignore it.
if (Loc.isInvalid()) return;
@@ -593,7 +593,7 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) {
RewriteCategoryDecl(CD);
} else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
RewriteProtocolDecl(PD);
- } else if (ObjCForwardProtocolDecl *FP =
+ } else if (ObjCForwardProtocolDecl *FP =
dyn_cast<ObjCForwardProtocolDecl>(D)){
RewriteForwardProtocolDecl(FP);
} else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
@@ -619,7 +619,7 @@ void RewriteObjC::RewriteInclude() {
const char *MainBufEnd = MainBuf.second;
size_t ImportLen = strlen("import");
size_t IncludeLen = strlen("include");
-
+
// Loop over the whole file, looking for includes.
for (const char *BufPtr = MainBufStart; BufPtr < MainBufEnd; ++BufPtr) {
if (*BufPtr == '#') {
@@ -630,7 +630,7 @@ void RewriteObjC::RewriteInclude() {
return;
if (!strncmp(BufPtr, "import", ImportLen)) {
// replace import with include
- SourceLocation ImportLoc =
+ SourceLocation ImportLoc =
LocStart.getFileLocWithOffset(BufPtr-MainBufStart);
ReplaceText(ImportLoc, ImportLen, "include", IncludeLen);
BufPtr += ImportLen;
@@ -643,27 +643,27 @@ void RewriteObjC::RewriteTabs() {
std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID);
const char *MainBufStart = MainBuf.first;
const char *MainBufEnd = MainBuf.second;
-
+
// Loop over the whole file, looking for tabs.
for (const char *BufPtr = MainBufStart; BufPtr != MainBufEnd; ++BufPtr) {
if (*BufPtr != '\t')
continue;
-
+
// Okay, we found a tab. This tab will turn into at least one character,
// but it depends on which 'virtual column' it is in. Compute that now.
unsigned VCol = 0;
while (BufPtr-VCol != MainBufStart && BufPtr[-VCol-1] != '\t' &&
BufPtr[-VCol-1] != '\n' && BufPtr[-VCol-1] != '\r')
++VCol;
-
+
// Okay, now that we know the virtual column, we know how many spaces to
// insert. We assume 8-character tab-stops.
unsigned Spaces = 8-(VCol & 7);
-
+
// Get the location of the tab.
SourceLocation TabLoc = SM->getLocForStartOfFile(MainFileID);
TabLoc = TabLoc.getFileLocWithOffset(BufPtr-MainBufStart);
-
+
// Rewrite the single tab character into a sequence of spaces.
ReplaceText(TabLoc, 1, " ", Spaces);
}
@@ -693,35 +693,35 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
return; // FIXME: is this correct?
-
+
// Generate the 'getter' function.
ObjCPropertyDecl *PD = PID->getPropertyDecl();
ObjCInterfaceDecl *ClassDecl = PD->getGetterMethodDecl()->getClassInterface();
ObjCIvarDecl *OID = PID->getPropertyIvarDecl();
-
+
if (!OID)
return;
-
+
std::string Getr;
RewriteObjCMethodDecl(PD->getGetterMethodDecl(), Getr);
Getr += "{ ";
// Synthesize an explicit cast to gain access to the ivar.
- // FIXME: deal with code generation implications for various property
- // attributes (copy, retain, nonatomic).
+ // FIXME: deal with code generation implications for various property
+ // attributes (copy, retain, nonatomic).
// See objc-act.c:objc_synthesize_new_getter() for details.
Getr += "return " + getIvarAccessString(ClassDecl, OID);
Getr += "; }";
InsertText(onePastSemiLoc, Getr.c_str(), Getr.size());
if (PD->isReadOnly())
return;
-
+
// Generate the 'setter' function.
std::string Setr;
RewriteObjCMethodDecl(PD->getSetterMethodDecl(), Setr);
Setr += "{ ";
// Synthesize an explicit cast to initialize the ivar.
- // FIXME: deal with code generation implications for various property
- // attributes (copy, retain, nonatomic).
+ // FIXME: deal with code generation implications for various property
+ // attributes (copy, retain, nonatomic).
// See objc-act.c:objc_synthesize_new_setter() for details.
Setr += getIvarAccessString(ClassDecl, OID) + " = ";
Setr += PD->getNameAsCString();
@@ -734,7 +734,7 @@ void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
SourceLocation startLoc = ClassDecl->getLocation();
const char *startBuf = SM->getCharacterData(startLoc);
const char *semiPtr = strchr(startBuf, ';');
-
+
// Translate to typedef's that forward reference structs with the same name
// as the class. As a convenience, we include the original declaration
// as a comment.
@@ -755,16 +755,16 @@ void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
typedefString += ForwardDecl->getNameAsString();
typedefString += ";\n#endif\n";
}
-
+
// Replace the @class with typedefs corresponding to the classes.
- ReplaceText(startLoc, semiPtr-startBuf+1,
+ ReplaceText(startLoc, semiPtr-startBuf+1,
typedefString.c_str(), typedefString.size());
}
void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
SourceLocation LocStart = Method->getLocStart();
SourceLocation LocEnd = Method->getLocEnd();
-
+
if (SM->getInstantiationLineNumber(LocEnd) >
SM->getInstantiationLineNumber(LocStart)) {
InsertText(LocStart, "#if 0\n", 6);
@@ -774,26 +774,25 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
}
}
-void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop)
-{
+void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop) {
SourceLocation Loc = prop->getLocation();
-
+
ReplaceText(Loc, 0, "// ", 3);
-
+
// FIXME: handle properties that are declared across multiple lines.
}
void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
SourceLocation LocStart = CatDecl->getLocStart();
-
+
// FIXME: handle category headers that are declared across multiple lines.
ReplaceText(LocStart, 0, "// ", 3);
-
- for (ObjCCategoryDecl::instmeth_iterator
- I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
+
+ for (ObjCCategoryDecl::instmeth_iterator
+ I = CatDecl->instmeth_begin(), E = CatDecl->instmeth_end();
I != E; ++I)
RewriteMethodDeclaration(*I);
- for (ObjCCategoryDecl::classmeth_iterator
+ for (ObjCCategoryDecl::classmeth_iterator
I = CatDecl->classmeth_begin(), E = CatDecl->classmeth_end();
I != E; ++I)
RewriteMethodDeclaration(*I);
@@ -804,14 +803,14 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
std::pair<const char*, const char*> MainBuf = SM->getBufferData(MainFileID);
-
+
SourceLocation LocStart = PDecl->getLocStart();
-
+
// FIXME: handle protocol headers that are declared across multiple lines.
ReplaceText(LocStart, 0, "// ", 3);
-
- for (ObjCProtocolDecl::instmeth_iterator
- I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
+
+ for (ObjCProtocolDecl::instmeth_iterator
+ I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
I != E; ++I)
RewriteMethodDeclaration(*I);
for (ObjCProtocolDecl::classmeth_iterator
@@ -832,14 +831,14 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
SourceLocation OptionalLoc = LocStart.getFileLocWithOffset(p-startBuf);
ReplaceText(OptionalLoc, strlen("@optional"),
CommentedOptional.c_str(), CommentedOptional.size());
-
+
}
else if (*p == '@' && !strncmp(p+1, "required", strlen("required"))) {
std::string CommentedRequired = "/* @required */";
SourceLocation OptionalLoc = LocStart.getFileLocWithOffset(p-startBuf);
ReplaceText(OptionalLoc, strlen("@required"),
CommentedRequired.c_str(), CommentedRequired.size());
-
+
}
}
}
@@ -852,7 +851,7 @@ void RewriteObjC::RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *PDecl) {
ReplaceText(LocStart, 0, "// ", 3);
}
-void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
+void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
std::string &ResultStr) {
//fprintf(stderr,"In RewriteObjCMethodDecl\n");
const FunctionType *FPRetType = 0;
@@ -876,24 +875,24 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
} else
ResultStr += OMD->getResultType().getAsString();
ResultStr += " ";
-
+
// Unique method name
std::string NameStr;
-
+
if (OMD->isInstanceMethod())
NameStr += "_I_";
else
NameStr += "_C_";
-
+
NameStr += OMD->getClassInterface()->getNameAsString();
NameStr += "_";
-
- if (ObjCCategoryImplDecl *CID =
+
+ if (ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
NameStr += CID->getNameAsString();
NameStr += "_";
}
- // Append selector names, replacing ':' with '_'
+ // Append selector names, replacing ':' with '_'
{
std::string selString = OMD->getSelector().getAsString();
int len = selString.size();
@@ -905,10 +904,10 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
// Remember this name for metadata emission
MethodInternalNames[OMD] = NameStr;
ResultStr += NameStr;
-
+
// Rewrite arguments
ResultStr += "(";
-
+
// invisible arguments
if (OMD->isInstanceMethod()) {
QualType selfTy = Context->getObjCInterfaceType(OMD->getClassInterface());
@@ -923,11 +922,11 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
}
else
ResultStr += Context->getObjCClassType().getAsString();
-
+
ResultStr += " self, ";
ResultStr += Context->getObjCSelType().getAsString();
ResultStr += " _cmd";
-
+
// Method arguments.
for (ObjCMethodDecl::param_iterator PI = OMD->param_begin(),
E = OMD->param_end(); PI != E; ++PI) {
@@ -951,10 +950,10 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
if (OMD->isVariadic())
ResultStr += ", ...";
ResultStr += ") ";
-
+
if (FPRetType) {
ResultStr += ")"; // close the precedence "scope" for "*".
-
+
// Now, emit the argument types (if any).
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FPRetType)) {
ResultStr += "(";
@@ -976,12 +975,12 @@ void RewriteObjC::RewriteObjCMethodDecl(ObjCMethodDecl *OMD,
void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
ObjCImplementationDecl *IMD = dyn_cast<ObjCImplementationDecl>(OID);
ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(OID);
-
+
if (IMD)
InsertText(IMD->getLocStart(), "// ", 3);
else
InsertText(CID->getLocStart(), "// ", 3);
-
+
for (ObjCCategoryImplDecl::instmeth_iterator
I = IMD ? IMD->instmeth_begin() : CID->instmeth_begin(),
E = IMD ? IMD->instmeth_end() : CID->instmeth_end();
@@ -997,7 +996,7 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
ReplaceText(LocStart, endBuf-startBuf,
ResultStr.c_str(), ResultStr.size());
}
-
+
for (ObjCCategoryImplDecl::classmeth_iterator
I = IMD ? IMD->classmeth_begin() : CID->classmeth_begin(),
E = IMD ? IMD->classmeth_end() : CID->classmeth_end();
@@ -1007,15 +1006,15 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
RewriteObjCMethodDecl(OMD, ResultStr);
SourceLocation LocStart = OMD->getLocStart();
SourceLocation LocEnd = OMD->getCompoundBody()->getLocStart();
-
+
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
ReplaceText(LocStart, endBuf-startBuf,
- ResultStr.c_str(), ResultStr.size());
+ ResultStr.c_str(), ResultStr.size());
}
for (ObjCCategoryImplDecl::propimpl_iterator
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
- E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
+ E = IMD ? IMD->propimpl_end() : CID->propimpl_end();
I != E; ++I) {
RewritePropertyImplDecl(*I, IMD, CID);
}
@@ -1023,7 +1022,7 @@ void RewriteObjC::RewriteImplementationDecl(Decl *OID) {
if (IMD)
InsertText(IMD->getLocEnd(), "// ", 3);
else
- InsertText(CID->getLocEnd(), "// ", 3);
+ InsertText(CID->getLocEnd(), "// ", 3);
}
void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
@@ -1043,16 +1042,16 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
ObjCForwardDecls.insert(ClassDecl);
}
SynthesizeObjCInternalStruct(ClassDecl, ResultStr);
-
- for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
+
+ for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(),
E = ClassDecl->prop_end(); I != E; ++I)
RewriteProperty(*I);
- for (ObjCInterfaceDecl::instmeth_iterator
+ for (ObjCInterfaceDecl::instmeth_iterator
I = ClassDecl->instmeth_begin(), E = ClassDecl->instmeth_end();
I != E; ++I)
RewriteMethodDeclaration(*I);
- for (ObjCInterfaceDecl::classmeth_iterator
- I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
+ for (ObjCInterfaceDecl::classmeth_iterator
+ I = ClassDecl->classmeth_begin(), E = ClassDecl->classmeth_end();
I != E; ++I)
RewriteMethodDeclaration(*I);
@@ -1069,20 +1068,20 @@ Stmt *RewriteObjC::RewritePropertySetter(BinaryOperator *BinOp, Expr *newStmt,
ObjCPropertyDecl *PDecl = PropRefExpr->getProperty();
llvm::SmallVector<Expr *, 1> ExprVec;
ExprVec.push_back(newStmt);
-
+
Stmt *Receiver = PropRefExpr->getBase();
ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(Receiver);
if (PRE && PropGetters[PRE]) {
// This allows us to handle chain/nested property getters.
Receiver = PropGetters[PRE];
}
- MsgExpr = new (Context) ObjCMessageExpr(dyn_cast<Expr>(Receiver),
- PDecl->getSetterName(), PDecl->getType(),
- PDecl->getSetterMethodDecl(),
- SourceLocation(), SourceLocation(),
+ MsgExpr = new (Context) ObjCMessageExpr(dyn_cast<Expr>(Receiver),
+ PDecl->getSetterName(), PDecl->getType(),
+ PDecl->getSetterMethodDecl(),
+ SourceLocation(), SourceLocation(),
&ExprVec[0], 1);
Stmt *ReplacingStmt = SynthMessageExpr(MsgExpr);
-
+
// Now do the actual rewrite.
ReplaceStmtWithRange(BinOp, ReplacingStmt, SrcRange);
//delete BinOp;
@@ -1097,18 +1096,18 @@ Stmt *RewriteObjC::RewritePropertyGetter(ObjCPropertyRefExpr *PropRefExpr) {
// This allows us to reuse all the fun and games in SynthMessageExpr().
ObjCMessageExpr *MsgExpr;
ObjCPropertyDecl *PDecl = PropRefExpr->getProperty();
-
+
Stmt *Receiver = PropRefExpr->getBase();
-
+
ObjCPropertyRefExpr *PRE = dyn_cast<ObjCPropertyRefExpr>(Receiver);
if (PRE && PropGetters[PRE]) {
// This allows us to handle chain/nested property getters.
Receiver = PropGetters[PRE];
}
- MsgExpr = new (Context) ObjCMessageExpr(dyn_cast<Expr>(Receiver),
- PDecl->getGetterName(), PDecl->getType(),
- PDecl->getGetterMethodDecl(),
- SourceLocation(), SourceLocation(),
+ MsgExpr = new (Context) ObjCMessageExpr(dyn_cast<Expr>(Receiver),
+ PDecl->getGetterName(), PDecl->getType(),
+ PDecl->getGetterMethodDecl(),
+ SourceLocation(), SourceLocation(),
0, 0);
Stmt *ReplacingStmt = SynthMessageExpr(MsgExpr);
@@ -1127,7 +1126,7 @@ Stmt *RewriteObjC::RewritePropertyGetter(ObjCPropertyRefExpr *PropRefExpr) {
return PropRefExpr; // return the original...
} else {
ReplaceStmt(PropRefExpr, ReplacingStmt);
- // delete PropRefExpr; elsewhere...
+ // delete PropRefExpr; elsewhere...
// NOTE: We don't want to call MsgExpr->Destroy(), as it holds references
// to things that stay around.
Context->Deallocate(MsgExpr);
@@ -1135,7 +1134,7 @@ Stmt *RewriteObjC::RewritePropertyGetter(ObjCPropertyRefExpr *PropRefExpr) {
}
}
-Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
+Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation OrigStart) {
ObjCIvarDecl *D = IV->getDecl();
if (CurMethodDef) {
@@ -1144,10 +1143,10 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
// lookup which class implements the instance variable.
ObjCInterfaceDecl *clsDeclared = 0;
- iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
+ iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
clsDeclared);
assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
-
+
// Synthesize an explicit cast to gain access to the ivar.
std::string RecName = clsDeclared->getIdentifier()->getName();
RecName += "_IMPL";
@@ -1156,7 +1155,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
- CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
+ CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
CastExpr::CK_Unknown,
IV->getBase(),
castT,SourceLocation(),
@@ -1165,7 +1164,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
IV->getBase()->getLocEnd(),
castExpr);
- if (IV->isFreeIvar() &&
+ if (IV->isFreeIvar() &&
CurMethodDef->getClassInterface() == iFaceDecl->getDecl()) {
MemberExpr *ME = new (Context) MemberExpr(PE, true, D,
IV->getLocation(),
@@ -1174,27 +1173,27 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
// delete IV; leak for now, see RewritePropertySetter() usage for more info.
return ME;
}
-
+
ReplaceStmt(IV->getBase(), PE);
// Cannot delete IV->getBase(), since PE points to it.
// Replace the old base with the cast. This is important when doing
// embedded rewrites. For example, [newInv->_container addObject:0].
- IV->setBase(PE);
+ IV->setBase(PE);
return IV;
}
} else { // we are outside a method.
assert(!IV->isFreeIvar() && "Cannot have a free standing ivar outside a method");
-
+
// Explicit ivar refs need to have a cast inserted.
// FIXME: consider sharing some of this code with the code above.
if (const PointerType *pType = IV->getBase()->getType()->getAs<PointerType>()) {
ObjCInterfaceType *iFaceDecl = dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
// lookup which class implements the instance variable.
ObjCInterfaceDecl *clsDeclared = 0;
- iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
+ iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
clsDeclared);
assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
-
+
// Synthesize an explicit cast to gain access to the ivar.
std::string RecName = clsDeclared->getIdentifier()->getName();
RecName += "_IMPL";
@@ -1203,7 +1202,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
- CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
+ CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
CastExpr::CK_Unknown,
IV->getBase(),
castT, SourceLocation(),
@@ -1215,7 +1214,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
// Cannot delete IV->getBase(), since PE points to it.
// Replace the old base with the cast. This is important when doing
// embedded rewrites. For example, [newInv->_container addObject:0].
- IV->setBase(PE);
+ IV->setBase(PE);
return IV;
}
}
@@ -1225,10 +1224,10 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
/// SynthCountByEnumWithState - To print:
/// ((unsigned int (*)
/// (id, SEL, struct __objcFastEnumerationState *, id *, unsigned int))
-/// (void *)objc_msgSend)((id)l_collection,
+/// (void *)objc_msgSend)((id)l_collection,
/// sel_registerName(
-/// "countByEnumeratingWithState:objects:count:"),
-/// &enumState,
+/// "countByEnumeratingWithState:objects:count:"),
+/// &enumState,
/// (id *)items, (unsigned int)16)
///
void RewriteObjC::SynthCountByEnumWithState(std::string &buf) {
@@ -1250,7 +1249,7 @@ Stmt *RewriteObjC::RewriteBreakStmt(BreakStmt *S) {
return S;
// replace break with goto __break_label
std::string buf;
-
+
SourceLocation startLoc = S->getLocStart();
buf = "goto __break_label_";
buf += utostr(ObjCBcLabelNo.back());
@@ -1267,39 +1266,39 @@ Stmt *RewriteObjC::RewriteContinueStmt(ContinueStmt *S) {
return S;
// replace continue with goto __continue_label
std::string buf;
-
+
SourceLocation startLoc = S->getLocStart();
buf = "goto __continue_label_";
buf += utostr(ObjCBcLabelNo.back());
ReplaceText(startLoc, strlen("continue"), buf.c_str(), buf.size());
-
+
return 0;
}
/// RewriteObjCForCollectionStmt - Rewriter for ObjC2's foreach statement.
/// It rewrites:
/// for ( type elem in collection) { stmts; }
-
+
/// Into:
/// {
-/// type elem;
+/// type elem;
/// struct __objcFastEnumerationState enumState = { 0 };
/// id items[16];
/// id l_collection = (id)collection;
-/// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState
+/// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:items count:16];
/// if (limit) {
/// unsigned long startMutations = *enumState.mutationsPtr;
/// do {
/// unsigned long counter = 0;
/// do {
-/// if (startMutations != *enumState.mutationsPtr)
+/// if (startMutations != *enumState.mutationsPtr)
/// objc_enumerationMutation(l_collection);
/// elem = (type)enumState.itemsPtr[counter++];
/// stmts;
/// __continue_label: ;
/// } while (counter < limit);
-/// } while (limit = [l_collection countByEnumeratingWithState:&enumState
+/// } while (limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:items count:16]);
/// elem = nil;
/// __break_label: ;
@@ -1311,11 +1310,11 @@ Stmt *RewriteObjC::RewriteContinueStmt(ContinueStmt *S) {
Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
SourceLocation OrigEnd) {
assert(!Stmts.empty() && "ObjCForCollectionStmt - Statement stack empty");
- assert(isa<ObjCForCollectionStmt>(Stmts.back()) &&
+ assert(isa<ObjCForCollectionStmt>(Stmts.back()) &&
"ObjCForCollectionStmt Statement stack mismatch");
- assert(!ObjCBcLabelNo.empty() &&
+ assert(!ObjCBcLabelNo.empty() &&
"ObjCForCollectionStmt - Label No stack empty");
-
+
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
const char *elementName;
@@ -1336,10 +1335,10 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
else {
DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
elementName = DR->getDecl()->getNameAsCString();
- elementTypeAsString
+ elementTypeAsString
= cast<ValueDecl>(DR->getDecl())->getType().getAsString();
}
-
+
// struct __objcFastEnumerationState enumState = { 0 };
buf += "struct __objcFastEnumerationState enumState = { 0 };\n\t";
// id items[16];
@@ -1358,8 +1357,8 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
*(startCollectionBuf+3) != '[' && *(startCollectionBuf+3) != '('))
startCollectionBuf++;
startCollectionBuf += 3;
-
- // Replace: "for (type element in" with string constructed thus far.
+
+ // Replace: "for (type element in" with string constructed thus far.
ReplaceText(startLoc, startCollectionBuf - startBuf,
buf.c_str(), buf.size());
// Replace ')' in for '(' type elem in collection ')' with ';'
@@ -1367,17 +1366,17 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
const char *rparenBuf = SM->getCharacterData(rightParenLoc);
SourceLocation lparenLoc = startLoc.getFileLocWithOffset(rparenBuf-startBuf);
buf = ";\n\t";
-
+
// unsigned long limit = [l_collection countByEnumeratingWithState:&enumState
// objects:items count:16];
// which is synthesized into:
- // unsigned int limit =
+ // unsigned int limit =
// ((unsigned int (*)
// (id, SEL, struct __objcFastEnumerationState *, id *, unsigned int))
- // (void *)objc_msgSend)((id)l_collection,
+ // (void *)objc_msgSend)((id)l_collection,
// sel_registerName(
- // "countByEnumeratingWithState:objects:count:"),
- // (struct __objcFastEnumerationState *)&state,
+ // "countByEnumeratingWithState:objects:count:"),
+ // (struct __objcFastEnumerationState *)&state,
// (id *)items, (unsigned int)16);
buf += "unsigned long limit =\n\t\t";
SynthCountByEnumWithState(buf);
@@ -1387,7 +1386,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
/// do {
/// unsigned long counter = 0;
/// do {
- /// if (startMutations != *enumState.mutationsPtr)
+ /// if (startMutations != *enumState.mutationsPtr)
/// objc_enumerationMutation(l_collection);
/// elem = (type)enumState.itemsPtr[counter++];
buf += "if (limit) {\n\t";
@@ -1403,10 +1402,10 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
buf += ")enumState.itemsPtr[counter++];";
// Replace ')' in for '(' type elem in collection ')' with all of these.
ReplaceText(lparenLoc, 1, buf.c_str(), buf.size());
-
+
/// __continue_label: ;
/// } while (counter < limit);
- /// } while (limit = [l_collection countByEnumeratingWithState:&enumState
+ /// } while (limit = [l_collection countByEnumeratingWithState:&enumState
/// objects:items count:16]);
/// elem = nil;
/// __break_label: ;
@@ -1414,7 +1413,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
/// else
/// elem = nil;
/// }
- ///
+ ///
buf = ";\n\t";
buf += "__continue_label_";
buf += utostr(ObjCBcLabelNo.back());
@@ -1434,7 +1433,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
buf += elementName;
buf += " = ((id)0);\n";
buf += "}\n";
-
+
// Insert all these *after* the statement body.
// FIXME: If this should support Obj-C++, support CXXTryStmt
if (isa<CompoundStmt>(S->getBody())) {
@@ -1459,7 +1458,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
return 0;
}
-/// RewriteObjCSynchronizedStmt -
+/// RewriteObjCSynchronizedStmt -
/// This routine rewrites @synchronized(expr) stmt;
/// into:
/// objc_sync_enter(expr);
@@ -1469,16 +1468,16 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
-
+
assert((*startBuf == '@') && "bogus @synchronized location");
-
- std::string buf;
+
+ std::string buf;
buf = "objc_sync_enter((id)";
const char *lparenBuf = startBuf;
while (*lparenBuf != '(') lparenBuf++;
ReplaceText(startLoc, lparenBuf-startBuf+1, buf.c_str(), buf.size());
- // We can't use S->getSynchExpr()->getLocEnd() to find the end location, since
- // the sync expression is typically a message expression that's already
+ // We can't use S->getSynchExpr()->getLocEnd() to find the end location, since
+ // the sync expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
SourceLocation endLoc = S->getSynchBody()->getLocStart();
const char *endBuf = SM->getCharacterData(endLoc);
@@ -1495,7 +1494,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
ReplaceText(rparenLoc, 1, buf.c_str(), buf.size());
startLoc = S->getSynchBody()->getLocEnd();
startBuf = SM->getCharacterData(startLoc);
-
+
assert((*startBuf == '}') && "bogus @synchronized block");
SourceLocation lastCurlyLoc = startLoc;
buf = "}\nelse {\n";
@@ -1504,9 +1503,9 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
buf += "{ /* implicit finally clause */\n";
buf += " if (!_rethrow) objc_exception_try_exit(&_stack);\n";
buf += " objc_sync_exit(";
- Expr *syncExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ Expr *syncExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
- S->getSynchExpr(),
+ S->getSynchExpr(),
Context->getObjCIdType(),
SourceLocation(),
SourceLocation());
@@ -1519,21 +1518,21 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
buf += " if (_rethrow) objc_exception_throw(_rethrow);\n";
buf += "}\n";
buf += "}";
-
+
ReplaceText(lastCurlyLoc, 1, buf.c_str(), buf.size());
return 0;
}
-void RewriteObjC::WarnAboutReturnGotoContinueOrBreakStmts(Stmt *S) {
+void RewriteObjC::WarnAboutReturnGotoContinueOrBreakStmts(Stmt *S) {
// Perform a bottom up traversal of all children.
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
if (*CI)
WarnAboutReturnGotoContinueOrBreakStmts(*CI);
- if (isa<ReturnStmt>(S) || isa<ContinueStmt>(S) ||
+ if (isa<ReturnStmt>(S) || isa<ContinueStmt>(S) ||
isa<BreakStmt>(S) || isa<GotoStmt>(S)) {
- Diags.Report(Context->getFullLoc(S->getLocStart()),
+ Diags.Report(Context->getFullLoc(S->getLocStart()),
TryFinallyContainsReturnDiag);
}
return;
@@ -1543,7 +1542,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
-
+
assert((*startBuf == '@') && "bogus @try location");
std::string buf;
@@ -1556,12 +1555,12 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
buf += "if (!_setjmp(_stack.buf)) /* @try block continue */\n";
ReplaceText(startLoc, 4, buf.c_str(), buf.size());
-
+
startLoc = S->getTryBody()->getLocEnd();
startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '}') && "bogus @try block");
-
+
SourceLocation lastCurlyLoc = startLoc;
ObjCAtCatchStmt *catchList = S->getCatchStmts();
if (catchList) {
@@ -1572,7 +1571,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
buf += " if (_setjmp(_stack.buf))\n";
buf += " _rethrow = objc_exception_extract(&_stack);\n";
buf += " else { /* @catch continue */";
-
+
InsertText(startLoc, buf.c_str(), buf.size());
} else { /* no catch list */
buf = "}\nelse {\n";
@@ -1585,15 +1584,15 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
while (catchList) {
ParmVarDecl *catchDecl = catchList->getCatchParamDecl();
- if (catchList == S->getCatchStmts())
+ if (catchList == S->getCatchStmts())
buf = "if ("; // we are generating code for the first catch clause
else
buf = "else if (";
startLoc = catchList->getLocStart();
startBuf = SM->getCharacterData(startLoc);
-
+
assert((*startBuf == '@') && "bogus @catch location");
-
+
const char *lParenLoc = strchr(startBuf, '(');
if (catchList->hasEllipsis()) {
@@ -1604,7 +1603,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
assert(*SM->getCharacterData(catchList->getRParenLoc()) == ')' &&
"bogus @catch paren location");
assert((*bodyBuf == '{') && "bogus @catch body location");
-
+
buf += "1) { id _tmp = _caught;";
Rewrite.ReplaceText(startLoc, bodyBuf-startBuf+1, buf);
} else if (catchDecl) {
@@ -1613,9 +1612,9 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
buf += "1) { ";
ReplaceText(startLoc, lParenLoc-startBuf+1, buf.c_str(), buf.size());
sawIdTypedCatch = true;
- } else if (const PointerType *pType = t->getAs<PointerType>()) {
+ } else if (const PointerType *pType = t->getAs<PointerType>()) {
ObjCInterfaceType *cls; // Should be a pointer to a class.
-
+
cls = dyn_cast<ObjCInterfaceType>(pType->getPointeeType().getTypePtr());
if (cls) {
buf += "objc_exception_match((struct objc_class *)objc_getClass(\"";
@@ -1632,9 +1631,9 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
const char *rParenBuf = SM->getCharacterData(rParenLoc);
assert((*rParenBuf == ')') && "bogus @catch paren location");
assert((*bodyBuf == '{') && "bogus @catch body location");
-
+
buf = " = _caught;";
- // Here we replace ") {" with "= _caught;" (which initializes and
+ // Here we replace ") {" with "= _caught;" (which initializes and
// declares the @catch parameter).
ReplaceText(rParenLoc, bodyBuf-rParenBuf+1, buf.c_str(), buf.size());
} else {
@@ -1648,7 +1647,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
SourceLocation bodyLoc = lastCatchBody->getLocEnd();
assert(*SM->getCharacterData(bodyLoc) == '}' &&
"bogus @catch body location");
-
+
// Insert the last (implicit) else clause *before* the right curly brace.
bodyLoc = bodyLoc.getFileLocWithOffset(-1);
buf = "} /* last catch end */\n";
@@ -1659,7 +1658,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
if (!S->getFinallyStmt())
buf += "}\n";
InsertText(bodyLoc, buf.c_str(), buf.size());
-
+
// Set lastCurlyLoc
lastCurlyLoc = lastCatchBody->getLocEnd();
}
@@ -1667,28 +1666,28 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
startLoc = finalStmt->getLocStart();
startBuf = SM->getCharacterData(startLoc);
assert((*startBuf == '@') && "bogus @finally start");
-
+
buf = "/* @finally */";
ReplaceText(startLoc, 8, buf.c_str(), buf.size());
-
+
Stmt *body = finalStmt->getFinallyBody();
SourceLocation startLoc = body->getLocStart();
SourceLocation endLoc = body->getLocEnd();
assert(*SM->getCharacterData(startLoc) == '{' &&
"bogus @finally body location");
- assert(*SM->getCharacterData(endLoc) == '}' &&
+ assert(*SM->getCharacterData(endLoc) == '}' &&
"bogus @finally body location");
-
+
startLoc = startLoc.getFileLocWithOffset(1);
buf = " if (!_rethrow) objc_exception_try_exit(&_stack);\n";
InsertText(startLoc, buf.c_str(), buf.size());
endLoc = endLoc.getFileLocWithOffset(-1);
buf = " if (_rethrow) objc_exception_throw(_rethrow);\n";
InsertText(endLoc, buf.c_str(), buf.size());
-
+
// Set lastCurlyLoc
lastCurlyLoc = body->getLocEnd();
-
+
// Now check for any return/continue/go statements within the @try.
WarnAboutReturnGotoContinueOrBreakStmts(S->getTryBody());
} else { /* no finally clause - make sure we synthesize an implicit one */
@@ -1713,14 +1712,14 @@ Stmt *RewriteObjC::RewriteObjCFinallyStmt(ObjCAtFinallyStmt *S) {
return 0;
}
-// This can't be done with ReplaceStmt(S, ThrowExpr), since
-// the throw expression is typically a message expression that's already
+// This can't be done with ReplaceStmt(S, ThrowExpr), since
+// the throw expression is typically a message expression that's already
// been rewritten! (which implies the SourceLocation's are invalid).
Stmt *RewriteObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();
const char *startBuf = SM->getCharacterData(startLoc);
-
+
assert((*startBuf == '@') && "bogus @throw location");
std::string buf;
@@ -1729,12 +1728,12 @@ Stmt *RewriteObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) {
buf = "objc_exception_throw(";
else // add an implicit argument
buf = "objc_exception_throw(_caught";
-
+
// handle "@ throw" correctly.
const char *wBuf = strchr(startBuf, 'w');
assert((*wBuf == 'w') && "@throw: can't find 'w'");
ReplaceText(startLoc, wBuf-startBuf+1, buf.c_str(), buf.size());
-
+
const char *semiBuf = strchr(startBuf, ';');
assert((*semiBuf == ';') && "@throw: can't find ';'");
SourceLocation semiLoc = startLoc.getFileLocWithOffset(semiBuf-startBuf);
@@ -1752,7 +1751,7 @@ Stmt *RewriteObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) {
StrEncoding.length(), false,StrType,
SourceLocation());
ReplaceStmt(Exp, Replacement);
-
+
// Replace this subexpr in the parent.
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return Replacement;
@@ -1765,7 +1764,7 @@ Stmt *RewriteObjC::RewriteAtSelector(ObjCSelectorExpr *Exp) {
// Create a call to sel_registerName("selName").
llvm::SmallVector<Expr*, 8> SelExprs;
QualType argType = Context->getPointerType(Context->CharTy);
- SelExprs.push_back(StringLiteral::Create(*Context,
+ SelExprs.push_back(StringLiteral::Create(*Context,
Exp->getSelector().getAsString().c_str(),
Exp->getSelector().getAsString().size(),
false, argType, SourceLocation()));
@@ -1780,19 +1779,19 @@ CallExpr *RewriteObjC::SynthesizeCallToFunctionDecl(
FunctionDecl *FD, Expr **args, unsigned nargs) {
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = FD->getType();
-
+
// Create a reference to the objc_msgSend() declaration.
DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, msgSendType, SourceLocation());
-
+
// Now, we cast the reference to a pointer to the objc_msgSend type.
QualType pToFunc = Context->getPointerType(msgSendType);
- ImplicitCastExpr *ICE = new (Context) ImplicitCastExpr(pToFunc,
+ ImplicitCastExpr *ICE = new (Context) ImplicitCastExpr(pToFunc,
CastExpr::CK_Unknown,
- DRE,
+ DRE,
/*isLvalue=*/false);
-
+
const FunctionType *FT = msgSendType->getAsFunctionType();
-
+
return new (Context) CallExpr(*Context, ICE, args, nargs, FT->getResultType(),
SourceLocation());
}
@@ -1834,7 +1833,7 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
QualType Type = E->getType();
if (needToScanForQualifiers(Type)) {
SourceLocation Loc, EndLoc;
-
+
if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E)) {
Loc = ECE->getLParenLoc();
EndLoc = ECE->getRParenLoc();
@@ -1881,10 +1880,10 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
}
else
return;
-
+
if (needToScanForQualifiers(Type)) {
// Since types are unique, we need to scan the buffer.
-
+
const char *endBuf = SM->getCharacterData(Loc);
const char *startBuf = endBuf;
while (*startBuf != ';' && *startBuf != '<' && startBuf != MainFileStart)
@@ -1907,16 +1906,16 @@ void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) {
for (unsigned i = 0; i < proto->getNumArgs(); i++) {
if (needToScanForQualifiers(proto->getArgType(i))) {
// Since types are unique, we need to scan the buffer.
-
+
const char *endBuf = startBuf;
// scan forward (from the decl location) for argument types.
scanToNextArgument(endBuf);
const char *startRef = 0, *endRef = 0;
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
// Get the locations of the startRef, endRef.
- SourceLocation LessLoc =
+ SourceLocation LessLoc =
Loc.getFileLocWithOffset(startRef-startFuncBuf);
- SourceLocation GreaterLoc =
+ SourceLocation GreaterLoc =
Loc.getFileLocWithOffset(endRef-startFuncBuf+1);
// Comment out the protocol references.
InsertText(LessLoc, "/*", 2);
@@ -1944,7 +1943,7 @@ void RewriteObjC::SynthSelGetUidFunctionDecl() {
&ArgTys[0], ArgTys.size(),
false /*isVariadic*/, 0);
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
SelGetUidIdent, getFuncType, 0,
FunctionDecl::Extern, false);
}
@@ -1973,7 +1972,7 @@ void RewriteObjC::SynthSuperContructorFunctionDecl() {
&ArgTys[0], ArgTys.size(),
false, 0);
SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
msgSendIdent, msgSendType, 0,
FunctionDecl::Extern, false);
}
@@ -2014,7 +2013,7 @@ void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
&ArgTys[0], ArgTys.size(),
true /*isVariadic*/, 0);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
msgSendIdent, msgSendType, 0,
FunctionDecl::Extern, false);
}
@@ -2033,15 +2032,15 @@ void RewriteObjC::SynthMsgSendStretFunctionDecl() {
&ArgTys[0], ArgTys.size(),
true /*isVariadic*/, 0);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
msgSendIdent, msgSendType, 0,
FunctionDecl::Extern, false);
}
-// SynthMsgSendSuperStretFunctionDecl -
+// SynthMsgSendSuperStretFunctionDecl -
// id objc_msgSendSuper_stret(struct objc_super *, SEL op, ...);
void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
- IdentifierInfo *msgSendIdent =
+ IdentifierInfo *msgSendIdent =
&Context->Idents.get("objc_msgSendSuper_stret");
llvm::SmallVector<QualType, 16> ArgTys;
RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
@@ -2057,7 +2056,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
&ArgTys[0], ArgTys.size(),
true /*isVariadic*/, 0);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
msgSendIdent, msgSendType, 0,
FunctionDecl::Extern, false);
}
@@ -2076,7 +2075,7 @@ void RewriteObjC::SynthMsgSendFpretFunctionDecl() {
&ArgTys[0], ArgTys.size(),
true /*isVariadic*/, 0);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
msgSendIdent, msgSendType, 0,
FunctionDecl::Extern, false);
}
@@ -2091,7 +2090,7 @@ void RewriteObjC::SynthGetClassFunctionDecl() {
&ArgTys[0], ArgTys.size(),
false /*isVariadic*/, 0);
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
getClassIdent, getClassType, 0,
FunctionDecl::Extern, false);
}
@@ -2106,7 +2105,7 @@ void RewriteObjC::SynthGetMetaClassFunctionDecl() {
&ArgTys[0], ArgTys.size(),
false /*isVariadic*/, 0);
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
getClassIdent, getClassType, 0,
FunctionDecl::Extern, false);
}
@@ -2140,19 +2139,19 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
Preamble += ",";
// The minus 2 removes the begin/end double quotes.
Preamble += utostr(prettyBuf.str().size()-2) + "};\n";
-
- VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
- &Context->Idents.get(S.c_str()), strType, 0,
+
+ VarDecl *NewVD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
+ &Context->Idents.get(S.c_str()), strType, 0,
VarDecl::Static);
DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, strType, SourceLocation());
Expr *Unop = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf,
- Context->getPointerType(DRE->getType()),
+ Context->getPointerType(DRE->getType()),
SourceLocation());
// cast to NSConstantString *
- CastExpr *cast = new (Context) CStyleCastExpr(Exp->getType(),
+ CastExpr *cast = new (Context) CStyleCastExpr(Exp->getType(),
CastExpr::CK_Unknown,
- Unop, Exp->getType(),
- SourceLocation(),
+ Unop, Exp->getType(),
+ SourceLocation(),
SourceLocation());
ReplaceStmt(Exp, cast);
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
@@ -2162,9 +2161,9 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) {
// check if we are sending a message to 'super'
if (!CurMethodDef || !CurMethodDef->isInstanceMethod()) return 0;
-
+
if (ObjCSuperExpr *Super = dyn_cast<ObjCSuperExpr>(recExpr)) {
- const ObjCObjectPointerType *OPT =
+ const ObjCObjectPointerType *OPT =
Super->getType()->getAsObjCObjectPointerType();
assert(OPT);
const ObjCInterfaceType *IT = OPT->getInterfaceType();
@@ -2177,24 +2176,24 @@ ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) {
QualType RewriteObjC::getSuperStructType() {
if (!SuperStructDecl) {
SuperStructDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
- SourceLocation(),
+ SourceLocation(),
&Context->Idents.get("objc_super"));
QualType FieldTypes[2];
-
+
// struct objc_object *receiver;
- FieldTypes[0] = Context->getObjCIdType();
+ FieldTypes[0] = Context->getObjCIdType();
// struct objc_class *super;
- FieldTypes[1] = Context->getObjCClassType();
+ FieldTypes[1] = Context->getObjCClassType();
// Create fields
for (unsigned i = 0; i < 2; ++i) {
- SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl,
- SourceLocation(), 0,
+ SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl,
+ SourceLocation(), 0,
FieldTypes[i], 0,
/*BitWidth=*/0,
/*Mutable=*/false));
}
-
+
SuperStructDecl->completeDefinition(*Context);
}
return Context->getTagDeclType(SuperStructDecl);
@@ -2203,23 +2202,23 @@ QualType RewriteObjC::getSuperStructType() {
QualType RewriteObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
ConstantStringDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
- SourceLocation(),
+ SourceLocation(),
&Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];
-
+
// struct objc_object *receiver;
- FieldTypes[0] = Context->getObjCIdType();
+ FieldTypes[0] = Context->getObjCIdType();
// int flags;
- FieldTypes[1] = Context->IntTy;
+ FieldTypes[1] = Context->IntTy;
// char *str;
- FieldTypes[2] = Context->getPointerType(Context->CharTy);
+ FieldTypes[2] = Context->getPointerType(Context->CharTy);
// long length;
- FieldTypes[3] = Context->LongTy;
+ FieldTypes[3] = Context->LongTy;
// Create fields
for (unsigned i = 0; i < 4; ++i) {
- ConstantStringDecl->addDecl(FieldDecl::Create(*Context,
- ConstantStringDecl,
+ ConstantStringDecl->addDecl(FieldDecl::Create(*Context,
+ ConstantStringDecl,
SourceLocation(), 0,
FieldTypes[i], 0,
/*BitWidth=*/0,
@@ -2248,7 +2247,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
SynthGetClassFunctionDecl();
if (!GetMetaClassFunctionDecl)
SynthGetMetaClassFunctionDecl();
-
+
// default to objc_msgSend().
FunctionDecl *MsgSendFlavor = MsgSendFunctionDecl;
// May need to use objc_msgSend_stret() as well.
@@ -2260,11 +2259,11 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
else if (resultType->isRealFloatingType())
MsgSendFlavor = MsgSendFpretFunctionDecl;
}
-
+
// Synthesize a call to objc_msgSend().
llvm::SmallVector<Expr*, 8> MsgExprs;
IdentifierInfo *clsName = Exp->getClassName();
-
+
// Derive/push the receiver/selector, 2 implicit arguments to objc_msgSend().
if (clsName) { // class message.
// FIXME: We need to fix Sema (and the AST for ObjCMessageExpr) to handle
@@ -2274,17 +2273,17 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
if (MsgSendStretFlavor)
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;
assert(MsgSendFlavor && "MsgSendFlavor is NULL!");
-
- ObjCInterfaceDecl *SuperDecl =
+
+ ObjCInterfaceDecl *SuperDecl =
CurMethodDef->getClassInterface()->getSuperClass();
llvm::SmallVector<Expr*, 4> InitExprs;
-
+
// set the receiver to self, the first argument to all methods.
InitExprs.push_back(
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
- new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
+ new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
SourceLocation()),
Context->getObjCIdType(),
@@ -2293,29 +2292,29 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy);
ClsExprs.push_back(StringLiteral::Create(*Context,
- SuperDecl->getIdentifier()->getName(),
+ SuperDecl->getIdentifier()->getName(),
SuperDecl->getIdentifier()->getLength(),
false, argType, SourceLocation()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl,
- &ClsExprs[0],
+ &ClsExprs[0],
ClsExprs.size());
// To turn off a warning, type-cast to 'id'
InitExprs.push_back( // set 'super class', using objc_getClass().
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
Cls, Context->getObjCIdType(),
- SourceLocation(), SourceLocation()));
+ SourceLocation(), SourceLocation()));
// struct objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
-
+
if (LangOpts.Microsoft) {
SynthSuperContructorFunctionDecl();
// Simulate a contructor call...
- DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
+ DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
superType, SourceLocation());
SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
- InitExprs.size(),
+ InitExprs.size(),
superType, SourceLocation());
// The code for super is a little tricky to prevent collision with
// the structure definition in the header. The rewriter has it's own
@@ -2324,22 +2323,22 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
//
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
- Context->getPointerType(SuperRep->getType()),
+ Context->getPointerType(SuperRep->getType()),
SourceLocation());
- SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
- CastExpr::CK_Unknown, SuperRep,
+ SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
+ CastExpr::CK_Unknown, SuperRep,
Context->getPointerType(superType),
- SourceLocation(), SourceLocation());
- } else {
+ SourceLocation(), SourceLocation());
+ } else {
// (struct objc_super) { <exprs from above> }
- InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
- &InitExprs[0], InitExprs.size(),
+ InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
+ &InitExprs[0], InitExprs.size(),
SourceLocation());
SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE,
false);
// struct objc_super *
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
- Context->getPointerType(SuperRep->getType()),
+ Context->getPointerType(SuperRep->getType()),
SourceLocation());
}
MsgExprs.push_back(SuperRep);
@@ -2347,12 +2346,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy);
ClsExprs.push_back(StringLiteral::Create(*Context,
- clsName->getName(),
+ clsName->getName(),
clsName->getLength(),
false, argType,
SourceLocation()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
- &ClsExprs[0],
+ &ClsExprs[0],
ClsExprs.size());
MsgExprs.push_back(Cls);
}
@@ -2364,44 +2363,44 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
if (MsgSendStretFlavor)
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;
assert(MsgSendFlavor && "MsgSendFlavor is NULL!");
-
+
llvm::SmallVector<Expr*, 4> InitExprs;
-
+
InitExprs.push_back(
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
- new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
+ new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
SourceLocation()),
Context->getObjCIdType(),
SourceLocation(), SourceLocation())); // set the 'receiver'.
-
+
llvm::SmallVector<Expr*, 8> ClsExprs;
QualType argType = Context->getPointerType(Context->CharTy);
- ClsExprs.push_back(StringLiteral::Create(*Context,
- SuperDecl->getIdentifier()->getName(),
+ ClsExprs.push_back(StringLiteral::Create(*Context,
+ SuperDecl->getIdentifier()->getName(),
SuperDecl->getIdentifier()->getLength(),
false, argType, SourceLocation()));
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
- &ClsExprs[0],
+ &ClsExprs[0],
ClsExprs.size());
// To turn off a warning, type-cast to 'id'
InitExprs.push_back(
// set 'super class', using objc_getClass().
- new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
- Cls, Context->getObjCIdType(), SourceLocation(), SourceLocation()));
+ Cls, Context->getObjCIdType(), SourceLocation(), SourceLocation()));
// struct objc_super
QualType superType = getSuperStructType();
Expr *SuperRep;
-
+
if (LangOpts.Microsoft) {
SynthSuperContructorFunctionDecl();
// Simulate a contructor call...
- DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
+ DeclRefExpr *DRE = new (Context) DeclRefExpr(SuperContructorFunctionDecl,
superType, SourceLocation());
SuperRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0],
- InitExprs.size(),
+ InitExprs.size(),
superType, SourceLocation());
// The code for super is a little tricky to prevent collision with
// the structure definition in the header. The rewriter has it's own
@@ -2410,16 +2409,16 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER"))
//
SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
- Context->getPointerType(SuperRep->getType()),
+ Context->getPointerType(SuperRep->getType()),
SourceLocation());
- SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
+ SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
CastExpr::CK_Unknown,
SuperRep, Context->getPointerType(superType),
- SourceLocation(), SourceLocation());
+ SourceLocation(), SourceLocation());
} else {
// (struct objc_super) { <exprs from above> }
- InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
- &InitExprs[0], InitExprs.size(),
+ InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
+ &InitExprs[0], InitExprs.size(),
SourceLocation());
SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE, false);
}
@@ -2429,9 +2428,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// Foo<Proto> *.
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
recExpr = CE->getSubExpr();
- recExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ recExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown, recExpr,
- Context->getObjCIdType(),
+ Context->getObjCIdType(),
SourceLocation(), SourceLocation());
MsgExprs.push_back(recExpr);
}
@@ -2439,14 +2438,14 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// Create a call to sel_registerName("selName"), it will be the 2nd argument.
llvm::SmallVector<Expr*, 8> SelExprs;
QualType argType = Context->getPointerType(Context->CharTy);
- SelExprs.push_back(StringLiteral::Create(*Context,
+ SelExprs.push_back(StringLiteral::Create(*Context,
Exp->getSelector().getAsString().c_str(),
Exp->getSelector().getAsString().size(),
false, argType, SourceLocation()));
CallExpr *SelExp = SynthesizeCallToFunctionDecl(SelGetUidFunctionDecl,
&SelExprs[0], SelExprs.size());
MsgExprs.push_back(SelExp);
-
+
// Now push any user supplied arguments.
for (unsigned i = 0; i < Exp->getNumArgs(); i++) {
Expr *userExpr = Exp->getArg(i);
@@ -2457,7 +2456,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
? Context->getObjCIdType()
: ICE->getType();
userExpr = new (Context) CStyleCastExpr(type, CastExpr::CK_Unknown,
- userExpr, type, SourceLocation(),
+ userExpr, type, SourceLocation(),
SourceLocation());
}
// Make id<P...> cast into an 'id' cast.
@@ -2465,12 +2464,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
if (CE->getType()->isObjCQualifiedIdType()) {
while ((CE = dyn_cast<CStyleCastExpr>(userExpr)))
userExpr = CE->getSubExpr();
- userExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
+ userExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
- userExpr, Context->getObjCIdType(),
+ userExpr, Context->getObjCIdType(),
SourceLocation(), SourceLocation());
}
- }
+ }
MsgExprs.push_back(userExpr);
// We've transferred the ownership to MsgExprs. For now, we *don't* null
// out the argument in the original expression (since we aren't deleting
@@ -2481,7 +2480,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
CastExpr *cast;
llvm::SmallVector<QualType, 8> ArgTypes;
QualType returnType;
-
+
// Push 'id' and 'SEL', the 2 implicit arguments.
if (MsgSendFlavor == MsgSendSuperFunctionDecl)
ArgTypes.push_back(Context->getPointerType(getSuperStructType()));
@@ -2493,7 +2492,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
for (ObjCMethodDecl::param_iterator PI = OMD->param_begin(),
E = OMD->param_end(); PI != E; ++PI) {
QualType t = (*PI)->getType()->isObjCQualifiedIdType()
- ? Context->getObjCIdType()
+ ? Context->getObjCIdType()
: (*PI)->getType();
// Make sure we convert "t (^)(...)" to "t (*)(...)".
if (isTopLevelBlockPointerType(t)) {
@@ -2509,36 +2508,36 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
}
// Get the type, we will need to reference it in a couple spots.
QualType msgSendType = MsgSendFlavor->getType();
-
+
// Create a reference to the objc_msgSend() declaration.
- DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
+ DeclRefExpr *DRE = new (Context) DeclRefExpr(MsgSendFlavor, msgSendType,
SourceLocation());
- // Need to cast objc_msgSend to "void *" (to workaround a GCC bandaid).
+ // Need to cast objc_msgSend to "void *" (to workaround a GCC bandaid).
// If we don't do this cast, we get the following bizarre warning/note:
// xx.m:13: warning: function called through a non-compatible type
// xx.m:13: note: if this code is reached, the program will abort
- cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
- CastExpr::CK_Unknown, DRE,
+ cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
+ CastExpr::CK_Unknown, DRE,
Context->getPointerType(Context->VoidTy),
SourceLocation(), SourceLocation());
-
+
// Now do the "normal" pointer to function cast.
- QualType castType = Context->getFunctionType(returnType,
+ QualType castType = Context->getFunctionType(returnType,
&ArgTypes[0], ArgTypes.size(),
// If we don't have a method decl, force a variadic cast.
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0);
castType = Context->getPointerType(castType);
- cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown, cast,
- castType, SourceLocation(),
+ cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown, cast,
+ castType, SourceLocation(),
SourceLocation());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
-
+
const FunctionType *FT = msgSendType->getAsFunctionType();
CallExpr *CE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
- MsgExprs.size(),
+ MsgExprs.size(),
FT->getResultType(), SourceLocation());
Stmt *ReplacingStmt = CE;
if (MsgSendStretFlavor) {
@@ -2546,33 +2545,33 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// call to objc_msgSend_stret and hang both varieties on a conditional
// expression which dictate which one to envoke depending on size of
// method's return type.
-
+
// Create a reference to the objc_msgSend_stret() declaration.
- DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
+ DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
SourceLocation());
// Need to cast objc_msgSend_stret to "void *" (see above comment).
- cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
- CastExpr::CK_Unknown, STDRE,
+ cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
+ CastExpr::CK_Unknown, STDRE,
Context->getPointerType(Context->VoidTy),
SourceLocation(), SourceLocation());
// Now do the "normal" pointer to function cast.
- castType = Context->getFunctionType(returnType,
+ castType = Context->getFunctionType(returnType,
&ArgTypes[0], ArgTypes.size(),
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0);
castType = Context->getPointerType(castType);
cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown,
cast, castType, SourceLocation(), SourceLocation());
-
+
// Don't forget the parens to enforce the proper binding.
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
-
+
FT = msgSendType->getAsFunctionType();
CallExpr *STCE = new (Context) CallExpr(*Context, PE, &MsgExprs[0],
- MsgExprs.size(),
+ MsgExprs.size(),
FT->getResultType(), SourceLocation());
-
+
// Build sizeof(returnType)
- SizeOfAlignOfExpr *sizeofExpr = new (Context) SizeOfAlignOfExpr(true,
+ SizeOfAlignOfExpr *sizeofExpr = new (Context) SizeOfAlignOfExpr(true,
returnType,
Context->getSizeType(),
SourceLocation(), SourceLocation());
@@ -2580,33 +2579,33 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// FIXME: Value of 8 is base on ppc32/x86 ABI for the most common cases.
// For X86 it is more complicated and some kind of target specific routine
// is needed to decide what to do.
- unsigned IntSize =
+ unsigned IntSize =
static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
- IntegerLiteral *limit = new (Context) IntegerLiteral(llvm::APInt(IntSize, 8),
+ IntegerLiteral *limit = new (Context) IntegerLiteral(llvm::APInt(IntSize, 8),
Context->IntTy,
SourceLocation());
- BinaryOperator *lessThanExpr = new (Context) BinaryOperator(sizeofExpr, limit,
- BinaryOperator::LE,
- Context->IntTy,
+ BinaryOperator *lessThanExpr = new (Context) BinaryOperator(sizeofExpr, limit,
+ BinaryOperator::LE,
+ Context->IntTy,
SourceLocation());
// (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...))
- ConditionalOperator *CondExpr =
+ ConditionalOperator *CondExpr =
new (Context) ConditionalOperator(lessThanExpr,
SourceLocation(), CE,
SourceLocation(), STCE, returnType);
ReplacingStmt = new (Context) ParenExpr(SourceLocation(), SourceLocation(), CondExpr);
}
- // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
+ // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return ReplacingStmt;
}
Stmt *RewriteObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
Stmt *ReplacingStmt = SynthMessageExpr(Exp);
-
+
// Now do the actual rewrite.
ReplaceStmt(Exp, ReplacingStmt);
-
- // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
+
+ // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return ReplacingStmt;
}
@@ -2614,7 +2613,7 @@ Stmt *RewriteObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) {
QualType RewriteObjC::getProtocolType() {
if (!ProtocolTypeDecl) {
ProtocolTypeDecl = TypedefDecl::Create(*Context, TUDecl,
- SourceLocation(),
+ SourceLocation(),
&Context->Idents.get("Protocol"),
Context->getObjCIdType());
}
@@ -2628,24 +2627,24 @@ QualType RewriteObjC::getProtocolType() {
Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
std::string Name = "_OBJC_PROTOCOL_" + Exp->getProtocol()->getNameAsString();
IdentifierInfo *ID = &Context->Idents.get(Name);
- VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
+ VarDecl *VD = VarDecl::Create(*Context, TUDecl, SourceLocation(),
ID, QualType()/*UNUSED*/, 0, VarDecl::Extern);
DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, getProtocolType(), SourceLocation());
Expr *DerefExpr = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf,
Context->getPointerType(DRE->getType()),
SourceLocation());
- CastExpr *castExpr = new (Context) CStyleCastExpr(DerefExpr->getType(),
- CastExpr::CK_Unknown,
- DerefExpr, DerefExpr->getType(),
+ CastExpr *castExpr = new (Context) CStyleCastExpr(DerefExpr->getType(),
+ CastExpr::CK_Unknown,
+ DerefExpr, DerefExpr->getType(),
SourceLocation(), SourceLocation());
ReplaceStmt(Exp, castExpr);
ProtocolExprDecls.insert(Exp->getProtocol());
- // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
+ // delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return castExpr;
-
+
}
-bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf,
+bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf,
const char *endBuf) {
while (startBuf < endBuf) {
if (*startBuf == '#') {
@@ -2676,7 +2675,7 @@ bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf,
void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result) {
assert(CDecl && "Class missing in SynthesizeObjCInternalStruct");
- assert(CDecl->getNameAsCString() &&
+ assert(CDecl->getNameAsCString() &&
"Name missing in SynthesizeObjCInternalStruct");
// Do not synthesize more than once.
if (ObjCSynthesizedStructs.count(CDecl))
@@ -2685,10 +2684,10 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
int NumIvars = CDecl->ivar_size();
SourceLocation LocStart = CDecl->getLocStart();
SourceLocation LocEnd = CDecl->getLocEnd();
-
+
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
-
+
// If no ivars and no root or if its root, directly or indirectly,
// have no ivars (thus not synthesized) then no need to synthesize this class.
if ((CDecl->isForwardDecl() || NumIvars == 0) &&
@@ -2697,8 +2696,8 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
ReplaceText(LocStart, endBuf-startBuf, Result.c_str(), Result.size());
return;
}
-
- // FIXME: This has potential of causing problem. If
+
+ // FIXME: This has potential of causing problem. If
// SynthesizeObjCInternalStruct is ever called recursively.
Result += "\nstruct ";
Result += CDecl->getNameAsString();
@@ -2707,7 +2706,7 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
if (NumIvars > 0) {
const char *cursor = strchr(startBuf, '{');
- assert((cursor && endBuf)
+ assert((cursor && endBuf)
&& "SynthesizeObjCInternalStruct - malformed @interface");
// If the buffer contains preprocessor directives, we do more fine-grained
// rewrites. This is intended to fix code that looks like (which occurs in
@@ -2725,7 +2724,7 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
//
// This clause is segregated to avoid breaking the common case.
if (BufferContainsPPDirectives(startBuf, cursor)) {
- SourceLocation L = RCDecl ? CDecl->getSuperClassLoc() :
+ SourceLocation L = RCDecl ? CDecl->getSuperClassLoc() :
CDecl->getClassLoc();
const char *endHeader = SM->getCharacterData(L);
endHeader += Lexer::MeasureTokenLength(L, *SM, LangOpts);
@@ -2747,14 +2746,14 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
Result += "_IMPL ";
Result += RCDecl->getNameAsString();
Result += "_IVARS;\n";
-
+
// insert the super class structure definition.
SourceLocation OnePastCurly =
LocStart.getFileLocWithOffset(cursor-startBuf+1);
InsertText(OnePastCurly, Result.c_str(), Result.size());
}
cursor++; // past '{'
-
+
// Now comment out any visibility specifiers.
while (cursor < endBuf) {
if (*cursor == '@') {
@@ -2813,7 +2812,7 @@ void RewriteObjC::RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
const char *ClassName,
std::string &Result) {
if (MethodBegin == MethodEnd) return;
-
+
static bool objc_impl_method = false;
if (!objc_impl_method) {
/* struct _objc_method {
@@ -2827,12 +2826,12 @@ void RewriteObjC::RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
Result += "\tchar *method_types;\n";
Result += "\tvoid *_imp;\n";
Result += "};\n";
-
+
objc_impl_method = true;
}
-
+
// Build _objc_method_list for class's methods if needed
-
+
/* struct {
struct _objc_method_list *next_method;
int method_count;
@@ -2895,13 +2894,13 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
Result += "\tstruct objc_selector *_cmd;\n";
Result += "\tchar *method_types;\n";
Result += "};\n";
-
+
objc_protocol_methods = true;
}
// Do not synthesize the protocol more than once.
if (ObjCSynthesizedProtocols.count(PDecl))
return;
-
+
if (PDecl->instmeth_begin() != PDecl->instmeth_end()) {
unsigned NumMethods = std::distance(PDecl->instmeth_begin(),
PDecl->instmeth_end());
@@ -2918,10 +2917,10 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
Result += PDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__OBJC, __cat_inst_meth\")))= "
"{\n\t" + utostr(NumMethods) + "\n";
-
+
// Output instance methods declared in this protocol.
- for (ObjCProtocolDecl::instmeth_iterator
- I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
+ for (ObjCProtocolDecl::instmeth_iterator
+ I = PDecl->instmeth_begin(), E = PDecl->instmeth_end();
I != E; ++I) {
if (I == PDecl->instmeth_begin())
Result += "\t ,{{(struct objc_selector *)\"";
@@ -2936,7 +2935,7 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
}
Result += "\t }\n};\n";
}
-
+
// Output class methods declared in this protocol.
unsigned NumMethods = std::distance(PDecl->classmeth_begin(),
PDecl->classmeth_end());
@@ -2956,9 +2955,9 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
"{\n\t";
Result += utostr(NumMethods);
Result += "\n";
-
+
// Output instance methods declared in this protocol.
- for (ObjCProtocolDecl::classmeth_iterator
+ for (ObjCProtocolDecl::classmeth_iterator
I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
I != E; ++I) {
if (I == PDecl->classmeth_begin())
@@ -2983,7 +2982,7 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
struct _objc_protocol **protocol_list;
struct _objc_protocol_method_list *instance_methods;
struct _objc_protocol_method_list *class_methods;
- };
+ };
*/
static bool objc_protocol = false;
if (!objc_protocol) {
@@ -2994,10 +2993,10 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
Result += "\tstruct _objc_protocol_method_list *instance_methods;\n";
Result += "\tstruct _objc_protocol_method_list *class_methods;\n";
Result += "};\n";
-
+
objc_protocol = true;
}
-
+
Result += "\nstatic struct _objc_protocol _OBJC_PROTOCOL_";
Result += PDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__OBJC, __protocol\")))= "
@@ -3019,7 +3018,7 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, const char *prefix,
else
Result += "0\n";
Result += "};\n";
-
+
// Mark this protocol as having been generated.
if (!ObjCSynthesizedProtocols.insert(PDecl))
assert(false && "protocol already synthesized");
@@ -3031,7 +3030,7 @@ RewriteObjCProtocolListMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
const char *prefix, const char *ClassName,
std::string &Result) {
if (Protocols.empty()) return;
-
+
for (unsigned i = 0; i != Protocols.size(); i++)
RewriteObjCProtocolMetaData(Protocols[i], prefix, ClassName, Result);
@@ -3055,11 +3054,11 @@ RewriteObjCProtocolListMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
"{\n\t0, ";
Result += utostr(Protocols.size());
Result += "\n";
-
+
Result += "\t,{&_OBJC_PROTOCOL_";
Result += Protocols[0]->getNameAsString();
Result += " \n";
-
+
for (unsigned i = 1; i != Protocols.size(); i++) {
Result += "\t ,&_OBJC_PROTOCOL_";
Result += Protocols[i]->getNameAsString();
@@ -3069,24 +3068,24 @@ RewriteObjCProtocolListMetaData(const ObjCList<ObjCProtocolDecl> &Protocols,
}
-/// RewriteObjCCategoryImplDecl - Rewrite metadata for each category
+/// RewriteObjCCategoryImplDecl - Rewrite metadata for each category
/// implementation.
void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
std::string &Result) {
ObjCInterfaceDecl *ClassDecl = IDecl->getClassInterface();
// Find category declaration for this implementation.
ObjCCategoryDecl *CDecl;
- for (CDecl = ClassDecl->getCategoryList(); CDecl;
+ for (CDecl = ClassDecl->getCategoryList(); CDecl;
CDecl = CDecl->getNextClassCategory())
if (CDecl->getIdentifier() == IDecl->getIdentifier())
break;
-
+
std::string FullCategoryName = ClassDecl->getNameAsString();
FullCategoryName += '_';
FullCategoryName += IDecl->getNameAsString();
-
+
// Build _objc_method_list for class's instance methods if needed
- llvm::SmallVector<ObjCMethodDecl *, 32>
+ llvm::SmallVector<ObjCMethodDecl *, 32>
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
// If any of our property implementations have associated getters or
@@ -3111,12 +3110,12 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(),
true, "CATEGORY_", FullCategoryName.c_str(),
Result);
-
+
// Build _objc_method_list for class's class methods if needed
RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
false, "CATEGORY_", FullCategoryName.c_str(),
Result);
-
+
// Protocols referenced in class declaration?
// Null CDecl is case of a category implementation with no category interface
if (CDecl)
@@ -3130,11 +3129,11 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
struct _objc_protocol_list *protocols;
// Objective-C 1.0 extensions
uint32_t size; // sizeof (struct _objc_category)
- struct _objc_property_list *instance_properties; // category's own
+ struct _objc_property_list *instance_properties; // category's own
// @property decl.
- };
+ };
*/
-
+
static bool objc_category = false;
if (!objc_category) {
Result += "\nstruct _objc_category {\n";
@@ -3143,7 +3142,7 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
Result += "\tstruct _objc_method_list *instance_methods;\n";
Result += "\tstruct _objc_method_list *class_methods;\n";
Result += "\tstruct _objc_protocol_list *protocols;\n";
- Result += "\tunsigned int size;\n";
+ Result += "\tunsigned int size;\n";
Result += "\tstruct _objc_property_list *instance_properties;\n";
Result += "};\n";
objc_category = true;
@@ -3155,7 +3154,7 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
Result += "\"\n\t, \"";
Result += ClassDecl->getNameAsString();
Result += "\"\n";
-
+
if (IDecl->instmeth_begin() != IDecl->instmeth_end()) {
Result += "\t, (struct _objc_method_list *)"
"&_OBJC_CATEGORY_INSTANCE_METHODS_";
@@ -3172,9 +3171,9 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
}
else
Result += "\t, 0\n";
-
+
if (CDecl && CDecl->protocol_begin() != CDecl->protocol_end()) {
- Result += "\t, (struct _objc_protocol_list *)&_OBJC_CATEGORY_PROTOCOLS_";
+ Result += "\t, (struct _objc_protocol_list *)&_OBJC_CATEGORY_PROTOCOLS_";
Result += FullCategoryName;
Result += "\n";
}
@@ -3185,8 +3184,8 @@ void RewriteObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
/// SynthesizeIvarOffsetComputation - This rutine synthesizes computation of
/// ivar offset.
-void RewriteObjC::SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
- ObjCIvarDecl *ivar,
+void RewriteObjC::SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
+ ObjCIvarDecl *ivar,
std::string &Result) {
if (ivar->isBitField()) {
// FIXME: The hack below doesn't work for bitfields. For now, we simply
@@ -3210,17 +3209,17 @@ void RewriteObjC::SynthesizeIvarOffsetComputation(ObjCImplementationDecl *IDecl,
void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
std::string &Result) {
ObjCInterfaceDecl *CDecl = IDecl->getClassInterface();
-
+
// Explictly declared @interface's are already synthesized.
if (CDecl->isImplicitInterfaceDecl()) {
- // FIXME: Implementation of a class with no @interface (legacy) doese not
+ // FIXME: Implementation of a class with no @interface (legacy) doese not
// produce correct synthesis as yet.
SynthesizeObjCInternalStruct(CDecl, Result);
}
-
+
// Build _objc_ivar_list metadata for classes ivars if needed
unsigned NumIvars = !IDecl->ivar_empty()
- ? IDecl->ivar_size()
+ ? IDecl->ivar_size()
: (CDecl ? CDecl->ivar_size() : 0);
if (NumIvars > 0) {
static bool objc_ivar = false;
@@ -3229,23 +3228,23 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
char *ivar_name;
char *ivar_type;
int ivar_offset;
- };
+ };
*/
Result += "\nstruct _objc_ivar {\n";
Result += "\tchar *ivar_name;\n";
Result += "\tchar *ivar_type;\n";
Result += "\tint ivar_offset;\n";
Result += "};\n";
-
+
objc_ivar = true;
}
/* struct {
int ivar_count;
struct _objc_ivar ivar_list[nIvars];
- };
+ };
*/
- Result += "\nstatic struct {\n";
+ Result += "\nstatic struct {\n";
Result += "\tint ivar_count;\n";
Result += "\tstruct _objc_ivar ivar_list[";
Result += utostr(NumIvars);
@@ -3255,11 +3254,11 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
"{\n\t";
Result += utostr(NumIvars);
Result += "\n";
-
+
ObjCInterfaceDecl::ivar_iterator IVI, IVE;
llvm::SmallVector<ObjCIvarDecl *, 8> IVars;
if (!IDecl->ivar_empty()) {
- for (ObjCImplementationDecl::ivar_iterator
+ for (ObjCImplementationDecl::ivar_iterator
IV = IDecl->ivar_begin(), IVEnd = IDecl->ivar_end();
IV != IVEnd; ++IV)
IVars.push_back(*IV);
@@ -3291,12 +3290,12 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
SynthesizeIvarOffsetComputation(IDecl, (*IVI), Result);
Result += "}\n";
}
-
+
Result += "\t }\n};\n";
}
-
+
// Build _objc_method_list for class's instance methods if needed
- llvm::SmallVector<ObjCMethodDecl *, 32>
+ llvm::SmallVector<ObjCMethodDecl *, 32>
InstanceMethods(IDecl->instmeth_begin(), IDecl->instmeth_end());
// If any of our property implementations have associated getters or
@@ -3320,15 +3319,15 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
}
RewriteObjCMethodsMetaData(InstanceMethods.begin(), InstanceMethods.end(),
true, "", IDecl->getNameAsCString(), Result);
-
+
// Build _objc_method_list for class's class methods if needed
RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
false, "", IDecl->getNameAsCString(), Result);
-
+
// Protocols referenced in class declaration?
RewriteObjCProtocolListMetaData(CDecl->getReferencedProtocols(),
"CLASS", CDecl->getNameAsCString(), Result);
-
+
// Declaration of class/meta-class metadata
/* struct _objc_class {
struct _objc_class *isa; // or const char *root_class_name when metadata
@@ -3343,7 +3342,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
struct objc_protocol_list *protocols;
const char *ivar_layout;
struct _objc_class_ext *ext;
- };
+ };
*/
static bool objc_class = false;
if (!objc_class) {
@@ -3363,7 +3362,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
Result += "};\n";
objc_class = true;
}
-
+
// Meta-class metadata generation.
ObjCInterfaceDecl *RootClass = 0;
ObjCInterfaceDecl *SuperClass = CDecl->getSuperClass();
@@ -3372,7 +3371,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
SuperClass = SuperClass->getSuperClass();
}
SuperClass = CDecl->getSuperClass();
-
+
Result += "\nstatic struct _objc_class _OBJC_METACLASS_";
Result += CDecl->getNameAsString();
Result += " __attribute__ ((used, section (\"__OBJC, __meta_class\")))= "
@@ -3398,7 +3397,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
if (IDecl->classmeth_begin() != IDecl->classmeth_end()) {
Result += "\n\t, (struct _objc_method_list *)&_OBJC_CLASS_METHODS_";
Result += IDecl->getNameAsString();
- Result += "\n";
+ Result += "\n";
}
else
Result += ", 0\n";
@@ -3410,7 +3409,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
else
Result += "\t,0,0,0,0\n";
Result += "};\n";
-
+
// class metadata generation.
Result += "\nstatic struct _objc_class _OBJC_CLASS_";
Result += CDecl->getNameAsString();
@@ -3451,7 +3450,7 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
if (IDecl->instmeth_begin() != IDecl->instmeth_end()) {
Result += ", (struct _objc_method_list *)&_OBJC_INSTANCE_METHODS_";
Result += CDecl->getNameAsString();
- Result += ", 0\n\t";
+ Result += ", 0\n\t";
}
else
Result += ",0,0";
@@ -3471,25 +3470,25 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
void RewriteObjC::RewriteImplementations() {
int ClsDefCount = ClassImplementation.size();
int CatDefCount = CategoryImplementation.size();
-
+
// Rewrite implemented methods
for (int i = 0; i < ClsDefCount; i++)
RewriteImplementationDecl(ClassImplementation[i]);
-
+
for (int i = 0; i < CatDefCount; i++)
RewriteImplementationDecl(CategoryImplementation[i]);
}
-
+
void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
int ClsDefCount = ClassImplementation.size();
int CatDefCount = CategoryImplementation.size();
// This is needed for determining instance variable offsets.
- Result += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)\n";
+ Result += "\n#define __OFFSETOFIVAR__(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)\n";
// For each implemented class, write out all its meta data.
for (int i = 0; i < ClsDefCount; i++)
RewriteObjCClassMetaData(ClassImplementation[i], Result);
-
+
// For each implemented category, write out all its meta data.
for (int i = 0; i < CatDefCount; i++)
RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
@@ -3503,9 +3502,9 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
short cls_def_cnt;
short cat_def_cnt;
void *defs[cls_def_cnt + cat_def_cnt];
- };
+ };
*/
-
+
Result += "\nstruct _objc_symtab {\n";
Result += "\tlong sel_ref_cnt;\n";
Result += "\tSEL *refs;\n";
@@ -3513,17 +3512,17 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
Result += "\tshort cat_def_cnt;\n";
Result += "\tvoid *defs[" + utostr(ClsDefCount + CatDefCount)+ "];\n";
Result += "};\n\n";
-
+
Result += "static struct _objc_symtab "
"_OBJC_SYMBOLS __attribute__((used, section (\"__OBJC, __symbols\")))= {\n";
- Result += "\t0, 0, " + utostr(ClsDefCount)
+ Result += "\t0, 0, " + utostr(ClsDefCount)
+ ", " + utostr(CatDefCount) + "\n";
for (int i = 0; i < ClsDefCount; i++) {
Result += "\t,&_OBJC_CLASS_";
Result += ClassImplementation[i]->getNameAsString();
Result += "\n";
}
-
+
for (int i = 0; i < CatDefCount; i++) {
Result += "\t,&_OBJC_CATEGORY_";
Result += CategoryImplementation[i]->getClassInterface()->getNameAsString();
@@ -3531,11 +3530,11 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
Result += CategoryImplementation[i]->getNameAsString();
Result += "\n";
}
-
+
Result += "};\n\n";
-
+
// Write objc_module metadata
-
+
/*
struct _objc_module {
long version;
@@ -3544,7 +3543,7 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
struct _objc_symtab *symtab;
}
*/
-
+
Result += "\nstruct _objc_module {\n";
Result += "\tlong version;\n";
Result += "\tlong size;\n";
@@ -3553,7 +3552,7 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
Result += "};\n\n";
Result += "static struct _objc_module "
"_OBJC_MODULES __attribute__ ((used, section (\"__OBJC, __module_info\")))= {\n";
- Result += "\t" + utostr(OBJC_ABI_VERSION) +
+ Result += "\t" + utostr(OBJC_ABI_VERSION) +
", sizeof(struct _objc_module), \"\", &_OBJC_SYMBOLS\n";
Result += "};\n\n";
@@ -3561,7 +3560,7 @@ void RewriteObjC::SynthesizeMetaDataIntoBuffer(std::string &Result) {
if (ProtocolExprDecls.size()) {
Result += "#pragma section(\".objc_protocol$B\",long,read,write)\n";
Result += "#pragma data_seg(push, \".objc_protocol$B\")\n";
- for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
+ for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
E = ProtocolExprDecls.end(); I != E; ++I) {
Result += "static struct _objc_protocol *_POINTER_OBJC_PROTOCOL_";
Result += (*I)->getNameAsString();
@@ -3589,9 +3588,9 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
funcName + "_" + "block_func_" + utostr(i);
BlockDecl *BD = CE->getBlockDecl();
-
+
if (isa<FunctionNoProtoType>(AFT)) {
- // No user-supplied arguments. Still need to pass in a pointer to the
+ // No user-supplied arguments. Still need to pass in a pointer to the
// block (to reference imported block decl refs).
S += "(" + StructRef + " *__cself)";
} else if (BD->param_empty()) {
@@ -3617,19 +3616,19 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
S += ')';
}
S += " {\n";
-
+
// Create local declarations to avoid rewriting all closure decl ref exprs.
// First, emit a declaration for all "by ref" decls.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
- Context->getPointerType((*I)->getType()).getAsStringInternal(Name,
+ Context->getPointerType((*I)->getType()).getAsStringInternal(Name,
Context->PrintingPolicy);
S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by ref\n";
- }
+ }
// Next, emit a declaration for all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
@@ -3637,7 +3636,7 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
//
// void (^myImportedClosure)(void);
// myImportedClosure = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherClosure)(void);
// anotherClosure = ^(void) {
// myImportedClosure(); // import and invoke the closure
@@ -3662,13 +3661,13 @@ std::string RewriteObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
std::string Tag) {
std::string StructRef = "struct " + Tag;
std::string S = "static void __";
-
+
S += funcName;
S += "_block_copy_" + utostr(i);
S += "(" + StructRef;
S += "*dst, " + StructRef;
S += "*src) {";
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
E = ImportedBlockDecls.end(); I != E; ++I) {
S += "_Block_object_assign((void*)&dst->";
S += (*I)->getNameAsString();
@@ -3681,13 +3680,13 @@ std::string RewriteObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
S += "_block_dispose_" + utostr(i);
S += "(" + StructRef;
S += "*src) {";
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = ImportedBlockDecls.begin(),
E = ImportedBlockDecls.end(); I != E; ++I) {
S += "_Block_object_dispose((void*)src->";
S += (*I)->getNameAsString();
S += ", 3/*BLOCK_FIELD_IS_OBJECT*/);";
}
- S += "}\n";
+ S += "}\n";
return S;
}
@@ -3695,20 +3694,20 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
bool hasCopyDisposeHelpers) {
std::string S = "\nstruct " + Tag;
std::string Constructor = " " + Tag;
-
+
S += " {\n struct __block_impl impl;\n";
-
+
if (hasCopyDisposeHelpers)
S += " void *copy;\n void *dispose;\n";
-
+
Constructor += "(void *fp";
-
+
if (hasCopyDisposeHelpers)
Constructor += ", void *copyHelp, void *disposeHelp";
-
+
if (BlockDeclRefs.size()) {
// Output all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
@@ -3717,7 +3716,7 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
//
// void (^myImportedBlock)(void);
// myImportedBlock = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherBlock)(void);
// anotherBlock = ^(void) {
// myImportedBlock(); // import and invoke the closure
@@ -3734,7 +3733,7 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
S += FieldName + ";\n";
}
// Output all "by ref" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
@@ -3743,7 +3742,7 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
//
// void (^myImportedBlock)(void);
// myImportedBlock = ^(void) { setGlobalInt(x + y); };
- //
+ //
// void (^anotherBlock)(void);
// anotherBlock = ^(void) {
// myImportedBlock(); // import and invoke the closure
@@ -3753,9 +3752,9 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
S += "struct __block_impl *";
Constructor += ", void *" + ArgName;
} else {
- Context->getPointerType((*I)->getType()).getAsStringInternal(FieldName,
+ Context->getPointerType((*I)->getType()).getAsStringInternal(FieldName,
Context->PrintingPolicy);
- Context->getPointerType((*I)->getType()).getAsStringInternal(ArgName,
+ Context->getPointerType((*I)->getType()).getAsStringInternal(ArgName,
Context->PrintingPolicy);
Constructor += ", " + ArgName;
}
@@ -3769,12 +3768,12 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += " impl.isa = &_NSConcreteStackBlock;\n";
Constructor += " impl.Size = sizeof(";
Constructor += Tag + ");\n impl.Flags = flags;\n impl.FuncPtr = fp;\n";
-
+
if (hasCopyDisposeHelpers)
Constructor += " copy = copyHelp;\n dispose = disposeHelp;\n";
-
+
// Initialize all "by copy" arguments.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
Constructor += " ";
@@ -3785,7 +3784,7 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += Name + ";\n";
}
// Initialize all "by ref" arguments.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
std::string Name = (*I)->getNameAsString();
Constructor += " ";
@@ -3822,21 +3821,21 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
CollectBlockDeclRefInfo(Blocks[i]);
std::string Tag = "__" + std::string(FunName) + "_block_impl_" + utostr(i);
-
- std::string CI = SynthesizeBlockImpl(Blocks[i], Tag,
+
+ std::string CI = SynthesizeBlockImpl(Blocks[i], Tag,
ImportedBlockDecls.size() > 0);
InsertText(FunLocStart, CI.c_str(), CI.size());
std::string CF = SynthesizeBlockFunc(Blocks[i], i, FunName, Tag);
-
+
InsertText(FunLocStart, CF.c_str(), CF.size());
if (ImportedBlockDecls.size()) {
std::string HF = SynthesizeBlockHelperFuncs(Blocks[i], i, FunName, Tag);
InsertText(FunLocStart, HF.c_str(), HF.size());
}
-
+
BlockDeclRefs.clear();
BlockByRefDecls.clear();
BlockByCopyDecls.clear();
@@ -3850,7 +3849,7 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
const char *FuncName = FD->getNameAsCString();
-
+
SynthesizeBlockLiterals(FunLocStart, FuncName);
}
@@ -3864,7 +3863,7 @@ void RewriteObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
std::string::size_type loc = 0;
while ((loc = FuncName.find(":", loc)) != std::string::npos)
FuncName.replace(loc, 1, "_");
-
+
SynthesizeBlockLiterals(FunLocStart, FuncName.c_str());
}
@@ -3894,7 +3893,7 @@ void RewriteObjC::GetBlockCallExprs(Stmt *S) {
else
GetBlockCallExprs(*CI);
}
-
+
if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
if (CE->getCallee()->getType()->isBlockPointerType()) {
BlockCallExprs[dyn_cast<BlockDeclRefExpr>(CE->getCallee())] = CE;
@@ -3907,7 +3906,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
// Navigate to relevant type information.
const char *closureName = 0;
const BlockPointerType *CPT = 0;
-
+
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
closureName = DRE->getDecl()->getNameAsCString();
CPT = DRE->getType()->getAs<BlockPointerType>();
@@ -3925,7 +3924,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
assert(FT && "RewriteBlockClass: Bad type");
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.
-
+
RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&Context->Idents.get("__block_impl"));
@@ -3933,11 +3932,11 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
// Generate a funky cast.
llvm::SmallVector<QualType, 8> ArgTypes;
-
+
// Push the block argument type.
ArgTypes.push_back(PtrBlock);
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
E = FTP->arg_type_end(); I && (I != E); ++I) {
QualType t = *I;
// Make sure we convert "t (^)(...)" to "t (*)(...)".
@@ -3949,12 +3948,12 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
}
}
// Now do the pointer to function cast.
- QualType PtrToFuncCastType = Context->getFunctionType(Exp->getType(),
+ QualType PtrToFuncCastType = Context->getFunctionType(Exp->getType(),
&ArgTypes[0], ArgTypes.size(), false/*no variadic*/, 0);
-
+
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
-
- CastExpr *BlkCast = new (Context) CStyleCastExpr(PtrBlock,
+
+ CastExpr *BlkCast = new (Context) CStyleCastExpr(PtrBlock,
CastExpr::CK_Unknown,
Exp->getCallee(),
PtrBlock, SourceLocation(),
@@ -3963,25 +3962,25 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(),
BlkCast);
//PE->dump();
-
+
FieldDecl *FD = FieldDecl::Create(*Context, 0, SourceLocation(),
- &Context->Idents.get("FuncPtr"), Context->VoidPtrTy, 0,
+ &Context->Idents.get("FuncPtr"), Context->VoidPtrTy, 0,
/*BitWidth=*/0, /*Mutable=*/true);
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType());
-
+
CastExpr *FunkCast = new (Context) CStyleCastExpr(PtrToFuncCastType,
CastExpr::CK_Unknown, ME,
PtrToFuncCastType,
SourceLocation(),
SourceLocation());
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast);
-
+
llvm::SmallVector<Expr*, 8> BlkExprs;
// Add the implicit argument.
BlkExprs.push_back(BlkCast);
// Add the user arguments.
- for (CallExpr::arg_iterator I = Exp->arg_begin(),
+ for (CallExpr::arg_iterator I = Exp->arg_begin(),
E = Exp->arg_end(); I != E; ++I) {
BlkExprs.push_back(*I);
}
@@ -4003,7 +4002,7 @@ void RewriteObjC::RewriteBlockCall(CallExpr *Exp) {
// int main() {
// __block Foo *f;
// __block int i;
-//
+//
// void (^myblock)() = ^() {
// [f test]; // f is a BlockDeclRefExpr embedded in a message (which is being rewritten).
// i = 77;
@@ -4030,16 +4029,16 @@ void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) {
// Need to avoid trying to rewrite casts contained in macros.
if (!Rewriter::isRewritable(LocStart) || !Rewriter::isRewritable(LocEnd))
return;
-
+
const char *startBuf = SM->getCharacterData(LocStart);
const char *endBuf = SM->getCharacterData(LocEnd);
-
+
// advance the location to startArgList.
const char *argPtr = startBuf;
-
+
while (*argPtr++ && (argPtr < endBuf)) {
switch (*argPtr) {
- case '^':
+ case '^':
// Replace the '^' with '*'.
LocStart = LocStart.getFileLocWithOffset(argPtr-startBuf);
ReplaceText(LocStart, 1, "*", 1);
@@ -4052,31 +4051,31 @@ void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) {
void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) {
SourceLocation DeclLoc = FD->getLocation();
unsigned parenCount = 0;
-
+
// We have 1 or more arguments that have closure pointers.
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *startArgList = strchr(startBuf, '(');
-
+
assert((*startArgList == '(') && "Rewriter fuzzy parser confused");
-
+
parenCount++;
// advance the location to startArgList.
DeclLoc = DeclLoc.getFileLocWithOffset(startArgList-startBuf);
assert((DeclLoc.isValid()) && "Invalid DeclLoc");
-
+
const char *argPtr = startArgList;
-
+
while (*argPtr++ && parenCount) {
switch (*argPtr) {
- case '^':
+ case '^':
// Replace the '^' with '*'.
DeclLoc = DeclLoc.getFileLocWithOffset(argPtr-startArgList);
ReplaceText(DeclLoc, 1, "*", 1);
break;
- case '(':
- parenCount++;
+ case '(':
+ parenCount++;
break;
- case ')':
+ case ')':
parenCount--;
break;
}
@@ -4095,7 +4094,7 @@ bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) {
FTP = BPT->getPointeeType()->getAsFunctionProtoType();
}
if (FTP) {
- for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator I = FTP->arg_type_begin(),
E = FTP->arg_type_end(); I != E; ++I)
if (isTopLevelBlockPointerType(*I))
return true;
@@ -4107,11 +4106,11 @@ void RewriteObjC::GetExtentOfArgList(const char *Name, const char *&LParen,
const char *&RParen) {
const char *argPtr = strchr(Name, '(');
assert((*argPtr == '(') && "Rewriter fuzzy parser confused");
-
+
LParen = argPtr; // output the start.
argPtr++; // skip past the left paren.
unsigned parenCount = 1;
-
+
while (*argPtr && parenCount) {
switch (*argPtr) {
case '(': parenCount++; break;
@@ -4128,7 +4127,7 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
RewriteBlockPointerFunctionArgs(FD);
return;
- }
+ }
// Handle Variables and Typedefs.
SourceLocation DeclLoc = ND->getLocation();
QualType DeclT;
@@ -4138,15 +4137,15 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
DeclT = TDD->getUnderlyingType();
else if (FieldDecl *FD = dyn_cast<FieldDecl>(ND))
DeclT = FD->getType();
- else
+ else
assert(0 && "RewriteBlockPointerDecl(): Decl type not yet handled");
-
+
const char *startBuf = SM->getCharacterData(DeclLoc);
const char *endBuf = startBuf;
// scan backward (from the decl location) for the end of the previous decl.
while (*startBuf != '^' && *startBuf != ';' && startBuf != MainFileStart)
startBuf--;
-
+
// *startBuf != '^' if we are dealing with a pointer to function that
// may take block argument types (which will be handled below).
if (*startBuf == '^') {
@@ -4171,7 +4170,7 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
return;
}
-void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
+void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
// Add initializers for any closure decl refs.
GetBlockDeclRefExprs(Exp->getBody());
if (BlockDeclRefs.size()) {
@@ -4196,7 +4195,7 @@ void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
FunctionDecl *RewriteObjC::SynthBlockInitFunctionDecl(const char *name) {
IdentifierInfo *ID = &Context->Idents.get(name);
QualType FType = Context->getFunctionNoProtoType(Context->VoidPtrTy);
- return FunctionDecl::Create(*Context, TUDecl,SourceLocation(),
+ return FunctionDecl::Create(*Context, TUDecl,SourceLocation(),
ID, FType, 0, FunctionDecl::Extern, false,
false);
}
@@ -4206,7 +4205,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
CollectBlockDeclRefInfo(Exp);
std::string FuncName;
-
+
if (CurFunctionDef)
FuncName = CurFunctionDef->getNameAsString();
else if (CurMethodDef) {
@@ -4217,58 +4216,58 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
FuncName.replace(loc, 1, "_");
} else if (GlobalVarDecl)
FuncName = std::string(GlobalVarDecl->getNameAsString());
-
+
std::string BlockNumber = utostr(Blocks.size()-1);
-
+
std::string Tag = "__" + FuncName + "_block_impl_" + BlockNumber;
std::string Func = "__" + FuncName + "_block_func_" + BlockNumber;
-
+
// Get a pointer to the function type so we can cast appropriately.
QualType FType = Context->getPointerType(QualType(Exp->getFunctionType(),0));
FunctionDecl *FD;
Expr *NewRep;
-
+
// Simulate a contructor call...
FD = SynthBlockInitFunctionDecl(Tag.c_str());
DeclRefExpr *DRE = new (Context) DeclRefExpr(FD, FType, SourceLocation());
-
+
llvm::SmallVector<Expr*, 4> InitExprs;
-
+
// Initialize the block function.
FD = SynthBlockInitFunctionDecl(Func.c_str());
DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(),
SourceLocation());
- CastExpr *castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
+ CastExpr *castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
- InitExprs.push_back(castExpr);
-
+ InitExprs.push_back(castExpr);
+
if (ImportedBlockDecls.size()) {
std::string Buf = "__" + FuncName + "_block_copy_" + BlockNumber;
FD = SynthBlockInitFunctionDecl(Buf.c_str());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
- castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
+ castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
- InitExprs.push_back(castExpr);
-
+ InitExprs.push_back(castExpr);
+
Buf = "__" + FuncName + "_block_dispose_" + BlockNumber;
FD = SynthBlockInitFunctionDecl(Buf.c_str());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
- castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
+ castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
- InitExprs.push_back(castExpr);
+ InitExprs.push_back(castExpr);
}
// Add initializers for any closure decl refs.
if (BlockDeclRefs.size()) {
Expr *Exp;
// Output all "by copy" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByCopyDecls.begin(),
E = BlockByCopyDecls.end(); I != E; ++I) {
if (isObjCType((*I)->getType())) {
// FIXME: Conform to ABI ([[obj retain] autorelease]).
@@ -4277,34 +4276,34 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
- Exp = new (Context) CStyleCastExpr(Context->VoidPtrTy,
- CastExpr::CK_Unknown, Arg,
- Context->VoidPtrTy,
+ Exp = new (Context) CStyleCastExpr(Context->VoidPtrTy,
+ CastExpr::CK_Unknown, Arg,
+ Context->VoidPtrTy,
SourceLocation(),
SourceLocation());
} else {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
}
- InitExprs.push_back(Exp);
+ InitExprs.push_back(Exp);
}
// Output all "by ref" declarations.
- for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
+ for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
Exp = new (Context) UnaryOperator(Exp, UnaryOperator::AddrOf,
- Context->getPointerType(Exp->getType()),
+ Context->getPointerType(Exp->getType()),
SourceLocation());
- InitExprs.push_back(Exp);
+ InitExprs.push_back(Exp);
}
}
NewRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0], InitExprs.size(),
FType, SourceLocation());
NewRep = new (Context) UnaryOperator(NewRep, UnaryOperator::AddrOf,
- Context->getPointerType(NewRep->getType()),
+ Context->getPointerType(NewRep->getType()),
SourceLocation());
- NewRep = new (Context) CStyleCastExpr(FType, CastExpr::CK_Unknown, NewRep,
+ NewRep = new (Context) CStyleCastExpr(FType, CastExpr::CK_Unknown, NewRep,
FType, SourceLocation(),
SourceLocation());
BlockDeclRefs.clear();
@@ -4340,33 +4339,33 @@ void RewriteObjC::CollectPropertySetters(Stmt *S) {
}
Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
- if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
+ if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
isa<DoStmt>(S) || isa<ForStmt>(S))
Stmts.push_back(S);
else if (isa<ObjCForCollectionStmt>(S)) {
Stmts.push_back(S);
ObjCBcLabelNo.push_back(++BcLabelCount);
}
-
+
SourceRange OrigStmtRange = S->getSourceRange();
-
+
// Perform a bottom up rewrite of all children.
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
CI != E; ++CI)
if (*CI) {
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(*CI);
- if (newStmt)
+ if (newStmt)
*CI = newStmt;
}
-
+
if (BlockExpr *BE = dyn_cast<BlockExpr>(S)) {
// Rewrite the block body in place.
RewriteFunctionBodyOrGlobalInitializer(BE->getBody());
-
+
// Now we snarf the rewritten text and stash it away for later use.
std::string Str = Rewrite.getRewritenText(BE->getSourceRange());
RewrittenBlockExprs[BE] = Str;
-
+
Stmt *blockTranscribed = SynthBlockInitExpr(BE);
//blockTranscribed->dump();
ReplaceStmt(S, blockTranscribed);
@@ -4375,7 +4374,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
// Handle specific things.
if (ObjCEncodeExpr *AtEncode = dyn_cast<ObjCEncodeExpr>(S))
return RewriteAtEncode(AtEncode);
-
+
if (ObjCIvarRefExpr *IvarRefExpr = dyn_cast<ObjCIvarRefExpr>(S))
return RewriteObjCIvarRefExpr(IvarRefExpr, OrigStmtRange.getBegin());
@@ -4388,7 +4387,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
// Save the source range. Even if we disable the replacement, the
// rewritten node will have been inserted into the tree. If the synthesized
// node is at the 'end', the rewriter will fail. Consider this:
- // self.errorHandler = handler ? handler :
+ // self.errorHandler = handler ? handler :
// ^(NSURL *errorURL, NSError *error) { return (BOOL)1; };
SourceRange SrcRange = BinOp->getSourceRange();
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(BinOp->getRHS());
@@ -4422,7 +4421,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
// can be used as the setter argument. ReplaceStmt() will still 'see'
// the original RHS (since we haven't altered BinOp).
//
- // This implies the Rewrite* routines can no longer delete the original
+ // This implies the Rewrite* routines can no longer delete the original
// node. As a result, we now leak the original AST nodes.
//
return RewritePropertySetter(BinOp, dyn_cast<Expr>(newStmt), SrcRange);
@@ -4432,25 +4431,25 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
}
if (ObjCSelectorExpr *AtSelector = dyn_cast<ObjCSelectorExpr>(S))
return RewriteAtSelector(AtSelector);
-
+
if (ObjCStringLiteral *AtString = dyn_cast<ObjCStringLiteral>(S))
return RewriteObjCStringLiteral(AtString);
-
+
if (ObjCMessageExpr *MessExpr = dyn_cast<ObjCMessageExpr>(S)) {
#if 0
// Before we rewrite it, put the original message expression in a comment.
SourceLocation startLoc = MessExpr->getLocStart();
SourceLocation endLoc = MessExpr->getLocEnd();
-
+
const char *startBuf = SM->getCharacterData(startLoc);
const char *endBuf = SM->getCharacterData(endLoc);
-
+
std::string messString;
messString += "// ";
messString.append(startBuf, endBuf-startBuf+1);
messString += "\n";
-
- // FIXME: Missing definition of
+
+ // FIXME: Missing definition of
// InsertText(clang::SourceLocation, char const*, unsigned int).
// InsertText(startLoc, messString.c_str(), messString.size());
// Tried this, but it didn't work either...
@@ -4458,7 +4457,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
#endif
return RewriteMessageExpr(MessExpr);
}
-
+
if (ObjCAtTryStmt *StmtTry = dyn_cast<ObjCAtTryStmt>(S))
return RewriteObjCTryStmt(StmtTry);
@@ -4467,13 +4466,13 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
if (ObjCAtThrowStmt *StmtThrow = dyn_cast<ObjCAtThrowStmt>(S))
return RewriteObjCThrowStmt(StmtThrow);
-
+
if (ObjCProtocolExpr *ProtocolExp = dyn_cast<ObjCProtocolExpr>(S))
return RewriteObjCProtocolExpr(ProtocolExp);
-
- if (ObjCForCollectionStmt *StmtForCollection =
+
+ if (ObjCForCollectionStmt *StmtForCollection =
dyn_cast<ObjCForCollectionStmt>(S))
- return RewriteObjCForCollectionStmt(StmtForCollection,
+ return RewriteObjCForCollectionStmt(StmtForCollection,
OrigStmtRange.getEnd());
if (BreakStmt *StmtBreakStmt =
dyn_cast<BreakStmt>(S))
@@ -4481,15 +4480,15 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
if (ContinueStmt *StmtContinueStmt =
dyn_cast<ContinueStmt>(S))
return RewriteContinueStmt(StmtContinueStmt);
-
- // Need to check for protocol refs (id <P>, Foo <P> *) in variable decls
+
+ // Need to check for protocol refs (id <P>, Foo <P> *) in variable decls
// and cast exprs.
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
// FIXME: What we're doing here is modifying the type-specifier that
// precedes the first Decl. In the future the DeclGroup should have
- // a separate type-specifier that we can rewrite.
+ // a separate type-specifier that we can rewrite.
RewriteObjCQualifiedInterfaceTypes(*DS->decl_begin());
-
+
// Blocks rewrite rules.
for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
DI != DE; ++DI) {
@@ -4497,26 +4496,26 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
if (ValueDecl *ND = dyn_cast<ValueDecl>(SD)) {
if (isTopLevelBlockPointerType(ND->getType()))
RewriteBlockPointerDecl(ND);
- else if (ND->getType()->isFunctionPointerType())
+ else if (ND->getType()->isFunctionPointerType())
CheckFunctionPointerDecl(ND->getType(), ND);
}
if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) {
if (isTopLevelBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
- else if (TD->getUnderlyingType()->isFunctionPointerType())
+ else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
}
}
}
-
+
if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(S))
RewriteObjCQualifiedInterfaceTypes(CE);
-
- if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
+
+ if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) ||
isa<DoStmt>(S) || isa<ForStmt>(S)) {
assert(!Stmts.empty() && "Statement stack is empty");
- assert ((isa<SwitchStmt>(Stmts.back()) || isa<WhileStmt>(Stmts.back()) ||
- isa<DoStmt>(Stmts.back()) || isa<ForStmt>(Stmts.back()))
+ assert ((isa<SwitchStmt>(Stmts.back()) || isa<WhileStmt>(Stmts.back()) ||
+ isa<DoStmt>(Stmts.back()) || isa<ForStmt>(Stmts.back()))
&& "Statement stack mismatch");
Stmts.pop_back();
}
@@ -4560,7 +4559,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (FD->isOverloadedOperator())
return;
-
+
// Since function prototypes don't have ParmDecl's, we check the function
// prototype. This enables us to rewrite function declarations and
// definitions using the same code.
@@ -4583,7 +4582,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
// and any copy/dispose helper functions.
InsertBlockLiteralsWithinFunction(FD);
CurFunctionDef = 0;
- }
+ }
return;
}
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
@@ -4631,7 +4630,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
delete PropParentMap;
PropParentMap = 0;
}
- SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(),
+ SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(),
VD->getNameAsCString());
GlobalVarDecl = 0;
@@ -4645,13 +4644,13 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
if (isTopLevelBlockPointerType(TD->getUnderlyingType()))
RewriteBlockPointerDecl(TD);
- else if (TD->getUnderlyingType()->isFunctionPointerType())
+ else if (TD->getUnderlyingType()->isFunctionPointerType())
CheckFunctionPointerDecl(TD->getUnderlyingType(), TD);
return;
}
if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) {
if (RD->isDefinition()) {
- for (RecordDecl::field_iterator i = RD->field_begin(),
+ for (RecordDecl::field_iterator i = RD->field_begin(),
e = RD->field_end(); i != e; ++i) {
FieldDecl *FD = *i;
if (isTopLevelBlockPointerType(FD->getType()))
@@ -4665,29 +4664,29 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
void RewriteObjC::HandleTranslationUnit(ASTContext &C) {
// Get the top-level buffer that this corresponds to.
-
+
// Rewrite tabs if we care.
//RewriteTabs();
-
+
if (Diags.hasErrorOccurred())
return;
-
+
RewriteInclude();
-
+
// Here's a great place to add any extra declarations that may be needed.
// Write out meta data for each @protocol(<expr>).
- for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
+ for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(),
E = ProtocolExprDecls.end(); I != E; ++I)
RewriteObjCProtocolMetaData(*I, "", "", Preamble);
- InsertText(SM->getLocForStartOfFile(MainFileID),
+ InsertText(SM->getLocForStartOfFile(MainFileID),
Preamble.c_str(), Preamble.size(), false);
if (ClassImplementation.size() || CategoryImplementation.size())
RewriteImplementations();
// Get the buffer corresponding to MainFileID. If we haven't changed it, then
// we are done.
- if (const RewriteBuffer *RewriteBuf =
+ if (const RewriteBuffer *RewriteBuf =
Rewrite.getRewriteBufferFor(MainFileID)) {
//printf("Changed:\n");
*OutFile << std::string(RewriteBuf->begin(), RewriteBuf->end());
diff --git a/lib/Frontend/RewriteTest.cpp b/lib/Frontend/RewriteTest.cpp
index f9eb58f867..0414678fb6 100644
--- a/lib/Frontend/RewriteTest.cpp
+++ b/lib/Frontend/RewriteTest.cpp
@@ -30,8 +30,8 @@ void clang::DoRewriteTest(Preprocessor &PP, llvm::raw_ostream* OS) {
Rewriter.AddTokenBefore(I, "<i>");
Rewriter.AddTokenAfter(I, "</i>");
}
-
-
+
+
// Print out the output.
for (TokenRewriter::token_iterator I = Rewriter.token_begin(),
E = Rewriter.token_end(); I != E; ++I)
diff --git a/lib/Frontend/StmtXML.cpp b/lib/Frontend/StmtXML.cpp
index b6d04810bf..4a3c0bf1c6 100644
--- a/lib/Frontend/StmtXML.cpp
+++ b/lib/Frontend/StmtXML.cpp
@@ -32,25 +32,18 @@ namespace {
//static const char *getOpcodeStr(BinaryOperator::Opcode Op);
- void addSpecialAttribute(const char* pName, StringLiteral* Str)
- {
+ void addSpecialAttribute(const char* pName, StringLiteral* Str) {
Doc.addAttribute(pName, Doc.escapeString(Str->getStrData(), Str->getByteLength()));
}
- void addSpecialAttribute(const char* pName, SizeOfAlignOfExpr* S)
- {
+ void addSpecialAttribute(const char* pName, SizeOfAlignOfExpr* S) {
if (S->isArgumentType())
- {
Doc.addAttribute(pName, S->getArgumentType());
- }
}
- void addSpecialAttribute(const char* pName, CXXTypeidExpr* S)
- {
+ void addSpecialAttribute(const char* pName, CXXTypeidExpr* S) {
if (S->isTypeOperand())
- {
Doc.addAttribute(pName, S->getTypeOperand());
- }
}
@@ -58,29 +51,21 @@ namespace {
StmtXML(DocumentXML& doc)
: Doc(doc) {
}
-
+
void DumpSubTree(Stmt *S) {
- if (S)
- {
+ if (S) {
Visit(S);
- if (DeclStmt* DS = dyn_cast<DeclStmt>(S))
- {
- for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();
- DI != DE; ++DI)
- {
+ if (DeclStmt* DS = dyn_cast<DeclStmt>(S)) {
+ for (DeclStmt::decl_iterator DI = DS->decl_begin(),
+ DE = DS->decl_end(); DI != DE; ++DI) {
Doc.PrintDecl(*DI);
}
- }
- else
- {
+ } else {
if (CXXConditionDeclExpr* CCDE = dyn_cast<CXXConditionDeclExpr>(S))
- {
Doc.PrintDecl(CCDE->getVarDecl());
- }
- for (Stmt::child_iterator i = S->child_begin(), e = S->child_end(); i != e; ++i)
- {
+ for (Stmt::child_iterator i = S->child_begin(), e = S->child_end();
+ i != e; ++i)
DumpSubTree(*i);
- }
}
Doc.toParent();
} else {
@@ -93,12 +78,12 @@ namespace {
void Visit##CLASS(CLASS* S) \
{ \
typedef CLASS tStmtType; \
- Doc.addSubNode(NAME);
+ Doc.addSubNode(NAME);
-#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, S->FN);
+#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, S->FN);
#define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type")
-#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, S->FN);
-#define ATTRIBUTE_SPECIAL_XML( FN, NAME ) addSpecialAttribute(NAME, S);
+#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, S->FN);
+#define ATTRIBUTE_SPECIAL_XML( FN, NAME ) addSpecialAttribute(NAME, S);
#define ATTRIBUTE_FILE_LOCATION_XML Doc.addLocationRange(S->getSourceRange());
@@ -107,14 +92,14 @@ namespace {
const char* pAttributeName = NAME; \
const bool optional = false; \
switch (S->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME ) \
{ \
const char* pAttributeName = NAME; \
const bool optional = true; \
switch (S->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ENUM_XML( VALUE, NAME ) case VALUE: if ((!optional) || NAME[0]) Doc.addAttribute(pAttributeName, NAME); break;
#define END_ENUM_XML } }
@@ -133,7 +118,7 @@ namespace {
void VisitDeclStmt(DeclStmt *Node);
void VisitLabelStmt(LabelStmt *Node);
void VisitGotoStmt(GotoStmt *Node);
-
+
// Exprs
void VisitExpr(Expr *Node);
void VisitDeclRefExpr(DeclRefExpr *Node);
@@ -156,7 +141,7 @@ namespace {
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node);
void VisitCXXThisExpr(CXXThisExpr *Node);
void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node);
-
+
// ObjC
void VisitObjCEncodeExpr(ObjCEncodeExpr *Node);
void VisitObjCMessageExpr(ObjCMessageExpr* Node);
@@ -175,27 +160,22 @@ namespace {
// Stmt printing methods.
//===----------------------------------------------------------------------===//
#if (0)
-void StmtXML::VisitStmt(Stmt *Node)
-{
+void StmtXML::VisitStmt(Stmt *Node) {
// nothing special to do
}
-void StmtXML::VisitDeclStmt(DeclStmt *Node)
-{
+void StmtXML::VisitDeclStmt(DeclStmt *Node) {
for (DeclStmt::decl_iterator DI = Node->decl_begin(), DE = Node->decl_end();
- DI != DE; ++DI)
- {
+ DI != DE; ++DI) {
Doc.PrintDecl(*DI);
}
}
-void StmtXML::VisitLabelStmt(LabelStmt *Node)
-{
+void StmtXML::VisitLabelStmt(LabelStmt *Node) {
Doc.addAttribute("name", Node->getName());
}
-void StmtXML::VisitGotoStmt(GotoStmt *Node)
-{
+void StmtXML::VisitGotoStmt(GotoStmt *Node) {
Doc.addAttribute("name", Node->getLabel()->getName());
}
@@ -336,9 +316,7 @@ void StmtXML::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
Doc.addAttribute("is_sizeof", Node->isSizeOf() ? "sizeof" : "alignof");
Doc.addAttribute("is_type", Node->isArgumentType() ? "1" : "0");
if (Node->isArgumentType())
- {
DumpTypeExpr(Node->getArgumentType());
- }
}
void StmtXML::VisitMemberExpr(MemberExpr *Node) {
@@ -415,7 +393,7 @@ void StmtXML::VisitObjCMessageExpr(ObjCMessageExpr* Node) {
DumpExpr(Node);
Doc.addAttribute("selector", Node->getSelector().getAsString());
IdentifierInfo* clsName = Node->getClassName();
- if (clsName)
+ if (clsName)
Doc.addAttribute("class", clsName->getName());
}
diff --git a/lib/Frontend/TextDiagnosticBuffer.cpp b/lib/Frontend/TextDiagnosticBuffer.cpp
index a4518ee7e6..34bc3c796a 100644
--- a/lib/Frontend/TextDiagnosticBuffer.cpp
+++ b/lib/Frontend/TextDiagnosticBuffer.cpp
@@ -17,7 +17,7 @@ using namespace clang;
/// HandleDiagnostic - Store the errors, warnings, and notes that are
/// reported.
-///
+///
void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
const DiagnosticInfo &Info) {
llvm::SmallString<100> StrC;
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 973a47f779..63d9a50b36 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -436,7 +436,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
/// greater than or equal to Idx or, if no such character exists,
/// returns the end of the string.
static unsigned skipWhitespace(unsigned Idx,
- const llvm::SmallVectorImpl<char> &Str,
+ const llvm::SmallVectorImpl<char> &Str,
unsigned Length) {
while (Idx < Length && isspace(Str[Idx]))
++Idx;
@@ -536,7 +536,7 @@ unsigned findEndOfWord(unsigned Start,
/// \returns true if word-wrapping was required, or false if the
/// string fit on the first line.
static bool PrintWordWrapped(llvm::raw_ostream &OS,
- const llvm::SmallVectorImpl<char> &Str,
+ const llvm::SmallVectorImpl<char> &Str,
unsigned Columns,
unsigned Column = 0,
unsigned Indentation = WordWrapIndentation) {
diff --git a/lib/Frontend/TypeXML.cpp b/lib/Frontend/TypeXML.cpp
index f32fbbd241..8bd05443a7 100644
--- a/lib/Frontend/TypeXML.cpp
+++ b/lib/Frontend/TypeXML.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the XML document class, which provides the means to
+// This file implements the XML document class, which provides the means to
// dump out the AST in a XML form that exposes type details and other fields.
//
//===----------------------------------------------------------------------===//
@@ -21,38 +21,36 @@ namespace clang {
namespace XML {
namespace {
-//---------------------------------------------------------
-class TypeWriter : public TypeVisitor<TypeWriter>
-{
+//---------------------------------------------------------
+class TypeWriter : public TypeVisitor<TypeWriter> {
DocumentXML& Doc;
public:
TypeWriter(DocumentXML& doc) : Doc(doc) {}
#define NODE_XML( CLASS, NAME ) \
- void Visit##CLASS(CLASS* T) \
- { \
- Doc.addSubNode(NAME);
+ void Visit##CLASS(CLASS* T) { \
+ Doc.addSubNode(NAME);
#define ID_ATTRIBUTE_XML // done by the Document class itself
-#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, T->FN);
+#define ATTRIBUTE_XML( FN, NAME ) Doc.addAttribute(NAME, T->FN);
#define TYPE_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "type")
#define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context")
-#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, T->FN);
+#define ATTRIBUTE_OPT_XML( FN, NAME ) Doc.addAttributeOptional(NAME, T->FN);
#define ATTRIBUTE_ENUM_XML( FN, NAME ) \
{ \
const char* pAttributeName = NAME; \
const bool optional = false; \
switch (T->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME ) \
{ \
const char* pAttributeName = NAME; \
const bool optional = true; \
switch (T->FN) { \
- default: assert(0 && "unknown enum value");
+ default: assert(0 && "unknown enum value");
#define ENUM_XML( VALUE, NAME ) case VALUE: if ((!optional) || NAME[0]) Doc.addAttribute(pAttributeName, NAME); break;
#define END_ENUM_XML } }
@@ -62,22 +60,19 @@ public:
};
-//---------------------------------------------------------
+//---------------------------------------------------------
} // anon clang
} // NS XML
-//---------------------------------------------------------
-class DocumentXML::TypeAdder : public TypeVisitor<DocumentXML::TypeAdder>
-{
+//---------------------------------------------------------
+class DocumentXML::TypeAdder : public TypeVisitor<DocumentXML::TypeAdder> {
DocumentXML& Doc;
- void addIfType(const Type* pType)
- {
+ void addIfType(const Type* pType) {
Doc.addTypeRecursively(pType);
}
- void addIfType(const QualType& pType)
- {
+ void addIfType(const QualType& pType) {
Doc.addTypeRecursively(pType);
}
@@ -88,40 +83,37 @@ public:
#define NODE_XML( CLASS, NAME ) \
void Visit##CLASS(CLASS* T) \
- {
-
-#define ID_ATTRIBUTE_XML
-#define TYPE_ATTRIBUTE_XML( FN ) Doc.addTypeRecursively(T->FN);
-#define CONTEXT_ATTRIBUTE_XML( FN )
-#define ATTRIBUTE_XML( FN, NAME ) addIfType(T->FN);
-#define ATTRIBUTE_OPT_XML( FN, NAME )
-#define ATTRIBUTE_ENUM_XML( FN, NAME )
-#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME )
-#define ENUM_XML( VALUE, NAME )
-#define END_ENUM_XML
+ {
+
+#define ID_ATTRIBUTE_XML
+#define TYPE_ATTRIBUTE_XML( FN ) Doc.addTypeRecursively(T->FN);
+#define CONTEXT_ATTRIBUTE_XML( FN )
+#define ATTRIBUTE_XML( FN, NAME ) addIfType(T->FN);
+#define ATTRIBUTE_OPT_XML( FN, NAME )
+#define ATTRIBUTE_ENUM_XML( FN, NAME )
+#define ATTRIBUTE_ENUM_OPT_XML( FN, NAME )
+#define ENUM_XML( VALUE, NAME )
+#define END_ENUM_XML
#define END_NODE_XML }
#include "clang/Frontend/TypeXML.def"
};
-//---------------------------------------------------------
-void DocumentXML::addParentTypes(const Type* pType)
-{
+//---------------------------------------------------------
+void DocumentXML::addParentTypes(const Type* pType) {
TypeAdder(*this).Visit(const_cast<Type*>(pType));
}
-//---------------------------------------------------------
-void DocumentXML::writeTypeToXML(const Type* pType)
-{
+//---------------------------------------------------------
+void DocumentXML::writeTypeToXML(const Type* pType) {
XML::TypeWriter(*this).Visit(const_cast<Type*>(pType));
}
-//---------------------------------------------------------
-void DocumentXML::writeTypeToXML(const QualType& pType)
-{
+//---------------------------------------------------------
+void DocumentXML::writeTypeToXML(const QualType& pType) {
XML::TypeWriter(*this).VisitQualType(const_cast<QualType*>(&pType));
}
-//---------------------------------------------------------
+//---------------------------------------------------------
} // NS clang
diff --git a/lib/Frontend/Warnings.cpp b/lib/Frontend/Warnings.cpp
index 87178e93b4..7b01b0fb74 100644
--- a/lib/Frontend/Warnings.cpp
+++ b/lib/Frontend/Warnings.cpp
@@ -47,7 +47,7 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Warn);
else
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore);
-
+
// FIXME: -Wfatal-errors / -Wfatal-errors=foo
for (unsigned i = 0, e = Warnings.size(); i != e; ++i) {
@@ -55,7 +55,7 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
const char *OptStart = &Opt[0];
const char *OptEnd = OptStart+Opt.size();
assert(*OptEnd == 0 && "Expect null termination for lower-bound search");
-
+
// Check to see if this warning starts with "no-", if so, this is a negative
// form of the option.
bool isPositive = true;
@@ -74,7 +74,7 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
Diags.setSuppressSystemWarnings(!isPositive);
continue;
}
-
+
// -Werror/-Wno-error is a special case, not controlled by the option table.
// It also has the "specifier" form of -Werror=foo and -Werror-foo.
if (OptEnd-OptStart >= 5 && memcmp(OptStart, "error", 5) == 0) {
@@ -88,21 +88,21 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
}
Specifier = OptStart+6;
}
-
+
if (Specifier == 0) {
Diags.setWarningsAsErrors(isPositive);
continue;
}
-
+
// -Werror=foo maps foo to Error, -Wno-error=foo maps it to Warning.
Mapping = isPositive ? diag::MAP_ERROR : diag::MAP_WARNING_NO_WERROR;
OptStart = Specifier;
}
-
+
if (Diags.setDiagnosticGroupMapping(OptStart, Mapping))
Diags.Report(FullSourceLoc(), diag::warn_unknown_warning_option)
<< ("-W" + Opt);
}
-
+
return false;
}
diff --git a/lib/Headers/stdarg.h b/lib/Headers/stdarg.h
index c436ced97c..bbbaff93e2 100644
--- a/lib/Headers/stdarg.h
+++ b/lib/Headers/stdarg.h
@@ -34,7 +34,7 @@ typedef __builtin_va_list va_list;
/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode
* or -ansi is not specified, since it was not part of C90.
*/
-#define __va_copy(d,s) __builtin_va_copy(d,s)
+#define __va_copy(d,s) __builtin_va_copy(d,s)
#if __STDC_VERSION__ >= 199900L || !defined(__STRICT_ANSI__)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp
index f010a2bcc8..d6f5cc7cfb 100644
--- a/lib/Index/ASTLocation.cpp
+++ b/lib/Index/ASTLocation.cpp
@@ -32,7 +32,7 @@ static Decl *getDeclFromExpr(Stmt *E) {
return getDeclFromExpr(CE->getCallee());
if (CastExpr *CE = dyn_cast<CastExpr>(E))
return getDeclFromExpr(CE->getSubExpr());
-
+
return 0;
}
@@ -41,7 +41,7 @@ Decl *ASTLocation::getReferencedDecl() {
return 0;
if (isDecl())
return getDecl();
-
+
assert(getStmt());
return getDeclFromExpr(getStmt());
}
@@ -49,17 +49,17 @@ Decl *ASTLocation::getReferencedDecl() {
static bool isContainedInStatement(Stmt *Node, Stmt *Parent) {
assert(Node && Parent && "Passed null Node or Parent");
-
+
if (Node == Parent)
return true;
-
+
for (Stmt::child_iterator
I = Parent->child_begin(), E = Parent->child_end(); I != E; ++I) {
if (*I)
if (isContainedInStatement(Node, *I))
return true;
}
-
+
return false;
}
@@ -76,7 +76,7 @@ Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (!FD->isThisDeclarationADefinition())
return 0;
-
+
for (DeclContext::decl_iterator
I = FD->decls_begin(), E = FD->decls_end(); I != E; ++I) {
Decl *Child = FindImmediateParent(*I, Node);
@@ -138,7 +138,7 @@ void ASTLocation::print(llvm::raw_ostream &OS) const {
OS << "[Decl: " << getDecl()->getDeclKindName() << " ";
if (const NamedDecl *ND = dyn_cast<NamedDecl>(getDecl()))
OS << ND->getNameAsString();
-
+
if (getStmt()) {
ASTContext &Ctx = getDecl()->getASTContext();
OS << " | Stmt: " << getStmt()->getStmtClassName() << " ";
@@ -146,7 +146,7 @@ void ASTLocation::print(llvm::raw_ostream &OS) const {
}
OS << "] <";
-
+
SourceRange Range = getSourceRange();
SourceManager &SourceMgr = getDecl()->getASTContext().getSourceManager();
Range.getBegin().print(OS, SourceMgr);
diff --git a/lib/Index/Analyzer.cpp b/lib/Index/Analyzer.cpp
index 1dd2178ad4..cda2c505fd 100644
--- a/lib/Index/Analyzer.cpp
+++ b/lib/Index/Analyzer.cpp
@@ -36,11 +36,11 @@ namespace {
class VISIBILITY_HIDDEN DeclEntityAnalyzer : public TranslationUnitHandler {
Entity Ent;
TULocationHandler &TULocHandler;
-
+
public:
DeclEntityAnalyzer(Entity ent, TULocationHandler &handler)
: Ent(ent), TULocHandler(handler) { }
-
+
virtual void Handle(TranslationUnit *TU) {
assert(TU && "Passed null translation unit");
@@ -60,11 +60,11 @@ public:
class VISIBILITY_HIDDEN RefEntityAnalyzer : public TranslationUnitHandler {
Entity Ent;
TULocationHandler &TULocHandler;
-
+
public:
RefEntityAnalyzer(Entity ent, TULocationHandler &handler)
: Ent(ent), TULocHandler(handler) { }
-
+
virtual void Handle(TranslationUnit *TU) {
assert(TU && "Passed null translation unit");
@@ -115,12 +115,12 @@ public:
IFaceEnt = Entity::get(IFD, Prog);
GlobSel = GlobalSelector::get(MD->getSelector(), Prog);
IsInstanceMethod = MD->isInstanceMethod();
-
+
for (ObjCInterfaceDecl *Cls = IFD->getSuperClass();
Cls; Cls = Cls->getSuperClass())
HierarchyEntities.insert(Entity::get(Cls, Prog));
}
-
+
virtual void Handle(TranslationUnit *TU) {
assert(TU && "Passed null translation unit");
@@ -150,7 +150,7 @@ public:
// FIXME: Finding @selector references should be through another Analyzer
// method, like FindSelectors.
if (isa<ObjCSelectorExpr>(ASTLoc.getStmt()))
- return false;
+ return false;
ObjCInterfaceDecl *MsgD = 0;
ObjCMessageExpr *Msg = cast<ObjCMessageExpr>(ASTLoc.getStmt());
@@ -181,7 +181,7 @@ public:
MsgD = Msg->getClassInfo().first;
// FIXME: Case when we only have an identifier.
- assert(MsgD && "Identifier only");
+ assert(MsgD && "Identifier only");
}
assert(MsgD);
@@ -233,7 +233,7 @@ class VISIBILITY_HIDDEN MessageAnalyzer : public TranslationUnitHandler {
/// \brief Super classes of the ObjCInterface.
typedef llvm::SmallSet<Entity, 16> EntitiesSetTy;
EntitiesSetTy HierarchyEntities;
-
+
/// \brief The interface in the message interface hierarchy that "intercepts"
/// the selector.
Entity ReceiverIFaceEnt;
@@ -254,7 +254,7 @@ public:
CanBeClassMethod = true;
MsgD = Msg->getClassInfo().first;
// FIXME: Case when we only have an identifier.
- assert(MsgD && "Identifier only");
+ assert(MsgD && "Identifier only");
break;
}
@@ -276,7 +276,7 @@ public:
CanBeInstanceMethod = true;
break;
}
-
+
assert(CanBeInstanceMethod || CanBeClassMethod);
Selector sel = Msg->getSelector();
@@ -304,7 +304,7 @@ public:
break;
}
}
-
+
if (isReceiver) {
ReceiverIFaceEnt = Entity::get(Cls, Prog);
break;
@@ -312,7 +312,7 @@ public:
}
}
}
-
+
virtual void Handle(TranslationUnit *TU) {
assert(TU && "Passed null translation unit");
ASTContext &Ctx = TU->getASTContext();
@@ -406,7 +406,7 @@ void Analyzer::FindDeclarations(Decl *D, TULocationHandler &Handler) {
Entity Ent = Entity::get(D, Prog);
if (Ent.isInvalid())
return;
-
+
DeclEntityAnalyzer DEA(Ent, Handler);
Idxer.GetTranslationUnitsFor(Ent, DEA);
}
@@ -423,7 +423,7 @@ void Analyzer::FindReferences(Decl *D, TULocationHandler &Handler) {
Entity Ent = Entity::get(D, Prog);
if (Ent.isInvalid())
return;
-
+
RefEntityAnalyzer REA(Ent, Handler);
Idxer.GetTranslationUnitsFor(Ent, REA);
}
diff --git a/lib/Index/DeclReferenceMap.cpp b/lib/Index/DeclReferenceMap.cpp
index 1e6ae21a64..0aee2a40ec 100644
--- a/lib/Index/DeclReferenceMap.cpp
+++ b/lib/Index/DeclReferenceMap.cpp
@@ -63,16 +63,16 @@ DeclReferenceMap::DeclReferenceMap(ASTContext &Ctx) {
DeclReferenceMap::astlocation_iterator
DeclReferenceMap::refs_begin(NamedDecl *D) const {
NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return astlocation_iterator(Map.lower_bound(Prim));
+ return astlocation_iterator(Map.lower_bound(Prim));
}
DeclReferenceMap::astlocation_iterator
DeclReferenceMap::refs_end(NamedDecl *D) const {
NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return astlocation_iterator(Map.upper_bound(Prim));
+ return astlocation_iterator(Map.upper_bound(Prim));
}
bool DeclReferenceMap::refs_empty(NamedDecl *D) const {
NamedDecl *Prim = cast<NamedDecl>(D->getCanonicalDecl());
- return refs_begin(Prim) == refs_end(Prim);
+ return refs_begin(Prim) == refs_end(Prim);
}
diff --git a/lib/Index/Entity.cpp b/lib/Index/Entity.cpp
index 245fc9a555..77d7a84da4 100644
--- a/lib/Index/Entity.cpp
+++ b/lib/Index/Entity.cpp
@@ -41,10 +41,10 @@ class EntityGetter : public DeclVisitor<EntityGetter, Entity> {
public:
EntityGetter(Program &prog, ProgramImpl &progImpl)
: Prog(prog), ProgImpl(progImpl) { }
-
+
Entity VisitNamedDecl(NamedDecl *D);
Entity VisitVarDecl(VarDecl *D);
- Entity VisitFunctionDecl(FunctionDecl *D);
+ Entity VisitFunctionDecl(FunctionDecl *D);
};
}
@@ -80,12 +80,12 @@ Entity EntityGetter::VisitNamedDecl(NamedDecl *D) {
// Treats other DeclarationNames as internal Decls for now..
if (LocalSel.isNull())
return Entity(D);
-
+
Selector GlobSel =
(uintptr_t)GlobalSelector::get(LocalSel, Prog).getAsOpaquePtr();
GlobName = DeclarationName(GlobSel);
}
-
+
assert(GlobName);
unsigned IdNS = D->getIdentifierNamespace();
@@ -105,7 +105,7 @@ Entity EntityGetter::VisitNamedDecl(NamedDecl *D) {
EntityImpl *New =
new (Buf) EntityImpl(Parent, GlobName, IdNS, isObjCInstanceMethod);
Entities.InsertNode(New, InsertPos);
-
+
return Entity(New);
}
@@ -113,7 +113,7 @@ Entity EntityGetter::VisitVarDecl(VarDecl *D) {
// If it's static it cannot be referred to by another translation unit.
if (D->getStorageClass() == VarDecl::Static)
return Entity(D);
-
+
return VisitNamedDecl(D);
}
@@ -121,7 +121,7 @@ Entity EntityGetter::VisitFunctionDecl(FunctionDecl *D) {
// If it's static it cannot be refered to by another translation unit.
if (D->getStorageClass() == FunctionDecl::Static)
return Entity(D);
-
+
return VisitNamedDecl(D);
}
@@ -188,18 +188,18 @@ Entity::Entity(Decl *D) : Val(D->getCanonicalDecl()) { }
Decl *Entity::getDecl(ASTContext &AST) const {
if (isInvalid())
return 0;
-
+
if (Decl *D = Val.dyn_cast<Decl *>())
// Check that the passed AST is actually the one that this Decl belongs to.
return (&D->getASTContext() == &AST) ? D : 0;
-
+
return Val.get<EntityImpl *>()->getDecl(AST);
}
std::string Entity::getPrintableName() const {
if (isInvalid())
return "<< Invalid >>";
-
+
if (Decl *D = Val.dyn_cast<Decl *>()) {
if (NamedDecl *ND = dyn_cast<NamedDecl>(D))
return ND->getNameAsString();
@@ -219,7 +219,7 @@ Entity Entity::get(Decl *D, Program &Prog) {
return EntityImpl::get(D, Prog, ProgImpl);
}
-unsigned
+unsigned
llvm::DenseMapInfo<Entity>::getHashValue(Entity E) {
return DenseMapInfo<void*>::getHashValue(E.getAsOpaquePtr());
}
diff --git a/lib/Index/EntityImpl.h b/lib/Index/EntityImpl.h
index b4a883a3bf..cbce934bf7 100644
--- a/lib/Index/EntityImpl.h
+++ b/lib/Index/EntityImpl.h
@@ -30,7 +30,7 @@ class EntityImpl : public llvm::FoldingSetNode {
/// \brief Identifier namespace.
unsigned IdNS;
-
+
/// \brief If Name is a selector, this keeps track whether it's for an
/// instance method.
bool IsObjCInstanceMethod;
@@ -47,7 +47,7 @@ public:
/// \brief Get an Entity associated with the given Decl.
/// \returns Null if an Entity cannot refer to this Decl.
static Entity get(Decl *D, Program &Prog, ProgramImpl &ProgImpl);
-
+
std::string getPrintableName();
void Profile(llvm::FoldingSetNodeID &ID) const {
diff --git a/lib/Index/GlobalSelector.cpp b/lib/Index/GlobalSelector.cpp
index a1ec929901..f3ec41d44f 100644
--- a/lib/Index/GlobalSelector.cpp
+++ b/lib/Index/GlobalSelector.cpp
@@ -41,7 +41,7 @@ Selector GlobalSelector::getSelector(ASTContext &AST) const {
std::string GlobalSelector::getPrintableName() const {
if (isInvalid())
return "<< Invalid >>";
-
+
Selector GlobSel = Selector(reinterpret_cast<uintptr_t>(Val));
return GlobSel.getAsString();
}
@@ -67,7 +67,7 @@ GlobalSelector GlobalSelector::get(Selector Sel, Program &Prog) {
return GlobalSelector(GlobSel.getAsOpaquePtr());
}
-unsigned
+unsigned
llvm::DenseMapInfo<GlobalSelector>::getHashValue(GlobalSelector Sel) {
return DenseMapInfo<void*>::getHashValue(Sel.getAsOpaquePtr());
}
diff --git a/lib/Index/Indexer.cpp b/lib/Index/Indexer.cpp
index 75dfbd584c..57bfc5b4fb 100644
--- a/lib/Index/Indexer.cpp
+++ b/lib/Index/Indexer.cpp
@@ -25,7 +25,7 @@ namespace {
class EntityIndexer : public EntityHandler {
TranslationUnit *TU;
Indexer::MapTy &Map;
-
+
public:
EntityIndexer(TranslationUnit *tu, Indexer::MapTy &map) : TU(tu), Map(map) { }
@@ -64,7 +64,7 @@ void Indexer::IndexAST(TranslationUnit *TU) {
CtxTUMap[&Ctx] = TU;
EntityIndexer Idx(TU, Map);
Prog.FindEntities(Ctx, Idx);
-
+
SelectorIndexer SelIdx(Prog, TU, SelMap);
SelIdx.Visit(Ctx.getTranslationUnitDecl());
}
@@ -84,7 +84,7 @@ void Indexer::GetTranslationUnitsFor(Entity Ent,
MapTy::iterator I = Map.find(Ent);
if (I == Map.end())
return;
-
+
TUSetTy &Set = I->second;
for (TUSetTy::iterator I = Set.begin(), E = Set.end(); I != E; ++I)
Handler.Handle(*I);
@@ -97,7 +97,7 @@ void Indexer::GetTranslationUnitsFor(GlobalSelector Sel,
SelMapTy::iterator I = SelMap.find(Sel);
if (I == SelMap.end())
return;
-
+
TUSetTy &Set = I->second;
for (TUSetTy::iterator I = Set.begin(), E = Set.end(); I != E; ++I)
Handler.Handle(*I);
diff --git a/lib/Index/ProgramImpl.h b/lib/Index/ProgramImpl.h
index 1fbff9b325..57b9ce3115 100644
--- a/lib/Index/ProgramImpl.h
+++ b/lib/Index/ProgramImpl.h
@@ -30,16 +30,16 @@ public:
private:
EntitySetTy Entities;
llvm::BumpPtrAllocator BumpAlloc;
-
+
IdentifierTable Identifiers;
SelectorTable Selectors;
ProgramImpl(const ProgramImpl&); // do not implement
ProgramImpl &operator=(const ProgramImpl &); // do not implement
-
+
public:
ProgramImpl() : Identifiers(LangOptions()) { }
-
+
EntitySetTy &getEntities() { return Entities; }
IdentifierTable &getIdents() { return Identifiers; }
SelectorTable &getSelectors() { return Selectors; }
diff --git a/lib/Index/ResolveLocation.cpp b/lib/Index/ResolveLocation.cpp
index ce8512ddf3..281f4d9df1 100644
--- a/lib/Index/ResolveLocation.cpp
+++ b/lib/Index/ResolveLocation.cpp
@@ -119,7 +119,7 @@ StmtLocResolver::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
Nodes.push_back(Node->getArg(0));
Nodes.push_back(Node->getCallee());
Nodes.push_back(Node->getArg(1));
-
+
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
RangePos RP = CheckRange(Nodes[i]);
if (RP == AfterLoc)
@@ -201,9 +201,9 @@ ASTLocation DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {
if (RP == ContainsLoc)
return Visit(*I);
}
-
+
// We didn't find the location in the parameters and we didn't get passed it.
-
+
if (!D->isThisDeclarationADefinition())
return ASTLocation(D);
@@ -214,7 +214,7 @@ ASTLocation DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {
I = D->decls_begin(), E = D->decls_end(); I != E; ++I) {
if (isa<ParmVarDecl>(*I))
continue; // We already searched through the parameters.
-
+
RangePos RP = CheckRange(*I);
if (RP == AfterLoc)
break;
@@ -223,7 +223,7 @@ ASTLocation DeclLocResolver::VisitFunctionDecl(FunctionDecl *D) {
}
// We didn't find a declaration that corresponds to the source location.
-
+
// Finally, search through the body of the function.
Stmt *Body = D->getBody();
assert(Body && "Expected definition");
@@ -325,10 +325,10 @@ LocResolverBase::RangePos LocResolverBase::CheckRange(SourceRange Range) {
Ctx.getLangOptions());
Range.setEnd(Range.getEnd().getFileLocWithOffset(TokSize-1));
- SourceManager &SourceMgr = Ctx.getSourceManager();
+ SourceManager &SourceMgr = Ctx.getSourceManager();
if (SourceMgr.isBeforeInTranslationUnit(Range.getEnd(), Loc))
return BeforeLoc;
-
+
if (SourceMgr.isBeforeInTranslationUnit(Loc, Range.getBegin()))
return AfterLoc;
@@ -367,6 +367,6 @@ void LocResolverBase::print(Stmt *Node) {
ASTLocation idx::ResolveLocationInAST(ASTContext &Ctx, SourceLocation Loc) {
if (Loc.isInvalid())
return ASTLocation();
-
+
return DeclLocResolver(Ctx, Loc).Visit(Ctx.getTranslationUnitDecl());
}
diff --git a/lib/Lex/HeaderMap.cpp b/lib/Lex/HeaderMap.cpp
index 4c8b70eb78..c9a10dc027 100644
--- a/lib/Lex/HeaderMap.cpp
+++ b/lib/Lex/HeaderMap.cpp
@@ -28,8 +28,8 @@ using namespace clang;
enum {
HMAP_HeaderMagicNumber = ('h' << 24) | ('m' << 16) | ('a' << 8) | 'p',
HMAP_HeaderVersion = 1,
-
- HMAP_EmptyBucketKey = 0
+
+ HMAP_EmptyBucketKey = 0
};
namespace clang {
@@ -58,7 +58,7 @@ struct HMapHeader {
/// linear probing based on this function.
static inline unsigned HashHMapKey(const char *S, const char *End) {
unsigned Result = 0;
-
+
for (; S != End; S++)
Result += tolower(*S) * 13;
return Result;
@@ -78,27 +78,27 @@ const HeaderMap *HeaderMap::Create(const FileEntry *FE) {
// If the file is too small to be a header map, ignore it.
unsigned FileSize = FE->getSize();
if (FileSize <= sizeof(HMapHeader)) return 0;
-
- llvm::OwningPtr<const llvm::MemoryBuffer> FileBuffer(
+
+ llvm::OwningPtr<const llvm::MemoryBuffer> FileBuffer(
llvm::MemoryBuffer::getFile(FE->getName(), 0, FE->getSize()));
if (FileBuffer == 0) return 0; // Unreadable file?
const char *FileStart = FileBuffer->getBufferStart();
// We know the file is at least as big as the header, check it now.
const HMapHeader *Header = reinterpret_cast<const HMapHeader*>(FileStart);
-
+
// Sniff it to see if it's a headermap by checking the magic number and
// version.
bool NeedsByteSwap;
- if (Header->Magic == HMAP_HeaderMagicNumber &&
+ if (Header->Magic == HMAP_HeaderMagicNumber &&
Header->Version == HMAP_HeaderVersion)
NeedsByteSwap = false;
else if (Header->Magic == llvm::ByteSwap_32(HMAP_HeaderMagicNumber) &&
Header->Version == llvm::ByteSwap_16(HMAP_HeaderVersion))
NeedsByteSwap = true; // Mixed endianness headermap.
- else
+ else
return 0; // Not a header map.
-
+
if (Header->Reserved != 0) return 0;
// Okay, everything looks good, create the header map.
@@ -137,11 +137,11 @@ const HMapHeader &HeaderMap::getHeader() const {
HMapBucket HeaderMap::getBucket(unsigned BucketNo) const {
HMapBucket Result;
Result.Key = HMAP_EmptyBucketKey;
-
- const HMapBucket *BucketArray =
+
+ const HMapBucket *BucketArray =
reinterpret_cast<const HMapBucket*>(FileBuffer->getBufferStart() +
sizeof(HMapHeader));
-
+
const HMapBucket *BucketPtr = BucketArray+BucketNo;
if ((char*)(BucketPtr+1) > FileBuffer->getBufferEnd()) {
Result.Prefix = 0;
@@ -161,11 +161,11 @@ HMapBucket HeaderMap::getBucket(unsigned BucketNo) const {
const char *HeaderMap::getString(unsigned StrTabIdx) const {
// Add the start of the string table to the idx.
StrTabIdx += getEndianAdjustedWord(getHeader().StringsOffset);
-
+
// Check for invalid index.
if (StrTabIdx >= FileBuffer->getBufferSize())
return 0;
-
+
// Otherwise, we have a valid pointer into the file. Just return it. We know
// that the "string" can not overrun the end of the file, because the buffer
// is nul terminated by virtue of being a MemoryBuffer.
@@ -191,15 +191,15 @@ static bool StringsEqualWithoutCase(const char *S1, const char *S2,
void HeaderMap::dump() const {
const HMapHeader &Hdr = getHeader();
unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
-
- fprintf(stderr, "Header Map %s:\n %d buckets, %d entries\n",
+
+ fprintf(stderr, "Header Map %s:\n %d buckets, %d entries\n",
getFileName(), NumBuckets,
getEndianAdjustedWord(Hdr.NumEntries));
-
+
for (unsigned i = 0; i != NumBuckets; ++i) {
HMapBucket B = getBucket(i);
if (B.Key == HMAP_EmptyBucketKey) continue;
-
+
const char *Key = getString(B.Key);
const char *Prefix = getString(B.Prefix);
const char *Suffix = getString(B.Suffix);
@@ -219,22 +219,22 @@ const FileEntry *HeaderMap::LookupFile(const char *FilenameStart,
// Don't probe infinitely.
if (NumBuckets & (NumBuckets-1))
return 0;
-
+
// Linearly probe the hash table.
for (unsigned Bucket = HashHMapKey(FilenameStart, FilenameEnd);; ++Bucket) {
HMapBucket B = getBucket(Bucket & (NumBuckets-1));
if (B.Key == HMAP_EmptyBucketKey) return 0; // Hash miss.
-
+
// See if the key matches. If not, probe on.
const char *Key = getString(B.Key);
unsigned BucketKeyLen = strlen(Key);
if (BucketKeyLen != unsigned(FilenameEnd-FilenameStart))
continue;
-
+
// See if the actual strings equal.
if (!StringsEqualWithoutCase(FilenameStart, Key, BucketKeyLen))
continue;
-
+
// If so, we have a match in the hash table. Construct the destination
// path.
llvm::SmallString<1024> DestPath;
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index 9023b11022..2b9b7c977c 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -35,7 +35,7 @@ HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) {
HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) {
SystemDirIdx = 0;
NoCurDirSearch = false;
-
+
ExternalLookup = 0;
NumIncluded = 0;
NumMultiIncludeFileOptzn = 0;
@@ -47,7 +47,7 @@ HeaderSearch::~HeaderSearch() {
for (unsigned i = 0, e = HeaderMaps.size(); i != e; ++i)
delete HeaderMaps[i].second;
}
-
+
void HeaderSearch::PrintStats() {
fprintf(stderr, "\n*** HeaderSearch Stats:\n");
fprintf(stderr, "%d files tracked.\n", (int)FileInfo.size());
@@ -61,11 +61,11 @@ void HeaderSearch::PrintStats() {
fprintf(stderr, " %d #import/#pragma once files.\n", NumOnceOnlyFiles);
fprintf(stderr, " %d included exactly once.\n", NumSingleIncludedFiles);
fprintf(stderr, " %d max times a file is included.\n", MaxNumIncludes);
-
+
fprintf(stderr, " %d #include/#include_next/#import.\n", NumIncluded);
fprintf(stderr, " %d #includes skipped due to"
" the multi-include optimization.\n", NumMultiIncludeFileOptzn);
-
+
fprintf(stderr, "%d framework lookups.\n", NumFrameworkLookups);
fprintf(stderr, "%d subframework lookups.\n", NumSubFrameworkLookups);
}
@@ -79,15 +79,15 @@ const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) {
for (unsigned i = 0, e = HeaderMaps.size(); i != e; ++i)
// Pointer equality comparison of FileEntries works because they are
// already uniqued by inode.
- if (HeaderMaps[i].first == FE)
+ if (HeaderMaps[i].first == FE)
return HeaderMaps[i].second;
}
-
+
if (const HeaderMap *HM = HeaderMap::Create(FE)) {
HeaderMaps.push_back(std::make_pair(FE, HM));
return HM;
}
-
+
return 0;
}
@@ -121,10 +121,10 @@ const FileEntry *DirectoryLookup::LookupFile(const char *FilenameStart,
TmpDir.append(FilenameStart, FilenameEnd);
return HS.getFileMgr().getFile(TmpDir.begin(), TmpDir.end());
}
-
+
if (isFramework())
return DoFrameworkLookup(FilenameStart, FilenameEnd, HS);
-
+
assert(isHeaderMap() && "Unknown directory lookup");
return getHeaderMap()->LookupFile(FilenameStart, FilenameEnd,HS.getFileMgr());
}
@@ -136,63 +136,63 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(const char *FilenameStart,
const char *FilenameEnd,
HeaderSearch &HS) const {
FileManager &FileMgr = HS.getFileMgr();
-
+
// Framework names must have a '/' in the filename.
const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/');
if (SlashPos == FilenameEnd) return 0;
-
+
// Find out if this is the home for the specified framework, by checking
// HeaderSearch. Possible answer are yes/no and unknown.
- const DirectoryEntry *&FrameworkDirCache =
+ const DirectoryEntry *&FrameworkDirCache =
HS.LookupFrameworkCache(FilenameStart, SlashPos);
-
+
// If it is known and in some other directory, fail.
if (FrameworkDirCache && FrameworkDirCache != getFrameworkDir())
return 0;
-
+
// Otherwise, construct the path to this framework dir.
-
+
// FrameworkName = "/System/Library/Frameworks/"
llvm::SmallString<1024> FrameworkName;
FrameworkName += getFrameworkDir()->getName();
if (FrameworkName.empty() || FrameworkName.back() != '/')
FrameworkName.push_back('/');
-
+
// FrameworkName = "/System/Library/Frameworks/Cocoa"
FrameworkName.append(FilenameStart, SlashPos);
-
+
// FrameworkName = "/System/Library/Frameworks/Cocoa.framework/"
FrameworkName += ".framework/";
-
+
// If the cache entry is still unresolved, query to see if the cache entry is
// still unresolved. If so, check its existence now.
if (FrameworkDirCache == 0) {
HS.IncrementFrameworkLookupCount();
-
+
// If the framework dir doesn't exist, we fail.
// FIXME: It's probably more efficient to query this with FileMgr.getDir.
- if (!llvm::sys::Path(std::string(FrameworkName.begin(),
+ if (!llvm::sys::Path(std::string(FrameworkName.begin(),
FrameworkName.end())).exists())
return 0;
-
+
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
FrameworkDirCache = getFrameworkDir();
}
-
+
// Check "/System/Library/Frameworks/Cocoa.framework/Headers/file.h"
unsigned OrigSize = FrameworkName.size();
-
+
FrameworkName += "Headers/";
FrameworkName.append(SlashPos+1, FilenameEnd);
if (const FileEntry *FE = FileMgr.getFile(FrameworkName.begin(),
FrameworkName.end())) {
return FE;
}
-
+
// Check "/System/Library/Frameworks/Cocoa.framework/PrivateHeaders/file.h"
const char *Private = "Private";
- FrameworkName.insert(FrameworkName.begin()+OrigSize, Private,
+ FrameworkName.insert(FrameworkName.begin()+OrigSize, Private,
Private+strlen(Private));
return FileMgr.getFile(FrameworkName.begin(), FrameworkName.end());
}
@@ -209,7 +209,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup(const char *FilenameStart,
/// non-null, indicates where the #including file is, in case a relative search
/// is needed.
const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart,
- const char *FilenameEnd,
+ const char *FilenameEnd,
bool isAngled,
const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir,
@@ -220,11 +220,11 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart,
// If this was an #include_next "/absolute/file", fail.
if (FromDir) return 0;
-
+
// Otherwise, just return the file.
return FileMgr.getFile(FilenameStart, FilenameEnd);
}
-
+
// Step #0, unless disabled, check to see if the file is in the #includer's
// directory. This has to be based on CurFileEnt, not CurDir, because
// CurFileEnt could be a #include of a subdirectory (#include "foo/bar.h") and
@@ -249,17 +249,17 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart,
return FE;
}
}
-
+
CurDir = 0;
// If this is a system #include, ignore the user #include locs.
unsigned i = isAngled ? SystemDirIdx : 0;
-
+
// If this is a #include_next request, start searching after the directory the
// file was found in.
if (FromDir)
i = FromDir-&SearchDirs[0];
-
+
// Cache all of the lookups performed by this method. Many headers are
// multiply included, and the "pragma once" optimization prevents them from
// being relex/pp'd, but they would still have to search through a
@@ -279,23 +279,23 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart,
// start point value.
CacheLookup.first = i+1;
}
-
+
// Check each directory in sequence to see if it contains this file.
for (; i != SearchDirs.size(); ++i) {
- const FileEntry *FE =
+ const FileEntry *FE =
SearchDirs[i].LookupFile(FilenameStart, FilenameEnd, *this);
if (!FE) continue;
-
+
CurDir = &SearchDirs[i];
-
+
// This file is a system header or C++ unfriendly if the dir is.
getFileInfo(FE).DirInfo = CurDir->getDirCharacteristic();
-
+
// Remember this location for the next lookup we do.
CacheLookup.second = i;
return FE;
}
-
+
// Otherwise, didn't find it. Remember we didn't find this.
CacheLookup.second = SearchDirs.size();
return 0;
@@ -311,20 +311,20 @@ LookupSubframeworkHeader(const char *FilenameStart,
const char *FilenameEnd,
const FileEntry *ContextFileEnt) {
assert(ContextFileEnt && "No context file?");
-
+
// Framework names must have a '/' in the filename. Find it.
const char *SlashPos = std::find(FilenameStart, FilenameEnd, '/');
if (SlashPos == FilenameEnd) return 0;
-
+
// Look up the base framework name of the ContextFileEnt.
const char *ContextName = ContextFileEnt->getName();
-
+
// If the context info wasn't a framework, couldn't be a subframework.
const char *FrameworkPos = strstr(ContextName, ".framework/");
if (FrameworkPos == 0)
return 0;
-
- llvm::SmallString<1024> FrameworkName(ContextName,
+
+ llvm::SmallString<1024> FrameworkName(ContextName,
FrameworkPos+strlen(".framework/"));
// Append Frameworks/HIToolbox.framework/
@@ -334,28 +334,28 @@ LookupSubframeworkHeader(const char *FilenameStart,
llvm::StringMapEntry<const DirectoryEntry *> &CacheLookup =
FrameworkMap.GetOrCreateValue(FilenameStart, SlashPos);
-
+
// Some other location?
if (CacheLookup.getValue() &&
CacheLookup.getKeyLength() == FrameworkName.size() &&
memcmp(CacheLookup.getKeyData(), &FrameworkName[0],
CacheLookup.getKeyLength()) != 0)
return 0;
-
+
// Cache subframework.
if (CacheLookup.getValue() == 0) {
++NumSubFrameworkLookups;
-
+
// If the framework dir doesn't exist, we fail.
const DirectoryEntry *Dir = FileMgr.getDirectory(FrameworkName.begin(),
FrameworkName.end());
if (Dir == 0) return 0;
-
+
// Otherwise, if it does, remember that this is the right direntry for this
// framework.
CacheLookup.setValue(Dir);
}
-
+
const FileEntry *FE = 0;
// Check ".../Frameworks/HIToolbox.framework/Headers/HIToolbox.h"
@@ -364,7 +364,7 @@ LookupSubframeworkHeader(const char *FilenameStart,
HeadersFilename.append(SlashPos+1, FilenameEnd);
if (!(FE = FileMgr.getFile(HeadersFilename.begin(),
HeadersFilename.end()))) {
-
+
// Check ".../Frameworks/HIToolbox.framework/PrivateHeaders/HIToolbox.h"
HeadersFilename = FrameworkName;
HeadersFilename += "PrivateHeaders/";
@@ -372,7 +372,7 @@ LookupSubframeworkHeader(const char *FilenameStart,
if (!(FE = FileMgr.getFile(HeadersFilename.begin(), HeadersFilename.end())))
return 0;
}
-
+
// This file is a system header or C++ unfriendly if the old file is.
//
// Note that the temporary 'DirInfo' is required here, as either call to
@@ -394,7 +394,7 @@ HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
if (FE->getUID() >= FileInfo.size())
FileInfo.resize(FE->getUID()+1);
return FileInfo[FE->getUID()];
-}
+}
void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) {
if (UID >= FileInfo.size())
@@ -410,13 +410,13 @@ bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
// Get information about this file.
HeaderFileInfo &FileInfo = getFileInfo(File);
-
+
// If this is a #import directive, check that we have not already imported
// this header.
if (isImport) {
// If this has already been imported, don't import it again.
FileInfo.isImport = true;
-
+
// Has this already been #import'ed or #include'd?
if (FileInfo.NumIncludes) return false;
} else {
@@ -425,19 +425,19 @@ bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){
if (FileInfo.isImport)
return false;
}
-
+
// Next, check to see if the file is wrapped with #ifndef guards. If so, and
// if the macro that guards it is defined, we know the #include has no effect.
- if (const IdentifierInfo *ControllingMacro
+ if (const IdentifierInfo *ControllingMacro
= FileInfo.getControllingMacro(ExternalLookup))
if (ControllingMacro->hasMacroDefinition()) {
++NumMultiIncludeFileOptzn;
return false;
}
-
+
// Increment the number of times this file has been included.
++FileInfo.NumIncludes;
-
+
return true;
}
diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp
index 974b6900b7..23ba6e1ca7 100644
--- a/lib/Lex/Lexer.cpp
+++ b/lib/Lex/Lexer.cpp
@@ -39,7 +39,7 @@ static void InitCharacterInfo();
// Token Class Implementation
//===----------------------------------------------------------------------===//
-/// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
+/// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.
bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const {
if (IdentifierInfo *II = getIdentifierInfo())
return II->getObjCKeywordID() == objcKey;
@@ -57,35 +57,35 @@ tok::ObjCKeywordKind Token::getObjCKeywordID() const {
// Lexer Class Implementation
//===----------------------------------------------------------------------===//
-void Lexer::InitLexer(const char *BufStart, const char *BufPtr,
+void Lexer::InitLexer(const char *BufStart, const char *BufPtr,
const char *BufEnd) {
InitCharacterInfo();
-
+
BufferStart = BufStart;
BufferPtr = BufPtr;
BufferEnd = BufEnd;
-
+
assert(BufEnd[0] == 0 &&
"We assume that the input buffer has a null character at the end"
" to simplify lexing!");
-
+
Is_PragmaLexer = false;
// Start of the file is a start of line.
IsAtStartOfLine = true;
-
+
// We are not after parsing a #.
ParsingPreprocessorDirective = false;
-
+
// We are not after parsing #include.
ParsingFilename = false;
-
+
// We are not in raw mode. Raw mode disables diagnostics and interpretation
// of tokens (e.g. identifiers, thus disabling macro expansion). It is used
// to quickly lex the tokens of the buffer, e.g. when handling a "#if 0" block
// or otherwise skipping over tokens.
LexingRawMode = false;
-
+
// Default to not keeping comments.
ExtendedTokenMode = 0;
}
@@ -98,12 +98,12 @@ Lexer::Lexer(FileID FID, Preprocessor &PP)
: PreprocessorLexer(&PP, FID),
FileLoc(PP.getSourceManager().getLocForStartOfFile(FID)),
Features(PP.getLangOptions()) {
-
+
const llvm::MemoryBuffer *InputFile = PP.getSourceManager().getBuffer(FID);
-
+
InitLexer(InputFile->getBufferStart(), InputFile->getBufferStart(),
InputFile->getBufferEnd());
-
+
// Default to keeping comments if the preprocessor wants them.
SetCommentRetentionState(PP.getCommentRetentionState());
}
@@ -116,7 +116,7 @@ Lexer::Lexer(SourceLocation fileloc, const LangOptions &features,
: FileLoc(fileloc), Features(features) {
InitLexer(BufStart, BufPtr, BufEnd);
-
+
// We *are* in raw mode.
LexingRawMode = true;
}
@@ -128,9 +128,9 @@ Lexer::Lexer(FileID FID, const SourceManager &SM, const LangOptions &features)
: FileLoc(SM.getLocForStartOfFile(FID)), Features(features) {
const llvm::MemoryBuffer *FromFile = SM.getBuffer(FID);
- InitLexer(FromFile->getBufferStart(), FromFile->getBufferStart(),
+ InitLexer(FromFile->getBufferStart(), FromFile->getBufferStart(),
FromFile->getBufferEnd());
-
+
// We *are* in raw mode.
LexingRawMode = true;
}
@@ -150,7 +150,7 @@ Lexer::Lexer(FileID FID, const SourceManager &SM, const LangOptions &features)
/// interface that could handle this stuff. This would pull GetMappedTokenLoc
/// out of the critical path of the lexer!
///
-Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
+Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
SourceLocation InstantiationLocStart,
SourceLocation InstantiationLocEnd,
unsigned TokLen, Preprocessor &PP) {
@@ -159,12 +159,12 @@ Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
// Create the lexer as if we were going to lex the file normally.
FileID SpellingFID = SM.getFileID(SpellingLoc);
Lexer *L = new Lexer(SpellingFID, PP);
-
+
// Now that the lexer is created, change the start/end locations so that we
// just lex the subsection of the file that we want. This is lexing from a
// scratch buffer.
const char *StrData = SM.getCharacterData(SpellingLoc);
-
+
L->BufferPtr = StrData;
L->BufferEnd = StrData+TokLen;
assert(L->BufferEnd[0] == 0 && "Buffer is not nul terminated!");
@@ -174,11 +174,11 @@ Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
L->FileLoc = SM.createInstantiationLoc(SM.getLocForStartOfFile(SpellingFID),
InstantiationLocStart,
InstantiationLocEnd, TokLen);
-
+
// Ensure that the lexer thinks it is inside a directive, so that end \n will
// return an EOM token.
L->ParsingPreprocessorDirective = true;
-
+
// This lexer really is for _Pragma.
L->Is_PragmaLexer = true;
return L;
@@ -220,7 +220,7 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
const LangOptions &LangOpts) {
// TODO: this could be special cased for common tokens like identifiers, ')',
// etc to make this faster, if it mattered. Just look at StrData[0] to handle
- // all obviously single-char tokens. This could use
+ // all obviously single-char tokens. This could use
// Lexer::isObviouslySimpleCharacter for example to handle identifiers or
// something.
@@ -365,7 +365,7 @@ static inline bool isWhitespace(unsigned char c) {
/// isNumberBody - Return true if this is the body character of an
/// preprocessing number, which is [a-zA-Z0-9_.].
static inline bool isNumberBody(unsigned char c) {
- return (CharInfo[c] & (CHAR_LETTER|CHAR_NUMBER|CHAR_UNDER|CHAR_PERIOD)) ?
+ return (CharInfo[c] & (CHAR_LETTER|CHAR_NUMBER|CHAR_UNDER|CHAR_PERIOD)) ?
true : false;
}
@@ -386,22 +386,22 @@ static SourceLocation GetMappedTokenLoc(Preprocessor &PP,
SourceLocation FileLoc,
unsigned CharNo, unsigned TokLen) {
assert(FileLoc.isMacroID() && "Must be an instantiation");
-
+
// Otherwise, we're lexing "mapped tokens". This is used for things like
// _Pragma handling. Combine the instantiation location of FileLoc with the
// spelling location.
SourceManager &SM = PP.getSourceManager();
-
+
// Create a new SLoc which is expanded from Instantiation(FileLoc) but whose
// characters come from spelling(FileLoc)+Offset.
SourceLocation SpellingLoc = SM.getSpellingLoc(FileLoc);
SpellingLoc = SpellingLoc.getFileLocWithOffset(CharNo);
-
+
// Figure out the expansion loc range, which is the range covered by the
// original _Pragma(...) sequence.
std::pair<SourceLocation,SourceLocation> II =
SM.getImmediateInstantiationRange(FileLoc);
-
+
return SM.createInstantiationLoc(SpellingLoc, II.first, II.second, TokLen);
}
@@ -417,7 +417,7 @@ SourceLocation Lexer::getSourceLocation(const char *Loc,
unsigned CharNo = Loc-BufferStart;
if (FileLoc.isFileID())
return FileLoc.getFileLocWithOffset(CharNo);
-
+
// Otherwise, this is the _Pragma lexer case, which pretends that all of the
// tokens are lexed from where the _Pragma was defined.
assert(PP && "This doesn't work on raw lexers");
@@ -458,13 +458,13 @@ static char GetTrigraphCharForLetter(char Letter) {
static char DecodeTrigraphChar(const char *CP, Lexer *L) {
char Res = GetTrigraphCharForLetter(*CP);
if (!Res || !L) return Res;
-
+
if (!L->getFeatures().Trigraphs) {
if (!L->isLexingRawMode())
L->Diag(CP-2, diag::trigraph_ignored);
return 0;
}
-
+
if (!L->isLexingRawMode())
L->Diag(CP-2, diag::trigraph_converted) << std::string()+Res;
return Res;
@@ -472,12 +472,12 @@ static char DecodeTrigraphChar(const char *CP, Lexer *L) {
/// getEscapedNewLineSize - Return the size of the specified escaped newline,
/// or 0 if it is not an escaped newline. P[-1] is known to be a "\" or a
-/// trigraph equivalent on entry to this function.
+/// trigraph equivalent on entry to this function.
unsigned Lexer::getEscapedNewLineSize(const char *Ptr) {
unsigned Size = 0;
while (isWhitespace(Ptr[Size])) {
++Size;
-
+
if (Ptr[Size-1] != '\n' && Ptr[Size-1] != '\r')
continue;
@@ -485,10 +485,10 @@ unsigned Lexer::getEscapedNewLineSize(const char *Ptr) {
if ((Ptr[Size] == '\r' || Ptr[Size] == '\n') &&
Ptr[Size-1] != Ptr[Size])
++Size;
-
+
return Size;
- }
-
+ }
+
// Not an escaped newline, must be a \t or something else.
return 0;
}
@@ -509,7 +509,7 @@ const char *Lexer::SkipEscapedNewLines(const char *P) {
} else {
return P;
}
-
+
unsigned NewLineSize = Lexer::getEscapedNewLineSize(AfterEscape);
if (NewLineSize == 0) return P;
P = AfterEscape+NewLineSize;
@@ -543,7 +543,7 @@ char Lexer::getCharAndSizeSlow(const char *Ptr, unsigned &Size,
Slash:
// Common case, backslash-char where the char is not whitespace.
if (!isWhitespace(Ptr[0])) return '\\';
-
+
// See if we have optional whitespace characters between the slash and
// newline.
if (unsigned EscapedNewLineSize = getEscapedNewLineSize(Ptr)) {
@@ -553,18 +553,18 @@ Slash:
// Warn if there was whitespace between the backslash and newline.
if (Ptr[0] != '\n' && Ptr[0] != '\r' && Tok && !isLexingRawMode())
Diag(Ptr, diag::backslash_newline_space);
-
+
// Found backslash<whitespace><newline>. Parse the char after it.
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlow(Ptr, Size, Tok);
}
-
+
// Otherwise, this is not an escaped newline, just return the slash.
return '\\';
}
-
+
// If this is a trigraph, process it.
if (Ptr[0] == '?' && Ptr[1] == '?') {
// If this is actually a legal trigraph (not something like "??x"), emit
@@ -579,7 +579,7 @@ Slash:
return C;
}
}
-
+
// If this is neither, return a single character.
++Size;
return *Ptr;
@@ -601,21 +601,21 @@ char Lexer::getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size,
Slash:
// Common case, backslash-char where the char is not whitespace.
if (!isWhitespace(Ptr[0])) return '\\';
-
+
// See if we have optional whitespace characters followed by a newline.
if (unsigned EscapedNewLineSize = getEscapedNewLineSize(Ptr)) {
// Found backslash<whitespace><newline>. Parse the char after it.
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
-
+
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
}
-
+
// Otherwise, this is not an escaped newline, just return the slash.
return '\\';
}
-
+
// If this is a trigraph, process it.
if (Features.Trigraphs && Ptr[0] == '?' && Ptr[1] == '?') {
// If this is actually a legal trigraph (not something like "??x"), return
@@ -627,7 +627,7 @@ Slash:
return C;
}
}
-
+
// If this is neither, return a single character.
++Size;
return *Ptr;
@@ -653,34 +653,34 @@ void Lexer::LexIdentifier(Token &Result, const char *CurPtr) {
FinishIdentifier:
const char *IdStart = BufferPtr;
FormTokenWithChars(Result, CurPtr, tok::identifier);
-
+
// If we are in raw mode, return this identifier raw. There is no need to
// look up identifier information or attempt to macro expand it.
if (LexingRawMode) return;
-
+
// Fill in Result.IdentifierInfo, looking up the identifier in the
// identifier table.
IdentifierInfo *II = PP->LookUpIdentifierInfo(Result, IdStart);
-
+
// Change the kind of this identifier to the appropriate token kind, e.g.
// turning "for" into a keyword.
Result.setKind(II->getTokenID());
-
+
// Finally, now that we know we have an identifier, pass this off to the
// preprocessor, which may macro expand it or something.
if (II->isHandleIdentifierCase())
PP->HandleIdentifier(Result);
return;
}
-
+
// Otherwise, $,\,? in identifier found. Enter slower path.
-
+
C = getCharAndSize(CurPtr, Size);
while (1) {
if (C == '$') {
// If we hit a $ and they are not supported in identifiers, we are done.
if (!Features.DollarIdents) goto FinishIdentifier;
-
+
// Otherwise, emit a diagnostic and continue.
if (!isLexingRawMode())
Diag(CurPtr, diag::ext_dollar_in_identifier);
@@ -716,7 +716,7 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
PrevCh = C;
C = getCharAndSize(CurPtr, Size);
}
-
+
// If we fell out, check for a sign, due to 1e+12. If we have one, continue.
if ((C == '-' || C == '+') && (PrevCh == 'E' || PrevCh == 'e'))
return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
@@ -724,7 +724,7 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
// If we have a hex FP constant, continue.
if ((C == '-' || C == '+') && (PrevCh == 'P' || PrevCh == 'p'))
return LexNumericConstant(Result, ConsumeChar(CurPtr, Size, Result));
-
+
// Update the location of token as well as BufferPtr.
const char *TokStart = BufferPtr;
FormTokenWithChars(Result, CurPtr, tok::numeric_constant);
@@ -735,7 +735,7 @@ void Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
/// either " or L".
void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, bool Wide) {
const char *NulCharacter = 0; // Does this string contain the \0 character?
-
+
char C = getAndAdvanceChar(CurPtr, Result);
while (C != '"') {
// Skip escaped characters.
@@ -753,7 +753,7 @@ void Lexer::LexStringLiteral(Token &Result, const char *CurPtr, bool Wide) {
}
C = getAndAdvanceChar(CurPtr, Result);
}
-
+
// If a nul character existed in the string, warn about it.
if (NulCharacter && !isLexingRawMode())
Diag(NulCharacter, diag::null_in_string);
@@ -787,11 +787,11 @@ void Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) {
}
C = getAndAdvanceChar(CurPtr, Result);
}
-
+
// If a nul character existed in the string, warn about it.
if (NulCharacter && !isLexingRawMode())
Diag(NulCharacter, diag::null_in_string);
-
+
// Update the location of token as well as BufferPtr.
const char *TokStart = BufferPtr;
FormTokenWithChars(Result, CurPtr, tok::angle_string_literal);
@@ -816,7 +816,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr) {
// FIXME: UCN's.
C = getAndAdvanceChar(CurPtr, Result);
}
-
+
if (C && C != '\n' && C != '\r' && CurPtr[0] == '\'') {
++CurPtr;
} else {
@@ -838,7 +838,7 @@ void Lexer::LexCharConstant(Token &Result, const char *CurPtr) {
C = getAndAdvanceChar(CurPtr, Result);
} while (C != '\'');
}
-
+
if (NulCharacter && !isLexingRawMode())
Diag(NulCharacter, diag::null_in_char);
@@ -860,17 +860,17 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) {
// Skip horizontal whitespace very aggressively.
while (isHorizontalWhitespace(Char))
Char = *++CurPtr;
-
+
// Otherwise if we have something other than whitespace, we're done.
if (Char != '\n' && Char != '\r')
break;
-
+
if (ParsingPreprocessorDirective) {
// End of preprocessor directive line, let LexTokenInternal handle this.
BufferPtr = CurPtr;
return false;
}
-
+
// ok, but handle newline.
// The returned token is at the start of the line.
Result.setFlag(Token::StartOfLine);
@@ -889,7 +889,7 @@ bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr) {
FormTokenWithChars(Result, CurPtr, tok::unknown);
return true;
}
-
+
BufferPtr = CurPtr;
return false;
}
@@ -903,12 +903,12 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
// extension warning.
if (!Features.BCPLComment && !isLexingRawMode()) {
Diag(BufferPtr, diag::ext_bcpl_comment);
-
+
// Mark them enabled so we only emit one warning for this translation
// unit.
Features.BCPLComment = true;
}
-
+
// Scan over the body of the comment. The common case, when scanning, is that
// the comment contains normal ascii characters with nothing interesting in
// them. As such, optimize for this case with the inner loop.
@@ -918,7 +918,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
// FIXME: Speedup BCPL comment lexing. Just scan for a \n or \r character.
// If we find a \n character, scan backwards, checking to see if it's an
// escaped newline, like we do for block comments.
-
+
// Skip over characters in the fast loop.
while (C != 0 && // Potentially EOF.
C != '\\' && // Potentially escaped newline.
@@ -929,7 +929,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
// If this is a newline, we're done.
if (C == '\n' || C == '\r')
break; // Found the newline? Break out!
-
+
// Otherwise, this is a hard case. Fall back on getAndAdvanceChar to
// properly decode the character. Read it in raw mode to avoid emitting
// diagnostics about things like trigraphs. If we see an escaped newline,
@@ -947,7 +947,7 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
--CurPtr;
C = 'x'; // doesn't matter what this is.
}
-
+
// If we read multiple characters, and one of those characters was a \r or
// \n, then we had an escaped newline within the comment. Emit diagnostic
// unless the next line is also a // comment.
@@ -963,21 +963,21 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
if (ForwardPtr[0] == '/' && ForwardPtr[1] == '/')
break;
}
-
+
if (!isLexingRawMode())
Diag(OldPtr-1, diag::ext_multi_line_bcpl_comment);
break;
}
}
-
+
if (CurPtr == BufferEnd+1) { --CurPtr; break; }
} while (C != '\n' && C != '\r');
// Found but did not consume the newline.
if (PP)
- PP->HandleComment(SourceRange(getSourceLocation(BufferPtr),
+ PP->HandleComment(SourceRange(getSourceLocation(BufferPtr),
getSourceLocation(CurPtr)));
-
+
// If we are returning comments as tokens, return this comment as a token.
if (inKeepCommentMode())
return SaveBCPLComment(Result, CurPtr);
@@ -988,14 +988,14 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
BufferPtr = CurPtr;
return false;
}
-
+
// Otherwise, eat the \n character. We don't care if this is a \n\r or
// \r\n sequence. This is an efficiency hack (because we know the \n can't
// contribute to another token), it isn't needed for correctness. Note that
// this is ok even in KeepWhitespaceMode, because we would have returned the
/// comment above in that mode.
++CurPtr;
-
+
// The next returned token is at the start of the line.
Result.setFlag(Token::StartOfLine);
// No leading whitespace seen so far.
@@ -1010,17 +1010,17 @@ bool Lexer::SaveBCPLComment(Token &Result, const char *CurPtr) {
// If we're not in a preprocessor directive, just return the // comment
// directly.
FormTokenWithChars(Result, CurPtr, tok::comment);
-
+
if (!ParsingPreprocessorDirective)
return true;
-
+
// If this BCPL-style comment is in a macro definition, transmogrify it into
// a C-style block comment.
std::string Spelling = PP->getSpelling(Result);
assert(Spelling[0] == '/' && Spelling[1] == '/' && "Not bcpl comment?");
Spelling[1] = '*'; // Change prefix to "/*".
Spelling += "*/"; // add suffix.
-
+
Result.setKind(tok::comment);
PP->CreateString(&Spelling[0], Spelling.size(), Result,
Result.getLocation());
@@ -1030,13 +1030,13 @@ bool Lexer::SaveBCPLComment(Token &Result, const char *CurPtr) {
/// isBlockCommentEndOfEscapedNewLine - Return true if the specified newline
/// character (either \n or \r) is part of an escaped newline sequence. Issue a
/// diagnostic if so. We know that the newline is inside of a block comment.
-static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
+static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
Lexer *L) {
assert(CurPtr[0] == '\n' || CurPtr[0] == '\r');
-
+
// Back up off the newline.
--CurPtr;
-
+
// If this is a two-character newline sequence, skip the other character.
if (CurPtr[0] == '\n' || CurPtr[0] == '\r') {
// \n\n or \r\r -> not escaped newline.
@@ -1045,7 +1045,7 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
// \n\r or \r\n -> skip the newline.
--CurPtr;
}
-
+
// If we have horizontal whitespace, skip over it. We allow whitespace
// between the slash and newline.
bool HasSpace = false;
@@ -1053,7 +1053,7 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
--CurPtr;
HasSpace = true;
}
-
+
// If we have a slash, we know this is an escaped newline.
if (*CurPtr == '\\') {
if (CurPtr[-1] != '*') return false;
@@ -1062,7 +1062,7 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
if (CurPtr[0] != '/' || CurPtr[-1] != '?' || CurPtr[-2] != '?' ||
CurPtr[-3] != '*')
return false;
-
+
// This is the trigraph ending the comment. Emit a stern warning!
CurPtr -= 2;
@@ -1076,15 +1076,15 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
if (!L->isLexingRawMode())
L->Diag(CurPtr, diag::trigraph_ends_block_comment);
}
-
+
// Warn about having an escaped newline between the */ characters.
if (!L->isLexingRawMode())
L->Diag(CurPtr, diag::escaped_newline_block_comment_end);
-
+
// If there was space between the backslash and newline, warn about it.
if (HasSpace && !L->isLexingRawMode())
L->Diag(CurPtr, diag::backslash_newline_space);
-
+
return true;
}
@@ -1120,23 +1120,23 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
if (!isLexingRawMode())
Diag(BufferPtr, diag::err_unterminated_block_comment);
--CurPtr;
-
+
// KeepWhitespaceMode should return this broken comment as a token. Since
// it isn't a well formed comment, just return it as an 'unknown' token.
if (isKeepWhitespaceMode()) {
FormTokenWithChars(Result, CurPtr, tok::unknown);
return true;
}
-
+
BufferPtr = CurPtr;
return false;
}
-
+
// Check to see if the first character after the '/*' is another /. If so,
// then this slash does not end the block comment, it is part of it.
if (C == '/')
C = *CurPtr++;
-
+
while (1) {
// Skip over all non-interesting characters until we find end of buffer or a
// (probably ending) '/' character.
@@ -1144,7 +1144,7 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
// While not aligned to a 16-byte boundary.
while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)
C = *CurPtr++;
-
+
if (C == '/') goto FoundSlash;
#ifdef __SSE2__
@@ -1155,13 +1155,13 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
CurPtr += 16;
#elif __ALTIVEC__
__vector unsigned char Slashes = {
- '/', '/', '/', '/', '/', '/', '/', '/',
+ '/', '/', '/', '/', '/', '/', '/', '/',
'/', '/', '/', '/', '/', '/', '/', '/'
};
while (CurPtr+16 <= BufferEnd &&
!vec_any_eq(*(vector unsigned char*)CurPtr, Slashes))
CurPtr += 16;
-#else
+#else
// Scan for '/' quickly. Many block comments are very large.
while (CurPtr[0] != '/' &&
CurPtr[1] != '/' &&
@@ -1171,20 +1171,20 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
CurPtr += 4;
}
#endif
-
+
// It has to be one of the bytes scanned, increment to it and read one.
C = *CurPtr++;
}
-
+
// Loop to scan the remainder.
while (C != '/' && C != '\0')
C = *CurPtr++;
-
+
FoundSlash:
if (C == '/') {
if (CurPtr[-2] == '*') // We found the final */. We're done!
break;
-
+
if ((CurPtr[-2] == '\n' || CurPtr[-2] == '\r')) {
if (isEndOfBlockCommentWithEscapedNewLine(CurPtr-2, this)) {
// We found the final */, though it had an escaped newline between the
@@ -1206,22 +1206,22 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
// after the /*, but this would involve lexing a lot of what really is the
// comment, which surely would confuse the parser.
--CurPtr;
-
+
// KeepWhitespaceMode should return this broken comment as a token. Since
// it isn't a well formed comment, just return it as an 'unknown' token.
if (isKeepWhitespaceMode()) {
FormTokenWithChars(Result, CurPtr, tok::unknown);
return true;
}
-
+
BufferPtr = CurPtr;
return false;
}
C = *CurPtr++;
}
-
- if (PP)
- PP->HandleComment(SourceRange(getSourceLocation(BufferPtr),
+
+ if (PP)
+ PP->HandleComment(SourceRange(getSourceLocation(BufferPtr),
getSourceLocation(CurPtr)));
// If we are returning comments as tokens, return this comment as a token.
@@ -1279,11 +1279,11 @@ std::string Lexer::ReadToEndOfLine() {
// Okay, we found the end of the line. First, back up past the \0, \r, \n.
assert(CurPtr[-1] == Char && "Trigraphs for newline?");
BufferPtr = CurPtr-1;
-
+
// Next, lex the character, which should handle the EOM transition.
Lex(Tmp);
assert(Tmp.is(tok::eom) && "Unexpected token!");
-
+
// Finally, we're done, return the string we found.
return Result;
}
@@ -1303,11 +1303,11 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
ParsingPreprocessorDirective = false;
// Update the location of token as well as BufferPtr.
FormTokenWithChars(Result, CurPtr, tok::eom);
-
+
// Restore comment saving mode, in case it was disabled for directive.
SetCommentRetentionState(PP->getCommentRetentionState());
return true; // Have a token.
- }
+ }
// If we are in raw mode, return this event as an EOF token. Let the caller
// that put us in raw mode handle the event.
@@ -1317,7 +1317,7 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
FormTokenWithChars(Result, BufferEnd, tok::eof);
return true;
}
-
+
// Otherwise, issue diagnostics for unterminated #if and missing newline.
// If we are in a #if directive, emit an error.
@@ -1326,14 +1326,14 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
diag::err_pp_unterminated_conditional);
ConditionalStack.pop_back();
}
-
+
// C99 5.1.1.2p2: If the file is non-empty and didn't end in a newline, issue
// a pedwarn.
if (CurPtr != BufferStart && (CurPtr[-1] != '\n' && CurPtr[-1] != '\r'))
Diag(BufferEnd, diag::ext_no_newline_eof)
<< CodeModificationHint::CreateInsertion(getSourceLocation(BufferEnd),
"\n");
-
+
BufferPtr = CurPtr;
// Finally, let the preprocessor handle this.
@@ -1346,27 +1346,27 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
/// lexer.
unsigned Lexer::isNextPPTokenLParen() {
assert(!LexingRawMode && "How can we expand a macro from a skipping buffer?");
-
+
// Switch to 'skipping' mode. This will ensure that we can lex a token
// without emitting diagnostics, disables macro expansion, and will cause EOF
// to return an EOF token instead of popping the include stack.
LexingRawMode = true;
-
+
// Save state that can be changed while lexing so that we can restore it.
const char *TmpBufferPtr = BufferPtr;
bool inPPDirectiveMode = ParsingPreprocessorDirective;
-
+
Token Tok;
Tok.startToken();
LexTokenInternal(Tok);
-
+
// Restore state that may have changed.
BufferPtr = TmpBufferPtr;
ParsingPreprocessorDirective = inPPDirectiveMode;
-
+
// Restore the lexer back to non-skipping mode.
LexingRawMode = false;
-
+
if (Tok.is(tok::eof))
return 2;
return Tok.is(tok::l_paren);
@@ -1383,7 +1383,7 @@ LexNextToken:
// New token, can't need cleaning yet.
Result.clearFlag(Token::NeedsCleaning);
Result.setIdentifierInfo(0);
-
+
// CurPtr - Cache BufferPtr in an automatic variable.
const char *CurPtr = BufferPtr;
@@ -1392,7 +1392,7 @@ LexNextToken:
++CurPtr;
while ((*CurPtr == ' ') || (*CurPtr == '\t'))
++CurPtr;
-
+
// If we are keeping whitespace and other tokens, just return what we just
// skipped. The next lexer invocation will return the token after the
// whitespace.
@@ -1400,17 +1400,17 @@ LexNextToken:
FormTokenWithChars(Result, CurPtr, tok::unknown);
return;
}
-
+
BufferPtr = CurPtr;
Result.setFlag(Token::LeadingSpace);
}
-
+
unsigned SizeTmp, SizeTmp2; // Temporaries for use in cases below.
-
+
// Read a character, advancing over it.
char Char = getAndAdvanceChar(CurPtr, Result);
tok::TokenKind Kind;
-
+
switch (Char) {
case 0: // Null.
// Found end of file?
@@ -1423,13 +1423,13 @@ LexNextToken:
assert(PPCache && "Raw buffer::LexEndOfFile should return a token");
return PPCache->Lex(Result);
}
-
+
if (!isLexingRawMode())
Diag(CurPtr-1, diag::null_in_file);
Result.setFlag(Token::LeadingSpace);
if (SkipWhitespace(Result, CurPtr))
return; // KeepWhitespaceMode
-
+
goto LexNextToken; // GCC isn't tail call eliminating.
case '\n':
case '\r':
@@ -1438,13 +1438,13 @@ LexNextToken:
if (ParsingPreprocessorDirective) {
// Done parsing the "line".
ParsingPreprocessorDirective = false;
-
+
// Restore comment saving mode, in case it was disabled for directive.
SetCommentRetentionState(PP->getCommentRetentionState());
-
+
// Since we consumed a newline, we are back at the start of a line.
IsAtStartOfLine = true;
-
+
Kind = tok::eom;
break;
}
@@ -1452,7 +1452,7 @@ LexNextToken:
Result.setFlag(Token::StartOfLine);
// No leading whitespace seen so far.
Result.clearFlag(Token::LeadingSpace);
-
+
if (SkipWhitespace(Result, CurPtr))
return; // KeepWhitespaceMode
goto LexNextToken; // GCC isn't tail call eliminating.
@@ -1467,7 +1467,7 @@ LexNextToken:
SkipIgnoredUnits:
CurPtr = BufferPtr;
-
+
// If the next token is obviously a // or /* */ comment, skip it efficiently
// too (without going through the big switch stmt).
if (CurPtr[0] == '/' && CurPtr[1] == '/' && !inKeepCommentMode() &&
@@ -1489,7 +1489,7 @@ LexNextToken:
// Notify MIOpt that we read a non-whitespace/non-comment token.
MIOpt.ReadToken();
return LexNumericConstant(Result, CurPtr);
-
+
case 'L': // Identifier (Loony) or wide literal (L'x' or L"xyz").
// Notify MIOpt that we read a non-whitespace/non-comment token.
MIOpt.ReadToken();
@@ -1504,7 +1504,7 @@ LexNextToken:
if (Char == '\'')
return LexCharConstant(Result, ConsumeChar(CurPtr, SizeTmp, Result));
// FALL THROUGH, treating L like the start of an identifier.
-
+
// C99 6.4.2: Identifiers.
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K': /*'L'*/case 'M': case 'N':
@@ -1527,10 +1527,10 @@ LexNextToken:
MIOpt.ReadToken();
return LexIdentifier(Result, CurPtr);
}
-
+
Kind = tok::unknown;
break;
-
+
// C99 6.4.4: Character Constants.
case '\'':
// Notify MIOpt that we read a non-whitespace/non-comment token.
@@ -1596,7 +1596,7 @@ LexNextToken:
Kind = tok::amp;
}
break;
- case '*':
+ case '*':
if (getCharAndSize(CurPtr, SizeTmp) == '=') {
Kind = tok::starequal;
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
@@ -1621,7 +1621,7 @@ LexNextToken:
if (Char == '-') { // --
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::minusminus;
- } else if (Char == '>' && Features.CPlusPlus &&
+ } else if (Char == '>' && Features.CPlusPlus &&
getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == '*') { // C++ ->*
CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
SizeTmp2, Result);
@@ -1662,20 +1662,20 @@ LexNextToken:
getCharAndSize(CurPtr+SizeTmp, SizeTmp2) != '*') {
if (SkipBCPLComment(Result, ConsumeChar(CurPtr, SizeTmp, Result)))
return; // KeepCommentMode
-
+
// It is common for the tokens immediately after a // comment to be
// whitespace (indentation for the next line). Instead of going through
// the big switch, handle it efficiently now.
goto SkipIgnoredUnits;
}
}
-
+
if (Char == '*') { // /**/ comment.
if (SkipBlockComment(Result, ConsumeChar(CurPtr, SizeTmp, Result)))
return; // KeepCommentMode
goto LexNextToken; // GCC isn't tail call eliminating.
}
-
+
if (Char == '=') {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::slashequal;
@@ -1711,7 +1711,7 @@ LexNextToken:
if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
FormTokenWithChars(Result, CurPtr, tok::hash);
PP->HandleDirective(Result);
-
+
// As an optimization, if the preprocessor didn't switch lexers, tail
// recurse.
if (PP->isCurrentLexer(this)) {
@@ -1724,10 +1724,10 @@ LexNextToken:
}
goto LexNextToken; // GCC isn't tail call eliminating.
}
-
+
return PP->Lex(Result);
}
-
+
Kind = tok::hash;
}
} else {
@@ -1764,7 +1764,7 @@ LexNextToken:
if (Char == '=') {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::greaterequal;
- } else if (Char == '>' &&
+ } else if (Char == '>' &&
getCharAndSize(CurPtr+SizeTmp, SizeTmp2) == '=') {
CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result),
SizeTmp2, Result);
@@ -1805,7 +1805,7 @@ LexNextToken:
} else if (Features.CPlusPlus && Char == ':') {
Kind = tok::coloncolon;
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
- } else {
+ } else {
Kind = tok::colon;
}
break;
@@ -1817,7 +1817,7 @@ LexNextToken:
if (Char == '=') {
Kind = tok::equalequal;
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
- } else {
+ } else {
Kind = tok::equal;
}
break;
@@ -1842,7 +1842,7 @@ LexNextToken:
if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
FormTokenWithChars(Result, CurPtr, tok::hash);
PP->HandleDirective(Result);
-
+
// As an optimization, if the preprocessor didn't switch lexers, tail
// recurse.
if (PP->isCurrentLexer(this)) {
@@ -1857,7 +1857,7 @@ LexNextToken:
}
return PP->Lex(Result);
}
-
+
Kind = tok::hash;
}
break;
@@ -1869,7 +1869,7 @@ LexNextToken:
else
Kind = tok::unknown;
break;
-
+
case '\\':
// FIXME: UCN's.
// FALL THROUGH.
@@ -1877,7 +1877,7 @@ LexNextToken:
Kind = tok::unknown;
break;
}
-
+
// Notify MIOpt that we read a non-whitespace/non-comment token.
MIOpt.ReadToken();
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index cb04e00305..9f91e0450d 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -44,7 +44,7 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
switch (ResultChar) {
// These map to themselves.
case '\\': case '\'': case '"': case '?': break;
-
+
// These have fixed mappings.
case 'a':
// TODO: K&R: the meaning of '\\a' is different in traditional C
@@ -83,7 +83,7 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
HadError = 1;
break;
}
-
+
// Hex escapes are a maximal series of hex digits.
bool Overflow = false;
for (; ThisTokBuf != ThisTokEnd; ++ThisTokBuf) {
@@ -99,12 +99,12 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
unsigned CharWidth = IsWide
? PP.getTargetInfo().getWCharWidth()
: PP.getTargetInfo().getCharWidth();
-
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
Overflow = true;
ResultChar &= ~0U >> (32-CharWidth);
}
-
+
// Check for overflow.
if (Overflow) // Too many digits to fit in
PP.Diag(Loc, diag::warn_hex_escape_too_large);
@@ -125,19 +125,19 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
++NumDigits;
} while (ThisTokBuf != ThisTokEnd && NumDigits < 3 &&
ThisTokBuf[0] >= '0' && ThisTokBuf[0] <= '7');
-
+
// Check for overflow. Reject '\777', but not L'\777'.
unsigned CharWidth = IsWide
? PP.getTargetInfo().getWCharWidth()
: PP.getTargetInfo().getCharWidth();
-
+
if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) {
PP.Diag(Loc, diag::warn_octal_escape_too_large);
ResultChar &= ~0U >> (32-CharWidth);
}
break;
}
-
+
// Otherwise, these are not valid escapes.
case '(': case '{': case '[': case '%':
// GCC accepts these as extensions. We warn about them as such though.
@@ -151,7 +151,7 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
PP.Diag(Loc, diag::ext_unknown_escape) << "x"+llvm::utohexstr(ResultChar);
break;
}
-
+
return ResultChar;
}
@@ -159,16 +159,16 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
/// convert the UTF32 to UTF8. This is a subroutine of StringLiteralParser.
/// When we decide to implement UCN's for character constants and identifiers,
/// we will likely rework our support for UCN's.
-static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
- char *&ResultBuf, bool &HadError,
- SourceLocation Loc, bool IsWide, Preprocessor &PP)
+static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
+ char *&ResultBuf, bool &HadError,
+ SourceLocation Loc, bool IsWide, Preprocessor &PP)
{
// FIXME: Add a warning - UCN's are only valid in C++ & C99.
// FIXME: Handle wide strings.
-
+
// Save the beginning of the string (for error diagnostics).
const char *ThisTokBegin = ThisTokBuf;
-
+
// Skip the '\u' char's.
ThisTokBuf += 2;
@@ -178,7 +178,7 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
return;
}
typedef uint32_t UTF32;
-
+
UTF32 UcnVal = 0;
unsigned short UcnLen = (ThisTokBuf[-1] == 'u' ? 4 : 8);
for (; ThisTokBuf != ThisTokEnd && UcnLen; ++ThisTokBuf, UcnLen--) {
@@ -194,10 +194,10 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
HadError = 1;
return;
}
- // Check UCN constraints (C99 6.4.3p2).
+ // Check UCN constraints (C99 6.4.3p2).
if ((UcnVal < 0xa0 &&
(UcnVal != 0x24 && UcnVal != 0x40 && UcnVal != 0x60 )) // $, @, `
- || (UcnVal >= 0xD800 && UcnVal <= 0xDFFF)
+ || (UcnVal >= 0xD800 && UcnVal <= 0xDFFF)
|| (UcnVal > 0x10FFFF)) /* the maximum legal UTF32 value */ {
PP.Diag(Loc, diag::err_ucn_escape_invalid);
HadError = 1;
@@ -206,7 +206,7 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
// Now that we've parsed/checked the UCN, we convert from UTF32->UTF8.
// The conversion below was inspired by:
// http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
- // First, we determine how many bytes the result will require.
+ // First, we determine how many bytes the result will require.
typedef uint8_t UTF8;
unsigned short bytesToWrite = 0;
@@ -218,13 +218,13 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
bytesToWrite = 3;
else
bytesToWrite = 4;
-
+
const unsigned byteMask = 0xBF;
const unsigned byteMark = 0x80;
-
+
// Once the bits are split out into bytes of UTF8, this is a mask OR-ed
// into the first byte, depending on how many bytes follow.
- static const UTF8 firstByteMark[5] = {
+ static const UTF8 firstByteMark[5] = {
0x00, 0x00, 0xC0, 0xE0, 0xF0
};
// Finally, we write the bytes into ResultBuf.
@@ -244,13 +244,13 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
/// decimal-constant integer-suffix
/// octal-constant integer-suffix
/// hexadecimal-constant integer-suffix
-/// decimal-constant:
+/// decimal-constant:
/// nonzero-digit
/// decimal-constant digit
-/// octal-constant:
+/// octal-constant:
/// 0
/// octal-constant octal-digit
-/// hexadecimal-constant:
+/// hexadecimal-constant:
/// hexadecimal-prefix hexadecimal-digit
/// hexadecimal-constant hexadecimal-digit
/// hexadecimal-prefix: one of
@@ -272,7 +272,7 @@ static void ProcessUCNEscape(const char *&ThisTokBuf, const char *ThisTokEnd,
/// u U
/// long-suffix: one of
/// l L
-/// long-long-suffix: one of
+/// long-long-suffix: one of
/// ll LL
///
/// floating-constant: [C99 6.4.4.2]
@@ -282,14 +282,14 @@ NumericLiteralParser::
NumericLiteralParser(const char *begin, const char *end,
SourceLocation TokLoc, Preprocessor &pp)
: PP(pp), ThisTokBegin(begin), ThisTokEnd(end) {
-
+
// This routine assumes that the range begin/end matches the regex for integer
// and FP constants (specifically, the 'pp-number' regex), and assumes that
// the byte at "*end" is both valid and not part of the regex. Because of
// this, it doesn't have to check for 'overscan' in various places.
assert(!isalnum(*end) && *end != '.' && *end != '_' &&
"Lexer didn't maximally munch?");
-
+
s = DigitsBegin = begin;
saw_exponent = false;
saw_period = false;
@@ -299,7 +299,7 @@ NumericLiteralParser(const char *begin, const char *end,
isFloat = false;
isImaginary = false;
hadError = false;
-
+
if (*s == '0') { // parse radix
ParseNumberStartingWithZero(TokLoc);
if (hadError)
@@ -318,7 +318,7 @@ NumericLiteralParser(const char *begin, const char *end,
s++;
saw_period = true;
s = SkipDigits(s);
- }
+ }
if ((*s == 'e' || *s == 'E')) { // exponent
const char *Exponent = s;
s++;
@@ -337,11 +337,11 @@ NumericLiteralParser(const char *begin, const char *end,
}
SuffixBegin = s;
-
+
// Parse the suffix. At this point we can classify whether we have an FP or
// integer constant.
bool isFPConstant = isFloatingLiteral();
-
+
// Loop over all of the characters of the suffix. If we see something bad,
// we break out of the loop.
for (; s != ThisTokEnd; ++s) {
@@ -362,7 +362,7 @@ NumericLiteralParser(const char *begin, const char *end,
case 'L':
if (isLong || isLongLong) break; // Cannot be repeated.
if (isFloat) break; // LF invalid.
-
+
// Check for long long. The L's need to be adjacent and the same case.
if (s+1 != ThisTokEnd && s[1] == s[0]) {
if (isFPConstant) break; // long long invalid for floats.
@@ -377,7 +377,7 @@ NumericLiteralParser(const char *begin, const char *end,
// Allow i8, i16, i32, i64, and i128.
if (++s == ThisTokEnd) break;
switch (*s) {
- case '8':
+ case '8':
s++; // i8 suffix
break;
case '1':
@@ -414,7 +414,7 @@ NumericLiteralParser(const char *begin, const char *end,
// If we reached here, there was an error.
break;
}
-
+
// Report an error if there are any.
if (s != ThisTokEnd) {
PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
@@ -429,12 +429,12 @@ NumericLiteralParser(const char *begin, const char *end,
/// ParseNumberStartingWithZero - This method is called when the first character
/// of the number is found to be a zero. This means it is either an octal
/// number (like '04') or a hex number ('0x123a') a binary number ('0b1010') or
-/// a floating point number (01239.123e4). Eat the prefix, determining the
+/// a floating point number (01239.123e4). Eat the prefix, determining the
/// radix etc.
void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
assert(s[0] == '0' && "Invalid method call");
s++;
-
+
// Handle a hex number like 0x1234.
if ((*s == 'x' || *s == 'X') && (isxdigit(s[1]) || s[1] == '.')) {
s++;
@@ -449,7 +449,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
s = SkipHexDigits(s);
}
// A binary exponent can appear with or with a '.'. If dotted, the
- // binary exponent is required.
+ // binary exponent is required.
if (*s == 'p' || *s == 'P') {
const char *Exponent = s;
s++;
@@ -463,7 +463,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
return;
}
s = first_non_digit;
-
+
if (!PP.getLangOptions().HexFloats)
PP.Diag(TokLoc, diag::ext_hexconstant_invalid);
} else if (saw_period) {
@@ -473,7 +473,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
}
return;
}
-
+
// Handle simple binary numbers 0b01010
if (*s == 'b' || *s == 'B') {
// 0b101010 is a GCC extension.
@@ -492,16 +492,16 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
// Other suffixes will be diagnosed by the caller.
return;
}
-
+
// For now, the radix is set to 8. If we discover that we have a
// floating point constant, the radix will change to 10. Octal floating
- // point constants are not permitted (only decimal and hexadecimal).
+ // point constants are not permitted (only decimal and hexadecimal).
radix = 8;
DigitsBegin = s;
s = SkipOctalDigits(s);
if (s == ThisTokEnd)
return; // Done, simple octal number like 01234
-
+
// If we have some other non-octal digit that *is* a decimal digit, see if
// this is part of a floating point number like 094.123 or 09e1.
if (isdigit(*s)) {
@@ -511,7 +511,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
radix = 10;
}
}
-
+
// If we have a hex digit other than 'e' (which denotes a FP exponent) then
// the code is using an incorrect base.
if (isxdigit(*s) && *s != 'e' && *s != 'E') {
@@ -520,7 +520,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
hadError = true;
return;
}
-
+
if (*s == '.') {
s++;
radix = 10;
@@ -537,7 +537,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
if (first_non_digit != s) {
s = first_non_digit;
} else {
- PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
+ PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
diag::err_exponent_has_no_digits);
hadError = true;
return;
@@ -557,7 +557,7 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) {
// handles the common cases that matter (small decimal integers and
// hex/octal values which don't overflow).
unsigned MaxBitsPerDigit = 1;
- while ((1U << MaxBitsPerDigit) < radix)
+ while ((1U << MaxBitsPerDigit) < radix)
MaxBitsPerDigit += 1;
if ((SuffixBegin - DigitsBegin) * MaxBitsPerDigit <= 64) {
uint64_t N = 0;
@@ -576,16 +576,16 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) {
llvm::APInt RadixVal(Val.getBitWidth(), radix);
llvm::APInt CharVal(Val.getBitWidth(), 0);
llvm::APInt OldVal = Val;
-
+
bool OverflowOccurred = false;
while (s < SuffixBegin) {
unsigned C = HexDigitValue(*s++);
-
+
// If this letter is out of bound for this radix, reject it.
assert(C < radix && "NumericLiteralParser ctor should have rejected this");
-
+
CharVal = C;
-
+
// Add the digit to the value in the appropriate radix. If adding in digits
// made the value smaller, then this overflowed.
OldVal = Val;
@@ -606,23 +606,23 @@ llvm::APFloat NumericLiteralParser::
GetFloatValue(const llvm::fltSemantics &Format, bool* isExact) {
using llvm::APFloat;
using llvm::StringRef;
-
+
llvm::SmallVector<char,256> floatChars;
unsigned n = std::min(SuffixBegin - ThisTokBegin, ThisTokEnd - ThisTokBegin);
for (unsigned i = 0; i != n; ++i)
floatChars.push_back(ThisTokBegin[i]);
-
+
floatChars.push_back('\0');
-
+
APFloat V (Format, APFloat::fcZero, false);
APFloat::opStatus status;
-
+
status = V.convertFromString(StringRef(&floatChars[0], n),
APFloat::rmNearestTiesToEven);
-
+
if (isExact)
*isExact = status == APFloat::opOK;
-
+
return V;
}
@@ -631,16 +631,16 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
SourceLocation Loc, Preprocessor &PP) {
// At this point we know that the character matches the regex "L?'.*'".
HadError = false;
-
+
// Determine if this is a wide character.
IsWide = begin[0] == 'L';
if (IsWide) ++begin;
-
+
// Skip over the entry quote.
assert(begin[0] == '\'' && "Invalid token lexed");
++begin;
- // FIXME: The "Value" is an uint64_t so we can handle char literals of
+ // FIXME: The "Value" is an uint64_t so we can handle char literals of
// upto 64-bits.
// FIXME: This extensively assumes that 'char' is 8-bits.
assert(PP.getTargetInfo().getCharWidth() == 8 &&
@@ -651,9 +651,9 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
assert(PP.getTargetInfo().getWCharWidth() <= 64 &&
"Assumes sizeof(wchar) on target is <= 64");
- // This is what we will use for overflow detection
+ // This is what we will use for overflow detection
llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0);
-
+
unsigned NumCharsSoFar = 0;
while (begin[0] != '\'') {
uint64_t ResultChar;
@@ -676,7 +676,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
LitVal <<= 8;
}
}
-
+
LitVal = LitVal + ResultChar;
++NumCharsSoFar;
}
@@ -697,7 +697,7 @@ CharLiteralParser::CharLiteralParser(const char *begin, const char *end,
// Transfer the value from APInt to uint64_t
Value = LitVal.getZExtValue();
-
+
// If this is a single narrow character, sign extend it (e.g. '\xFF' is "-1")
// if 'char' is signed for this target (C99 6.4.4.4p10). Note that multiple
// character constants are not sign extended in the this implementation:
@@ -752,7 +752,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
MaxTokenLength = StringToks[0].getLength();
SizeBound = StringToks[0].getLength()-2; // -2 for "".
AnyWide = StringToks[0].is(tok::wide_string_literal);
-
+
hadError = false;
// Implement Translation Phase #6: concatenation of string literals
@@ -761,20 +761,20 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
// The string could be shorter than this if it needs cleaning, but this is a
// reasonable bound, which is all we need.
SizeBound += StringToks[i].getLength()-2; // -2 for "".
-
+
// Remember maximum string piece length.
- if (StringToks[i].getLength() > MaxTokenLength)
+ if (StringToks[i].getLength() > MaxTokenLength)
MaxTokenLength = StringToks[i].getLength();
-
+
// Remember if we see any wide strings.
AnyWide |= StringToks[i].is(tok::wide_string_literal);
}
// Include space for the null terminator.
++SizeBound;
-
+
// TODO: K&R warning: "traditional C rejects string constant concatenation"
-
+
// Get the width in bytes of wchar_t. If no wchar_t strings are used, do not
// query the target. As such, wchar_tByteWidth is only valid if AnyWide=true.
wchar_tByteWidth = ~0U;
@@ -783,25 +783,25 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!");
wchar_tByteWidth /= 8;
}
-
+
// The output buffer size needs to be large enough to hold wide characters.
// This is a worst-case assumption which basically corresponds to L"" "long".
if (AnyWide)
SizeBound *= wchar_tByteWidth;
-
+
// Size the temporary buffer to hold the result string data.
ResultBuf.resize(SizeBound);
-
+
// Likewise, but for each string piece.
llvm::SmallString<512> TokenBuf;
TokenBuf.resize(MaxTokenLength);
-
+
// Loop over all the strings, getting their spelling, and expanding them to
// wide strings as appropriate.
ResultPtr = &ResultBuf[0]; // Next byte to fill in.
-
+
Pascal = false;
-
+
for (unsigned i = 0, e = NumStringToks; i != e; ++i) {
const char *ThisTokBuf = &TokenBuf[0];
// Get the spelling of the token, which eliminates trigraphs, etc. We know
@@ -809,23 +809,23 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
// and 'spelled' tokens can only shrink.
unsigned ThisTokLen = PP.getSpelling(StringToks[i], ThisTokBuf);
const char *ThisTokEnd = ThisTokBuf+ThisTokLen-1; // Skip end quote.
-
+
// TODO: Input character set mapping support.
-
+
// Skip L marker for wide strings.
bool ThisIsWide = false;
if (ThisTokBuf[0] == 'L') {
++ThisTokBuf;
ThisIsWide = true;
}
-
+
assert(ThisTokBuf[0] == '"' && "Expected quote, lexer broken?");
++ThisTokBuf;
-
+
// Check if this is a pascal string
if (pp.getLangOptions().PascalStrings && ThisTokBuf + 1 != ThisTokEnd &&
ThisTokBuf[0] == '\\' && ThisTokBuf[1] == 'p') {
-
+
// If the \p sequence is found in the first token, we have a pascal string
// Otherwise, if we already have a pascal string, ignore the first \p
if (i == 0) {
@@ -834,7 +834,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
} else if (Pascal)
ThisTokBuf += 2;
}
-
+
while (ThisTokBuf != ThisTokEnd) {
// Is this a span of non-escape characters?
if (ThisTokBuf[0] != '\\') {
@@ -842,7 +842,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
do {
++ThisTokBuf;
} while (ThisTokBuf != ThisTokEnd && ThisTokBuf[0] != '\\');
-
+
// Copy the character span over.
unsigned Len = ThisTokBuf-InStart;
if (!AnyWide) {
@@ -861,7 +861,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
}
// Is this a Universal Character Name escape?
if (ThisTokBuf[1] == 'u' || ThisTokBuf[1] == 'U') {
- ProcessUCNEscape(ThisTokBuf, ThisTokEnd, ResultPtr,
+ ProcessUCNEscape(ThisTokBuf, ThisTokEnd, ResultPtr,
hadError, StringToks[i].getLocation(), ThisIsWide, PP);
continue;
}
@@ -869,17 +869,17 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks,
unsigned ResultChar = ProcessCharEscape(ThisTokBuf, ThisTokEnd, hadError,
StringToks[i].getLocation(),
ThisIsWide, PP);
-
+
// Note: our internal rep of wide char tokens is always little-endian.
*ResultPtr++ = ResultChar & 0xFF;
-
+
if (AnyWide) {
for (unsigned i = 1, e = wchar_tByteWidth; i != e; ++i)
*ResultPtr++ = ResultChar >> i*8;
}
}
}
-
+
if (Pascal) {
ResultBuf[0] = ResultPtr-&ResultBuf[0]-1;
@@ -904,31 +904,31 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok,
// Get the spelling of the token.
llvm::SmallString<16> SpellingBuffer;
SpellingBuffer.resize(Tok.getLength());
-
+
const char *SpellingPtr = &SpellingBuffer[0];
unsigned TokLen = PP.getSpelling(Tok, SpellingPtr);
assert(SpellingPtr[0] != 'L' && "Doesn't handle wide strings yet");
-
+
const char *SpellingStart = SpellingPtr;
const char *SpellingEnd = SpellingPtr+TokLen;
// Skip over the leading quote.
assert(SpellingPtr[0] == '"' && "Should be a string literal!");
++SpellingPtr;
-
+
// Skip over bytes until we find the offset we're looking for.
while (ByteNo) {
assert(SpellingPtr < SpellingEnd && "Didn't find byte offset!");
-
+
// Step over non-escapes simply.
if (*SpellingPtr != '\\') {
++SpellingPtr;
--ByteNo;
continue;
}
-
+
// Otherwise, this is an escape character. Advance over it.
bool HadError = false;
ProcessCharEscape(SpellingPtr, SpellingEnd, HadError,
@@ -936,6 +936,6 @@ unsigned StringLiteralParser::getOffsetOfStringByte(const Token &Tok,
assert(!HadError && "This method isn't valid on erroneous strings");
--ByteNo;
}
-
+
return SpellingPtr-SpellingStart;
}
diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp
index cba69b7d79..c14d7c438d 100644
--- a/lib/Lex/MacroArgs.cpp
+++ b/lib/Lex/MacroArgs.cpp
@@ -23,18 +23,18 @@ MacroArgs *MacroArgs::create(const MacroInfo *MI,
unsigned NumToks, bool VarargsElided) {
assert(MI->isFunctionLike() &&
"Can't have args for an object-like macro!");
-
+
// Allocate memory for the MacroArgs object with the lexer tokens at the end.
MacroArgs *Result = (MacroArgs*)malloc(sizeof(MacroArgs) +
NumToks*sizeof(Token));
// Construct the macroargs object.
new (Result) MacroArgs(NumToks, VarargsElided);
-
+
// Copy the actual unexpanded tokens to immediately after the result ptr.
if (NumToks)
memcpy(const_cast<Token*>(Result->getUnexpArgument(0)),
UnexpArgTokens, NumToks*sizeof(Token));
-
+
return Result;
}
@@ -98,7 +98,7 @@ bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok,
const std::vector<Token> &
MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) {
assert(Arg < NumUnexpArgTokens && "Invalid argument number!");
-
+
// If we have already computed this, return it.
if (PreExpArgTokens.empty())
PreExpArgTokens.resize(NumUnexpArgTokens);
@@ -108,12 +108,12 @@ MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) {
const Token *AT = getUnexpArgument(Arg);
unsigned NumToks = getArgLength(AT)+1; // Include the EOF.
-
+
// Otherwise, we have to pre-expand this argument, populating Result. To do
// this, we set up a fake TokenLexer to lex from the unexpanded argument
// list. With this installed, we lex expanded tokens until we hit the EOF
// token at the end of the unexp list.
- PP.EnterTokenStream(AT, NumToks, false /*disable expand*/,
+ PP.EnterTokenStream(AT, NumToks, false /*disable expand*/,
false /*owns tokens*/);
// Lex all of the macro-expanded tokens into Result.
@@ -122,7 +122,7 @@ MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) {
Token &Tok = Result.back();
PP.Lex(Tok);
} while (Result.back().isNot(tok::eof));
-
+
// Pop the token stream off the top of the stack. We know that the internal
// pointer inside of it is to the "end" of the token stream, but the stack
// will not otherwise be popped until the next token is lexed. The problem is
@@ -145,18 +145,18 @@ Token MacroArgs::StringifyArgument(const Token *ArgToks,
Tok.setKind(tok::string_literal);
const Token *ArgTokStart = ArgToks;
-
+
// Stringify all the tokens.
llvm::SmallString<128> Result;
Result += "\"";
-
+
bool isFirst = true;
for (; ArgToks->isNot(tok::eof); ++ArgToks) {
const Token &Tok = *ArgToks;
if (!isFirst && (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()))
Result += ' ';
isFirst = false;
-
+
// If this is a string or character constant, escape the token as specified
// by 6.10.3.2p2.
if (Tok.is(tok::string_literal) || // "foo"
@@ -171,18 +171,18 @@ Token MacroArgs::StringifyArgument(const Token *ArgToks,
Result.resize(CurStrLen+Tok.getLength());
const char *BufPtr = &Result[CurStrLen];
unsigned ActualTokLen = PP.getSpelling(Tok, BufPtr);
-
+
// If getSpelling returned a pointer to an already uniqued version of the
// string instead of filling in BufPtr, memcpy it onto our string.
if (BufPtr != &Result[CurStrLen])
memcpy(&Result[CurStrLen], BufPtr, ActualTokLen);
-
+
// If the token was dirty, the spelling may be shorter than the token.
if (ActualTokLen != Tok.getLength())
Result.resize(CurStrLen+ActualTokLen);
}
}
-
+
// If the last character of the string is a \, and if it isn't escaped, this
// is an invalid string literal, diagnose it as specified in C99.
if (Result.back() == '\\') {
@@ -199,27 +199,27 @@ Token MacroArgs::StringifyArgument(const Token *ArgToks,
}
}
Result += '"';
-
+
// If this is the charify operation and the result is not a legal character
// constant, diagnose it.
if (Charify) {
// First step, turn double quotes into single quotes:
Result[0] = '\'';
Result[Result.size()-1] = '\'';
-
+
// Check for bogus character.
bool isBad = false;
if (Result.size() == 3)
isBad = Result[1] == '\''; // ''' is not legal. '\' already fixed above.
else
isBad = (Result.size() != 4 || Result[1] != '\\'); // Not '\x'
-
+
if (isBad) {
PP.Diag(ArgTokStart[0], diag::err_invalid_character_to_charify);
Result = "' '"; // Use something arbitrary, but legal.
}
}
-
+
PP.CreateString(&Result[0], Result.size(), Tok);
return Tok;
}
diff --git a/lib/Lex/MacroArgs.h b/lib/Lex/MacroArgs.h
index 4b22fa18aa..8dee5b3bc9 100644
--- a/lib/Lex/MacroArgs.h
+++ b/lib/Lex/MacroArgs.h
@@ -20,7 +20,7 @@ namespace clang {
class MacroInfo;
class Preprocessor;
class Token;
-
+
/// MacroArgs - An instance of this class captures information about
/// the formal arguments specified to a function-like macro invocation.
class MacroArgs {
@@ -45,7 +45,7 @@ class MacroArgs {
/// if in strict mode and the C99 varargs macro had only a ... argument, this
/// is false.
bool VarargsElided;
-
+
MacroArgs(unsigned NumToks, bool varargsElided)
: NumUnexpArgTokens(NumToks), VarargsElided(varargsElided) {}
~MacroArgs() {}
@@ -55,46 +55,46 @@ public:
static MacroArgs *create(const MacroInfo *MI,
const Token *UnexpArgTokens,
unsigned NumArgTokens, bool VarargsElided);
-
+
/// destroy - Destroy and deallocate the memory for this object.
///
void destroy();
-
+
/// ArgNeedsPreexpansion - If we can prove that the argument won't be affected
/// by pre-expansion, return false. Otherwise, conservatively return true.
bool ArgNeedsPreexpansion(const Token *ArgTok, Preprocessor &PP) const;
-
+
/// getUnexpArgument - Return a pointer to the first token of the unexpanded
/// token list for the specified formal.
///
const Token *getUnexpArgument(unsigned Arg) const;
-
+
/// getArgLength - Given a pointer to an expanded or unexpanded argument,
/// return the number of tokens, not counting the EOF, that make up the
/// argument.
static unsigned getArgLength(const Token *ArgPtr);
-
+
/// getPreExpArgument - Return the pre-expanded form of the specified
/// argument.
const std::vector<Token> &
- getPreExpArgument(unsigned Arg, Preprocessor &PP);
-
+ getPreExpArgument(unsigned Arg, Preprocessor &PP);
+
/// getStringifiedArgument - Compute, cache, and return the specified argument
/// that has been 'stringified' as required by the # operator.
const Token &getStringifiedArgument(unsigned ArgNo, Preprocessor &PP);
-
+
/// getNumArguments - Return the number of arguments passed into this macro
/// invocation.
unsigned getNumArguments() const { return NumUnexpArgTokens; }
-
-
+
+
/// isVarargsElidedUse - Return true if this is a C99 style varargs macro
/// invocation and there was no argument specified for the "..." argument. If
/// the argument was specified (even empty) or this isn't a C99 style varargs
/// function, or if in strict mode and the C99 varargs macro had only a ...
/// argument, this returns false.
bool isVarargsElidedUse() const { return VarargsElided; }
-
+
/// StringifyArgument - Implement C99 6.10.3.2p2, converting a sequence of
/// tokens into the literal string token that should be produced by the C #
/// preprocessor operator. If Charify is true, then it should be turned into
diff --git a/lib/Lex/MacroInfo.cpp b/lib/Lex/MacroInfo.cpp
index df89450f5a..fda884c4da 100644
--- a/lib/Lex/MacroInfo.cpp
+++ b/lib/Lex/MacroInfo.cpp
@@ -22,7 +22,7 @@ MacroInfo::MacroInfo(SourceLocation DefLoc) : Location(DefLoc) {
IsBuiltinMacro = false;
IsDisabled = false;
IsUsed = true;
-
+
ArgumentList = 0;
NumArguments = 0;
}
@@ -44,32 +44,32 @@ bool MacroInfo::isIdenticalTo(const MacroInfo &Other, Preprocessor &PP) const {
for (arg_iterator I = arg_begin(), OI = Other.arg_begin(), E = arg_end();
I != E; ++I, ++OI)
if (*I != *OI) return false;
-
+
// Check all the tokens.
for (unsigned i = 0, e = ReplacementTokens.size(); i != e; ++i) {
const Token &A = ReplacementTokens[i];
const Token &B = Other.ReplacementTokens[i];
if (A.getKind() != B.getKind())
return false;
-
+
// If this isn't the first first token, check that the whitespace and
// start-of-line characteristics match.
if (i != 0 &&
(A.isAtStartOfLine() != B.isAtStartOfLine() ||
A.hasLeadingSpace() != B.hasLeadingSpace()))
return false;
-
+
// If this is an identifier, it is easy.
if (A.getIdentifierInfo() || B.getIdentifierInfo()) {
if (A.getIdentifierInfo() != B.getIdentifierInfo())
return false;
continue;
}
-
+
// Otherwise, check the spelling.
if (PP.getSpelling(A) != PP.getSpelling(B))
return false;
}
-
+
return true;
}
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index 808787864b..c3f0eeab58 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/lib/Lex/PPCaching.cpp
@@ -36,7 +36,7 @@ void Preprocessor::CommitBacktrackedTokens() {
}
/// Backtrack - Make Preprocessor re-lex the tokens that were lexed since
-/// EnableBacktrackAtThisPos() was previously called.
+/// EnableBacktrackAtThisPos() was previously called.
void Preprocessor::Backtrack() {
assert(!BacktrackPositions.empty()
&& "EnableBacktrackAtThisPos was not called!");
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 1b6eb150f8..196a77f642 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -26,7 +26,7 @@ using namespace clang;
MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) {
MacroInfo *MI;
-
+
if (!MICache.empty()) {
MI = MICache.back();
MICache.pop_back();
@@ -61,13 +61,13 @@ void Preprocessor::DiscardUntilEndOfDirective() {
void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) {
// Read the token, don't allow macro expansion on it.
LexUnexpandedToken(MacroNameTok);
-
+
// Missing macro name?
if (MacroNameTok.is(tok::eom)) {
Diag(MacroNameTok, diag::err_pp_missing_macro_name);
return;
}
-
+
IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
if (II == 0) {
std::string Spelling = getSpelling(MacroNameTok);
@@ -93,7 +93,7 @@ void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) {
// Okay, we got a good identifier node. Return it.
return;
}
-
+
// Invalid macro name, read and discard the rest of the line. Then set the
// token kind to tok::eom.
MacroNameTok.setKind(tok::eom);
@@ -112,12 +112,12 @@ void Preprocessor::CheckEndOfDirective(const char *DirType, bool EnableMacros) {
Lex(Tmp);
else
LexUnexpandedToken(Tmp);
-
+
// There should be no tokens after the directive, but we allow them as an
// extension.
while (Tmp.is(tok::comment)) // Skip comments in -C mode.
LexUnexpandedToken(Tmp);
-
+
if (Tmp.isNot(tok::eom)) {
// Add a fixit in GNU/C99/C++ mode. Don't offer a fixit for strict-C89,
// because it is more trouble than it is worth to insert /**/ and check that
@@ -148,12 +148,12 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
CurPPLexer->pushConditionalLevel(IfTokenLoc, /*isSkipping*/false,
FoundNonSkipPortion, FoundElse);
-
+
if (CurPTHLexer) {
PTHSkipExcludedConditionalBlock();
return;
}
-
+
// Enter raw mode to disable identifier lookup (and thus macro expansion),
// disabling warnings, etc.
CurPPLexer->LexingRawMode = true;
@@ -163,7 +163,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
CurLexer->Lex(Tok);
else
CurPTHLexer->Lex(Tok);
-
+
// If this is the end of the buffer, we have an error.
if (Tok.is(tok::eof)) {
// Emit errors for each unterminated conditional on the stack, including
@@ -172,26 +172,26 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
Diag(CurPPLexer->ConditionalStack.back().IfLoc,
diag::err_pp_unterminated_conditional);
CurPPLexer->ConditionalStack.pop_back();
- }
-
+ }
+
// Just return and let the caller lex after this #include.
break;
}
-
+
// If this token is not a preprocessor directive, just skip it.
if (Tok.isNot(tok::hash) || !Tok.isAtStartOfLine())
continue;
-
+
// We just parsed a # character at the start of a line, so we're in
// directive mode. Tell the lexer this so any newlines we see will be
// converted into an EOM token (this terminates the macro).
CurPPLexer->ParsingPreprocessorDirective = true;
if (CurLexer) CurLexer->SetCommentRetentionState(false);
-
+
// Read the next token, the directive flavor.
LexUnexpandedToken(Tok);
-
+
// If this isn't an identifier directive (e.g. is "# 1\n" or "#\n", or
// something bogus), skip it.
if (Tok.isNot(tok::identifier)) {
@@ -208,14 +208,14 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
// other common directives.
const char *RawCharData = SourceMgr.getCharacterData(Tok.getLocation());
char FirstChar = RawCharData[0];
- if (FirstChar >= 'a' && FirstChar <= 'z' &&
+ if (FirstChar >= 'a' && FirstChar <= 'z' &&
FirstChar != 'i' && FirstChar != 'e') {
CurPPLexer->ParsingPreprocessorDirective = false;
// Restore comment saving mode.
if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
continue;
}
-
+
// Get the identifier name without trigraphs or embedded newlines. Note
// that we can't use Tok.getIdentifierInfo() because its lookup is disabled
// when skipping.
@@ -240,7 +240,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
Directive[IdLen] = 0;
FirstChar = Directive[0];
}
-
+
if (FirstChar == 'i' && Directive[1] == 'f') {
if ((IdLen == 2) || // "if"
(IdLen == 5 && !strcmp(Directive+2, "def")) || // "ifdef"
@@ -260,7 +260,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
bool InCond = CurPPLexer->popConditionalLevel(CondInfo);
InCond = InCond; // Silence warning in no-asserts mode.
assert(!InCond && "Can't be skipping if not in a conditional!");
-
+
// If we popped the outermost skipping block, we're done skipping!
if (!CondInfo.WasSkipping)
break;
@@ -270,13 +270,13 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
// as a non-skipping conditional.
DiscardUntilEndOfDirective(); // C99 6.10p4.
PPConditionalInfo &CondInfo = CurPPLexer->peekConditionalLevel();
-
+
// If this is a #else with a #else before it, report the error.
if (CondInfo.FoundElse) Diag(Tok, diag::pp_err_else_after_else);
-
+
// Note that we've seen a #else in this conditional.
CondInfo.FoundElse = true;
-
+
// If the conditional is at the top level, and the #if block wasn't
// entered, enter the #else block now.
if (!CondInfo.WasSkipping && !CondInfo.FoundNonSkip) {
@@ -301,10 +301,10 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
ShouldEnter = EvaluateDirectiveExpression(IfNDefMacro);
CurPPLexer->LexingRawMode = true;
}
-
+
// If this is a #elif with a #else before it, report the error.
if (CondInfo.FoundElse) Diag(Tok, diag::pp_err_elif_after_else);
-
+
// If this condition is true, enter it!
if (ShouldEnter) {
CondInfo.FoundNonSkip = true;
@@ -312,7 +312,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
}
}
}
-
+
CurPPLexer->ParsingPreprocessorDirective = false;
// Restore comment saving mode.
if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
@@ -325,11 +325,11 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc,
}
void Preprocessor::PTHSkipExcludedConditionalBlock() {
-
- while(1) {
+
+ while (1) {
assert(CurPTHLexer);
assert(CurPTHLexer->LexingRawMode == false);
-
+
// Skip to the next '#else', '#elif', or #endif.
if (CurPTHLexer->SkipBlock()) {
// We have reached an #endif. Both the '#' and 'endif' tokens
@@ -340,12 +340,12 @@ void Preprocessor::PTHSkipExcludedConditionalBlock() {
assert(!InCond && "Can't be skipping if not in a conditional!");
break;
}
-
+
// We have reached a '#else' or '#elif'. Lex the next token to get
// the directive flavor.
Token Tok;
LexUnexpandedToken(Tok);
-
+
// We can actually look up the IdentifierInfo here since we aren't in
// raw mode.
tok::PPKeywordKind K = Tok.getIdentifierInfo()->getPPKeywordID();
@@ -357,32 +357,32 @@ void Preprocessor::PTHSkipExcludedConditionalBlock() {
PPConditionalInfo &CondInfo = CurPTHLexer->peekConditionalLevel();
// Note that we've seen a #else in this conditional.
CondInfo.FoundElse = true;
-
+
// If the #if block wasn't entered then enter the #else block now.
if (!CondInfo.FoundNonSkip) {
CondInfo.FoundNonSkip = true;
-
+
// Scan until the eom token.
CurPTHLexer->ParsingPreprocessorDirective = true;
DiscardUntilEndOfDirective();
CurPTHLexer->ParsingPreprocessorDirective = false;
-
+
break;
}
-
+
// Otherwise skip this block.
continue;
}
-
+
assert(K == tok::pp_elif);
PPConditionalInfo &CondInfo = CurPTHLexer->peekConditionalLevel();
// If this is a #elif with a #else before it, report the error.
if (CondInfo.FoundElse)
Diag(Tok, diag::pp_err_elif_after_else);
-
+
// If this is in a skipping block or if we're already handled this #if
- // block, don't bother parsing the condition. We just skip this block.
+ // block, don't bother parsing the condition. We just skip this block.
if (CondInfo.FoundNonSkip)
continue;
@@ -417,7 +417,7 @@ const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
if (!FromDir) {
FileID FID = getCurrentFileLexer()->getFileID();
CurFileEnt = SourceMgr.getFileEntryForID(FID);
-
+
// If there is no file entry associated with this file, it must be the
// predefines buffer. Any other file is not lexed with a normal lexer, so
// it won't be scanned for preprocessor directives. If we have the
@@ -429,14 +429,14 @@ const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
CurFileEnt = SourceMgr.getFileEntryForID(FID);
}
}
-
+
// Do a standard file entry lookup.
CurDir = CurDirLookup;
const FileEntry *FE =
HeaderInfo.LookupFile(FilenameStart, FilenameEnd,
isAngled, FromDir, CurDir, CurFileEnt);
if (FE) return FE;
-
+
// Otherwise, see if this is a subframework header. If so, this is relative
// to one of the headers on the #include stack. Walk the list of the current
// headers on the #include stack and pass them to HeaderInfo.
@@ -446,18 +446,18 @@ const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
CurFileEnt)))
return FE;
}
-
+
for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
if (IsFileLexer(ISEntry)) {
- if ((CurFileEnt =
+ if ((CurFileEnt =
SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID())))
if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart,
FilenameEnd, CurFileEnt)))
return FE;
}
}
-
+
// Otherwise, we really couldn't find the file.
return 0;
}
@@ -468,31 +468,31 @@ const FileEntry *Preprocessor::LookupFile(const char *FilenameStart,
//===----------------------------------------------------------------------===//
/// HandleDirective - This callback is invoked when the lexer sees a # token
-/// at the start of a line. This consumes the directive, modifies the
+/// at the start of a line. This consumes the directive, modifies the
/// lexer/preprocessor state, and advances the lexer(s) so that the next token
/// read is the correct one.
void Preprocessor::HandleDirective(Token &Result) {
// FIXME: Traditional: # with whitespace before it not recognized by K&R?
-
+
// We just parsed a # character at the start of a line, so we're in directive
// mode. Tell the lexer this so any newlines we see will be converted into an
// EOM token (which terminates the directive).
CurPPLexer->ParsingPreprocessorDirective = true;
-
+
++NumDirectives;
-
+
// We are about to read a token. For the multiple-include optimization FA to
- // work, we have to remember if we had read any tokens *before* this
+ // work, we have to remember if we had read any tokens *before* this
// pp-directive.
bool ReadAnyTokensBeforeDirective = CurPPLexer->MIOpt.getHasReadAnyTokensVal();
-
+
// Save the '#' token in case we need to return it later.
Token SavedHash = Result;
-
+
// Read the next token, the directive flavor. This isn't expanded due to
// C99 6.10.3p8.
LexUnexpandedToken(Result);
-
+
// C99 6.10.3p11: Is this preprocessor directive in macro invocation? e.g.:
// #define A(x) #x
// A(abc
@@ -501,7 +501,7 @@ void Preprocessor::HandleDirective(Token &Result) {
// If so, the user is relying on non-portable behavior, emit a diagnostic.
if (InMacroArgs)
Diag(Result, diag::ext_embedded_directive);
-
+
TryAgain:
switch (Result.getKind()) {
case tok::eom:
@@ -518,7 +518,7 @@ TryAgain:
default:
IdentifierInfo *II = Result.getIdentifierInfo();
if (II == 0) break; // Not an identifier.
-
+
// Ask what the preprocessor keyword ID is.
switch (II->getPPKeywordID()) {
default: break;
@@ -535,13 +535,13 @@ TryAgain:
return HandleElseDirective(Result);
case tok::pp_endif:
return HandleEndifDirective(Result);
-
+
// C99 6.10.2 - Source File Inclusion.
case tok::pp_include:
return HandleIncludeDirective(Result); // Handle #include.
case tok::pp___include_macros:
return HandleIncludeMacrosDirective(Result); // Handle -imacros.
-
+
// C99 6.10.3 - Macro Replacement.
case tok::pp_define:
return HandleDefineDirective(Result);
@@ -551,21 +551,21 @@ TryAgain:
// C99 6.10.4 - Line Control.
case tok::pp_line:
return HandleLineDirective(Result);
-
+
// C99 6.10.5 - Error Directive.
case tok::pp_error:
return HandleUserDiagnosticDirective(Result, false);
-
+
// C99 6.10.6 - Pragma Directive.
case tok::pp_pragma:
return HandlePragmaDirective();
-
+
// GNU Extensions.
case tok::pp_import:
return HandleImportDirective(Result);
case tok::pp_include_next:
return HandleIncludeNextDirective(Result);
-
+
case tok::pp_warning:
Diag(Result, diag::ext_pp_warning_directive);
return HandleUserDiagnosticDirective(Result, true);
@@ -582,7 +582,7 @@ TryAgain:
}
break;
}
-
+
// If this is a .S file, treat unknown # directives as non-preprocessor
// directives. This is important because # may be a comment or introduce
// various pseudo-ops. Just return the # token and push back the following
@@ -590,7 +590,7 @@ TryAgain:
if (getLangOptions().AsmPreprocessor) {
Token *Toks = new Token[2];
// Return the # and the token after it.
- Toks[0] = SavedHash;
+ Toks[0] = SavedHash;
Toks[1] = Result;
// Enter this token stream so that we re-lex the tokens. Make sure to
// enable macro expansion, in case the token after the # is an identifier
@@ -598,13 +598,13 @@ TryAgain:
EnterTokenStream(Toks, 2, false, true);
return;
}
-
+
// If we reached here, the preprocessing token is not valid!
Diag(Result, diag::err_pp_invalid_directive);
-
+
// Read the rest of the PP line.
DiscardUntilEndOfDirective();
-
+
// Okay, we're done parsing the directive.
}
@@ -614,17 +614,17 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
unsigned DiagID, Preprocessor &PP) {
if (DigitTok.isNot(tok::numeric_constant)) {
PP.Diag(DigitTok, DiagID);
-
+
if (DigitTok.isNot(tok::eom))
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
llvm::SmallString<64> IntegerBuffer;
IntegerBuffer.resize(DigitTok.getLength());
const char *DigitTokBegin = &IntegerBuffer[0];
unsigned ActualLength = PP.getSpelling(DigitTok, DigitTokBegin);
-
+
// Verify that we have a simple digit-sequence, and compute the value. This
// is always a simple digit string computed in decimal, so we do this manually
// here.
@@ -636,7 +636,7 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
unsigned NextVal = Val*10+(DigitTokBegin[i]-'0');
if (NextVal < Val) { // overflow.
PP.Diag(DigitTok, DiagID);
@@ -645,21 +645,21 @@ static bool GetLineValue(Token &DigitTok, unsigned &Val,
}
Val = NextVal;
}
-
- // Reject 0, this is needed both by #line numbers and flags.
+
+ // Reject 0, this is needed both by #line numbers and flags.
if (Val == 0) {
PP.Diag(DigitTok, DiagID);
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
if (DigitTokBegin[0] == '0')
PP.Diag(DigitTok.getLocation(), diag::warn_pp_line_decimal);
-
+
return false;
}
-/// HandleLineDirective - Handle #line directive: C99 6.10.4. The two
+/// HandleLineDirective - Handle #line directive: C99 6.10.4. The two
/// acceptable forms are:
/// # line digit-sequence
/// # line digit-sequence "s-char-sequence"
@@ -679,14 +679,14 @@ void Preprocessor::HandleLineDirective(Token &Tok) {
unsigned LineLimit = Features.C99 ? 2147483648U : 32768U;
if (LineNo >= LineLimit)
Diag(DigitTok, diag::ext_pp_line_too_big) << LineLimit;
-
+
int FilenameID = -1;
Token StrTok;
Lex(StrTok);
// If the StrTok is "eom", then it wasn't present. Otherwise, it must be a
// string followed by eom.
- if (StrTok.is(tok::eom))
+ if (StrTok.is(tok::eom))
; // ok
else if (StrTok.isNot(tok::string_literal)) {
Diag(StrTok, diag::err_pp_line_invalid_filename);
@@ -704,14 +704,14 @@ void Preprocessor::HandleLineDirective(Token &Tok) {
}
FilenameID = SourceMgr.getLineTableFilenameID(Literal.GetString(),
Literal.GetStringLength());
-
+
// Verify that there is nothing after the string, other than EOM. Because
// of C99 6.10.4p5, macros that expand to empty tokens are ok.
CheckEndOfDirective("line", true);
}
-
+
SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID);
-
+
if (Callbacks)
Callbacks->FileChanged(DigitTok.getLocation(), PPCallbacks::RenameFile,
SrcMgr::C_User);
@@ -731,21 +731,21 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,
if (FlagVal == 1) {
IsFileEntry = true;
-
+
PP.Lex(FlagTok);
if (FlagTok.is(tok::eom)) return false;
if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag,PP))
return true;
} else if (FlagVal == 2) {
IsFileExit = true;
-
+
SourceManager &SM = PP.getSourceManager();
// If we are leaving the current presumed file, check to make sure the
// presumed include stack isn't empty!
FileID CurFileID =
SM.getDecomposedInstantiationLoc(FlagTok.getLocation()).first;
PresumedLoc PLoc = SM.getPresumedLoc(FlagTok.getLocation());
-
+
// If there is no include loc (main file) or if the include loc is in a
// different physical file, then we aren't in a "1" line marker flag region.
SourceLocation IncLoc = PLoc.getIncludeLoc();
@@ -755,7 +755,7 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
PP.Lex(FlagTok);
if (FlagTok.is(tok::eom)) return false;
if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag,PP))
@@ -768,9 +768,9 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
IsSystemHeader = true;
-
+
PP.Lex(FlagTok);
if (FlagTok.is(tok::eom)) return false;
if (GetLineValue(FlagTok, FlagVal, diag::err_pp_linemarker_invalid_flag, PP))
@@ -782,9 +782,9 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,
PP.DiscardUntilEndOfDirective();
return true;
}
-
+
IsExternCHeader = true;
-
+
PP.Lex(FlagTok);
if (FlagTok.is(tok::eom)) return false;
@@ -798,7 +798,7 @@ static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,
/// one of the following forms:
///
/// # 42
-/// # 42 "file" ('1' | '2')?
+/// # 42 "file" ('1' | '2')?
/// # 42 "file" ('1' | '2')? '3' '4'?
///
void Preprocessor::HandleDigitDirective(Token &DigitTok) {
@@ -808,17 +808,17 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
if (GetLineValue(DigitTok, LineNo, diag::err_pp_linemarker_requires_integer,
*this))
return;
-
+
Token StrTok;
Lex(StrTok);
-
+
bool IsFileEntry = false, IsFileExit = false;
bool IsSystemHeader = false, IsExternCHeader = false;
int FilenameID = -1;
// If the StrTok is "eom", then it wasn't present. Otherwise, it must be a
// string followed by eom.
- if (StrTok.is(tok::eom))
+ if (StrTok.is(tok::eom))
; // ok
else if (StrTok.isNot(tok::string_literal)) {
Diag(StrTok, diag::err_pp_linemarker_invalid_filename);
@@ -835,18 +835,18 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
}
FilenameID = SourceMgr.getLineTableFilenameID(Literal.GetString(),
Literal.GetStringLength());
-
+
// If a filename was present, read any flags that are present.
- if (ReadLineMarkerFlags(IsFileEntry, IsFileExit,
+ if (ReadLineMarkerFlags(IsFileEntry, IsFileExit,
IsSystemHeader, IsExternCHeader, *this))
return;
}
-
+
// Create a line note with this information.
SourceMgr.AddLineNote(DigitTok.getLocation(), LineNo, FilenameID,
- IsFileEntry, IsFileExit,
+ IsFileEntry, IsFileExit,
IsSystemHeader, IsExternCHeader);
-
+
// If the preprocessor has callbacks installed, notify them of the #line
// change. This is used so that the line marker comes out in -E mode for
// example.
@@ -861,7 +861,7 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
FileKind = SrcMgr::C_ExternCSystem;
else if (IsSystemHeader)
FileKind = SrcMgr::C_System;
-
+
Callbacks->FileChanged(DigitTok.getLocation(), Reason, FileKind);
}
}
@@ -869,7 +869,7 @@ void Preprocessor::HandleDigitDirective(Token &DigitTok) {
/// HandleUserDiagnosticDirective - Handle a #warning or #error directive.
///
-void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
+void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
bool isWarning) {
// PTH doesn't emit #warning or #error directives.
if (CurPTHLexer)
@@ -892,11 +892,11 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
void Preprocessor::HandleIdentSCCSDirective(Token &Tok) {
// Yes, this directive is an extension.
Diag(Tok, diag::ext_pp_ident_directive);
-
+
// Read the string argument.
Token StrTok;
Lex(StrTok);
-
+
// If the token kind isn't a string, it's a malformed directive.
if (StrTok.isNot(tok::string_literal) &&
StrTok.isNot(tok::wide_string_literal)) {
@@ -905,7 +905,7 @@ void Preprocessor::HandleIdentSCCSDirective(Token &Tok) {
DiscardUntilEndOfDirective();
return;
}
-
+
// Verify that there is nothing after the string, other than EOM.
CheckEndOfDirective("ident");
@@ -928,7 +928,7 @@ bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc,
const char *&BufEnd) {
// Get the text form of the filename.
assert(BufStart != BufEnd && "Can't have tokens with empty spellings!");
-
+
// Make sure the filename is <x> or "x".
bool isAngled;
if (BufStart[0] == '<') {
@@ -950,14 +950,14 @@ bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc,
BufStart = 0;
return true;
}
-
+
// Diagnose #include "" as invalid.
if (BufEnd-BufStart <= 2) {
Diag(Loc, diag::err_pp_empty_filename);
BufStart = 0;
return "";
}
-
+
// Skip the brackets.
++BufStart;
--BufEnd;
@@ -977,33 +977,33 @@ bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc,
static bool ConcatenateIncludeName(llvm::SmallVector<char, 128> &FilenameBuffer,
Preprocessor &PP) {
Token CurTok;
-
+
PP.Lex(CurTok);
while (CurTok.isNot(tok::eom)) {
// Append the spelling of this token to the buffer. If there was a space
// before it, add it now.
if (CurTok.hasLeadingSpace())
FilenameBuffer.push_back(' ');
-
+
// Get the spelling of the token, directly into FilenameBuffer if possible.
unsigned PreAppendSize = FilenameBuffer.size();
FilenameBuffer.resize(PreAppendSize+CurTok.getLength());
-
+
const char *BufPtr = &FilenameBuffer[PreAppendSize];
unsigned ActualLen = PP.getSpelling(CurTok, BufPtr);
-
+
// If the token was spelled somewhere else, copy it into FilenameBuffer.
if (BufPtr != &FilenameBuffer[PreAppendSize])
memcpy(&FilenameBuffer[PreAppendSize], BufPtr, ActualLen);
-
+
// Resize FilenameBuffer to the correct size.
if (CurTok.getLength() != ActualLen)
FilenameBuffer.resize(PreAppendSize+ActualLen);
-
+
// If we found the '>' marker, return success.
if (CurTok.is(tok::greater))
return false;
-
+
PP.Lex(CurTok);
}
@@ -1017,14 +1017,14 @@ static bool ConcatenateIncludeName(llvm::SmallVector<char, 128> &FilenameBuffer,
/// file to be included from the lexer, then include it! This is a common
/// routine with functionality shared between #include, #include_next and
/// #import. LookupFrom is set when this is a #include_next directive, it
-/// specifies the file to start searching from.
+/// specifies the file to start searching from.
void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
const DirectoryLookup *LookupFrom,
bool isImport) {
Token FilenameTok;
CurPPLexer->LexIncludeFilename(FilenameTok);
-
+
// Reserve a buffer to get the spelling.
llvm::SmallVector<char, 128> FilenameBuffer;
const char *FilenameStart, *FilenameEnd;
@@ -1033,7 +1033,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
case tok::eom:
// If the token kind is EOM, the error has already been diagnosed.
return;
-
+
case tok::angle_string_literal:
case tok::string_literal: {
FilenameBuffer.resize(FilenameTok.getLength());
@@ -1042,7 +1042,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
FilenameEnd = FilenameStart+Len;
break;
}
-
+
case tok::less:
// This could be a <foo/bar.h> file coming from a macro expansion. In this
// case, glue the tokens together into FilenameBuffer and interpret those.
@@ -1057,7 +1057,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
DiscardUntilEndOfDirective();
return;
}
-
+
bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
FilenameStart, FilenameEnd);
// If GetIncludeFilenameSpelling set the start ptr to null, there was an
@@ -1066,7 +1066,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
DiscardUntilEndOfDirective();
return;
}
-
+
// Verify that there is nothing after the filename, other than EOM. Note that
// we allow macros that expand to nothing after the filename, because this
// falls into the category of "#include pp-tokens new-line" specified in
@@ -1078,7 +1078,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
Diag(FilenameTok, diag::err_pp_include_too_deep);
return;
}
-
+
// Search include directories.
const DirectoryLookup *CurDir;
const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
@@ -1088,19 +1088,19 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
<< std::string(FilenameStart, FilenameEnd);
return;
}
-
+
// Ask HeaderInfo if we should enter this #include file. If not, #including
// this file will have no effect.
if (!HeaderInfo.ShouldEnterIncludeFile(File, isImport))
return;
-
+
// The #included file will be considered to be a system header if either it is
// in a system include directory, or if the #includer is a system include
// header.
- SrcMgr::CharacteristicKind FileCharacter =
+ SrcMgr::CharacteristicKind FileCharacter =
std::max(HeaderInfo.getFileDirFlavor(File),
SourceMgr.getFileCharacteristic(FilenameTok.getLocation()));
-
+
// Look up the file, create a File ID for it.
FileID FID = SourceMgr.createFileID(File, FilenameTok.getLocation(),
FileCharacter);
@@ -1118,7 +1118,7 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
///
void Preprocessor::HandleIncludeNextDirective(Token &IncludeNextTok) {
Diag(IncludeNextTok, diag::ext_pp_include_next_directive);
-
+
// #include_next is like #include, except that we start searching after
// the current found directory. If we can't do this, issue a
// diagnostic.
@@ -1132,7 +1132,7 @@ void Preprocessor::HandleIncludeNextDirective(Token &IncludeNextTok) {
// Start looking up in the next directory.
++Lookup;
}
-
+
return HandleIncludeDirective(IncludeNextTok, Lookup);
}
@@ -1141,7 +1141,7 @@ void Preprocessor::HandleIncludeNextDirective(Token &IncludeNextTok) {
void Preprocessor::HandleImportDirective(Token &ImportTok) {
if (!Features.ObjC1) // #import is standard for ObjC.
Diag(ImportTok, diag::ext_pp_import_directive);
-
+
return HandleIncludeDirective(ImportTok, 0, true);
}
@@ -1159,11 +1159,11 @@ void Preprocessor::HandleIncludeMacrosDirective(Token &IncludeMacrosTok) {
DiscardUntilEndOfDirective();
return;
}
-
+
// Treat this as a normal #include for checking purposes. If this is
// successful, it will push a new lexer onto the include stack.
HandleIncludeDirective(IncludeMacrosTok, 0, false);
-
+
Token TmpTok;
do {
Lex(TmpTok);
@@ -1181,7 +1181,7 @@ void Preprocessor::HandleIncludeMacrosDirective(Token &IncludeMacrosTok) {
/// parsing the arg list.
bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) {
llvm::SmallVector<IdentifierInfo*, 32> Arguments;
-
+
Token Tok;
while (1) {
LexUnexpandedToken(Tok);
@@ -1223,18 +1223,18 @@ bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) {
// If this is already used as an argument, it is used multiple times (e.g.
// #define X(A,A.
- if (std::find(Arguments.begin(), Arguments.end(), II) !=
+ if (std::find(Arguments.begin(), Arguments.end(), II) !=
Arguments.end()) { // C99 6.10.3p6
Diag(Tok, diag::err_pp_duplicate_name_in_arg_list) << II;
return true;
}
-
+
// Add the argument to the macro info.
Arguments.push_back(II);
-
+
// Lex the token after the identifier.
LexUnexpandedToken(Tok);
-
+
switch (Tok.getKind()) {
default: // #define X(A B
Diag(Tok, diag::err_pp_expected_comma_in_arg_list);
@@ -1247,14 +1247,14 @@ bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) {
case tok::ellipsis: // #define X(A... -> GCC extension
// Diagnose extension.
Diag(Tok, diag::ext_named_variadic_macro);
-
+
// Lex the token after the identifier.
LexUnexpandedToken(Tok);
if (Tok.isNot(tok::r_paren)) {
Diag(Tok, diag::err_pp_missing_rparen_in_macro_def);
return true;
}
-
+
MI->setIsGNUVarargs();
MI->setArgumentList(&Arguments[0], Arguments.size(), BP);
return false;
@@ -1270,7 +1270,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
Token MacroNameTok;
ReadMacroName(MacroNameTok, 1);
-
+
// Error reading macro name? If so, diagnostic already issued.
if (MacroNameTok.is(tok::eom))
return;
@@ -1280,13 +1280,13 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
// If we are supposed to keep comments in #defines, reenable comment saving
// mode.
if (CurLexer) CurLexer->SetCommentRetentionState(KeepMacroComments);
-
+
// Create the new macro.
MacroInfo *MI = AllocateMacroInfo(MacroNameTok.getLocation());
-
+
Token Tok;
LexUnexpandedToken(Tok);
-
+
// If this is a function-like macro definition, parse the argument list,
// marking each of the identifiers as being used as macro arguments. Also,
// check other constraints on the first token of the macro body.
@@ -1310,13 +1310,13 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
// If this is a definition of a variadic C99 function-like macro, not using
// the GNU named varargs extension, enabled __VA_ARGS__.
-
+
// "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.
// This gets unpoisoned where it is allowed.
assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned!");
if (MI->isC99Varargs())
Ident__VA_ARGS__->setIsPoisoned(false);
-
+
// Read the first token after the arg list for down below.
LexUnexpandedToken(Tok);
} else if (Features.C99) {
@@ -1357,7 +1357,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
// Get the next token of the macro.
LexUnexpandedToken(Tok);
}
-
+
} else {
// Otherwise, read the body of a function-like macro. While we are at it,
// check C99 6.10.3.2p1: ensure that # operators are followed by macro
@@ -1367,15 +1367,15 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
if (Tok.isNot(tok::hash)) {
MI->AddTokenToBody(Tok);
-
+
// Get the next token of the macro.
LexUnexpandedToken(Tok);
continue;
}
-
+
// Get the next token of the macro.
LexUnexpandedToken(Tok);
-
+
// Check for a valid macro arg identifier.
if (Tok.getIdentifierInfo() == 0 ||
MI->getArgumentNum(Tok.getIdentifierInfo()) == -1) {
@@ -1389,24 +1389,24 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
} else {
Diag(Tok, diag::err_pp_stringize_not_parameter);
ReleaseMacroInfo(MI);
-
+
// Disable __VA_ARGS__ again.
Ident__VA_ARGS__->setIsPoisoned(true);
return;
}
}
-
+
// Things look ok, add the '#' and param name tokens to the macro.
MI->AddTokenToBody(LastTok);
MI->AddTokenToBody(Tok);
LastTok = Tok;
-
+
// Get the next token of the macro.
LexUnexpandedToken(Tok);
}
}
-
-
+
+
// Disable __VA_ARGS__ again.
Ident__VA_ARGS__->setIsPoisoned(true);
@@ -1425,14 +1425,14 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
return;
}
}
-
+
// If this is the primary source file, remember that this macro hasn't been
// used yet.
if (isInPrimaryFile())
MI->setIsUsed(false);
MI->setDefinitionEndLoc(LastTok.getLocation());
-
+
// Finally, if this identifier already had a macro defined for it, verify that
// the macro bodies are identical and free the old definition.
if (MacroInfo *OtherMI = getMacroInfo(MacroNameTok.getIdentifierInfo())) {
@@ -1452,12 +1452,12 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
Diag(OtherMI->getDefinitionLoc(), diag::note_previous_definition);
}
}
-
+
ReleaseMacroInfo(OtherMI);
}
-
+
setMacroInfo(MacroNameTok.getIdentifierInfo(), MI);
-
+
// If the callbacks want to know, tell them about the macro definition.
if (Callbacks)
Callbacks->MacroDefined(MacroNameTok.getIdentifierInfo(), MI);
@@ -1470,17 +1470,17 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) {
Token MacroNameTok;
ReadMacroName(MacroNameTok, 2);
-
+
// Error reading macro name? If so, diagnostic already issued.
if (MacroNameTok.is(tok::eom))
return;
-
+
// Check to see if this is the last token on the #undef line.
CheckEndOfDirective("undef");
-
+
// Okay, we finally have a valid identifier to undef.
MacroInfo *MI = getMacroInfo(MacroNameTok.getIdentifierInfo());
-
+
// If the macro is not defined, this is a noop undef, just return.
if (MI == 0) return;
@@ -1513,7 +1513,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
Token MacroNameTok;
ReadMacroName(MacroNameTok);
-
+
// Error reading macro name? If so, diagnostic already issued.
if (MacroNameTok.is(tok::eom)) {
// Skip code until we get to #endif. This helps with recovery by not
@@ -1522,7 +1522,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
/*Foundnonskip*/false, /*FoundElse*/false);
return;
}
-
+
// Check to see if this is the last token on the #if[n]def line.
CheckEndOfDirective(isIfndef ? "ifndef" : "ifdef");
@@ -1541,7 +1541,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
// If there is a macro, process it.
if (MI) // Mark it used.
MI->setIsUsed(true);
-
+
// Should we include the stuff contained by this directive?
if (!MI == isIfndef) {
// Yes, remember that we are inside a conditional, then lex the next token.
@@ -1550,7 +1550,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
} else {
// No, skip the contents of this block and return the first token after it.
SkipExcludedConditionalBlock(DirectiveTok.getLocation(),
- /*Foundnonskip*/false,
+ /*Foundnonskip*/false,
/*FoundElse*/false);
}
}
@@ -1560,11 +1560,11 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef,
void Preprocessor::HandleIfDirective(Token &IfToken,
bool ReadAnyTokensBeforeDirective) {
++NumIf;
-
+
// Parse and evaluation the conditional expression.
IdentifierInfo *IfNDefMacro = 0;
bool ConditionalTrue = EvaluateDirectiveExpression(IfNDefMacro);
-
+
// If this condition is equivalent to #ifndef X, and if this is the first
// directive seen, handle it for the multiple-include optimization.
@@ -1582,7 +1582,7 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
/*foundnonskip*/true, /*foundelse*/false);
} else {
// No, skip the contents of this block and return the first token after it.
- SkipExcludedConditionalBlock(IfToken.getLocation(), /*Foundnonskip*/false,
+ SkipExcludedConditionalBlock(IfToken.getLocation(), /*Foundnonskip*/false,
/*FoundElse*/false);
}
}
@@ -1591,21 +1591,21 @@ void Preprocessor::HandleIfDirective(Token &IfToken,
///
void Preprocessor::HandleEndifDirective(Token &EndifToken) {
++NumEndif;
-
+
// Check that this is the whole directive.
CheckEndOfDirective("endif");
-
+
PPConditionalInfo CondInfo;
if (CurPPLexer->popConditionalLevel(CondInfo)) {
// No conditionals on the stack: this is an #endif without an #if.
Diag(EndifToken, diag::err_pp_endif_without_if);
return;
}
-
+
// If this the end of a top-level #endif, inform MIOpt.
if (CurPPLexer->getConditionalStackDepth() == 0)
CurPPLexer->MIOpt.ExitTopLevelConditional();
-
+
assert(!CondInfo.WasSkipping && !CurPPLexer->LexingRawMode &&
"This code should only be reachable in the non-skipping case!");
}
@@ -1613,23 +1613,23 @@ void Preprocessor::HandleEndifDirective(Token &EndifToken) {
void Preprocessor::HandleElseDirective(Token &Result) {
++NumElse;
-
+
// #else directive in a non-skipping conditional... start skipping.
CheckEndOfDirective("else");
-
+
PPConditionalInfo CI;
if (CurPPLexer->popConditionalLevel(CI)) {
Diag(Result, diag::pp_err_else_without_if);
return;
}
-
+
// If this is a top-level #else, inform the MIOpt.
if (CurPPLexer->getConditionalStackDepth() == 0)
CurPPLexer->MIOpt.EnterTopLevelConditional();
// If this is a #else with a #else before it, report the error.
if (CI.FoundElse) Diag(Result, diag::pp_err_else_after_else);
-
+
// Finally, skip the rest of the contents of this block and return the first
// token after it.
return SkipExcludedConditionalBlock(CI.IfLoc, /*Foundnonskip*/true,
@@ -1638,7 +1638,7 @@ void Preprocessor::HandleElseDirective(Token &Result) {
void Preprocessor::HandleElifDirective(Token &ElifToken) {
++NumElse;
-
+
// #elif directive in a non-skipping conditional... start skipping.
// We don't care what the condition is, because we will always skip it (since
// the block immediately before it was included).
@@ -1649,11 +1649,11 @@ void Preprocessor::HandleElifDirective(Token &ElifToken) {
Diag(ElifToken, diag::pp_err_elif_without_if);
return;
}
-
+
// If this is a top-level #elif, inform the MIOpt.
if (CurPPLexer->getConditionalStackDepth() == 0)
CurPPLexer->MIOpt.EnterTopLevelConditional();
-
+
// If this is a #elif with a #else before it, report the error.
if (CI.FoundElse) Diag(ElifToken, diag::pp_err_elif_after_else);
diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp
index a7307c6b56..908385c5d3 100644
--- a/lib/Lex/PPExpressions.cpp
+++ b/lib/Lex/PPExpressions.cpp
@@ -30,18 +30,18 @@ class PPValue {
SourceRange Range;
public:
llvm::APSInt Val;
-
+
// Default ctor - Construct an 'invalid' PPValue.
PPValue(unsigned BitWidth) : Val(BitWidth) {}
-
+
unsigned getBitWidth() const { return Val.getBitWidth(); }
bool isUnsigned() const { return Val.isUnsigned(); }
-
+
const SourceRange &getRange() const { return Range; }
-
+
void setRange(SourceLocation L) { Range.setBegin(L); Range.setEnd(L); }
void setRange(SourceLocation B, SourceLocation E) {
- Range.setBegin(B); Range.setEnd(E);
+ Range.setBegin(B); Range.setEnd(E);
}
void setBegin(SourceLocation L) { Range.setBegin(L); }
void setEnd(SourceLocation L) { Range.setEnd(L); }
@@ -82,7 +82,7 @@ struct DefinedTracker {
static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
bool ValueLive, Preprocessor &PP) {
DT.State = DefinedTracker::Unknown;
-
+
// If this token's spelling is a pp-identifier, check to see if it is
// 'defined' or if it is a macro. Note that we check here because many
// keywords are pp-identifiers, so we can't check the kind.
@@ -113,13 +113,13 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
LParenLoc = PeekTok.getLocation();
PP.LexUnexpandedToken(PeekTok);
}
-
+
// If we don't have a pp-identifier now, this is an error.
if ((II = PeekTok.getIdentifierInfo()) == 0) {
PP.Diag(PeekTok, diag::err_pp_defined_requires_identifier);
return true;
}
-
+
// Otherwise, we got an identifier, is it defined to something?
Result.Val = II->hasMacroDefinition();
Result.Val.setIsUnsigned(false); // Result is signed intmax_t.
@@ -145,13 +145,13 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
Result.setEnd(PeekTok.getLocation());
PP.LexNonComment(PeekTok);
}
-
+
// Success, remember that we saw defined(X).
DT.State = DefinedTracker::DefinedMacro;
DT.TheMacro = II;
return false;
}
-
+
switch (PeekTok.getKind()) {
default: // Non-value token.
PP.Diag(PeekTok, diag::err_pp_expr_bad_token_start_expr);
@@ -166,11 +166,11 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
IntegerBuffer.resize(PeekTok.getLength());
const char *ThisTokBegin = &IntegerBuffer[0];
unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin);
- NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
+ NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
PeekTok.getLocation(), PP);
if (Literal.hadError)
return true; // a diagnostic was already reported.
-
+
if (Literal.isFloatingLiteral() || Literal.isImaginary) {
PP.Diag(PeekTok, diag::err_pp_illegal_floating_literal);
return true;
@@ -191,7 +191,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// Set the signedness of the result to match whether there was a U suffix
// or not.
Result.Val.setIsUnsigned(Literal.isUnsigned);
-
+
// Detect overflow based on whether the value is signed. If signed
// and if the value is too large, emit a warning "integer constant is so
// large that it is unsigned" e.g. on 12345678901234567890 where intmax_t
@@ -203,7 +203,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
Result.Val.setIsUnsigned(true);
}
}
-
+
// Consume the token.
Result.setRange(PeekTok.getLocation());
PP.LexNonComment(PeekTok);
@@ -214,7 +214,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
CharBuffer.resize(PeekTok.getLength());
const char *ThisTokBegin = &CharBuffer[0];
unsigned ActualLength = PP.getSpelling(PeekTok, ThisTokBegin);
- CharLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
+ CharLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
PeekTok.getLocation(), PP);
if (Literal.hadError())
return true; // A diagnostic was already emitted.
@@ -235,7 +235,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
Val = Literal.getValue();
// Set the signedness.
Val.setIsUnsigned(!PP.getLangOptions().CharIsSigned);
-
+
if (Result.Val.getBitWidth() > Val.getBitWidth()) {
Result.Val = Val.extend(Result.Val.getBitWidth());
} else {
@@ -264,7 +264,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
// Otherwise, we have something like (x+y), and we consumed '(x'.
if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP))
return true;
-
+
if (PeekTok.isNot(tok::r_paren)) {
PP.Diag(PeekTok.getLocation(), diag::err_pp_expected_rparen)
<< Result.getRange();
@@ -290,21 +290,21 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
PP.LexNonComment(PeekTok);
if (EvaluateValue(Result, PeekTok, DT, ValueLive, PP)) return true;
Result.setBegin(Loc);
-
+
// C99 6.5.3.3p3: The sign of the result matches the sign of the operand.
Result.Val = -Result.Val;
-
+
// -MININT is the only thing that overflows. Unsigned never overflows.
bool Overflow = !Result.isUnsigned() && Result.Val.isMinSignedValue();
-
+
// If this operator is live and overflowed, report the issue.
if (Overflow && ValueLive)
PP.Diag(Loc, diag::warn_pp_expr_overflow) << Result.getRange();
-
+
DT.State = DefinedTracker::Unknown;
return false;
}
-
+
case tok::tilde: {
SourceLocation Start = PeekTok.getLocation();
PP.LexNonComment(PeekTok);
@@ -316,7 +316,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
DT.State = DefinedTracker::Unknown;
return false;
}
-
+
case tok::exclaim: {
SourceLocation Start = PeekTok.getLocation();
PP.LexNonComment(PeekTok);
@@ -325,14 +325,14 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
Result.Val = !Result.Val;
// C99 6.5.3.3p5: The sign of the result is 'int', aka it is signed.
Result.Val.setIsUnsigned(false);
-
+
if (DT.State == DefinedTracker::DefinedMacro)
DT.State = DefinedTracker::NotDefinedMacro;
else if (DT.State == DefinedTracker::NotDefinedMacro)
DT.State = DefinedTracker::DefinedMacro;
return false;
}
-
+
// FIXME: Handle #assert
}
}
@@ -390,17 +390,17 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
<< LHS.getRange();
return true;
}
-
+
while (1) {
// If this token has a lower precedence than we are allowed to parse, return
// it so that higher levels of the recursion can parse it.
if (PeekPrec < MinPrec)
return false;
-
+
tok::TokenKind Operator = PeekTok.getKind();
-
+
// If this is a short-circuiting operator, see if the RHS of the operator is
- // dead. Note that this cannot just clobber ValueLive. Consider
+ // dead. Note that this cannot just clobber ValueLive. Consider
// "0 && 1 ? 4 : 1 / 0", which is parsed as "(0 && 1) ? 4 : (1 / 0)". In
// this example, the RHS of the && being dead does not make the rest of the
// expr dead.
@@ -434,7 +434,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
<< RHS.getRange();
return true;
}
-
+
// Decide whether to include the next binop in this subexpression. For
// example, when parsing x+y*z and looking at '*', we want to recursively
// handle y*z as a single subexpression. We do this because the precedence
@@ -451,16 +451,16 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
RHSPrec = getPrecedence(tok::comma);
else // All others should munch while higher precedence.
RHSPrec = ThisPrec+1;
-
+
if (PeekPrec >= RHSPrec) {
if (EvaluateDirectiveSubExpr(RHS, RHSPrec, PeekTok, RHSIsLive, PP))
return true;
PeekPrec = getPrecedence(PeekTok.getKind());
}
assert(PeekPrec <= ThisPrec && "Recursion didn't work!");
-
+
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
- // either operand is unsigned.
+ // either operand is unsigned.
llvm::APSInt Res(LHS.getBitWidth());
switch (Operator) {
case tok::question: // No UAC for x and y in "x ? y : z".
@@ -489,7 +489,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
LHS.Val.setIsUnsigned(Res.isUnsigned());
RHS.Val.setIsUnsigned(Res.isUnsigned());
}
-
+
// FIXME: All of these should detect and report overflow??
bool Overflow = false;
switch (Operator) {
@@ -514,7 +514,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
return true;
}
break;
-
+
case tok::star:
Res = LHS.Val * RHS.Val;
if (Res.isSigned() && LHS.Val != 0 && RHS.Val != 0)
@@ -531,7 +531,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
Overflow = ShAmt >= LHS.Val.countLeadingZeros();
else
Overflow = ShAmt >= LHS.Val.countLeadingOnes();
-
+
Res = LHS.Val << ShAmt;
break;
}
@@ -607,7 +607,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
PP.Diag(OpLoc, diag::ext_pp_comma_expr)
<< LHS.getRange() << RHS.getRange();
Res = RHS.Val; // LHS = LHS,RHS -> RHS.
- break;
+ break;
case tok::question: {
// Parse the : part of the expression.
if (PeekTok.isNot(tok::colon)) {
@@ -631,7 +631,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
if (EvaluateDirectiveSubExpr(AfterColonVal, ThisPrec,
PeekTok, AfterColonLive, PP))
return true;
-
+
// Now that we have the condition, the LHS and the RHS of the :, evaluate.
Res = LHS.Val != 0 ? RHS.Val : AfterColonVal.Val;
RHS.setEnd(AfterColonVal.getRange().getEnd());
@@ -639,7 +639,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
// either operand is unsigned.
Res.setIsUnsigned(RHS.isUnsigned() | AfterColonVal.isUnsigned());
-
+
// Figure out the precedence of the token after the : part.
PeekPrec = getPrecedence(PeekTok.getKind());
break;
@@ -655,12 +655,12 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
if (Overflow && ValueLive)
PP.Diag(OpLoc, diag::warn_pp_expr_overflow)
<< LHS.getRange() << RHS.getRange();
-
+
// Put the result back into 'LHS' for our next iteration.
LHS.Val = Res;
LHS.setEnd(RHS.getRange().getEnd());
}
-
+
return false;
}
@@ -672,10 +672,10 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
// Peek ahead one token.
Token Tok;
Lex(Tok);
-
+
// C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t.
unsigned BitWidth = getTargetInfo().getIntMaxTWidth();
-
+
PPValue ResVal(BitWidth);
DefinedTracker DT;
if (EvaluateValue(ResVal, Tok, DT, true, *this)) {
@@ -684,7 +684,7 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
DiscardUntilEndOfDirective();
return false;
}
-
+
// If we are at the end of the expression after just parsing a value, there
// must be no (unparenthesized) binary operators involved, so we can exit
// directly.
@@ -693,10 +693,10 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
// macro in IfNDefMacro.
if (DT.State == DefinedTracker::NotDefinedMacro)
IfNDefMacro = DT.TheMacro;
-
+
return ResVal.Val != 0;
}
-
+
// Otherwise, we must have a binary operator (e.g. "#if 1 < 2"), so parse the
// operator and the stuff after it.
if (EvaluateDirectiveSubExpr(ResVal, getPrecedence(tok::question),
@@ -706,14 +706,14 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
DiscardUntilEndOfDirective();
return false;
}
-
+
// If we aren't at the tok::eom token, something bad happened, like an extra
// ')' token.
if (Tok.isNot(tok::eom)) {
Diag(Tok, diag::err_pp_expected_eol);
DiscardUntilEndOfDirective();
}
-
+
return ResVal.Val != 0;
}
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp
index 2a05ba336f..41ed991436 100644
--- a/lib/Lex/PPLexerChange.cpp
+++ b/lib/Lex/PPLexerChange.cpp
@@ -31,7 +31,7 @@ PPCallbacks::~PPCallbacks() {}
bool Preprocessor::isInPrimaryFile() const {
if (IsFileLexer())
return IncludeMacroStack.empty();
-
+
// If there are any stacked lexers, we're in a #include.
assert(IsFileLexer(IncludeMacroStack[0]) &&
"Top level include stack isn't our primary lexer?");
@@ -47,7 +47,7 @@ bool Preprocessor::isInPrimaryFile() const {
PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
if (IsFileLexer())
return CurPPLexer;
-
+
// Look for a stacked lexer.
for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
const IncludeStackInfo& ISI = IncludeMacroStack[i-1];
@@ -68,7 +68,7 @@ PreprocessorLexer *Preprocessor::getCurrentFileLexer() const {
void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) {
assert(CurTokenLexer == 0 && "Cannot #include a file inside a macro!");
++NumEnteredSourceFiles;
-
+
if (MaxIncludeStackDepth < IncludeMacroStack.size())
MaxIncludeStackDepth = IncludeMacroStack.size();
@@ -77,13 +77,13 @@ void Preprocessor::EnterSourceFile(FileID FID, const DirectoryLookup *CurDir) {
return EnterSourceFileWithPTH(PL, CurDir);
}
EnterSourceFileWithLexer(new Lexer(FID, *this), CurDir);
-}
+}
/// EnterSourceFileWithLexer - Add a source file to the top of the include stack
/// and start lexing tokens from it instead of the current buffer.
-void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
+void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
const DirectoryLookup *CurDir) {
-
+
// Add the current lexer to the include stack.
if (CurPPLexer || CurTokenLexer)
PushIncludeMacroStack();
@@ -91,12 +91,12 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
CurLexer.reset(TheLexer);
CurPPLexer = TheLexer;
CurDirLookup = CurDir;
-
+
// Notify the client, if desired, that we are in a new source file.
if (Callbacks && !CurLexer->Is_PragmaLexer) {
SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
-
+
Callbacks->FileChanged(CurLexer->getFileLoc(),
PPCallbacks::EnterFile, FileType);
}
@@ -104,9 +104,9 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
/// EnterSourceFileWithPTH - Add a source file to the top of the include stack
/// and start getting tokens from it using the PTH cache.
-void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL,
+void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL,
const DirectoryLookup *CurDir) {
-
+
if (CurPPLexer || CurTokenLexer)
PushIncludeMacroStack();
@@ -130,7 +130,7 @@ void Preprocessor::EnterMacro(Token &Tok, SourceLocation ILEnd,
MacroArgs *Args) {
PushIncludeMacroStack();
CurDirLookup = 0;
-
+
if (NumCachedTokenLexers == 0) {
CurTokenLexer.reset(new TokenLexer(Tok, ILEnd, Args, *this));
} else {
@@ -174,18 +174,18 @@ void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks,
bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
assert(!CurTokenLexer &&
"Ending a file when currently in a macro!");
-
+
// See if this file had a controlling macro.
if (CurPPLexer) { // Not ending a macro, ignore it.
- if (const IdentifierInfo *ControllingMacro =
+ if (const IdentifierInfo *ControllingMacro =
CurPPLexer->MIOpt.GetControllingMacroAtEndOfFile()) {
// Okay, this has a controlling macro, remember in HeaderFileInfo.
- if (const FileEntry *FE =
+ if (const FileEntry *FE =
SourceMgr.getFileEntryForID(CurPPLexer->getFileID()))
HeaderInfo.SetFileControllingMacro(FE, ControllingMacro);
}
}
-
+
// If this is a #include'd file, pop it off the include stack and continue
// lexing the #includer file.
if (!IncludeMacroStack.empty()) {
@@ -197,7 +197,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType);
+ PPCallbacks::ExitFile, FileType);
}
// Client should lex another token.
@@ -210,21 +210,21 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
// actually typed, which is goodness.
if (CurLexer) {
const char *EndPos = CurLexer->BufferEnd;
- if (EndPos != CurLexer->BufferStart &&
+ if (EndPos != CurLexer->BufferStart &&
(EndPos[-1] == '\n' || EndPos[-1] == '\r')) {
--EndPos;
-
+
// Handle \n\r and \r\n:
- if (EndPos != CurLexer->BufferStart &&
+ if (EndPos != CurLexer->BufferStart &&
(EndPos[-1] == '\n' || EndPos[-1] == '\r') &&
EndPos[-1] != EndPos[0])
--EndPos;
}
-
+
Result.startToken();
CurLexer->BufferPtr = EndPos;
CurLexer->FormTokenWithChars(Result, EndPos, tok::eof);
-
+
// We're done with the #included file.
CurLexer.reset();
} else {
@@ -232,12 +232,12 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
CurPTHLexer->getEOF(Result);
CurPTHLexer.reset();
}
-
+
CurPPLexer = 0;
// This is the end of the top-level file. If the diag::pp_macro_not_used
// diagnostic is enabled, look for macros that have not been used.
- if (getDiagnostics().getDiagnosticLevel(diag::pp_macro_not_used) !=
+ if (getDiagnostics().getDiagnosticLevel(diag::pp_macro_not_used) !=
Diagnostic::Ignored) {
for (macro_iterator I = macro_begin(), E = macro_end(); I != E; ++I)
if (!I->second->isUsed())
@@ -267,15 +267,15 @@ bool Preprocessor::HandleEndOfTokenLexer(Token &Result) {
/// state of the top-of-stack lexer is unknown.
void Preprocessor::RemoveTopOfLexerStack() {
assert(!IncludeMacroStack.empty() && "Ran out of stack entries to load");
-
+
if (CurTokenLexer) {
// Delete or cache the now-dead macro expander.
if (NumCachedTokenLexers == TokenLexerCacheSize)
CurTokenLexer.reset();
else
TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.take();
- }
-
+ }
+
PopIncludeMacroStack();
}
@@ -285,7 +285,7 @@ void Preprocessor::RemoveTopOfLexerStack() {
void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
assert(CurTokenLexer && !CurPPLexer &&
"Pasted comment can only be formed from macro");
-
+
// We handle this by scanning for the closest real lexer, switching it to
// raw mode and preprocessor mode. This will cause it to return \n as an
// explicit EOM token.
@@ -294,7 +294,7 @@ void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
IncludeStackInfo &ISI = *(IncludeMacroStack.end()-i-1);
if (ISI.ThePPLexer == 0) continue; // Scan for a real lexer.
-
+
// Once we find a real lexer, mark it as raw mode (disabling macro
// expansions) and preprocessor mode (return EOM). We know that the lexer
// was *not* in raw mode before, because the macro that the comment came
@@ -307,12 +307,12 @@ void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
FoundLexer->ParsingPreprocessorDirective = true;
break;
}
-
+
// Okay, we either found and switched over the lexer, or we didn't find a
// lexer. In either case, finish off the macro the comment came from, getting
// the next token.
if (!HandleEndOfTokenLexer(Tok)) Lex(Tok);
-
+
// Discarding comments as long as we don't have EOF or EOM. This 'comments
// out' the rest of the line, including any tokens that came from other macros
// that were active, as in:
@@ -321,22 +321,22 @@ void Preprocessor::HandleMicrosoftCommentPaste(Token &Tok) {
// which should lex to 'a' only: 'b' and 'c' should be removed.
while (Tok.isNot(tok::eom) && Tok.isNot(tok::eof))
Lex(Tok);
-
+
// If we got an eom token, then we successfully found the end of the line.
if (Tok.is(tok::eom)) {
assert(FoundLexer && "Can't get end of line without an active lexer");
// Restore the lexer back to normal mode instead of raw mode.
FoundLexer->LexingRawMode = false;
-
+
// If the lexer was already in preprocessor mode, just return the EOM token
// to finish the preprocessor line.
if (LexerWasInPPMode) return;
-
+
// Otherwise, switch out of PP mode and return the next lexed token.
FoundLexer->ParsingPreprocessorDirective = false;
return Lex(Tok);
}
-
+
// If we got an EOF token, then we reached the end of the token stream but
// didn't find an explicit \n. This can only happen if there was no lexer
// active (an active lexer would return EOM at EOF if there was no \n in
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index b57f68a5a5..47056fc380 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -39,7 +39,7 @@ void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI) {
static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name){
// Get the identifier.
IdentifierInfo *Id = PP.getIdentifierInfo(Name);
-
+
// Mark it as being a macro that is builtin.
MacroInfo *MI = PP.AllocateMacroInfo(SourceLocation());
MI->setIsBuiltinMacro();
@@ -57,12 +57,12 @@ void Preprocessor::RegisterBuiltinMacros() {
Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
Ident_Pragma = RegisterBuiltinMacro(*this, "_Pragma");
-
+
// GCC Extensions.
Ident__BASE_FILE__ = RegisterBuiltinMacro(*this, "__BASE_FILE__");
Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro(*this, "__INCLUDE_LEVEL__");
Ident__TIMESTAMP__ = RegisterBuiltinMacro(*this, "__TIMESTAMP__");
-
+
// Clang Extensions.
Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -77,14 +77,14 @@ static bool isTrivialSingleTokenExpansion(const MacroInfo *MI,
// If the token isn't an identifier, it's always literally expanded.
if (II == 0) return true;
-
+
// If the identifier is a macro, and if that macro is enabled, it may be
// expanded so it's not a trivial expansion.
if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled() &&
// Fast expanding "#define X X" is ok, because X would be disabled.
II != MacroIdent)
return false;
-
+
// If this is an object-like macro invocation, it is safe to trivially expand
// it.
if (MI->isObjectLike()) return true;
@@ -95,7 +95,7 @@ static bool isTrivialSingleTokenExpansion(const MacroInfo *MI,
I != E; ++I)
if (*I == II)
return false; // Identifier is a macro argument.
-
+
return true;
}
@@ -112,7 +112,7 @@ bool Preprocessor::isNextPPTokenLParen() {
Val = CurPTHLexer->isNextPPTokenLParen();
else
Val = CurTokenLexer->isNextTokenLParen();
-
+
if (Val == 2) {
// We have run off the end. If it's a source file we don't
// examine enclosing ones (C99 5.1.1.2p4). Otherwise walk up the
@@ -127,10 +127,10 @@ bool Preprocessor::isNextPPTokenLParen() {
Val = Entry.ThePTHLexer->isNextPPTokenLParen();
else
Val = Entry.TheTokenLexer->isNextTokenLParen();
-
+
if (Val != 2)
break;
-
+
// Ran off the end of a source file?
if (Entry.ThePPLexer)
return false;
@@ -145,72 +145,72 @@ bool Preprocessor::isNextPPTokenLParen() {
/// HandleMacroExpandedIdentifier - If an identifier token is read that is to be
/// expanded as a macro, handle it and return the next token as 'Identifier'.
-bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
+bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
MacroInfo *MI) {
if (Callbacks) Callbacks->MacroExpands(Identifier, MI);
-
+
// If this is a macro exapnsion in the "#if !defined(x)" line for the file,
// then the macro could expand to different things in other contexts, we need
// to disable the optimization in this case.
if (CurPPLexer) CurPPLexer->MIOpt.ExpandedMacro();
-
+
// If this is a builtin macro, like __LINE__ or _Pragma, handle it specially.
if (MI->isBuiltinMacro()) {
ExpandBuiltinMacro(Identifier);
return false;
}
-
+
/// Args - If this is a function-like macro expansion, this contains,
/// for each macro argument, the list of tokens that were provided to the
/// invocation.
MacroArgs *Args = 0;
-
+
// Remember where the end of the instantiation occurred. For an object-like
// macro, this is the identifier. For a function-like macro, this is the ')'.
SourceLocation InstantiationEnd = Identifier.getLocation();
-
+
// If this is a function-like macro, read the arguments.
if (MI->isFunctionLike()) {
// C99 6.10.3p10: If the preprocessing token immediately after the the macro
// name isn't a '(', this macro should not be expanded.
if (!isNextPPTokenLParen())
return true;
-
+
// Remember that we are now parsing the arguments to a macro invocation.
// Preprocessor directives used inside macro arguments are not portable, and
// this enables the warning.
InMacroArgs = true;
Args = ReadFunctionLikeMacroArgs(Identifier, MI, InstantiationEnd);
-
+
// Finished parsing args.
InMacroArgs = false;
-
+
// If there was an error parsing the arguments, bail out.
if (Args == 0) return false;
-
+
++NumFnMacroExpanded;
} else {
++NumMacroExpanded;
}
-
+
// Notice that this macro has been used.
MI->setIsUsed(true);
-
+
// If we started lexing a macro, enter the macro expansion body.
-
+
// If this macro expands to no tokens, don't bother to push it onto the
// expansion stack, only to take it right back off.
if (MI->getNumTokens() == 0) {
// No need for arg info.
if (Args) Args->destroy();
-
+
// Ignore this macro use, just return the next token in the current
// buffer.
bool HadLeadingSpace = Identifier.hasLeadingSpace();
bool IsAtStartOfLine = Identifier.isAtStartOfLine();
-
+
Lex(Identifier);
-
+
// If the identifier isn't on some OTHER line, inherit the leading
// whitespace/first-on-a-line property of this token. This handles
// stuff like "! XX," -> "! ," and " XX," -> " ,", when XX is
@@ -221,12 +221,12 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
}
++NumFastMacroExpanded;
return false;
-
+
} else if (MI->getNumTokens() == 1 &&
isTrivialSingleTokenExpansion(MI, Identifier.getIdentifierInfo(),
*this)) {
// Otherwise, if this macro expands into a single trivially-expanded
- // token: expand it now. This handles common cases like
+ // token: expand it now. This handles common cases like
// "#define VAL 42".
// No need for arg info.
@@ -236,38 +236,38 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
// identifier to the expanded token.
bool isAtStartOfLine = Identifier.isAtStartOfLine();
bool hasLeadingSpace = Identifier.hasLeadingSpace();
-
+
// Remember where the token is instantiated.
SourceLocation InstantiateLoc = Identifier.getLocation();
-
+
// Replace the result token.
Identifier = MI->getReplacementToken(0);
-
+
// Restore the StartOfLine/LeadingSpace markers.
Identifier.setFlagValue(Token::StartOfLine , isAtStartOfLine);
Identifier.setFlagValue(Token::LeadingSpace, hasLeadingSpace);
-
+
// Update the tokens location to include both its instantiation and physical
// locations.
SourceLocation Loc =
SourceMgr.createInstantiationLoc(Identifier.getLocation(), InstantiateLoc,
InstantiationEnd,Identifier.getLength());
Identifier.setLocation(Loc);
-
+
// If this is #define X X, we must mark the result as unexpandible.
if (IdentifierInfo *NewII = Identifier.getIdentifierInfo())
if (getMacroInfo(NewII) == MI)
Identifier.setFlag(Token::DisableExpand);
-
+
// Since this is not an identifier token, it can't be macro expanded, so
// we're done.
++NumFastMacroExpanded;
return false;
}
-
+
// Start expanding the macro.
EnterMacro(Identifier, InstantiationEnd, Args);
-
+
// Now that the macro is at the top of the include stack, ask the
// preprocessor to read the next token from it.
Lex(Identifier);
@@ -284,7 +284,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// The number of fixed arguments to parse.
unsigned NumFixedArgsLeft = MI->getNumArgs();
bool isVariadic = MI->isVariadic();
-
+
// Outer loop, while there are more arguments, keep reading them.
Token Tok;
@@ -292,7 +292,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// an argument value in a macro could expand to ',' or '(' or ')'.
LexUnexpandedToken(Tok);
assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?");
-
+
// ArgTokens - Build up a list of tokens that make up each argument. Each
// argument is separated by an EOF token. Use a SmallVector so we can avoid
// heap allocations in the common case.
@@ -302,19 +302,19 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
while (Tok.isNot(tok::r_paren)) {
assert((Tok.is(tok::l_paren) || Tok.is(tok::comma)) &&
"only expect argument separators here");
-
+
unsigned ArgTokenStart = ArgTokens.size();
SourceLocation ArgStartLoc = Tok.getLocation();
-
+
// C99 6.10.3p11: Keep track of the number of l_parens we have seen. Note
// that we already consumed the first one.
unsigned NumParens = 0;
-
+
while (1) {
// Read arguments as unexpanded tokens. This avoids issues, e.g., where
// an argument value in a macro could expand to ',' or '(' or ')'.
LexUnexpandedToken(Tok);
-
+
if (Tok.is(tok::eof) || Tok.is(tok::eom)) { // "#if f(<eof>" & "#if f(\n"
Diag(MacroName, diag::err_unterm_macro_invoc);
// Do not lose the EOF/EOM. Return it to the client.
@@ -331,7 +331,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
} else if (Tok.is(tok::comma) && NumParens == 0) {
// Comma ends this argument if there are more fixed arguments expected.
// However, if this is a variadic macro, and this is part of the
- // variadic part, then the comma is just an argument token.
+ // variadic part, then the comma is just an argument token.
if (!isVariadic) break;
if (NumFixedArgsLeft > 1)
break;
@@ -344,7 +344,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// expanding from to be popped off the expansion stack. Doing so causes
// them to be reenabled for expansion. Here we record whether any
// identifiers we lex as macro arguments correspond to disabled macros.
- // If so, we mark the token as noexpand. This is a subtle aspect of
+ // If so, we mark the token as noexpand. This is a subtle aspect of
// C99 6.10.3.4p2.
if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo()))
if (!MI->isEnabled())
@@ -352,7 +352,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
}
ArgTokens.push_back(Tok);
}
-
+
// If this was an empty argument list foo(), don't add this as an empty
// argument.
if (ArgTokens.empty() && Tok.getKind() == tok::r_paren)
@@ -363,18 +363,18 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
if (!isVariadic && NumFixedArgsLeft == 0) {
if (ArgTokens.size() != ArgTokenStart)
ArgStartLoc = ArgTokens[ArgTokenStart].getLocation();
-
+
// Emit the diagnostic at the macro name in case there is a missing ).
// Emitting it at the , could be far away from the macro name.
Diag(ArgStartLoc, diag::err_too_many_args_in_macro_invoc);
return 0;
}
-
+
// Empty arguments are standard in C99 and supported as an extension in
// other modes.
if (ArgTokens.size() == ArgTokenStart && !Features.C99)
Diag(Tok, diag::ext_empty_fnmacro_arg);
-
+
// Add a marker EOF token to the end of the token list for this argument.
Token EOFTok;
EOFTok.startToken();
@@ -386,19 +386,19 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
assert(NumFixedArgsLeft != 0 && "Too many arguments parsed");
--NumFixedArgsLeft;
}
-
+
// Okay, we either found the r_paren. Check to see if we parsed too few
// arguments.
unsigned MinArgsExpected = MI->getNumArgs();
-
+
// See MacroArgs instance var for description of this.
bool isVarargsElided = false;
-
+
if (NumActuals < MinArgsExpected) {
// There are several cases where too few arguments is ok, handle them now.
if (NumActuals == 0 && MinArgsExpected == 1) {
// #define A(X) or #define A(...) ---> A()
-
+
// If there is exactly one argument, and that argument is missing,
// then we have an empty "()" argument empty list. This is fine, even if
// the macro expects one argument (the argument is just empty).
@@ -413,9 +413,9 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// Remember this occurred, allowing us to elide the comma when used for
// cases like:
- // #define A(x, foo...) blah(a, ## foo)
- // #define B(x, ...) blah(a, ## __VA_ARGS__)
- // #define C(...) blah(a, ## __VA_ARGS__)
+ // #define A(x, foo...) blah(a, ## foo)
+ // #define B(x, ...) blah(a, ## __VA_ARGS__)
+ // #define C(...) blah(a, ## __VA_ARGS__)
// A(x) B(x) C()
isVarargsElided = true;
} else {
@@ -423,7 +423,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
Diag(Tok, diag::err_too_few_args_in_macro_invoc);
return 0;
}
-
+
// Add a marker EOF token to the end of the token list for this argument.
SourceLocation EndLoc = Tok.getLocation();
Tok.startToken();
@@ -435,14 +435,14 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// If we expect two arguments, add both as empty.
if (NumActuals == 0 && MinArgsExpected == 2)
ArgTokens.push_back(Tok);
-
+
} else if (NumActuals > MinArgsExpected && !MI->isVariadic()) {
// Emit the diagnostic at the macro name in case there is a missing ).
// Emitting it at the , could be far away from the macro name.
Diag(MacroName, diag::err_too_many_args_in_macro_invoc);
return 0;
}
-
+
return MacroArgs::create(MI, ArgTokens.data(), ArgTokens.size(),
isVarargsElided);
}
@@ -454,15 +454,15 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
Preprocessor &PP) {
time_t TT = time(0);
struct tm *TM = localtime(&TT);
-
+
static const char * const Months[] = {
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
};
-
+
char TmpBuffer[100];
- sprintf(TmpBuffer, "\"%s %2d %4d\"", Months[TM->tm_mon], TM->tm_mday,
+ sprintf(TmpBuffer, "\"%s %2d %4d\"", Months[TM->tm_mon], TM->tm_mday,
TM->tm_year+1900);
-
+
Token TmpTok;
TmpTok.startToken();
PP.CreateString(TmpBuffer, strlen(TmpBuffer), TmpTok);
@@ -478,7 +478,7 @@ static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
/// specified by the identifier.
static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
const LangOptions &LangOpts = PP.getLangOptions();
-
+
switch (II->getLength()) {
default: return false;
case 6:
@@ -510,12 +510,12 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// Figure out which token this is.
IdentifierInfo *II = Tok.getIdentifierInfo();
assert(II && "Can't be a macro without id info!");
-
+
// If this is an _Pragma directive, expand it, invoke the pragma handler, then
// lex the token after it.
if (II == Ident_Pragma)
return Handle_Pragma(Tok);
-
+
++NumBuiltinMacroExpanded;
char TmpBuffer[100];
@@ -523,17 +523,17 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// Set up the return result.
Tok.setIdentifierInfo(0);
Tok.clearFlag(Token::NeedsCleaning);
-
+
if (II == Ident__LINE__) {
// C99 6.10.8: "__LINE__: The presumed line number (within the current
// source file) of the current source line (an integer constant)". This can
// be affected by #line.
SourceLocation Loc = Tok.getLocation();
-
+
// Advance to the location of the first _, this might not be the first byte
// of the token if it starts with an escaped newline.
Loc = AdvanceToTokenCharacter(Loc, 0);
-
+
// One wrinkle here is that GCC expands __LINE__ to location of the *end* of
// a macro instantiation. This doesn't matter for object-like macros, but
// can matter for a function-like macro that expands to contain __LINE__.
@@ -541,7 +541,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// end of the instantiation history.
Loc = SourceMgr.getInstantiationRange(Loc).second;
PresumedLoc PLoc = SourceMgr.getPresumedLoc(Loc);
-
+
// __LINE__ expands to a simple numeric value.
sprintf(TmpBuffer, "%u", PLoc.getLine());
Tok.setKind(tok::numeric_constant);
@@ -561,7 +561,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
NextLoc = PLoc.getIncludeLoc();
}
}
-
+
// Escape this filename. Turn '\' -> '\\' '"' -> '\"'
std::string FN = PLoc.getFilename();
FN = '"' + Lexer::Stringify(FN) + '"';
@@ -589,12 +589,12 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// Compute the presumed include depth of this token. This can be affected
// by GNU line markers.
unsigned Depth = 0;
-
+
PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
PLoc = SourceMgr.getPresumedLoc(PLoc.getIncludeLoc());
for (; PLoc.isValid(); ++Depth)
PLoc = SourceMgr.getPresumedLoc(PLoc.getIncludeLoc());
-
+
// __INCLUDE_LEVEL__ expands to a simple numeric value.
sprintf(TmpBuffer, "%u", Depth);
Tok.setKind(tok::numeric_constant);
@@ -608,10 +608,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// a macro, dig into the include stack.
const FileEntry *CurFile = 0;
PreprocessorLexer *TheLexer = getCurrentFileLexer();
-
+
if (TheLexer)
CurFile = SourceMgr.getFileEntryForID(TheLexer->getFileID());
-
+
// If this file is older than the file it depends on, emit a diagnostic.
const char *Result;
if (CurFile) {
@@ -629,7 +629,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
CreateString(TmpBuffer, Len+1, Tok, Tok.getLocation());
} else if (II == Ident__COUNTER__) {
Diag(Tok, diag::ext_pp_counter);
-
+
// __COUNTER__ expands to a simple numeric value.
sprintf(TmpBuffer, "%u", CounterValue++);
Tok.setKind(tok::numeric_constant);
@@ -638,10 +638,10 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
II == Ident__has_builtin) {
// The argument to these two builtins should be a parenthesized identifier.
SourceLocation StartLoc = Tok.getLocation();
-
+
bool IsValid = false;
IdentifierInfo *FeatureII = 0;
-
+
// Read the '('.
Lex(Tok);
if (Tok.is(tok::l_paren)) {
@@ -649,25 +649,25 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Lex(Tok);
if (Tok.is(tok::identifier)) {
FeatureII = Tok.getIdentifierInfo();
-
+
// Read the ')'.
Lex(Tok);
if (Tok.is(tok::r_paren))
IsValid = true;
}
}
-
+
bool Value = false;
if (!IsValid)
Diag(StartLoc, diag::err_feature_check_malformed);
else if (II == Ident__has_builtin) {
- // Check for a builtin is trivial.
+ // Check for a builtin is trivial.
Value = FeatureII->getBuiltinID() != 0;
} else {
assert(II == Ident__has_feature && "Must be feature check");
Value = HasFeature(*this, FeatureII);
}
-
+
sprintf(TmpBuffer, "%d", (int)Value);
Tok.setKind(tok::numeric_constant);
CreateString(TmpBuffer, strlen(TmpBuffer), Tok, Tok.getLocation());
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 2b91cea5ed..36ace8be7e 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -37,7 +37,7 @@ PTHLexer::PTHLexer(Preprocessor &PP, FileID FID, const unsigned char *D,
const unsigned char *ppcond, PTHManager &PM)
: PreprocessorLexer(&PP, FID), TokBuf(D), CurPtr(D), LastHashTokPtr(0),
PPCond(ppcond), CurPPCondPtr(ppcond), PTHMgr(PM) {
-
+
FileStartLoc = PP.getSourceManager().getLocForStartOfFile(FID);
}
@@ -47,25 +47,25 @@ LexNextToken:
//===--------------------------------------==//
// Read the raw token data.
//===--------------------------------------==//
-
+
// Shadow CurPtr into an automatic variable.
- const unsigned char *CurPtrShadow = CurPtr;
+ const unsigned char *CurPtrShadow = CurPtr;
// Read in the data for the token.
unsigned Word0 = ReadLE32(CurPtrShadow);
uint32_t IdentifierID = ReadLE32(CurPtrShadow);
uint32_t FileOffset = ReadLE32(CurPtrShadow);
-
+
tok::TokenKind TKind = (tok::TokenKind) (Word0 & 0xFF);
Token::TokenFlags TFlags = (Token::TokenFlags) ((Word0 >> 8) & 0xFF);
uint32_t Len = Word0 >> 16;
CurPtr = CurPtrShadow;
-
+
//===--------------------------------------==//
// Construct the token itself.
//===--------------------------------------==//
-
+
Tok.startToken();
Tok.setKind(TKind);
Tok.setFlag(TFlags);
@@ -80,57 +80,57 @@ LexNextToken:
else if (IdentifierID) {
MIOpt.ReadToken();
IdentifierInfo *II = PTHMgr.GetIdentifierInfo(IdentifierID-1);
-
+
Tok.setIdentifierInfo(II);
-
+
// Change the kind of this identifier to the appropriate token kind, e.g.
// turning "for" into a keyword.
Tok.setKind(II->getTokenID());
-
+
if (II->isHandleIdentifierCase())
PP->HandleIdentifier(Tok);
return;
}
-
+
//===--------------------------------------==//
// Process the token.
//===--------------------------------------==//
-#if 0
+#if 0
SourceManager& SM = PP->getSourceManager();
llvm::errs() << SM.getFileEntryForID(FileID)->getName()
<< ':' << SM.getLogicalLineNumber(Tok.getLocation())
<< ':' << SM.getLogicalColumnNumber(Tok.getLocation())
<< '\n';
-#endif
+#endif
if (TKind == tok::eof) {
// Save the end-of-file token.
EofToken = Tok;
-
+
Preprocessor *PPCache = PP;
-
+
assert(!ParsingPreprocessorDirective);
assert(!LexingRawMode);
-
+
// FIXME: Issue diagnostics similar to Lexer.
if (PP->HandleEndOfFile(Tok, false))
return;
-
+
assert(PPCache && "Raw buffer::LexEndOfFile should return a token");
return PPCache->Lex(Tok);
}
-
+
if (TKind == tok::hash && Tok.isAtStartOfLine()) {
LastHashTokPtr = CurPtr - DISK_TOKEN_SIZE;
assert(!LexingRawMode);
PP->HandleDirective(Tok);
-
+
if (PP->isCurrentLexer(this))
goto LexNextToken;
-
+
return PP->Lex(Tok);
}
-
+
if (TKind == tok::eom) {
assert(ParsingPreprocessorDirective);
ParsingPreprocessorDirective = false;
@@ -154,7 +154,7 @@ void PTHLexer::DiscardToEndOfLine() {
// We assume that if the preprocessor wishes to discard to the end of
// the line that it also means to end the current preprocessor directive.
ParsingPreprocessorDirective = false;
-
+
// Skip tokens by only peeking at their token kind and the flags.
// We don't need to actually reconstruct full tokens from the token buffer.
// This saves some copies and it also reduces IdentifierInfo* lookup.
@@ -163,7 +163,7 @@ void PTHLexer::DiscardToEndOfLine() {
// Read the token kind. Are we at the end of the file?
tok::TokenKind x = (tok::TokenKind) (uint8_t) *p;
if (x == tok::eof) break;
-
+
// Read the token flags. Are we at the start of the next line?
Token::TokenFlags y = (Token::TokenFlags) (uint8_t) p[1];
if (y & Token::StartOfLine) break;
@@ -171,7 +171,7 @@ void PTHLexer::DiscardToEndOfLine() {
// Skip to the next token.
p += DISK_TOKEN_SIZE;
}
-
+
CurPtr = p;
}
@@ -179,18 +179,18 @@ void PTHLexer::DiscardToEndOfLine() {
bool PTHLexer::SkipBlock() {
assert(CurPPCondPtr && "No cached PP conditional information.");
assert(LastHashTokPtr && "No known '#' token.");
-
+
const unsigned char* HashEntryI = 0;
- uint32_t Offset;
+ uint32_t Offset;
uint32_t TableIdx;
-
+
do {
// Read the token offset from the side-table.
Offset = ReadLE32(CurPPCondPtr);
-
- // Read the target table index from the side-table.
+
+ // Read the target table index from the side-table.
TableIdx = ReadLE32(CurPPCondPtr);
-
+
// Compute the actual memory address of the '#' token data for this entry.
HashEntryI = TokBuf + Offset;
@@ -208,7 +208,7 @@ bool PTHLexer::SkipBlock() {
// Read where we should jump to.
uint32_t TmpOffset = ReadLE32(NextPPCondPtr);
const unsigned char* HashEntryJ = TokBuf + TmpOffset;
-
+
if (HashEntryJ <= LastHashTokPtr) {
// Jump directly to the next entry in the side table.
HashEntryI = HashEntryJ;
@@ -218,23 +218,23 @@ bool PTHLexer::SkipBlock() {
}
}
}
- while (HashEntryI < LastHashTokPtr);
+ while (HashEntryI < LastHashTokPtr);
assert(HashEntryI == LastHashTokPtr && "No PP-cond entry found for '#'");
assert(TableIdx && "No jumping from #endifs.");
-
+
// Update our side-table iterator.
const unsigned char* NextPPCondPtr = PPCond + TableIdx*(sizeof(uint32_t)*2);
assert(NextPPCondPtr >= CurPPCondPtr);
CurPPCondPtr = NextPPCondPtr;
-
+
// Read where we should jump to.
HashEntryI = TokBuf + ReadLE32(NextPPCondPtr);
uint32_t NextIdx = ReadLE32(NextPPCondPtr);
-
+
// By construction NextIdx will be zero if this is a #endif. This is useful
// to know to obviate lexing another token.
bool isEndif = NextIdx == 0;
-
+
// This case can occur when we see something like this:
//
// #if ...
@@ -243,7 +243,7 @@ bool PTHLexer::SkipBlock() {
//
// If we are skipping the first #if block it will be the case that CurPtr
// already points 'elif'. Just return.
-
+
if (CurPtr > HashEntryI) {
assert(CurPtr == HashEntryI + DISK_TOKEN_SIZE);
// Did we reach a #endif? If so, go ahead and consume that token as well.
@@ -251,13 +251,13 @@ bool PTHLexer::SkipBlock() {
CurPtr += DISK_TOKEN_SIZE*2;
else
LastHashTokPtr = HashEntryI;
-
+
return isEndif;
}
// Otherwise, we need to advance. Update CurPtr to point to the '#' token.
CurPtr = HashEntryI;
-
+
// Update the location of the last observed '#'. This is useful if we
// are skipping multiple blocks.
LastHashTokPtr = CurPtr;
@@ -265,7 +265,7 @@ bool PTHLexer::SkipBlock() {
// Skip the '#' token.
assert(((tok::TokenKind)*CurPtr) == tok::hash);
CurPtr += DISK_TOKEN_SIZE;
-
+
// Did we reach a #endif? If so, go ahead and consume that token as well.
if (isEndif) { CurPtr += DISK_TOKEN_SIZE*2; }
@@ -297,12 +297,12 @@ class VISIBILITY_HIDDEN PTHFileData {
public:
PTHFileData(uint32_t tokenOff, uint32_t ppCondOff)
: TokenOff(tokenOff), PPCondOff(ppCondOff) {}
-
- uint32_t getTokenOffset() const { return TokenOff; }
- uint32_t getPPCondOffset() const { return PPCondOff; }
+
+ uint32_t getTokenOffset() const { return TokenOff; }
+ uint32_t getPPCondOffset() const { return PPCondOff; }
};
-
-
+
+
class VISIBILITY_HIDDEN PTHFileLookupCommonTrait {
public:
typedef std::pair<unsigned char, const char*> internal_key_type;
@@ -310,84 +310,84 @@ public:
static unsigned ComputeHash(internal_key_type x) {
return BernsteinHash(x.second);
}
-
+
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
unsigned keyLen = (unsigned) ReadUnalignedLE16(d);
unsigned dataLen = (unsigned) *(d++);
return std::make_pair(keyLen, dataLen);
}
-
+
static internal_key_type ReadKey(const unsigned char* d, unsigned) {
unsigned char k = *(d++); // Read the entry kind.
return std::make_pair(k, (const char*) d);
}
};
-
+
class VISIBILITY_HIDDEN PTHFileLookupTrait : public PTHFileLookupCommonTrait {
public:
typedef const FileEntry* external_key_type;
typedef PTHFileData data_type;
-
+
static internal_key_type GetInternalKey(const FileEntry* FE) {
return std::make_pair((unsigned char) 0x1, FE->getName());
}
static bool EqualKey(internal_key_type a, internal_key_type b) {
return a.first == b.first && strcmp(a.second, b.second) == 0;
- }
-
- static PTHFileData ReadData(const internal_key_type& k,
- const unsigned char* d, unsigned) {
+ }
+
+ static PTHFileData ReadData(const internal_key_type& k,
+ const unsigned char* d, unsigned) {
assert(k.first == 0x1 && "Only file lookups can match!");
uint32_t x = ::ReadUnalignedLE32(d);
uint32_t y = ::ReadUnalignedLE32(d);
- return PTHFileData(x, y);
+ return PTHFileData(x, y);
}
};
class VISIBILITY_HIDDEN PTHStringLookupTrait {
public:
- typedef uint32_t
+ typedef uint32_t
data_type;
typedef const std::pair<const char*, unsigned>
external_key_type;
typedef external_key_type internal_key_type;
-
+
static bool EqualKey(const internal_key_type& a,
const internal_key_type& b) {
return (a.second == b.second) ? memcmp(a.first, b.first, a.second) == 0
: false;
}
-
+
static unsigned ComputeHash(const internal_key_type& a) {
return BernsteinHash(a.first, a.second);
}
-
+
// This hopefully will just get inlined and removed by the optimizer.
static const internal_key_type&
GetInternalKey(const external_key_type& x) { return x; }
-
+
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
return std::make_pair((unsigned) ReadUnalignedLE16(d), sizeof(uint32_t));
}
-
+
static std::pair<const char*, unsigned>
ReadKey(const unsigned char* d, unsigned n) {
assert(n >= 2 && d[n-1] == '\0');
return std::make_pair((const char*) d, n-1);
}
-
+
static uint32_t ReadData(const internal_key_type& k, const unsigned char* d,
unsigned) {
return ::ReadUnalignedLE32(d);
}
};
-
-} // end anonymous namespace
+
+} // end anonymous namespace
typedef OnDiskChainedHashTable<PTHFileLookupTrait> PTHFileLookup;
typedef OnDiskChainedHashTable<PTHStringLookupTrait> PTHStringIdLookup;
@@ -398,7 +398,7 @@ typedef OnDiskChainedHashTable<PTHStringLookupTrait> PTHStringIdLookup;
PTHManager::PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup,
const unsigned char* idDataTable,
- IdentifierInfo** perIDCache,
+ IdentifierInfo** perIDCache,
void* stringIdLookup, unsigned numIds,
const unsigned char* spellingBase,
const char* originalSourceFile)
@@ -416,7 +416,7 @@ PTHManager::~PTHManager() {
static void InvalidPTH(Diagnostic *Diags, Diagnostic::Level level,
const char* Msg = 0) {
- if (!Diags) return;
+ if (!Diags) return;
if (!Msg) Msg = "Invalid or corrupted PTH file";
unsigned DiagID = Diags->getCustomDiagID(level, Msg);
Diags->Report(FullSourceLoc(), DiagID);
@@ -427,7 +427,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
// Memory map the PTH file.
llvm::OwningPtr<llvm::MemoryBuffer>
File(llvm::MemoryBuffer::getFile(file.c_str()));
-
+
if (!File) {
if (Diags) {
unsigned DiagID = Diags->getCustomDiagID(level,
@@ -437,7 +437,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
return 0;
}
-
+
// Get the buffer ranges and check if there are at least three 32-bit
// words at the end of the file.
const unsigned char* BufBeg = (unsigned char*)File->getBufferStart();
@@ -449,54 +449,54 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
InvalidPTH(Diags, level);
return 0;
}
-
+
// Read the PTH version.
const unsigned char *p = BufBeg + (sizeof("cfe-pth") - 1);
unsigned Version = ReadLE32(p);
-
+
if (Version != PTHManager::Version) {
InvalidPTH(Diags, level,
- Version < PTHManager::Version
+ Version < PTHManager::Version
? "PTH file uses an older PTH format that is no longer supported"
: "PTH file uses a newer PTH format that cannot be read");
return 0;
}
- // Compute the address of the index table at the end of the PTH file.
+ // Compute the address of the index table at the end of the PTH file.
const unsigned char *PrologueOffset = p;
-
+
if (PrologueOffset >= BufEnd) {
InvalidPTH(Diags, level);
return 0;
}
-
+
// Construct the file lookup table. This will be used for mapping from
// FileEntry*'s to cached tokens.
const unsigned char* FileTableOffset = PrologueOffset + sizeof(uint32_t)*2;
const unsigned char* FileTable = BufBeg + ReadLE32(FileTableOffset);
-
+
if (!(FileTable > BufBeg && FileTable < BufEnd)) {
InvalidPTH(Diags, level);
return 0; // FIXME: Proper error diagnostic?
}
-
+
llvm::OwningPtr<PTHFileLookup> FL(PTHFileLookup::Create(FileTable, BufBeg));
-
+
// Warn if the PTH file is empty. We still want to create a PTHManager
// as the PTH could be used with -include-pth.
if (FL->isEmpty())
InvalidPTH(Diags, level, "PTH file contains no cached source data");
-
+
// Get the location of the table mapping from persistent ids to the
// data needed to reconstruct identifiers.
const unsigned char* IDTableOffset = PrologueOffset + sizeof(uint32_t)*0;
const unsigned char* IData = BufBeg + ReadLE32(IDTableOffset);
-
+
if (!(IData >= BufBeg && IData < BufEnd)) {
InvalidPTH(Diags, level);
return 0;
}
-
+
// Get the location of the hashtable mapping between strings and
// persistent IDs.
const unsigned char* StringIdTableOffset = PrologueOffset + sizeof(uint32_t)*1;
@@ -508,7 +508,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
llvm::OwningPtr<PTHStringIdLookup> SL(PTHStringIdLookup::Create(StringIdTable,
BufBeg));
-
+
// Get the location of the spelling cache.
const unsigned char* spellingBaseOffset = PrologueOffset + sizeof(uint32_t)*3;
const unsigned char* spellingBase = BufBeg + ReadLE32(spellingBaseOffset);
@@ -516,19 +516,19 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
InvalidPTH(Diags, level);
return 0;
}
-
+
// Get the number of IdentifierInfos and pre-allocate the identifier cache.
uint32_t NumIds = ReadLE32(IData);
-
+
// Pre-allocate the peristent ID -> IdentifierInfo* cache. We use calloc()
// so that we in the best case only zero out memory once when the OS returns
// us new pages.
IdentifierInfo** PerIDCache = 0;
-
+
if (NumIds) {
- PerIDCache = (IdentifierInfo**)calloc(NumIds, sizeof(*PerIDCache));
+ PerIDCache = (IdentifierInfo**)calloc(NumIds, sizeof(*PerIDCache));
if (!PerIDCache) {
- InvalidPTH(Diags, level,
+ InvalidPTH(Diags, level,
"Could not allocate memory for processing PTH file");
return 0;
}
@@ -537,8 +537,8 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags,
// Compute the address of the original source file.
const unsigned char* originalSourceBase = PrologueOffset + sizeof(uint32_t)*4;
unsigned len = ReadUnalignedLE16(originalSourceBase);
- if (!len) originalSourceBase = 0;
-
+ if (!len) originalSourceBase = 0;
+
// Create the new PTHManager.
return new PTHManager(File.take(), FL.take(), IData, PerIDCache,
SL.take(), NumIds, spellingBase,
@@ -551,7 +551,7 @@ IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
const unsigned char* IDData =
(const unsigned char*)Buf->getBufferStart() + ReadLE32(TableEntry);
assert(IDData < (const unsigned char*)Buf->getBufferEnd());
-
+
// Allocate the object.
std::pair<IdentifierInfo,const unsigned char*> *Mem =
Alloc.Allocate<std::pair<IdentifierInfo,const unsigned char*> >();
@@ -559,7 +559,7 @@ IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
Mem->second = IDData;
assert(IDData[0] != '\0');
IdentifierInfo *II = new ((void*) Mem) IdentifierInfo();
-
+
// Store the new IdentifierInfo in the cache.
PerIDCache[PersistentID] = II;
assert(II->getName() && II->getName()[0] != '\0');
@@ -584,18 +584,18 @@ PTHLexer *PTHManager::CreateLexer(FileID FID) {
const FileEntry *FE = PP->getSourceManager().getFileEntryForID(FID);
if (!FE)
return 0;
-
+
// Lookup the FileEntry object in our file lookup data structure. It will
// return a variant that indicates whether or not there is an offset within
// the PTH file that contains cached tokens.
PTHFileLookup& PFL = *((PTHFileLookup*)FileLookup);
PTHFileLookup::iterator I = PFL.find(FE);
-
+
if (I == PFL.end()) // No tokens available?
return 0;
-
- const PTHFileData& FileData = *I;
-
+
+ const PTHFileData& FileData = *I;
+
const unsigned char *BufStart = (const unsigned char *)Buf->getBufferStart();
// Compute the offset of the token data within the buffer.
const unsigned char* data = BufStart + FileData.getTokenOffset();
@@ -604,9 +604,9 @@ PTHLexer *PTHManager::CreateLexer(FileID FID) {
const unsigned char* ppcond = BufStart + FileData.getPPCondOffset();
uint32_t Len = ReadLE32(ppcond);
if (Len == 0) ppcond = 0;
-
+
assert(PP && "No preprocessor set yet!");
- return new PTHLexer(*PP, FID, data, ppcond, *this);
+ return new PTHLexer(*PP, FID, data, ppcond, *this);
}
//===----------------------------------------------------------------------===//
@@ -622,19 +622,19 @@ public:
const mode_t mode;
const time_t mtime;
const off_t size;
-
+
PTHStatData(ino_t i, dev_t d, mode_t mo, time_t m, off_t s)
- : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
-
+ : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
+
PTHStatData()
: hasStat(false), ino(0), dev(0), mode(0), mtime(0), size(0) {}
};
-
+
class VISIBILITY_HIDDEN PTHStatLookupTrait : public PTHFileLookupCommonTrait {
public:
typedef const char* external_key_type; // const char*
typedef PTHStatData data_type;
-
+
static internal_key_type GetInternalKey(const char *path) {
// The key 'kind' doesn't matter here because it is ignored in EqualKey.
return std::make_pair((unsigned char) 0x0, path);
@@ -644,17 +644,17 @@ public:
// When doing 'stat' lookups we don't care about the kind of 'a' and 'b',
// just the paths.
return strcmp(a.second, b.second) == 0;
- }
-
+ }
+
static data_type ReadData(const internal_key_type& k, const unsigned char* d,
- unsigned) {
-
+ unsigned) {
+
if (k.first /* File or Directory */) {
if (k.first == 0x1 /* File */) d += 4 * 2; // Skip the first 2 words.
ino_t ino = (ino_t) ReadUnalignedLE32(d);
dev_t dev = (dev_t) ReadUnalignedLE32(d);
mode_t mode = (mode_t) ReadUnalignedLE16(d);
- time_t mtime = (time_t) ReadUnalignedLE64(d);
+ time_t mtime = (time_t) ReadUnalignedLE64(d);
return data_type(ino, dev, mode, mtime, (off_t) ReadUnalignedLE64(d));
}
@@ -667,22 +667,22 @@ class VISIBILITY_HIDDEN PTHStatCache : public StatSysCallCache {
typedef OnDiskChainedHashTable<PTHStatLookupTrait> CacheTy;
CacheTy Cache;
-public:
+public:
PTHStatCache(PTHFileLookup &FL) :
Cache(FL.getNumBuckets(), FL.getNumEntries(), FL.getBuckets(),
FL.getBase()) {}
~PTHStatCache() {}
-
+
int stat(const char *path, struct stat *buf) {
// Do the lookup for the file's data in the PTH file.
CacheTy::iterator I = Cache.find(path);
// If we don't get a hit in the PTH file just forward to 'stat'.
if (I == Cache.end()) return ::stat(path, buf);
-
+
const PTHStatData& Data = *I;
-
+
if (!Data.hasStat)
return 1;
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index fbdbd0b6e7..8b46f71691 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -44,9 +44,9 @@ PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name,
bool IgnoreNull) const {
PragmaHandler *NullHandler = 0;
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
- if (Handlers[i]->getName() == Name)
+ if (Handlers[i]->getName() == Name)
return Handlers[i];
-
+
if (Handlers[i]->getName() == 0)
NullHandler = Handlers[i];
}
@@ -68,14 +68,14 @@ void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
// Read the 'namespace' that the directive is in, e.g. STDC. Do not macro
// expand it, the user can have a STDC #define, that should not affect this.
PP.LexUnexpandedToken(Tok);
-
+
// Get the handler for this token. If there is no handler, ignore the pragma.
PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false);
if (Handler == 0) {
PP.Diag(Tok, diag::warn_pragma_ignored);
return;
}
-
+
// Otherwise, pass it down.
Handler->HandlePragma(PP, Tok);
}
@@ -88,11 +88,11 @@ void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
/// rest of the pragma, passing it to the registered pragma handlers.
void Preprocessor::HandlePragmaDirective() {
++NumPragma;
-
+
// Invoke the first level of pragma handlers which reads the namespace id.
Token Tok;
PragmaHandlers->HandlePragma(*this, Tok);
-
+
// If the pragma handler didn't read the rest of the line, consume it now.
if (CurPPLexer && CurPPLexer->ParsingPreprocessorDirective)
DiscardUntilEndOfDirective();
@@ -104,7 +104,7 @@ void Preprocessor::HandlePragmaDirective() {
void Preprocessor::Handle_Pragma(Token &Tok) {
// Remember the pragma token location.
SourceLocation PragmaLoc = Tok.getLocation();
-
+
// Read the '('.
Lex(Tok);
if (Tok.isNot(tok::l_paren)) {
@@ -118,7 +118,7 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
Diag(PragmaLoc, diag::err__Pragma_malformed);
return;
}
-
+
// Remember the string.
std::string StrVal = getSpelling(Tok);
@@ -128,9 +128,9 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
Diag(PragmaLoc, diag::err__Pragma_malformed);
return;
}
-
+
SourceLocation RParenLoc = Tok.getLocation();
-
+
// The _Pragma is lexically sound. Destringize according to C99 6.10.9.1:
// "The string literal is destringized by deleting the L prefix, if present,
// deleting the leading and trailing double-quotes, replacing each escape
@@ -140,14 +140,14 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
StrVal.erase(StrVal.begin());
assert(StrVal[0] == '"' && StrVal[StrVal.size()-1] == '"' &&
"Invalid string token!");
-
+
// Remove the front quote, replacing it with a space, so that the pragma
// contents appear to have a space before them.
StrVal[0] = ' ';
-
+
// Replace the terminating quote with a \n.
StrVal[StrVal.size()-1] = '\n';
-
+
// Remove escaped quotes and escapes.
for (unsigned i = 0, e = StrVal.size(); i != e-1; ++i) {
if (StrVal[i] == '\\' &&
@@ -157,7 +157,7 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
--e;
}
}
-
+
// Plop the string (including the newline and trailing null) into a buffer
// where we can lex it.
Token TmpTok;
@@ -174,7 +174,7 @@ void Preprocessor::Handle_Pragma(Token &Tok) {
// With everything set up, lex this as a #pragma directive.
HandlePragmaDirective();
-
+
// Finally, return whatever came after the pragma directive.
return Lex(Tok);
}
@@ -188,7 +188,7 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
Diag(OnceTok, diag::pp_pragma_once_in_main_file);
return;
}
-
+
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
// Mark the file as a once-only file now.
HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
@@ -217,27 +217,27 @@ void Preprocessor::HandlePragmaPoison(Token &PoisonTok) {
if (CurPPLexer) CurPPLexer->LexingRawMode = true;
LexUnexpandedToken(Tok);
if (CurPPLexer) CurPPLexer->LexingRawMode = false;
-
+
// If we reached the end of line, we're done.
if (Tok.is(tok::eom)) return;
-
+
// Can only poison identifiers.
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_pp_invalid_poison);
return;
}
-
+
// Look up the identifier info for the token. We disabled identifier lookup
// by saying we're skipping contents, so we need to do this manually.
IdentifierInfo *II = LookUpIdentifierInfo(Tok);
-
+
// Already poisoned.
if (II->isPoisoned()) continue;
-
+
// If this is a macro identifier, emit a warning.
if (II->hasMacroDefinition())
Diag(Tok, diag::pp_poisoning_existing_macro);
-
+
// Finally, poison it!
II->setIsPoisoned();
}
@@ -250,25 +250,25 @@ void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) {
Diag(SysHeaderTok, diag::pp_pragma_sysheader_in_main_file);
return;
}
-
+
// Get the current file lexer we're looking at. Ignore _Pragma 'files' etc.
PreprocessorLexer *TheLexer = getCurrentFileLexer();
-
+
// Mark the file as a system header.
HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry());
-
-
+
+
PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation());
unsigned FilenameLen = strlen(PLoc.getFilename());
unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename(),
FilenameLen);
-
+
// Emit a line marker. This will change any source locations from this point
// forward to realize they are in a system header.
// Create a line note with this information.
SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine(), FilenameID,
false, false, true, false);
-
+
// Notify the client, if desired, that we are in a new source file.
if (Callbacks)
Callbacks->FileChanged(SysHeaderTok.getLocation(),
@@ -284,11 +284,11 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
// If the token kind is EOM, the error has already been diagnosed.
if (FilenameTok.is(tok::eom))
return;
-
+
// Reserve a buffer to get the spelling.
llvm::SmallVector<char, 128> FilenameBuffer;
FilenameBuffer.resize(FilenameTok.getLength());
-
+
const char *FilenameStart = &FilenameBuffer[0];
unsigned Len = getSpelling(FilenameTok, FilenameStart);
const char *FilenameEnd = FilenameStart+Len;
@@ -298,7 +298,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
// error.
if (FilenameStart == 0)
return;
-
+
// Search include directories for this file.
const DirectoryLookup *CurDir;
const FileEntry *File = LookupFile(FilenameStart, FilenameEnd,
@@ -308,7 +308,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
<< std::string(FilenameStart, FilenameEnd);
return;
}
-
+
const FileEntry *CurFile = getCurrentFileLexer()->getFileEntry();
// If this file is older than the file it depends on, emit a diagnostic.
@@ -320,7 +320,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) {
Message += getSpelling(DependencyTok) + " ";
Lex(DependencyTok);
}
-
+
Message.erase(Message.end()-1);
Diag(FilenameTok, diag::pp_out_of_date_dependency) << Message;
}
@@ -339,23 +339,23 @@ void Preprocessor::HandlePragmaComment(Token &Tok) {
Diag(CommentLoc, diag::err_pragma_comment_malformed);
return;
}
-
+
// Read the identifier.
Lex(Tok);
if (Tok.isNot(tok::identifier)) {
Diag(CommentLoc, diag::err_pragma_comment_malformed);
return;
}
-
+
// Verify that this is one of the 5 whitelisted options.
// FIXME: warn that 'exestr' is deprecated.
const IdentifierInfo *II = Tok.getIdentifierInfo();
- if (!II->isStr("compiler") && !II->isStr("exestr") && !II->isStr("lib") &&
+ if (!II->isStr("compiler") && !II->isStr("exestr") && !II->isStr("lib") &&
!II->isStr("linker") && !II->isStr("user")) {
Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind);
return;
}
-
+
// Read the optional string if present.
Lex(Tok);
std::string ArgumentString;
@@ -390,13 +390,13 @@ void Preprocessor::HandlePragmaComment(Token &Tok) {
ArgumentString = std::string(Literal.GetString(),
Literal.GetString()+Literal.GetStringLength());
}
-
+
// FIXME: If the kind is "compiler" warn if the string is present (it is
// ignored).
// FIXME: 'lib' requires a comment string.
// FIXME: 'linker' requires a comment string, and has a specific list of
// things that are allowable.
-
+
if (Tok.isNot(tok::r_paren)) {
Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
return;
@@ -407,7 +407,7 @@ void Preprocessor::HandlePragmaComment(Token &Tok) {
Diag(Tok.getLocation(), diag::err_pragma_comment_malformed);
return;
}
-
+
// If the pragma is lexically sound, notify any interested PPCallbacks.
if (Callbacks)
Callbacks->PragmaComment(CommentLoc, II, ArgumentString);
@@ -419,14 +419,14 @@ void Preprocessor::HandlePragmaComment(Token &Tok) {
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
-void Preprocessor::AddPragmaHandler(const char *Namespace,
+void Preprocessor::AddPragmaHandler(const char *Namespace,
PragmaHandler *Handler) {
PragmaNamespace *InsertNS = PragmaHandlers;
-
+
// If this is specified to be in a namespace, step down into it.
if (Namespace) {
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
-
+
// If there is already a pragma handler with the name of this namespace,
// we either have an error (directive with the same name as a namespace) or
// we already have the namespace to insert into.
@@ -441,7 +441,7 @@ void Preprocessor::AddPragmaHandler(const char *Namespace,
PragmaHandlers->AddPragma(InsertNS);
}
}
-
+
// Check to make sure we don't already have a pragma for this identifier.
assert(!InsertNS->FindHandler(Handler->getName()) &&
"Pragma handler already exists for this identifier!");
@@ -455,7 +455,7 @@ void Preprocessor::AddPragmaHandler(const char *Namespace,
void Preprocessor::RemovePragmaHandler(const char *Namespace,
PragmaHandler *Handler) {
PragmaNamespace *NS = PragmaHandlers;
-
+
// If this is specified to be in a namespace, step down into it.
if (Namespace) {
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
@@ -467,7 +467,7 @@ void Preprocessor::RemovePragmaHandler(const char *Namespace,
}
NS->RemovePragmaHandler(Handler);
-
+
// If this is a non-default namespace and it is now empty, remove
// it.
if (NS != PragmaHandlers && NS->IsEmpty())
@@ -516,7 +516,7 @@ struct PragmaDependencyHandler : public PragmaHandler {
PP.HandlePragmaDependency(DepToken);
}
};
-
+
/// PragmaDiagnosticHandler - e.g. '#pragma GCC diagnostic ignored "-Wformat"'
/// Since clang's diagnostic supports extended functionality beyond GCC's
/// the constructor takes a clangMode flag to tell it whether or not to allow
@@ -538,7 +538,7 @@ public:
return;
}
IdentifierInfo *II = Tok.getIdentifierInfo();
-
+
diag::Mapping Map;
if (II->isStr("warning"))
Map = diag::MAP_WARNING;
@@ -550,14 +550,14 @@ public:
Map = diag::MAP_FATAL;
else if (ClangMode) {
if (II->isStr("pop")) {
- if(!PP.getDiagnostics().popMappings())
+ if (!PP.getDiagnostics().popMappings())
PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_cannot_ppp);
return;
}
if (II->isStr("push")) {
PP.getDiagnostics().pushMappings();
- return;
+ return;
}
PP.Diag(Tok, diag::warn_pragma_diagnostic_clang_invalid);
@@ -566,7 +566,7 @@ public:
PP.Diag(Tok, diag::warn_pragma_diagnostic_gcc_invalid);
return;
}
-
+
PP.LexUnexpandedToken(Tok);
// We need at least one string.
@@ -574,7 +574,7 @@ public:
PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
return;
}
-
+
// String concatenation allows multiple strings, which can even come from
// macro expansion.
// "foo " "bar" "Baz"
@@ -583,12 +583,12 @@ public:
StrToks.push_back(Tok);
PP.LexUnexpandedToken(Tok);
}
-
+
if (Tok.isNot(tok::eom)) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_diagnostic_invalid_token);
return;
}
-
+
// Concatenate and parse the strings.
StringLiteralParser Literal(&StrToks[0], StrToks.size(), PP);
assert(!Literal.AnyWide && "Didn't allow wide strings in");
@@ -610,14 +610,14 @@ public:
diag::warn_pragma_diagnostic_invalid_option);
return;
}
-
+
if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.c_str()+2,
Map))
PP.Diag(StrToks[0].getLocation(),
diag::warn_pragma_diagnostic_unknown_warning) << WarningName;
}
};
-
+
/// PragmaCommentHandler - "#pragma comment ...".
struct PragmaCommentHandler : public PragmaHandler {
PragmaCommentHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
@@ -625,13 +625,13 @@ struct PragmaCommentHandler : public PragmaHandler {
PP.HandlePragmaComment(CommentTok);
}
};
-
+
// Pragma STDC implementations.
enum STDCSetting {
STDC_ON, STDC_OFF, STDC_DEFAULT, STDC_INVALID
};
-
+
static STDCSetting LexOnOffSwitch(Preprocessor &PP) {
Token Tok;
PP.LexUnexpandedToken(Tok);
@@ -659,7 +659,7 @@ static STDCSetting LexOnOffSwitch(Preprocessor &PP) {
PP.Diag(Tok, diag::ext_stdc_pragma_syntax_eom);
return Result;
}
-
+
/// PragmaSTDC_FP_CONTRACTHandler - "#pragma STDC FP_CONTRACT ...".
struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
PragmaSTDC_FP_CONTRACTHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
@@ -671,7 +671,7 @@ struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
LexOnOffSwitch(PP);
}
};
-
+
/// PragmaSTDC_FENV_ACCESSHandler - "#pragma STDC FENV_ACCESS ...".
struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
@@ -680,7 +680,7 @@ struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
}
};
-
+
/// PragmaSTDC_CX_LIMITED_RANGEHandler - "#pragma STDC CX_LIMITED_RANGE ...".
struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
PragmaSTDC_CX_LIMITED_RANGEHandler(const IdentifierInfo *ID)
@@ -689,7 +689,7 @@ struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
LexOnOffSwitch(PP);
}
};
-
+
/// PragmaSTDC_UnknownHandler - "#pragma STDC ...".
struct PragmaSTDC_UnknownHandler : public PragmaHandler {
PragmaSTDC_UnknownHandler() : PragmaHandler(0) {}
@@ -698,7 +698,7 @@ struct PragmaSTDC_UnknownHandler : public PragmaHandler {
PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
}
};
-
+
} // end anonymous namespace
@@ -707,7 +707,7 @@ struct PragmaSTDC_UnknownHandler : public PragmaHandler {
void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler(0, new PragmaOnceHandler(getIdentifierInfo("once")));
AddPragmaHandler(0, new PragmaMarkHandler(getIdentifierInfo("mark")));
-
+
// #pragma GCC ...
AddPragmaHandler("GCC", new PragmaPoisonHandler(getIdentifierInfo("poison")));
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler(
@@ -735,7 +735,7 @@ void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler(
getIdentifierInfo("CX_LIMITED_RANGE")));
AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler());
-
+
// MS extensions.
if (Features.Microsoft)
AddPragmaHandler(0, new PragmaCommentHandler(getIdentifierInfo("comment")));
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 4b1cd63187..bfa090a09e 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -46,7 +46,7 @@ using namespace clang;
PreprocessorFactory::~PreprocessorFactory() {}
Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
- TargetInfo &target, SourceManager &SM,
+ TargetInfo &target, SourceManager &SM,
HeaderSearch &Headers,
IdentifierInfoLookup* IILookup)
: Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()),
@@ -54,20 +54,20 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
BuiltinInfo(Target), CurPPLexer(0), CurDirLookup(0), Callbacks(0) {
ScratchBuf = new ScratchBuffer(SourceMgr);
CounterValue = 0; // __COUNTER__ starts at 0.
-
+
// Clear stats.
NumDirectives = NumDefined = NumUndefined = NumPragma = 0;
NumIf = NumElse = NumEndif = 0;
NumEnteredSourceFiles = 0;
NumMacroExpanded = NumFnMacroExpanded = NumBuiltinMacroExpanded = 0;
NumFastMacroExpanded = NumTokenPaste = NumFastTokenPaste = 0;
- MaxIncludeStackDepth = 0;
+ MaxIncludeStackDepth = 0;
NumSkipped = 0;
// Default to discarding comments.
KeepComments = false;
KeepMacroComments = false;
-
+
// Macro expansion is enabled.
DisableMacroExpansion = false;
InMacroArgs = false;
@@ -78,11 +78,11 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
// "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.
// This gets unpoisoned where it is allowed.
(Ident__VA_ARGS__ = getIdentifierInfo("__VA_ARGS__"))->setIsPoisoned();
-
+
// Initialize the pragma handlers.
PragmaHandlers = new PragmaNamespace(0);
RegisterBuiltinPragmas();
-
+
// Initialize builtin macros like __LINE__ and friends.
RegisterBuiltinMacros();
}
@@ -106,11 +106,11 @@ Preprocessor::~Preprocessor() {
I->second->Destroy(BP);
I->first->setHasMacroDefinition(false);
}
-
+
// Free any cached macro expanders.
for (unsigned i = 0, e = NumCachedTokenLexers; i != e; ++i)
delete TokenLexerCache[i];
-
+
// Release pragma information.
delete PragmaHandlers;
@@ -128,9 +128,9 @@ void Preprocessor::setPTHManager(PTHManager* pm) {
void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
llvm::errs() << tok::getTokenName(Tok.getKind()) << " '"
<< getSpelling(Tok) << "'";
-
+
if (!DumpFlags) return;
-
+
llvm::errs() << "\t";
if (Tok.isAtStartOfLine())
llvm::errs() << " [StartOfLine]";
@@ -143,7 +143,7 @@ void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
llvm::errs() << " [UnClean='" << std::string(Start, Start+Tok.getLength())
<< "']";
}
-
+
llvm::errs() << "\tLoc=<";
DumpLocation(Tok.getLocation());
llvm::errs() << ">";
@@ -201,10 +201,10 @@ std::string Preprocessor::getSpelling(const Token &Tok) const {
const char* TokStart = SourceMgr.getCharacterData(Tok.getLocation());
if (!Tok.needsCleaning())
return std::string(TokStart, TokStart+Tok.getLength());
-
+
std::string Result;
Result.reserve(Tok.getLength());
-
+
// Otherwise, hard case, relex the characters into the string.
for (const char *Ptr = TokStart, *End = TokStart+Tok.getLength();
Ptr != End; ) {
@@ -230,7 +230,7 @@ std::string Preprocessor::getSpelling(const Token &Tok) const {
unsigned Preprocessor::getSpelling(const Token &Tok,
const char *&Buffer) const {
assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
-
+
// If this token is an identifier, just return the string from the identifier
// table, which is very quick.
if (const IdentifierInfo *II = Tok.getIdentifierInfo()) {
@@ -240,10 +240,10 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
// Otherwise, compute the start of the token in the input lexer buffer.
const char *TokStart = 0;
-
+
if (Tok.isLiteral())
TokStart = Tok.getLiteralData();
-
+
if (TokStart == 0)
TokStart = SourceMgr.getCharacterData(Tok.getLocation());
@@ -252,7 +252,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
Buffer = TokStart;
return Tok.getLength();
}
-
+
// Otherwise, hard case, relex the characters into the string.
char *OutBuf = const_cast<char*>(Buffer);
for (const char *Ptr = TokStart, *End = TokStart+Tok.getLength();
@@ -263,7 +263,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
}
assert(unsigned(OutBuf-Buffer) != Tok.getLength() &&
"NeedsCleaning flag set on something that didn't need cleaning!");
-
+
return OutBuf-Buffer;
}
@@ -273,15 +273,15 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
void Preprocessor::CreateString(const char *Buf, unsigned Len, Token &Tok,
SourceLocation InstantiationLoc) {
Tok.setLength(Len);
-
+
const char *DestPtr;
SourceLocation Loc = ScratchBuf->getToken(Buf, Len, DestPtr);
-
+
if (InstantiationLoc.isValid())
Loc = SourceMgr.createInstantiationLoc(Loc, InstantiationLoc,
InstantiationLoc, Len);
Tok.setLocation(Loc);
-
+
// If this is a literal token, set the pointer data.
if (Tok.isLiteral())
Tok.setLiteralData(DestPtr);
@@ -290,19 +290,19 @@ void Preprocessor::CreateString(const char *Buf, unsigned Len, Token &Tok,
/// AdvanceToTokenCharacter - Given a location that specifies the start of a
/// token, return a new location that specifies a character within the token.
-SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
+SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
unsigned CharNo) {
// Figure out how many physical characters away the specified instantiation
// character is. This needs to take into consideration newlines and
// trigraphs.
const char *TokPtr = SourceMgr.getCharacterData(TokStart);
-
+
// If they request the first char of the token, we're trivially done.
if (CharNo == 0 && Lexer::isObviouslySimpleCharacter(*TokPtr))
return TokStart;
-
+
unsigned PhysOffset = 0;
-
+
// The usual case is that tokens don't contain anything interesting. Skip
// over the uninteresting characters. If a token only consists of simple
// chars, this method is extremely fast.
@@ -311,7 +311,7 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
return TokStart.getFileLocWithOffset(PhysOffset);
++TokPtr, --CharNo, ++PhysOffset;
}
-
+
// If we have a character that may be a trigraph or escaped newline, use a
// lexer to parse it correctly.
for (; CharNo; --CharNo) {
@@ -320,14 +320,14 @@ SourceLocation Preprocessor::AdvanceToTokenCharacter(SourceLocation TokStart,
TokPtr += Size;
PhysOffset += Size;
}
-
+
// Final detail: if we end up on an escaped newline, we want to return the
// location of the actual byte of the token. For example foo\<newline>bar
// advanced by 3 should return the location of b, not of \\. One compounding
// detail of this is that the escape may be made by a trigraph.
if (!Lexer::isObviouslySimpleCharacter(*TokPtr))
PhysOffset = Lexer::SkipEscapedNewLines(TokPtr)-TokPtr;
-
+
return TokStart.getFileLocWithOffset(PhysOffset);
}
@@ -364,33 +364,33 @@ void Preprocessor::EnterMainSourceFile() {
// information) and predefined macros aren't guaranteed to be set properly.
assert(NumEnteredSourceFiles == 0 && "Cannot reenter the main file!");
FileID MainFileID = SourceMgr.getMainFileID();
-
+
// Enter the main file source buffer.
EnterSourceFile(MainFileID, 0);
-
+
// Tell the header info that the main file was entered. If the file is later
// #imported, it won't be re-entered.
if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
HeaderInfo.IncrementIncludeCount(FE);
-
+
std::vector<char> PrologFile;
PrologFile.reserve(4080);
-
+
// FIXME: Don't make a copy.
PrologFile.insert(PrologFile.end(), Predefines.begin(), Predefines.end());
-
+
// Memory buffer must end with a null byte!
PrologFile.push_back(0);
// Now that we have emitted the predefined macros, #includes, etc into
// PrologFile, preprocess it to populate the initial preprocessor state.
- llvm::MemoryBuffer *SB =
+ llvm::MemoryBuffer *SB =
llvm::MemoryBuffer::getMemBufferCopy(&PrologFile.front(),&PrologFile.back(),
"<built-in>");
assert(SB && "Cannot fail to create predefined source buffer");
FileID FID = SourceMgr.createFileIDForMemBuffer(SB);
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
-
+
// Start parsing the predefines.
EnterSourceFile(FID, 0);
}
@@ -406,7 +406,7 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier,
const char *BufPtr) {
assert(Identifier.is(tok::identifier) && "Not an identifier!");
assert(Identifier.getIdentifierInfo() == 0 && "Identinfo already exists!");
-
+
// Look up this token, see if it is a macro, or if it is a language keyword.
IdentifierInfo *II;
if (BufPtr && !Identifier.needsCleaning()) {
@@ -436,7 +436,7 @@ IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier,
void Preprocessor::HandleIdentifier(Token &Identifier) {
assert(Identifier.getIdentifierInfo() &&
"Can't handle identifiers without identifier info!");
-
+
IdentifierInfo &II = *Identifier.getIdentifierInfo();
// If this identifier was poisoned, and if it was not produced from a macro
@@ -447,7 +447,7 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
else
Diag(Identifier, diag::ext_pp_bad_vaargs_use);
}
-
+
// If this is a macro to be expanded, do it.
if (MacroInfo *MI = getMacroInfo(&II)) {
if (!DisableMacroExpansion && !Identifier.isExpandDisabled()) {
diff --git a/lib/Lex/PreprocessorLexer.cpp b/lib/Lex/PreprocessorLexer.cpp
index f9dfad9c80..e005c49476 100644
--- a/lib/Lex/PreprocessorLexer.cpp
+++ b/lib/Lex/PreprocessorLexer.cpp
@@ -26,13 +26,13 @@ void PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) {
// We are now parsing a filename!
ParsingFilename = true;
-
+
// Lex the filename.
IndirectLex(FilenameTok);
// We should have obtained the filename now.
ParsingFilename = false;
-
+
// No filename?
if (FilenameTok.is(tok::eom))
PP->Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
diff --git a/lib/Lex/ScratchBuffer.cpp b/lib/Lex/ScratchBuffer.cpp
index 28f3d7ff45..0e98c17519 100644
--- a/lib/Lex/ScratchBuffer.cpp
+++ b/lib/Lex/ScratchBuffer.cpp
@@ -38,16 +38,16 @@ SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len,
// Prefix the token with a \n, so that it looks like it is the first thing on
// its own virtual line in caret diagnostics.
CurBuffer[BytesUsed++] = '\n';
-
+
// Return a pointer to the character data.
DestPtr = CurBuffer+BytesUsed;
-
+
// Copy the token data into the buffer.
memcpy(CurBuffer+BytesUsed, Buf, Len);
// Remember that we used these bytes.
BytesUsed += Len+1;
-
+
// Add a NUL terminator to the token. This keeps the tokens separated, in
// case they get relexed, and puts them on their own virtual lines in case a
// diagnostic points to one.
@@ -62,8 +62,8 @@ void ScratchBuffer::AllocScratchBuffer(unsigned RequestLen) {
// support gigantic tokens, which almost certainly won't happen. :)
if (RequestLen < ScratchBufSize)
RequestLen = ScratchBufSize;
-
- llvm::MemoryBuffer *Buf =
+
+ llvm::MemoryBuffer *Buf =
llvm::MemoryBuffer::getNewMemBuffer(RequestLen, "<scratch space>");
FileID FID = SourceMgr.createFileIDForMemBuffer(Buf);
BufferStartLoc = SourceMgr.getLocForStartOfFile(FID);
diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp
index be13b27457..ade7f8516e 100644
--- a/lib/Lex/TokenConcatenation.cpp
+++ b/lib/Lex/TokenConcatenation.cpp
@@ -13,7 +13,7 @@
#include "clang/Lex/TokenConcatenation.h"
#include "clang/Lex/Preprocessor.h"
-using namespace clang;
+using namespace clang;
/// StartsWithL - Return true if the spelling of this token starts with 'L'.
@@ -22,14 +22,14 @@ bool TokenConcatenation::StartsWithL(const Token &Tok) const {
SourceManager &SM = PP.getSourceManager();
return *SM.getCharacterData(SM.getSpellingLoc(Tok.getLocation())) == 'L';
}
-
+
if (Tok.getLength() < 256) {
char Buffer[256];
const char *TokPtr = Buffer;
PP.getSpelling(Tok, TokPtr);
return TokPtr[0] == 'L';
}
-
+
return PP.getSpelling(Tok)[0] == 'L';
}
@@ -42,21 +42,21 @@ bool TokenConcatenation::IsIdentifierL(const Token &Tok) const {
SourceManager &SM = PP.getSourceManager();
return *SM.getCharacterData(SM.getSpellingLoc(Tok.getLocation())) == 'L';
}
-
+
if (Tok.getLength() < 256) {
char Buffer[256];
const char *TokPtr = Buffer;
- if (PP.getSpelling(Tok, TokPtr) != 1)
+ if (PP.getSpelling(Tok, TokPtr) != 1)
return false;
return TokPtr[0] == 'L';
}
-
+
return PP.getSpelling(Tok) == "L";
}
TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
memset(TokenInfo, 0, sizeof(TokenInfo));
-
+
// These tokens have custom code in AvoidConcat.
TokenInfo[tok::identifier ] |= aci_custom;
TokenInfo[tok::numeric_constant] |= aci_custom_firstchar;
@@ -72,7 +72,7 @@ TokenConcatenation::TokenConcatenation(Preprocessor &pp) : PP(pp) {
TokenInfo[tok::colon ] |= aci_custom_firstchar;
TokenInfo[tok::hash ] |= aci_custom_firstchar;
TokenInfo[tok::arrow ] |= aci_custom_firstchar;
-
+
// These tokens change behavior if followed by an '='.
TokenInfo[tok::amp ] |= aci_avoid_equal; // &=
TokenInfo[tok::plus ] |= aci_avoid_equal; // +=
@@ -130,29 +130,29 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok,
// source. If they were, it must be okay to stick them together: if there
// were an issue, the tokens would have been lexed differently.
if (PrevTok.getLocation().isFileID() && Tok.getLocation().isFileID() &&
- PrevTok.getLocation().getFileLocWithOffset(PrevTok.getLength()) ==
+ PrevTok.getLocation().getFileLocWithOffset(PrevTok.getLength()) ==
Tok.getLocation())
return false;
-
+
tok::TokenKind PrevKind = PrevTok.getKind();
if (PrevTok.getIdentifierInfo()) // Language keyword or named operator.
PrevKind = tok::identifier;
-
+
// Look up information on when we should avoid concatenation with prevtok.
unsigned ConcatInfo = TokenInfo[PrevKind];
-
+
// If prevtok never causes a problem for anything after it, return quickly.
if (ConcatInfo == 0) return false;
-
+
if (ConcatInfo & aci_avoid_equal) {
// If the next token is '=' or '==', avoid concatenation.
if (Tok.is(tok::equal) || Tok.is(tok::equalequal))
return true;
ConcatInfo &= ~aci_avoid_equal;
}
-
+
if (ConcatInfo == 0) return false;
-
+
// Basic algorithm: we look at the first character of the second token, and
// determine whether it, if appended to the first token, would form (or
// would contribute) to a larger token if concatenated.
@@ -162,10 +162,10 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok,
} else {
FirstChar = GetFirstChar(PP, Tok);
}
-
+
switch (PrevKind) {
default: assert(0 && "InitAvoidConcatTokenInfo built wrong");
- case tok::identifier: // id+id or id+number or id+L"foo".
+ case tok::identifier: // id+id or id+number or id+L"foo".
// id+'.'... will not append.
if (Tok.is(tok::numeric_constant))
return GetFirstChar(PP, Tok) != '.';
@@ -173,18 +173,18 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok,
if (Tok.getIdentifierInfo() || Tok.is(tok::wide_string_literal) /* ||
Tok.is(tok::wide_char_literal)*/)
return true;
-
+
// If this isn't identifier + string, we're done.
if (Tok.isNot(tok::char_constant) && Tok.isNot(tok::string_literal))
return false;
-
+
// FIXME: need a wide_char_constant!
-
+
// If the string was a wide string L"foo" or wide char L'f', it would
// concat with the previous identifier into fooL"bar". Avoid this.
if (StartsWithL(Tok))
return true;
-
+
// Otherwise, this is a narrow character or string. If the *identifier*
// is a literal 'L', avoid pasting L "foo" -> L"foo".
return IsIdentifierL(PrevTok);
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index f9f93867c8..f006f5ae55 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -27,11 +27,11 @@ void TokenLexer::Init(Token &Tok, SourceLocation ILEnd, MacroArgs *Actuals) {
// If the client is reusing a TokenLexer, make sure to free any memory
// associated with it.
destroy();
-
+
Macro = PP.getMacroInfo(Tok.getIdentifierInfo());
ActualArgs = Actuals;
CurToken = 0;
-
+
InstantiateLocStart = Tok.getLocation();
InstantiateLocEnd = ILEnd;
AtStartOfLine = Tok.isAtStartOfLine();
@@ -45,7 +45,7 @@ void TokenLexer::Init(Token &Tok, SourceLocation ILEnd, MacroArgs *Actuals) {
// Tokens to point to the expanded tokens.
if (Macro->isFunctionLike() && Macro->getNumArgs())
ExpandFunctionArguments();
-
+
// Mark the macro as currently disabled, so that it is not recursively
// expanded. The macro must be disabled only after argument pre-expansion of
// function-like macro arguments occurs.
@@ -61,7 +61,7 @@ void TokenLexer::Init(const Token *TokArray, unsigned NumToks,
// If the client is reusing a TokenLexer, make sure to free any memory
// associated with it.
destroy();
-
+
Macro = 0;
ActualArgs = 0;
Tokens = TokArray;
@@ -72,7 +72,7 @@ void TokenLexer::Init(const Token *TokArray, unsigned NumToks,
InstantiateLocStart = InstantiateLocEnd = SourceLocation();
AtStartOfLine = false;
HasLeadingSpace = false;
-
+
// Set HasLeadingSpace/AtStartOfLine so that the first token will be
// returned unmodified.
if (NumToks != 0) {
@@ -90,7 +90,7 @@ void TokenLexer::destroy() {
Tokens = 0;
OwnsTokens = false;
}
-
+
// TokenLexer owns its formal arguments.
if (ActualArgs) ActualArgs->destroy();
}
@@ -99,17 +99,17 @@ void TokenLexer::destroy() {
/// return preexpanded tokens from Tokens.
void TokenLexer::ExpandFunctionArguments() {
llvm::SmallVector<Token, 128> ResultToks;
-
+
// Loop through 'Tokens', expanding them into ResultToks. Keep
// track of whether we change anything. If not, no need to keep them. If so,
// we install the newly expanded sequence as the new 'Tokens' list.
bool MadeChange = false;
-
+
// NextTokGetsSpace - When this is true, the next token appended to the
// output list will get a leading space, regardless of whether it had one to
// begin with or not. This is used for placemarker support.
bool NextTokGetsSpace = false;
-
+
for (unsigned i = 0, e = NumTokens; i != e; ++i) {
// If we found the stringify operator, get the argument stringified. The
// preprocessor already verified that the following token is a macro name
@@ -118,7 +118,7 @@ void TokenLexer::ExpandFunctionArguments() {
if (CurTok.is(tok::hash) || CurTok.is(tok::hashat)) {
int ArgNo = Macro->getArgumentNum(Tokens[i+1].getIdentifierInfo());
assert(ArgNo != -1 && "Token following # is not an argument?");
-
+
Token Res;
if (CurTok.is(tok::hash)) // Stringify
Res = ActualArgs->getStringifiedArgument(ArgNo, PP);
@@ -127,19 +127,19 @@ void TokenLexer::ExpandFunctionArguments() {
Res = MacroArgs::StringifyArgument(ActualArgs->getUnexpArgument(ArgNo),
PP, true);
}
-
+
// The stringified/charified string leading space flag gets set to match
// the #/#@ operator.
if (CurTok.hasLeadingSpace() || NextTokGetsSpace)
Res.setFlag(Token::LeadingSpace);
-
+
ResultToks.push_back(Res);
MadeChange = true;
++i; // Skip arg name.
NextTokGetsSpace = false;
continue;
}
-
+
// Otherwise, if this is not an argument token, just add the token to the
// output buffer.
IdentifierInfo *II = CurTok.getIdentifierInfo();
@@ -154,17 +154,17 @@ void TokenLexer::ExpandFunctionArguments() {
}
continue;
}
-
+
// An argument is expanded somehow, the result is different than the
// input.
MadeChange = true;
// Otherwise, this is a use of the argument. Find out if there is a paste
// (##) operator before or after the argument.
- bool PasteBefore =
+ bool PasteBefore =
!ResultToks.empty() && ResultToks.back().is(tok::hashhash);
bool PasteAfter = i+1 != e && Tokens[i+1].is(tok::hashhash);
-
+
// If it is not the LHS/RHS of a ## operator, we must pre-expand the
// argument and substitute the expanded tokens into the result. This is
// C99 6.10.3.1p1.
@@ -178,13 +178,13 @@ void TokenLexer::ExpandFunctionArguments() {
ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, PP)[0];
else
ResultArgToks = ArgTok; // Use non-preexpanded tokens.
-
+
// If the arg token expanded into anything, append it.
if (ResultArgToks->isNot(tok::eof)) {
unsigned FirstResult = ResultToks.size();
unsigned NumToks = MacroArgs::getArgLength(ResultArgToks);
ResultToks.append(ResultArgToks, ResultArgToks+NumToks);
-
+
// If any tokens were substituted from the argument, the whitespace
// before the first token should match the whitespace of the arg
// identifier.
@@ -199,7 +199,7 @@ void TokenLexer::ExpandFunctionArguments() {
}
continue;
}
-
+
// Okay, we have a token that is either the LHS or RHS of a paste (##)
// argument. It gets substituted as its non-pre-expanded tokens.
const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
@@ -217,9 +217,9 @@ void TokenLexer::ExpandFunctionArguments() {
PP.Diag(ResultToks.back().getLocation(), diag::ext_paste_comma);
ResultToks.pop_back();
}
-
+
ResultToks.append(ArgToks, ArgToks+NumToks);
-
+
// If this token (the macro argument) was supposed to get leading
// whitespace, transfer this information onto the first token of the
// expansion.
@@ -233,11 +233,11 @@ void TokenLexer::ExpandFunctionArguments() {
if ((CurTok.hasLeadingSpace() || NextTokGetsSpace) &&
!PasteBefore)
ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace);
-
+
NextTokGetsSpace = false;
continue;
}
-
+
// If an empty argument is on the LHS or RHS of a paste, the standard (C99
// 6.10.3.3p2,3) calls for a bunch of placemarker stuff to occur. We
// implement this by eating ## operators when a LHS or RHS expands to
@@ -250,13 +250,13 @@ void TokenLexer::ExpandFunctionArguments() {
++i;
continue;
}
-
+
// If this is on the RHS of a paste operator, we've already copied the
// paste operator to the ResultToks list. Remove it.
assert(PasteBefore && ResultToks.back().is(tok::hashhash));
NextTokGetsSpace |= ResultToks.back().hasLeadingSpace();
ResultToks.pop_back();
-
+
// If this is the __VA_ARGS__ token, and if the argument wasn't provided,
// and if the macro had at least one real argument, and if the token before
// the ## was a comma, remove the comma.
@@ -271,7 +271,7 @@ void TokenLexer::ExpandFunctionArguments() {
}
continue;
}
-
+
// If anything changed, install this as the new Tokens list.
if (MadeChange) {
assert(!OwnsTokens && "This would leak if we already own the token list");
@@ -284,7 +284,7 @@ void TokenLexer::ExpandFunctionArguments() {
if (NumTokens)
memcpy(Res, &ResultToks[0], NumTokens*sizeof(Token));
Tokens = Res;
-
+
// The preprocessor bump pointer owns these tokens, not us.
OwnsTokens = false;
}
@@ -309,16 +309,16 @@ void TokenLexer::Lex(Token &Tok) {
// whatever is next.
return PPCache.Lex(Tok);
}
-
+
// If this is the first token of the expanded result, we inherit spacing
// properties later.
bool isFirstToken = CurToken == 0;
-
+
// Get the next token to return.
Tok = Tokens[CurToken++];
-
+
bool TokenIsFromPaste = false;
-
+
// If this token is followed by a token paste (##) operator, paste the tokens!
if (!isAtEnd() && Tokens[CurToken].is(tok::hashhash)) {
if (PasteTokens(Tok)) {
@@ -328,7 +328,7 @@ void TokenLexer::Lex(Token &Tok) {
} else {
TokenIsFromPaste = true;
}
- }
+ }
// The token's current location indicate where the token was lexed from. We
// need this information to compute the spelling of the token, but any
@@ -337,26 +337,26 @@ void TokenLexer::Lex(Token &Tok) {
// that captures all of this.
if (InstantiateLocStart.isValid()) { // Don't do this for token streams.
SourceManager &SM = PP.getSourceManager();
- Tok.setLocation(SM.createInstantiationLoc(Tok.getLocation(),
+ Tok.setLocation(SM.createInstantiationLoc(Tok.getLocation(),
InstantiateLocStart,
InstantiateLocEnd,
Tok.getLength()));
}
-
+
// If this is the first token, set the lexical properties of the token to
// match the lexical properties of the macro identifier.
if (isFirstToken) {
Tok.setFlagValue(Token::StartOfLine , AtStartOfLine);
Tok.setFlagValue(Token::LeadingSpace, HasLeadingSpace);
}
-
+
// Handle recursive expansion!
if (!Tok.isAnnotation() && Tok.getIdentifierInfo() != 0) {
// Change the kind of this identifier to the appropriate token kind, e.g.
// turning "for" into a keyword.
IdentifierInfo *II = Tok.getIdentifierInfo();
Tok.setKind(II->getTokenID());
-
+
// If this identifier was poisoned and from a paste, emit an error. This
// won't be handled by Preprocessor::HandleIdentifier because this is coming
// from a macro expansion.
@@ -367,7 +367,7 @@ void TokenLexer::Lex(Token &Tok) {
else
PP.Diag(Tok, diag::err_pp_used_poisoned_id);
}
-
+
if (!DisableMacroExpansion && II->isHandleIdentifierCase())
PP.HandleIdentifier(Tok);
}
@@ -387,33 +387,33 @@ bool TokenLexer::PasteTokens(Token &Tok) {
SourceLocation PasteOpLoc = Tokens[CurToken].getLocation();
++CurToken;
assert(!isAtEnd() && "No token on the RHS of a paste operator!");
-
+
// Get the RHS token.
const Token &RHS = Tokens[CurToken];
-
+
// Allocate space for the result token. This is guaranteed to be enough for
// the two tokens.
Buffer.resize(Tok.getLength() + RHS.getLength());
-
+
// Get the spelling of the LHS token in Buffer.
const char *BufPtr = &Buffer[0];
unsigned LHSLen = PP.getSpelling(Tok, BufPtr);
if (BufPtr != &Buffer[0]) // Really, we want the chars in Buffer!
memcpy(&Buffer[0], BufPtr, LHSLen);
-
+
BufPtr = &Buffer[LHSLen];
unsigned RHSLen = PP.getSpelling(RHS, BufPtr);
if (BufPtr != &Buffer[LHSLen]) // Really, we want the chars in Buffer!
memcpy(&Buffer[LHSLen], BufPtr, RHSLen);
-
+
// Trim excess space.
Buffer.resize(LHSLen+RHSLen);
-
+
// Plop the pasted result (including the trailing newline and null) into a
// scratch buffer where we can lex it.
Token ResultTokTmp;
ResultTokTmp.startToken();
-
+
// Claim that the tmp token is a string_literal so that we can get the
// character pointer back from CreateString.
ResultTokTmp.setKind(tok::string_literal);
@@ -423,7 +423,7 @@ bool TokenLexer::PasteTokens(Token &Tok) {
// Lex the resultant pasted token into Result.
Token Result;
-
+
if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
// Common paste case: identifier+identifier = identifier. Avoid creating
// a lexer and other overhead.
@@ -434,42 +434,42 @@ bool TokenLexer::PasteTokens(Token &Tok) {
Result.setLength(LHSLen+RHSLen);
} else {
PP.IncrementPasteCounter(false);
-
+
assert(ResultTokLoc.isFileID() &&
"Should be a raw location into scratch buffer");
SourceManager &SourceMgr = PP.getSourceManager();
FileID LocFileID = SourceMgr.getFileID(ResultTokLoc);
-
+
const char *ScratchBufStart = SourceMgr.getBufferData(LocFileID).first;
-
+
// Make a lexer to lex this string from. Lex just this one token.
// Make a lexer object so that we lex and expand the paste result.
Lexer TL(SourceMgr.getLocForStartOfFile(LocFileID),
PP.getLangOptions(), ScratchBufStart,
ResultTokStrPtr, ResultTokStrPtr+LHSLen+RHSLen);
-
+
// Lex a token in raw mode. This way it won't look up identifiers
// automatically, lexing off the end will return an eof token, and
// warnings are disabled. This returns true if the result token is the
// entire buffer.
bool isInvalid = !TL.LexFromRawLexer(Result);
-
+
// If we got an EOF token, we didn't form even ONE token. For example, we
// did "/ ## /" to get "//".
isInvalid |= Result.is(tok::eof);
-
+
// If pasting the two tokens didn't form a full new token, this is an
// error. This occurs with "x ## +" and other stuff. Return with Tok
// unmodified and with RHS as the next token to lex.
if (isInvalid) {
// Test for the Microsoft extension of /##/ turning into // here on the
// error path.
- if (PP.getLangOptions().Microsoft && Tok.is(tok::slash) &&
+ if (PP.getLangOptions().Microsoft && Tok.is(tok::slash) &&
RHS.is(tok::slash)) {
HandleMicrosoftCommentPaste(Tok);
return true;
}
-
+
// Do not emit the warning when preprocessing assembler code.
if (!PP.getLangOptions().AsmPreprocessor) {
// Explicitly convert the token location to have proper instantiation
@@ -481,26 +481,26 @@ bool TokenLexer::PasteTokens(Token &Tok) {
PP.Diag(Loc, diag::err_pp_bad_paste)
<< std::string(Buffer.begin(), Buffer.end());
}
-
+
// Do not consume the RHS.
--CurToken;
}
-
+
// Turn ## into 'unknown' to avoid # ## # from looking like a paste
// operator.
if (Result.is(tok::hashhash))
Result.setKind(tok::unknown);
}
-
+
// Transfer properties of the LHS over the the Result.
Result.setFlagValue(Token::StartOfLine , Tok.isAtStartOfLine());
Result.setFlagValue(Token::LeadingSpace, Tok.hasLeadingSpace());
-
+
// Finally, replace LHS with the result, consume the RHS, and iterate.
++CurToken;
Tok = Result;
} while (!isAtEnd() && Tokens[CurToken].is(tok::hashhash));
-
+
// Now that we got the result token, it will be subject to expansion. Since
// token pasting re-lexes the result token in raw mode, identifier information
// isn't looked up. As such, if the result is an identifier, look up id info.
@@ -532,11 +532,11 @@ unsigned TokenLexer::isNextTokenLParen() const {
void TokenLexer::HandleMicrosoftCommentPaste(Token &Tok) {
// We 'comment out' the rest of this macro by just ignoring the rest of the
// tokens that have not been lexed yet, if any.
-
+
// Since this must be a macro, mark the macro enabled now that it is no longer
// being expanded.
assert(Macro && "Token streams can't paste comments");
Macro->EnableMacro();
-
+
PP.HandleMicrosoftCommentPaste(Tok);
}
diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp
index 32ffba36dd..2ee41bc3eb 100644
--- a/lib/Parse/AttributeList.cpp
+++ b/lib/Parse/AttributeList.cpp
@@ -21,7 +21,7 @@ AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
AttributeList *n, bool declspec)
: AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
NumArgs(numArgs), Next(n), DeclspecAttribute(declspec) {
-
+
if (numArgs == 0)
Args = 0;
else {
@@ -32,12 +32,12 @@ AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
AttributeList::~AttributeList() {
if (Args) {
- // FIXME: before we delete the vector, we need to make sure the Expr's
+ // FIXME: before we delete the vector, we need to make sure the Expr's
// have been deleted. Since ActionBase::ExprTy is "void", we are dependent
// on the actions module for actually freeing the memory. The specific
- // hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType,
- // ParseField, ParseTag. Once these routines have freed the expression,
- // they should zero out the Args slot (to indicate the memory has been
+ // hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType,
+ // ParseField, ParseTag. Once these routines have freed the expression,
+ // they should zero out the Args slot (to indicate the memory has been
// freed). If any element of the vector is non-null, we should assert.
delete [] Args;
}
@@ -54,7 +54,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
Str += 2;
Len -= 4;
}
-
+
// FIXME: Hand generating this is neither smart nor efficient.
switch (Len) {
case 4:
@@ -103,7 +103,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
if (!memcmp(Str, "deprecated", 10)) return AT_deprecated;
if (!memcmp(Str, "visibility", 10)) return AT_visibility;
if (!memcmp(Str, "destructor", 10)) return AT_destructor;
- if (!memcmp(Str, "format_arg", 10)) return AT_format_arg;
+ if (!memcmp(Str, "format_arg", 10)) return AT_format_arg;
if (!memcmp(Str, "gnu_inline", 10)) return AT_gnu_inline;
break;
case 11:
@@ -136,13 +136,13 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
case 19:
if (!memcmp(Str, "ns_returns_retained", 19)) return AT_ns_returns_retained;
if (!memcmp(Str, "cf_returns_retained", 19)) return AT_cf_returns_retained;
- break;
+ break;
case 20:
if (!memcmp(Str, "reqd_work_group_size", 20)) return AT_reqd_wg_size;
case 22:
if (!memcmp(Str, "no_instrument_function", 22))
return AT_no_instrument_function;
break;
- }
+ }
return UnknownAttribute;
}
diff --git a/lib/Parse/DeclSpec.cpp b/lib/Parse/DeclSpec.cpp
index ceb19a3b3b..0342e39363 100644
--- a/lib/Parse/DeclSpec.cpp
+++ b/lib/Parse/DeclSpec.cpp
@@ -65,7 +65,7 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic,
// parameter list there (in an effort to avoid new/delete traffic). If it
// is already used (consider a function returning a function pointer) or too
// small (function taking too many arguments), go to the heap.
- if (!TheDeclarator.InlineParamsUsed &&
+ if (!TheDeclarator.InlineParamsUsed &&
NumArgs <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
I.Fun.ArgInfo = TheDeclarator.InlineParams;
I.Fun.DeleteArgInfo = false;
@@ -98,10 +98,10 @@ unsigned DeclSpec::getParsedSpecifiers() const {
if (TypeQualifiers != TQ_unspecified)
Res |= PQ_TypeQualifier;
-
+
if (hasTypeSpecifier())
Res |= PQ_TypeSpecifier;
-
+
if (FS_inline_specified || FS_virtual_specified || FS_explicit_specified)
Res |= PQ_FunctionSpecifier;
return Res;
@@ -114,7 +114,7 @@ template <class T> static bool BadSpecifier(T TNew, T TPrev,
DiagID = (TNew == TPrev ? diag::ext_duplicate_declspec
: diag::err_invalid_decl_spec_combination);
return true;
-}
+}
const char *DeclSpec::getSpecifierName(DeclSpec::SCS S) {
switch (S) {
@@ -209,7 +209,7 @@ bool DeclSpec::SetStorageClassSpec(SCS S, SourceLocation Loc,
return false;
}
-bool DeclSpec::SetStorageClassSpecThread(SourceLocation Loc,
+bool DeclSpec::SetStorageClassSpecThread(SourceLocation Loc,
const char *&PrevSpec,
unsigned &DiagID) {
if (SCS_thread_specified) {
@@ -238,7 +238,7 @@ bool DeclSpec::SetTypeSpecWidth(TSW W, SourceLocation Loc,
return false;
}
-bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
+bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
const char *&PrevSpec,
unsigned &DiagID) {
if (TypeSpecComplex != TSC_unspecified)
@@ -248,7 +248,7 @@ bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
return false;
}
-bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
+bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
const char *&PrevSpec,
unsigned &DiagID) {
if (TypeSpecSign != TSS_unspecified)
@@ -287,7 +287,7 @@ bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
if ((TypeQualifiers & T) && !Lang.C99)
return BadSpecifier(T, T, PrevSpec, DiagID);
TypeQualifiers |= T;
-
+
switch (T) {
default: assert(0 && "Unknown type qualifier!");
case TQ_const: TQ_constLoc = Loc; break;
@@ -380,7 +380,7 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
}
break;
}
-
+
// TODO: if the implementation does not implement _Complex or _Imaginary,
// disallow their use. Need information about the backend.
if (TypeSpecComplex != TSC_unspecified) {
@@ -419,9 +419,9 @@ void DeclSpec::Finish(Diagnostic &D, Preprocessor &PP) {
// Okay, now we can infer the real type.
-
+
// TODO: return "auto function" and other bad things based on the real type.
-
+
// 'data definition has no type or storage class'?
}
diff --git a/lib/Parse/ExtensionRAIIObject.h b/lib/Parse/ExtensionRAIIObject.h
index 2b2bd3b216..cc7c8e2170 100644
--- a/lib/Parse/ExtensionRAIIObject.h
+++ b/lib/Parse/ExtensionRAIIObject.h
@@ -30,7 +30,7 @@ namespace clang {
ExtensionRAIIObject(Diagnostic &diags) : Diags(diags) {
Diags.IncrementAllExtensionsSilenced();
}
-
+
~ExtensionRAIIObject() {
Diags.DecrementAllExtensionsSilenced();
}
diff --git a/lib/Parse/MinimalAction.cpp b/lib/Parse/MinimalAction.cpp
index d89cc8c3ea..71b22cad6f 100644
--- a/lib/Parse/MinimalAction.cpp
+++ b/lib/Parse/MinimalAction.cpp
@@ -34,7 +34,7 @@ Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope,
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList) {
-
+
// FIXME: Parser seems to assume that Action::ActOn* takes ownership over
// passed AttributeList, however other actions don't free it, is it
// temporary state or bug?
@@ -52,7 +52,7 @@ Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope,
OverloadedOperatorKind Op,
AttributeList *AttrList,
bool IsTypeName) {
-
+
// FIXME: Parser seems to assume that Action::ActOn* takes ownership over
// passed AttributeList, however other actions don't free it, is it
// temporary state or bug?
@@ -67,11 +67,11 @@ void PrettyStackTraceActionsDecl::print(llvm::raw_ostream &OS) const {
OS << ": ";
}
OS << Message;
-
+
std::string Name = Actions.getDeclName(TheDecl);
if (!Name.empty())
OS << " '" << Name << '\'';
-
+
OS << '\n';
}
@@ -81,7 +81,7 @@ namespace {
struct TypeNameInfo {
TypeNameInfo *Prev;
bool isTypeName;
-
+
TypeNameInfo(bool istypename, TypeNameInfo *prev) {
isTypeName = istypename;
Prev = prev;
@@ -90,13 +90,13 @@ namespace {
struct TypeNameInfoTable {
llvm::RecyclingAllocator<llvm::BumpPtrAllocator, TypeNameInfo> Allocator;
-
+
void AddEntry(bool isTypename, IdentifierInfo *II) {
TypeNameInfo *TI = Allocator.Allocate<TypeNameInfo>();
new (TI) TypeNameInfo(isTypename, II->getFETokenInfo<TypeNameInfo>());
II->setFETokenInfo(TI);
}
-
+
void DeleteEntry(TypeNameInfo *Entry) {
Entry->~TypeNameInfo();
Allocator.Deallocate(Entry);
@@ -108,7 +108,7 @@ static TypeNameInfoTable *getTable(void *TP) {
return static_cast<TypeNameInfoTable*>(TP);
}
-MinimalAction::MinimalAction(Preprocessor &pp)
+MinimalAction::MinimalAction(Preprocessor &pp)
: Idents(pp.getIdentifierTable()), PP(pp) {
TypeNameInfoTablePtr = new TypeNameInfoTable();
}
@@ -127,9 +127,9 @@ void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TNIT.AddEntry(true, &Idents.get("__int128_t"));
TNIT.AddEntry(true, &Idents.get("__uint128_t"));
}
-
+
if (PP.getLangOptions().ObjC1) {
- // Recognize the ObjC built-in type identifiers as types.
+ // Recognize the ObjC built-in type identifiers as types.
TNIT.AddEntry(true, &Idents.get("id"));
TNIT.AddEntry(true, &Idents.get("SEL"));
TNIT.AddEntry(true, &Idents.get("Class"));
@@ -159,12 +159,12 @@ bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *,
return false;
}
-TemplateNameKind
+TemplateNameKind
MinimalAction::isTemplateName(Scope *S,
const IdentifierInfo &II,
SourceLocation IdLoc,
const CXXScopeSpec *SS,
- TypeTy *ObjectType,
+ TypeTy *ObjectType,
bool EnteringScope,
TemplateTy &TemplateDecl) {
return TNK_Non_template;
@@ -176,10 +176,10 @@ MinimalAction::isTemplateName(Scope *S,
Action::DeclPtrTy
MinimalAction::ActOnDeclarator(Scope *S, Declarator &D) {
IdentifierInfo *II = D.getIdentifier();
-
+
// If there is no identifier associated with this declarator, bail out.
if (II == 0) return DeclPtrTy();
-
+
TypeNameInfo *weCurrentlyHaveTypeInfo = II->getFETokenInfo<TypeNameInfo>();
bool isTypeName =
D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef;
@@ -190,10 +190,10 @@ MinimalAction::ActOnDeclarator(Scope *S, Declarator &D) {
if (weCurrentlyHaveTypeInfo || isTypeName) {
// Allocate and add the 'TypeNameInfo' "decl".
getTable(TypeNameInfoTablePtr)->AddEntry(isTypeName, II);
-
+
// Remember that this needs to be removed when the scope is popped.
S->AddDecl(DeclPtrTy::make(II));
- }
+ }
return DeclPtrTy();
}
@@ -212,15 +212,15 @@ MinimalAction::ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
return DeclPtrTy();
}
-/// ActOnForwardClassDeclaration -
-/// Scope will always be top level file scope.
+/// ActOnForwardClassDeclaration -
+/// Scope will always be top level file scope.
Action::DeclPtrTy
MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentifierInfo **IdentList, unsigned NumElts) {
for (unsigned i = 0; i != NumElts; ++i) {
// Allocate and add the 'TypeNameInfo' "decl".
getTable(TypeNameInfoTablePtr)->AddEntry(true, IdentList[i]);
-
+
// Remember that this needs to be removed when the scope is popped.
TUScope->AddDecl(DeclPtrTy::make(IdentList[i]));
}
@@ -231,17 +231,17 @@ MinimalAction::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
/// out-of-scope, they are removed from the IdentifierInfo::FETokenInfo field.
void MinimalAction::ActOnPopScope(SourceLocation Loc, Scope *S) {
TypeNameInfoTable &Table = *getTable(TypeNameInfoTablePtr);
-
+
for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
I != E; ++I) {
IdentifierInfo &II = *(*I).getAs<IdentifierInfo>();
TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>();
assert(TI && "This decl didn't get pushed??");
-
+
if (TI) {
TypeNameInfo *Next = TI->Prev;
Table.DeleteEntry(TI);
-
+
II.setFETokenInfo(Next);
}
}
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp
index bfdbde6ddf..82b7da9f68 100644
--- a/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/lib/Parse/ParseCXXInlineMethods.cpp
@@ -36,7 +36,7 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
// FIXME: Friend templates
FnD = Actions.ActOnFriendDecl(CurScope, &D, /*IsDefinition*/ true);
else // FIXME: pass template information through
- FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D,
+ FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D,
move(TemplateParams), 0, 0);
HandleMemberFunctionDefaultArgs(D, FnD);
@@ -44,7 +44,7 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
// Consume the tokens and store them for later parsing.
getCurrentClass().MethodDefs.push_back(LexedMethod(FnD));
- getCurrentClass().MethodDefs.back().TemplateScope
+ getCurrentClass().MethodDefs.back().TemplateScope
= CurScope->isTemplateParamScope();
CachedTokens &Toks = getCurrentClass().MethodDefs.back().Toks;
@@ -54,7 +54,7 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
// Consume everything up to (and including) the left brace.
if (!ConsumeAndStoreUntil(tok::l_brace, tok::unknown, Toks, tok::semi)) {
// We didn't find the left-brace we expected after the
- // constructor initializer.
+ // constructor initializer.
if (Tok.is(tok::semi)) {
// We found a semicolon; complain, consume the semicolon, and
// don't try to parse this method later.
@@ -66,7 +66,7 @@ Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
}
} else {
- // Begin by storing the '{' token.
+ // Begin by storing the '{' token.
Toks.push_back(Tok);
ConsumeBrace();
}
@@ -100,18 +100,18 @@ void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
for (; !Class.MethodDecls.empty(); Class.MethodDecls.pop_front()) {
LateParsedMethodDeclaration &LM = Class.MethodDecls.front();
-
+
// If this is a member template, introduce the template parameter scope.
ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
if (LM.TemplateScope)
Actions.ActOnReenterTemplateScope(CurScope, LM.Method);
-
+
// Start the delayed C++ method declaration
Actions.ActOnStartDelayedCXXMethodDeclaration(CurScope, LM.Method);
// Introduce the parameters into scope and parse their default
// arguments.
- ParseScope PrototypeScope(this,
+ ParseScope PrototypeScope(this,
Scope::FunctionPrototypeScope|Scope::DeclScope);
for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
// Introduce the parameter into scope.
@@ -169,7 +169,7 @@ void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
if (LM.TemplateScope)
Actions.ActOnReenterTemplateScope(CurScope, LM.D);
-
+
assert(!LM.Toks.empty() && "Empty body!");
// Append the current token at the end of the new token stream so that it
// doesn't get lost.
@@ -205,7 +205,7 @@ void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
/// ConsumeAndStoreUntil - Consume and store the token at the passed token
/// container until the token 'T' is reached (which gets
-/// consumed/stored too, if ConsumeFinalToken).
+/// consumed/stored too, if ConsumeFinalToken).
/// If EarlyAbortIf is specified, then we will stop early if we find that
/// token at the top level.
/// Returns true if token 'T1' or 'T2' was found.
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 25ff53ca9f..5d62c0c67e 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -69,10 +69,10 @@ Action::TypeResult Parser::ParseTypeName(SourceRange *Range) {
/// typespec
/// typequal
/// storageclass
-///
+///
/// FIXME: The GCC grammar/code for this construct implies we need two
-/// token lookahead. Comment from gcc: "If they start with an identifier
-/// which is followed by a comma or close parenthesis, then the arguments
+/// token lookahead. Comment from gcc: "If they start with an identifier
+/// which is followed by a comma or close parenthesis, then the arguments
/// start with that identifier; otherwise they are an expression list."
///
/// At the moment, I am not doing 2 token lookahead. I am also unaware of
@@ -82,9 +82,9 @@ Action::TypeResult Parser::ParseTypeName(SourceRange *Range) {
AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
assert(Tok.is(tok::kw___attribute) && "Not an attribute list!");
-
+
AttributeList *CurrAttr = 0;
-
+
while (Tok.is(tok::kw___attribute)) {
ConsumeToken();
if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
@@ -99,8 +99,8 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
// Parse the attribute-list. e.g. __attribute__(( weak, alias("__f") ))
while (Tok.is(tok::identifier) || isDeclarationSpecifier() ||
Tok.is(tok::comma)) {
-
- if (Tok.is(tok::comma)) {
+
+ if (Tok.is(tok::comma)) {
// allows for empty/non-empty attributes. ((__vector_size__(16),,,,))
ConsumeToken();
continue;
@@ -108,26 +108,26 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
// we have an identifier or declaration specifier (const, int, etc.)
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
SourceLocation AttrNameLoc = ConsumeToken();
-
+
// check if we have a "paramterized" attribute
if (Tok.is(tok::l_paren)) {
ConsumeParen(); // ignore the left paren loc for now
-
+
if (Tok.is(tok::identifier)) {
IdentifierInfo *ParmName = Tok.getIdentifierInfo();
SourceLocation ParmLoc = ConsumeToken();
-
- if (Tok.is(tok::r_paren)) {
+
+ if (Tok.is(tok::r_paren)) {
// __attribute__(( mode(byte) ))
ConsumeParen(); // ignore the right paren loc for now
- CurrAttr = new AttributeList(AttrName, AttrNameLoc,
+ CurrAttr = new AttributeList(AttrName, AttrNameLoc,
ParmName, ParmLoc, 0, 0, CurrAttr);
} else if (Tok.is(tok::comma)) {
ConsumeToken();
// __attribute__(( format(printf, 1, 2) ))
ExprVector ArgExprs(Actions);
bool ArgExprsOk = true;
-
+
// now parse the non-empty comma separated list of expressions
while (1) {
OwningExprResult ArgExpr(ParseAssignmentExpression());
@@ -144,7 +144,7 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
}
if (ArgExprsOk && Tok.is(tok::r_paren)) {
ConsumeParen(); // ignore the right paren loc for now
- CurrAttr = new AttributeList(AttrName, AttrNameLoc, ParmName,
+ CurrAttr = new AttributeList(AttrName, AttrNameLoc, ParmName,
ParmLoc, ArgExprs.take(), ArgExprs.size(), CurrAttr);
}
}
@@ -154,7 +154,7 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
// parse a possibly empty comma separated list of expressions
// __attribute__(( nonnull() ))
ConsumeParen(); // ignore the right paren loc for now
- CurrAttr = new AttributeList(AttrName, AttrNameLoc,
+ CurrAttr = new AttributeList(AttrName, AttrNameLoc,
0, SourceLocation(), 0, 0, CurrAttr);
break;
case tok::kw_char:
@@ -174,7 +174,7 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
// If it's a builtin type name, eat it and expect a rparen
// __attribute__(( vec_type_hint(char) ))
ConsumeToken();
- CurrAttr = new AttributeList(AttrName, AttrNameLoc,
+ CurrAttr = new AttributeList(AttrName, AttrNameLoc,
0, SourceLocation(), 0, 0, CurrAttr);
if (Tok.is(tok::r_paren))
ConsumeParen();
@@ -183,7 +183,7 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
// __attribute__(( aligned(16) ))
ExprVector ArgExprs(Actions);
bool ArgExprsOk = true;
-
+
// now parse the list of expressions
while (1) {
OwningExprResult ArgExpr(ParseAssignmentExpression());
@@ -209,7 +209,7 @@ AttributeList *Parser::ParseAttributes(SourceLocation *EndLoc) {
}
}
} else {
- CurrAttr = new AttributeList(AttrName, AttrNameLoc,
+ CurrAttr = new AttributeList(AttrName, AttrNameLoc,
0, SourceLocation(), 0, 0, CurrAttr);
}
}
@@ -322,7 +322,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context,
default:
return ParseSimpleDeclaration(Context, DeclEnd);
}
-
+
// This routine returns a DeclGroup, if the thing we parsed only contains a
// single decl, convert it now.
return Actions.ConvertDeclToDeclGroup(SingleDecl);
@@ -341,7 +341,7 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
// Parse the common declaration-specifiers piece.
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
-
+
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
if (Tok.is(tok::semi)) {
@@ -349,24 +349,24 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(unsigned Context,
DeclPtrTy TheDecl = Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
-
+
Declarator DeclaratorInfo(DS, (Declarator::TheContext)Context);
ParseDeclarator(DeclaratorInfo);
-
+
DeclGroupPtrTy DG =
ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
DeclEnd = Tok.getLocation();
-
+
// If the client wants to check what comes after the declaration, just return
// immediately without checking anything!
if (!RequireSemi) return DG;
-
+
if (Tok.is(tok::semi)) {
ConsumeToken();
return DG;
}
-
+
Diag(Tok, diag::err_expected_semi_declaration);
// Skip to end of block or statement
SkipUntil(tok::r_brace, true, true);
@@ -406,27 +406,27 @@ Parser::DeclPtrTy Parser::ParseDeclarationAfterDeclarator(Declarator &D,
SkipUntil(tok::semi, true, true);
return DeclPtrTy();
}
-
+
D.setAsmLabel(AsmLabel.release());
D.SetRangeEnd(Loc);
}
-
+
// If attributes are present, parse them.
if (Tok.is(tok::kw___attribute)) {
SourceLocation Loc;
AttributeList *AttrList = ParseAttributes(&Loc);
D.AddAttributes(AttrList, Loc);
}
-
+
// Inform the current actions module that we just parsed this declarator.
- DeclPtrTy ThisDecl = TemplateInfo.TemplateParams?
+ DeclPtrTy ThisDecl = TemplateInfo.TemplateParams?
Actions.ActOnTemplateDeclarator(CurScope,
Action::MultiTemplateParamsArg(Actions,
TemplateInfo.TemplateParams->data(),
TemplateInfo.TemplateParams->size()),
D)
: Actions.ActOnDeclarator(CurScope, D);
-
+
// Parse declarator '=' initializer.
if (Tok.is(tok::equal)) {
ConsumeToken();
@@ -467,7 +467,7 @@ Parser::DeclPtrTy Parser::ParseDeclarationAfterDeclarator(Declarator &D,
CommaLocs.data(), RParenLoc);
}
} else {
- bool TypeContainsUndeducedAuto =
+ bool TypeContainsUndeducedAuto =
D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto;
Actions.ActOnUninitializedDecl(ThisDecl, TypeContainsUndeducedAuto);
}
@@ -492,25 +492,25 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) {
// Declarators may be grouped together ("int X, *Y, Z();"). Remember the decls
// that we parse together here.
llvm::SmallVector<DeclPtrTy, 8> DeclsInGroup;
-
+
// At this point, we know that it is not a function definition. Parse the
// rest of the init-declarator-list.
while (1) {
DeclPtrTy ThisDecl = ParseDeclarationAfterDeclarator(D);
if (ThisDecl.get())
DeclsInGroup.push_back(ThisDecl);
-
+
// If we don't have a comma, it is either the end of the list (a ';') or an
// error, bail out.
if (Tok.isNot(tok::comma))
break;
-
+
// Consume the comma.
ConsumeToken();
-
+
// Parse the next declarator.
D.clear();
-
+
// Accept attributes in an init-declarator. In the first declarator in a
// declaration, these would be part of the declspec. In subsequent
// declarators, they become part of the declarator itself, so that they
@@ -523,10 +523,10 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) {
AttributeList *AttrList = ParseAttributes(&Loc);
D.AddAttributes(AttrList, Loc);
}
-
+
ParseDeclarator(D);
}
-
+
return Actions.FinalizeDeclaratorGroup(CurScope, D.getDeclSpec(),
DeclsInGroup.data(),
DeclsInGroup.size());
@@ -542,13 +542,13 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS) {
/// specifier-qualifier-list is a subset of declaration-specifiers. Just
/// parse declaration-specifiers and complain about extra stuff.
ParseDeclarationSpecifiers(DS);
-
+
// Validate declspec for type-name.
unsigned Specs = DS.getParsedSpecifiers();
if (Specs == DeclSpec::PQ_None && !DS.getNumProtocolQualifiers() &&
!DS.getAttributes())
Diag(Tok, diag::err_typename_requires_specqual);
-
+
// Issue diagnostic and remove storage class if present.
if (Specs & DeclSpec::PQ_StorageClassSpecifier) {
if (DS.getStorageClassSpecLoc().isValid())
@@ -557,7 +557,7 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS) {
Diag(DS.getThreadSpecLoc(), diag::err_typename_invalid_storageclass);
DS.ClearStorageClassSpecs();
}
-
+
// Issue diagnostic and remove function specfier if present.
if (Specs & DeclSpec::PQ_FunctionSpecifier) {
if (DS.isInlineSpecified())
@@ -608,7 +608,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS) {
assert(Tok.is(tok::identifier) && "should have identifier");
-
+
SourceLocation Loc = Tok.getLocation();
// If we see an identifier that is not a type name, we normally would
// parse it as the identifer being declared. However, when a typename
@@ -623,7 +623,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// next token is obviously invalid for a type. Parse these as a case
// with an invalid type specifier.
assert(!DS.hasTypeSpecifier() && "Type specifier checked above");
-
+
// Since we know that this either implicit int (which is rare) or an
// error, we'd do lookahead to try to do better recovery.
if (isValidAfterIdentifierInDeclarator(NextToken())) {
@@ -632,7 +632,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// identifier in the declarator.
return false;
}
-
+
// Otherwise, if we don't consume this token, we are going to emit an
// error anyway. Try to recover from various common problems. Check
// to see if this was a reference to a tag name without a tag specified.
@@ -642,7 +642,7 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
if (SS == 0) {
const char *TagName = 0;
tok::TokenKind TagKind = tok::unknown;
-
+
switch (Actions.isTagName(*Tok.getIdentifierInfo(), CurScope)) {
default: break;
case DeclSpec::TST_enum: TagName="enum" ;TagKind=tok::kw_enum ;break;
@@ -650,12 +650,12 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
case DeclSpec::TST_struct:TagName="struct";TagKind=tok::kw_struct;break;
case DeclSpec::TST_class: TagName="class" ;TagKind=tok::kw_class ;break;
}
-
+
if (TagName) {
Diag(Loc, diag::err_use_of_tag_name_without_tag)
<< Tok.getIdentifierInfo() << TagName
<< CodeModificationHint::CreateInsertion(Tok.getLocation(),TagName);
-
+
// Parse this as a tag as if the missing tag were present.
if (TagKind == tok::kw_enum)
ParseEnumSpecifier(Loc, DS, AS);
@@ -664,20 +664,20 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
return true;
}
}
-
+
// Since this is almost certainly an invalid type name, emit a
// diagnostic that says it, eat the token, and mark the declspec as
// invalid.
SourceRange R;
if (SS) R = SS->getRange();
-
+
Diag(Loc, diag::err_unknown_typename) << Tok.getIdentifierInfo() << R;
const char *PrevSpec;
unsigned DiagID;
DS.SetTypeSpecType(DeclSpec::TST_error, Loc, PrevSpec, DiagID);
DS.SetRangeEnd(Tok.getLocation());
ConsumeToken();
-
+
// TODO: Could inject an invalid typedef decl in an enclosing scope to
// avoid rippling error messages on subsequent uses of the same type,
// could be useful if #include was forgotten.
@@ -719,13 +719,13 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
SourceLocation Loc = Tok.getLocation();
switch (Tok.getKind()) {
- default:
+ default:
DoneWithDeclSpec:
// If this is not a declaration specifier token, we're done reading decl
// specifiers. First verify that DeclSpec's are consistent.
DS.Finish(Diags, PP);
return;
-
+
case tok::coloncolon: // ::foo::bar
// Annotate C++ scope specifiers. If we get one, loop.
if (TryAnnotateCXXScopeToken(true))
@@ -738,13 +738,13 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// We are looking for a qualified typename.
Token Next = NextToken();
- if (Next.is(tok::annot_template_id) &&
+ if (Next.is(tok::annot_template_id) &&
static_cast<TemplateIdAnnotation *>(Next.getAnnotationValue())
->Kind == TNK_Type_template) {
// We have a qualified template-id, e.g., N::A<int>
CXXScopeSpec SS;
ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true);
- assert(Tok.is(tok::annot_template_id) &&
+ assert(Tok.is(tok::annot_template_id) &&
"ParseOptionalCXXScopeSpecifier not working");
AnnotateTemplateIdTokenAsType(&SS);
continue;
@@ -771,26 +771,26 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// If the referenced identifier is not a type, then this declspec is
// erroneous: We already checked about that it has no type specifier, and
// C++ doesn't have implicit int. Diagnose it as a typo w.r.t. to the
- // typename.
+ // typename.
if (TypeRep == 0) {
ConsumeToken(); // Eat the scope spec so the identifier is current.
if (ParseImplicitInt(DS, &SS, TemplateInfo, AS)) continue;
goto DoneWithDeclSpec;
}
-
+
ConsumeToken(); // The C++ scope.
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
DiagID, TypeRep);
if (isInvalid)
break;
-
+
DS.SetRangeEnd(Tok.getLocation());
ConsumeToken(); // The typename.
continue;
}
-
+
case tok::annot_typename: {
if (Tok.getAnnotationValue())
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec,
@@ -799,38 +799,38 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
DS.SetTypeSpecError();
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeToken(); // The typename
-
+
// Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id'
// is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an
// Objective-C interface. If we don't have Objective-C or a '<', this is
// just a normal reference to a typedef name.
if (!Tok.is(tok::less) || !getLang().ObjC1)
continue;
-
+
SourceLocation EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
-
+
DS.SetRangeEnd(EndProtoLoc);
continue;
}
-
+
// typedef-name
case tok::identifier: {
// In C++, check to see if this is a scope specifier like foo::bar::, if
// so handle it as such. This is important for ctor parsing.
if (getLang().CPlusPlus && TryAnnotateCXXScopeToken(true))
continue;
-
+
// This identifier can only be a typedef name if we haven't already seen
// a type-specifier. Without this check we misparse:
// typedef int X; struct Y { short X; }; as 'short int'.
if (DS.hasTypeSpecifier())
goto DoneWithDeclSpec;
-
+
// It has to be available as a typedef too!
- TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(),
+ TypeTy *TypeRep = Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), CurScope);
// If this is not a typedef name, don't parse it as part of the declspec,
@@ -844,11 +844,11 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// being defined and the next token is a '(', then this is a
// constructor declaration. We're done with the decl-specifiers
// and will treat this token as an identifier.
- if (getLang().CPlusPlus &&
- (CurScope->isClassScope() ||
- (CurScope->isTemplateParamScope() &&
+ if (getLang().CPlusPlus &&
+ (CurScope->isClassScope() ||
+ (CurScope->isTemplateParamScope() &&
CurScope->getParent()->isClassScope())) &&
- Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope) &&
+ Actions.isCurrentClassName(*Tok.getIdentifierInfo(), CurScope) &&
NextToken().getKind() == tok::l_paren)
goto DoneWithDeclSpec;
@@ -856,7 +856,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
DiagID, TypeRep);
if (isInvalid)
break;
-
+
DS.SetRangeEnd(Tok.getLocation());
ConsumeToken(); // The identifier
@@ -866,12 +866,12 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// just a normal reference to a typedef name.
if (!Tok.is(tok::less) || !getLang().ObjC1)
continue;
-
+
SourceLocation EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
-
+
DS.SetRangeEnd(EndProtoLoc);
// Need to support trailing type qualifiers (e.g. "id<p> const").
@@ -881,7 +881,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// type-name
case tok::annot_template_id: {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
if (TemplateId->Kind != TNK_Type_template) {
// This template-id does not refer to a type name, so we're
@@ -904,7 +904,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
case tok::kw___declspec:
DS.AddAttributes(ParseMicrosoftDeclSpec());
continue;
-
+
// Microsoft single token adornments.
case tok::kw___forceinline:
// FIXME: Add handling here!
@@ -958,7 +958,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
case tok::kw___thread:
isInvalid = DS.SetStorageClassSpecThread(Loc, PrevSpec, DiagID);
break;
-
+
// function-specifier
case tok::kw_inline:
isInvalid = DS.SetFunctionSpecInline(Loc, PrevSpec, DiagID);
@@ -980,7 +980,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
isInvalid = true;
}
break;
-
+
// type-specifier
case tok::kw_short:
isInvalid = DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec,
@@ -1111,7 +1111,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
// but we support it.
if (DS.hasTypeSpecifier() || !getLang().ObjC1)
goto DoneWithDeclSpec;
-
+
{
SourceLocation EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
@@ -1201,7 +1201,7 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
if (NextToken().is(tok::kw_new) || // ::new
NextToken().is(tok::kw_delete)) // ::delete
return false;
-
+
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
@@ -1209,7 +1209,7 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
TemplateInfo);
// Otherwise, not a type specifier.
return false;
-
+
// simple-type-specifier:
case tok::annot_typename: {
if (Tok.getAnnotationValue())
@@ -1219,19 +1219,19 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
DS.SetTypeSpecError();
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeToken(); // The typename
-
+
// Objective-C supports syntax of the form 'id<proto1,proto2>' where 'id'
// is a specific typedef and 'itf<proto1,proto2>' where 'itf' is an
// Objective-C interface. If we don't have Objective-C or a '<', this is
// just a normal reference to a typedef name.
if (!Tok.is(tok::less) || !getLang().ObjC1)
return true;
-
+
SourceLocation EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
-
+
DS.SetRangeEnd(EndProtoLoc);
return true;
}
@@ -1342,7 +1342,7 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid,
case tok::kw_decltype:
ParseDecltypeSpecifier(DS);
return true;
-
+
// C++0x auto support.
case tok::kw_auto:
if (!getLang().CPlusPlus0x)
@@ -1400,11 +1400,11 @@ ParseStructDeclaration(DeclSpec &DS,
ConsumeToken();
return ParseStructDeclaration(DS, Fields);
}
-
+
// Parse the common specifier-qualifiers-list piece.
SourceLocation DSStart = Tok.getLocation();
ParseSpecifierQualifierList(DS);
-
+
// If there are no declarators, this is a free-standing declaration
// specifier. Let the actions module cope with it.
if (Tok.is(tok::semi)) {
@@ -1416,12 +1416,12 @@ ParseStructDeclaration(DeclSpec &DS,
Fields.push_back(FieldDeclarator(DS));
while (1) {
FieldDeclarator &DeclaratorInfo = Fields.back();
-
+
/// struct-declarator: declarator
/// struct-declarator: declarator[opt] ':' constant-expression
if (Tok.isNot(tok::colon))
ParseDeclarator(DeclaratorInfo.D);
-
+
if (Tok.is(tok::colon)) {
ConsumeToken();
OwningExprResult Res(ParseConstantExpression());
@@ -1473,9 +1473,9 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
PrettyStackTraceActionsDecl CrashInfo(TagDecl, RecordLoc, Actions,
PP.getSourceManager(),
"parsing struct/union body");
-
+
SourceLocation LBraceLoc = ConsumeBrace();
-
+
ParseScope StructScope(this, Scope::ClassScope|Scope::DeclScope);
Actions.ActOnTagStartDefinition(CurScope, TagDecl);
@@ -1491,7 +1491,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
// While we still have something to read, read the declarations in the struct.
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
// Each iteration of this loop reads one struct-declaration.
-
+
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
Diag(Tok, diag::ext_extra_struct_semi)
@@ -1505,7 +1505,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
FieldDeclarators.clear();
if (!Tok.is(tok::at)) {
ParseStructDeclaration(DS, FieldDeclarators);
-
+
// Convert them all to fields.
for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
FieldDeclarator &FD = FieldDeclarators[i];
@@ -1539,12 +1539,12 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
continue;
}
llvm::SmallVector<DeclPtrTy, 16> Fields;
- Actions.ActOnDefs(CurScope, TagDecl, Tok.getLocation(),
+ Actions.ActOnDefs(CurScope, TagDecl, Tok.getLocation(),
Tok.getIdentifierInfo(), Fields);
FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end());
ConsumeToken();
ExpectAndConsume(tok::r_paren, diag::err_expected_rparen);
- }
+ }
if (Tok.is(tok::semi)) {
ConsumeToken();
@@ -1557,9 +1557,9 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
SkipUntil(tok::r_brace, true, true);
}
}
-
+
SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc);
-
+
AttributeList *AttrList = 0;
// If attributes exist after struct contents, parse them.
if (Tok.is(tok::kw___attribute))
@@ -1607,16 +1607,16 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
}
}
}
-
+
// Must have either 'enum name' or 'enum {...}'.
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::l_brace)) {
Diag(Tok, diag::err_expected_ident_lbrace);
-
+
// Skip the rest of this declarator, up until the comma or semicolon.
SkipUntil(tok::comma, true);
return;
}
-
+
// If an identifier is present, consume and remember it.
IdentifierInfo *Name = 0;
SourceLocation NameLoc;
@@ -1624,7 +1624,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
Name = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
}
-
+
// There are three options here. If we have 'enum foo;', then this is a
// forward declaration. If we have 'enum foo {...' then this is a
// definition. Otherwise we have something like 'enum foo xyz', a reference.
@@ -1645,10 +1645,10 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
StartLoc, SS, Name, NameLoc, Attr, AS,
Action::MultiTemplateParamsArg(Actions),
Owned);
-
+
if (Tok.is(tok::l_brace))
ParseEnumBody(StartLoc, TagDecl);
-
+
// TODO: semantic analysis on the declspec for enums.
const char *PrevSpec = 0;
unsigned DiagID;
@@ -1673,20 +1673,20 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
Actions.ActOnTagStartDefinition(CurScope, EnumDecl);
SourceLocation LBraceLoc = ConsumeBrace();
-
+
// C does not allow an empty enumerator-list, C++ does [dcl.enum].
if (Tok.is(tok::r_brace) && !getLang().CPlusPlus)
Diag(Tok, diag::ext_empty_struct_union_enum) << "enum";
-
+
llvm::SmallVector<DeclPtrTy, 32> EnumConstantDecls;
DeclPtrTy LastEnumConstDecl;
-
+
// Parse the enumerator-list.
while (Tok.is(tok::identifier)) {
IdentifierInfo *Ident = Tok.getIdentifierInfo();
SourceLocation IdentLoc = ConsumeToken();
-
+
SourceLocation EqualLoc;
OwningExprResult AssignedVal(Actions);
if (Tok.is(tok::equal)) {
@@ -1695,7 +1695,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
if (AssignedVal.isInvalid())
SkipUntil(tok::comma, tok::r_brace, true, true);
}
-
+
// Install the enumerator constant into EnumDecl.
DeclPtrTy EnumConstDecl = Actions.ActOnEnumConstant(CurScope, EnumDecl,
LastEnumConstDecl,
@@ -1704,18 +1704,18 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
AssignedVal.release());
EnumConstantDecls.push_back(EnumConstDecl);
LastEnumConstDecl = EnumConstDecl;
-
+
if (Tok.isNot(tok::comma))
break;
SourceLocation CommaLoc = ConsumeToken();
-
- if (Tok.isNot(tok::identifier) &&
+
+ if (Tok.isNot(tok::identifier) &&
!(getLang().C99 || getLang().CPlusPlus0x))
Diag(CommaLoc, diag::ext_enumerator_list_comma)
<< getLang().CPlusPlus
<< CodeModificationHint::CreateRemoval((SourceRange(CommaLoc)));
}
-
+
// Eat the }.
SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc);
@@ -1727,7 +1727,7 @@ void Parser::ParseEnumBody(SourceLocation StartLoc, DeclPtrTy EnumDecl) {
Actions.ActOnEnumBody(StartLoc, LBraceLoc, RBraceLoc, EnumDecl,
EnumConstantDecls.data(), EnumConstantDecls.size(),
CurScope, Attr);
-
+
EnumScope.Exit();
Actions.ActOnTagFinishDefinition(CurScope, EnumDecl, RBraceLoc);
}
@@ -1750,7 +1750,7 @@ bool Parser::isTypeQualifier() const {
bool Parser::isTypeSpecifierQualifier() {
switch (Tok.getKind()) {
default: return false;
-
+
case tok::identifier: // foo::bar
case tok::kw_typename: // typename T::type
// Annotate typenames and C++ scope specifiers. If we get one, just
@@ -1771,12 +1771,12 @@ bool Parser::isTypeSpecifierQualifier() {
return isTypeSpecifierQualifier();
// Otherwise, not a type specifier.
return false;
-
+
// GNU attributes support.
case tok::kw___attribute:
// GNU typeof support.
case tok::kw_typeof:
-
+
// type-specifiers
case tok::kw_short:
case tok::kw_long:
@@ -1797,14 +1797,14 @@ bool Parser::isTypeSpecifierQualifier() {
case tok::kw__Decimal32:
case tok::kw__Decimal64:
case tok::kw__Decimal128:
-
+
// struct-or-union-specifier (C99) or class-specifier (C++)
case tok::kw_class:
case tok::kw_struct:
case tok::kw_union:
// enum-specifier
case tok::kw_enum:
-
+
// type-qualifier
case tok::kw_const:
case tok::kw_volatile:
@@ -1813,11 +1813,11 @@ bool Parser::isTypeSpecifierQualifier() {
// typedef-name
case tok::annot_typename:
return true;
-
+
// GNU ObjC bizarre protocol extension: <proto1,proto2> with implicit 'id'.
case tok::less:
return getLang().ObjC1;
-
+
case tok::kw___cdecl:
case tok::kw___stdcall:
case tok::kw___fastcall:
@@ -1832,7 +1832,7 @@ bool Parser::isTypeSpecifierQualifier() {
bool Parser::isDeclarationSpecifier() {
switch (Tok.getKind()) {
default: return false;
-
+
case tok::identifier: // foo::bar
// Unfortunate hack to support "Class.factoryMethod" notation.
if (getLang().ObjC1 && NextToken().is(tok::period))
@@ -1850,14 +1850,14 @@ bool Parser::isDeclarationSpecifier() {
if (NextToken().is(tok::kw_new) || // ::new
NextToken().is(tok::kw_delete)) // ::delete
return false;
-
+
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return isDeclarationSpecifier();
// Otherwise, not a declaration specifier.
return false;
-
+
// storage-class-specifier
case tok::kw_typedef:
case tok::kw_extern:
@@ -1866,7 +1866,7 @@ bool Parser::isDeclarationSpecifier() {
case tok::kw_auto:
case tok::kw_register:
case tok::kw___thread:
-
+
// type-specifiers
case tok::kw_short:
case tok::kw_long:
@@ -1888,14 +1888,14 @@ bool Parser::isDeclarationSpecifier() {
case tok::kw__Decimal32:
case tok::kw__Decimal64:
case tok::kw__Decimal128:
-
+
// struct-or-union-specifier (C99) or class-specifier (C++)
case tok::kw_class:
case tok::kw_struct:
case tok::kw_union:
// enum-specifier
case tok::kw_enum:
-
+
// type-qualifier
case tok::kw_const:
case tok::kw_volatile:
@@ -1911,15 +1911,15 @@ bool Parser::isDeclarationSpecifier() {
// GNU typeof support.
case tok::kw_typeof:
-
+
// GNU attributes.
case tok::kw___attribute:
return true;
-
+
// GNU ObjC bizarre protocol extension: <proto1,proto2> with implicit 'id'.
case tok::less:
return getLang().ObjC1;
-
+
case tok::kw___declspec:
case tok::kw___cdecl:
case tok::kw___stdcall:
@@ -2035,7 +2035,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
Tok.is(tok::annot_cxxscope))) {
CXXScopeSpec SS;
if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true)) {
- if(Tok.isNot(tok::star)) {
+ if (Tok.isNot(tok::star)) {
// The scope spec really belongs to the direct-declarator.
D.getCXXScopeSpec() = SS;
if (DirectDeclParser)
@@ -2093,7 +2093,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
SourceLocation());
else
// Remember that we parsed a Block type, and remember the type-quals.
- D.AddTypeInfo(DeclaratorChunk::getBlockPointer(DS.getTypeQualifiers(),
+ D.AddTypeInfo(DeclaratorChunk::getBlockPointer(DS.getTypeQualifiers(),
Loc, DS.TakeAttributes()),
SourceLocation());
} else {
@@ -2178,10 +2178,10 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
/// qualified-id [TODO]
///
/// unqualified-id: [C++ 5.1]
-/// identifier
+/// identifier
/// operator-function-id
/// conversion-function-id [TODO]
-/// '~' class-name
+/// '~' class-name
/// template-id
///
void Parser::ParseDirectDeclarator(Declarator &D) {
@@ -2191,7 +2191,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
if (D.mayHaveIdentifier()) {
// ParseDeclaratorInternal might already have parsed the scope.
bool afterCXXScope = D.getCXXScopeSpec().isSet() ||
- ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), /*ObjectType=*/0,
+ ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), /*ObjectType=*/0,
true);
if (afterCXXScope) {
// Change the declaration context for name lookup, until this function
@@ -2203,7 +2203,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
assert(Tok.getIdentifierInfo() && "Not an identifier?");
// If this identifier is the name of the current class, it's a
- // constructor name.
+ // constructor name.
if (!D.getDeclSpec().hasTypeSpecifier() &&
Actions.isCurrentClassName(*Tok.getIdentifierInfo(),CurScope)) {
CXXScopeSpec *SS = afterCXXScope? &D.getCXXScopeSpec() : 0;
@@ -2216,7 +2216,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
ConsumeToken();
goto PastIdentifier;
} else if (Tok.is(tok::annot_template_id)) {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
// FIXME: Could this template-id name a constructor?
@@ -2305,11 +2305,11 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
D.SetIdentifier(0, Tok.getLocation());
D.setInvalidType(true);
}
-
+
PastIdentifier:
assert(D.isPastIdentifier() &&
"Haven't past the location of the identifier yet?");
-
+
while (1) {
if (Tok.is(tok::l_paren)) {
// The paren may be part of a C++ direct initializer, eg. "int x(1);".
@@ -2333,7 +2333,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
/// ParseParenDeclarator - We parsed the declarator D up to a paren. This is
/// only called before the identifier, so these are most likely just grouping
-/// parens for precedence. If we find that these are actually function
+/// parens for precedence. If we find that these are actually function
/// parameter parens in an abstract-declarator, we call ParseFunctionDeclarator.
///
/// direct-declarator:
@@ -2347,7 +2347,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
void Parser::ParseParenDeclarator(Declarator &D) {
SourceLocation StartLoc = ConsumeParen();
assert(!D.isPastIdentifier() && "Should be called before passing identifier");
-
+
// Eat any attributes before we look at whether this is a grouping or function
// declarator paren. If this is a grouping paren, the attribute applies to
// the type being built up, for example:
@@ -2362,7 +2362,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
bool RequiresArg = false;
if (Tok.is(tok::kw___attribute)) {
AttrList = ParseAttributes();
-
+
// We require that the argument list (if this is a non-grouping paren) be
// present even if the attribute list was empty.
RequiresArg = true;
@@ -2373,13 +2373,13 @@ void Parser::ParseParenDeclarator(Declarator &D) {
Tok.is(tok::kw___ptr64)) {
AttrList = ParseMicrosoftTypeAttributes(AttrList);
}
-
+
// If we haven't past the identifier yet (or where the identifier would be
// stored, if this is an abstract declarator), then this is probably just
// grouping parens. However, if this could be an abstract-declarator, then
// this could also be the start of function arguments (consider 'void()').
bool isGrouping;
-
+
if (!D.mayOmitIdentifier()) {
// If this can't be an abstract-declarator, this *must* be a grouping
// paren, because we haven't seen the identifier yet.
@@ -2394,7 +2394,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
// Otherwise, this is a grouping paren, e.g. 'int (*X)' or 'int(X)'.
isGrouping = true;
}
-
+
// If this is a grouping paren, handle:
// direct-declarator: '(' declarator ')'
// direct-declarator: '(' attributes declarator ')'
@@ -2412,7 +2412,7 @@ void Parser::ParseParenDeclarator(Declarator &D) {
D.SetRangeEnd(Loc);
return;
}
-
+
// Okay, if this wasn't a grouping paren, it must be the start of a function
// argument list. Recognize that this declarator will never have an
// identifier (and remember where it would have been), then call into
@@ -2458,7 +2458,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
bool RequiresArg) {
// lparen is already consumed!
assert(D.isPastIdentifier() && "Should not call before identifier!");
-
+
// This parameter list may be empty.
if (Tok.is(tok::r_paren)) {
if (RequiresArg) {
@@ -2524,9 +2524,9 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
return ParseFunctionDeclaratorIdentifierList(LParenLoc, D);
}
}
-
+
// Finally, a normal, non-empty parameter type list.
-
+
// Build up an array of information about the parsed arguments.
llvm::SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
@@ -2534,7 +2534,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// function prototype scope, including parameter declarators.
ParseScope PrototypeScope(this,
Scope::FunctionPrototypeScope|Scope::DeclScope);
-
+
bool IsVariadic = false;
SourceLocation EllipsisLoc;
while (1) {
@@ -2543,9 +2543,9 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
EllipsisLoc = ConsumeToken(); // Consume the ellipsis.
break;
}
-
+
SourceLocation DSStart = Tok.getLocation();
-
+
// Parse the declaration-specifiers.
DeclSpec DS;
@@ -2555,7 +2555,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
AttrList = 0; // Only apply the attributes to the first parameter.
}
ParseDeclarationSpecifiers(DS);
-
+
// Parse the declarator. This is "PrototypeContext", because we must
// accept either 'declarator' or 'abstract-declarator' here.
Declarator ParmDecl(DS, Declarator::PrototypeContext);
@@ -2567,10 +2567,10 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
AttributeList *AttrList = ParseAttributes(&Loc);
ParmDecl.AddAttributes(AttrList, Loc);
}
-
+
// Remember this parsed parameter in ParamInfo.
IdentifierInfo *ParmII = ParmDecl.getIdentifier();
-
+
// DefArgToks is used when the parsing of default arguments needs
// to be delayed.
CachedTokens *DefArgToks = 0;
@@ -2584,7 +2584,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
} else {
// Otherwise, we have something. Add it and let semantic analysis try
// to grok it and add the result to the ParamInfo we are building.
-
+
// Inform the actions module about the parameter declarator, so it gets
// added to the current scope.
DeclPtrTy Param = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
@@ -2605,18 +2605,18 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// FIXME: Can we use a smart pointer for Toks?
DefArgToks = new CachedTokens;
- if (!ConsumeAndStoreUntil(tok::comma, tok::r_paren, *DefArgToks,
+ if (!ConsumeAndStoreUntil(tok::comma, tok::r_paren, *DefArgToks,
tok::semi, false)) {
delete DefArgToks;
DefArgToks = 0;
Actions.ActOnParamDefaultArgumentError(Param);
} else
- Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
+ Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
(*DefArgToks)[1].getLocation());
} else {
// Consume the '='.
ConsumeToken();
-
+
OwningExprResult DefArgResult(ParseAssignmentExpression());
if (DefArgResult.isInvalid()) {
Actions.ActOnParamDefaultArgumentError(Param);
@@ -2628,22 +2628,22 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
}
}
}
-
- ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
- ParmDecl.getIdentifierLoc(), Param,
+
+ ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
+ ParmDecl.getIdentifierLoc(), Param,
DefArgToks));
}
// If the next token is a comma, consume it and keep reading arguments.
if (Tok.isNot(tok::comma)) break;
-
+
// Consume the comma.
ConsumeToken();
}
-
+
// Leave prototype scope.
PrototypeScope.Exit();
-
+
// If we have the closing ')', eat it.
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
SourceLocation EndLoc = RParenLoc;
@@ -2698,7 +2698,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
// Build up an array of information about the parsed arguments.
llvm::SmallVector<DeclaratorChunk::ParamInfo, 16> ParamInfo;
llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
-
+
// If there was no identifier specified for the declarator, either we are in
// an abstract-declarator, or we are in a parameter declarator which was found
// to be abstract. In abstract-declarators, identifier lists are not valid:
@@ -2712,13 +2712,13 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
ParamInfo.push_back(DeclaratorChunk::ParamInfo(Tok.getIdentifierInfo(),
Tok.getLocation(),
DeclPtrTy()));
-
+
ConsumeToken(); // eat the first identifier.
-
+
while (Tok.is(tok::comma)) {
// Eat the comma.
ConsumeToken();
-
+
// If this isn't an identifier, report the error and skip until ')'.
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
@@ -2731,7 +2731,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
// Reject 'typedef int y; int test(x, y)', but continue parsing.
if (Actions.getTypeName(*ParmII, Tok.getLocation(), CurScope))
Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
-
+
// Verify that the argument identifier has not already been mentioned.
if (!ParamsSoFar.insert(ParmII)) {
Diag(Tok, diag::err_param_redefinition) << ParmII;
@@ -2741,7 +2741,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
Tok.getLocation(),
DeclPtrTy()));
}
-
+
// Eat the identifier.
ConsumeToken();
}
@@ -2769,7 +2769,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
/// [C99] direct-declarator '[' type-qual-list[opt] '*' ']'
void Parser::ParseBracketDeclarator(Declarator &D) {
SourceLocation StartLoc = ConsumeBracket();
-
+
// C array syntax has many features, but by-far the most common is [] and [4].
// This code does a fast path to handle some of the most obvious cases.
if (Tok.getKind() == tok::r_square) {
@@ -2791,33 +2791,33 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
// If there was an error parsing the assignment-expression, recover.
if (ExprRes.isInvalid())
ExprRes.release(); // Deallocate expr, just use [].
-
+
// Remember that we parsed a array type, and remember its features.
D.AddTypeInfo(DeclaratorChunk::getArray(0, false, 0, ExprRes.release(),
StartLoc, EndLoc),
EndLoc);
return;
}
-
+
// If valid, this location is the position where we read the 'static' keyword.
SourceLocation StaticLoc;
if (Tok.is(tok::kw_static))
StaticLoc = ConsumeToken();
-
+
// If there is a type-qualifier-list, read it now.
// Type qualifiers in an array subscript are a C99 feature.
DeclSpec DS;
ParseTypeQualifierListOpt(DS, false /*no attributes*/);
-
+
// If we haven't already read 'static', check to see if there is one after the
// type-qualifier-list.
if (!StaticLoc.isValid() && Tok.is(tok::kw_static))
StaticLoc = ConsumeToken();
-
+
// Handle "direct-declarator [ type-qual-list[opt] * ]".
bool isStar = false;
OwningExprResult NumElements(Actions);
-
+
// Handle the case where we have '[*]' as the array size. However, a leading
// star could be the start of an expression, for example 'X[*p + 4]'. Verify
// the the token after the star is a ']'. Since stars in arrays are
@@ -2835,7 +2835,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
// of assignment-expr. The only difference is that assignment-expr allows
// things like '=' and '*='. Sema rejects these in C89 mode because they
// are not i-c-e's, so we don't need to distinguish between the two here.
-
+
// Parse the constant-expression or assignment-expression now (depending
// on dialect).
if (getLang().CPlusPlus)
@@ -2843,7 +2843,7 @@ void Parser::ParseBracketDeclarator(Declarator &D) {
else
NumElements = ParseAssignmentExpression();
}
-
+
// If there was an error parsing the assignment-expression, recover.
if (NumElements.isInvalid()) {
D.setInvalidType(true);
@@ -2885,7 +2885,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
DS.SetRangeEnd(Tok.getLocation());
else
DS.SetRangeEnd(CastRange.getEnd());
-
+
if (isCastExpr) {
if (!CastTy) {
DS.SetTypeSpecError();
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 55c7c85fa6..fc3e6ae17f 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -38,7 +38,7 @@ using namespace clang;
///
/// extension-namespace-definition:
/// 'namespace' original-namespace-name '{' namespace-body '}'
-///
+///
/// namespace-alias-definition: [C++ 7.3.2: namespace.alias]
/// 'namespace' identifier '=' qualified-namespace-specifier ';'
///
@@ -46,17 +46,17 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context,
SourceLocation &DeclEnd) {
assert(Tok.is(tok::kw_namespace) && "Not a namespace!");
SourceLocation NamespaceLoc = ConsumeToken(); // eat the 'namespace'.
-
+
SourceLocation IdentLoc;
IdentifierInfo *Ident = 0;
Token attrTok;
-
+
if (Tok.is(tok::identifier)) {
Ident = Tok.getIdentifierInfo();
IdentLoc = ConsumeToken(); // eat the identifier.
}
-
+
// Read label attributes, if present.
Action::AttrTy *AttrList = 0;
if (Tok.is(tok::kw___attribute)) {
@@ -65,20 +65,20 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context,
// FIXME: save these somewhere.
AttrList = ParseAttributes();
}
-
+
if (Tok.is(tok::equal)) {
if (AttrList)
Diag(attrTok, diag::err_unexpected_namespace_attributes_alias);
return ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
}
-
+
if (Tok.isNot(tok::l_brace)) {
- Diag(Tok, Ident ? diag::err_expected_lbrace :
+ Diag(Tok, Ident ? diag::err_expected_lbrace :
diag::err_expected_ident_lbrace);
return DeclPtrTy();
}
-
+
SourceLocation LBrace = ConsumeBrace();
// Enter a scope for the namespace.
@@ -90,10 +90,10 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context,
PrettyStackTraceActionsDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions,
PP.getSourceManager(),
"parsing namespace");
-
+
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof))
ParseExternalDeclaration();
-
+
// Leave the namespace scope.
NamespaceScope.Exit();
@@ -108,13 +108,13 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context,
/// alias definition.
///
Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
- SourceLocation AliasLoc,
+ SourceLocation AliasLoc,
IdentifierInfo *Alias,
SourceLocation &DeclEnd) {
assert(Tok.is(tok::equal) && "Not equal token");
-
+
ConsumeToken(); // eat the '='.
-
+
CXXScopeSpec SS;
// Parse (optional) nested-name-specifier.
ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
@@ -129,13 +129,13 @@ Parser::DeclPtrTy Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
// Parse identifier.
IdentifierInfo *Ident = Tok.getIdentifierInfo();
SourceLocation IdentLoc = ConsumeToken();
-
+
// Eat the ';'.
DeclEnd = Tok.getLocation();
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name,
"", tok::semi);
-
- return Actions.ActOnNamespaceAliasDef(CurScope, NamespaceLoc, AliasLoc, Alias,
+
+ return Actions.ActOnNamespaceAliasDef(CurScope, NamespaceLoc, AliasLoc, Alias,
SS, IdentLoc, Ident);
}
@@ -157,18 +157,18 @@ Parser::DeclPtrTy Parser::ParseLinkage(unsigned Context) {
SourceLocation Loc = ConsumeStringToken();
ParseScope LinkageScope(this, Scope::DeclScope);
- DeclPtrTy LinkageSpec
- = Actions.ActOnStartLinkageSpecification(CurScope,
+ DeclPtrTy LinkageSpec
+ = Actions.ActOnStartLinkageSpecification(CurScope,
/*FIXME: */SourceLocation(),
Loc, LangBufPtr, StrSize,
- Tok.is(tok::l_brace)? Tok.getLocation()
+ Tok.is(tok::l_brace)? Tok.getLocation()
: SourceLocation());
if (Tok.isNot(tok::l_brace)) {
ParseDeclarationOrFunctionDefinition();
- return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec,
+ return Actions.ActOnFinishLinkageSpecification(CurScope, LinkageSpec,
SourceLocation());
- }
+ }
SourceLocation LBrace = ConsumeBrace();
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
@@ -230,15 +230,15 @@ Parser::DeclPtrTy Parser::ParseUsingDirective(unsigned Context,
// FIXME: Are there cases, when we would like to call ActOnUsingDirective?
return DeclPtrTy();
}
-
+
// Parse identifier.
NamespcName = Tok.getIdentifierInfo();
IdentLoc = ConsumeToken();
-
+
// Parse (optional) attributes (most likely GNU strong-using extension).
if (Tok.is(tok::kw___attribute))
AttrList = ParseAttributes();
-
+
// Eat ';'.
DeclEnd = Tok.getLocation();
ExpectAndConsume(tok::semi,
@@ -284,16 +284,16 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context,
}
if (Tok.is(tok::annot_template_id)) {
// C++0x N2914 [namespace.udecl]p5:
- // A using-declaration shall not name a template-id.
+ // A using-declaration shall not name a template-id.
Diag(Tok, diag::err_using_decl_can_not_refer_to_template_spec);
SkipUntil(tok::semi);
return DeclPtrTy();
}
-
+
IdentifierInfo *TargetName = 0;
OverloadedOperatorKind Op = OO_None;
SourceLocation IdentLoc;
-
+
if (Tok.is(tok::kw_operator)) {
IdentLoc = Tok.getLocation();
@@ -315,11 +315,11 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context,
SkipUntil(tok::semi);
return DeclPtrTy();
}
-
+
// Parse (optional) attributes (most likely GNU strong-using extension).
if (Tok.is(tok::kw___attribute))
AttrList = ParseAttributes();
-
+
// Eat ';'.
DeclEnd = Tok.getLocation();
ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
@@ -338,12 +338,12 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context,
Parser::DeclPtrTy Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
assert(Tok.is(tok::kw_static_assert) && "Not a static_assert declaration");
SourceLocation StaticAssertLoc = ConsumeToken();
-
+
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen);
return DeclPtrTy();
}
-
+
SourceLocation LParenLoc = ConsumeParen();
OwningExprResult AssertExpr(ParseConstantExpression());
@@ -351,7 +351,7 @@ Parser::DeclPtrTy Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
SkipUntil(tok::semi);
return DeclPtrTy();
}
-
+
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "", tok::semi))
return DeclPtrTy();
@@ -360,17 +360,17 @@ Parser::DeclPtrTy Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
SkipUntil(tok::semi);
return DeclPtrTy();
}
-
+
OwningExprResult AssertMessage(ParseStringLiteralExpression());
- if (AssertMessage.isInvalid())
+ if (AssertMessage.isInvalid())
return DeclPtrTy();
MatchRHSPunctuation(tok::r_paren, LParenLoc);
-
+
DeclEnd = Tok.getLocation();
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_static_assert);
- return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, move(AssertExpr),
+ return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, move(AssertExpr),
move(AssertMessage));
}
@@ -383,15 +383,15 @@ void Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
SourceLocation StartLoc = ConsumeToken();
SourceLocation LParenLoc = Tok.getLocation();
-
- if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
+
+ if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"decltype")) {
SkipUntil(tok::r_paren);
return;
}
-
+
// Parse the expression
-
+
// C++0x [dcl.type.simple]p4:
// The operand of the decltype specifier is an unevaluated operand.
EnterExpressionEvaluationContext Unevaluated(Actions,
@@ -401,21 +401,21 @@ void Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
SkipUntil(tok::r_paren);
return;
}
-
+
// Match the ')'
SourceLocation RParenLoc;
if (Tok.is(tok::r_paren))
RParenLoc = ConsumeParen();
else
MatchRHSPunctuation(tok::r_paren, LParenLoc);
-
+
if (RParenLoc.isInvalid())
return;
const char *PrevSpec = 0;
unsigned DiagID;
// Check for duplicate type specifiers (e.g. "int decltype(a)").
- if (DS.SetTypeSpecType(DeclSpec::TST_decltype, StartLoc, PrevSpec,
+ if (DS.SetTypeSpecType(DeclSpec::TST_decltype, StartLoc, PrevSpec,
DiagID, Result.release()))
Diag(StartLoc, DiagID) << PrevSpec;
}
@@ -429,13 +429,13 @@ void Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
/// class-name: [C++ 9.1]
/// identifier
/// simple-template-id
-///
+///
Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
const CXXScopeSpec *SS,
bool DestrExpected) {
// Check whether we have a template-id that names a type.
if (Tok.is(tok::annot_template_id)) {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
if (TemplateId->Kind == TNK_Type_template) {
AnnotateTemplateIdTokenAsType(SS);
@@ -459,11 +459,11 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
}
// We have an identifier; check whether it is actually a type.
- TypeTy *Type = Actions.getTypeName(*Tok.getIdentifierInfo(),
+ TypeTy *Type = Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), CurScope, SS,
true);
if (!Type) {
- Diag(Tok, DestrExpected ? diag::err_destructor_class_name
+ Diag(Tok, DestrExpected ? diag::err_destructor_class_name
: diag::err_expected_class_name);
return true;
}
@@ -487,9 +487,9 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
/// class-key nested-name-specifier[opt] simple-template-id
/// base-clause[opt]
/// [GNU] class-key attributes[opt] identifier[opt] base-clause[opt]
-/// [GNU] class-key attributes[opt] nested-name-specifier
+/// [GNU] class-key attributes[opt] nested-name-specifier
/// identifier base-clause[opt]
-/// [GNU] class-key attributes[opt] nested-name-specifier[opt]
+/// [GNU] class-key attributes[opt] nested-name-specifier[opt]
/// simple-template-id base-clause[opt]
/// class-key:
/// 'class'
@@ -497,9 +497,9 @@ Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
/// 'union'
///
/// elaborated-type-specifier: [C++ dcl.type.elab]
-/// class-key ::[opt] nested-name-specifier[opt] identifier
-/// class-key ::[opt] nested-name-specifier[opt] 'template'[opt]
-/// simple-template-id
+/// class-key ::[opt] nested-name-specifier[opt] identifier
+/// class-key ::[opt] nested-name-specifier[opt] 'template'[opt]
+/// simple-template-id
///
/// Note that the C++ class-specifier and elaborated-type-specifier,
/// together, subsume the C99 struct-or-union-specifier:
@@ -535,11 +535,11 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// If declspecs exist after tag, parse them.
if (Tok.is(tok::kw___declspec))
Attr = ParseMicrosoftDeclSpec(Attr);
-
+
if (TagType == DeclSpec::TST_struct && Tok.is(tok::kw___is_pod)) {
// GNU libstdc++ 4.2 uses __is_pod as the name of a struct template, but
// __is_pod is a keyword in GCC >= 4.3. Therefore, when we see the
- // token sequence "struct __is_pod", make __is_pod into a normal
+ // token sequence "struct __is_pod", make __is_pod into a normal
// identifier rather than a keyword, to allow libstdc++ 4.2 to work
// properly.
Tok.getIdentifierInfo()->setTokenID(tok::identifier);
@@ -549,16 +549,16 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
if (TagType == DeclSpec::TST_struct && Tok.is(tok::kw___is_empty)) {
// GNU libstdc++ 4.2 uses __is_empty as the name of a struct template, but
// __is_empty is a keyword in GCC >= 4.3. Therefore, when we see the
- // token sequence "struct __is_empty", make __is_empty into a normal
+ // token sequence "struct __is_empty", make __is_empty into a normal
// identifier rather than a keyword, to allow libstdc++ 4.2 to work
// properly.
Tok.getIdentifierInfo()->setTokenID(tok::identifier);
Tok.setKind(tok::identifier);
}
-
+
// Parse the (optional) nested-name-specifier.
CXXScopeSpec SS;
- if (getLang().CPlusPlus &&
+ if (getLang().CPlusPlus &&
ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, true))
if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
Diag(Tok, diag::err_expected_ident);
@@ -584,7 +584,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
Diag(TemplateId->LAngleLoc, diag::err_template_spec_syntax_non_template)
<< Name << static_cast<int>(TemplateId->Kind) << Range;
-
+
DS.SetTypeSpecError();
SkipUntil(tok::semi, false, true);
TemplateId->Destroy();
@@ -629,7 +629,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
if (TemplateId) {
// Explicit specialization, class template partial specialization,
// or explicit instantiation.
- ASTTemplateArgsPtr TemplateArgsPtr(Actions,
+ ASTTemplateArgsPtr TemplateArgsPtr(Actions,
TemplateId->getTemplateArgs(),
TemplateId->getTemplateArgIsType(),
TemplateId->NumArgs);
@@ -637,18 +637,18 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
TUK == Action::TUK_Declaration) {
// This is an explicit instantiation of a class template.
TagOrTempResult
- = Actions.ActOnExplicitInstantiation(CurScope,
+ = Actions.ActOnExplicitInstantiation(CurScope,
TemplateInfo.ExternLoc,
- TemplateInfo.TemplateLoc,
+ TemplateInfo.TemplateLoc,
TagType,
- StartLoc,
+ StartLoc,
SS,
- TemplateTy::make(TemplateId->Template),
- TemplateId->TemplateNameLoc,
- TemplateId->LAngleLoc,
+ TemplateTy::make(TemplateId->Template),
+ TemplateId->TemplateNameLoc,
+ TemplateId->LAngleLoc,
TemplateArgsPtr,
TemplateId->getTemplateArgLocations(),
- TemplateId->RAngleLoc,
+ TemplateId->RAngleLoc,
Attr);
} else if (TUK == Action::TUK_Reference || TUK == Action::TUK_Friend) {
Action::TypeResult Type
@@ -675,7 +675,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
Diag(StartLoc, DiagID) << PrevSpec;
return;
-
+
} else {
// This is an explicit specialization or a class template
// partial specialization.
@@ -692,9 +692,9 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// the '<>' after 'template'.
assert(TUK == Action::TUK_Definition && "Expected a definition here");
- SourceLocation LAngleLoc
+ SourceLocation LAngleLoc
= PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
- Diag(TemplateId->TemplateNameLoc,
+ Diag(TemplateId->TemplateNameLoc,
diag::err_explicit_instantiation_with_definition)
<< SourceRange(TemplateInfo.TemplateLoc)
<< CodeModificationHint::CreateInsertion(LAngleLoc, "<>");
@@ -703,10 +703,10 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// "template<>", so that we treat this construct as a class
// template specialization.
FakedParamLists.push_back(
- Actions.ActOnTemplateParameterList(0, SourceLocation(),
+ Actions.ActOnTemplateParameterList(0, SourceLocation(),
TemplateInfo.TemplateLoc,
- LAngleLoc,
- 0, 0,
+ LAngleLoc,
+ 0, 0,
LAngleLoc));
TemplateParams = &FakedParamLists;
}
@@ -715,14 +715,14 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
TagOrTempResult
= Actions.ActOnClassTemplateSpecialization(CurScope, TagType, TUK,
StartLoc, SS,
- TemplateTy::make(TemplateId->Template),
- TemplateId->TemplateNameLoc,
- TemplateId->LAngleLoc,
+ TemplateTy::make(TemplateId->Template),
+ TemplateId->TemplateNameLoc,
+ TemplateId->LAngleLoc,
TemplateArgsPtr,
TemplateId->getTemplateArgLocations(),
- TemplateId->RAngleLoc,
+ TemplateId->RAngleLoc,
Attr,
- Action::MultiTemplateParamsArg(Actions,
+ Action::MultiTemplateParamsArg(Actions,
TemplateParams? &(*TemplateParams)[0] : 0,
TemplateParams? TemplateParams->size() : 0));
}
@@ -735,10 +735,10 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// template struct Outer<int>::Inner;
//
TagOrTempResult
- = Actions.ActOnExplicitInstantiation(CurScope,
+ = Actions.ActOnExplicitInstantiation(CurScope,
TemplateInfo.ExternLoc,
- TemplateInfo.TemplateLoc,
- TagType, StartLoc, SS, Name,
+ TemplateInfo.TemplateLoc,
+ TagType, StartLoc, SS, Name,
NameLoc, Attr);
} else {
if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
@@ -747,9 +747,9 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
}
// Declaration or definition of a class type
- TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TUK, StartLoc, SS,
+ TagOrTempResult = Actions.ActOnTag(CurScope, TagType, TUK, StartLoc, SS,
Name, NameLoc, Attr, AS,
- Action::MultiTemplateParamsArg(Actions,
+ Action::MultiTemplateParamsArg(Actions,
TemplateParams? &(*TemplateParams)[0] : 0,
TemplateParams? TemplateParams->size() : 0),
Owned);
@@ -775,7 +775,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
DS.SetTypeSpecError();
return;
}
-
+
const char *PrevSpec = 0;
unsigned DiagID;
if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, DiagID,
@@ -783,7 +783,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
Diag(StartLoc, DiagID) << PrevSpec;
}
-/// ParseBaseClause - Parse the base-clause of a C++ class [C++ class.derived].
+/// ParseBaseClause - Parse the base-clause of a C++ class [C++ class.derived].
///
/// base-clause : [C++ class.derived]
/// ':' base-specifier-list
@@ -812,7 +812,7 @@ void Parser::ParseBaseClause(DeclPtrTy ClassDecl) {
// If the next token is a comma, consume it and keep reading
// base-specifiers.
if (Tok.isNot(tok::comma)) break;
-
+
// Consume the comma.
ConsumeToken();
}
@@ -846,7 +846,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) {
AccessSpecifier Access = getAccessSpecifierIfPresent();
if (Access)
ConsumeToken();
-
+
// Parse the 'virtual' keyword (again!), in case it came after the
// access specifier.
if (Tok.is(tok::kw_virtual)) {
@@ -872,10 +872,10 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) {
TypeResult BaseType = ParseClassName(EndLocation, &SS);
if (BaseType.isInvalid())
return true;
-
- // Find the complete source range for the base-specifier.
+
+ // Find the complete source range for the base-specifier.
SourceRange Range(StartLoc, EndLocation);
-
+
// Notify semantic analysis that we have parsed a complete
// base-specifier.
return Actions.ActOnBaseSpecifier(ClassDecl, Range, IsVirtual, Access,
@@ -889,8 +889,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclPtrTy ClassDecl) {
/// 'private'
/// 'protected'
/// 'public'
-AccessSpecifier Parser::getAccessSpecifierIfPresent() const
-{
+AccessSpecifier Parser::getAccessSpecifierIfPresent() const {
switch (Tok.getKind()) {
default: return AS_none;
case tok::kw_private: return AS_private;
@@ -904,7 +903,7 @@ void Parser::HandleMemberFunctionDefaultArgs(Declarator& DeclaratorInfo,
// We just declared a member function. If this member function
// has any default arguments, we'll need to parse them later.
LateParsedMethodDeclaration *LateMethod = 0;
- DeclaratorChunk::FunctionTypeInfo &FTI
+ DeclaratorChunk::FunctionTypeInfo &FTI
= DeclaratorInfo.getTypeObject(0).Fun;
for (unsigned ParamIdx = 0; ParamIdx < FTI.NumArgs; ++ParamIdx) {
if (LateMethod || FTI.ArgInfo[ParamIdx].DefaultArgTokens) {
@@ -968,12 +967,12 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ParseStaticAssertDeclaration(DeclEnd);
return;
}
-
+
if (Tok.is(tok::kw_template)) {
- assert(!TemplateInfo.TemplateParams &&
+ assert(!TemplateInfo.TemplateParams &&
"Nested template improperly parsed?");
SourceLocation DeclEnd;
- ParseDeclarationStartingWithTemplate(Declarator::MemberContext, DeclEnd,
+ ParseDeclarationStartingWithTemplate(Declarator::MemberContext, DeclEnd,
AS);
return;
}
@@ -988,7 +987,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (Tok.is(tok::kw_using)) {
// FIXME: Check for template aliases
-
+
// Eat 'using'.
SourceLocation UsingLoc = ConsumeToken();
@@ -1084,7 +1083,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (BitfieldSize.isInvalid())
SkipUntil(tok::comma, true, true);
}
-
+
// pure-specifier:
// '= 0'
//
@@ -1138,7 +1137,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
DeclsInGroup.push_back(ThisDecl);
if (DeclaratorInfo.isFunctionDeclarator() &&
- DeclaratorInfo.getDeclSpec().getStorageClassSpec()
+ DeclaratorInfo.getDeclSpec().getStorageClassSpec()
!= DeclSpec::SCS_typedef) {
HandleMemberFunctionDefaultArgs(DeclaratorInfo, ThisDecl);
}
@@ -1147,16 +1146,16 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// or an error, bail out.
if (Tok.isNot(tok::comma))
break;
-
+
// Consume the comma.
ConsumeToken();
-
+
// Parse the next declarator.
DeclaratorInfo.clear();
BitfieldSize = 0;
Init = 0;
Deleted = false;
-
+
// Attributes are only allowed on the second declarator.
if (Tok.is(tok::kw___attribute)) {
SourceLocation Loc;
@@ -1198,11 +1197,11 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
PrettyStackTraceActionsDecl CrashInfo(TagDecl, RecordLoc, Actions,
PP.getSourceManager(),
"parsing struct/union/class body");
-
+
SourceLocation LBraceLoc = ConsumeBrace();
// Determine whether this is a top-level (non-nested) class.
- bool TopLevelClass = ClassStack.empty() ||
+ bool TopLevelClass = ClassStack.empty() ||
CurScope->isInCXXInlineMethodScope();
// Enter a scope for the class.
@@ -1230,7 +1229,7 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
// While we still have something to read, read the member-declarations.
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
// Each iteration of this loop reads one member-declaration.
-
+
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
Diag(Tok, diag::ext_extra_struct_semi);
@@ -1248,13 +1247,13 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
}
// FIXME: Make sure we don't have a template here.
-
+
// Parse all the comma separated declarators.
ParseCXXClassMemberDeclaration(CurAS);
}
-
+
SourceLocation RBraceLoc = MatchRHSPunctuation(tok::r_brace, LBraceLoc);
-
+
AttributeList *AttrList = 0;
// If attributes exist after class contents, parse them.
if (Tok.is(tok::kw___attribute))
@@ -1300,19 +1299,19 @@ void Parser::ParseCXXMemberSpecification(SourceLocation RecordLoc,
/// };
/// @endcode
///
-/// [C++] ctor-initializer:
-/// ':' mem-initializer-list
+/// [C++] ctor-initializer:
+/// ':' mem-initializer-list
///
-/// [C++] mem-initializer-list:
-/// mem-initializer
-/// mem-initializer , mem-initializer-list
+/// [C++] mem-initializer-list:
+/// mem-initializer
+/// mem-initializer , mem-initializer-list
void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) {
assert(Tok.is(tok::colon) && "Constructor initializer always starts with ':'");
SourceLocation ColonLoc = ConsumeToken();
-
+
llvm::SmallVector<MemInitTy*, 4> MemInitializers;
-
+
do {
MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
if (!MemInit.isInvalid())
@@ -1330,7 +1329,7 @@ void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) {
}
} while (true);
- Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc,
+ Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc,
MemInitializers.data(), MemInitializers.size());
}
@@ -1341,7 +1340,7 @@ void Parser::ParseConstructorInitializer(DeclPtrTy ConstructorDecl) {
///
/// [C++] mem-initializer:
/// mem-initializer-id '(' expression-list[opt] ')'
-///
+///
/// [C++] mem-initializer-id:
/// '::'[opt] nested-name-specifier[opt] class-name
/// identifier
@@ -1364,7 +1363,7 @@ Parser::MemInitResult Parser::ParseMemInitializer(DeclPtrTy ConstructorDecl) {
Diag(Tok, diag::err_expected_member_or_base_name);
return true;
}
-
+
// Get the identifier. This may be a member name or a class name,
// but we'll let the semantic analysis determine which it is.
IdentifierInfo *II = Tok.is(tok::identifier) ? Tok.getIdentifierInfo() : 0;
@@ -1400,7 +1399,7 @@ Parser::MemInitResult Parser::ParseMemInitializer(DeclPtrTy ConstructorDecl) {
/// exception-specification:
/// 'throw' '(' type-id-list [opt] ')'
/// [MS] 'throw' '(' '...' ')'
-///
+///
/// type-id-list:
/// type-id
/// type-id-list ',' type-id
@@ -1412,9 +1411,9 @@ bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc,
&Ranges,
bool &hasAnyExceptionSpec) {
assert(Tok.is(tok::kw_throw) && "expected throw");
-
+
SourceLocation ThrowLoc = ConsumeToken();
-
+
if (!Tok.is(tok::l_paren)) {
return Diag(Tok, diag::err_expected_lparen_after) << "throw";
}
@@ -1453,7 +1452,7 @@ bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc,
/// so push that class onto our stack of classes that is currently
/// being parsed.
void Parser::PushParsingClass(DeclPtrTy ClassDecl, bool TopLevelClass) {
- assert((TopLevelClass || !ClassStack.empty()) &&
+ assert((TopLevelClass || !ClassStack.empty()) &&
"Nested class without outer class");
ClassStack.push(new ParsingClass(ClassDecl, TopLevelClass));
}
@@ -1477,7 +1476,7 @@ void Parser::DeallocateParsedClasses(Parser::ParsingClass *Class) {
/// false otherwise.
void Parser::PopParsingClass() {
assert(!ClassStack.empty() && "Mismatched push/pop for class parsing");
-
+
ParsingClass *Victim = ClassStack.top();
ClassStack.pop();
if (Victim->TopLevelClass) {
@@ -1485,7 +1484,7 @@ void Parser::PopParsingClass() {
// recursively: we don't need to keep any of this information.
DeallocateParsedClasses(Victim);
return;
- }
+ }
assert(!ClassStack.empty() && "Missing top-level class?");
if (Victim->MethodDecls.empty() && Victim->MethodDefs.empty() &&
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 39496626fe..60c8192965 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -55,7 +55,7 @@ namespace prec {
/// getBinOpPrecedence - Return the precedence of the specified binary operator
/// token. This returns:
///
-static prec::Level getBinOpPrecedence(tok::TokenKind Kind,
+static prec::Level getBinOpPrecedence(tok::TokenKind Kind,
bool GreaterThanIsOperator,
bool CPlusPlus0x) {
switch (Kind) {
@@ -67,7 +67,7 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind,
if (GreaterThanIsOperator)
return prec::Relational;
return prec::Unknown;
-
+
case tok::greatergreater:
// C++0x [temp.names]p3:
//
@@ -206,7 +206,7 @@ Parser::OwningExprResult Parser::ParseExpression() {
return ParseRHSOfBinaryExpression(move(LHS), prec::Comma);
}
-/// This routine is called when the '@' is seen and consumed.
+/// This routine is called when the '@' is seen and consumed.
/// Current token is an Identifier and is not a 'try'. This
/// routine is necessary to disambiguate @try-statement from,
/// for example, @encode-expression.
@@ -277,11 +277,11 @@ Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
Parser::OwningExprResult Parser::ParseConstantExpression() {
// C++ [basic.def.odr]p2:
- // An expression is potentially evaluated unless it appears where an
+ // An expression is potentially evaluated unless it appears where an
// integral constant expression is required (see 5.19) [...].
EnterExpressionEvaluationContext Unevaluated(Actions,
Action::Unevaluated);
-
+
OwningExprResult LHS(ParseCastExpression(false));
if (LHS.isInvalid()) return move(LHS);
@@ -292,7 +292,7 @@ Parser::OwningExprResult Parser::ParseConstantExpression() {
/// LHS and has a precedence of at least MinPrec.
Parser::OwningExprResult
Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
- unsigned NextTokPrec = getBinOpPrecedence(Tok.getKind(),
+ unsigned NextTokPrec = getBinOpPrecedence(Tok.getKind(),
GreaterThanIsOperator,
getLang().CPlusPlus0x);
SourceLocation ColonLoc;
@@ -465,10 +465,10 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
/// assign-expr ')'
/// [GNU] '__builtin_types_compatible_p' '(' type-name ',' type-name ')'
/// [GNU] '__null'
-/// [OBJC] '[' objc-message-expr ']'
+/// [OBJC] '[' objc-message-expr ']'
/// [OBJC] '@selector' '(' objc-selector-arg ')'
-/// [OBJC] '@protocol' '(' identifier ')'
-/// [OBJC] '@encode' '(' type-name ')'
+/// [OBJC] '@protocol' '(' identifier ')'
+/// [OBJC] '@encode' '(' type-name ')'
/// [OBJC] objc-string-literal
/// [C++] simple-type-specifier '(' expression-list[opt] ')' [C++ 5.2.3]
/// [C++] typename-specifier '(' expression-list[opt] ')' [TODO]
@@ -537,7 +537,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
OwningExprResult Res(Actions);
tok::TokenKind SavedKind = Tok.getKind();
NotCastExpr = false;
-
+
// This handles all of cast-expression, unary-expression, postfix-expression,
// and primary-expression. We handle them together like this for efficiency
// and to simplify handling of an expression starting with a '(' token: which
@@ -560,7 +560,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
parseParenAsExprList, CastTy, RParenLoc);
if (Res.isInvalid()) return move(Res);
-
+
switch (ParenExprType) {
case SimpleExpr: break; // Nothing else to do.
case CompoundStmt: break; // Nothing else to do.
@@ -608,23 +608,23 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
}
// Support 'Class.property' notation.
- // We don't use isTokObjCMessageIdentifierReceiver(), since it allows
+ // We don't use isTokObjCMessageIdentifierReceiver(), since it allows
// 'super' (which is inappropriate here).
- if (getLang().ObjC1 &&
- Actions.getTypeName(*Tok.getIdentifierInfo(),
+ if (getLang().ObjC1 &&
+ Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), CurScope) &&
NextToken().is(tok::period)) {
IdentifierInfo &ReceiverName = *Tok.getIdentifierInfo();
SourceLocation IdentLoc = ConsumeToken();
SourceLocation DotLoc = ConsumeToken();
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
return ExprError();
}
IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
SourceLocation PropertyLoc = ConsumeToken();
-
+
Res = Actions.ActOnClassPropertyRefExpr(ReceiverName, PropertyName,
IdentLoc, PropertyLoc);
// These can be followed by postfix-expr pieces.
@@ -799,7 +799,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
return ParseCXXNewExpression(true, CCLoc);
if (Tok.is(tok::kw_delete))
return ParseCXXDeleteExpression(true, CCLoc);
-
+
// This is not a type name or scope specifier, it is an invalid expression.
Diag(CCLoc, diag::err_expected_expression);
return ExprError();
@@ -834,7 +834,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// These can be followed by postfix-expr pieces.
if (getLang().ObjC1)
return ParsePostfixExpressionSuffix(ParseObjCMessageExpression());
- // FALL THROUGH.
+ // FALL THROUGH.
default:
NotCastExpr = true;
return ExprError();
@@ -906,7 +906,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
MatchRHSPunctuation(tok::r_paren, Loc);
return ExprError();
}
-
+
if (!LHS.isInvalid()) {
assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
"Unexpected number of commas!");
@@ -914,7 +914,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
move_arg(ArgExprs), CommaLocs.data(),
Tok.getLocation());
}
-
+
ConsumeParen();
break;
}
@@ -944,19 +944,19 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
ConsumeToken();
} else if (getLang().CPlusPlus && Tok.is(tok::tilde)) {
// We have a C++ pseudo-destructor or a destructor call, e.g., t.~T()
-
+
// Consume the tilde.
ConsumeToken();
-
+
if (!Tok.is(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
return ExprError();
}
-
+
if (!LHS.isInvalid())
- LHS = Actions.ActOnDestructorReferenceExpr(CurScope, move(LHS),
+ LHS = Actions.ActOnDestructorReferenceExpr(CurScope, move(LHS),
OpLoc, OpKind,
- Tok.getLocation(),
+ Tok.getLocation(),
Tok.getIdentifierInfo(),
SS,
NextToken().is(tok::l_paren));
@@ -987,14 +987,14 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
} else if (getLang().CPlusPlus && Tok.is(tok::annot_template_id)) {
// We have a reference to a member template along with explicitly-
// specified template arguments, e.g., t.f<int>.
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
if (!LHS.isInvalid()) {
- ASTTemplateArgsPtr TemplateArgsPtr(Actions,
+ ASTTemplateArgsPtr TemplateArgsPtr(Actions,
TemplateId->getTemplateArgs(),
TemplateId->getTemplateArgIsType(),
TemplateId->NumArgs);
-
+
LHS = Actions.ActOnMemberTemplateIdReferenceExpr(CurScope, move(LHS),
OpLoc, OpKind, SS,
TemplateTy::make(TemplateId->Template),
@@ -1014,7 +1014,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
case tok::plusplus: // postfix-expression: postfix-expression '++'
case tok::minusminus: // postfix-expression: postfix-expression '--'
if (!LHS.isInvalid()) {
- LHS = Actions.ActOnPostfixUnaryOp(CurScope, Tok.getLocation(),
+ LHS = Actions.ActOnPostfixUnaryOp(CurScope, Tok.getLocation(),
Tok.getKind(), move(LHS));
}
ConsumeToken();
@@ -1045,13 +1045,13 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
bool &isCastExpr,
TypeTy *&CastTy,
SourceRange &CastRange) {
-
- assert((OpTok.is(tok::kw_typeof) || OpTok.is(tok::kw_sizeof) ||
+
+ assert((OpTok.is(tok::kw_typeof) || OpTok.is(tok::kw_sizeof) ||
OpTok.is(tok::kw___alignof) || OpTok.is(tok::kw_alignof)) &&
"Not a typeof/sizeof/alignof expression!");
OwningExprResult Operand(Actions);
-
+
// If the operand doesn't start with an '(', it must be an expression.
if (Tok.isNot(tok::l_paren)) {
isCastExpr = false;
@@ -1059,9 +1059,9 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
Diag(Tok,diag::err_expected_lparen_after_id) << OpTok.getIdentifierInfo();
return ExprError();
}
-
+
// C++0x [expr.sizeof]p1:
- // [...] The operand is either an expression, which is an unevaluated
+ // [...] The operand is either an expression, which is an unevaluated
// operand (Clause 5) [...]
//
// The GNU typeof and alignof extensions also behave as unevaluated
@@ -1076,9 +1076,9 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
// expression.
ParenParseOption ExprType = CastExpr;
SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
-
+
// C++0x [expr.sizeof]p1:
- // [...] The operand is either an expression, which is an unevaluated
+ // [...] The operand is either an expression, which is an unevaluated
// operand (Clause 5) [...]
//
// The GNU typeof and alignof extensions also behave as unevaluated
@@ -1096,7 +1096,7 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
return ExprEmpty();
}
- // If this is a parenthesized expression, it is the start of a
+ // If this is a parenthesized expression, it is the start of a
// unary-expression, but doesn't include any postfix pieces. Parse these
// now if present.
Operand = ParsePostfixExpressionSuffix(move(Operand));
@@ -1121,7 +1121,7 @@ Parser::OwningExprResult Parser::ParseSizeofAlignofExpression() {
"Not a sizeof/alignof expression!");
Token OpTok = Tok;
ConsumeToken();
-
+
bool isCastExpr;
TypeTy *CastTy;
SourceRange CastRange;
@@ -1153,7 +1153,7 @@ Parser::OwningExprResult Parser::ParseSizeofAlignofExpression() {
/// [GNU] '__builtin_choose_expr' '(' assign-expr ',' assign-expr ','
/// assign-expr ')'
/// [GNU] '__builtin_types_compatible_p' '(' type-name ',' type-name ')'
-///
+///
/// [GNU] offsetof-member-designator:
/// [GNU] identifier
/// [GNU] offsetof-member-designator '.' identifier
@@ -1205,7 +1205,7 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
SkipUntil(tok::r_paren);
return ExprError();
}
-
+
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
return ExprError();
@@ -1261,8 +1261,8 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
} else if (Ty.isInvalid()) {
Res = ExprError();
} else {
- Res = Actions.ActOnBuiltinOffsetOf(CurScope, StartLoc, TypeLoc,
- Ty.get(), &Comps[0],
+ Res = Actions.ActOnBuiltinOffsetOf(CurScope, StartLoc, TypeLoc,
+ Ty.get(), &Comps[0],
Comps.size(), ConsumeParen());
}
break;
@@ -1342,7 +1342,7 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
///
Parser::OwningExprResult
Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
- bool parseAsExprList, TypeTy *&CastTy,
+ bool parseAsExprList, TypeTy *&CastTy,
SourceLocation &RParenLoc) {
assert(Tok.is(tok::l_paren) && "Not a paren expr!");
GreaterThanIsOperatorScope G(GreaterThanIsOperator, true);
@@ -1362,9 +1362,9 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
} else if (ExprType >= CompoundLiteral &&
isTypeIdInParens(isAmbiguousTypeId)) {
-
+
// Otherwise, this is a compound literal expression or cast expression.
-
+
// In C++, if the type-id is ambiguous we disambiguate based on context.
// If stopIfCastExpr is true the context is a typeof/sizeof/alignof
// in which case we should treat it as type-id.
@@ -1373,7 +1373,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
if (isAmbiguousTypeId && !stopIfCastExpr)
return ParseCXXAmbiguousParenExpression(ExprType, CastTy,
OpenLoc, RParenLoc);
-
+
TypeResult Ty = ParseTypeName();
// Match the ')'.
@@ -1419,7 +1419,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
if (!ParseExpressionList(ArgExprs, CommaLocs)) {
ExprType = SimpleExpr;
- Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
+ Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
move_arg(ArgExprs));
}
} else {
@@ -1434,7 +1434,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
SkipUntil(tok::r_paren);
return ExprError();
}
-
+
if (Tok.is(tok::r_paren))
RParenLoc = ConsumeParen();
else
@@ -1554,7 +1554,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
"block literal parsing");
- // Enter a scope to hold everything within the block. This includes the
+ // Enter a scope to hold everything within the block. This includes the
// argument decls, decls within the compound expression, etc. This also
// allows determining whether a variable reference inside the block is
// within or outside of the block.
@@ -1564,7 +1564,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
// Inform sema that we are starting a block.
Actions.ActOnBlockStart(CaretLoc, CurScope);
-
+
// Parse the return type if present.
DeclSpec DS;
Declarator ParamInfo(DS, Declarator::BlockLiteralContext);
@@ -1602,7 +1602,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
ParseBlockId();
} else {
// Otherwise, pretend we saw (void).
- ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(true, false,
+ ParamInfo.AddTypeInfo(DeclaratorChunk::getFunction(true, false,
SourceLocation(),
0, 0, 0,
false, SourceLocation(),
@@ -1629,7 +1629,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
Actions.ActOnBlockError(CaretLoc, CurScope);
return ExprError();
}
-
+
OwningStmtResult Stmt(ParseCompoundStatementBody());
if (!Stmt.isInvalid())
Result = Actions.ActOnBlockStmtExpr(CaretLoc, move(Stmt), CurScope);
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index a248a5dbee..a68ed6a803 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -16,10 +16,10 @@
#include "clang/Parse/DeclSpec.h"
using namespace clang;
-/// \brief Parse global scope or nested-name-specifier if present.
+/// \brief Parse global scope or nested-name-specifier if present.
///
/// Parses a C++ global scope specifier ('::') or nested-name-specifier (which
-/// may be preceded by '::'). Note that this routine will not parse ::new or
+/// may be preceded by '::'). Note that this routine will not parse ::new or
/// ::delete; it will just leave them in the token stream.
///
/// '::'[opt] nested-name-specifier
@@ -32,10 +32,10 @@ using namespace clang;
/// nested-name-specifier 'template'[opt] simple-template-id '::'
///
///
-/// \param SS the scope specifier that will be set to the parsed
+/// \param SS the scope specifier that will be set to the parsed
/// nested-name-specifier (or empty)
///
-/// \param ObjectType if this nested-name-specifier is being parsed following
+/// \param ObjectType if this nested-name-specifier is being parsed following
/// the "." or "->" of a member access expression, this parameter provides the
/// type of the object whose members are being accessed.
///
@@ -48,7 +48,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
bool EnteringContext) {
assert(getLang().CPlusPlus &&
"Call sites of this function should be guarded by checking for C++");
-
+
if (Tok.is(tok::annot_cxxscope)) {
SS.setScopeRep(Tok.getAnnotationValue());
SS.setRange(Tok.getAnnotationRange());
@@ -63,7 +63,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
tok::TokenKind NextKind = NextToken().getKind();
if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
return false;
-
+
// '::' - Global scope qualifier.
SourceLocation CCLoc = ConsumeToken();
SS.setBeginLoc(CCLoc);
@@ -86,7 +86,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
// seen a leading '::' or part of a nested-name-specifier.
ObjectType = 0;
}
-
+
// nested-name-specifier:
// nested-name-specifier 'template'[opt] simple-template-id '::'
@@ -100,14 +100,14 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
break;
SourceLocation TemplateKWLoc = ConsumeToken();
-
+
if (Tok.isNot(tok::identifier)) {
- Diag(Tok.getLocation(),
+ Diag(Tok.getLocation(),
diag::err_id_after_template_in_nested_name_spec)
<< SourceRange(TemplateKWLoc);
break;
}
-
+
if (NextToken().isNot(tok::less)) {
Diag(NextToken().getLocation(),
diag::err_less_after_template_name_in_nested_name_spec)
@@ -115,8 +115,8 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
<< SourceRange(TemplateKWLoc, Tok.getLocation());
break;
}
-
- TemplateTy Template
+
+ TemplateTy Template
= Actions.ActOnDependentTemplateName(TemplateKWLoc,
*Tok.getIdentifierInfo(),
Tok.getLocation(), SS,
@@ -126,40 +126,40 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
if (AnnotateTemplateIdToken(Template, TNK_Dependent_template_name,
&SS, TemplateKWLoc, false))
break;
-
+
continue;
}
-
+
if (Tok.is(tok::annot_template_id) && NextToken().is(tok::coloncolon)) {
- // We have
+ // We have
//
// simple-template-id '::'
//
// So we need to check whether the simple-template-id is of the
// right kind (it should name a type or be dependent), and then
// convert it into a type within the nested-name-specifier.
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
- if (TemplateId->Kind == TNK_Type_template ||
+ if (TemplateId->Kind == TNK_Type_template ||
TemplateId->Kind == TNK_Dependent_template_name) {
AnnotateTemplateIdTokenAsType(&SS);
- assert(Tok.is(tok::annot_typename) &&
+ assert(Tok.is(tok::annot_typename) &&
"AnnotateTemplateIdTokenAsType isn't working");
Token TypeToken = Tok;
ConsumeToken();
assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!");
SourceLocation CCLoc = ConsumeToken();
-
+
if (!HasScopeSpecifier) {
SS.setBeginLoc(TypeToken.getLocation());
HasScopeSpecifier = true;
}
-
+
if (TypeToken.getAnnotationValue())
SS.setScopeRep(
- Actions.ActOnCXXNestedNameSpecifier(CurScope, SS,
+ Actions.ActOnCXXNestedNameSpecifier(CurScope, SS,
TypeToken.getAnnotationValue(),
TypeToken.getAnnotationRange(),
CCLoc));
@@ -168,7 +168,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
SS.setEndLoc(CCLoc);
continue;
}
-
+
assert(false && "FIXME: Only type template names supported here");
}
@@ -191,22 +191,22 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
SourceLocation IdLoc = ConsumeToken();
assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!");
SourceLocation CCLoc = ConsumeToken();
-
+
if (!HasScopeSpecifier) {
SS.setBeginLoc(IdLoc);
HasScopeSpecifier = true;
}
-
+
if (SS.isInvalid())
continue;
-
+
SS.setScopeRep(
Actions.ActOnCXXNestedNameSpecifier(CurScope, SS, IdLoc, CCLoc, II,
ObjectType, EnteringContext));
SS.setEndLoc(CCLoc);
continue;
}
-
+
// nested-name-specifier:
// type-name '<'
if (Next.is(tok::less)) {
@@ -234,7 +234,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS,
// nested-name-specifier, so we're done.
break;
}
-
+
return HasScopeSpecifier;
}
@@ -337,17 +337,17 @@ Parser::OwningExprResult Parser::ParseCXXIdExpression(bool isAddressOfOperand) {
}
case tok::annot_template_id: {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
assert((TemplateId->Kind == TNK_Function_template ||
TemplateId->Kind == TNK_Dependent_template_name) &&
"A template type name is not an ID expression");
- ASTTemplateArgsPtr TemplateArgsPtr(Actions,
+ ASTTemplateArgsPtr TemplateArgsPtr(Actions,
TemplateId->getTemplateArgs(),
TemplateId->getTemplateArgIsType(),
TemplateId->NumArgs);
-
+
OwningExprResult Result
= Actions.ActOnTemplateIdExpr(TemplateTy::make(TemplateId->Template),
TemplateId->TemplateNameLoc,
@@ -403,11 +403,11 @@ Parser::OwningExprResult Parser::ParseCXXCasts() {
return ExprError();
OwningExprResult Result = ParseExpression();
-
+
// Match the ')'.
if (Result.isInvalid())
SkipUntil(tok::r_paren);
-
+
if (Tok.is(tok::r_paren))
RParenLoc = ConsumeParen();
else
@@ -455,11 +455,11 @@ Parser::OwningExprResult Parser::ParseCXXTypeid() {
Ty.get(), RParenLoc);
} else {
// C++0x [expr.typeid]p3:
- // When typeid is applied to an expression other than an lvalue of a
- // polymorphic class type [...] The expression is an unevaluated
+ // When typeid is applied to an expression other than an lvalue of a
+ // polymorphic class type [...] The expression is an unevaluated
// operand (Clause 5).
//
- // Note that we can't tell whether the expression is an lvalue of a
+ // Note that we can't tell whether the expression is an lvalue of a
// polymorphic class type until after we've parsed the expression, so
// we the expression is potentially potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(Actions,
@@ -654,12 +654,12 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
const char *PrevSpec;
unsigned DiagID;
SourceLocation Loc = Tok.getLocation();
-
+
switch (Tok.getKind()) {
case tok::identifier: // foo::bar
case tok::coloncolon: // ::foo::bar
assert(0 && "Annotation token should already be formed!");
- default:
+ default:
assert(0 && "Not a simple-type-specifier token!");
abort();
@@ -669,7 +669,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
Tok.getAnnotationValue());
break;
}
-
+
// builtin types
case tok::kw_short:
DS.SetTypeSpecWidth(DeclSpec::TSW_short, Loc, PrevSpec, DiagID);
@@ -710,7 +710,7 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
case tok::kw_bool:
DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID);
break;
-
+
// GNU typeof support.
case tok::kw_typeof:
ParseTypeofSpecifier(DS);
@@ -747,7 +747,7 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
Diag(Tok, diag::err_operator_missing_type_specifier);
return true;
}
-
+
while (ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec, DiagID)) ;
return false;
@@ -878,7 +878,7 @@ Parser::TypeTy *Parser::ParseConversionFunctionId(SourceLocation *EndLoc) {
/// ParseCXXNewExpression - Parse a C++ new-expression. New is used to allocate
/// memory in a typesafe manner and call constructors.
-///
+///
/// This method is called to parse the new expression after the optional :: has
/// been already parsed. If the :: was present, "UseGlobal" is true and "Start"
/// is its location. Otherwise, "Start" is the location of the 'new' token.
@@ -1087,8 +1087,7 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) {
return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, move(Operand));
}
-static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind)
-{
+static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
switch(kind) {
default: assert(false && "Not a known unary type trait.");
case tok::kw___has_nothrow_assign: return UTT_HasNothrowAssign;
@@ -1116,8 +1115,7 @@ static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind)
/// primary-expression:
/// [GNU] unary-type-trait '(' type-id ')'
///
-Parser::OwningExprResult Parser::ParseUnaryTypeTrait()
-{
+Parser::OwningExprResult Parser::ParseUnaryTypeTrait() {
UnaryTypeTrait UTT = UnaryTypeTraitFromTokKind(Tok.getKind());
SourceLocation Loc = ConsumeToken();
@@ -1172,7 +1170,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
// parsing a cast-expression), and then we re-introduce the cached tokens
// into the token stream and parse them appropriately.
- ParenParseOption ParseAs;
+ ParenParseOption ParseAs;
CachedTokens Toks;
// Store the tokens of the parentheses. We will parse them after we determine
@@ -1204,7 +1202,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
ParseAs = NotCastExpr ? SimpleExpr : CastExpr;
}
- // The current token should go after the cached tokens.
+ // The current token should go after the cached tokens.
Toks.push_back(Tok);
// Re-enter the stored parenthesized tokens into the token stream, so we may
// parse them now.
@@ -1227,7 +1225,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
ExprType = CompoundLiteral;
return ParseCompoundLiteralExpression(Ty.get(), LParenLoc, RParenLoc);
}
-
+
// We parsed '(' type-id ')' and the thing after it wasn't a '{'.
assert(ParseAs == CastExpr);
@@ -1238,11 +1236,11 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
// Result is what ParseCastExpression returned earlier.
if (!Result.isInvalid())
- Result = Actions.ActOnCastExpr(CurScope, LParenLoc, CastTy, RParenLoc,
+ Result = Actions.ActOnCastExpr(CurScope, LParenLoc, CastTy, RParenLoc,
move(Result));
return move(Result);
}
-
+
// Not a compound literal, and not followed by a cast-expression.
assert(ParseAs == SimpleExpr);
@@ -1256,7 +1254,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
SkipUntil(tok::r_paren);
return ExprError();
}
-
+
if (Tok.is(tok::r_paren))
RParenLoc = ConsumeParen();
else
diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp
index bbc2124e59..6ab23fd42d 100644
--- a/lib/Parse/ParseInit.cpp
+++ b/lib/Parse/ParseInit.cpp
@@ -20,7 +20,7 @@ using namespace clang;
/// MayBeDesignationStart - Return true if this token might be the start of a
/// designator. If we can tell it is impossible that it is a designator, return
-/// false.
+/// false.
static bool MayBeDesignationStart(tok::TokenKind K, Preprocessor &PP) {
switch (K) {
default: return false;
@@ -70,46 +70,46 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
NewSyntax += " = ";
SourceLocation NameLoc = ConsumeToken(); // Eat the identifier.
-
+
assert(Tok.is(tok::colon) && "MayBeDesignationStart not working properly!");
SourceLocation ColonLoc = ConsumeToken();
Diag(Tok, diag::ext_gnu_old_style_field_designator)
- << CodeModificationHint::CreateReplacement(SourceRange(NameLoc,
+ << CodeModificationHint::CreateReplacement(SourceRange(NameLoc,
ColonLoc),
NewSyntax);
Designation D;
D.AddDesignator(Designator::getField(FieldName, SourceLocation(), NameLoc));
- return Actions.ActOnDesignatedInitializer(D, ColonLoc, true,
+ return Actions.ActOnDesignatedInitializer(D, ColonLoc, true,
ParseInitializer());
}
-
+
// Desig - This is initialized when we see our first designator. We may have
// an objc message send with no designator, so we don't want to create this
// eagerly.
Designation Desig;
-
+
// Parse each designator in the designator list until we find an initializer.
while (Tok.is(tok::period) || Tok.is(tok::l_square)) {
if (Tok.is(tok::period)) {
// designator: '.' identifier
SourceLocation DotLoc = ConsumeToken();
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok.getLocation(), diag::err_expected_field_designator);
return ExprError();
}
-
+
Desig.AddDesignator(Designator::getField(Tok.getIdentifierInfo(), DotLoc,
Tok.getLocation()));
ConsumeToken(); // Eat the identifier.
continue;
}
-
+
// We must have either an array designator now or an objc message send.
assert(Tok.is(tok::l_square) && "Unexpected token!");
-
+
// Handle the two forms of array designator:
// array-designator: '[' constant-expression ']'
// array-designator: '[' constant-expression '...' constant-expression ']'
@@ -123,14 +123,14 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
// [4][foo bar] -> obsolete GNU designation with objc message send.
//
SourceLocation StartLoc = ConsumeBracket();
-
+
// If Objective-C is enabled and this is a typename or other identifier
// receiver, parse this as a message send expression.
if (getLang().ObjC1 && isTokObjCMessageIdentifierReceiver()) {
// If we have exactly one array designator, this used the GNU
// 'designation: array-designator' extension, otherwise there should be no
// designators at all!
- if (Desig.getNumDesignators() == 1 &&
+ if (Desig.getNumDesignators() == 1 &&
(Desig.getDesignator(0).isArrayDesignator() ||
Desig.getDesignator(0).isArrayRangeDesignator()))
Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
@@ -151,18 +151,18 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
SkipUntil(tok::r_square);
return move(Idx);
}
-
+
// Given an expression, we could either have a designator (if the next
// tokens are '...' or ']' or an objc message send. If this is an objc
- // message send, handle it now. An objc-message send is the start of
+ // message send, handle it now. An objc-message send is the start of
// an assignment-expression production.
- if (getLang().ObjC1 && Tok.isNot(tok::ellipsis) &&
+ if (getLang().ObjC1 && Tok.isNot(tok::ellipsis) &&
Tok.isNot(tok::r_square)) {
-
+
// If we have exactly one array designator, this used the GNU
// 'designation: array-designator' extension, otherwise there should be no
// designators at all!
- if (Desig.getNumDesignators() == 1 &&
+ if (Desig.getNumDesignators() == 1 &&
(Desig.getDesignator(0).isArrayDesignator() ||
Desig.getDesignator(0).isArrayRangeDesignator()))
Diag(StartLoc, diag::ext_gnu_missing_equal_designator);
@@ -213,7 +213,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
// an initializer. If we have exactly one array designator, this
// is the GNU 'designation: array-designator' extension. Otherwise, it is a
// parse error.
- if (Desig.getNumDesignators() == 1 &&
+ if (Desig.getNumDesignators() == 1 &&
(Desig.getDesignator(0).isArrayDesignator() ||
Desig.getDesignator(0).isArrayRangeDesignator())) {
Diag(Tok, diag::ext_gnu_missing_equal_designator)
@@ -267,13 +267,13 @@ Parser::OwningExprResult Parser::ParseBraceInitializer() {
SubElt = ParseInitializerWithPotentialDesignator();
else
SubElt = ParseInitializer();
-
+
// If we couldn't parse the subelement, bail out.
if (!SubElt.isInvalid()) {
InitExprs.push_back(SubElt.release());
} else {
InitExprsOk = false;
-
+
// We have two ways to try to recover from this error: if the code looks
// gramatically ok (i.e. we have a comma coming up) try to continue
// parsing the rest of the initializer. This allows us to emit
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 013e26b891..fdd031c66d 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -29,7 +29,7 @@ using namespace clang;
/// [OBJC] '@' 'end'
Parser::DeclPtrTy Parser::ParseObjCAtDirectives() {
SourceLocation AtLoc = ConsumeToken(); // the "@"
-
+
switch (Tok.getObjCKeywordID()) {
case tok::objc_class:
return ParseObjCAtClassDeclaration(AtLoc);
@@ -55,13 +55,13 @@ Parser::DeclPtrTy Parser::ParseObjCAtDirectives() {
}
///
-/// objc-class-declaration:
+/// objc-class-declaration:
/// '@' 'class' identifier-list ';'
-///
+///
Parser::DeclPtrTy Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
ConsumeToken(); // the identifier "class"
llvm::SmallVector<IdentifierInfo *, 8> ClassNames;
-
+
while (1) {
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
@@ -70,17 +70,17 @@ Parser::DeclPtrTy Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
}
ClassNames.push_back(Tok.getIdentifierInfo());
ConsumeToken();
-
+
if (Tok.isNot(tok::comma))
break;
-
+
ConsumeToken();
}
-
+
// Consume the ';'.
if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
return DeclPtrTy();
-
+
return Actions.ActOnForwardClassDeclaration(atLoc,
&ClassNames[0], ClassNames.size());
}
@@ -91,14 +91,14 @@ Parser::DeclPtrTy Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
/// objc-category-interface
///
/// objc-class-interface:
-/// '@' 'interface' identifier objc-superclass[opt]
+/// '@' 'interface' identifier objc-superclass[opt]
/// objc-protocol-refs[opt]
-/// objc-class-instance-variables[opt]
+/// objc-class-instance-variables[opt]
/// objc-interface-decl-list
/// @end
///
/// objc-category-interface:
-/// '@' 'interface' identifier '(' identifier[opt] ')'
+/// '@' 'interface' identifier '(' identifier[opt] ')'
/// objc-protocol-refs[opt]
/// objc-interface-decl-list
/// @end
@@ -118,7 +118,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
"ParseObjCAtInterfaceDeclaration(): Expected @interface");
ConsumeToken(); // the "interface" identifier
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return DeclPtrTy();
@@ -126,12 +126,12 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
// We have a class or category name - consume it.
IdentifierInfo *nameId = Tok.getIdentifierInfo();
SourceLocation nameLoc = ConsumeToken();
-
+
if (Tok.is(tok::l_paren)) { // we have a category.
SourceLocation lparenLoc = ConsumeParen();
SourceLocation categoryLoc, rparenLoc;
IdentifierInfo *categoryId = 0;
-
+
// For ObjC2, the category name is optional (not an error).
if (Tok.is(tok::identifier)) {
categoryId = Tok.getIdentifierInfo();
@@ -146,25 +146,25 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
return DeclPtrTy();
}
rparenLoc = ConsumeParen();
-
+
// Next, we need to check for any protocol references.
SourceLocation EndProtoLoc;
llvm::SmallVector<DeclPtrTy, 8> ProtocolRefs;
if (Tok.is(tok::less) &&
ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
return DeclPtrTy();
-
+
if (attrList) // categories don't support attributes.
Diag(Tok, diag::err_objc_no_attributes_on_category);
-
+
DeclPtrTy CategoryType =
- Actions.ActOnStartCategoryInterface(atLoc,
+ Actions.ActOnStartCategoryInterface(atLoc,
nameId, nameLoc,
categoryId, categoryLoc,
ProtocolRefs.data(),
ProtocolRefs.size(),
EndProtoLoc);
-
+
ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword);
return CategoryType;
}
@@ -187,13 +187,13 @@ Parser::DeclPtrTy Parser::ParseObjCAtInterfaceDeclaration(
if (Tok.is(tok::less) &&
ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc))
return DeclPtrTy();
-
- DeclPtrTy ClsType =
- Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc,
+
+ DeclPtrTy ClsType =
+ Actions.ActOnStartClassInterface(atLoc, nameId, nameLoc,
superClassId, superClassLoc,
ProtocolRefs.data(), ProtocolRefs.size(),
EndProtoLoc, attrList);
-
+
if (Tok.is(tok::l_brace))
ParseObjCClassInstanceVariables(ClsType, atLoc);
@@ -219,13 +219,13 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
llvm::SmallVector<DeclPtrTy, 16> allProperties;
llvm::SmallVector<DeclGroupPtrTy, 8> allTUVariables;
tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
-
+
SourceLocation AtEndLoc;
while (1) {
// If this is a method prototype, parse it.
if (Tok.is(tok::minus) || Tok.is(tok::plus)) {
- DeclPtrTy methodPrototype =
+ DeclPtrTy methodPrototype =
ParseObjCMethodPrototype(interfaceDecl, MethodImplKind);
allMethods.push_back(methodPrototype);
// Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
@@ -234,17 +234,17 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
"", tok::semi);
continue;
}
-
+
// Ignore excess semicolons.
if (Tok.is(tok::semi)) {
ConsumeToken();
continue;
}
-
+
// If we got to the end of the file, exit the loop.
if (Tok.is(tok::eof))
break;
-
+
// If we don't have an @ directive, parse it as a function definition.
if (Tok.isNot(tok::at)) {
// The code below does not consume '}'s because it is afraid of eating the
@@ -252,22 +252,22 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
// erroneous r_brace would cause an infinite loop if not handled here.
if (Tok.is(tok::r_brace))
break;
-
+
// FIXME: as the name implies, this rule allows function definitions.
// We could pass a flag or check for functions during semantic analysis.
allTUVariables.push_back(ParseDeclarationOrFunctionDefinition());
continue;
}
-
+
// Otherwise, we have an @ directive, eat the @.
SourceLocation AtLoc = ConsumeToken(); // the "@"
tok::ObjCKeywordKind DirectiveKind = Tok.getObjCKeywordID();
-
+
if (DirectiveKind == tok::objc_end) { // @end -> terminate list
AtEndLoc = AtLoc;
break;
}
-
+
// Eat the identifier.
ConsumeToken();
@@ -281,7 +281,7 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
// Skip until we see an '@' or '}' or ';'.
SkipUntil(tok::r_brace, tok::at);
break;
-
+
case tok::objc_required:
case tok::objc_optional:
// This is only valid on protocols.
@@ -291,24 +291,24 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
else
MethodImplKind = DirectiveKind;
break;
-
+
case tok::objc_property:
if (!getLang().ObjC2)
Diag(AtLoc, diag::err_objc_propertoes_require_objc2);
ObjCDeclSpec OCDS;
- // Parse property attribute list, if any.
+ // Parse property attribute list, if any.
if (Tok.is(tok::l_paren))
ParseObjCPropertyAttribute(OCDS);
-
+
// Parse all the comma separated declarators.
DeclSpec DS;
llvm::SmallVector<FieldDeclarator, 8> FieldDeclarators;
ParseStructDeclaration(DS, FieldDeclarators);
-
+
ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list, "",
tok::at);
-
+
// Convert them all to property declarations.
for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
FieldDeclarator &FD = FieldDeclarators[i];
@@ -322,12 +322,12 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
<< FD.D.getSourceRange();
continue;
}
-
+
// Install the property declarator into interfaceDecl.
IdentifierInfo *SelName =
OCDS.getGetterName() ? OCDS.getGetterName() : FD.D.getIdentifier();
-
- Selector GetterSel =
+
+ Selector GetterSel =
PP.getSelectorTable().getNullarySelector(SelName);
IdentifierInfo *SetterName = OCDS.getSetterName();
Selector SetterSel;
@@ -340,7 +340,7 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
bool isOverridingProperty = false;
DeclPtrTy Property = Actions.ActOnProperty(CurScope, AtLoc, FD, OCDS,
GetterSel, SetterSel,
- interfaceDecl,
+ interfaceDecl,
&isOverridingProperty,
MethodImplKind);
if (!isOverridingProperty)
@@ -356,11 +356,11 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
ConsumeToken(); // the "end" identifier
else
Diag(Tok, diag::err_objc_missing_end);
-
+
// Insert collected methods declarations into the @interface object.
// This passes in an invalid SourceLocation for AtEndLoc when EOF is hit.
Actions.ActOnAtEnd(AtEndLoc, interfaceDecl,
- allMethods.data(), allMethods.size(),
+ allMethods.data(), allMethods.size(),
allProperties.data(), allProperties.size(),
allTUVariables.data(), allTUVariables.size());
}
@@ -384,18 +384,18 @@ void Parser::ParseObjCInterfaceDeclList(DeclPtrTy interfaceDecl,
void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
assert(Tok.getKind() == tok::l_paren);
SourceLocation LHSLoc = ConsumeParen(); // consume '('
-
+
while (1) {
const IdentifierInfo *II = Tok.getIdentifierInfo();
-
+
// If this is not an identifier at all, bail out early.
if (II == 0) {
MatchRHSPunctuation(tok::r_paren, LHSLoc);
return;
}
-
+
SourceLocation AttrName = ConsumeToken(); // consume last attribute name
-
+
if (II->isStr("readonly"))
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readonly);
else if (II->isStr("assign"))
@@ -413,18 +413,18 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
if (ExpectAndConsume(tok::equal, diag::err_objc_expected_equal, "",
tok::r_paren))
return;
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return;
}
-
+
if (II->getName()[0] == 's') {
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
DS.setSetterName(Tok.getIdentifierInfo());
ConsumeToken(); // consume method name
-
+
if (ExpectAndConsume(tok::colon, diag::err_expected_colon, "",
tok::r_paren))
return;
@@ -438,18 +438,18 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
SkipUntil(tok::r_paren);
return;
}
-
+
if (Tok.isNot(tok::comma))
break;
-
+
ConsumeToken();
}
-
+
MatchRHSPunctuation(tok::r_paren, LHSLoc);
}
/// objc-method-proto:
-/// objc-instance-method objc-method-decl objc-method-attributes[opt]
+/// objc-instance-method objc-method-decl objc-method-attributes[opt]
/// objc-class-method objc-method-decl objc-method-attributes[opt]
///
/// objc-instance-method: '-'
@@ -458,13 +458,13 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
/// objc-method-attributes: [OBJC2]
/// __attribute__((deprecated))
///
-Parser::DeclPtrTy Parser::ParseObjCMethodPrototype(DeclPtrTy IDecl,
+Parser::DeclPtrTy Parser::ParseObjCMethodPrototype(DeclPtrTy IDecl,
tok::ObjCKeywordKind MethodImplKind) {
assert((Tok.is(tok::minus) || Tok.is(tok::plus)) && "expected +/-");
- tok::TokenKind methodType = Tok.getKind();
+ tok::TokenKind methodType = Tok.getKind();
SourceLocation mLoc = ConsumeToken();
-
+
DeclPtrTy MDecl = ParseObjCMethodDecl(mLoc, methodType, IDecl,MethodImplKind);
// Since this rule is used for both method declarations and definitions,
// the caller is (optionally) responsible for consuming the ';'.
@@ -564,7 +564,7 @@ bool Parser::isTokIdentifier_in() const {
// FIXME: May have to do additional look-ahead to only allow for
// valid tokens following an 'in'; such as an identifier, unary operators,
// '[' etc.
- return (getLang().ObjC2 && Tok.is(tok::identifier) &&
+ return (getLang().ObjC2 && Tok.is(tok::identifier) &&
Tok.getIdentifierInfo() == ObjCTypeQuals[objc_in]);
}
@@ -580,12 +580,12 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS) {
while (1) {
if (Tok.isNot(tok::identifier))
return;
-
+
const IdentifierInfo *II = Tok.getIdentifierInfo();
for (unsigned i = 0; i != objc_NumQuals; ++i) {
if (II != ObjCTypeQuals[i])
continue;
-
+
ObjCDeclSpec::ObjCDeclQualifier Qual;
switch (i) {
default: assert(0 && "Unknown decl qualifier");
@@ -601,7 +601,7 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS) {
II = 0;
break;
}
-
+
// If this wasn't a recognized qualifier, bail out.
if (II) return;
}
@@ -613,10 +613,10 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS) {
///
Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS) {
assert(Tok.is(tok::l_paren) && "expected (");
-
+
SourceLocation LParenLoc = ConsumeParen();
SourceLocation TypeStartLoc = Tok.getLocation();
-
+
// Parse type qualifiers, in, inout, etc.
ParseObjCTypeQualifierList(DS);
@@ -626,7 +626,7 @@ Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS) {
if (!TypeSpec.isInvalid())
Ty = TypeSpec.get();
}
-
+
if (Tok.is(tok::r_paren))
ConsumeParen();
else if (Tok.getLocation() == TypeStartLoc) {
@@ -648,7 +648,7 @@ Parser::TypeTy *Parser::ParseObjCTypeName(ObjCDeclSpec &DS) {
/// objc-type-name objc-keyword-selector objc-parmlist[opt]
///
/// objc-keyword-selector:
-/// objc-keyword-decl
+/// objc-keyword-decl
/// objc-keyword-selector objc-keyword-decl
///
/// objc-keyword-decl:
@@ -678,7 +678,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
ObjCDeclSpec DSRet;
if (Tok.is(tok::l_paren))
ReturnType = ParseObjCTypeName(DSRet);
-
+
SourceLocation selLoc;
IdentifierInfo *SelIdent = ParseObjCSelectorPiece(selLoc);
@@ -690,14 +690,14 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
SkipUntil(tok::r_brace);
return DeclPtrTy();
}
-
+
llvm::SmallVector<Declarator, 8> CargNames;
if (Tok.isNot(tok::colon)) {
// If attributes exist after the method, parse them.
AttributeList *MethodAttrs = 0;
- if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
+ if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
MethodAttrs = ParseAttributes();
-
+
Selector Sel = PP.getSelectorTable().getNullarySelector(SelIdent);
return Actions.ActOnMethodDeclaration(mLoc, Tok.getLocation(),
mType, IDecl, DSRet, ReturnType, Sel,
@@ -707,17 +707,17 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
llvm::SmallVector<Action::ObjCArgInfo, 12> ArgInfos;
-
+
while (1) {
Action::ObjCArgInfo ArgInfo;
-
+
// Each iteration parses a single keyword argument.
if (Tok.isNot(tok::colon)) {
Diag(Tok, diag::err_expected_colon);
break;
}
ConsumeToken(); // Eat the ':'.
-
+
ArgInfo.Type = 0;
if (Tok.is(tok::l_paren)) // Parse the argument type if present.
ArgInfo.Type = ParseObjCTypeName(ArgInfo.DeclSpec);
@@ -731,11 +731,11 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
Diag(Tok, diag::err_expected_ident); // missing argument name.
break;
}
-
+
ArgInfo.Name = Tok.getIdentifierInfo();
ArgInfo.NameLoc = Tok.getLocation();
ConsumeToken(); // Eat the identifier.
-
+
ArgInfos.push_back(ArgInfo);
KeyIdents.push_back(SelIdent);
@@ -746,9 +746,9 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
break;
// We have a selector or a colon, continue parsing.
}
-
+
bool isVariadic = false;
-
+
// Parse the (optional) parameter list.
while (Tok.is(tok::comma)) {
ConsumeToken();
@@ -759,18 +759,18 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDecl(SourceLocation mLoc,
}
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
- // Parse the declarator.
+ // Parse the declarator.
Declarator ParmDecl(DS, Declarator::PrototypeContext);
ParseDeclarator(ParmDecl);
CargNames.push_back(ParmDecl);
}
-
+
// FIXME: Add support for optional parmameter list...
// If attributes exist after the method, parse them.
AttributeList *MethodAttrs = 0;
- if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
+ if (getLang().ObjC2 && Tok.is(tok::kw___attribute))
MethodAttrs = ParseAttributes();
-
+
if (KeyIdents.size() == 0)
return DeclPtrTy();
Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(),
@@ -788,11 +788,11 @@ bool Parser::
ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &Protocols,
bool WarnOnDeclarations, SourceLocation &EndLoc) {
assert(Tok.is(tok::less) && "expected <");
-
+
ConsumeToken(); // the "<"
-
+
llvm::SmallVector<IdentifierLocPair, 8> ProtocolIdents;
-
+
while (1) {
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
@@ -802,20 +802,20 @@ ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &Protocols,
ProtocolIdents.push_back(std::make_pair(Tok.getIdentifierInfo(),
Tok.getLocation()));
ConsumeToken();
-
+
if (Tok.isNot(tok::comma))
break;
ConsumeToken();
}
-
+
// Consume the '>'.
if (Tok.isNot(tok::greater)) {
Diag(Tok, diag::err_expected_greater);
return true;
}
-
+
EndLoc = ConsumeAnyToken();
-
+
// Convert the list of protocols identifiers into a list of protocol decls.
Actions.FindProtocolDeclaration(WarnOnDeclarations,
&ProtocolIdents[0], ProtocolIdents.size(),
@@ -841,7 +841,7 @@ ParseObjCProtocolReferences(llvm::SmallVectorImpl<Action::DeclPtrTy> &Protocols,
/// @package [OBJC2]
///
/// objc-instance-variable-decl:
-/// struct-declaration
+/// struct-declaration
///
void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
SourceLocation atLoc) {
@@ -852,19 +852,19 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
ParseScope ClassScope(this, Scope::DeclScope|Scope::ClassScope);
SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
-
+
tok::ObjCKeywordKind visibility = tok::objc_protected;
// While we still have something to read, read the instance variables.
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
// Each iteration of this loop reads one objc-instance-variable-decl.
-
+
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
Diag(Tok, diag::ext_extra_struct_semi);
ConsumeToken();
continue;
}
-
+
// Set the default visibility to private.
if (Tok.is(tok::at)) { // parse objc-visibility-spec
ConsumeToken(); // eat the @ sign
@@ -875,18 +875,18 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
case tok::objc_package:
visibility = Tok.getObjCKeywordID();
ConsumeToken();
- continue;
+ continue;
default:
Diag(Tok, diag::err_objc_illegal_visibility_spec);
continue;
}
}
-
+
// Parse all the comma separated declarators.
DeclSpec DS;
FieldDeclarators.clear();
ParseStructDeclaration(DS, FieldDeclarators);
-
+
// Convert them all to fields.
for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
FieldDeclarator &FD = FieldDeclarators[i];
@@ -897,7 +897,7 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
FD.D, FD.BitfieldSize, visibility);
AllIvarDecls.push_back(Field);
}
-
+
if (Tok.is(tok::semi)) {
ConsumeToken();
} else {
@@ -920,9 +920,9 @@ void Parser::ParseObjCClassInstanceVariables(DeclPtrTy interfaceDecl,
/// objc-protocol-forward-reference
///
/// objc-protocol-definition:
-/// @protocol identifier
-/// objc-protocol-refs[opt]
-/// objc-interface-decl-list
+/// @protocol identifier
+/// objc-protocol-refs[opt]
+/// objc-interface-decl-list
/// @end
///
/// objc-protocol-forward-reference:
@@ -936,7 +936,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
"ParseObjCAtProtocolDeclaration(): Expected @protocol");
ConsumeToken(); // the "protocol" identifier
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing protocol name.
return DeclPtrTy();
@@ -944,14 +944,14 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
// Save the protocol name, then consume it.
IdentifierInfo *protocolName = Tok.getIdentifierInfo();
SourceLocation nameLoc = ConsumeToken();
-
+
if (Tok.is(tok::semi)) { // forward declaration of one protocol.
IdentifierLocPair ProtoInfo(protocolName, nameLoc);
ConsumeToken();
- return Actions.ActOnForwardProtocolDeclaration(AtLoc, &ProtoInfo, 1,
+ return Actions.ActOnForwardProtocolDeclaration(AtLoc, &ProtoInfo, 1,
attrList);
}
-
+
if (Tok.is(tok::comma)) { // list of forward declarations.
llvm::SmallVector<IdentifierLocPair, 8> ProtocolRefs;
ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
@@ -967,20 +967,20 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
ProtocolRefs.push_back(IdentifierLocPair(Tok.getIdentifierInfo(),
Tok.getLocation()));
ConsumeToken(); // the identifier
-
+
if (Tok.isNot(tok::comma))
break;
}
// Consume the ';'.
if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@protocol"))
return DeclPtrTy();
-
+
return Actions.ActOnForwardProtocolDeclaration(AtLoc,
- &ProtocolRefs[0],
+ &ProtocolRefs[0],
ProtocolRefs.size(),
attrList);
}
-
+
// Last, and definitely not least, parse a protocol declaration.
SourceLocation EndProtoLoc;
@@ -988,7 +988,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
if (Tok.is(tok::less) &&
ParseObjCProtocolReferences(ProtocolRefs, false, EndProtoLoc))
return DeclPtrTy();
-
+
DeclPtrTy ProtoType =
Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
ProtocolRefs.data(),
@@ -1013,7 +1013,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
"ParseObjCAtImplementationDeclaration(): Expected @implementation");
ConsumeToken(); // the "implementation" identifier
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return DeclPtrTy();
@@ -1021,20 +1021,20 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
// We have a class or category name - consume it.
IdentifierInfo *nameId = Tok.getIdentifierInfo();
SourceLocation nameLoc = ConsumeToken(); // consume class or category name
-
- if (Tok.is(tok::l_paren)) {
+
+ if (Tok.is(tok::l_paren)) {
// we have a category implementation.
SourceLocation lparenLoc = ConsumeParen();
SourceLocation categoryLoc, rparenLoc;
IdentifierInfo *categoryId = 0;
-
+
if (Tok.is(tok::identifier)) {
categoryId = Tok.getIdentifierInfo();
categoryLoc = ConsumeToken();
} else {
Diag(Tok, diag::err_expected_ident); // missing category name.
return DeclPtrTy();
- }
+ }
if (Tok.isNot(tok::r_paren)) {
Diag(Tok, diag::err_expected_rparen);
SkipUntil(tok::r_paren, false); // don't stop at ';'
@@ -1042,7 +1042,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
}
rparenLoc = ConsumeParen();
DeclPtrTy ImplCatType = Actions.ActOnStartCategoryImplementation(
- atLoc, nameId, nameLoc, categoryId,
+ atLoc, nameId, nameLoc, categoryId,
categoryLoc);
ObjCImpDecl = ImplCatType;
return DeclPtrTy();
@@ -1063,11 +1063,11 @@ Parser::DeclPtrTy Parser::ParseObjCAtImplementationDeclaration(
DeclPtrTy ImplClsType = Actions.ActOnStartClassImplementation(
atLoc, nameId, nameLoc,
superClassId, superClassLoc);
-
+
if (Tok.is(tok::l_brace)) // we have ivars
ParseObjCClassInstanceVariables(ImplClsType/*FIXME*/, atLoc);
ObjCImpDecl = ImplClsType;
-
+
return DeclPtrTy();
}
@@ -1131,7 +1131,7 @@ Parser::DeclPtrTy Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
Diag(Tok, diag::err_expected_ident);
return DeclPtrTy();
}
-
+
while (Tok.is(tok::identifier)) {
IdentifierInfo *propertyIvar = 0;
IdentifierInfo *propertyId = Tok.getIdentifierInfo();
@@ -1186,7 +1186,7 @@ Parser::DeclPtrTy Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
Diag(Tok, diag::err_expected_semi_after) << "@dynamic";
return DeclPtrTy();
}
-
+
/// objc-throw-statement:
/// throw expression[opt];
///
@@ -1288,7 +1288,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
DeclSpec DS;
ParseDeclarationSpecifiers(DS);
// For some odd reason, the name of the exception variable is
- // optional. As a result, we need to use "PrototypeContext", because
+ // optional. As a result, we need to use "PrototypeContext", because
// we must accept either 'declarator' or 'abstract-declarator' here.
Declarator ParmDecl(DS, Declarator::PrototypeContext);
ParseDeclarator(ParmDecl);
@@ -1298,9 +1298,9 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
} else
ConsumeToken(); // consume '...'
-
+
SourceLocation RParenLoc;
-
+
if (Tok.is(tok::r_paren))
RParenLoc = ConsumeParen();
else // Skip over garbage, until we get to ')'. Eat the ')'.
@@ -1352,11 +1352,11 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
///
Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
DeclPtrTy MDecl = ParseObjCMethodPrototype(ObjCImpDecl);
-
+
PrettyStackTraceActionsDecl CrashInfo(MDecl, Tok.getLocation(), Actions,
PP.getSourceManager(),
"parsing Objective-C method");
-
+
// parse optional ';'
if (Tok.is(tok::semi))
ConsumeToken();
@@ -1364,19 +1364,19 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
// We should have an opening brace now.
if (Tok.isNot(tok::l_brace)) {
Diag(Tok, diag::err_expected_method_body);
-
+
// Skip over garbage, until we get to '{'. Don't eat the '{'.
SkipUntil(tok::l_brace, true, true);
-
+
// If we didn't find the '{', bail out.
if (Tok.isNot(tok::l_brace))
return DeclPtrTy();
}
SourceLocation BraceLoc = Tok.getLocation();
-
+
// Enter a scope for the method body.
ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
-
+
// Tell the actions module that we have entered a method definition with the
// specified Declarator for the method.
Actions.ActOnStartOfObjCMethodDef(CurScope, MDecl);
@@ -1390,7 +1390,7 @@ Parser::DeclPtrTy Parser::ParseObjCMethodDefinition() {
// TODO: Pass argument information.
Actions.ActOnFinishFunctionBody(MDecl, move(FnBody));
-
+
// Leave the function body scope.
BodyScope.Exit();
@@ -1439,7 +1439,7 @@ Parser::OwningExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
}
}
-/// objc-message-expr:
+/// objc-message-expr:
/// '[' objc-receiver objc-message-args ']'
///
/// objc-receiver:
@@ -1472,7 +1472,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
/// ParseObjCMessageExpressionBody - Having parsed "'[' objc-receiver", parse
/// the rest of a message expression.
-///
+///
/// objc-message-args:
/// objc-selector
/// objc-keywordarg-list
@@ -1481,7 +1481,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
/// objc-keywordarg
/// objc-keywordarg-list objc-keywordarg
///
-/// objc-keywordarg:
+/// objc-keywordarg:
/// selector-name[opt] ':' objc-keywordexpr
///
/// objc-keywordexpr:
@@ -1501,7 +1501,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
IdentifierInfo *selIdent = ParseObjCSelectorPiece(Loc);
SourceLocation SelectorLoc = Loc;
-
+
llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
ExprVector KeyExprs(Actions);
@@ -1520,7 +1520,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
}
ConsumeToken(); // Eat the ':'.
- /// Parse the expression after ':'
+ /// Parse the expression after ':'
OwningExprResult Res(ParseAssignmentExpression());
if (Res.isInvalid()) {
// We must manually skip to a ']', otherwise the expression skipper will
@@ -1542,7 +1542,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
// Parse the, optional, argument list, comma separated.
while (Tok.is(tok::comma)) {
ConsumeToken(); // Eat the ','.
- /// Parse the expression after ','
+ /// Parse the expression after ','
OwningExprResult Res(ParseAssignmentExpression());
if (Res.isInvalid()) {
// We must manually skip to a ']', otherwise the expression skipper will
@@ -1584,7 +1584,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
// We've just parsed a keyword message.
if (ReceiverName)
return Owned(Actions.ActOnClassMessage(CurScope, ReceiverName, Sel,
- LBracLoc, NameLoc, SelectorLoc,
+ LBracLoc, NameLoc, SelectorLoc,
RBracLoc,
KeyExprs.take(), KeyExprs.size()));
return Owned(Actions.ActOnInstanceMessage(ReceiverExpr.release(), Sel,
@@ -1642,7 +1642,7 @@ Parser::ParseObjCEncodeExpression(SourceLocation AtLoc) {
if (Ty.isInvalid())
return ExprError();
- return Owned(Actions.ParseObjCEncodeExpression(AtLoc, EncLoc, LParenLoc,
+ return Owned(Actions.ParseObjCEncodeExpression(AtLoc, EncLoc, LParenLoc,
Ty.get(), RParenLoc));
}
diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp
index 68b10934b1..812d8e2af9 100644
--- a/lib/Parse/ParsePragma.cpp
+++ b/lib/Parse/ParsePragma.cpp
@@ -37,7 +37,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
IdentifierInfo *Name = 0;
Action::OwningExprResult Alignment(Actions);
SourceLocation LParenLoc = Tok.getLocation();
- PP.Lex(Tok);
+ PP.Lex(Tok);
if (Tok.is(tok::numeric_constant)) {
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
@@ -57,12 +57,12 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
} else {
PP.Diag(Tok.getLocation(), diag::warn_pragma_pack_invalid_action);
return;
- }
+ }
PP.Lex(Tok);
-
+
if (Tok.is(tok::comma)) {
PP.Lex(Tok);
-
+
if (Tok.is(tok::numeric_constant)) {
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
@@ -72,15 +72,15 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
} else if (Tok.is(tok::identifier)) {
Name = Tok.getIdentifierInfo();
PP.Lex(Tok);
-
+
if (Tok.is(tok::comma)) {
PP.Lex(Tok);
-
+
if (Tok.isNot(tok::numeric_constant)) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_pack_malformed);
return;
}
-
+
Alignment = Actions.ActOnNumericConstant(Tok);
if (Alignment.isInvalid())
return;
@@ -115,7 +115,7 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, Token &PackTok) {
void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
// FIXME: Should we be expanding macros here? My guess is no.
SourceLocation UnusedLoc = UnusedTok.getLocation();
-
+
// Lex the left '('.
Token Tok;
PP.Lex(Tok);
@@ -124,17 +124,17 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
return;
}
SourceLocation LParenLoc = Tok.getLocation();
-
+
// Lex the declaration reference(s).
llvm::SmallVector<Token, 5> Identifiers;
SourceLocation RParenLoc;
bool LexID = true;
-
+
while (true) {
PP.Lex(Tok);
-
+
if (LexID) {
- if (Tok.is(tok::identifier)) {
+ if (Tok.is(tok::identifier)) {
Identifiers.push_back(Tok);
LexID = false;
continue;
@@ -144,18 +144,18 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_unused_expected_var);
return;
}
-
+
// We are execting a ')' or a ','.
if (Tok.is(tok::comma)) {
LexID = true;
continue;
}
-
+
if (Tok.is(tok::r_paren)) {
RParenLoc = Tok.getLocation();
break;
}
-
+
// Illegal token!
PP.Diag(Tok.getLocation(), diag::warn_pragma_unused_expected_punc);
return;
@@ -172,7 +172,7 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, Token &UnusedTok) {
assert(RParenLoc.isValid() && "Valid '#pragma unused' must have ')'");
assert(!Identifiers.empty() && "Valid '#pragma unused' must have arguments");
- // Perform the action to handle the pragma.
+ // Perform the action to handle the pragma.
Actions.ActOnPragmaUnused(Identifiers.data(), Identifiers.size(),
parser.CurScope, UnusedLoc, LParenLoc, RParenLoc);
}
@@ -197,7 +197,7 @@ void PragmaWeakHandler::HandlePragma(Preprocessor &PP, Token &WeakTok) {
if (Tok.is(tok::equal)) {
PP.Lex(Tok);
if (Tok.isNot(tok::identifier)) {
- PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
<< "weak";
return;
}
diff --git a/lib/Parse/ParsePragma.h b/lib/Parse/ParsePragma.h
index 39c86eea43..db385c6371 100644
--- a/lib/Parse/ParsePragma.h
+++ b/lib/Parse/ParsePragma.h
@@ -23,29 +23,29 @@ namespace clang {
class PragmaPackHandler : public PragmaHandler {
Action &Actions;
public:
- PragmaPackHandler(const IdentifierInfo *N, Action &A) : PragmaHandler(N),
+ PragmaPackHandler(const IdentifierInfo *N, Action &A) : PragmaHandler(N),
Actions(A) {}
-
- virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
+
+ virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};
-
+
class PragmaUnusedHandler : public PragmaHandler {
Action &Actions;
Parser &parser;
public:
PragmaUnusedHandler(const IdentifierInfo *N, Action &A, Parser& p)
: PragmaHandler(N), Actions(A), parser(p) {}
-
- virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
-};
+
+ virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
+};
class PragmaWeakHandler : public PragmaHandler {
Action &Actions;
public:
PragmaWeakHandler(const IdentifierInfo *N, Action &A)
: PragmaHandler(N), Actions(A) {}
-
- virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
+
+ virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};
} // end namespace clang
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 4a7bd57d78..edb0018d20 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -71,8 +71,8 @@ using namespace clang;
///
/// [OBC] objc-throw-statement:
/// [OBC] '@' 'throw' expression ';'
-/// [OBC] '@' 'throw' ';'
-///
+/// [OBC] '@' 'throw' ';'
+///
Parser::OwningStmtResult
Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
const char *SemiError = 0;
@@ -108,7 +108,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
Diag(Tok, diag::err_expected_statement);
return StmtError();
}
-
+
// expression[opt] ';'
OwningExprResult Expr(ParseExpression());
if (Expr.isInvalid()) {
@@ -187,7 +187,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
// Skip until we see a } or ;, but don't eat it.
SkipUntil(tok::r_brace, true, true);
}
-
+
return move(Res);
}
@@ -233,7 +233,7 @@ Parser::OwningStmtResult Parser::ParseLabeledStatement() {
///
Parser::OwningStmtResult Parser::ParseCaseStatement() {
assert(Tok.is(tok::kw_case) && "Not a case stmt!");
-
+
// It is very very common for code to contain many case statements recursively
// nested, as in (but usually without indentation):
// case 1:
@@ -247,20 +247,20 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() {
// flatten this recursion into an iterative loop. This is complex and gross,
// but all the grossness is constrained to ParseCaseStatement (and some
// wierdness in the actions), so this is just local grossness :).
-
+
// TopLevelCase - This is the highest level we have parsed. 'case 1' in the
// example above.
OwningStmtResult TopLevelCase(Actions, true);
-
+
// DeepestParsedCaseStmt - This is the deepest statement we have parsed, which
// gets updated each time a new case is parsed, and whose body is unset so
// far. When parsing 'case 4', this is the 'case 3' node.
StmtTy *DeepestParsedCaseStmt = 0;
-
+
// While we have case statements, eat and stack them.
do {
SourceLocation CaseLoc = ConsumeToken(); // eat the 'case'.
-
+
OwningExprResult LHS(ParseConstantExpression());
if (LHS.isInvalid()) {
SkipUntil(tok::colon);
@@ -288,11 +288,11 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() {
}
SourceLocation ColonLoc = ConsumeToken();
-
+
OwningStmtResult Case =
Actions.ActOnCaseStmt(CaseLoc, move(LHS), DotDotDotLoc,
move(RHS), ColonLoc);
-
+
// If we had a sema error parsing this case, then just ignore it and
// continue parsing the sub-stmt.
if (Case.isInvalid()) {
@@ -309,15 +309,15 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() {
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, move(Case));
DeepestParsedCaseStmt = NextDeepest;
}
-
+
// Handle all case statements.
} while (Tok.is(tok::kw_case));
-
+
assert(!TopLevelCase.isInvalid() && "Should have parsed at least one case!");
-
+
// If we found a non-case statement, start by parsing it.
OwningStmtResult SubStmt(Actions);
-
+
if (Tok.isNot(tok::r_brace)) {
SubStmt = ParseStatement();
} else {
@@ -327,11 +327,11 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() {
Diag(Tok, diag::err_label_end_of_compound_statement);
SubStmt = true;
}
-
+
// Broken sub-stmt shouldn't prevent forming the case statement properly.
if (SubStmt.isInvalid())
SubStmt = Actions.ActOnNullStmt(SourceLocation());
-
+
// Install the body into the most deeply-nested case.
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, move(SubStmt));
@@ -415,10 +415,10 @@ Parser::OwningStmtResult Parser::ParseCompoundStatement(bool isStmtExpr) {
/// consume the '}' at the end of the block. It does not manipulate the scope
/// stack.
Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
- PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),
+ PrettyStackTraceLoc CrashInfo(PP.getSourceManager(),
Tok.getLocation(),
"in compound statement ('{}')");
-
+
SourceLocation LBraceLoc = ConsumeBrace(); // eat the '{'.
// TODO: "__label__ X, Y, Z;" is the GNU "Local Label" extension. These are
@@ -496,12 +496,12 @@ bool Parser::ParseParenExprOrCondition(OwningExprResult &CondExp,
SourceLocation *RParenLocPtr) {
SourceLocation LParenLoc = ConsumeParen();
if (LParenLocPtr) *LParenLocPtr = LParenLoc;
-
+
if (getLang().CPlusPlus)
CondExp = ParseCXXCondition();
else
CondExp = ParseExpression();
-
+
// If the parser was confused by the condition and we don't have a ')', try to
// recover by skipping ahead to a semi and bailing out. If condexp is
// semantically invalid but we have well formed code, keep going.
@@ -512,7 +512,7 @@ bool Parser::ParseParenExprOrCondition(OwningExprResult &CondExp,
if (Tok.isNot(tok::r_paren))
return true;
}
-
+
// Otherwise the condition is valid or the rparen is present.
SourceLocation RPLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
if (RParenLocPtr) *RParenLocPtr = RPLoc;
@@ -559,7 +559,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement() {
return StmtError();
FullExprArg FullCondExp(Actions.FullExpr(CondExp));
-
+
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
@@ -578,7 +578,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement() {
// would have to notify ParseStatement not to create a new scope. It's
// simpler to let it create a new scope.
//
- ParseScope InnerScope(this, Scope::DeclScope,
+ ParseScope InnerScope(this, Scope::DeclScope,
C99orCXX && Tok.isNot(tok::l_brace));
// Read the 'then' stmt.
@@ -619,14 +619,14 @@ Parser::OwningStmtResult Parser::ParseIfStatement() {
}
IfScope.Exit();
-
+
// If the condition was invalid, discard the if statement. We could recover
// better by replacing it with a valid expr, but don't do that yet.
if (CondExp.isInvalid())
return StmtError();
// If the then or else stmt is invalid and the other is valid (and present),
- // make turn the invalid one into a null stmt to avoid dropping the other
+ // make turn the invalid one into a null stmt to avoid dropping the other
// part. If both are invalid, return error.
if ((ThenStmt.isInvalid() && ElseStmt.isInvalid()) ||
(ThenStmt.isInvalid() && ElseStmt.get() == 0) ||
@@ -641,7 +641,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement() {
if (ElseStmt.isInvalid())
ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
- return Actions.ActOnIfStmt(IfLoc, FullCondExp, move(ThenStmt),
+ return Actions.ActOnIfStmt(IfLoc, FullCondExp, move(ThenStmt),
ElseLoc, move(ElseStmt));
}
@@ -698,7 +698,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement() {
// See comments in ParseIfStatement for why we create a scope for the
// condition and a new scope for substatement in C++.
//
- ParseScope InnerScope(this, Scope::DeclScope,
+ ParseScope InnerScope(this, Scope::DeclScope,
C99orCXX && Tok.isNot(tok::l_brace));
// Read the body statement.
@@ -763,7 +763,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement() {
return StmtError();
FullExprArg FullCond(Actions.FullExpr(Cond));
-
+
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
// if the body isn't a compound statement to avoid push/pop in common cases.
@@ -775,7 +775,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement() {
// See comments in ParseIfStatement for why we create a scope for the
// condition and a new scope for substatement in C++.
//
- ParseScope InnerScope(this, Scope::DeclScope,
+ ParseScope InnerScope(this, Scope::DeclScope,
C99orCXX && Tok.isNot(tok::l_brace));
// Read the body statement.
@@ -818,7 +818,7 @@ Parser::OwningStmtResult Parser::ParseDoStatement() {
// which is entered and exited each time through the loop.
//
ParseScope InnerScope(this, Scope::DeclScope,
- (getLang().C99 || getLang().CPlusPlus) &&
+ (getLang().C99 || getLang().CPlusPlus) &&
Tok.isNot(tok::l_brace));
// Read the body statement.
@@ -847,7 +847,7 @@ Parser::OwningStmtResult Parser::ParseDoStatement() {
OwningExprResult Cond(Actions);
SourceLocation LPLoc, RPLoc;
ParseParenExprOrCondition(Cond, true, &LPLoc, &RPLoc);
-
+
DoScope.Exit();
if (Cond.isInvalid() || Body.isInvalid())
@@ -926,11 +926,11 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
DeclGroupPtrTy DG = ParseSimpleDeclaration(Declarator::ForContext, DeclEnd,
false);
FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
-
+
if (Tok.is(tok::semi)) { // for (int x = 4;
ConsumeToken();
} else if ((ForEach = isTokIdentifier_in())) {
- // ObjC: for (id x in expr)
+ // ObjC: for (id x in expr)
ConsumeToken(); // consume 'in'
SecondPart = ParseExpression();
} else {
@@ -988,7 +988,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
// See comments in ParseIfStatement for why we create a scope for
// for-init-statement/condition and a new scope for substatement in C++.
//
- ParseScope InnerScope(this, Scope::DeclScope,
+ ParseScope InnerScope(this, Scope::DeclScope,
C99orCXXorObjC && Tok.isNot(tok::l_brace));
// Read the body statement.
@@ -1007,7 +1007,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() {
return Actions.ActOnForStmt(ForLoc, LParenLoc, move(FirstPart),
move(SecondPart), move(ThirdPart),
RParenLoc, move(Body));
-
+
return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
move(FirstPart),
move(SecondPart),
@@ -1096,7 +1096,7 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
do {
ConsumeAnyToken();
} while (BraceCount > savedBraceCount && Tok.isNot(tok::eof));
- } else {
+ } else {
// From the MS website: If used without braces, the __asm keyword means
// that the rest of the line is an assembly-language statement.
SourceManager &SrcMgr = PP.getSourceManager();
@@ -1105,8 +1105,8 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
do {
ConsumeAnyToken();
TokLoc = Tok.getLocation();
- } while ((SrcMgr.getInstantiationLineNumber(TokLoc) == LineNo) &&
- Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
+ } while ((SrcMgr.getInstantiationLineNumber(TokLoc) == LineNo) &&
+ Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
Tok.isNot(tok::eof));
}
return Actions.ActOnNullStmt(Tok.getLocation());
@@ -1196,7 +1196,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
return StmtError();
assert(Names.size() == Constraints.size() &&
- Constraints.size() == Exprs.size()
+ Constraints.size() == Exprs.size()
&& "Input operand size mismatch!");
NumInputs = Names.size() - NumOutputs;
@@ -1247,22 +1247,22 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
// Only do anything if this operand is present.
if (Tok.isNot(tok::colon)) return false;
ConsumeToken();
-
+
// 'asm-operands' isn't present?
if (!isTokenStringLiteral() && Tok.isNot(tok::l_square))
return false;
-
- while (1) {
+
+ while (1) {
// Read the [id] if present.
if (Tok.is(tok::l_square)) {
SourceLocation Loc = ConsumeBracket();
-
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return true;
}
-
+
IdentifierInfo *II = Tok.getIdentifierInfo();
ConsumeToken();
@@ -1308,7 +1308,7 @@ Parser::DeclPtrTy Parser::ParseFunctionStatementBody(DeclPtrTy Decl) {
PrettyStackTraceActionsDecl CrashInfo(Decl, LBraceLoc, Actions,
PP.getSourceManager(),
"parsing function body");
-
+
// Do not enter a scope for the brace, as the arguments are in the same scope
// (the function body) as the body itself. Instead, just read the statement
// list and put it into a CompoundStmt for safe keeping.
@@ -1316,7 +1316,7 @@ Parser::DeclPtrTy Parser::ParseFunctionStatementBody(DeclPtrTy Decl) {
// If the function body could not be parsed, make a bogus compoundstmt.
if (FnBody.isInvalid())
- FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
+ FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
MultiStmtArg(Actions), false);
return Actions.ActOnFinishFunctionBody(Decl, move(FnBody));
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 40de81a883..8e63fb89db 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -25,7 +25,7 @@ Parser::ParseDeclarationStartingWithTemplate(unsigned Context,
SourceLocation &DeclEnd,
AccessSpecifier AS) {
if (Tok.is(tok::kw_template) && NextToken().isNot(tok::less))
- return ParseExplicitInstantiation(SourceLocation(), ConsumeToken(),
+ return ParseExplicitInstantiation(SourceLocation(), ConsumeToken(),
DeclEnd);
return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AS);
@@ -38,18 +38,18 @@ namespace {
unsigned AddedLevels;
public:
- explicit TemplateParameterDepthCounter(unsigned &Depth)
+ explicit TemplateParameterDepthCounter(unsigned &Depth)
: Depth(Depth), AddedLevels(0) { }
-
+
~TemplateParameterDepthCounter() {
Depth -= AddedLevels;
}
-
- void operator++() {
+
+ void operator++() {
++Depth;
++AddedLevels;
}
-
+
operator unsigned() const { return Depth; }
};
}
@@ -73,9 +73,9 @@ Parser::DeclPtrTy
Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
SourceLocation &DeclEnd,
AccessSpecifier AS) {
- assert((Tok.is(tok::kw_export) || Tok.is(tok::kw_template)) &&
- "Token does not start a template declaration.");
-
+ assert((Tok.is(tok::kw_export) || Tok.is(tok::kw_template)) &&
+ "Token does not start a template declaration.");
+
// Enter template-parameter scope.
ParseScope TemplateParmScope(this, Scope::TemplateParamScope);
@@ -118,33 +118,33 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
Diag(Tok.getLocation(), diag::err_expected_template);
return DeclPtrTy();
}
-
+
// Parse the '<' template-parameter-list '>'
SourceLocation LAngleLoc, RAngleLoc;
TemplateParameterList TemplateParams;
- if (ParseTemplateParameters(Depth, TemplateParams, LAngleLoc,
+ if (ParseTemplateParameters(Depth, TemplateParams, LAngleLoc,
RAngleLoc)) {
// Skip until the semi-colon or a }.
SkipUntil(tok::r_brace, true, true);
if (Tok.is(tok::semi))
ConsumeToken();
- return DeclPtrTy();
+ return DeclPtrTy();
}
ParamLists.push_back(
- Actions.ActOnTemplateParameterList(Depth, ExportLoc,
- TemplateLoc, LAngleLoc,
+ Actions.ActOnTemplateParameterList(Depth, ExportLoc,
+ TemplateLoc, LAngleLoc,
TemplateParams.data(),
TemplateParams.size(), RAngleLoc));
if (!TemplateParams.empty()) {
isSpecialization = false;
++Depth;
- }
+ }
} while (Tok.is(tok::kw_export) || Tok.is(tok::kw_template));
// Parse the actual template declaration.
- return ParseSingleDeclarationAfterTemplate(Context,
+ return ParseSingleDeclarationAfterTemplate(Context,
ParsedTemplateInfo(&ParamLists,
isSpecialization),
DeclEnd, AS);
@@ -170,7 +170,7 @@ Parser::ParseTemplateDeclarationOrSpecialization(unsigned Context,
/// declaration. Will be AS_none for namespace-scope declarations.
///
/// \returns the new declaration.
-Parser::DeclPtrTy
+Parser::DeclPtrTy
Parser::ParseSingleDeclarationAfterTemplate(
unsigned Context,
const ParsedTemplateInfo &TemplateInfo,
@@ -184,7 +184,7 @@ Parser::ParseSingleDeclarationAfterTemplate(
ParseCXXClassMemberDeclaration(AS, TemplateInfo);
return DeclPtrTy::make((void*)0);
}
-
+
// Parse the declaration specifiers.
DeclSpec DS;
ParseDeclarationSpecifiers(DS, TemplateInfo, AS);
@@ -205,7 +205,7 @@ Parser::ParseSingleDeclarationAfterTemplate(
ConsumeToken();
return DeclPtrTy();
}
-
+
// If we have a declaration or declarator list, handle it.
if (isDeclarationAfterDeclarator()) {
// Parse this declaration.
@@ -256,7 +256,7 @@ Parser::ParseSingleDeclarationAfterTemplate(
/// is the number of template headers directly enclosing this template header.
/// TemplateParams is the current list of template parameters we're building.
/// The template parameter we parse will be added to this list. LAngleLoc and
-/// RAngleLoc will receive the positions of the '<' and '>', respectively,
+/// RAngleLoc will receive the positions of the '<' and '>', respectively,
/// that enclose this template parameter list.
///
/// \returns true if an error occurred, false otherwise.
@@ -265,17 +265,17 @@ bool Parser::ParseTemplateParameters(unsigned Depth,
SourceLocation &LAngleLoc,
SourceLocation &RAngleLoc) {
// Get the template parameter list.
- if(!Tok.is(tok::less)) {
+ if (!Tok.is(tok::less)) {
Diag(Tok.getLocation(), diag::err_expected_less_after) << "template";
return true;
}
LAngleLoc = ConsumeToken();
-
+
// Try to parse the template parameter list.
if (Tok.is(tok::greater))
RAngleLoc = ConsumeToken();
- else if(ParseTemplateParameterList(Depth, TemplateParams)) {
- if(!Tok.is(tok::greater)) {
+ else if (ParseTemplateParameterList(Depth, TemplateParams)) {
+ if (!Tok.is(tok::greater)) {
Diag(Tok.getLocation(), diag::err_expected_greater);
return true;
}
@@ -287,15 +287,15 @@ bool Parser::ParseTemplateParameters(unsigned Depth,
/// ParseTemplateParameterList - Parse a template parameter list. If
/// the parsing fails badly (i.e., closing bracket was left out), this
/// will try to put the token stream in a reasonable position (closing
-/// a statement, etc.) and return false.
+/// a statement, etc.) and return false.
///
/// template-parameter-list: [C++ temp]
/// template-parameter
/// template-parameter-list ',' template-parameter
-bool
+bool
Parser::ParseTemplateParameterList(unsigned Depth,
TemplateParameterList &TemplateParams) {
- while(1) {
+ while (1) {
if (DeclPtrTy TmpParam
= ParseTemplateParameter(Depth, TemplateParams.size())) {
TemplateParams.push_back(TmpParam);
@@ -304,11 +304,11 @@ Parser::ParseTemplateParameterList(unsigned Depth,
// a comma or closing brace.
SkipUntil(tok::comma, tok::greater, true, true);
}
-
+
// Did we find a comma or the end of the template parmeter list?
- if(Tok.is(tok::comma)) {
+ if (Tok.is(tok::comma)) {
ConsumeToken();
- } else if(Tok.is(tok::greater)) {
+ } else if (Tok.is(tok::greater)) {
// Don't consume this... that's done by template parser.
break;
} else {
@@ -338,16 +338,16 @@ Parser::ParseTemplateParameterList(unsigned Depth,
/// 'typename' identifier[opt] '=' type-id
/// 'template' ...[opt][C++0x] '<' template-parameter-list '>' 'class' identifier[opt]
/// 'template' '<' template-parameter-list '>' 'class' identifier[opt] = id-expression
-Parser::DeclPtrTy
+Parser::DeclPtrTy
Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
- if(Tok.is(tok::kw_class) ||
- (Tok.is(tok::kw_typename) &&
- // FIXME: Next token has not been annotated!
- NextToken().isNot(tok::annot_typename))) {
+ if (Tok.is(tok::kw_class) ||
+ (Tok.is(tok::kw_typename) &&
+ // FIXME: Next token has not been annotated!
+ NextToken().isNot(tok::annot_typename))) {
return ParseTypeParameter(Depth, Position);
}
-
- if(Tok.is(tok::kw_template))
+
+ if (Tok.is(tok::kw_template))
return ParseTemplateTemplateParameter(Depth, Position);
// If it's none of the above, then it must be a parameter declaration.
@@ -367,7 +367,7 @@ Parser::ParseTemplateParameter(unsigned Depth, unsigned Position) {
/// 'typename' identifier[opt] '=' type-id
Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){
assert((Tok.is(tok::kw_class) || Tok.is(tok::kw_typename)) &&
- "A type-parameter starts with 'class' or 'typename'");
+ "A type-parameter starts with 'class' or 'typename'");
// Consume the 'class' or 'typename' keyword.
bool TypenameKeyword = Tok.is(tok::kw_typename);
@@ -379,33 +379,33 @@ Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){
if (Tok.is(tok::ellipsis)) {
Ellipsis = true;
EllipsisLoc = ConsumeToken();
-
- if (!getLang().CPlusPlus0x)
+
+ if (!getLang().CPlusPlus0x)
Diag(EllipsisLoc, diag::err_variadic_templates);
}
-
+
// Grab the template parameter name (if given)
SourceLocation NameLoc;
IdentifierInfo* ParamName = 0;
- if(Tok.is(tok::identifier)) {
+ if (Tok.is(tok::identifier)) {
ParamName = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
- } else if(Tok.is(tok::equal) || Tok.is(tok::comma) ||
- Tok.is(tok::greater)) {
+ } else if (Tok.is(tok::equal) || Tok.is(tok::comma) ||
+ Tok.is(tok::greater)) {
// Unnamed template parameter. Don't have to do anything here, just
// don't consume this token.
} else {
Diag(Tok.getLocation(), diag::err_expected_ident);
return DeclPtrTy();
}
-
+
DeclPtrTy TypeParam = Actions.ActOnTypeParameter(CurScope, TypenameKeyword,
Ellipsis, EllipsisLoc,
KeyLoc, ParamName, NameLoc,
Depth, Position);
// Grab a default type id (if given).
- if(Tok.is(tok::equal)) {
+ if (Tok.is(tok::equal)) {
SourceLocation EqualLoc = ConsumeToken();
SourceLocation DefaultLoc = Tok.getLocation();
TypeResult DefaultType = ParseTypeName();
@@ -413,12 +413,12 @@ Parser::DeclPtrTy Parser::ParseTypeParameter(unsigned Depth, unsigned Position){
Actions.ActOnTypeParameterDefault(TypeParam, EqualLoc, DefaultLoc,
DefaultType.get());
}
-
+
return TypeParam;
}
/// ParseTemplateTemplateParameter - Handle the parsing of template
-/// template parameters.
+/// template parameters.
///
/// type-parameter: [C++ temp.param]
/// 'template' '<' template-parameter-list '>' 'class' identifier[opt]
@@ -429,11 +429,11 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
// Handle the template <...> part.
SourceLocation TemplateLoc = ConsumeToken();
- TemplateParameterList TemplateParams;
+ TemplateParameterList TemplateParams;
SourceLocation LAngleLoc, RAngleLoc;
{
ParseScope TemplateParmScope(this, Scope::TemplateParamScope);
- if(ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
+ if (ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
RAngleLoc)) {
return DeclPtrTy();
}
@@ -441,8 +441,8 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
// Generate a meaningful error if the user forgot to put class before the
// identifier, comma, or greater.
- if(!Tok.is(tok::kw_class)) {
- Diag(Tok.getLocation(), diag::err_expected_class_before)
+ if (!Tok.is(tok::kw_class)) {
+ Diag(Tok.getLocation(), diag::err_expected_class_before)
<< PP.getSpelling(Tok);
return DeclPtrTy();
}
@@ -451,10 +451,10 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
// Get the identifier, if given.
SourceLocation NameLoc;
IdentifierInfo* ParamName = 0;
- if(Tok.is(tok::identifier)) {
+ if (Tok.is(tok::identifier)) {
ParamName = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
- } else if(Tok.is(tok::equal) || Tok.is(tok::comma) || Tok.is(tok::greater)) {
+ } else if (Tok.is(tok::equal) || Tok.is(tok::comma) || Tok.is(tok::greater)) {
// Unnamed template parameter. Don't have to do anything here, just
// don't consume this token.
} else {
@@ -462,10 +462,10 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
return DeclPtrTy();
}
- TemplateParamsTy *ParamList =
+ TemplateParamsTy *ParamList =
Actions.ActOnTemplateParameterList(Depth, SourceLocation(),
TemplateLoc, LAngleLoc,
- &TemplateParams[0],
+ &TemplateParams[0],
TemplateParams.size(),
RAngleLoc);
@@ -489,7 +489,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
}
/// ParseNonTypeTemplateParameter - Handle the parsing of non-type
-/// template parameters (e.g., in "template<int Size> class array;").
+/// template parameters (e.g., in "template<int Size> class array;").
///
/// template-parameter:
/// ...
@@ -501,7 +501,7 @@ Parser::ParseTemplateTemplateParameter(unsigned Depth, unsigned Position) {
/// parameters.
/// FIXME: We need to make a ParseParameterDeclaration that works for
/// non-type template parameters and normal function parameters.
-Parser::DeclPtrTy
+Parser::DeclPtrTy
Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
SourceLocation StartLoc = Tok.getLocation();
@@ -524,7 +524,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
return DeclPtrTy();
}
- // Create the parameter.
+ // Create the parameter.
DeclPtrTy Param = Actions.ActOnNonTypeTemplateParameter(CurScope, ParamDecl,
Depth, Position);
@@ -537,16 +537,16 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
// template-parameter, the first non-nested > is taken as the
// end of the template-parameter-list rather than a greater-than
// operator.
- GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
+ GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
OwningExprResult DefaultArg = ParseAssignmentExpression();
if (DefaultArg.isInvalid())
SkipUntil(tok::comma, tok::greater, true, true);
else if (Param)
- Actions.ActOnNonTypeTemplateParameterDefault(Param, EqualLoc,
+ Actions.ActOnNonTypeTemplateParameterDefault(Param, EqualLoc,
move(DefaultArg));
}
-
+
return Param;
}
@@ -568,9 +568,9 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
/// token that forms the template-id. Otherwise, we will leave the
/// last token in the stream (e.g., so that it can be replaced with an
/// annotation token).
-bool
+bool
Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
- SourceLocation TemplateNameLoc,
+ SourceLocation TemplateNameLoc,
const CXXScopeSpec *SS,
bool ConsumeLastToken,
SourceLocation &LAngleLoc,
@@ -628,7 +628,7 @@ Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
return false;
}
-
+
/// \brief Replace the tokens that form a simple-template-id with an
/// annotation token containing the complete template-id.
///
@@ -667,7 +667,7 @@ Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
/// formed, this function returns true.
///
bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
- const CXXScopeSpec *SS,
+ const CXXScopeSpec *SS,
SourceLocation TemplateKWLoc,
bool AllowTypeAnnotation) {
assert(getLang().CPlusPlus && "Can only annotate template-ids in C++");
@@ -684,12 +684,12 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
TemplateArgIsTypeList TemplateArgIsType;
TemplateArgLocationList TemplateArgLocations;
bool Invalid = ParseTemplateIdAfterTemplateName(Template, TemplateNameLoc,
- SS, false, LAngleLoc,
- TemplateArgs,
+ SS, false, LAngleLoc,
+ TemplateArgs,
TemplateArgIsType,
TemplateArgLocations,
RAngleLoc);
-
+
if (Invalid) {
// If we failed to parse the template ID but skipped ahead to a >, we're not
// going to be able to form a token annotation. Eat the '>' if present.
@@ -704,7 +704,7 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
// Build the annotation token.
if (TNK == TNK_Type_template && AllowTypeAnnotation) {
- Action::TypeResult Type
+ Action::TypeResult Type
= Actions.ActOnTemplateIdType(Template, TemplateNameLoc,
LAngleLoc, TemplateArgsPtr,
&TemplateArgLocations[0],
@@ -723,13 +723,13 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
Tok.setLocation(SS->getBeginLoc());
else if (TemplateKWLoc.isValid())
Tok.setLocation(TemplateKWLoc);
- else
+ else
Tok.setLocation(TemplateNameLoc);
} else {
// Build a template-id annotation token that can be processed
// later.
Tok.setKind(tok::annot_template_id);
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= TemplateIdAnnotation::Allocate(TemplateArgs.size());
TemplateId->TemplateNameLoc = TemplateNameLoc;
TemplateId->Name = Name;
@@ -772,21 +772,21 @@ bool Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
void Parser::AnnotateTemplateIdTokenAsType(const CXXScopeSpec *SS) {
assert(Tok.is(tok::annot_template_id) && "Requires template-id tokens");
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
assert((TemplateId->Kind == TNK_Type_template ||
TemplateId->Kind == TNK_Dependent_template_name) &&
"Only works for type and dependent templates");
-
- ASTTemplateArgsPtr TemplateArgsPtr(Actions,
+
+ ASTTemplateArgsPtr TemplateArgsPtr(Actions,
TemplateId->getTemplateArgs(),
TemplateId->getTemplateArgIsType(),
TemplateId->NumArgs);
- Action::TypeResult Type
+ Action::TypeResult Type
= Actions.ActOnTemplateIdType(TemplateTy::make(TemplateId->Template),
TemplateId->TemplateNameLoc,
- TemplateId->LAngleLoc,
+ TemplateId->LAngleLoc,
TemplateArgsPtr,
TemplateId->getTemplateArgLocations(),
TemplateId->RAngleLoc);
@@ -839,7 +839,7 @@ void *Parser::ParseTemplateArgument(bool &ArgIsType) {
/// template-argument-list: [C++ 14.2]
/// template-argument
/// template-argument-list ',' template-argument
-bool
+bool
Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
TemplateArgIsTypeList &TemplateArgIsType,
TemplateArgLocationList &TemplateArgLocations) {
@@ -867,18 +867,18 @@ Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
return Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater);
}
-/// \brief Parse a C++ explicit template instantiation
+/// \brief Parse a C++ explicit template instantiation
/// (C++ [temp.explicit]).
///
/// explicit-instantiation:
/// 'extern' [opt] 'template' declaration
///
/// Note that the 'extern' is a GNU extension and C++0x feature.
-Parser::DeclPtrTy
+Parser::DeclPtrTy
Parser::ParseExplicitInstantiation(SourceLocation ExternLoc,
SourceLocation TemplateLoc,
SourceLocation &DeclEnd) {
- return ParseSingleDeclarationAfterTemplate(Declarator::FileContext,
+ return ParseSingleDeclarationAfterTemplate(Declarator::FileContext,
ParsedTemplateInfo(ExternLoc,
TemplateLoc),
DeclEnd, AS_none);
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp
index 89c3db7415..eb6e935405 100644
--- a/lib/Parse/ParseTentative.cpp
+++ b/lib/Parse/ParseTentative.cpp
@@ -270,7 +270,7 @@ bool Parser::isCXXConditionDeclaration() {
return TPR == TPResult::True();
}
- /// \brief Determine whether the next set of tokens contains a type-id.
+ /// \brief Determine whether the next set of tokens contains a type-id.
///
/// The context parameter states what context we're parsing right
/// now, which affects how this routine copes with the token
@@ -288,7 +288,7 @@ bool Parser::isCXXConditionDeclaration() {
/// type-specifier-seq abstract-declarator[opt]
///
bool Parser::isCXXTypeId(TentativeCXXTypeIdContext Context, bool &isAmbiguous) {
-
+
isAmbiguous = false;
// C++ 8.2p2:
@@ -601,14 +601,14 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
if (NextToken().is(tok::kw_new) || // ::new
NextToken().is(tok::kw_delete)) // ::delete
return TPResult::False();
-
+
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return isCXXDeclarationSpecifier();
// Otherwise, not a typename.
return TPResult::False();
-
+
// decl-specifier:
// storage-class-specifier
// type-specifier
@@ -654,7 +654,7 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
case tok::kw__Complex:
case tok::kw___attribute:
return TPResult::True();
-
+
// Microsoft
case tok::kw___declspec:
case tok::kw___cdecl:
@@ -758,7 +758,7 @@ Parser::TPResult Parser::TryParseDeclarationSpecifier() {
TryParseTypeofSpecifier();
else
ConsumeToken();
-
+
assert(Tok.is(tok::l_paren) && "Expected '('!");
return TPResult::Ambiguous();
}
@@ -880,7 +880,7 @@ Parser::TPResult Parser::TryParseParameterDeclarationClause() {
/// If TryParseFunctionDeclarator fully parsed the function declarator, it will
/// return TPResult::Ambiguous(), otherwise it will return either False() or
/// Error().
-///
+///
/// '(' parameter-declaration-clause ')' cv-qualifier-seq[opt]
/// exception-specification[opt]
///
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 8572d32686..177290b438 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -24,17 +24,17 @@ using namespace clang;
/// to the parser action.
class ActionCommentHandler : public CommentHandler {
Action &Actions;
-
+
public:
explicit ActionCommentHandler(Action &Actions) : Actions(Actions) { }
-
+
virtual void HandleComment(Preprocessor &PP, SourceRange Comment) {
Actions.ActOnComment(Comment);
}
};
Parser::Parser(Preprocessor &pp, Action &actions)
- : CrashInfo(*this), PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
+ : CrashInfo(*this), PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
GreaterThanIsOperator(true), TemplateParameterDepth(0) {
Tok.setKind(tok::eof);
CurScope = 0;
@@ -47,7 +47,7 @@ Parser::Parser(Preprocessor &pp, Action &actions)
PackHandler.reset(new
PragmaPackHandler(&PP.getIdentifierTable().get("pack"), actions));
PP.AddPragmaHandler(0, PackHandler.get());
-
+
UnusedHandler.reset(new
PragmaUnusedHandler(&PP.getIdentifierTable().get("unused"), actions,
*this));
@@ -56,9 +56,9 @@ Parser::Parser(Preprocessor &pp, Action &actions)
WeakHandler.reset(new
PragmaWeakHandler(&PP.getIdentifierTable().get("weak"), actions));
PP.AddPragmaHandler(0, WeakHandler.get());
-
+
CommentHandler.reset(new ActionCommentHandler(actions));
- PP.AddCommentHandler(CommentHandler.get());
+ PP.AddCommentHandler(CommentHandler.get());
}
/// If a crash happens while the parser is active, print out a line indicating
@@ -69,12 +69,12 @@ void PrettyStackTraceParserEntry::print(llvm::raw_ostream &OS) const {
OS << "<eof> parser at end of file\n";
return;
}
-
+
if (Tok.getLocation().isInvalid()) {
OS << "<unknown> parser at unknown location\n";
return;
}
-
+
const Preprocessor &PP = P.getPreprocessor();
Tok.getLocation().print(OS, PP.getSourceManager());
OS << ": current parser token '" << PP.getSpelling(Tok) << "'\n";
@@ -104,8 +104,8 @@ void Parser::SuggestParentheses(SourceLocation Loc, unsigned DK,
Diag(Loc, DK);
return;
}
-
- Diag(Loc, DK)
+
+ Diag(Loc, DK)
<< CodeModificationHint::CreateInsertion(ParenRange.getBegin(), "(")
<< CodeModificationHint::CreateInsertion(EndLoc, ")");
}
@@ -152,10 +152,10 @@ bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
const char *Spelling = 0;
SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
- if (EndLoc.isValid() &&
+ if (EndLoc.isValid() &&
(Spelling = tok::getTokenSimpleSpelling(ExpectedTok))) {
// Show what code to insert to fix this problem.
- Diag(EndLoc, DiagID)
+ Diag(EndLoc, DiagID)
<< Msg
<< CodeModificationHint::CreateInsertion(EndLoc, Spelling);
} else
@@ -365,7 +365,7 @@ void Parser::ParseTranslationUnit() {
DeclGroupPtrTy Res;
while (!ParseTopLevelDecl(Res))
/*parse them all*/;
-
+
ExitScope();
assert(CurScope == 0 && "Scope imbalance!");
}
@@ -399,7 +399,7 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration() {
if (!getLang().CPlusPlus0x)
Diag(Tok, diag::ext_top_level_semi)
<< CodeModificationHint::CreateRemoval(SourceRange(Tok.getLocation()));
-
+
ConsumeToken();
// TODO: Invoke action for top-level semicolon.
return DeclGroupPtrTy();
@@ -462,16 +462,16 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration() {
return Actions.ConvertDeclToDeclGroup(
ParseExplicitInstantiation(ExternLoc, TemplateLoc, DeclEnd));
}
-
+
// FIXME: Detect C++ linkage specifications here?
-
+
// Fall through to handle other declarations or function definitions.
-
+
default:
// We can't tell whether this is a function-definition or declaration yet.
return ParseDeclarationOrFunctionDefinition();
}
-
+
// This routine returns a DeclGroup, if the thing we parsed only contains a
// single decl, convert it now.
return Actions.ConvertDeclToDeclGroup(SingleDecl);
@@ -493,7 +493,7 @@ bool Parser::isDeclarationAfterDeclarator() {
/// declarator, indicates the start of a function definition.
bool Parser::isStartOfFunctionDefinition() {
return Tok.is(tok::l_brace) || // int X() {}
- (!getLang().CPlusPlus &&
+ (!getLang().CPlusPlus &&
isDeclarationSpecifier()) || // int X(f) int f; {}
(getLang().CPlusPlus &&
(Tok.is(tok::colon) || // X() : Base() {} (used for ctors)
@@ -504,7 +504,7 @@ bool Parser::isStartOfFunctionDefinition() {
/// a declaration. We can't tell which we have until we read up to the
/// compound-statement in function-definition. TemplateParams, if
/// non-NULL, provides the template parameters when we're parsing a
-/// C++ template-declaration.
+/// C++ template-declaration.
///
/// function-definition: [C99 6.9.1]
/// decl-specs declarator declaration-list[opt] compound-statement
@@ -535,7 +535,7 @@ Parser::ParseDeclarationOrFunctionDefinition(AccessSpecifier AS) {
// attributes here, no types, etc.
if (getLang().ObjC2 && Tok.is(tok::at)) {
SourceLocation AtLoc = ConsumeToken(); // the "@"
- if (!Tok.isObjCAtKeyword(tok::objc_interface) &&
+ if (!Tok.isObjCAtKeyword(tok::objc_interface) &&
!Tok.isObjCAtKeyword(tok::objc_protocol)) {
Diag(Tok, diag::err_objc_unexpected_attr);
SkipUntil(tok::semi); // FIXME: better skip?
@@ -545,7 +545,7 @@ Parser::ParseDeclarationOrFunctionDefinition(AccessSpecifier AS) {
unsigned DiagID;
if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec, DiagID))
Diag(AtLoc, DiagID) << PrevSpec;
-
+
DeclPtrTy TheDecl;
if (Tok.isObjCAtKeyword(tok::objc_protocol))
TheDecl = ParseObjCAtProtocolDeclaration(AtLoc, DS.getAttributes());
@@ -585,7 +585,7 @@ Parser::ParseDeclarationOrFunctionDefinition(AccessSpecifier AS) {
ExpectAndConsume(tok::semi, diag::err_expected_semi_declaration);
return DG;
}
-
+
if (DeclaratorInfo.isFunctionDeclarator() &&
isStartOfFunctionDefinition()) {
if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
@@ -605,7 +605,7 @@ Parser::ParseDeclarationOrFunctionDefinition(AccessSpecifier AS) {
DeclPtrTy TheDecl = ParseFunctionDefinition(DeclaratorInfo);
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
-
+
if (DeclaratorInfo.isFunctionDeclarator())
Diag(Tok, diag::err_expected_fn_body);
else
@@ -672,7 +672,7 @@ Parser::DeclPtrTy Parser::ParseFunctionDefinition(Declarator &D,
// Tell the actions module that we have entered a function definition with the
// specified Declarator for the function.
- DeclPtrTy Res = TemplateInfo.TemplateParams?
+ DeclPtrTy Res = TemplateInfo.TemplateParams?
Actions.ActOnStartOfFunctionTemplateDef(CurScope,
Action::MultiTemplateParamsArg(Actions,
TemplateInfo.TemplateParams->data(),
@@ -882,24 +882,24 @@ Parser::OwningExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
///
/// This returns true if the token was annotated or an unrecoverable error
/// occurs.
-///
+///
/// Note that this routine emits an error if you call it with ::new or ::delete
/// as the current tokens, so only call it in contexts where these are invalid.
bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
- assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)
+ assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)
|| Tok.is(tok::kw_typename)) &&
"Cannot be a type or scope token!");
-
+
if (Tok.is(tok::kw_typename)) {
// Parse a C++ typename-specifier, e.g., "typename T::type".
//
// typename-specifier:
// 'typename' '::' [opt] nested-name-specifier identifier
- // 'typename' '::' [opt] nested-name-specifier template [opt]
+ // 'typename' '::' [opt] nested-name-specifier template [opt]
// simple-template-id
SourceLocation TypenameLoc = ConsumeToken();
CXXScopeSpec SS;
- bool HadNestedNameSpecifier
+ bool HadNestedNameSpecifier
= ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/0, false);
if (!HadNestedNameSpecifier) {
Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename);
@@ -909,10 +909,10 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
TypeResult Ty;
if (Tok.is(tok::identifier)) {
// FIXME: check whether the next token is '<', first!
- Ty = Actions.ActOnTypenameType(TypenameLoc, SS, *Tok.getIdentifierInfo(),
+ Ty = Actions.ActOnTypenameType(TypenameLoc, SS, *Tok.getIdentifierInfo(),
Tok.getLocation());
} else if (Tok.is(tok::annot_template_id)) {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
if (TemplateId->Kind == TNK_Function_template) {
Diag(Tok, diag::err_typename_refers_to_non_type_template)
@@ -921,7 +921,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
}
AnnotateTemplateIdTokenAsType(0);
- assert(Tok.is(tok::annot_typename) &&
+ assert(Tok.is(tok::annot_typename) &&
"AnnotateTemplateIdTokenAsType isn't working properly");
if (Tok.getAnnotationValue())
Ty = Actions.ActOnTypenameType(TypenameLoc, SS, SourceLocation(),
@@ -948,7 +948,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
if (Tok.is(tok::identifier)) {
// Determine whether the identifier is a type name.
- if (TypeTy *Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
+ if (TypeTy *Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), CurScope, &SS)) {
// This is a typename. Replace the current token in-place with an
// annotation type token.
@@ -957,27 +957,27 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
Tok.setAnnotationEndLoc(Tok.getLocation());
if (SS.isNotEmpty()) // it was a C++ qualified type name.
Tok.setLocation(SS.getBeginLoc());
-
+
// In case the tokens were cached, have Preprocessor replace
// them with the annotation token.
PP.AnnotateCachedTokens(Tok);
return true;
- }
+ }
if (!getLang().CPlusPlus) {
// If we're in C, we can't have :: tokens at all (the lexer won't return
// them). If the identifier is not a type, then it can't be scope either,
- // just early exit.
+ // just early exit.
return false;
}
-
+
// If this is a template-id, annotate with a template-id or type token.
if (NextToken().is(tok::less)) {
TemplateTy Template;
- if (TemplateNameKind TNK
- = Actions.isTemplateName(CurScope, *Tok.getIdentifierInfo(),
- Tok.getLocation(), &SS,
- /*ObjectType=*/0, EnteringContext,
+ if (TemplateNameKind TNK
+ = Actions.isTemplateName(CurScope, *Tok.getIdentifierInfo(),
+ Tok.getLocation(), &SS,
+ /*ObjectType=*/0, EnteringContext,
Template))
if (AnnotateTemplateIdToken(Template, TNK, &SS)) {
// If an unrecoverable error occurred, we need to return true here,
@@ -991,10 +991,10 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
// template-id, is not part of the annotation. Fall through to
// push that token back into the stream and complete the C++ scope
// specifier annotation.
- }
+ }
if (Tok.is(tok::annot_template_id)) {
- TemplateIdAnnotation *TemplateId
+ TemplateIdAnnotation *TemplateId
= static_cast<TemplateIdAnnotation *>(Tok.getAnnotationValue());
if (TemplateId->Kind == TNK_Type_template) {
// A template-id that refers to a type was parsed into a
@@ -1008,7 +1008,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
if (SS.isEmpty())
return Tok.isNot(tok::identifier) && Tok.isNot(tok::coloncolon);
-
+
// A C++ scope specifier that isn't followed by a typename.
// Push the current token back into the token stream (or revert it if it is
// cached) and use an annotation scope token for current token.
@@ -1030,7 +1030,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
/// annotates C++ scope specifiers and template-ids. This returns
/// true if the token was annotated or there was an error that could not be
/// recovered from.
-///
+///
/// Note that this routine emits an error if you call it with ::new or ::delete
/// as the current tokens, so only call it in contexts where these are invalid.
bool Parser::TryAnnotateCXXScopeToken(bool EnteringContext) {
diff --git a/lib/Rewrite/DeltaTree.cpp b/lib/Rewrite/DeltaTree.cpp
index 5d51ddae08..a94444b50c 100644
--- a/lib/Rewrite/DeltaTree.cpp
+++ b/lib/Rewrite/DeltaTree.cpp
@@ -39,7 +39,7 @@ namespace {
/// former and adds children pointers. Each node knows the full delta of all
/// entries (recursively) contained inside of it, which allows us to get the
/// full delta implied by a whole subtree in constant time.
-
+
namespace {
/// SourceDelta - As code in the original input buffer is added and deleted,
/// SourceDelta records are used to keep track of how the input SourceLocation
@@ -47,7 +47,7 @@ namespace {
struct SourceDelta {
unsigned FileLoc;
int Delta;
-
+
static SourceDelta get(unsigned Loc, int D) {
SourceDelta Delta;
Delta.FileLoc = Loc;
@@ -71,36 +71,36 @@ namespace {
///
class DeltaTreeNode {
friend class DeltaTreeInteriorNode;
-
+
/// WidthFactor - This controls the number of K/V slots held in the BTree:
/// how wide it is. Each level of the BTree is guaranteed to have at least
/// WidthFactor-1 K/V pairs (except the root) and may have at most
/// 2*WidthFactor-1 K/V pairs.
enum { WidthFactor = 8 };
-
+
/// Values - This tracks the SourceDelta's currently in this node.
///
SourceDelta Values[2*WidthFactor-1];
-
+
/// NumValuesUsed - This tracks the number of values this node currently
/// holds.
unsigned char NumValuesUsed;
-
+
/// IsLeaf - This is true if this is a leaf of the btree. If false, this is
/// an interior node, and is actually an instance of DeltaTreeInteriorNode.
bool IsLeaf;
-
+
/// FullDelta - This is the full delta of all the values in this node and
/// all children nodes.
int FullDelta;
public:
DeltaTreeNode(bool isLeaf = true)
: NumValuesUsed(0), IsLeaf(isLeaf), FullDelta(0) {}
-
+
bool isLeaf() const { return IsLeaf; }
int getFullDelta() const { return FullDelta; }
bool isFull() const { return NumValuesUsed == 2*WidthFactor-1; }
-
+
unsigned getNumValuesUsed() const { return NumValuesUsed; }
const SourceDelta &getValue(unsigned i) const {
assert(i < NumValuesUsed && "Invalid value #");
@@ -110,7 +110,7 @@ namespace {
assert(i < NumValuesUsed && "Invalid value #");
return Values[i];
}
-
+
/// DoInsertion - Do an insertion of the specified FileIndex/Delta pair into
/// this node. If insertion is easy, do it and return false. Otherwise,
/// split the node, populate InsertRes with info about the split, and return
@@ -118,14 +118,14 @@ namespace {
bool DoInsertion(unsigned FileIndex, int Delta, InsertResult *InsertRes);
void DoSplit(InsertResult &InsertRes);
-
-
+
+
/// RecomputeFullDeltaLocally - Recompute the FullDelta field by doing a
/// local walk over our contained deltas.
void RecomputeFullDeltaLocally();
-
+
void Destroy();
-
+
static inline bool classof(const DeltaTreeNode *) { return true; }
};
} // end anonymous namespace
@@ -142,14 +142,14 @@ namespace {
friend class DeltaTreeNode;
public:
DeltaTreeInteriorNode() : DeltaTreeNode(false /*nonleaf*/) {}
-
+
DeltaTreeInteriorNode(DeltaTreeNode *FirstChild)
: DeltaTreeNode(false /*nonleaf*/) {
FullDelta = FirstChild->FullDelta;
Children[0] = FirstChild;
}
-
- DeltaTreeInteriorNode(const InsertResult &IR)
+
+ DeltaTreeInteriorNode(const InsertResult &IR)
: DeltaTreeNode(false /*nonleaf*/) {
Children[0] = IR.LHS;
Children[1] = IR.RHS;
@@ -157,7 +157,7 @@ namespace {
FullDelta = IR.LHS->getFullDelta()+IR.RHS->getFullDelta()+IR.Split.Delta;
NumValuesUsed = 1;
}
-
+
const DeltaTreeNode *getChild(unsigned i) const {
assert(i < getNumValuesUsed()+1 && "Invalid child");
return Children[i];
@@ -166,7 +166,7 @@ namespace {
assert(i < getNumValuesUsed()+1 && "Invalid child");
return Children[i];
}
-
+
static inline bool classof(const DeltaTreeInteriorNode *) { return true; }
static inline bool classof(const DeltaTreeNode *N) { return !N->isLeaf(); }
};
@@ -197,16 +197,16 @@ void DeltaTreeNode::RecomputeFullDeltaLocally() {
/// this node. If insertion is easy, do it and return false. Otherwise,
/// split the node, populate InsertRes with info about the split, and return
/// true.
-bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
+bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
InsertResult *InsertRes) {
// Maintain full delta for this node.
FullDelta += Delta;
-
+
// Find the insertion point, the first delta whose index is >= FileIndex.
unsigned i = 0, e = getNumValuesUsed();
while (i != e && FileIndex > getValue(i).FileLoc)
++i;
-
+
// If we found an a record for exactly this file index, just merge this
// value into the pre-existing record and finish early.
if (i != e && getValue(i).FileLoc == FileIndex) {
@@ -230,19 +230,19 @@ bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
++NumValuesUsed;
return false;
}
-
+
// Otherwise, if this is leaf is full, split the node at its median, insert
// the value into one of the children, and return the result.
assert(InsertRes && "No result location specified");
DoSplit(*InsertRes);
-
+
if (InsertRes->Split.FileLoc > FileIndex)
InsertRes->LHS->DoInsertion(FileIndex, Delta, 0 /*can't fail*/);
else
InsertRes->RHS->DoInsertion(FileIndex, Delta, 0 /*can't fail*/);
return true;
}
-
+
// Otherwise, this is an interior node. Send the request down the tree.
DeltaTreeInteriorNode *IN = cast<DeltaTreeInteriorNode>(this);
if (!IN->Children[i]->DoInsertion(FileIndex, Delta, InsertRes))
@@ -259,21 +259,21 @@ bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
(e-i)*sizeof(IN->Children[0]));
IN->Children[i] = InsertRes->LHS;
IN->Children[i+1] = InsertRes->RHS;
-
+
if (e != i)
memmove(&Values[i+1], &Values[i], (e-i)*sizeof(Values[0]));
Values[i] = InsertRes->Split;
++NumValuesUsed;
return false;
}
-
+
// Finally, if this interior node was full and a node is percolated up, split
// ourself and return that up the chain. Start by saving all our info to
// avoid having the split clobber it.
IN->Children[i] = InsertRes->LHS;
DeltaTreeNode *SubRHS = InsertRes->RHS;
SourceDelta SubSplit = InsertRes->Split;
-
+
// Do the split.
DoSplit(*InsertRes);
@@ -283,22 +283,22 @@ bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
InsertSide = cast<DeltaTreeInteriorNode>(InsertRes->LHS);
else
InsertSide = cast<DeltaTreeInteriorNode>(InsertRes->RHS);
-
- // We now have a non-empty interior node 'InsertSide' to insert
+
+ // We now have a non-empty interior node 'InsertSide' to insert
// SubRHS/SubSplit into. Find out where to insert SubSplit.
-
+
// Find the insertion point, the first delta whose index is >SubSplit.FileLoc.
i = 0; e = InsertSide->getNumValuesUsed();
while (i != e && SubSplit.FileLoc > InsertSide->getValue(i).FileLoc)
++i;
-
+
// Now we know that i is the place to insert the split value into. Insert it
// and the child right after it.
if (i != e)
memmove(&InsertSide->Children[i+2], &InsertSide->Children[i+1],
(e-i)*sizeof(IN->Children[0]));
InsertSide->Children[i+1] = SubRHS;
-
+
if (e != i)
memmove(&InsertSide->Values[i+1], &InsertSide->Values[i],
(e-i)*sizeof(Values[0]));
@@ -313,12 +313,12 @@ bool DeltaTreeNode::DoInsertion(unsigned FileIndex, int Delta,
/// Return the pieces in InsertRes.
void DeltaTreeNode::DoSplit(InsertResult &InsertRes) {
assert(isFull() && "Why split a non-full node?");
-
+
// Since this node is full, it contains 2*WidthFactor-1 values. We move
// the first 'WidthFactor-1' values to the LHS child (which we leave in this
// node), propagate one value up, and move the last 'WidthFactor-1' values
// into the RHS child.
-
+
// Create the new child node.
DeltaTreeNode *NewNode;
if (DeltaTreeInteriorNode *IN = dyn_cast<DeltaTreeInteriorNode>(this)) {
@@ -332,18 +332,18 @@ void DeltaTreeNode::DoSplit(InsertResult &InsertRes) {
// Just create the new leaf node.
NewNode = new DeltaTreeNode();
}
-
+
// Move over the last 'WidthFactor-1' values from here to NewNode.
memcpy(&NewNode->Values[0], &Values[WidthFactor],
(WidthFactor-1)*sizeof(Values[0]));
-
+
// Decrease the number of values in the two nodes.
NewNode->NumValuesUsed = NumValuesUsed = WidthFactor-1;
-
+
// Recompute the two nodes' full delta.
NewNode->RecomputeFullDeltaLocally();
RecomputeFullDeltaLocally();
-
+
InsertRes.LHS = this;
InsertRes.RHS = NewNode;
InsertRes.Split = Values[WidthFactor-1];
@@ -374,7 +374,7 @@ static void VerifyTree(const DeltaTreeNode *N) {
assert(FullDelta == N->getFullDelta());
return;
}
-
+
// Verify interior nodes: Ensure that FullDelta matches up and the
// elements are in proper order and the children are in proper order.
int FullDelta = 0;
@@ -385,18 +385,18 @@ static void VerifyTree(const DeltaTreeNode *N) {
assert(IN->getValue(i-1).FileLoc < IVal.FileLoc);
FullDelta += IVal.Delta;
FullDelta += IChild->getFullDelta();
-
+
// The largest value in child #i should be smaller than FileLoc.
assert(IChild->getValue(IChild->getNumValuesUsed()-1).FileLoc <
IVal.FileLoc);
-
+
// The smallest value in child #i+1 should be larger than FileLoc.
assert(IN->getChild(i+1)->getValue(0).FileLoc > IVal.FileLoc);
VerifyTree(IChild);
}
-
+
FullDelta += IN->getChild(IN->getNumValuesUsed())->getFullDelta();
-
+
assert(FullDelta == N->getFullDelta());
}
#endif // VERIFY_TREE
@@ -424,9 +424,9 @@ DeltaTree::~DeltaTree() {
/// specified file index.
int DeltaTree::getDeltaAt(unsigned FileIndex) const {
const DeltaTreeNode *Node = getRoot(Root);
-
+
int Result = 0;
-
+
// Walk down the tree.
while (1) {
// For all nodes, include any local deltas before the specified file
@@ -436,29 +436,29 @@ int DeltaTree::getDeltaAt(unsigned FileIndex) const {
for (unsigned e = Node->getNumValuesUsed(); NumValsGreater != e;
++NumValsGreater) {
const SourceDelta &Val = Node->getValue(NumValsGreater);
-
+
if (Val.FileLoc >= FileIndex)
break;
Result += Val.Delta;
}
-
+
// If we have an interior node, include information about children and
// recurse. Otherwise, if we have a leaf, we're done.
const DeltaTreeInteriorNode *IN = dyn_cast<DeltaTreeInteriorNode>(Node);
if (!IN) return Result;
-
+
// Include any children to the left of the values we skipped, all of
// their deltas should be included as well.
for (unsigned i = 0; i != NumValsGreater; ++i)
Result += IN->getChild(i)->getFullDelta();
-
+
// If we found exactly the value we were looking for, break off the
// search early. There is no need to search the RHS of the value for
// partial results.
if (NumValsGreater != Node->getNumValuesUsed() &&
Node->getValue(NumValsGreater).FileLoc == FileIndex)
return Result+IN->getChild(NumValsGreater)->getFullDelta();
-
+
// Otherwise, traverse down the tree. The selected subtree may be
// partially included in the range.
Node = IN->getChild(NumValsGreater);
@@ -472,12 +472,12 @@ int DeltaTree::getDeltaAt(unsigned FileIndex) const {
void DeltaTree::AddDelta(unsigned FileIndex, int Delta) {
assert(Delta && "Adding a noop?");
DeltaTreeNode *MyRoot = getRoot(Root);
-
+
InsertResult InsertRes;
if (MyRoot->DoInsertion(FileIndex, Delta, &InsertRes)) {
Root = MyRoot = new DeltaTreeInteriorNode(InsertRes);
}
-
+
#ifdef VERIFY_TREE
VerifyTree(MyRoot);
#endif
diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp
index 925fa55312..7326890ded 100644
--- a/lib/Rewrite/HTMLRewrite.cpp
+++ b/lib/Rewrite/HTMLRewrite.cpp
@@ -39,10 +39,10 @@ void html::HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E,
unsigned BOffset = SM.getFileOffset(B);
unsigned EOffset = SM.getFileOffset(E);
-
+
// Include the whole end token in the range.
EOffset += Lexer::MeasureTokenLength(E, R.getSourceMgr(), R.getLangOpts());
-
+
HighlightRange(R.getEditBuffer(FID), BOffset, EOffset,
SM.getBufferData(FID).first, StartTag, EndTag);
}
@@ -55,11 +55,11 @@ void html::HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
// Insert the tag at the absolute start/end of the range.
RB.InsertTextAfter(B, StartTag);
RB.InsertTextBefore(E, EndTag);
-
+
// Scan the range to see if there is a \r or \n. If so, and if the line is
// not blank, insert tags on that line as well.
bool HadOpenTag = true;
-
+
unsigned LastNonWhiteSpace = B;
for (unsigned i = B; i != E; ++i) {
switch (BufferStart[i]) {
@@ -69,7 +69,7 @@ void html::HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
// to insert a close tag at the first non-whitespace before the newline.
if (HadOpenTag)
RB.InsertTextBefore(LastNonWhiteSpace+1, EndTag);
-
+
// Instead of inserting an open tag immediately after the newline, we
// wait until we see a non-whitespace character. This prevents us from
// inserting tags around blank lines, and also allows the open tag to
@@ -83,14 +83,14 @@ void html::HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
case '\v':
// Ignore whitespace.
break;
-
+
default:
// If there is no tag open, do it now.
if (!HadOpenTag) {
RB.InsertTextAfter(i, StartTag);
HadOpenTag = true;
}
-
+
// Remember this character.
LastNonWhiteSpace = i;
break;
@@ -100,13 +100,13 @@ void html::HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E,
void html::EscapeText(Rewriter &R, FileID FID,
bool EscapeSpaces, bool ReplaceTabs) {
-
+
const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FID);
const char* C = Buf->getBufferStart();
const char* FileEnd = Buf->getBufferEnd();
-
+
assert (C <= FileEnd);
-
+
RewriteBuffer &RB = R.getEditBuffer(FID);
unsigned ColNo = 0;
@@ -117,7 +117,7 @@ void html::EscapeText(Rewriter &R, FileID FID,
case '\r':
ColNo = 0;
break;
-
+
case ' ':
if (EscapeSpaces)
RB.ReplaceText(FilePos, 1, "&nbsp;");
@@ -127,7 +127,7 @@ void html::EscapeText(Rewriter &R, FileID FID,
RB.ReplaceText(FilePos, 1, "<hr>");
ColNo = 0;
break;
-
+
case '\t': {
if (!ReplaceTabs)
break;
@@ -145,12 +145,12 @@ void html::EscapeText(Rewriter &R, FileID FID,
RB.ReplaceText(FilePos, 1, "&lt;");
++ColNo;
break;
-
+
case '>':
RB.ReplaceText(FilePos, 1, "&gt;");
++ColNo;
break;
-
+
case '&':
RB.ReplaceText(FilePos, 1, "&amp;");
++ColNo;
@@ -161,23 +161,23 @@ void html::EscapeText(Rewriter &R, FileID FID,
std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
bool ReplaceTabs) {
-
+
unsigned len = s.size();
std::string Str;
llvm::raw_string_ostream os(Str);
-
+
for (unsigned i = 0 ; i < len; ++i) {
-
+
char c = s[i];
switch (c) {
default:
os << c; break;
-
+
case ' ':
if (EscapeSpaces) os << "&nbsp;";
else os << ' ';
break;
-
+
case '\t':
if (ReplaceTabs) {
if (EscapeSpaces)
@@ -187,17 +187,17 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces,
for (unsigned i = 0; i < 4; ++i)
os << " ";
}
- else
+ else
os << c;
-
+
break;
-
+
case '<': os << "&lt;"; break;
case '>': os << "&gt;"; break;
case '&': os << "&amp;"; break;
}
}
-
+
return os.str();
}
@@ -209,7 +209,7 @@ static void AddLineNumber(RewriteBuffer &RB, unsigned LineNo,
OS << "<tr><td class=\"num\" id=\"LN"
<< LineNo << "\">"
<< LineNo << "</td><td class=\"line\">";
-
+
if (B == E) { // Handle empty lines.
OS << " </td></tr>";
RB.InsertTextBefore(B, OS.str());
@@ -226,44 +226,44 @@ void html::AddLineNumbers(Rewriter& R, FileID FID) {
const char* FileEnd = Buf->getBufferEnd();
const char* C = FileBeg;
RewriteBuffer &RB = R.getEditBuffer(FID);
-
+
assert (C <= FileEnd);
-
+
unsigned LineNo = 0;
unsigned FilePos = 0;
-
- while (C != FileEnd) {
-
+
+ while (C != FileEnd) {
+
++LineNo;
unsigned LineStartPos = FilePos;
unsigned LineEndPos = FileEnd - FileBeg;
-
+
assert (FilePos <= LineEndPos);
assert (C < FileEnd);
-
+
// Scan until the newline (or end-of-file).
-
+
while (C != FileEnd) {
char c = *C;
++C;
-
+
if (c == '\n') {
LineEndPos = FilePos++;
break;
}
-
+
++FilePos;
}
-
+
AddLineNumber(RB, LineNo, LineStartPos, LineEndPos);
}
-
+
// Add one big table tag that surrounds all of the code.
RB.InsertTextBefore(0, "<table class=\"code\">\n");
RB.InsertTextAfter(FileEnd - FileBeg, "</table>");
}
-void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
+void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
const char *title) {
const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FID);
@@ -277,10 +277,10 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
llvm::raw_string_ostream os(s);
os << "<!doctype html>\n" // Use HTML 5 doctype
"<html>\n<head>\n";
-
+
if (title)
os << "<title>" << html::EscapeText(title) << "</title>\n";
-
+
os << "<style type=\"text/css\">\n"
" body { color:#000000; background-color:#ffffff }\n"
" body { font-family:Helvetica, sans-serif; font-size:10pt }\n"
@@ -341,7 +341,7 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID,
// Generate header
R.InsertTextBefore(StartLoc, os.str());
// Generate footer
-
+
R.InsertTextAfter(EndLoc, "</body></html>\n");
}
@@ -355,16 +355,16 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
const SourceManager &SM = PP.getSourceManager();
Lexer L(FID, SM, PP.getLangOptions());
const char *BufferStart = L.getBufferStart();
-
- // Inform the preprocessor that we want to retain comments as tokens, so we
+
+ // Inform the preprocessor that we want to retain comments as tokens, so we
// can highlight them.
L.SetCommentRetentionState(true);
-
+
// Lex all the tokens in raw mode, to avoid entering #includes or expanding
// macros.
Token Tok;
L.LexFromRawLexer(Tok);
-
+
while (Tok.isNot(tok::eof)) {
// Since we are lexing unexpanded tokens, all tokens are from the main
// FileID.
@@ -376,7 +376,7 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
// Fill in Result.IdentifierInfo, looking up the identifier in the
// identifier table.
IdentifierInfo *II = PP.LookUpIdentifierInfo(Tok, BufferStart+TokOffs);
-
+
// If this is a pp-identifier, for a keyword, highlight it as such.
if (II->getTokenID() != tok::identifier)
HighlightRange(RB, TokOffs, TokOffs+TokLen, BufferStart,
@@ -400,7 +400,7 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
// If this is a preprocessor directive, all tokens to end of line are too.
if (!Tok.isAtStartOfLine())
break;
-
+
// Eat all of the tokens until we get to the next one at the start of
// line.
unsigned TokEnd = TokOffs+TokLen;
@@ -409,16 +409,16 @@ void html::SyntaxHighlight(Rewriter &R, FileID FID, Preprocessor &PP) {
TokEnd = SM.getFileOffset(Tok.getLocation())+Tok.getLength();
L.LexFromRawLexer(Tok);
}
-
+
// Find end of line. This is a hack.
HighlightRange(RB, TokOffs, TokEnd, BufferStart,
"<span class='directive'>", "</span>");
-
+
// Don't skip the next token.
continue;
}
}
-
+
L.LexFromRawLexer(Tok);
}
}
@@ -442,15 +442,15 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
// Re-lex the raw token stream into a token buffer.
const SourceManager &SM = PP.getSourceManager();
std::vector<Token> TokenStream;
-
+
Lexer L(FID, SM, PP.getLangOptions());
-
+
// Lex all the tokens in raw mode, to avoid entering #includes or expanding
// macros.
while (1) {
Token Tok;
L.LexFromRawLexer(Tok);
-
+
// If this is a # at the start of a line, discard it from the token stream.
// We don't want the re-preprocess step to see #defines, #includes or other
// preprocessor directives.
@@ -461,7 +461,7 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
// it will not produce an error.
if (Tok.is(tok::hashhash))
Tok.setKind(tok::unknown);
-
+
// If this raw token is an identifier, the raw lexer won't have looked up
// the corresponding identifier info for it. Do this now so that it will be
// macro expanded when we re-preprocess it.
@@ -469,30 +469,30 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
// Change the kind of this identifier to the appropriate token kind, e.g.
// turning "for" into a keyword.
Tok.setKind(PP.LookUpIdentifierInfo(Tok)->getTokenID());
- }
-
+ }
+
TokenStream.push_back(Tok);
-
+
if (Tok.is(tok::eof)) break;
}
-
+
// Temporarily change the diagnostics object so that we ignore any generated
// diagnostics from this pass.
IgnoringDiagClient TmpDC;
Diagnostic TmpDiags(&TmpDC);
-
+
Diagnostic *OldDiags = &PP.getDiagnostics();
PP.setDiagnostics(TmpDiags);
-
+
// Inform the preprocessor that we don't want comments.
PP.SetCommentRetentionState(false, false);
// Enter the tokens we just lexed. This will cause them to be macro expanded
// but won't enter sub-files (because we removed #'s).
PP.EnterTokenStream(&TokenStream[0], TokenStream.size(), false, false);
-
+
TokenConcatenation ConcatInfo(PP);
-
+
// Lex all the tokens.
Token Tok;
PP.Lex(Tok);
@@ -502,13 +502,13 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
PP.Lex(Tok);
continue;
}
-
+
// Okay, we have the first token of a macro expansion: highlight the
// instantiation by inserting a start tag before the macro instantiation and
// end tag after it.
std::pair<SourceLocation, SourceLocation> LLoc =
SM.getInstantiationRange(Tok.getLocation());
-
+
// Ignore tokens whose instantiation location was not the main file.
if (SM.getFileID(LLoc.first) != FID) {
PP.Lex(Tok);
@@ -520,11 +520,11 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
std::string Expansion = EscapeText(PP.getSpelling(Tok));
unsigned LineLen = Expansion.size();
-
+
Token PrevTok = Tok;
// Okay, eat this token, getting the next one.
PP.Lex(Tok);
-
+
// Skip all the rest of the tokens that are part of this macro
// instantiation. It would be really nice to pop up a window with all the
// spelling of the tokens or something.
@@ -535,23 +535,23 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
Expansion += "<br>";
LineLen = 0;
}
-
+
LineLen -= Expansion.size();
-
+
// If the tokens were already space separated, or if they must be to avoid
// them being implicitly pasted, add a space between them.
if (Tok.hasLeadingSpace() ||
ConcatInfo.AvoidConcat(PrevTok, Tok))
Expansion += ' ';
-
+
// Escape any special characters in the token text.
Expansion += EscapeText(PP.getSpelling(Tok));
LineLen += Expansion.size();
-
+
PrevTok = Tok;
PP.Lex(Tok);
}
-
+
// Insert the expansion as the end tag, so that multi-line macros all get
// highlighted.
@@ -567,7 +567,7 @@ void html::HighlightMacros(Rewriter &R, FileID FID, Preprocessor& PP) {
void html::HighlightMacros(Rewriter &R, FileID FID,
PreprocessorFactory &PPF) {
-
+
llvm::OwningPtr<Preprocessor> PP(PPF.CreatePreprocessor());
HighlightMacros(R, FID, *PP);
}
diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp
index 61cb02b9a5..30bbcfafb5 100644
--- a/lib/Rewrite/RewriteRope.cpp
+++ b/lib/Rewrite/RewriteRope.cpp
@@ -81,24 +81,24 @@ namespace {
/// the root, which may have less) and may have at most 2*WidthFactor
/// elements.
enum { WidthFactor = 8 };
-
+
/// Size - This is the number of bytes of file this node (including any
/// potential children) covers.
unsigned Size;
-
+
/// IsLeaf - True if this is an instance of RopePieceBTreeLeaf, false if it
/// is an instance of RopePieceBTreeInterior.
bool IsLeaf;
-
+
RopePieceBTreeNode(bool isLeaf) : Size(0), IsLeaf(isLeaf) {}
~RopePieceBTreeNode() {}
public:
-
+
bool isLeaf() const { return IsLeaf; }
unsigned size() const { return Size; }
-
+
void Destroy();
-
+
/// split - Split the range containing the specified offset so that we are
/// guaranteed that there is a place to do an insertion at the specified
/// offset. The offset is relative, so "0" is the start of the node.
@@ -106,7 +106,7 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *split(unsigned Offset);
-
+
/// insert - Insert the specified ropepiece into this tree node at the
/// specified offset. The offset is relative, so "0" is the start of the
/// node.
@@ -114,13 +114,13 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
-
+
/// erase - Remove NumBytes from this node at the specified offset. We are
/// guaranteed that there is a split at Offset.
void erase(unsigned Offset, unsigned NumBytes);
-
+
static inline bool classof(const RopePieceBTreeNode *) { return true; }
-
+
};
} // end anonymous namespace
@@ -140,11 +140,11 @@ namespace {
/// NumPieces - This holds the number of rope pieces currently active in the
/// Pieces array.
unsigned char NumPieces;
-
+
/// Pieces - This tracks the file chunks currently in this leaf.
///
RopePiece Pieces[2*WidthFactor];
-
+
/// NextLeaf - This is a pointer to the next leaf in the tree, allowing
/// efficient in-order forward iteration of the tree without traversal.
RopePieceBTreeLeaf **PrevLeaf, *NextLeaf;
@@ -155,34 +155,34 @@ namespace {
if (PrevLeaf || NextLeaf)
removeFromLeafInOrder();
}
-
+
bool isFull() const { return NumPieces == 2*WidthFactor; }
-
+
/// clear - Remove all rope pieces from this leaf.
void clear() {
while (NumPieces)
Pieces[--NumPieces] = RopePiece();
Size = 0;
}
-
+
unsigned getNumPieces() const { return NumPieces; }
-
+
const RopePiece &getPiece(unsigned i) const {
assert(i < getNumPieces() && "Invalid piece ID");
return Pieces[i];
}
-
+
const RopePieceBTreeLeaf *getNextLeafInOrder() const { return NextLeaf; }
void insertAfterLeafInOrder(RopePieceBTreeLeaf *Node) {
assert(PrevLeaf == 0 && NextLeaf == 0 && "Already in ordering");
-
+
NextLeaf = Node->NextLeaf;
if (NextLeaf)
NextLeaf->PrevLeaf = &NextLeaf;
PrevLeaf = &Node->NextLeaf;
Node->NextLeaf = this;
}
-
+
void removeFromLeafInOrder() {
if (PrevLeaf) {
*PrevLeaf = NextLeaf;
@@ -192,7 +192,7 @@ namespace {
NextLeaf->PrevLeaf = 0;
}
}
-
+
/// FullRecomputeSizeLocally - This method recomputes the 'Size' field by
/// summing the size of all RopePieces.
void FullRecomputeSizeLocally() {
@@ -200,7 +200,7 @@ namespace {
for (unsigned i = 0, e = getNumPieces(); i != e; ++i)
Size += getPiece(i).size();
}
-
+
/// split - Split the range containing the specified offset so that we are
/// guaranteed that there is a place to do an insertion at the specified
/// offset. The offset is relative, so "0" is the start of the node.
@@ -208,7 +208,7 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *split(unsigned Offset);
-
+
/// insert - Insert the specified ropepiece into this tree node at the
/// specified offset. The offset is relative, so "0" is the start of the
/// node.
@@ -216,12 +216,12 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
-
-
+
+
/// erase - Remove NumBytes from this node at the specified offset. We are
/// guaranteed that there is a split at Offset.
void erase(unsigned Offset, unsigned NumBytes);
-
+
static inline bool classof(const RopePieceBTreeLeaf *) { return true; }
static inline bool classof(const RopePieceBTreeNode *N) {
return N->isLeaf();
@@ -242,7 +242,7 @@ RopePieceBTreeNode *RopePieceBTreeLeaf::split(unsigned Offset) {
// Fastpath for a common case. There is already a splitpoint at the end.
return 0;
}
-
+
// Find the piece that this offset lands in.
unsigned PieceOffs = 0;
unsigned i = 0;
@@ -250,23 +250,23 @@ RopePieceBTreeNode *RopePieceBTreeLeaf::split(unsigned Offset) {
PieceOffs += Pieces[i].size();
++i;
}
-
+
// If there is already a split point at the specified offset, just return
// success.
if (PieceOffs == Offset)
return 0;
-
+
// Otherwise, we need to split piece 'i' at Offset-PieceOffs. Convert Offset
// to being Piece relative.
unsigned IntraPieceOffset = Offset-PieceOffs;
-
+
// We do this by shrinking the RopePiece and then doing an insert of the tail.
RopePiece Tail(Pieces[i].StrData, Pieces[i].StartOffs+IntraPieceOffset,
Pieces[i].EndOffs);
Size -= Pieces[i].size();
Pieces[i].EndOffs = Pieces[i].StartOffs+IntraPieceOffset;
Size += Pieces[i].size();
-
+
return insert(Offset, Tail);
}
@@ -292,7 +292,7 @@ RopePieceBTreeNode *RopePieceBTreeLeaf::insert(unsigned Offset,
SlotOffs += getPiece(i).size();
assert(SlotOffs == Offset && "Split didn't occur before insertion!");
}
-
+
// For an insertion into a non-full leaf node, just insert the value in
// its sorted position. This requires moving later values over.
for (; i != e; --e)
@@ -302,31 +302,31 @@ RopePieceBTreeNode *RopePieceBTreeLeaf::insert(unsigned Offset,
Size += R.size();
return 0;
}
-
+
// Otherwise, if this is leaf is full, split it in two halves. Since this
// node is full, it contains 2*WidthFactor values. We move the first
// 'WidthFactor' values to the LHS child (which we leave in this node) and
// move the last 'WidthFactor' values into the RHS child.
-
+
// Create the new node.
RopePieceBTreeLeaf *NewNode = new RopePieceBTreeLeaf();
-
+
// Move over the last 'WidthFactor' values from here to NewNode.
std::copy(&Pieces[WidthFactor], &Pieces[2*WidthFactor],
&NewNode->Pieces[0]);
// Replace old pieces with null RopePieces to drop refcounts.
std::fill(&Pieces[WidthFactor], &Pieces[2*WidthFactor], RopePiece());
-
+
// Decrease the number of values in the two nodes.
NewNode->NumPieces = NumPieces = WidthFactor;
-
+
// Recompute the two nodes' size.
NewNode->FullRecomputeSizeLocally();
FullRecomputeSizeLocally();
-
+
// Update the list of leaves.
NewNode->insertAfterLeafInOrder(this);
-
+
// These insertions can't fail.
if (this->size() >= Offset)
this->insert(Offset, R);
@@ -345,42 +345,42 @@ void RopePieceBTreeLeaf::erase(unsigned Offset, unsigned NumBytes) {
for (; Offset > PieceOffs; ++i)
PieceOffs += getPiece(i).size();
assert(PieceOffs == Offset && "Split didn't occur before erase!");
-
+
unsigned StartPiece = i;
-
+
// Figure out how many pieces completely cover 'NumBytes'. We want to remove
// all of them.
for (; Offset+NumBytes > PieceOffs+getPiece(i).size(); ++i)
PieceOffs += getPiece(i).size();
-
+
// If we exactly include the last one, include it in the region to delete.
if (Offset+NumBytes == PieceOffs+getPiece(i).size())
PieceOffs += getPiece(i).size(), ++i;
-
+
// If we completely cover some RopePieces, erase them now.
if (i != StartPiece) {
unsigned NumDeleted = i-StartPiece;
for (; i != getNumPieces(); ++i)
Pieces[i-NumDeleted] = Pieces[i];
-
+
// Drop references to dead rope pieces.
std::fill(&Pieces[getNumPieces()-NumDeleted], &Pieces[getNumPieces()],
RopePiece());
NumPieces -= NumDeleted;
-
+
unsigned CoverBytes = PieceOffs-Offset;
NumBytes -= CoverBytes;
Size -= CoverBytes;
}
-
+
// If we completely removed some stuff, we could be done.
if (NumBytes == 0) return;
-
+
// Okay, now might be erasing part of some Piece. If this is the case, then
// move the start point of the piece.
assert(getPiece(StartPiece).size() > NumBytes);
Pieces[StartPiece].StartOffs += NumBytes;
-
+
// The size of this node just shrunk by NumBytes.
Size -= NumBytes;
}
@@ -399,7 +399,7 @@ namespace {
RopePieceBTreeNode *Children[2*WidthFactor];
public:
RopePieceBTreeInterior() : RopePieceBTreeNode(false), NumChildren(0) {}
-
+
RopePieceBTreeInterior(RopePieceBTreeNode *LHS, RopePieceBTreeNode *RHS)
: RopePieceBTreeNode(false) {
Children[0] = LHS;
@@ -407,9 +407,9 @@ namespace {
NumChildren = 2;
Size = LHS->size() + RHS->size();
}
-
+
bool isFull() const { return NumChildren == 2*WidthFactor; }
-
+
unsigned getNumChildren() const { return NumChildren; }
const RopePieceBTreeNode *getChild(unsigned i) const {
assert(i < NumChildren && "invalid child #");
@@ -419,7 +419,7 @@ namespace {
assert(i < NumChildren && "invalid child #");
return Children[i];
}
-
+
/// FullRecomputeSizeLocally - Recompute the Size field of this node by
/// summing up the sizes of the child nodes.
void FullRecomputeSizeLocally() {
@@ -427,8 +427,8 @@ namespace {
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
Size += getChild(i)->size();
}
-
-
+
+
/// split - Split the range containing the specified offset so that we are
/// guaranteed that there is a place to do an insertion at the specified
/// offset. The offset is relative, so "0" is the start of the node.
@@ -436,8 +436,8 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *split(unsigned Offset);
-
-
+
+
/// insert - Insert the specified ropepiece into this tree node at the
/// specified offset. The offset is relative, so "0" is the start of the
/// node.
@@ -445,18 +445,18 @@ namespace {
/// If there is no space in this subtree for the extra piece, the extra tree
/// node is returned and must be inserted into a parent.
RopePieceBTreeNode *insert(unsigned Offset, const RopePiece &R);
-
+
/// HandleChildPiece - A child propagated an insertion result up to us.
/// Insert the new child, and/or propagate the result further up the tree.
RopePieceBTreeNode *HandleChildPiece(unsigned i, RopePieceBTreeNode *RHS);
-
+
/// erase - Remove NumBytes from this node at the specified offset. We are
/// guaranteed that there is a split at Offset.
void erase(unsigned Offset, unsigned NumBytes);
-
+
static inline bool classof(const RopePieceBTreeInterior *) { return true; }
static inline bool classof(const RopePieceBTreeNode *N) {
- return !N->isLeaf();
+ return !N->isLeaf();
}
};
} // end anonymous namespace
@@ -471,18 +471,18 @@ RopePieceBTreeNode *RopePieceBTreeInterior::split(unsigned Offset) {
// Figure out which child to split.
if (Offset == 0 || Offset == size())
return 0; // If we have an exact offset, we're already split.
-
+
unsigned ChildOffset = 0;
unsigned i = 0;
for (; Offset >= ChildOffset+getChild(i)->size(); ++i)
ChildOffset += getChild(i)->size();
-
+
// If already split there, we're done.
if (ChildOffset == Offset)
return 0;
-
+
// Otherwise, recursively split the child.
- if (RopePieceBTreeNode *RHS = getChild(i)->split(Offset-ChildOffset))
+ if (RopePieceBTreeNode *RHS = getChild(i)->split(Offset-ChildOffset))
return HandleChildPiece(i, RHS);
return 0; // Done!
}
@@ -498,7 +498,7 @@ RopePieceBTreeNode *RopePieceBTreeInterior::insert(unsigned Offset,
// Find the insertion point. We are guaranteed that there is a split at the
// specified offset so find it.
unsigned i = 0, e = getNumChildren();
-
+
unsigned ChildOffs = 0;
if (Offset == size()) {
// Fastpath for a common case. Insert at end of last child.
@@ -508,13 +508,13 @@ RopePieceBTreeNode *RopePieceBTreeInterior::insert(unsigned Offset,
for (; Offset > ChildOffs+getChild(i)->size(); ++i)
ChildOffs += getChild(i)->size();
}
-
+
Size += R.size();
-
+
// Insert at the end of this child.
if (RopePieceBTreeNode *RHS = getChild(i)->insert(Offset-ChildOffs, R))
return HandleChildPiece(i, RHS);
-
+
return 0;
}
@@ -533,27 +533,27 @@ RopePieceBTreeInterior::HandleChildPiece(unsigned i, RopePieceBTreeNode *RHS) {
++NumChildren;
return false;
}
-
+
// Okay, this node is full. Split it in half, moving WidthFactor children to
// a newly allocated interior node.
-
+
// Create the new node.
RopePieceBTreeInterior *NewNode = new RopePieceBTreeInterior();
-
+
// Move over the last 'WidthFactor' values from here to NewNode.
memcpy(&NewNode->Children[0], &Children[WidthFactor],
WidthFactor*sizeof(Children[0]));
-
+
// Decrease the number of values in the two nodes.
NewNode->NumChildren = NumChildren = WidthFactor;
-
+
// Finally, insert the two new children in the side the can (now) hold them.
// These insertions can't fail.
if (i < WidthFactor)
this->HandleChildPiece(i, RHS);
else
NewNode->HandleChildPiece(i-WidthFactor, RHS);
-
+
// Recompute the two nodes' size.
NewNode->FullRecomputeSizeLocally();
FullRecomputeSizeLocally();
@@ -565,24 +565,24 @@ RopePieceBTreeInterior::HandleChildPiece(unsigned i, RopePieceBTreeNode *RHS) {
void RopePieceBTreeInterior::erase(unsigned Offset, unsigned NumBytes) {
// This will shrink this node by NumBytes.
Size -= NumBytes;
-
+
// Find the first child that overlaps with Offset.
unsigned i = 0;
for (; Offset >= getChild(i)->size(); ++i)
Offset -= getChild(i)->size();
-
+
// Propagate the delete request into overlapping children, or completely
// delete the children as appropriate.
while (NumBytes) {
RopePieceBTreeNode *CurChild = getChild(i);
-
+
// If we are deleting something contained entirely in the child, pass on the
// request.
if (Offset+NumBytes < CurChild->size()) {
CurChild->erase(Offset, NumBytes);
return;
}
-
+
// If this deletion request starts somewhere in the middle of the child, it
// must be deleting to the end of the child.
if (Offset) {
@@ -665,19 +665,19 @@ static const RopePieceBTreeLeaf *getCN(const void *P) {
// begin iterator.
RopePieceBTreeIterator::RopePieceBTreeIterator(const void *n) {
const RopePieceBTreeNode *N = static_cast<const RopePieceBTreeNode*>(n);
-
+
// Walk down the left side of the tree until we get to a leaf.
while (const RopePieceBTreeInterior *IN = dyn_cast<RopePieceBTreeInterior>(N))
N = IN->getChild(0);
-
+
// We must have at least one leaf.
CurNode = cast<RopePieceBTreeLeaf>(N);
-
+
// If we found a leaf that happens to be empty, skip over it until we get
// to something full.
while (CurNode && getCN(CurNode)->getNumPieces() == 0)
CurNode = getCN(CurNode)->getNextLeafInOrder();
-
+
if (CurNode != 0)
CurPiece = &getCN(CurNode)->getPiece(0);
else // Empty tree, this is an end() iterator.
@@ -691,12 +691,12 @@ void RopePieceBTreeIterator::MoveToNextPiece() {
++CurPiece;
return;
}
-
+
// Find the next non-empty leaf node.
do
CurNode = getCN(CurNode)->getNextLeafInOrder();
while (CurNode && getCN(CurNode)->getNumPieces() == 0);
-
+
if (CurNode != 0)
CurPiece = &getCN(CurNode)->getPiece(0);
else // Hit end().
@@ -740,7 +740,7 @@ void RopePieceBTree::insert(unsigned Offset, const RopePiece &R) {
// #1. Split at Offset.
if (RopePieceBTreeNode *RHS = getRoot(Root)->split(Offset))
Root = new RopePieceBTreeInterior(getRoot(Root), RHS);
-
+
// #2. Do the insertion.
if (RopePieceBTreeNode *RHS = getRoot(Root)->insert(Offset, R))
Root = new RopePieceBTreeInterior(getRoot(Root), RHS);
@@ -750,7 +750,7 @@ void RopePieceBTree::erase(unsigned Offset, unsigned NumBytes) {
// #1. Split at Offset.
if (RopePieceBTreeNode *RHS = getRoot(Root)->split(Offset))
Root = new RopePieceBTreeInterior(getRoot(Root), RHS);
-
+
// #2. Do the erasing.
getRoot(Root)->erase(Offset, NumBytes);
}
@@ -766,38 +766,38 @@ void RopePieceBTree::erase(unsigned Offset, unsigned NumBytes) {
RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) {
unsigned Len = End-Start;
assert(Len && "Zero length RopePiece is invalid!");
-
+
// If we have space for this string in the current alloc buffer, use it.
if (AllocOffs+Len <= AllocChunkSize) {
memcpy(AllocBuffer->Data+AllocOffs, Start, Len);
AllocOffs += Len;
return RopePiece(AllocBuffer, AllocOffs-Len, AllocOffs);
}
-
+
// If we don't have enough room because this specific allocation is huge,
// just allocate a new rope piece for it alone.
if (Len > AllocChunkSize) {
unsigned Size = End-Start+sizeof(RopeRefCountString)-1;
- RopeRefCountString *Res =
+ RopeRefCountString *Res =
reinterpret_cast<RopeRefCountString *>(new char[Size]);
Res->RefCount = 0;
memcpy(Res->Data, Start, End-Start);
return RopePiece(Res, 0, End-Start);
}
-
+
// Otherwise, this was a small request but we just don't have space for it
// Make a new chunk and share it with later allocations.
-
+
// If we had an old allocation, drop our reference to it.
if (AllocBuffer && --AllocBuffer->RefCount == 0)
delete [] (char*)AllocBuffer;
-
+
unsigned AllocSize = offsetof(RopeRefCountString, Data) + AllocChunkSize;
AllocBuffer = reinterpret_cast<RopeRefCountString *>(new char[AllocSize]);
AllocBuffer->RefCount = 0;
memcpy(AllocBuffer->Data, Start, Len);
AllocOffs = Len;
-
+
// Start out the new allocation with a refcount of 1, since we have an
// internal reference to it.
AllocBuffer->addRef();
diff --git a/lib/Rewrite/Rewriter.cpp b/lib/Rewrite/Rewriter.cpp
index 6efe31fb89..27a5f8b5ff 100644
--- a/lib/Rewrite/Rewriter.cpp
+++ b/lib/Rewrite/Rewriter.cpp
@@ -26,7 +26,7 @@ void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size) {
unsigned RealOffset = getMappedOffset(OrigOffset, true);
assert(RealOffset+Size < Buffer.size() && "Invalid location");
-
+
// Remove the dead characters.
Buffer.erase(RealOffset, Size);
@@ -36,13 +36,13 @@ void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size) {
void RewriteBuffer::InsertText(unsigned OrigOffset, const llvm::StringRef &Str,
bool InsertAfter) {
-
+
// Nothing to insert, exit early.
if (Str.empty()) return;
unsigned RealOffset = getMappedOffset(OrigOffset, InsertAfter);
Buffer.insert(RealOffset, Str.begin(), Str.end());
-
+
// Add a delta so that future changes are offset correctly.
AddInsertDelta(OrigOffset, Str.size());
}
@@ -69,16 +69,16 @@ void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength,
int Rewriter::getRangeSize(SourceRange Range) const {
if (!isRewritable(Range.getBegin()) ||
!isRewritable(Range.getEnd())) return -1;
-
+
FileID StartFileID, EndFileID;
unsigned StartOff, EndOff;
-
+
StartOff = getLocationOffsetAndFileID(Range.getBegin(), StartFileID);
EndOff = getLocationOffsetAndFileID(Range.getEnd(), EndFileID);
-
+
if (StartFileID != EndFileID)
return -1;
-
+
// If edits have been made to this buffer, the delta between the range may
// have changed.
std::map<FileID, RewriteBuffer>::const_iterator I =
@@ -89,17 +89,17 @@ int Rewriter::getRangeSize(SourceRange Range) const {
StartOff = RB.getMappedOffset(StartOff);
}
-
+
// Adjust the end offset to the end of the last token, instead of being the
// start of the last token.
EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
-
+
return EndOff-StartOff;
}
/// getRewritenText - Return the rewritten form of the text in the specified
/// range. If the start or end of the range was unrewritable or if they are
-/// in different buffers, this returns an empty string.
+/// in different buffers, this returns an empty string.
///
/// Note that this method is not particularly efficient.
///
@@ -107,15 +107,15 @@ std::string Rewriter::getRewritenText(SourceRange Range) const {
if (!isRewritable(Range.getBegin()) ||
!isRewritable(Range.getEnd()))
return "";
-
+
FileID StartFileID, EndFileID;
unsigned StartOff, EndOff;
StartOff = getLocationOffsetAndFileID(Range.getBegin(), StartFileID);
EndOff = getLocationOffsetAndFileID(Range.getEnd(), EndFileID);
-
+
if (StartFileID != EndFileID)
return ""; // Start and end in different buffers.
-
+
// If edits have been made to this buffer, the delta between the range may
// have changed.
std::map<FileID, RewriteBuffer>::const_iterator I =
@@ -123,17 +123,17 @@ std::string Rewriter::getRewritenText(SourceRange Range) const {
if (I == RewriteBuffers.end()) {
// If the buffer hasn't been rewritten, just return the text from the input.
const char *Ptr = SourceMgr->getCharacterData(Range.getBegin());
-
+
// Adjust the end offset to the end of the last token, instead of being the
// start of the last token.
EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
return std::string(Ptr, Ptr+EndOff-StartOff);
}
-
+
const RewriteBuffer &RB = I->second;
EndOff = RB.getMappedOffset(EndOff, true);
StartOff = RB.getMappedOffset(StartOff);
-
+
// Adjust the end offset to the end of the last token, instead of being the
// start of the last token.
EndOff += Lexer::MeasureTokenLength(Range.getEnd(), *SourceMgr, *LangOpts);
@@ -143,7 +143,7 @@ std::string Rewriter::getRewritenText(SourceRange Range) const {
std::advance(Start, StartOff);
RewriteBuffer::iterator End = Start;
std::advance(End, EndOff-StartOff);
-
+
return std::string(Start, End);
}
@@ -161,13 +161,13 @@ unsigned Rewriter::getLocationOffsetAndFileID(SourceLocation Loc,
RewriteBuffer &Rewriter::getEditBuffer(FileID FID) {
std::map<FileID, RewriteBuffer>::iterator I =
RewriteBuffers.lower_bound(FID);
- if (I != RewriteBuffers.end() && I->first == FID)
+ if (I != RewriteBuffers.end() && I->first == FID)
return I->second;
I = RewriteBuffers.insert(I, std::make_pair(FID, RewriteBuffer()));
-
+
std::pair<const char*, const char*> MB = SourceMgr->getBufferData(FID);
I->second.Initialize(MB.first, MB.second);
-
+
return I->second;
}
@@ -199,7 +199,7 @@ bool Rewriter::ReplaceText(SourceLocation Start, unsigned OrigLength,
if (!isRewritable(Start)) return true;
FileID StartFileID;
unsigned StartOffs = getLocationOffsetAndFileID(Start, StartFileID);
-
+
getEditBuffer(StartFileID).ReplaceText(StartOffs, OrigLength, NewStr);
return false;
}
@@ -212,7 +212,7 @@ bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) {
int Size = getRangeSize(From->getSourceRange());
if (Size == -1)
return true;
-
+
// Get the new text.
std::string SStr;
llvm::raw_string_ostream S(SStr);
diff --git a/lib/Rewrite/TokenRewriter.cpp b/lib/Rewrite/TokenRewriter.cpp
index e17e80133b..0effbb18b8 100644
--- a/lib/Rewrite/TokenRewriter.cpp
+++ b/lib/Rewrite/TokenRewriter.cpp
@@ -21,10 +21,10 @@ using namespace clang;
TokenRewriter::TokenRewriter(FileID FID, SourceManager &SM,
const LangOptions &LangOpts) {
ScratchBuf.reset(new ScratchBuffer(SM));
-
+
// Create a lexer to lex all the tokens of the main file in raw mode.
Lexer RawLex(FID, SM, LangOpts);
-
+
// Return all comments and whitespace as tokens.
RawLex.SetKeepWhitespaceMode(true);
@@ -39,7 +39,7 @@ TokenRewriter::TokenRewriter(FileID FID, SourceManager &SM,
Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok));
}
#endif
-
+
AddToken(RawTok, TokenList.end());
RawLex.LexFromRawLexer(RawTok);
}
@@ -53,10 +53,10 @@ TokenRewriter::~TokenRewriter() {
/// TokenRefTy (a non-const iterator).
TokenRewriter::TokenRefTy TokenRewriter::RemapIterator(token_iterator I) {
if (I == token_end()) return TokenList.end();
-
+
// FIXME: This is horrible, we should use our own list or something to avoid
// this.
- std::map<SourceLocation, TokenRefTy>::iterator MapIt =
+ std::map<SourceLocation, TokenRefTy>::iterator MapIt =
TokenAtLoc.find(I->getLocation());
assert(MapIt != TokenAtLoc.end() && "iterator not in rewriter?");
return MapIt->second;
@@ -65,22 +65,22 @@ TokenRewriter::TokenRefTy TokenRewriter::RemapIterator(token_iterator I) {
/// AddToken - Add the specified token into the Rewriter before the other
/// position.
-TokenRewriter::TokenRefTy
+TokenRewriter::TokenRefTy
TokenRewriter::AddToken(const Token &T, TokenRefTy Where) {
Where = TokenList.insert(Where, T);
-
+
bool InsertSuccess = TokenAtLoc.insert(std::make_pair(T.getLocation(),
Where)).second;
assert(InsertSuccess && "Token location already in rewriter!");
InsertSuccess = InsertSuccess;
return Where;
}
-
+
TokenRewriter::token_iterator
TokenRewriter::AddTokenBefore(token_iterator I, const char *Val) {
unsigned Len = strlen(Val);
-
+
// Plop the string into the scratch buffer, then create a token for this
// string.
Token Tok;
@@ -88,7 +88,7 @@ TokenRewriter::AddTokenBefore(token_iterator I, const char *Val) {
const char *Spelling;
Tok.setLocation(ScratchBuf->getToken(Val, Len, Spelling));
Tok.setLength(Len);
-
+
// TODO: Form a whole lexer around this and relex the token! For now, just
// set kind to tok::unknown.
Tok.setKind(tok::unknown);
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp
index a36b85a87a..0dbf21961f 100644
--- a/lib/Sema/IdentifierResolver.cpp
+++ b/lib/Sema/IdentifierResolver.cpp
@@ -32,7 +32,7 @@ class IdentifierResolver::IdDeclInfoMap {
// New vectors are added when the current one is full.
std::list< std::vector<IdDeclInfo> > IDIVecs;
unsigned int CurIndex;
-
+
public:
IdDeclInfoMap() : CurIndex(VECTOR_SIZE) {}
@@ -75,7 +75,7 @@ void IdentifierResolver::IdDeclInfo::RemoveDecl(NamedDecl *D) {
assert(0 && "Didn't find this decl on its identifier's chain!");
}
-bool
+bool
IdentifierResolver::IdDeclInfo::ReplaceDecl(NamedDecl *Old, NamedDecl *New) {
for (DeclsTy::iterator I = Decls.end(); I != Decls.begin(); --I) {
if (Old == *(I-1)) {
@@ -108,7 +108,7 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx,
if (Ctx->isFunctionOrMethod()) {
// Ignore the scopes associated within transparent declaration contexts.
- while (S->getEntity() &&
+ while (S->getEntity() &&
((DeclContext *)S->getEntity())->isTransparentContext())
S = S->getParent();
@@ -200,14 +200,14 @@ void IdentifierResolver::RemoveDecl(NamedDecl *D) {
Name.setFETokenInfo(NULL);
return;
}
-
+
return toIdDeclInfo(Ptr)->RemoveDecl(D);
}
bool IdentifierResolver::ReplaceDecl(NamedDecl *Old, NamedDecl *New) {
- assert(Old->getDeclName() == New->getDeclName() &&
+ assert(Old->getDeclName() == New->getDeclName() &&
"Cannot replace a decl with another decl of a different name");
-
+
DeclarationName Name = Old->getDeclName();
void *Ptr = Name.getFETokenInfo<void>();
@@ -222,7 +222,7 @@ bool IdentifierResolver::ReplaceDecl(NamedDecl *Old, NamedDecl *New) {
return false;
}
- return toIdDeclInfo(Ptr)->ReplaceDecl(Old, New);
+ return toIdDeclInfo(Ptr)->ReplaceDecl(Old, New);
}
/// begin - Returns an iterator for decls with name 'Name'.
@@ -243,7 +243,7 @@ IdentifierResolver::begin(DeclarationName Name) {
return end();
}
-void IdentifierResolver::AddDeclToIdentifierChain(IdentifierInfo *II,
+void IdentifierResolver::AddDeclToIdentifierChain(IdentifierInfo *II,
NamedDecl *D) {
void *Ptr = II->getFETokenInfo<void>();
diff --git a/lib/Sema/IdentifierResolver.h b/lib/Sema/IdentifierResolver.h
index 0b0e6b388d..65f3256c21 100644
--- a/lib/Sema/IdentifierResolver.h
+++ b/lib/Sema/IdentifierResolver.h
@@ -99,7 +99,7 @@ public:
assert(isIterator() && "Ptr not an iterator!");
return reinterpret_cast<BaseIter>(Ptr & ~0x3);
}
-
+
friend class IdentifierResolver;
public:
iterator() : Ptr(0) {}
@@ -110,14 +110,14 @@ public:
else
return reinterpret_cast<NamedDecl*>(Ptr);
}
-
+
bool operator==(const iterator &RHS) const {
return Ptr == RHS.Ptr;
}
bool operator!=(const iterator &RHS) const {
return Ptr != RHS.Ptr;
}
-
+
// Preincrement.
iterator& operator++() {
if (!isIterator()) // common case.
@@ -127,7 +127,7 @@ public:
void *InfoPtr = D->getDeclName().getFETokenInfo<void>();
assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?");
IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
-
+
BaseIter I = getIterator();
if (I != Info->decls_begin())
*this = iterator(I-1);
@@ -138,7 +138,7 @@ public:
}
uintptr_t getAsOpaqueValue() const { return Ptr; }
-
+
static iterator getFromOpaqueValue(uintptr_t P) {
iterator Result;
Result.Ptr = P;
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp
index 853adaa336..a8e31d2cfa 100644
--- a/lib/Sema/JumpDiagnostics.cpp
+++ b/lib/Sema/JumpDiagnostics.cpp
@@ -28,7 +28,7 @@ namespace {
///
class JumpScopeChecker {
Sema &S;
-
+
/// GotoScope - This is a record that we use to keep track of all of the
/// scopes that are introduced by VLAs and other things that scope jumps like
/// gotos. This scope tree has nothing to do with the source scope tree,
@@ -38,17 +38,17 @@ class JumpScopeChecker {
/// ParentScope - The index in ScopeMap of the parent scope. This is 0 for
/// the parent scope is the function body.
unsigned ParentScope;
-
+
/// Diag - The diagnostic to emit if there is a jump into this scope.
unsigned Diag;
-
+
/// Loc - Location to emit the diagnostic.
SourceLocation Loc;
-
+
GotoScope(unsigned parentScope, unsigned diag, SourceLocation L)
: ParentScope(parentScope), Diag(diag), Loc(L) {}
};
-
+
llvm::SmallVector<GotoScope, 48> Scopes;
llvm::DenseMap<Stmt*, unsigned> LabelAndGotoScopes;
llvm::SmallVector<Stmt*, 16> Jumps;
@@ -66,15 +66,15 @@ private:
JumpScopeChecker::JumpScopeChecker(Stmt *Body, Sema &s) : S(s) {
// Add a scope entry for function scope.
Scopes.push_back(GotoScope(~0U, ~0U, SourceLocation()));
-
+
// Build information for the top level compound statement, so that we have a
// defined scope record for every "goto" and label.
BuildScopeInformation(Body, 0);
-
+
// Check that all jumps we saw are kosher.
VerifyJumps();
}
-
+
/// GetDiagForGotoScopeDecl - If this decl induces a new goto scope, return a
/// diagnostic that should be emitted if control goes over it. If not, return 0.
static unsigned GetDiagForGotoScopeDecl(const Decl *D) {
@@ -89,7 +89,7 @@ static unsigned GetDiagForGotoScopeDecl(const Decl *D) {
if (TD->getUnderlyingType()->isVariablyModifiedType())
return diag::note_protected_by_vla_typedef;
}
-
+
return 0;
}
@@ -99,7 +99,7 @@ static unsigned GetDiagForGotoScopeDecl(const Decl *D) {
/// statements, adding any labels or gotos to LabelAndGotoScopes and recursively
/// walking the AST as needed.
void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
-
+
// If we found a label, remember that it is in ParentScope scope.
if (isa<LabelStmt>(S) || isa<DefaultStmt>(S) || isa<CaseStmt>(S)) {
LabelAndGotoScopes[S] = ParentScope;
@@ -110,12 +110,12 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
LabelAndGotoScopes[S] = ParentScope;
Jumps.push_back(S);
}
-
+
for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); CI != E;
++CI) {
Stmt *SubStmt = *CI;
if (SubStmt == 0) continue;
-
+
// FIXME: diagnose jumps past initialization: required in C++, warning in C.
// goto L; int X = 4; L: ;
@@ -131,7 +131,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
Scopes.push_back(GotoScope(ParentScope, Diag, (*I)->getLocation()));
ParentScope = Scopes.size()-1;
}
-
+
// If the decl has an initializer, walk it with the potentially new
// scope we just installed.
if (VarDecl *VD = dyn_cast<VarDecl>(*I))
@@ -156,10 +156,10 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
Scopes.push_back(GotoScope(ParentScope,
diag::note_protected_by_objc_catch,
AC->getAtCatchLoc()));
- // @catches are nested and it isn't
+ // @catches are nested and it isn't
BuildScopeInformation(AC->getCatchBody(), Scopes.size()-1);
}
-
+
// Jump from the finally to the try or catch is not valid.
if (ObjCAtFinallyStmt *AF = AT->getFinallyStmt()) {
Scopes.push_back(GotoScope(ParentScope,
@@ -167,17 +167,17 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
AF->getAtFinallyLoc()));
BuildScopeInformation(AF, Scopes.size()-1);
}
-
+
continue;
}
-
+
// Disallow jumps into the protected statement of an @synchronized, but
// allow jumps into the object expression it protects.
if (ObjCAtSynchronizedStmt *AS = dyn_cast<ObjCAtSynchronizedStmt>(SubStmt)){
// Recursively walk the AST for the @synchronized object expr, it is
// evaluated in the normal scope.
BuildScopeInformation(AS->getSynchExpr(), ParentScope);
-
+
// Recursively walk the AST for the @synchronized part, protected by a new
// scope.
Scopes.push_back(GotoScope(ParentScope,
@@ -196,7 +196,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
BuildScopeInformation(TryBlock, Scopes.size()-1);
// Jump from the catch into the try is not allowed either.
- for(unsigned I = 0, E = TS->getNumHandlers(); I != E; ++I) {
+ for (unsigned I = 0, E = TS->getNumHandlers(); I != E; ++I) {
CXXCatchStmt *CS = TS->getHandler(I);
Scopes.push_back(GotoScope(ParentScope,
diag::note_protected_by_cxx_catch,
@@ -217,14 +217,14 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
void JumpScopeChecker::VerifyJumps() {
while (!Jumps.empty()) {
Stmt *Jump = Jumps.pop_back_val();
-
- // With a goto,
+
+ // With a goto,
if (GotoStmt *GS = dyn_cast<GotoStmt>(Jump)) {
CheckJump(GS, GS->getLabel(), GS->getGotoLoc(),
diag::err_goto_into_protected_scope);
continue;
}
-
+
if (SwitchStmt *SS = dyn_cast<SwitchStmt>(Jump)) {
for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase()) {
@@ -236,7 +236,7 @@ void JumpScopeChecker::VerifyJumps() {
}
unsigned DiagnosticScope;
-
+
// We don't know where an indirect goto goes, require that it be at the
// top level of scoping.
if (IndirectGotoStmt *IG = dyn_cast<IndirectGotoStmt>(Jump)) {
@@ -254,12 +254,12 @@ void JumpScopeChecker::VerifyJumps() {
// indirectly jumping to the label.
assert(isa<AddrLabelExpr>(Jump) && "Unknown jump type");
LabelStmt *TheLabel = cast<AddrLabelExpr>(Jump)->getLabel();
-
+
assert(LabelAndGotoScopes.count(TheLabel) &&
"Referenced label didn't get added to scopes?");
unsigned LabelScope = LabelAndGotoScopes[TheLabel];
if (LabelScope == 0) continue; // Addr of label is ok.
-
+
S.Diag(Jump->getLocStart(), diag::err_addr_of_label_in_protected_scope);
DiagnosticScope = LabelScope;
}
@@ -282,10 +282,10 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To,
assert(LabelAndGotoScopes.count(To) && "Jump didn't get added to scopes?");
unsigned ToScope = LabelAndGotoScopes[To];
-
+
// Common case: exactly the same scope, which is fine.
if (FromScope == ToScope) return;
-
+
// The only valid mismatch jump case happens when the jump is more deeply
// nested inside the jump target. Do a quick scan to see if the jump is valid
// because valid code is more common than invalid code.
@@ -294,11 +294,11 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To,
// If we found the jump target, then we're jumping out of our current scope,
// which is perfectly fine.
if (TestScope == ToScope) return;
-
+
// Otherwise, scan up the hierarchy.
TestScope = Scopes[TestScope].ParentScope;
}
-
+
// If we get here, then we know we have invalid code. Diagnose the bad jump,
// and then emit a note at each VLA being jumped out of.
S.Diag(DiagLoc, JumpDiag);
@@ -318,7 +318,7 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To,
FromScopes.pop_back();
ToScopes.pop_back();
}
-
+
// Emit diagnostics for whatever is left in ToScopes.
for (unsigned i = 0, e = ToScopes.size(); i != e; ++i)
S.Diag(Scopes[ToScopes[i]].Loc, Scopes[ToScopes[i]].Diag);
diff --git a/lib/Sema/ParseAST.cpp b/lib/Sema/ParseAST.cpp
index b6e52570ea..196c1c1b85 100644
--- a/lib/Sema/ParseAST.cpp
+++ b/lib/Sema/ParseAST.cpp
@@ -43,17 +43,17 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit);
Parser P(PP, S);
PP.EnterMainSourceFile();
-
+
// Initialize the parser.
P.Initialize();
-
+
Consumer->Initialize(Ctx);
-
+
if (SemaConsumer *SC = dyn_cast<SemaConsumer>(Consumer))
SC->InitializeSema(S);
if (ExternalASTSource *External = Ctx.getExternalSource()) {
- if (ExternalSemaSource *ExternalSema =
+ if (ExternalSemaSource *ExternalSema =
dyn_cast<ExternalSemaSource>(External))
ExternalSema->InitializeSema(S);
@@ -61,7 +61,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
}
Parser::DeclGroupPtrTy ADecl;
-
+
while (!P.ParseTopLevelDecl(ADecl)) { // Not end of file.
// If we got a null return and something *was* parsed, ignore it. This
// is due to a top-level semicolon, an action override, or a parse error
@@ -69,7 +69,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
if (ADecl)
Consumer->HandleTopLevelDecl(ADecl.getAsVal<DeclGroupRef>());
};
-
+
// process any TopLevelDecls generated by #pragma weak
for (llvm::SmallVector<Decl*,2>::iterator
I = S.WeakTopLevelDecls().begin(),
@@ -85,7 +85,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
Decl::PrintStats();
Stmt::PrintStats();
Consumer->PrintStats();
-
+
Decl::CollectingStats(false);
Stmt::CollectingStats(false);
}
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 2d72c3e1be..b158c85414 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -23,7 +23,7 @@
#include "clang/Basic/TargetInfo.h"
using namespace clang;
-/// ConvertQualTypeToStringFn - This function is used to pretty print the
+/// ConvertQualTypeToStringFn - This function is used to pretty print the
/// specified QualType as a string in diagnostics.
static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
const char *Modifier, unsigned ModLen,
@@ -31,7 +31,7 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
llvm::SmallVectorImpl<char> &Output,
void *Cookie) {
ASTContext &Context = *static_cast<ASTContext*>(Cookie);
-
+
std::string S;
if (Kind == Diagnostic::ak_qualtype) {
assert(ModLen == 0 && ArgLen == 0 &&
@@ -41,7 +41,7 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
// FIXME: Playing with std::string is really slow.
S = Ty.getAsString(Context.PrintingPolicy);
-
+
// If this is a sugared type (like a typedef, typeof, etc), then unwrap one
// level of the sugar so that the type is more obvious to the user.
QualType DesugaredTy = Ty->getDesugaredType(true);
@@ -56,13 +56,13 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
// Don't aka just because we saw an elaborated type.
(!isa<ElaboratedType>(Ty) ||
cast<ElaboratedType>(Ty)->getUnderlyingType() != DesugaredTy) &&
-
+
// Don't desugar magic Objective-C types.
Ty.getUnqualifiedType() != Context.getObjCIdType() &&
Ty.getUnqualifiedType() != Context.getObjCClassType() &&
Ty.getUnqualifiedType() != Context.getObjCSelType() &&
Ty.getUnqualifiedType() != Context.getObjCProtoType() &&
-
+
// Not va_list.
Ty.getUnqualifiedType() != Context.getBuiltinVaListType()) {
S = "'"+S+"' (aka '";
@@ -71,12 +71,12 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
Output.append(S.begin(), S.end());
return;
}
-
+
} else if (Kind == Diagnostic::ak_declarationname) {
-
+
DeclarationName N = DeclarationName::getFromOpaqueInteger(Val);
S = N.getAsString();
-
+
if (ModLen == 9 && !memcmp(Modifier, "objcclass", 9) && ArgLen == 0)
S = '+' + S;
else if (ModLen == 12 && !memcmp(Modifier, "objcinstance", 12) && ArgLen==0)
@@ -87,7 +87,7 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
} else if (Kind == Diagnostic::ak_nameddecl) {
if (ModLen == 1 && Modifier[0] == 'q' && ArgLen == 0)
S = reinterpret_cast<NamedDecl*>(Val)->getQualifiedNameAsString();
- else {
+ else {
assert(ModLen == 0 && ArgLen == 0 &&
"Invalid modifier for NamedDecl* argument");
S = reinterpret_cast<NamedDecl*>(Val)->getNameAsString();
@@ -95,10 +95,10 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
} else {
llvm::raw_string_ostream OS(S);
assert(Kind == Diagnostic::ak_nestednamespec);
- reinterpret_cast<NestedNameSpecifier*> (Val)->print(OS,
+ reinterpret_cast<NestedNameSpecifier*> (Val)->print(OS,
Context.PrintingPolicy);
}
-
+
Output.push_back('\'');
Output.append(S.begin(), S.end());
Output.push_back('\'');
@@ -107,11 +107,11 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name) {
if (C.getLangOptions().CPlusPlus)
- return CXXRecordDecl::Create(C, TagDecl::TK_struct,
+ return CXXRecordDecl::Create(C, TagDecl::TK_struct,
C.getTranslationUnitDecl(),
SourceLocation(), &C.Idents.get(Name));
- return RecordDecl::Create(C, TagDecl::TK_struct,
+ return RecordDecl::Create(C, TagDecl::TK_struct,
C.getTranslationUnitDecl(),
SourceLocation(), &C.Idents.get(Name));
}
@@ -119,7 +119,7 @@ static inline RecordDecl *CreateStructDecl(ASTContext &C, const char *Name) {
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
-
+
if (PP.getTargetInfo().getPointerWidth(0) >= 64) {
// Install [u]int128_t for 64-bit targets.
PushOnScopeChains(TypedefDecl::Create(Context, CurContext,
@@ -131,16 +131,16 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
&Context.Idents.get("__uint128_t"),
Context.UnsignedInt128Ty), TUScope);
}
-
-
+
+
if (!PP.getLangOptions().ObjC1) return;
-
+
// Built-in ObjC types may already be set by PCHReader (hence isNull checks).
if (Context.getObjCSelType().isNull()) {
// Synthesize "typedef struct objc_selector *SEL;"
RecordDecl *SelTag = CreateStructDecl(Context, "objc_selector");
PushOnScopeChains(SelTag, TUScope);
-
+
QualType SelT = Context.getPointerType(Context.getTagDeclType(SelTag));
TypedefDecl *SelTypedef = TypedefDecl::Create(Context, CurContext,
SourceLocation(),
@@ -154,15 +154,15 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
if (Context.getObjCProtoType().isNull()) {
ObjCInterfaceDecl *ProtocolDecl =
ObjCInterfaceDecl::Create(Context, CurContext, SourceLocation(),
- &Context.Idents.get("Protocol"),
+ &Context.Idents.get("Protocol"),
SourceLocation(), true);
Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
PushOnScopeChains(ProtocolDecl, TUScope);
}
// Create the built-in typedef for 'id'.
if (Context.getObjCIdType().isNull()) {
- TypedefDecl *IdTypedef =
- TypedefDecl::Create(
+ TypedefDecl *IdTypedef =
+ TypedefDecl::Create(
Context, CurContext, SourceLocation(), &Context.Idents.get("id"),
Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy)
);
@@ -172,8 +172,8 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
}
// Create the built-in typedef for 'Class'.
if (Context.getObjCClassType().isNull()) {
- TypedefDecl *ClassTypedef =
- TypedefDecl::Create(
+ TypedefDecl *ClassTypedef =
+ TypedefDecl::Create(
Context, CurContext, SourceLocation(), &Context.Idents.get("Class"),
Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy)
);
@@ -186,36 +186,36 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
bool CompleteTranslationUnit)
: LangOpts(pp.getLangOptions()), PP(pp), Context(ctxt), Consumer(consumer),
- Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
+ Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
ExternalSource(0), CurContext(0), PreDeclaratorDC(0),
CurBlock(0), PackContext(0), IdResolver(pp.getLangOptions()),
GlobalNewDeleteDeclared(false), ExprEvalContext(PotentiallyEvaluated),
CompleteTranslationUnit(CompleteTranslationUnit),
NumSFINAEErrors(0), CurrentInstantiationScope(0) {
-
+
StdNamespace = 0;
TUScope = 0;
if (getLangOptions().CPlusPlus)
FieldCollector.reset(new CXXFieldCollector());
-
+
// Tell diagnostics how to render things from the AST library.
PP.getDiagnostics().SetArgToStringFn(ConvertArgToStringFn, &Context);
}
-/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
+/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
/// If there is already an implicit cast, merge into the existing one.
/// If isLvalue, the result of the cast is an lvalue.
-void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
+void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
const CastExpr::CastInfo &Info, bool isLvalue) {
QualType ExprTy = Context.getCanonicalType(Expr->getType());
QualType TypeTy = Context.getCanonicalType(Ty);
-
+
if (ExprTy == TypeTy)
return;
-
+
if (Expr->getType().getTypePtr()->isPointerType() &&
Ty.getTypePtr()->isPointerType()) {
- QualType ExprBaseType =
+ QualType ExprBaseType =
cast<PointerType>(ExprTy.getUnqualifiedType())->getPointeeType();
QualType BaseType =
cast<PointerType>(TypeTy.getUnqualifiedType())->getPointeeType();
@@ -224,12 +224,12 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty,
<< Expr->getSourceRange();
}
}
-
+
if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) {
ImpCast->setType(Ty);
ImpCast->setLvalueCast(isLvalue);
- } else
- Expr = new (Context) ImplicitCastExpr(Ty, Info, Expr,
+ } else
+ Expr = new (Context) ImplicitCastExpr(Ty, Info, Expr,
isLvalue);
}
@@ -250,12 +250,12 @@ void Sema::ActOnEndOfTranslationUnit() {
// keep track of the point of instantiation (C++ [temp.point]). This means
// that name lookup that occurs within the template instantiation will
// always happen at the end of the translation unit, so it will find
- // some names that should not be found. Although this is common behavior
+ // some names that should not be found. Although this is common behavior
// for C++ compilers, it is technically wrong. In the future, we either need
// to be able to filter the results of name lookup or we need to perform
// template instantiations earlier.
PerformPendingImplicitInstantiations();
-
+
// Check for #pragma weak identifiers that were never declared
// FIXME: This will cause diagnostics to be emitted in a non-determinstic
// order! Iterating over a densemap like this is bad.
@@ -263,7 +263,7 @@ void Sema::ActOnEndOfTranslationUnit() {
I = WeakUndeclaredIdentifiers.begin(),
E = WeakUndeclaredIdentifiers.end(); I != E; ++I) {
if (I->second.getUsed()) continue;
-
+
Diag(I->second.getLocation(), diag::warn_weak_identifier_undeclared)
<< I->first;
}
@@ -284,29 +284,29 @@ void Sema::ActOnEndOfTranslationUnit() {
// translation unit, with an initializer equal to 0.
for (unsigned i = 0, e = TentativeDefinitionList.size(); i != e; ++i) {
VarDecl *VD = TentativeDefinitions.lookup(TentativeDefinitionList[i]);
-
+
// If the tentative definition was completed, it will be in the list, but
// not the map.
if (VD == 0 || VD->isInvalidDecl() || !VD->isTentativeDefinition(Context))
continue;
- if (const IncompleteArrayType *ArrayT
+ if (const IncompleteArrayType *ArrayT
= Context.getAsIncompleteArrayType(VD->getType())) {
- if (RequireCompleteType(VD->getLocation(),
+ if (RequireCompleteType(VD->getLocation(),
ArrayT->getElementType(),
diag::err_tentative_def_incomplete_type_arr)) {
VD->setInvalidDecl();
continue;
}
-
+
// Set the length of the array to 1 (C99 6.9.2p5).
Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
- QualType T
+ QualType T
= Context.getConstantArrayWithoutExprType(ArrayT->getElementType(),
One, ArrayType::Normal, 0);
VD->setType(T);
- } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
+ } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
diag::err_tentative_def_incomplete_type))
VD->setInvalidDecl();
@@ -324,10 +324,10 @@ void Sema::ActOnEndOfTranslationUnit() {
DeclContext *Sema::getFunctionLevelDeclContext() {
DeclContext *DC = PreDeclaratorDC ? PreDeclaratorDC : CurContext;
-
+
while (isa<BlockDecl>(DC))
DC = DC->getParent();
-
+
return DC;
}
@@ -351,7 +351,7 @@ NamedDecl *Sema::getCurFunctionOrMethodDecl() {
return 0;
}
-void Sema::DiagnoseMissingMember(SourceLocation MemberLoc,
+void Sema::DiagnoseMissingMember(SourceLocation MemberLoc,
DeclarationName Member,
NestedNameSpecifier *NNS, SourceRange Range) {
switch (NNS->getKind()) {
@@ -379,17 +379,17 @@ void Sema::DiagnoseMissingMember(SourceLocation MemberLoc,
Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
if (!this->Emit())
return;
-
+
// If this is not a note, and we're in a template instantiation
// that is different from the last template instantiation where
// we emitted an error, print a template instantiation
// backtrace.
if (!SemaRef.Diags.isBuiltinNote(DiagID) &&
!SemaRef.ActiveTemplateInstantiations.empty() &&
- SemaRef.ActiveTemplateInstantiations.back()
+ SemaRef.ActiveTemplateInstantiations.back()
!= SemaRef.LastTemplateInstantiationErrorContext) {
SemaRef.PrintInstantiationStack();
- SemaRef.LastTemplateInstantiationErrorContext
+ SemaRef.LastTemplateInstantiationErrorContext
= SemaRef.ActiveTemplateInstantiations.back();
}
}
@@ -398,7 +398,7 @@ Sema::SemaDiagnosticBuilder
Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID()));
PD.Emit(Builder);
-
+
return Builder;
}
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index ee893e2e0d..a73a2b912c 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -100,30 +100,30 @@ struct BlockSemaInfo {
bool hasPrototype;
bool isVariadic;
bool hasBlockDeclRefExprs;
-
+
BlockDecl *TheDecl;
-
+
/// TheScope - This is the scope for the block itself, which contains
/// arguments etc.
Scope *TheScope;
-
+
/// ReturnType - This will get set to block result type, by looking at
/// return types, if any, in the block body.
QualType ReturnType;
-
+
/// LabelMap - This is a mapping from label identifiers to the LabelStmt for
/// it (which acts like the label decl in some ways). Forward referenced
/// labels have a LabelStmt created for them with a null location & SubStmt.
llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
-
+
/// SwitchStack - This is the current set of active switch statements in the
/// block.
llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
-
+
/// SavedFunctionNeedsScopeChecking - This is the value of
/// CurFunctionNeedsScopeChecking at the point when the block started.
bool SavedFunctionNeedsScopeChecking;
-
+
/// PrevBlockInfo - If this is nested inside another block, this points
/// to the outer block.
BlockSemaInfo *PrevBlockInfo;
@@ -138,7 +138,7 @@ struct BlockSemaInfo {
class LocInfoType : public Type {
enum {
// The last number that can fit in Type's TC.
- // Avoids conflict with an existing Type class.
+ // Avoids conflict with an existing Type class.
LocInfo = (1 << TypeClassBitSize) - 1
};
@@ -201,13 +201,13 @@ public:
/// Note that this should always be accessed through getLabelMap() in order
/// to handle blocks properly.
llvm::DenseMap<IdentifierInfo*, LabelStmt*> FunctionLabelMap;
-
+
/// FunctionSwitchStack - This is the current set of active switch statements
/// in the top level function. Clients should always use getSwitchStack() to
/// handle the case when they are in a block.
llvm::SmallVector<SwitchStmt*, 8> FunctionSwitchStack;
- /// ExprTemporaries - This is the stack of temporaries that are created by
+ /// ExprTemporaries - This is the stack of temporaries that are created by
/// the current full expression.
llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
@@ -216,22 +216,22 @@ public:
/// scopes that need to be checked for goto conditions. If a function does
/// not contain this, then it need not have the jump checker run on it.
bool CurFunctionNeedsScopeChecking;
-
+
/// ExtVectorDecls - This is a list all the extended vector types. This allows
/// us to associate a raw vector type with one of the ext_vector type names.
/// This is only necessary for issuing pretty diagnostics.
llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
-
+
/// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
llvm::OwningPtr<CXXFieldCollector> FieldCollector;
typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
-
- /// PureVirtualClassDiagSet - a set of class declarations which we have
+
+ /// PureVirtualClassDiagSet - a set of class declarations which we have
/// emitted a list of pure virtual functions. Used to prevent emitting the
/// same list more than once.
llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
-
+
/// \brief A mapping from external names to the most recent
/// locally-scoped external declaration with that name.
///
@@ -315,17 +315,17 @@ public:
/// The current expression evaluation context.
ExpressionEvaluationContext ExprEvalContext;
-
- typedef std::vector<std::pair<SourceLocation, Decl *> >
+
+ typedef std::vector<std::pair<SourceLocation, Decl *> >
PotentiallyReferencedDecls;
-
+
/// A stack of declarations, each element of which is a set of declarations
/// that will be marked as referenced if the corresponding potentially
/// potentially evaluated expression is potentially evaluated. Each element
/// in the stack corresponds to a PotentiallyPotentiallyEvaluated expression
/// evaluation context.
std::list<PotentiallyReferencedDecls> PotentiallyReferencedDeclStack;
-
+
/// \brief Whether the code handled by Sema should be considered a
/// complete translation unit or not.
///
@@ -346,11 +346,11 @@ public:
/// Instance/Factory Method Pools - allows efficient lookup when typechecking
/// messages to "id". We need to maintain a list, since selectors can have
- /// differing signatures across classes. In Cocoa, this happens to be
+ /// differing signatures across classes. In Cocoa, this happens to be
/// extremely uncommon (only 1% of selectors are "overloaded").
MethodPool InstanceMethodPool;
MethodPool FactoryMethodPool;
-
+
MethodPool::iterator ReadMethodPool(Selector Sel, bool isInstance);
/// Private Helper predicate to check for 'self'.
@@ -361,7 +361,7 @@ public:
~Sema() {
if (PackContext) FreePackedContext();
}
-
+
const LangOptions &getLangOptions() const { return LangOpts; }
Diagnostic &getDiagnostics() const { return Diags; }
SourceManager &getSourceManager() const { return SourceMgr; }
@@ -383,7 +383,7 @@ public:
SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
: DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
- explicit SemaDiagnosticBuilder(Sema &SemaRef)
+ explicit SemaDiagnosticBuilder(Sema &SemaRef)
: DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { }
~SemaDiagnosticBuilder();
@@ -424,7 +424,7 @@ public:
llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() {
return CurBlock ? CurBlock->LabelMap : FunctionLabelMap;
}
-
+
/// getSwitchStack - This is returns the switch stack for the current block or
/// function.
llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() {
@@ -433,7 +433,7 @@ public:
/// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
-
+
virtual void ActOnComment(SourceRange Comment);
//===--------------------------------------------------------------------===//
@@ -443,21 +443,21 @@ public:
QualType ConvertDeclSpecToType(const DeclSpec &DS, SourceLocation DeclLoc,
bool &IsInvalid);
void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL);
- QualType BuildPointerType(QualType T, unsigned Quals,
+ QualType BuildPointerType(QualType T, unsigned Quals,
SourceLocation Loc, DeclarationName Entity);
QualType BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
SourceLocation Loc, DeclarationName Entity);
QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
Expr *ArraySize, unsigned Quals,
SourceRange Brackets, DeclarationName Entity);
- QualType BuildExtVectorType(QualType T, ExprArg ArraySize,
+ QualType BuildExtVectorType(QualType T, ExprArg ArraySize,
SourceLocation AttrLoc);
QualType BuildFunctionType(QualType T,
QualType *ParamTypes, unsigned NumParamTypes,
bool Variadic, unsigned Quals,
SourceLocation Loc, DeclarationName Entity);
- QualType BuildMemberPointerType(QualType T, QualType Class,
- unsigned Quals, SourceLocation Loc,
+ QualType BuildMemberPointerType(QualType T, QualType Class,
+ unsigned Quals, SourceLocation Loc,
DeclarationName Entity);
QualType BuildBlockPointerType(QualType T, unsigned Quals,
SourceLocation Loc, DeclarationName Entity);
@@ -487,32 +487,32 @@ public:
bool RequireCompleteType(SourceLocation Loc, QualType T,
const PartialDiagnostic &PD);
-
+
QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T);
QualType BuildTypeofExprType(Expr *E);
QualType BuildDecltypeType(Expr *E);
-
+
//===--------------------------------------------------------------------===//
// Symbol table / Decl tracking callbacks: SemaDecl.cpp.
//
/// getDeclName - Return a pretty name for the specified decl if possible, or
- /// an empty string if not. This is used for pretty crash reporting.
+ /// an empty string if not. This is used for pretty crash reporting.
virtual std::string getDeclName(DeclPtrTy D);
-
+
DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
- virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
+ virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS,
bool isClassName = false);
virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
-
+
virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
}
-
- DeclPtrTy HandleDeclarator(Scope *S, Declarator &D,
+
+ DeclPtrTy HandleDeclarator(Scope *S, Declarator &D,
MultiTemplateParamsArg TemplateParameterLists,
bool IsFunctionDefinition);
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl,
@@ -530,26 +530,26 @@ public:
bool &Redeclaration);
NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
QualType R, DeclaratorInfo *DInfo,
- NamedDecl* PrevDecl,
+ NamedDecl* PrevDecl,
MultiTemplateParamsArg TemplateParamLists,
bool IsFunctionDefinition,
bool &Redeclaration);
void CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
- bool &Redeclaration,
+ bool &Redeclaration,
bool &OverloadableAttrRequired);
void CheckMain(FunctionDecl *FD);
virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
virtual void ActOnParamDefaultArgument(DeclPtrTy param,
SourceLocation EqualLoc,
ExprArg defarg);
- virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
+ virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
SourceLocation EqualLoc,
SourceLocation ArgLoc);
virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
bool SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
SourceLocation EqualLoc);
-
+
// Contains the locations of the beginning of unparsed default
// argument locations.
llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs;
@@ -570,19 +570,19 @@ public:
virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body);
DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body,
bool IsInstantiation);
-
+
/// \brief Diagnose any unused parameters in the given sequence of
/// ParmVarDecl pointers.
template<typename InputIterator>
void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) {
for (; Param != ParamEnd; ++Param) {
- if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
+ if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
!(*Param)->template hasAttr<UnusedAttr>())
Diag((*Param)->getLocation(), diag::warn_unused_parameter)
<< (*Param)->getDeclName();
}
}
-
+
void DiagnoseInvalidJumps(Stmt *Body);
virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
@@ -593,13 +593,13 @@ public:
/// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
/// no declarator (e.g. "struct foo;") is parsed.
virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS);
-
+
bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
RecordDecl *AnonRecord);
- virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
+ virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
RecordDecl *Record);
- bool isAcceptableTagRedeclaration(const TagDecl *Previous,
+ bool isAcceptableTagRedeclaration(const TagDecl *Previous,
TagDecl::TagKind NewTag,
SourceLocation NewTagLoc,
const IdentifierInfo &Name);
@@ -610,7 +610,7 @@ public:
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,
bool &OwnedDecl);
-
+
virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
IdentifierInfo *ClassName,
llvm::SmallVectorImpl<DeclPtrTy> &Decls);
@@ -623,7 +623,7 @@ public:
AccessSpecifier AS);
FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
- DeclaratorInfo *DInfo,
+ DeclaratorInfo *DInfo,
RecordDecl *Record, SourceLocation Loc,
bool Mutable, Expr *BitfieldWidth,
SourceLocation TSSL,
@@ -637,7 +637,7 @@ public:
CXXDestructor = 3
};
void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem);
-
+
virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
DeclPtrTy IntfDecl,
Declarator &D, ExprTy *BitfieldWidth,
@@ -680,19 +680,19 @@ public:
/// Set the current declaration context until it gets popped.
void PushDeclContext(Scope *S, DeclContext *DC);
void PopDeclContext();
-
+
/// EnterDeclaratorContext - Used when we must lookup names in the context
/// of a declarator's nested name specifier.
void EnterDeclaratorContext(Scope *S, DeclContext *DC);
void ExitDeclaratorContext(Scope *S);
-
+
DeclContext *getFunctionLevelDeclContext();
-
+
/// getCurFunctionDecl - If inside of a function body, this returns a pointer
/// to the function decl for the function being parsed. If we're currently
/// in a 'block', this returns the containing context.
FunctionDecl *getCurFunctionDecl();
-
+
/// getCurMethodDecl - If inside of a method body, this returns a pointer to
/// the method decl for the method being parsed. If we're currently
/// in a 'block', this returns the containing context.
@@ -736,9 +736,9 @@ public:
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
/// C++ Overloading.
- bool IsOverload(FunctionDecl *New, Decl* OldD,
+ bool IsOverload(FunctionDecl *New, Decl* OldD,
OverloadedFunctionDecl::function_iterator &MatchedDecl);
- ImplicitConversionSequence
+ ImplicitConversionSequence
TryImplicitConversion(Expr* From, QualType ToType,
bool SuppressUserConversions,
bool AllowExplicit,
@@ -761,20 +761,20 @@ public:
bool CheckMemberPointerConversion(Expr *From, QualType ToType,
CastExpr::CastKind &Kind);
bool IsQualificationConversion(QualType FromType, QualType ToType);
- bool IsUserDefinedConversion(Expr *From, QualType ToType,
+ bool IsUserDefinedConversion(Expr *From, QualType ToType,
UserDefinedConversionSequence& User,
bool AllowConversionFunctions,
bool AllowExplicit, bool ForceRValue);
- ImplicitConversionSequence::CompareKind
+ ImplicitConversionSequence::CompareKind
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
const ImplicitConversionSequence& ICS2);
- ImplicitConversionSequence::CompareKind
+ ImplicitConversionSequence::CompareKind
CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
const StandardConversionSequence& SCS2);
- ImplicitConversionSequence::CompareKind
+ ImplicitConversionSequence::CompareKind
CompareQualificationConversions(const StandardConversionSequence& SCS1,
const StandardConversionSequence& SCS2);
@@ -782,11 +782,11 @@ public:
CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
const StandardConversionSequence& SCS2);
- ImplicitConversionSequence
+ ImplicitConversionSequence
TryCopyInitialization(Expr* From, QualType ToType,
bool SuppressUserConversions, bool ForceRValue,
bool InOverloadResolution);
- bool PerformCopyInitialization(Expr *&From, QualType ToType,
+ bool PerformCopyInitialization(Expr *&From, QualType ToType,
const char *Flavor, bool Elidable = false);
ImplicitConversionSequence
@@ -795,7 +795,7 @@ public:
ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
bool PerformContextuallyConvertToBool(Expr *&From);
-
+
bool PerformObjectMemberConversion(Expr *&From, NamedDecl *Member);
/// OverloadingResult - Capture the result of performing overload
@@ -814,7 +814,7 @@ public:
typedef llvm::SmallPtrSet<AnyFunctionDecl, 16> FunctionSet;
typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
- void AddOverloadCandidate(FunctionDecl *Function,
+ void AddOverloadCandidate(FunctionDecl *Function,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions = false,
@@ -864,13 +864,13 @@ public:
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
SourceRange OpRange = SourceRange());
- void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
+ void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool IsAssignmentOperator = false,
unsigned NumContextualBoolArguments = 0);
- void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
- Expr **Args, unsigned NumArgs,
+ void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
+ Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet);
void AddArgumentDependentLookupCandidates(DeclarationName Name,
Expr **Args, unsigned NumArgs,
@@ -882,7 +882,7 @@ public:
OverloadCandidateSet::iterator& Best);
void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
bool OnlyViable);
-
+
FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
bool Complain);
void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn);
@@ -894,7 +894,7 @@ public:
unsigned NumExplicitTemplateArgs,
SourceLocation LParenLoc,
Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
+ SourceLocation *CommaLocs,
SourceLocation RParenLoc,
bool &ArgumentDependentLookup);
@@ -910,18 +910,18 @@ public:
ExprResult
BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
- SourceLocation LParenLoc, Expr **Args,
+ SourceLocation LParenLoc, Expr **Args,
unsigned NumArgs, SourceLocation *CommaLocs,
SourceLocation RParenLoc);
- ExprResult
+ ExprResult
BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
+ SourceLocation *CommaLocs,
SourceLocation RParenLoc);
OwningExprResult BuildOverloadedArrowExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc);
-
+
/// Helpers for dealing with blocks and functions.
void CheckFallThroughForFunctionDef(Decl *D, Stmt *Body);
void CheckFallThroughForBlock(QualType BlockTy, Stmt *Body);
@@ -941,7 +941,7 @@ public:
/// overloaded operator names, constructor names, etc.) into zero or
/// more declarations within a particular scope. The major entry
/// points are LookupName, which performs unqualified name lookup,
- /// and LookupQualifiedName, which performs qualified name lookup.
+ /// and LookupQualifiedName, which performs qualified name lookup.
///
/// All name lookup is performed based on some specific criteria,
/// which specify what names will be visible to name lookup and how
@@ -988,7 +988,7 @@ public:
LookupNamespaceName,
/// Look up an ordinary name that is going to be redeclared as a
/// name with linkage. This lookup ignores any declarations that
- /// are outside of the current scope unless they have linkage. See
+ /// are outside of the current scope unless they have linkage. See
/// C99 6.2.2p4-5 and C++ [basic.link]p6.
LookupRedeclarationWithLinkage,
/// Look up the name of an Objective-C protocol.
@@ -1005,7 +1005,7 @@ public:
/// single name lookup, which can return no result (nothing found),
/// a single declaration, a set of overloaded functions, or an
/// ambiguity. Use the getKind() method to determine which of these
- /// results occurred for a given lookup.
+ /// results occurred for a given lookup.
///
/// Any non-ambiguous lookup can be converted into a single
/// (possibly NULL) @c NamedDecl* via a conversion function or the
@@ -1085,7 +1085,7 @@ public:
/// struct A { void f(int); }
/// struct B { void f(double); }
/// struct C : A, B { };
- /// void test(C c) {
+ /// void test(C c) {
/// c.f(0); // error: A::f and B::f come from subobjects of different
/// // types. overload resolution is not performed.
/// }
@@ -1124,15 +1124,15 @@ public:
static LookupResult CreateLookupResult(ASTContext &Context, NamedDecl *D);
- static LookupResult CreateLookupResult(ASTContext &Context,
- IdentifierResolver::iterator F,
+ static LookupResult CreateLookupResult(ASTContext &Context,
+ IdentifierResolver::iterator F,
IdentifierResolver::iterator L);
- static LookupResult CreateLookupResult(ASTContext &Context,
- DeclContext::lookup_iterator F,
+ static LookupResult CreateLookupResult(ASTContext &Context,
+ DeclContext::lookup_iterator F,
DeclContext::lookup_iterator L);
- static LookupResult CreateLookupResult(ASTContext &Context, BasePaths *Paths,
+ static LookupResult CreateLookupResult(ASTContext &Context, BasePaths *Paths,
bool DifferentSubobjectTypes) {
LookupResult Result;
Result.StoredKind = AmbiguousLookupStoresBasePaths;
@@ -1252,37 +1252,37 @@ public:
case Sema::LookupObjCImplementationName:
case Sema::LookupObjCCategoryImplName:
return D->isInIdentifierNamespace(IDNS);
-
+
case Sema::LookupOperatorName:
- return D->isInIdentifierNamespace(IDNS) &&
+ return D->isInIdentifierNamespace(IDNS) &&
!D->getDeclContext()->isRecord();
case Sema::LookupNestedNameSpecifierName:
return isa<TypedefDecl>(D) || D->isInIdentifierNamespace(Decl::IDNS_Tag);
-
+
case Sema::LookupNamespaceName:
return isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D);
}
-
- assert(false &&
+
+ assert(false &&
"isAcceptableLookupResult always returns before this point");
return false;
}
- LookupResult LookupName(Scope *S, DeclarationName Name,
- LookupNameKind NameKind,
+ LookupResult LookupName(Scope *S, DeclarationName Name,
+ LookupNameKind NameKind,
bool RedeclarationOnly = false,
bool AllowBuiltinCreation = false,
SourceLocation Loc = SourceLocation());
LookupResult LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
- LookupNameKind NameKind,
+ LookupNameKind NameKind,
bool RedeclarationOnly = false);
Decl *LookupQualifiedNameWithType(DeclContext *LookupCtx,
DeclarationName Name,
QualType T);
- LookupResult LookupParsedName(Scope *S, const CXXScopeSpec *SS,
+ LookupResult LookupParsedName(Scope *S, const CXXScopeSpec *SS,
DeclarationName Name,
- LookupNameKind NameKind,
+ LookupNameKind NameKind,
bool RedeclarationOnly = false,
bool AllowBuiltinCreation = false,
SourceLocation Loc = SourceLocation(),
@@ -1292,9 +1292,9 @@ public:
ObjCCategoryImplDecl *LookupObjCCategoryImpl(IdentifierInfo *II);
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
- QualType T1, QualType T2,
+ QualType T1, QualType T2,
FunctionSet &Functions);
-
+
void ArgumentDependentLookup(DeclarationName Name,
Expr **Args, unsigned NumArgs,
FunctionSet &Functions);
@@ -1304,12 +1304,12 @@ public:
AssociatedClassSet &AssociatedClasses);
bool DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
- SourceLocation NameLoc,
+ SourceLocation NameLoc,
SourceRange LookupRange = SourceRange());
//@}
-
+
ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id);
- NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
+ NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
Scope *S, bool ForRedeclaration,
SourceLocation Loc);
NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
@@ -1318,7 +1318,7 @@ public:
// More parsing and symbol table subroutines.
- // Decl attributes - this routine is the top level dispatcher.
+ // Decl attributes - this routine is the top level dispatcher.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AttrList);
@@ -1328,10 +1328,10 @@ public:
ObjCMethodDecl *IntfMethod);
NamespaceDecl *GetStdNamespace();
-
+
bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
ObjCInterfaceDecl *IDecl);
-
+
/// CheckProtocolMethodDefs - This routine checks unimplemented
/// methods declared in protocol, and those referenced by it.
/// \param IDecl - Used for checking for methods which may have been
@@ -1342,24 +1342,24 @@ public:
const llvm::DenseSet<Selector> &InsMap,
const llvm::DenseSet<Selector> &ClsMap,
ObjCInterfaceDecl *IDecl);
-
+
/// CheckImplementationIvars - This routine checks if the instance variables
- /// listed in the implelementation match those listed in the interface.
+ /// listed in the implelementation match those listed in the interface.
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
ObjCIvarDecl **Fields, unsigned nIvars,
SourceLocation Loc);
-
+
/// ImplMethodsVsClassMethods - This is main routine to warn if any method
/// remains unimplemented in the class or category @implementation.
- void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
- ObjCContainerDecl* IDecl,
+ void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
+ ObjCContainerDecl* IDecl,
bool IncompleteImpl = false);
-
+
/// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
/// true, or false, accordingly.
- bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
+ bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
const ObjCMethodDecl *PrevMethod,
- bool matchBasedOnSizeAndAlignment = false);
+ bool matchBasedOnSizeAndAlignment = false);
/// MatchAllMethodDeclarations - Check methods declaraed in interface or
/// or protocol against those declared in their implementations.
@@ -1377,7 +1377,7 @@ public:
/// a selector with a method declaraation for purposes of typechecking
/// messages sent to "id" (where the class of the object is unknown).
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method);
-
+
/// LookupInstanceMethodInGlobalPool - Returns the method and warns if
/// there are multiple signatures.
ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
@@ -1386,7 +1386,7 @@ public:
/// LookupFactoryMethodInGlobalPool - Returns the method and warns if
/// there are multiple signatures.
ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R);
-
+
/// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method);
//===--------------------------------------------------------------------===//
@@ -1405,7 +1405,7 @@ public:
SourceLocation DotDotDotLoc, ExprArg RHSVal,
SourceLocation ColonLoc);
virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt);
-
+
virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
SourceLocation ColonLoc,
StmtArg SubStmt, Scope *CurScope);
@@ -1413,13 +1413,13 @@ public:
IdentifierInfo *II,
SourceLocation ColonLoc,
StmtArg SubStmt);
- virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
- FullExprArg CondVal, StmtArg ThenVal,
+ virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
+ FullExprArg CondVal, StmtArg ThenVal,
SourceLocation ElseLoc, StmtArg ElseVal);
virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond);
virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
StmtArg Switch, StmtArg Body);
- virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
+ virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
FullExprArg Cond, StmtArg Body);
virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
SourceLocation WhileLoc,
@@ -1477,7 +1477,7 @@ public:
StmtArg Catch, StmtArg Finally);
virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
- ExprArg Throw,
+ ExprArg Throw,
Scope *CurScope);
virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
ExprArg SynchExpr,
@@ -1501,26 +1501,26 @@ public:
/// DiagnoseUnusedExprResult - If the statement passed in is an expression
/// whose result is unused, warn.
void DiagnoseUnusedExprResult(const Stmt *S);
-
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
- bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
+ bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
ObjCMethodDecl *Getter,
SourceLocation Loc);
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
Expr **Args, unsigned NumArgs);
- virtual ExpressionEvaluationContext
+ virtual ExpressionEvaluationContext
PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
-
- virtual void
+
+ virtual void
PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
ExpressionEvaluationContext NewContext);
-
+
void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
-
+
// Primary Expressions.
virtual SourceRange getExprRange(ExprTy *E) const;
@@ -1541,8 +1541,8 @@ public:
bool HasTrailingLParen,
const CXXScopeSpec &SS,
bool isAddressOfOperand);
- OwningExprResult BuildDeclRefExpr(NamedDecl *D, QualType Ty,
- SourceLocation Loc, bool TypeDependent,
+ OwningExprResult BuildDeclRefExpr(NamedDecl *D, QualType Ty,
+ SourceLocation Loc, bool TypeDependent,
bool ValueDependent,
const CXXScopeSpec *SS = 0);
VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
@@ -1559,9 +1559,9 @@ public:
bool isAddressOfOperand = false);
OwningExprResult BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
bool HasTrailingLParen,
- const CXXScopeSpec *SS,
+ const CXXScopeSpec *SS,
bool isAddressOfOperand);
-
+
virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
tok::TokenKind Kind);
virtual OwningExprResult ActOnNumericConstant(const Token &);
@@ -1571,7 +1571,7 @@ public:
virtual OwningExprResult ActOnParenListExpr(SourceLocation L,
SourceLocation R,
MultiExprArg Val);
-
+
/// ActOnStringLiteral - The specified tokens were lexed as pasted string
/// fragments (e.g. "foo" "bar" L"baz").
virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
@@ -1579,19 +1579,19 @@ public:
// Binary/Unary Operators. 'Tok' is the token for the operator.
OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
- unsigned OpcIn,
+ unsigned OpcIn,
ExprArg InputArg);
virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
tok::TokenKind Op, ExprArg Input);
- OwningExprResult CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
+ OwningExprResult CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
bool isSizeOf, SourceRange R);
- OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
+ OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
bool isSizeOf, SourceRange R);
virtual OwningExprResult
ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
void *TyOrEx, const SourceRange &ArgRange);
-
+
bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R);
bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
const SourceRange &R, bool isSizeof);
@@ -1613,7 +1613,7 @@ public:
DeclPtrTy ImplDecl,
const CXXScopeSpec *SS = 0,
NamedDecl *FirstQualifierInScope = 0) {
- // FIXME: Temporary helper while we migrate existing calls to
+ // FIXME: Temporary helper while we migrate existing calls to
// BuildMemberReferenceExpr to support explicitly-specified template
// arguments.
return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, MemberLoc,
@@ -1621,7 +1621,7 @@ public:
SourceLocation(), ImplDecl, SS,
FirstQualifierInScope);
}
-
+
OwningExprResult BuildMemberReferenceExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -1635,7 +1635,7 @@ public:
DeclPtrTy ImplDecl,
const CXXScopeSpec *SS,
NamedDecl *FirstQualifierInScope = 0);
-
+
virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -1667,7 +1667,7 @@ public:
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
TypeTy *Ty, SourceLocation RParenLoc,
ExprArg Op);
-
+
OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
SourceLocation RParenLoc, ExprArg E,
@@ -1769,7 +1769,7 @@ public:
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList);
-
+
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
@@ -1786,7 +1786,7 @@ public:
DeclarationName Name,
AttributeList *AttrList,
bool IsTypeName);
-
+
virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
AccessSpecifier AS,
SourceLocation UsingLoc,
@@ -1796,8 +1796,8 @@ public:
OverloadedOperatorKind Op,
AttributeList *AttrList,
bool IsTypeName);
-
- /// AddCXXDirectInitializerToDecl - This action is called immediately after
+
+ /// AddCXXDirectInitializerToDecl - This action is called immediately after
/// ActOnDeclarator, when a C++ direct initializer is present.
/// e.g: "int x(1);"
virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
@@ -1808,73 +1808,73 @@ public:
/// InitializeVarWithConstructor - Creates an CXXConstructExpr
/// and sets it as the initializer for the the passed in VarDecl.
- bool InitializeVarWithConstructor(VarDecl *VD,
+ bool InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
- QualType DeclInitType,
+ QualType DeclInitType,
MultiExprArg Exprs);
/// BuildCXXConstructExpr - Creates a complete call to a constructor,
/// including handling of its default argument expressions.
- OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
+ OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
QualType DeclInitType,
CXXConstructorDecl *Constructor,
MultiExprArg Exprs);
// FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
// the constructor can be elidable?
- OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
+ OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc,
QualType DeclInitType,
CXXConstructorDecl *Constructor,
bool Elidable,
MultiExprArg Exprs);
-
- OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons,
- QualType writtenTy,
- SourceLocation tyBeginLoc,
+
+ OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons,
+ QualType writtenTy,
+ SourceLocation tyBeginLoc,
MultiExprArg Args,
SourceLocation rParenLoc);
-
+
/// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
/// the default expr if needed.
OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
FunctionDecl *FD,
ParmVarDecl *Param);
-
+
/// FinalizeVarWithDestructor - Prepare for calling destructor on the
/// constructed variable.
void FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType);
-
- /// DefineImplicitDefaultConstructor - Checks for feasibility of
+
+ /// DefineImplicitDefaultConstructor - Checks for feasibility of
/// defining this constructor as the default constructor.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
CXXConstructorDecl *Constructor);
-
- /// DefineImplicitDestructor - Checks for feasibility of
+
+ /// DefineImplicitDestructor - Checks for feasibility of
/// defining this destructor as the default destructor.
void DefineImplicitDestructor(SourceLocation CurrentLocation,
CXXDestructorDecl *Destructor);
-
- /// DefineImplicitCopyConstructor - Checks for feasibility of
+
+ /// DefineImplicitCopyConstructor - Checks for feasibility of
/// defining this constructor as the copy constructor.
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
CXXConstructorDecl *Constructor,
unsigned TypeQuals);
-
+
/// DefineImplicitOverloadedAssign - Checks for feasibility of
/// defining implicit this overloaded assignment operator.
- void DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
+ void DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
CXXMethodDecl *MethodDecl);
-
+
/// getAssignOperatorMethod - Returns the default copy assignmment operator
/// for the class.
CXXMethodDecl *getAssignOperatorMethod(ParmVarDecl *Decl,
- CXXRecordDecl *ClassDecl);
+ CXXRecordDecl *ClassDecl);
/// MaybeBindToTemporary - If the passed in expression has a record type with
/// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
/// it simply returns the passed in expression.
OwningExprResult MaybeBindToTemporary(Expr *E);
-
+
/// InitializationKind - Represents which kind of C++ initialization
/// [dcl.init] a routine is to perform.
enum InitializationKind {
@@ -1945,7 +1945,7 @@ public:
SourceLocation PlacementLParen,
MultiExprArg PlacementArgs,
SourceLocation PlacementRParen,
- bool ParenTypeId,
+ bool ParenTypeId,
QualType AllocType,
SourceLocation TypeLoc,
SourceRange TypeRange,
@@ -1953,7 +1953,7 @@ public:
SourceLocation ConstructorLParen,
MultiExprArg ConstructorArgs,
SourceLocation ConstructorRParen);
-
+
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
SourceRange R);
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
@@ -1990,13 +1990,13 @@ public:
SourceLocation LParen,
TypeTy *Ty,
SourceLocation RParen);
-
+
virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
TypeTy *&ObjectType);
-
+
virtual OwningExprResult
ActOnDestructorReferenceExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
@@ -2020,7 +2020,7 @@ public:
SourceLocation ClassNameLoc,
TypeTy *Ty,
const CXXScopeSpec *SS = 0);
-
+
virtual OwningExprResult
ActOnMemberTemplateIdReferenceExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
@@ -2033,19 +2033,19 @@ public:
ASTTemplateArgsPtr TemplateArgs,
SourceLocation *TemplateArgLocs,
SourceLocation RAngleLoc);
-
- /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
+
+ /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
/// non-empty, will create a new CXXExprWithTemporaries expression.
/// Otherwise, just returs the passed in expression.
Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
bool ShouldDestroyTemporaries);
-
+
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
bool RequireCompleteDeclContext(const CXXScopeSpec &SS);
-
+
DeclContext *computeDeclContext(QualType T);
- DeclContext *computeDeclContext(const CXXScopeSpec &SS,
+ DeclContext *computeDeclContext(const CXXScopeSpec &SS,
bool EnteringContext = false);
bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
@@ -2057,7 +2057,7 @@ public:
SourceLocation CCLoc);
NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
-
+
CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
@@ -2067,7 +2067,7 @@ public:
QualType ObjectType,
NamedDecl *ScopeLookupResult,
bool EnteringContext);
-
+
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
SourceLocation IdLoc,
@@ -2117,26 +2117,26 @@ public:
virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl);
// ParseObjCStringLiteral - Parse Objective-C string literals.
- virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
+ virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
ExprTy **Strings,
unsigned NumStrings);
-
- Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
+
+ Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
QualType EncodedType,
- SourceLocation RParenLoc);
+ SourceLocation RParenLoc);
virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
TypeTy *Ty,
SourceLocation RParenLoc);
-
+
// ParseObjCSelectorExpression - Build selector expression for @selector
virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
SourceLocation AtLoc,
SourceLocation SelLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
-
+
// ParseObjCProtocolExpression - Build protocol expression for @protocol
virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
SourceLocation AtLoc,
@@ -2190,25 +2190,25 @@ public:
unsigned NumArgs, SourceLocation IdLoc,
SourceLocation RParenLoc,
CXXRecordDecl *ClassDecl);
-
+
void setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
CXXBaseOrMemberInitializer **Initializers,
unsigned NumInitializers,
llvm::SmallVectorImpl<CXXBaseSpecifier *>& Bases,
llvm::SmallVectorImpl<FieldDecl *>&Members);
-
- /// computeBaseOrMembersToDestroy - Compute information in current
- /// destructor decl's AST of bases and non-static data members which will be
+
+ /// computeBaseOrMembersToDestroy - Compute information in current
+ /// destructor decl's AST of bases and non-static data members which will be
/// implicitly destroyed. We are storing the destruction in the order that
/// they should occur (which is the reverse of construction order).
void computeBaseOrMembersToDestroy(CXXDestructorDecl *Destructor);
-
+
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
- virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
+ virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
SourceLocation ColonLoc,
MemInitTy **MemInits, unsigned NumMemInits);
-
+
virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
DeclPtrTy TagDecl,
SourceLocation LBrac,
@@ -2221,10 +2221,10 @@ public:
virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
DeclPtrTy Method);
- virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
+ virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
ExprArg AssertExpr,
ExprArg AssertMessageExpr);
-
+
virtual DeclPtrTy ActOnFriendDecl(Scope *S,
llvm::PointerUnion<const DeclSpec*,Declarator*> D,
bool IsDefinition);
@@ -2249,17 +2249,17 @@ public:
CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
SourceRange SpecifierRange,
bool Virtual, AccessSpecifier Access,
- QualType BaseType,
+ QualType BaseType,
SourceLocation BaseLoc);
- virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
+ virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
SourceRange SpecifierRange,
bool Virtual, AccessSpecifier Access,
- TypeTy *basetype, SourceLocation
+ TypeTy *basetype, SourceLocation
BaseLoc);
bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
unsigned NumBases);
- virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
+ virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
unsigned NumBases);
bool IsDerivedFrom(QualType Derived, QualType Base);
@@ -2273,9 +2273,9 @@ public:
unsigned AmbigiousBaseConvID,
SourceLocation Loc, SourceRange Range,
DeclarationName Name);
-
+
std::string getAmbiguousPathsDisplayString(BasePaths &Paths);
-
+
/// CheckOverridingFunctionReturnType - Checks whether the return types are
/// covariant, according to C++ [class.virtual]p5.
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
@@ -2290,7 +2290,7 @@ public:
// C++ Access Control
//
- bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
+ bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
NamedDecl *PrevMemberDecl,
AccessSpecifier LexicalAS);
@@ -2311,12 +2311,12 @@ public:
AbstractVariableType,
AbstractFieldType
};
-
+
bool RequireNonAbstractType(SourceLocation Loc, QualType T,
const PartialDiagnostic &PD,
const CXXRecordDecl *CurrentRD = 0);
-
- bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
+
+ bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
AbstractDiagSelID SelID = AbstractNone,
const CXXRecordDecl *CurrentRD = 0);
@@ -2330,7 +2330,7 @@ public:
// C++ Templates [C++ 14]
//
virtual TemplateNameKind isTemplateName(Scope *S,
- const IdentifierInfo &II,
+ const IdentifierInfo &II,
SourceLocation IdLoc,
const CXXScopeSpec *SS,
TypeTy *ObjectType,
@@ -2339,13 +2339,13 @@ public:
bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
- virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
+ virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
SourceLocation EllipsisLoc,
SourceLocation KeyLoc,
IdentifierInfo *ParamName,
SourceLocation ParamNameLoc,
unsigned Depth, unsigned Position);
- virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam,
+ virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam,
SourceLocation EqualLoc,
SourceLocation DefaultLoc,
TypeTy *Default);
@@ -2371,7 +2371,7 @@ public:
virtual TemplateParamsTy *
ActOnTemplateParameterList(unsigned Depth,
SourceLocation ExportLoc,
- SourceLocation TemplateLoc,
+ SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
DeclPtrTy *Params, unsigned NumParams,
SourceLocation RAngleLoc);
@@ -2382,7 +2382,7 @@ public:
const CXXScopeSpec &SS,
TemplateParameterList **ParamLists,
unsigned NumParamLists);
-
+
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
@@ -2408,21 +2408,21 @@ public:
TagUseKind TUK,
DeclSpec::TST TagSpec,
SourceLocation TagLoc);
-
+
OwningExprResult BuildTemplateIdExpr(TemplateName Template,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceLocation RAngleLoc);
-
+
virtual OwningExprResult ActOnTemplateIdExpr(TemplateTy Template,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
ASTTemplateArgsPtr TemplateArgs,
SourceLocation *TemplateArgLocs,
SourceLocation RAngleLoc);
-
+
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
const IdentifierInfo &Name,
SourceLocation NameLoc,
@@ -2443,7 +2443,7 @@ public:
virtual DeclResult
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
- SourceLocation KWLoc,
+ SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
SourceLocation TemplateNameLoc,
@@ -2454,19 +2454,19 @@ public:
AttributeList *Attr,
MultiTemplateParamsArg TemplateParameterLists);
- virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
+ virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D);
-
- virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
+
+ virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D);
-
+
virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
+ ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy Template,
@@ -2478,10 +2478,10 @@ public:
AttributeList *Attr);
virtual DeclResult
- ActOnExplicitInstantiation(Scope *S,
+ ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
IdentifierInfo *Name,
@@ -2497,16 +2497,16 @@ public:
bool PartialTemplateArgs,
TemplateArgumentListBuilder &Converted);
- bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
+ bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
const TemplateArgument &Arg,
TemplateArgumentListBuilder &Converted);
bool CheckTemplateArgument(TemplateTypeParmDecl *Param, QualType Arg,
SourceLocation ArgLoc);
- bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
+ bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
NamedDecl *&Entity);
bool CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member);
- bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
+ bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
QualType InstantiatedParamType, Expr *&Arg,
TemplateArgument &Converted);
bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, DeclRefExpr *Arg);
@@ -2516,7 +2516,7 @@ public:
bool IsTemplateTemplateParm = false,
SourceLocation TemplateArgLoc
= SourceLocation());
-
+
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
/// \brief Called when the parser has parsed a C++ typename
@@ -2531,7 +2531,7 @@ public:
const IdentifierInfo &II, SourceLocation IdLoc);
/// \brief Called when the parser has parsed a C++ typename
- /// specifier that ends in a template-id, e.g.,
+ /// specifier that ends in a template-id, e.g.,
/// "typename MetaFun::template apply<T1, T2>".
///
/// \param TypenameLoc the location of the 'typename' keyword
@@ -2583,10 +2583,10 @@ public:
/// produces a type that does not match the original template
/// arguments provided.
TDK_NonDeducedMismatch,
- /// \brief When performing template argument deduction for a function
+ /// \brief When performing template argument deduction for a function
/// template, there were too many call arguments.
TDK_TooManyArguments,
- /// \brief When performing template argument deduction for a function
+ /// \brief When performing template argument deduction for a function
/// template, there were too few call arguments.
TDK_TooFewArguments,
/// \brief The explicitly-specified template arguments were not valid
@@ -2617,7 +2617,7 @@ public:
}
/// \brief Take ownership of the deduced template argument list.
- TemplateArgumentList *take() {
+ TemplateArgumentList *take() {
TemplateArgumentList *Result = Deduced;
Deduced = 0;
return Result;
@@ -2670,7 +2670,7 @@ public:
DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
const TemplateArgumentList &TemplateArgs,
TemplateDeductionInfo &Info);
-
+
TemplateDeductionResult
SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
const TemplateArgument *ExplicitTemplateArgs,
@@ -2679,13 +2679,13 @@ public:
llvm::SmallVectorImpl<QualType> &ParamTypes,
QualType *FunctionType,
TemplateDeductionInfo &Info);
-
- TemplateDeductionResult
+
+ TemplateDeductionResult
FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
llvm::SmallVectorImpl<TemplateArgument> &Deduced,
FunctionDecl *&Specialization,
TemplateDeductionInfo &Info);
-
+
TemplateDeductionResult
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
bool HasExplicitTemplateArgs,
@@ -2703,7 +2703,7 @@ public:
QualType ArgFunctionType,
FunctionDecl *&Specialization,
TemplateDeductionInfo &Info);
-
+
TemplateDeductionResult
DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
QualType ToType,
@@ -2716,7 +2716,7 @@ public:
void MarkDeducedTemplateParameters(const TemplateArgumentList &TemplateArgs,
llvm::SmallVectorImpl<bool> &Deduced);
-
+
//===--------------------------------------------------------------------===//
// C++ Template Instantiation
//
@@ -2743,10 +2743,10 @@ public:
/// provides the template arguments as specified.
DefaultFunctionArgumentInstantiation,
- /// We are substituting explicit template arguments provided for
+ /// We are substituting explicit template arguments provided for
/// a function template. The entity is a FunctionTemplateDecl.
ExplicitTemplateArgumentSubstitution,
-
+
/// We are substituting template argument determined as part of
/// template argument deduction for either a class template
/// partial specialization or a function template. The
@@ -2793,7 +2793,7 @@ public:
case DeducedTemplateArgumentSubstitution:
case DefaultFunctionArgumentInstantiation:
return X.TemplateArgs == Y.TemplateArgs;
-
+
}
return true;
@@ -2811,7 +2811,7 @@ public:
/// requires another template instantiation, additional
/// instantiations are pushed onto the stack up to a
/// user-configurable limit LangOptions::InstantiationDepth.
- llvm::SmallVector<ActiveTemplateInstantiation, 16>
+ llvm::SmallVector<ActiveTemplateInstantiation, 16>
ActiveTemplateInstantiations;
/// \brief The last template from which a template instantiation
@@ -2857,7 +2857,7 @@ public:
unsigned NumTemplateArgs,
ActiveTemplateInstantiation::InstantiationKind Kind,
SourceRange InstantiationRange = SourceRange());
-
+
/// \brief Note that we are instantiating as part of template
/// argument deduction for a class template partial
/// specialization.
@@ -2891,7 +2891,7 @@ public:
InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
- InstantiatingTemplate&
+ InstantiatingTemplate&
operator=(const InstantiatingTemplate&); // not implemented
};
@@ -2918,8 +2918,8 @@ public:
~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; }
/// \brief Determine whether any SFINAE errors have been trapped.
- bool hasErrorOccurred() const {
- return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
+ bool hasErrorOccurred() const {
+ return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
}
};
@@ -2961,7 +2961,7 @@ public:
public:
LocalInstantiationScope(Sema &SemaRef)
- : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) {
+ : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) {
SemaRef.CurrentInstantiationScope = this;
}
@@ -2996,34 +2996,34 @@ public:
/// \brief An entity for which implicit template instantiation is required.
///
- /// The source location associated with the declaration is the first place in
+ /// The source location associated with the declaration is the first place in
/// the source code where the declaration was "used". It is not necessarily
- /// the point of instantiation (which will be either before or after the
+ /// the point of instantiation (which will be either before or after the
/// namespace-scope declaration that triggered this implicit instantiation),
/// However, it is the location that diagnostics should generally refer to,
/// because users will need to know what code triggered the instantiation.
typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
-
+
/// \brief The queue of implicit template instantiations that are required
/// but have not yet been performed.
std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations;
void PerformPendingImplicitInstantiations();
-
- QualType SubstType(QualType T,
+
+ QualType SubstType(QualType T,
const MultiLevelTemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity);
-
- OwningExprResult SubstExpr(Expr *E,
+
+ OwningExprResult SubstExpr(Expr *E,
const MultiLevelTemplateArgumentList &TemplateArgs);
- OwningStmtResult SubstStmt(Stmt *S,
+ OwningStmtResult SubstStmt(Stmt *S,
const MultiLevelTemplateArgumentList &TemplateArgs);
Decl *SubstDecl(Decl *D, DeclContext *Owner,
const MultiLevelTemplateArgumentList &TemplateArgs);
- bool
+ bool
SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const MultiLevelTemplateArgumentList &TemplateArgs);
@@ -3035,7 +3035,7 @@ public:
TemplateSpecializationKind TSK,
bool Complain = true);
- bool
+ bool
InstantiateClassTemplateSpecialization(
ClassTemplateSpecializationDecl *ClassTemplateSpec,
TemplateSpecializationKind TSK,
@@ -3073,10 +3073,10 @@ public:
void InstantiateMemInitializers(CXXConstructorDecl *New,
const CXXConstructorDecl *Tmpl,
const MultiLevelTemplateArgumentList &TemplateArgs);
-
+
NamedDecl *FindInstantiatedDecl(NamedDecl *D);
DeclContext *FindInstantiatedContext(DeclContext *DC);
-
+
// Objective-C declarations.
virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
IdentifierInfo *ClassName,
@@ -3087,7 +3087,7 @@ public:
unsigned NumProtoRefs,
SourceLocation EndProtoLoc,
AttributeList *AttrList);
-
+
virtual DeclPtrTy ActOnCompatiblityAlias(
SourceLocation AtCompatibilityAliasLoc,
IdentifierInfo *AliasName, SourceLocation AliasLocation,
@@ -3097,14 +3097,14 @@ public:
IdentifierInfo *PName,
SourceLocation &PLoc, SourceLocation PrevLoc,
const ObjCList<ObjCProtocolDecl> &PList);
-
+
virtual DeclPtrTy ActOnStartProtocolInterface(
SourceLocation AtProtoInterfaceLoc,
IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
SourceLocation EndProtoLoc,
AttributeList *AttrList);
-
+
virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
IdentifierInfo *ClassName,
SourceLocation ClassLoc,
@@ -3113,82 +3113,82 @@ public:
const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
SourceLocation EndProtoLoc);
-
+
virtual DeclPtrTy ActOnStartClassImplementation(
SourceLocation AtClassImplLoc,
IdentifierInfo *ClassName, SourceLocation ClassLoc,
- IdentifierInfo *SuperClassname,
+ IdentifierInfo *SuperClassname,
SourceLocation SuperClassLoc);
-
+
virtual DeclPtrTy ActOnStartCategoryImplementation(
SourceLocation AtCatImplLoc,
- IdentifierInfo *ClassName,
+ IdentifierInfo *ClassName,
SourceLocation ClassLoc,
IdentifierInfo *CatName,
SourceLocation CatLoc);
-
+
virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
IdentifierInfo **IdentList,
unsigned NumElts);
-
+
virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
const IdentifierLocPair *IdentList,
unsigned NumElts,
AttributeList *attrList);
-
+
virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
const IdentifierLocPair *ProtocolId,
unsigned NumProtocols,
llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
-
- /// Ensure attributes are consistent with type.
+
+ /// Ensure attributes are consistent with type.
/// \param [in, out] Attributes The attributes to check; they will
/// be modified to be consistent with \arg PropertyTy.
- void CheckObjCPropertyAttributes(QualType PropertyTy,
+ void CheckObjCPropertyAttributes(QualType PropertyTy,
SourceLocation Loc,
unsigned &Attributes);
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
- void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
+ void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
ObjCPropertyDecl *SuperProperty,
const IdentifierInfo *Name);
void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
-
- void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
+
+ void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
ObjCMethodDecl *MethodDecl,
bool IsInstance);
-
+
void MergeProtocolPropertiesIntoClass(Decl *CDecl,
DeclPtrTy MergeProtocols);
-
- void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
+
+ void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
ObjCInterfaceDecl *ID);
-
+
void MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
ObjCProtocolDecl *PDecl);
-
+
virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
DeclPtrTy *allMethods = 0, unsigned allNum = 0,
DeclPtrTy *allProperties = 0, unsigned pNum = 0,
DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
-
+
virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
FieldDeclarator &FD, ObjCDeclSpec &ODS,
Selector GetterSel, Selector SetterSel,
DeclPtrTy ClassCategory,
bool *OverridingProperty,
tok::ObjCKeywordKind MethodImplKind);
-
- virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc,
+
+ virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc,
SourceLocation PropertyLoc,
bool ImplKind,DeclPtrTy ClassImplDecl,
IdentifierInfo *PropertyId,
IdentifierInfo *PropertyIvar);
-
+
virtual DeclPtrTy ActOnMethodDeclaration(
SourceLocation BeginLoc, // location of the + or -.
SourceLocation EndLoc, // location of the ; or {.
- tok::TokenKind MethodType,
- DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
+ tok::TokenKind MethodType,
+ DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
Selector Sel,
// optional arguments. The number of types/arguments is obtained
// from the Sel.getNumArgs().
@@ -3201,24 +3201,24 @@ public:
// Will search "local" class/category implementations for a method decl.
// Will also search in class's root looking for instance method.
// Returns 0 if no method is found.
- ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
+ ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
ObjCInterfaceDecl *CDecl);
ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
ObjCInterfaceDecl *ClassDecl);
-
+
virtual OwningExprResult ActOnClassPropertyRefExpr(
IdentifierInfo &receiverName,
IdentifierInfo &propertyName,
SourceLocation &receiverNameLoc,
SourceLocation &propertyNameLoc);
-
+
// ActOnClassMessage - used for both unary and keyword messages.
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from NumArgs.
virtual ExprResult ActOnClassMessage(
Scope *S,
- IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac,
- SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac,
+ IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac,
+ SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac,
ExprTy **ArgExprs, unsigned NumArgs);
// ActOnInstanceMessage - used for both unary and keyword messages.
@@ -3226,21 +3226,21 @@ public:
// is obtained from NumArgs.
virtual ExprResult ActOnInstanceMessage(
ExprTy *receiver, Selector Sel,
- SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac,
+ SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac,
ExprTy **ArgExprs, unsigned NumArgs);
-
+
/// ActOnPragmaPack - Called on well formed #pragma pack(...).
virtual void ActOnPragmaPack(PragmaPackKind Kind,
IdentifierInfo *Name,
ExprTy *Alignment,
- SourceLocation PragmaLoc,
+ SourceLocation PragmaLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
-
+
/// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
virtual void ActOnPragmaUnused(const Token *Identifiers,
unsigned NumIdentifiers, Scope *curScope,
- SourceLocation PragmaLoc,
+ SourceLocation PragmaLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc);
@@ -3262,28 +3262,28 @@ public:
/// getPragmaPackAlignment() - Return the current alignment as specified by
/// the current #pragma pack directive, or 0 if none is currently active.
unsigned getPragmaPackAlignment() const;
-
+
/// FreePackedContext - Deallocate and null out PackContext.
void FreePackedContext();
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
/// cast. If there is already an implicit cast, merge into the existing one.
/// If isLvalue, the result of the cast is an lvalue.
- void ImpCastExprToType(Expr *&Expr, QualType Type,
- const CastExpr::CastInfo &Info =
+ void ImpCastExprToType(Expr *&Expr, QualType Type,
+ const CastExpr::CastInfo &Info =
CastExpr::CastInfo(CastExpr::CK_Unknown),
bool isLvalue = false);
// UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
// functions and arrays to their respective pointers (C99 6.3.2.1).
- Expr *UsualUnaryConversions(Expr *&expr);
+ Expr *UsualUnaryConversions(Expr *&expr);
// DefaultFunctionArrayConversion - converts functions and arrays
- // to their respective pointers (C99 6.3.2.1).
+ // to their respective pointers (C99 6.3.2.1).
void DefaultFunctionArrayConversion(Expr *&expr);
-
+
// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
- // do not have a prototype. Integer promotions are performed on each
+ // do not have a prototype. Integer promotions are performed on each
// argument, and arguments that have type float are promoted to double.
void DefaultArgumentPromotion(Expr *&Expr);
@@ -3294,19 +3294,19 @@ public:
VariadicMethod,
VariadicConstructor
};
-
+
// DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
// will warn if the resulting type is not a POD type.
bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT);
-
+
// UsualArithmeticConversions - performs the UsualUnaryConversions on it's
// operands and then handles various conversions that are common to binary
// operators (C99 6.3.1.8). If both operands aren't arithmetic, this
- // routine returns the first non-arithmetic type found. The client is
+ // routine returns the first non-arithmetic type found. The client is
// responsible for emitting appropriate error diagnostics.
QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
bool isCompAssign = false);
-
+
/// AssignConvertType - All of the 'assignment' semantic checks return this
/// enum to indicate whether the assignment was allowed. These checks are
/// done for simple assignments, as well as initialization, return from
@@ -3315,15 +3315,15 @@ public:
enum AssignConvertType {
/// Compatible - the types are compatible according to the standard.
Compatible,
-
+
/// PointerToInt - The assignment converts a pointer to an int, which we
/// accept as an extension.
PointerToInt,
-
+
/// IntToPointer - The assignment converts an int to a pointer, which we
/// accept as an extension.
IntToPointer,
-
+
/// FunctionVoidPointer - The assignment is between a function pointer and
/// void*, which the standard doesn't allow, but we accept as an extension.
FunctionVoidPointer,
@@ -3345,25 +3345,25 @@ public:
/// IncompatibleVectors - The assignment is between two vector types that
/// have the same size, which we accept as an extension.
IncompatibleVectors,
-
- /// IntToBlockPointer - The assignment converts an int to a block
+
+ /// IntToBlockPointer - The assignment converts an int to a block
/// pointer. We disallow this.
IntToBlockPointer,
- /// IncompatibleBlockPointer - The assignment is between two block
+ /// IncompatibleBlockPointer - The assignment is between two block
/// pointers types that are not compatible.
IncompatibleBlockPointer,
-
+
/// IncompatibleObjCQualifiedId - The assignment is between a qualified
/// id type and something else (that is incompatible with it). For example,
/// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
IncompatibleObjCQualifiedId,
-
+
/// Incompatible - We reject this conversion outright, it is invalid to
/// represent it in the AST.
Incompatible
};
-
+
/// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
/// assignment conversion type specified by ConvTy. This returns true if the
/// conversion was invalid or false if the conversion was accepted.
@@ -3371,39 +3371,39 @@ public:
SourceLocation Loc,
QualType DstType, QualType SrcType,
Expr *SrcExpr, const char *Flavor);
-
- /// CheckAssignmentConstraints - Perform type checking for assignment,
- /// argument passing, variable initialization, and function return values.
+
+ /// CheckAssignmentConstraints - Perform type checking for assignment,
+ /// argument passing, variable initialization, and function return values.
/// This routine is only used by the following two methods. C99 6.5.16.
AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
-
- // CheckSingleAssignmentConstraints - Currently used by
- // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
+
+ // CheckSingleAssignmentConstraints - Currently used by
+ // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
// this routine performs the default function/array converions.
- AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
+ AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
Expr *&rExpr);
// \brief If the lhs type is a transparent union, check whether we
// can initialize the transparent union with the given expression.
- AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
+ AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
Expr *&rExpr);
-
+
// Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
- AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
+ AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
QualType rhsType);
-
+
// Helper function for CheckAssignmentConstraints involving two
// block pointer types.
- AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
+ AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
QualType rhsType);
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
+ bool PerformImplicitConversion(Expr *&From, QualType ToType,
const char *Flavor,
bool AllowExplicit = false,
bool Elidable = false);
- bool PerformImplicitConversion(Expr *&From, QualType ToType,
+ bool PerformImplicitConversion(Expr *&From, QualType ToType,
const ImplicitConversionSequence& ICS,
const char *Flavor);
bool PerformImplicitConversion(Expr *&From, QualType ToType,
@@ -3450,7 +3450,7 @@ public:
inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
inline QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
SourceLocation l, bool isRel);
-
+
/// type checking unary operators (subroutines of ActOnUnaryOp).
/// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
@@ -3458,20 +3458,20 @@ public:
QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal);
-
+
/// type checking primary expressions.
QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
- const IdentifierInfo *Comp,
+ const IdentifierInfo *Comp,
SourceLocation CmpLoc);
-
+
/// type checking declaration initializers (C99 6.7.8)
-
+
bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType,
SourceLocation InitLoc,DeclarationName InitEntity,
bool DirectInit);
bool CheckInitList(InitListExpr *&InitList, QualType &DeclType);
bool CheckForConstantInitializer(Expr *e, QualType t);
-
+
bool CheckValueInitialization(QualType Type, SourceLocation Loc);
// type checking C++ declaration initializers (C++ [dcl.init]).
@@ -3509,17 +3509,17 @@ public:
/// CheckCastTypes - Check type constraints for casting between types under
/// C semantics, or forward to CXXCheckCStyleCast in C++.
bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
- CastExpr::CastKind &Kind,
+ CastExpr::CastKind &Kind,
CXXMethodDecl *& ConversionDecl,
bool FunctionalStyle = false);
- // CheckVectorCast - check type constraints for vectors.
+ // CheckVectorCast - check type constraints for vectors.
// Since vectors are an extension, there are no C standard reference for this.
// We allow casting between vectors and integer datatypes of the same size.
// returns true if the cast is invalid
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty);
-
- // CheckExtVectorCast - check type constraints for extended vectors.
+
+ // CheckExtVectorCast - check type constraints for extended vectors.
// Since vectors are an extension, there are no C standard reference for this.
// We allow casting between vectors and integer datatypes of the same size,
// or vectors and the element type of that vector.
@@ -3532,14 +3532,14 @@ public:
CastExpr::CastKind &Kind, bool FunctionalStyle,
CXXMethodDecl *&ConversionDecl);
- /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
+ /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
/// \param Method - May be null.
/// \param [out] ReturnType - The return type of the send.
/// \return true iff there were any incompatible types.
bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
ObjCMethodDecl *Method, bool isClassMessage,
SourceLocation lbrac, SourceLocation rbrac,
- QualType &ReturnType);
+ QualType &ReturnType);
/// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
bool CheckCXXBooleanCondition(Expr *&CondExpr);
@@ -3547,10 +3547,10 @@ public:
/// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
/// the specified width and sign. If an overflow occurs, detect it and emit
/// the specified diagnostic.
- void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
+ void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
unsigned NewWidth, bool NewSign,
SourceLocation Loc, unsigned DiagID);
-
+
/// Checks that the Objective-C declaration is declared in the global scope.
/// Emits an error and marks the declaration as invalid if it's not declared
/// in the global scope.
@@ -3564,22 +3564,22 @@ public:
bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
/// VerifyBitField - verifies that a bit field expression is an ICE and has
- /// the correct width, and that the field type is valid.
+ /// the correct width, and that the field type is valid.
/// Returns false on success.
/// Can optionally return whether the bit-field is of width 0
- bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
- QualType FieldTy, const Expr *BitWidth,
+ bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
+ QualType FieldTy, const Expr *BitWidth,
bool *ZeroWidth = 0);
void DiagnoseMissingMember(SourceLocation MemberLoc, DeclarationName Member,
NestedNameSpecifier *NNS, SourceRange Range);
-
+
//===--------------------------------------------------------------------===//
// Extra semantic analysis beyond the C type system
private:
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
-
+
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
unsigned ByteNo) const;
bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
@@ -3597,7 +3597,7 @@ public:
Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
private:
- bool SemaBuiltinPrefetch(CallExpr *TheCall);
+ bool SemaBuiltinPrefetch(CallExpr *TheCall);
bool SemaBuiltinObjectSize(CallExpr *TheCall);
bool SemaBuiltinLongjmp(CallExpr *TheCall);
bool SemaBuiltinAtomicOverloaded(CallExpr *TheCall);
@@ -3607,9 +3607,9 @@ private:
void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
const CallExpr *TheCall, bool HasVAListArg,
unsigned format_idx, unsigned firstDataArg);
- void CheckNonNullArguments(const NonNullAttr *NonNull,
+ void CheckNonNullArguments(const NonNullAttr *NonNull,
const CallExpr *TheCall);
- void CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
+ void CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
unsigned format_idx, unsigned firstDataArg);
void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc);
@@ -3623,12 +3623,12 @@ template <typename T>
class ExprOwningPtr : public Action::ExprArg {
public:
ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
-
+
void reset(T* p) { Action::ExprArg::operator=(p); }
T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
T* take() { return static_cast<T*>(Action::ExprArg::take()); }
T* release() { return take(); }
-
+
T& operator*() const { return *get(); }
T* operator->() const { return get(); }
};
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp
index 31d8a3f5ab..e1a7378061 100644
--- a/lib/Sema/SemaAccess.cpp
+++ b/lib/Sema/SemaAccess.cpp
@@ -19,7 +19,7 @@ using namespace clang;
/// SetMemberAccessSpecifier - Set the access specifier of a member.
/// Returns true on error (when the previous member decl access specifier
/// is different from the new member decl access specifier).
-bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
+bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
NamedDecl *PrevMemberDecl,
AccessSpecifier LexicalAS) {
if (!PrevMemberDecl) {
@@ -27,18 +27,18 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
MemberDecl->setAccess(LexicalAS);
return false;
}
-
+
// C++ [class.access.spec]p3: When a member is redeclared its access
// specifier must be same as its initial declaration.
if (LexicalAS != AS_none && LexicalAS != PrevMemberDecl->getAccess()) {
- Diag(MemberDecl->getLocation(),
- diag::err_class_redeclared_with_different_access)
+ Diag(MemberDecl->getLocation(),
+ diag::err_class_redeclared_with_different_access)
<< MemberDecl << LexicalAS;
Diag(PrevMemberDecl->getLocation(), diag::note_previous_access_declaration)
<< PrevMemberDecl << PrevMemberDecl->getAccess();
return true;
}
-
+
MemberDecl->setAccess(PrevMemberDecl->getAccess());
return false;
}
@@ -47,10 +47,9 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
/// inaccessible. If @p NoPrivileges is true, special access rights (members
/// and friends) are not considered.
const CXXBaseSpecifier *Sema::FindInaccessibleBase(
- QualType Derived, QualType Base, BasePaths &Paths, bool NoPrivileges)
-{
+ QualType Derived, QualType Base, BasePaths &Paths, bool NoPrivileges) {
Base = Context.getCanonicalType(Base).getUnqualifiedType();
- assert(!Paths.isAmbiguous(Base) &&
+ assert(!Paths.isAmbiguous(Base) &&
"Can't check base class access if set of paths is ambiguous");
assert(Paths.isRecordingPaths() &&
"Can't check base class access without recorded paths");
@@ -105,7 +104,7 @@ const CXXBaseSpecifier *Sema::FindInaccessibleBase(
/// CheckBaseClassAccess - Check that a derived class can access its base class
/// and report an error if it can't. [class.access.base]
-bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
+bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
unsigned InaccessibleBaseID,
BasePaths &Paths, SourceLocation AccessLoc,
DeclarationName Name) {
@@ -116,7 +115,7 @@ bool Sema::CheckBaseClassAccess(QualType Derived, QualType Base,
Derived, Base, Paths);
if (InaccessibleBase) {
- Diag(AccessLoc, InaccessibleBaseID)
+ Diag(AccessLoc, InaccessibleBaseID)
<< Derived << Base << Name;
AccessSpecifier AS = InaccessibleBase->getAccessSpecifierAsWritten();
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index 6622d53659..702e120f9c 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -32,8 +32,8 @@ namespace {
/// Stack - Entries in the #pragma pack stack, consisting of saved
/// alignments and optional names.
stack_ty Stack;
-
- public:
+
+ public:
PragmaPackStack() : Alignment(0) {}
void setAlignment(unsigned A) { Alignment = A; }
@@ -56,14 +56,14 @@ namespace {
bool PragmaPackStack::pop(IdentifierInfo *Name) {
if (Stack.empty())
return false;
-
+
// If name is empty just pop top.
if (!Name) {
Alignment = Stack.back().first;
Stack.pop_back();
return true;
- }
-
+ }
+
// Otherwise, find the named record.
for (unsigned i = Stack.size(); i != 0; ) {
--i;
@@ -74,7 +74,7 @@ bool PragmaPackStack::pop(IdentifierInfo *Name) {
return true;
}
}
-
+
return false;
}
@@ -93,8 +93,8 @@ unsigned Sema::getPragmaPackAlignment() const {
return 0;
}
-void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
- ExprTy *alignment, SourceLocation PragmaLoc,
+void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
+ ExprTy *alignment, SourceLocation PragmaLoc,
SourceLocation LParenLoc, SourceLocation RParenLoc) {
Expr *Alignment = static_cast<Expr *>(alignment);
@@ -102,7 +102,7 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
unsigned AlignmentVal = 0;
if (Alignment) {
llvm::APSInt Val;
-
+
// pack(0) is like pack(), which just works out since that is what
// we use 0 for in PackAttr.
if (!Alignment->isIntegerConstantExpr(Val, Context) ||
@@ -115,12 +115,12 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
AlignmentVal = (unsigned) Val.getZExtValue();
}
-
+
if (PackContext == 0)
PackContext = new PragmaPackStack();
-
+
PragmaPackStack *Context = static_cast<PragmaPackStack*>(PackContext);
-
+
switch (Kind) {
case Action::PPK_Default: // pack([n])
Context->setAlignment(AlignmentVal);
@@ -140,15 +140,15 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
Context->push(Name);
// Set the new alignment if specified.
if (Alignment)
- Context->setAlignment(AlignmentVal);
+ Context->setAlignment(AlignmentVal);
break;
case Action::PPK_Pop: // pack(pop [, id] [, n])
// MSDN, C/C++ Preprocessor Reference > Pragma Directives > pack:
// "#pragma pack(pop, identifier, n) is undefined"
if (Alignment && Name)
- Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifer_and_alignment);
-
+ Diag(PragmaLoc, diag::warn_pragma_pack_pop_identifer_and_alignment);
+
// Do the pop.
if (!Context->pop(Name)) {
// If a name was specified then failure indicates the name
@@ -178,7 +178,7 @@ void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers,
for (unsigned i = 0; i < NumIdentifiers; ++i) {
const Token &Tok = Identifiers[i];
- IdentifierInfo *Name = Tok.getIdentifierInfo();
+ IdentifierInfo *Name = Tok.getIdentifierInfo();
const LookupResult &Lookup = LookupParsedName(curScope, NULL, Name,
LookupOrdinaryName,
false, true,
@@ -187,18 +187,18 @@ void Sema::ActOnPragmaUnused(const Token *Identifiers, unsigned NumIdentifiers,
NamedDecl *ND = Lookup.getAsDecl();
- if (!ND) {
+ if (!ND) {
Diag(PragmaLoc, diag::warn_pragma_unused_undeclared_var)
<< Name << SourceRange(Tok.getLocation());
continue;
}
-
+
if (!isa<VarDecl>(ND) || !cast<VarDecl>(ND)->hasLocalStorage()) {
Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar)
<< Name << SourceRange(Tok.getLocation());
continue;
}
-
+
ND->addAttr(::new (Context) UnusedAttr());
}
}
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index ceb2de7ae8..ac85b79b39 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -47,7 +47,7 @@ static void CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
CastExpr::CastKind &Kind);
static void CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
const SourceRange &OpRange,
- const SourceRange &DestRange,
+ const SourceRange &DestRange,
CastExpr::CastKind &Kind);
static bool CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType);
@@ -89,7 +89,7 @@ static TryCastResult TryStaticImplicitCast(Sema &Self, Expr *SrcExpr,
CXXMethodDecl *&ConversionDecl);
static TryCastResult TryStaticCast(Sema &Self, Expr *SrcExpr,
QualType DestType, bool CStyle,
- CastExpr::CastKind &Kind,
+ CastExpr::CastKind &Kind,
const SourceRange &OpRange,
unsigned &msg,
CXXMethodDecl *&ConversionDecl);
@@ -97,7 +97,7 @@ static TryCastResult TryConstCast(Sema &Self, Expr *SrcExpr, QualType DestType,
bool CStyle, unsigned &msg);
static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr,
QualType DestType, bool CStyle,
- CastExpr::CastKind &Kind,
+ CastExpr::CastKind &Kind,
const SourceRange &OpRange,
unsigned &msg);
@@ -158,8 +158,7 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
/// the cast checkers. Both arguments must denote pointer (possibly to member)
/// types.
bool
-CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType)
-{
+CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType) {
// Casting away constness is defined in C++ 5.2.11p8 with reference to
// C++ 4.4. We piggyback on Sema::IsQualificationConversion for this, since
// the rules are non-trivial. So first we construct Tcv *...cv* as described
@@ -185,8 +184,7 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType)
QualType DestConstruct = Self.Context.VoidTy;
for (llvm::SmallVector<unsigned, 8>::reverse_iterator i1 = cv1.rbegin(),
i2 = cv2.rbegin();
- i1 != cv1.rend(); ++i1, ++i2)
- {
+ i1 != cv1.rend(); ++i1, ++i2) {
SrcConstruct = Self.Context.getPointerType(
SrcConstruct.getQualifiedType(*i1));
DestConstruct = Self.Context.getPointerType(
@@ -204,8 +202,7 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType)
static void
CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
const SourceRange &OpRange,
- const SourceRange &DestRange, CastExpr::CastKind &Kind)
-{
+ const SourceRange &DestRange, CastExpr::CastKind &Kind) {
QualType OrigDestType = DestType, OrigSrcType = SrcExpr->getType();
DestType = Self.Context.getCanonicalType(DestType);
@@ -325,8 +322,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
/// legacy_function(const_cast\<char*\>(str));
void
CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
- const SourceRange &OpRange, const SourceRange &DestRange)
-{
+ const SourceRange &OpRange, const SourceRange &DestRange) {
if (!DestType->isLValueReferenceType())
Self.DefaultFunctionArrayConversion(SrcExpr);
@@ -344,8 +340,7 @@ CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
/// char *bytes = reinterpret_cast\<char*\>(int_ptr);
void
CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
- const SourceRange &OpRange, const SourceRange &DestRange)
-{
+ const SourceRange &OpRange, const SourceRange &DestRange) {
if (!DestType->isLValueReferenceType())
Self.DefaultFunctionArrayConversion(SrcExpr);
@@ -364,8 +359,7 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
/// implicit conversions explicit and getting rid of data loss warnings.
void
CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
- const SourceRange &OpRange, CastExpr::CastKind &Kind)
-{
+ const SourceRange &OpRange, CastExpr::CastKind &Kind) {
// This test is outside everything else because it's the only case where
// a non-lvalue-reference target type does not lead to decay.
// C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void".
@@ -378,7 +372,7 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
unsigned msg = diag::err_bad_cxx_cast_generic;
CXXMethodDecl *ConversionDecl = 0;
- if (TryStaticCast(Self, SrcExpr, DestType, /*CStyle*/false, Kind,
+ if (TryStaticCast(Self, SrcExpr, DestType, /*CStyle*/false, Kind,
OpRange, msg, ConversionDecl)
!= TC_Success && msg != 0)
Self.Diag(OpRange.getBegin(), msg) << CT_Static
@@ -390,10 +384,9 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
/// and casting away constness.
static TryCastResult TryStaticCast(Sema &Self, Expr *SrcExpr,
QualType DestType, bool CStyle,
- CastExpr::CastKind &Kind,
+ CastExpr::CastKind &Kind,
const SourceRange &OpRange, unsigned &msg,
- CXXMethodDecl *&ConversionDecl)
-{
+ CXXMethodDecl *&ConversionDecl) {
// The order the tests is not entirely arbitrary. There is one conversion
// that can be handled in two different ways. Given:
// struct A {};
@@ -500,8 +493,7 @@ static TryCastResult TryStaticCast(Sema &Self, Expr *SrcExpr,
/// Tests whether a conversion according to N2844 is valid.
TryCastResult
TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
- unsigned &msg)
-{
+ unsigned &msg) {
// N2844 5.2.9p3: An lvalue of type "cv1 T1" can be cast to type "rvalue
// reference to cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
const RValueReferenceType *R = DestType->getAs<RValueReferenceType>();
@@ -531,8 +523,7 @@ TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
TryCastResult
TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType,
bool CStyle, const SourceRange &OpRange,
- unsigned &msg)
-{
+ unsigned &msg) {
// C++ 5.2.9p5: An lvalue of type "cv1 B", where B is a class type, can be
// cast to type "reference to cv2 D", where D is a class derived from B,
// if a valid standard conversion from "pointer to D" to "pointer to B"
@@ -562,8 +553,8 @@ TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType,
/// Tests whether a conversion according to C++ 5.2.9p8 is valid.
TryCastResult
TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType,
- bool CStyle, const SourceRange &OpRange, unsigned &msg)
-{
+ bool CStyle, const SourceRange &OpRange,
+ unsigned &msg) {
// C++ 5.2.9p8: An rvalue of type "pointer to cv1 B", where B is a class
// type, can be converted to an rvalue of type "pointer to cv2 D", where D
// is a class derived from B, if a valid standard conversion from "pointer
@@ -594,8 +585,7 @@ TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType,
TryCastResult
TryStaticDowncast(Sema &Self, QualType SrcType, QualType DestType,
bool CStyle, const SourceRange &OpRange, QualType OrigSrcType,
- QualType OrigDestType, unsigned &msg)
-{
+ QualType OrigDestType, unsigned &msg) {
// Downcast can only happen in class hierarchies, so we need classes.
if (!DestType->isRecordType() || !SrcType->isRecordType()) {
return TC_NotApplicable;
@@ -614,7 +604,7 @@ TryStaticDowncast(Sema &Self, QualType SrcType, QualType DestType,
// struct B : virtual A {
// B(A&);
// };
- //
+ //
// void f()
// {
// (void)static_cast<const B&>(*((A*)0));
@@ -691,8 +681,7 @@ TryStaticDowncast(Sema &Self, QualType SrcType, QualType DestType,
TryCastResult
TryStaticMemberPointerUpcast(Sema &Self, QualType SrcType, QualType DestType,
bool CStyle, const SourceRange &OpRange,
- unsigned &msg)
-{
+ unsigned &msg) {
const MemberPointerType *DestMemPtr = DestType->getAs<MemberPointerType>();
if (!DestMemPtr)
return TC_NotApplicable;
@@ -757,8 +746,7 @@ TryStaticMemberPointerUpcast(Sema &Self, QualType SrcType, QualType DestType,
TryCastResult
TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
bool CStyle, const SourceRange &OpRange, unsigned &msg,
- CXXMethodDecl *&ConversionDecl)
-{
+ CXXMethodDecl *&ConversionDecl) {
if (DestType->isRecordType()) {
if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
diag::err_bad_dynamic_cast_incomplete)) {
@@ -766,7 +754,7 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
return TC_Failed;
}
}
-
+
if (DestType->isReferenceType()) {
// At this point of CheckStaticCast, if the destination is a reference,
// this has to work. There is no other way that works.
@@ -774,7 +762,7 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
// the reinterpret_cast way. In that case, we pass an ICS so we don't
// get error messages.
ImplicitConversionSequence ICS;
- bool failed = Self.CheckReferenceInit(SrcExpr, DestType,
+ bool failed = Self.CheckReferenceInit(SrcExpr, DestType,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false,
@@ -792,15 +780,15 @@ TryStaticImplicitCast(Sema &Self, Expr *SrcExpr, QualType DestType,
// reimplement more of this.
// FIXME: This does not actually perform the conversion, and thus does not
// check for ambiguity or access.
- ImplicitConversionSequence ICS =
+ ImplicitConversionSequence ICS =
Self.TryImplicitConversion(SrcExpr, DestType,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/true,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
-
+
if (ICS.ConversionKind == ImplicitConversionSequence::UserDefinedConversion)
- if (CXXMethodDecl *MD =
+ if (CXXMethodDecl *MD =
dyn_cast<CXXMethodDecl>(ICS.UserDefined.ConversionFunction))
ConversionDecl = MD;
return ICS.ConversionKind == ImplicitConversionSequence::BadConversion ?
@@ -1032,8 +1020,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr,
bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
CastExpr::CastKind &Kind, bool FunctionalStyle,
- CXXMethodDecl *&ConversionDecl)
-{
+ CXXMethodDecl *&ConversionDecl) {
// This test is outside everything else because it's the only case where
// a non-lvalue-reference target type does not lead to decay.
// C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void".
@@ -1067,7 +1054,7 @@ bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
ConversionDecl);
if (tcr == TC_NotApplicable) {
// ... and finally a reinterpret_cast, ignoring const.
- tcr = TryReinterpretCast(*this, CastExpr, CastTy, /*CStyle*/true, Kind,
+ tcr = TryReinterpretCast(*this, CastExpr, CastTy, /*CStyle*/true, Kind,
R, msg);
}
}
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index fb6c88ebc4..759b56ced2 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -26,13 +26,13 @@ using namespace clang;
///
/// \param T the type for which we are attempting to find a DeclContext.
///
-/// \returns the declaration context represented by the type T,
+/// \returns the declaration context represented by the type T,
/// or NULL if the declaration context cannot be computed (e.g., because it is
/// dependent and not the current instantiation).
DeclContext *Sema::computeDeclContext(QualType T) {
if (const TagType *Tag = T->getAs<TagType>())
return Tag->getDecl();
-
+
return 0;
}
@@ -54,21 +54,21 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
if (!SS.isSet() || SS.isInvalid())
return 0;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
if (NNS->isDependent()) {
// If this nested-name-specifier refers to the current
// instantiation, return its DeclContext.
if (CXXRecordDecl *Record = getCurrentInstantiationOf(NNS))
return Record;
-
+
if (EnteringContext) {
if (const TemplateSpecializationType *SpecType
= dyn_cast_or_null<TemplateSpecializationType>(NNS->getAsType())) {
// We are entering the context of the nested name specifier, so try to
// match the nested name specifier to either a primary class template
// or a class template partial specialization.
- if (ClassTemplateDecl *ClassTemplate
+ if (ClassTemplateDecl *ClassTemplate
= dyn_cast_or_null<ClassTemplateDecl>(
SpecType->getTemplateName().getAsTemplateDecl())) {
QualType ContextType
@@ -80,7 +80,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
QualType Injected = ClassTemplate->getInjectedClassNameType(Context);
if (Context.hasSameType(Injected, ContextType))
return ClassTemplate->getTemplatedDecl();
-
+
// If the type of the nested name specifier is the same as the
// type of one of the class template's class template partial
// specializations, we're entering into the definition of that
@@ -89,13 +89,13 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
= ClassTemplate->findPartialSpecialization(ContextType))
return PartialSpec;
}
- } else if (const RecordType *RecordT
+ } else if (const RecordType *RecordT
= dyn_cast_or_null<RecordType>(NNS->getAsType())) {
// The nested name specifier refers to a member of a class template.
return RecordT->getDecl();
}
}
-
+
return 0;
}
@@ -126,7 +126,7 @@ bool Sema::isDependentScopeSpecifier(const CXXScopeSpec &SS) {
if (!SS.isSet() || SS.isInvalid())
return false;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return NNS->isDependent();
}
@@ -138,7 +138,7 @@ bool Sema::isUnknownSpecialization(const CXXScopeSpec &SS) {
if (!isDependentScopeSpecifier(SS))
return false;
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return getCurrentInstantiationOf(NNS) == 0;
}
@@ -154,7 +154,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
if (!NNS->getAsType())
return 0;
-
+
QualType T = QualType(NNS->getAsType(), 0);
// If the nested name specifier does not refer to a type, then it
// does not refer to the current instantiation.
@@ -174,7 +174,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
if (!Record)
continue;
- // If this record type is not dependent,
+ // If this record type is not dependent,
if (!Record->isDependentType())
return 0;
@@ -192,13 +192,13 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
// enclosed in <>,
// -- in the definition of a nested class of a class template,
// the name of the nested class referenced as a member of
- // the current instantiation, or
+ // the current instantiation, or
// -- in the definition of a partial specialization, the name
// of the class template followed by the template argument
// list of the partial specialization enclosed in <>. If
// the nth template parameter is a parameter pack, the nth
// template argument is a pack expansion (14.6.3) whose
- // pattern is the name of the parameter pack.
+ // pattern is the name of the parameter pack.
// (FIXME: parameter packs)
//
// All of these options come down to having the
@@ -207,9 +207,9 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
// our context.
if (Context.getCanonicalType(Context.getTypeDeclType(Record)) == T)
return Record;
-
+
if (ClassTemplateDecl *Template = Record->getDescribedClassTemplate()) {
- QualType InjectedClassName
+ QualType InjectedClassName
= Template->getInjectedClassNameType(Context);
if (T == Context.getCanonicalType(InjectedClassName))
return Template->getTemplatedDecl();
@@ -232,7 +232,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) {
if (!SS.isSet() || SS.isInvalid())
return false;
-
+
DeclContext *DC = computeDeclContext(SS, true);
if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
// If we're currently defining this type, then lookup into the
@@ -263,14 +263,14 @@ Sema::CXXScopeTy *Sema::ActOnCXXGlobalScopeSpecifier(Scope *S,
bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
if (!SD)
return false;
-
+
// Namespace and namespace aliases are fine.
if (isa<NamespaceDecl>(SD) || isa<NamespaceAliasDecl>(SD))
return true;
-
+
if (!isa<TypeDecl>(SD))
return false;
-
+
// Determine whether we have a class (or, in C++0x, an enum) or
// a typedef thereof. If so, build the nested-name-specifier.
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
@@ -278,10 +278,10 @@ bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
return true;
else if (TypedefDecl *TD = dyn_cast<TypedefDecl>(SD)) {
if (TD->getUnderlyingType()->isRecordType() ||
- (Context.getLangOptions().CPlusPlus0x &&
+ (Context.getLangOptions().CPlusPlus0x &&
TD->getUnderlyingType()->isEnumeralType()))
return true;
- } else if (isa<RecordDecl>(SD) ||
+ } else if (isa<RecordDecl>(SD) ||
(Context.getLangOptions().CPlusPlus0x && isa<EnumDecl>(SD)))
return true;
@@ -289,27 +289,27 @@ bool isAcceptableNestedNameSpecifier(ASTContext &Context, NamedDecl *SD) {
}
/// \brief If the given nested-name-specifier begins with a bare identifier
-/// (e.g., Base::), perform name lookup for that identifier as a
+/// (e.g., Base::), perform name lookup for that identifier as a
/// nested-name-specifier within the given scope, and return the result of that
/// name lookup.
NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) {
if (!S || !NNS)
return 0;
-
+
while (NNS->getPrefix())
NNS = NNS->getPrefix();
-
+
if (NNS->getKind() != NestedNameSpecifier::Identifier)
return 0;
-
- LookupResult Found
+
+ LookupResult Found
= LookupName(S, NNS->getAsIdentifier(), LookupNestedNameSpecifierName);
assert(!Found.isAmbiguous() && "Cannot handle ambiguities here yet");
NamedDecl *Result = Found;
if (isAcceptableNestedNameSpecifier(Context, Result))
return Result;
-
+
return 0;
}
@@ -328,9 +328,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
QualType ObjectType,
NamedDecl *ScopeLookupResult,
bool EnteringContext) {
- NestedNameSpecifier *Prefix
+ NestedNameSpecifier *Prefix
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
-
+
// Determine where to perform name lookup
DeclContext *LookupCtx = 0;
bool isDependent = false;
@@ -346,70 +346,70 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
LookupCtx = computeDeclContext(SS, EnteringContext);
isDependent = isDependentScopeSpecifier(SS);
}
-
+
LookupResult Found;
bool ObjectTypeSearchedInScope = false;
if (LookupCtx) {
- // Perform "qualified" name lookup into the declaration context we
+ // Perform "qualified" name lookup into the declaration context we
// computed, which is either the type of the base of a member access
- // expression or the declaration context associated with a prior
+ // expression or the declaration context associated with a prior
// nested-name-specifier.
-
+
// The declaration context must be complete.
if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(SS))
return 0;
-
+
Found = LookupQualifiedName(LookupCtx, &II, LookupNestedNameSpecifierName,
false);
-
+
if (!ObjectType.isNull() && Found.getKind() == LookupResult::NotFound) {
// C++ [basic.lookup.classref]p4:
// If the id-expression in a class member access is a qualified-id of
- // the form
+ // the form
//
// class-name-or-namespace-name::...
//
- // the class-name-or-namespace-name following the . or -> operator is
- // looked up both in the context of the entire postfix-expression and in
+ // the class-name-or-namespace-name following the . or -> operator is
+ // looked up both in the context of the entire postfix-expression and in
// the scope of the class of the object expression. If the name is found
- // only in the scope of the class of the object expression, the name
- // shall refer to a class-name. If the name is found only in the
+ // only in the scope of the class of the object expression, the name
+ // shall refer to a class-name. If the name is found only in the
// context of the entire postfix-expression, the name shall refer to a
// class-name or namespace-name. [...]
//
// Qualified name lookup into a class will not find a namespace-name,
- // so we do not need to diagnoste that case specifically. However,
+ // so we do not need to diagnoste that case specifically. However,
// this qualified name lookup may find nothing. In that case, perform
- // unqualified name lookup in the given scope (if available) or
+ // unqualified name lookup in the given scope (if available) or
// reconstruct the result from when name lookup was performed at template
// definition time.
if (S)
Found = LookupName(S, &II, LookupNestedNameSpecifierName);
else
Found = LookupResult::CreateLookupResult(Context, ScopeLookupResult);
-
+
ObjectTypeSearchedInScope = true;
}
} else if (isDependent) {
// We were not able to compute the declaration context for a dependent
- // base object type or prior nested-name-specifier, so this
+ // base object type or prior nested-name-specifier, so this
// nested-name-specifier refers to an unknown specialization. Just build
// a dependent nested-name-specifier.
if (!Prefix)
return NestedNameSpecifier::Create(Context, &II);
-
+
return NestedNameSpecifier::Create(Context, Prefix, &II);
} else {
// Perform unqualified name lookup in the current scope.
Found = LookupName(S, &II, LookupNestedNameSpecifierName);
}
-
+
// FIXME: Deal with ambiguities cleanly.
NamedDecl *SD = Found;
if (isAcceptableNestedNameSpecifier(Context, SD)) {
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
// C++ [basic.lookup.classref]p4:
- // [...] If the name is found in both contexts, the
+ // [...] If the name is found in both contexts, the
// class-name-or-namespace-name shall refer to the same entity.
//
// We already found the name in the scope of the object. Now, look
@@ -420,9 +420,9 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
if (S)
FoundOuter = LookupName(S, &II, LookupNestedNameSpecifierName);
else
- FoundOuter = LookupResult::CreateLookupResult(Context,
+ FoundOuter = LookupResult::CreateLookupResult(Context,
ScopeLookupResult);
-
+
// FIXME: Handle ambiguities in FoundOuter!
NamedDecl *OuterDecl = FoundOuter;
if (isAcceptableNestedNameSpecifier(Context, OuterDecl) &&
@@ -436,50 +436,50 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
Diag(SD->getLocation(), diag::note_ambig_member_ref_object_type)
<< ObjectType;
Diag(OuterDecl->getLocation(), diag::note_ambig_member_ref_scope);
-
+
// Fall through so that we'll pick the name we found in the object type,
// since that's probably what the user wanted anyway.
}
}
-
+
if (NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(SD))
return NestedNameSpecifier::Create(Context, Prefix, Namespace);
-
+
// FIXME: It would be nice to maintain the namespace alias name, then
// see through that alias when resolving the nested-name-specifier down to
// a declaration context.
if (NamespaceAliasDecl *Alias = dyn_cast<NamespaceAliasDecl>(SD))
return NestedNameSpecifier::Create(Context, Prefix,
-
+
Alias->getNamespace());
-
+
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
return NestedNameSpecifier::Create(Context, Prefix, false,
T.getTypePtr());
}
-
+
// If we didn't find anything during our lookup, try again with
// ordinary name lookup, which can help us produce better error
// messages.
if (!SD)
SD = LookupName(S, &II, LookupOrdinaryName);
-
+
unsigned DiagID;
if (SD)
DiagID = diag::err_expected_class_or_namespace;
else if (SS.isSet()) {
- DiagnoseMissingMember(IdLoc, DeclarationName(&II),
- (NestedNameSpecifier *)SS.getScopeRep(),
+ DiagnoseMissingMember(IdLoc, DeclarationName(&II),
+ (NestedNameSpecifier *)SS.getScopeRep(),
SS.getRange());
return 0;
} else
DiagID = diag::err_undeclared_var_use;
-
+
if (SS.isSet())
Diag(IdLoc, DiagID) << &II << SS.getRange();
else
Diag(IdLoc, DiagID) << &II;
-
+
return 0;
}
@@ -496,7 +496,7 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
IdentifierInfo &II,
TypeTy *ObjectTypePtr,
bool EnteringContext) {
- return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
+ return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
QualType::getFromOpaquePtr(ObjectTypePtr),
/*ScopeLookupResult=*/0, EnteringContext);
}
@@ -506,7 +506,7 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
TypeTy *Ty,
SourceRange TypeRange,
SourceLocation CCLoc) {
- NestedNameSpecifier *Prefix
+ NestedNameSpecifier *Prefix
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
QualType T = GetTypeFromParser(Ty);
return NestedNameSpecifier::Create(Context, Prefix, /*FIXME:*/false,
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index a63e044272..5faafada50 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements extra semantic analysis beyond what is enforced
+// This file implements extra semantic analysis beyond what is enforced
// by the C type system.
//
//===----------------------------------------------------------------------===//
@@ -32,14 +32,14 @@ using namespace clang;
SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
unsigned ByteNo) const {
assert(!SL->isWide() && "This doesn't work for wide strings yet");
-
+
// Loop over all of the tokens in this string until we find the one that
// contains the byte we're looking for.
unsigned TokNo = 0;
while (1) {
assert(TokNo < SL->getNumConcatenated() && "Invalid byte number!");
SourceLocation StrTokLoc = SL->getStrTokenLoc(TokNo);
-
+
// Get the spelling of the string so that we can get the data that makes up
// the string literal, not the identifier for the macro it is potentially
// expanded through.
@@ -51,33 +51,33 @@ SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
std::pair<const char *,const char *> Buffer =
SourceMgr.getBufferData(LocInfo.first);
const char *StrData = Buffer.first+LocInfo.second;
-
+
// Create a langops struct and enable trigraphs. This is sufficient for
// relexing tokens.
LangOptions LangOpts;
LangOpts.Trigraphs = true;
-
+
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(StrTokSpellingLoc, LangOpts, Buffer.first, StrData,
Buffer.second);
Token TheTok;
TheLexer.LexFromRawLexer(TheTok);
-
+
// Use the StringLiteralParser to compute the length of the string in bytes.
StringLiteralParser SLP(&TheTok, 1, PP);
unsigned TokNumBytes = SLP.GetStringLength();
-
+
// If the byte is in this token, return the location of the byte.
if (ByteNo < TokNumBytes ||
(ByteNo == TokNumBytes && TokNo == SL->getNumConcatenated())) {
- unsigned Offset =
+ unsigned Offset =
StringLiteralParser::getOffsetOfStringByte(TheTok, ByteNo, PP);
-
+
// Now that we know the offset of the token in the spelling, use the
// preprocessor to get the offset in the original source.
return PP.AdvanceToTokenCharacter(StrTokLoc, Offset);
}
-
+
// Move to the next string token.
++TokNo;
ByteNo -= TokNumBytes;
@@ -174,7 +174,7 @@ Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
return ExprError();
break;
}
-
+
return move(TheCallResult);
}
@@ -188,7 +188,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
// simple names (e.g., C++ conversion functions).
if (!FnInfo)
return false;
-
+
// FIXME: This mechanism should be abstracted to be less fragile and
// more efficient. For example, just map function ids to custom
// handlers.
@@ -198,7 +198,7 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
if (CheckablePrintfAttr(Format, TheCall)) {
bool HasVAListArg = Format->getFirstArg() == 0;
if (!HasVAListArg) {
- if (const FunctionProtoType *Proto
+ if (const FunctionProtoType *Proto
= FDecl->getType()->getAsFunctionProtoType())
HasVAListArg = !Proto->isVariadic();
}
@@ -206,8 +206,8 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
HasVAListArg ? 0 : Format->getFirstArg() - 1);
}
}
-
- for (const NonNullAttr *NonNull = FDecl->getAttr<NonNullAttr>(); NonNull;
+
+ for (const NonNullAttr *NonNull = FDecl->getAttr<NonNullAttr>(); NonNull;
NonNull = NonNull->getNext<NonNullAttr>())
CheckNonNullArguments(NonNull, TheCall);
@@ -219,21 +219,21 @@ bool Sema::CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall) {
const FormatAttr *Format = NDecl->getAttr<FormatAttr>();
if (!Format)
return false;
-
+
const VarDecl *V = dyn_cast<VarDecl>(NDecl);
if (!V)
return false;
-
+
QualType Ty = V->getType();
if (!Ty->isBlockPointerType())
return false;
-
+
if (!CheckablePrintfAttr(Format, TheCall))
return false;
-
+
bool HasVAListArg = Format->getFirstArg() == 0;
if (!HasVAListArg) {
- const FunctionType *FT =
+ const FunctionType *FT =
Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT))
HasVAListArg = !Proto->isVariadic();
@@ -260,7 +260,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
if (TheCall->getNumArgs() < 1)
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
<< 0 << TheCall->getCallee()->getSourceRange();
-
+
// Inspect the first argument of the atomic builtin. This should always be
// a pointer type, whose element is an integral scalar or pointer type.
// Because it is a pointer type, we don't have to worry about any implicit
@@ -269,9 +269,9 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
if (!FirstArg->getType()->isPointerType())
return Diag(DRE->getLocStart(), diag::err_atomic_builtin_must_be_pointer)
<< FirstArg->getType() << FirstArg->getSourceRange();
-
+
QualType ValType = FirstArg->getType()->getAs<PointerType>()->getPointeeType();
- if (!ValType->isIntegerType() && !ValType->isPointerType() &&
+ if (!ValType->isIntegerType() && !ValType->isPointerType() &&
!ValType->isBlockPointerType())
return Diag(DRE->getLocStart(),
diag::err_atomic_builtin_must_be_pointer_intptr)
@@ -283,7 +283,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
#define BUILTIN_ROW(x) \
{ Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \
Builtin::BI##x##_8, Builtin::BI##x##_16 }
-
+
static const unsigned BuiltinIndices[][5] = {
BUILTIN_ROW(__sync_fetch_and_add),
BUILTIN_ROW(__sync_fetch_and_sub),
@@ -291,21 +291,21 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
BUILTIN_ROW(__sync_fetch_and_and),
BUILTIN_ROW(__sync_fetch_and_xor),
BUILTIN_ROW(__sync_fetch_and_nand),
-
+
BUILTIN_ROW(__sync_add_and_fetch),
BUILTIN_ROW(__sync_sub_and_fetch),
BUILTIN_ROW(__sync_and_and_fetch),
BUILTIN_ROW(__sync_or_and_fetch),
BUILTIN_ROW(__sync_xor_and_fetch),
BUILTIN_ROW(__sync_nand_and_fetch),
-
+
BUILTIN_ROW(__sync_val_compare_and_swap),
BUILTIN_ROW(__sync_bool_compare_and_swap),
BUILTIN_ROW(__sync_lock_test_and_set),
BUILTIN_ROW(__sync_lock_release)
};
-#undef BUILTIN_ROW
-
+#undef BUILTIN_ROW
+
// Determine the index of the size.
unsigned SizeIndex;
switch (Context.getTypeSize(ValType)/8) {
@@ -318,7 +318,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
return Diag(DRE->getLocStart(), diag::err_atomic_builtin_pointer_size)
<< FirstArg->getType() << FirstArg->getSourceRange();
}
-
+
// Each of these builtins has one pointer argument, followed by some number of
// values (0, 1 or 2) followed by a potentially empty varags list of stuff
// that we ignore. Find out which row of BuiltinIndices to read from as well
@@ -333,14 +333,14 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
case Builtin::BI__sync_fetch_and_and: BuiltinIndex = 3; break;
case Builtin::BI__sync_fetch_and_xor: BuiltinIndex = 4; break;
case Builtin::BI__sync_fetch_and_nand:BuiltinIndex = 5; break;
-
+
case Builtin::BI__sync_add_and_fetch: BuiltinIndex = 6; break;
case Builtin::BI__sync_sub_and_fetch: BuiltinIndex = 7; break;
case Builtin::BI__sync_and_and_fetch: BuiltinIndex = 8; break;
case Builtin::BI__sync_or_and_fetch: BuiltinIndex = 9; break;
case Builtin::BI__sync_xor_and_fetch: BuiltinIndex =10; break;
case Builtin::BI__sync_nand_and_fetch:BuiltinIndex =11; break;
-
+
case Builtin::BI__sync_val_compare_and_swap:
BuiltinIndex = 12;
NumFixed = 2;
@@ -355,37 +355,37 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
NumFixed = 0;
break;
}
-
+
// Now that we know how many fixed arguments we expect, first check that we
// have at least that many.
if (TheCall->getNumArgs() < 1+NumFixed)
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
<< 0 << TheCall->getCallee()->getSourceRange();
-
-
+
+
// Get the decl for the concrete builtin from this, we can tell what the
// concrete integer type we should convert to is.
unsigned NewBuiltinID = BuiltinIndices[BuiltinIndex][SizeIndex];
const char *NewBuiltinName = Context.BuiltinInfo.GetName(NewBuiltinID);
IdentifierInfo *NewBuiltinII = PP.getIdentifierInfo(NewBuiltinName);
- FunctionDecl *NewBuiltinDecl =
+ FunctionDecl *NewBuiltinDecl =
cast<FunctionDecl>(LazilyCreateBuiltin(NewBuiltinII, NewBuiltinID,
TUScope, false, DRE->getLocStart()));
const FunctionProtoType *BuiltinFT =
NewBuiltinDecl->getType()->getAsFunctionProtoType();
ValType = BuiltinFT->getArgType(0)->getAs<PointerType>()->getPointeeType();
-
+
// If the first type needs to be converted (e.g. void** -> int*), do it now.
if (BuiltinFT->getArgType(0) != FirstArg->getType()) {
ImpCastExprToType(FirstArg, BuiltinFT->getArgType(0), CastExpr::CK_Unknown,
/*isLvalue=*/false);
TheCall->setArg(0, FirstArg);
}
-
+
// Next, walk the valid ones promoting to the right type.
for (unsigned i = 0; i != NumFixed; ++i) {
Expr *Arg = TheCall->getArg(i+1);
-
+
// If the argument is an implicit cast, then there was a promotion due to
// "...", just remove it now.
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) {
@@ -394,7 +394,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
ICE->Destroy(Context);
TheCall->setArg(i+1, Arg);
}
-
+
// GCC does an implicit conversion to the pointer or integer ValType. This
// can fail in some cases (1i -> int**), check for this error case now.
CastExpr::CastKind Kind = CastExpr::CK_Unknown;
@@ -402,27 +402,27 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
if (CheckCastTypes(Arg->getSourceRange(), ValType, Arg, Kind,
ConversionDecl))
return true;
-
+
// Okay, we have something that *can* be converted to the right type. Check
// to see if there is a potentially weird extension going on here. This can
// happen when you do an atomic operation on something like an char* and
// pass in 42. The 42 gets converted to char. This is even more strange
// for things like 45.123 -> char, etc.
- // FIXME: Do this check.
+ // FIXME: Do this check.
ImpCastExprToType(Arg, ValType, Kind, /*isLvalue=*/false);
TheCall->setArg(i+1, Arg);
}
-
+
// Switch the DeclRefExpr to refer to the new decl.
DRE->setDecl(NewBuiltinDecl);
DRE->setType(NewBuiltinDecl->getType());
-
+
// Set the callee in the CallExpr.
// FIXME: This leaks the original parens and implicit casts.
Expr *PromotedCall = DRE;
UsualUnaryConversions(PromotedCall);
TheCall->setCallee(PromotedCall);
-
+
// Change the result type of the call to match the result type of the decl.
TheCall->setType(NewBuiltinDecl->getResultType());
@@ -433,7 +433,7 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) {
/// CheckObjCString - Checks that the argument to the builtin
/// CFString constructor is correct
/// FIXME: GCC currently emits the following warning:
-/// "warning: input conversion stopped due to an input byte that does not
+/// "warning: input conversion stopped due to an input byte that does not
/// belong to the input codeset UTF-8"
/// Note: It might also make sense to do the UTF-16 conversion here (would
/// simplify the backend).
@@ -446,10 +446,10 @@ bool Sema::CheckObjCString(Expr *Arg) {
<< Arg->getSourceRange();
return true;
}
-
+
const char *Data = Literal->getStrData();
unsigned Length = Literal->getByteLength();
-
+
for (unsigned i = 0; i < Length; ++i) {
if (!Data[i]) {
Diag(getLocationOfStringLiteralByte(Literal, i),
@@ -458,7 +458,7 @@ bool Sema::CheckObjCString(Expr *Arg) {
break;
}
}
-
+
return false;
}
@@ -470,7 +470,7 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
Diag(TheCall->getArg(2)->getLocStart(),
diag::err_typecheck_call_too_many_args)
<< 0 /*function call*/ << Fn->getSourceRange()
- << SourceRange(TheCall->getArg(2)->getLocStart(),
+ << SourceRange(TheCall->getArg(2)->getLocStart(),
(*(TheCall->arg_end()-1))->getLocEnd());
return true;
}
@@ -493,17 +493,17 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
} else {
isVariadic = getCurMethodDecl()->isVariadic();
}
-
+
if (!isVariadic) {
Diag(Fn->getLocStart(), diag::err_va_start_used_in_non_variadic_function);
return true;
}
-
+
// Verify that the second argument to the builtin is the last argument of the
// current function or method.
bool SecondArgIsLastNamedArgument = false;
const Expr *Arg = TheCall->getArg(1)->IgnoreParenCasts();
-
+
if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
if (const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
// FIXME: This isn't correct for methods (results in bogus warning).
@@ -518,9 +518,9 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
SecondArgIsLastNamedArgument = PV == LastArg;
}
}
-
+
if (!SecondArgIsLastNamedArgument)
- Diag(TheCall->getArg(1)->getLocStart(),
+ Diag(TheCall->getArg(1)->getLocStart(),
diag::warn_second_parameter_of_va_start_not_last_named_argument);
return false;
}
@@ -532,12 +532,12 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
<< 0 /*function call*/;
if (TheCall->getNumArgs() > 2)
- return Diag(TheCall->getArg(2)->getLocStart(),
+ return Diag(TheCall->getArg(2)->getLocStart(),
diag::err_typecheck_call_too_many_args)
<< 0 /*function call*/
<< SourceRange(TheCall->getArg(2)->getLocStart(),
(*(TheCall->arg_end()-1))->getLocEnd());
-
+
Expr *OrigArg0 = TheCall->getArg(0);
Expr *OrigArg1 = TheCall->getArg(1);
@@ -550,18 +550,18 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
// foo(...)".
TheCall->setArg(0, OrigArg0);
TheCall->setArg(1, OrigArg1);
-
+
if (OrigArg0->isTypeDependent() || OrigArg1->isTypeDependent())
return false;
// If the common type isn't a real floating type, then the arguments were
// invalid for this operation.
if (!Res->isRealFloatingType())
- return Diag(OrigArg0->getLocStart(),
+ return Diag(OrigArg0->getLocStart(),
diag::err_typecheck_call_invalid_ordered_compare)
<< OrigArg0->getType() << OrigArg1->getType()
<< SourceRange(OrigArg0->getLocStart(), OrigArg1->getLocEnd());
-
+
return false;
}
@@ -572,23 +572,23 @@ bool Sema::SemaBuiltinUnaryFP(CallExpr *TheCall) {
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
<< 0 /*function call*/;
if (TheCall->getNumArgs() > 1)
- return Diag(TheCall->getArg(1)->getLocStart(),
+ return Diag(TheCall->getArg(1)->getLocStart(),
diag::err_typecheck_call_too_many_args)
<< 0 /*function call*/
<< SourceRange(TheCall->getArg(1)->getLocStart(),
(*(TheCall->arg_end()-1))->getLocEnd());
Expr *OrigArg = TheCall->getArg(0);
-
+
if (OrigArg->isTypeDependent())
return false;
// This operation requires a floating-point number
if (!OrigArg->getType()->isRealFloatingType())
- return Diag(OrigArg->getLocStart(),
+ return Diag(OrigArg->getLocStart(),
diag::err_typecheck_call_invalid_unary_fp)
<< OrigArg->getType() << OrigArg->getSourceRange();
-
+
return false;
}
@@ -600,7 +600,7 @@ bool Sema::SemaBuiltinStackAddress(CallExpr *TheCall) {
!TheCall->getArg(0)->isValueDependent() &&
!TheCall->getArg(0)->isIntegerConstantExpr(Context, &Loc))
return Diag(Loc, diag::err_stack_const_level) << TheCall->getSourceRange();
-
+
return false;
}
@@ -617,18 +617,18 @@ Action::OwningExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
!TheCall->getArg(1)->isTypeDependent()) {
QualType FAType = TheCall->getArg(0)->getType();
QualType SAType = TheCall->getArg(1)->getType();
-
+
if (!FAType->isVectorType() || !SAType->isVectorType()) {
Diag(TheCall->getLocStart(), diag::err_shufflevector_non_vector)
- << SourceRange(TheCall->getArg(0)->getLocStart(),
+ << SourceRange(TheCall->getArg(0)->getLocStart(),
TheCall->getArg(1)->getLocEnd());
return ExprError();
}
-
+
if (Context.getCanonicalType(FAType).getUnqualifiedType() !=
Context.getCanonicalType(SAType).getUnqualifiedType()) {
Diag(TheCall->getLocStart(), diag::err_shufflevector_incompatible_vector)
- << SourceRange(TheCall->getArg(0)->getLocStart(),
+ << SourceRange(TheCall->getArg(0)->getLocStart(),
TheCall->getArg(1)->getLocEnd());
return ExprError();
}
@@ -706,7 +706,7 @@ bool Sema::SemaBuiltinPrefetch(CallExpr *TheCall) {
if (!Arg->isIntegerConstantExpr(Result, Context))
return Diag(TheCall->getLocStart(), diag::err_prefetch_invalid_argument)
<< SourceRange(Arg->getLocStart(), Arg->getLocEnd());
-
+
// FIXME: gcc issues a warning and rewrites these to 0. These
// seems especially odd for the third argument since the default
// is 3.
@@ -732,8 +732,8 @@ bool Sema::SemaBuiltinObjectSize(CallExpr *TheCall) {
if (Arg->isTypeDependent())
return false;
- QualType ArgType = Arg->getType();
- const BuiltinType *BT = ArgType->getAsBuiltinType();
+ QualType ArgType = Arg->getType();
+ const BuiltinType *BT = ArgType->getAsBuiltinType();
llvm::APSInt Result(32);
if (!BT || BT->getKind() != BuiltinType::Int)
return Diag(TheCall->getLocStart(), diag::err_object_size_invalid_argument)
@@ -797,10 +797,10 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
return SemaCheckStringLiteral(Expr->getSubExpr(), TheCall, HasVAListArg,
format_idx, firstDataArg);
}
-
+
case Stmt::DeclRefExprClass: {
const DeclRefExpr *DR = cast<DeclRefExpr>(E);
-
+
// As an exception, do not flag errors for variables binding to
// const string literals.
if (const VarDecl *VD = dyn_cast<VarDecl>(DR->getDecl())) {
@@ -810,17 +810,17 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
if (const ArrayType *AT = Context.getAsArrayType(T)) {
isConstant = AT->getElementType().isConstant(Context);
} else if (const PointerType *PT = T->getAs<PointerType>()) {
- isConstant = T.isConstant(Context) &&
+ isConstant = T.isConstant(Context) &&
PT->getPointeeType().isConstant(Context);
}
-
+
if (isConstant) {
const VarDecl *Def = 0;
if (const Expr *Init = VD->getDefinition(Def))
return SemaCheckStringLiteral(Init, TheCall,
HasVAListArg, format_idx, firstDataArg);
}
-
+
// For vprintf* functions (i.e., HasVAListArg==true), we add a
// special check to see if the format string is a function parameter
// of the function calling the printf function. If the function
@@ -843,55 +843,55 @@ bool Sema::SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
if (isa<ParmVarDecl>(VD))
return true;
}
-
+
return false;
}
case Stmt::CallExprClass: {
const CallExpr *CE = cast<CallExpr>(E);
- if (const ImplicitCastExpr *ICE
+ if (const ImplicitCastExpr *ICE
= dyn_cast<ImplicitCastExpr>(CE->getCallee())) {
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr())) {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
if (const FormatArgAttr *FA = FD->getAttr<FormatArgAttr>()) {
unsigned ArgIndex = FA->getFormatIdx();
const Expr *Arg = CE->getArg(ArgIndex - 1);
-
- return SemaCheckStringLiteral(Arg, TheCall, HasVAListArg,
+
+ return SemaCheckStringLiteral(Arg, TheCall, HasVAListArg,
format_idx, firstDataArg);
}
}
}
}
-
+
return false;
}
case Stmt::ObjCStringLiteralClass:
case Stmt::StringLiteralClass: {
const StringLiteral *StrE = NULL;
-
+
if (const ObjCStringLiteral *ObjCFExpr = dyn_cast<ObjCStringLiteral>(E))
StrE = ObjCFExpr->getString();
else
StrE = cast<StringLiteral>(E);
-
+
if (StrE) {
- CheckPrintfString(StrE, E, TheCall, HasVAListArg, format_idx,
+ CheckPrintfString(StrE, E, TheCall, HasVAListArg, format_idx,
firstDataArg);
return true;
}
-
+
return false;
}
-
+
default:
return false;
}
}
void
-Sema::CheckNonNullArguments(const NonNullAttr *NonNull, const CallExpr *TheCall)
-{
+Sema::CheckNonNullArguments(const NonNullAttr *NonNull,
+ const CallExpr *TheCall) {
for (NonNullAttr::iterator i = NonNull->begin(), e = NonNull->end();
i != e; ++i) {
const Expr *ArgExpr = TheCall->getArg(*i);
@@ -902,7 +902,7 @@ Sema::CheckNonNullArguments(const NonNullAttr *NonNull, const CallExpr *TheCall)
}
/// CheckPrintfArguments - Check calls to printf (and similar functions) for
-/// correct use of format strings.
+/// correct use of format strings.
///
/// HasVAListArg - A predicate indicating whether the printf-like
/// function is passed an explicit va_arg argument (e.g., vprintf)
@@ -951,30 +951,30 @@ Sema::CheckNonNullArguments(const NonNullAttr *NonNull, const CallExpr *TheCall)
///
/// For now, we ONLY do (1), (3), (5), (6), (7), and (8).
void
-Sema::CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
+Sema::CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
unsigned format_idx, unsigned firstDataArg) {
const Expr *Fn = TheCall->getCallee();
- // CHECK: printf-like function is called with no format string.
+ // CHECK: printf-like function is called with no format string.
if (format_idx >= TheCall->getNumArgs()) {
Diag(TheCall->getRParenLoc(), diag::warn_printf_missing_format_string)
<< Fn->getSourceRange();
return;
}
-
+
const Expr *OrigFormatExpr = TheCall->getArg(format_idx)->IgnoreParenCasts();
-
+
// CHECK: format string is not a string literal.
- //
+ //
// Dynamically generated format strings are difficult to
// automatically vet at compile time. Requiring that format strings
// are string literals: (1) permits the checking of format strings by
// the compiler and thereby (2) can practically remove the source of
// many format string exploits.
- // Format string can be either ObjC string (e.g. @"%d") or
+ // Format string can be either ObjC string (e.g. @"%d") or
// C string (e.g. "%d")
- // ObjC string uses the same format specifiers as C string, so we can use
+ // ObjC string uses the same format specifiers as C string, so we can use
// the same format string checking logic for both ObjC and C strings.
if (SemaCheckStringLiteral(OrigFormatExpr, TheCall, HasVAListArg, format_idx,
firstDataArg))
@@ -983,11 +983,11 @@ Sema::CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
// If there are no arguments specified, warn with -Wformat-security, otherwise
// warn only with -Wformat-nonliteral.
if (TheCall->getNumArgs() == format_idx+1)
- Diag(TheCall->getArg(format_idx)->getLocStart(),
+ Diag(TheCall->getArg(format_idx)->getLocStart(),
diag::warn_printf_nonliteral_noargs)
<< OrigFormatExpr->getSourceRange();
else
- Diag(TheCall->getArg(format_idx)->getLocStart(),
+ Diag(TheCall->getArg(format_idx)->getLocStart(),
diag::warn_printf_nonliteral)
<< OrigFormatExpr->getSourceRange();
}
@@ -1013,7 +1013,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
// CHECK: empty format string?
unsigned StrLen = FExpr->getByteLength();
-
+
if (StrLen == 0) {
Diag(FExpr->getLocStart(), diag::warn_printf_empty_format_string)
<< OrigFormatExpr->getSourceRange();
@@ -1026,7 +1026,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
state_OrdChr,
state_Conversion
} CurrentState = state_OrdChr;
-
+
// numConversions - The number of conversions seen so far. This is
// incremented as we traverse the format string.
unsigned numConversions = 0;
@@ -1039,17 +1039,17 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
// Inspect the format string.
unsigned StrIdx = 0;
-
+
// LastConversionIdx - Index within the format string where we last saw
// a '%' character that starts a new format conversion.
unsigned LastConversionIdx = 0;
-
+
for (; StrIdx < StrLen; ++StrIdx) {
-
+
// Is the number of detected conversion conversions greater than
// the number of matching data arguments? If so, stop.
if (!HasVAListArg && numConversions > numDataArgs) break;
-
+
// Handle "\0"
if (Str[StrIdx] == '\0') {
// The string returned by getStrData() is not null-terminated,
@@ -1059,7 +1059,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
<< OrigFormatExpr->getSourceRange();
return;
}
-
+
// Ordinary characters (not processing a format conversion).
if (CurrentState == state_OrdChr) {
if (Str[StrIdx] == '%') {
@@ -1071,10 +1071,10 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
// Seen '%'. Now processing a format conversion.
switch (Str[StrIdx]) {
- // Handle dynamic precision or width specifier.
+ // Handle dynamic precision or width specifier.
case '*': {
++numConversions;
-
+
if (!HasVAListArg) {
if (numConversions > numDataArgs) {
SourceLocation Loc = getLocationOfStringLiteralByte(FExpr, StrIdx);
@@ -1085,39 +1085,39 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
else
Diag(Loc, diag::warn_printf_asterisk_width_missing_arg)
<< OrigFormatExpr->getSourceRange();
-
+
// Don't do any more checking. We'll just emit spurious errors.
return;
}
-
+
// Perform type checking on width/precision specifier.
const Expr *E = TheCall->getArg(format_idx+numConversions);
if (const BuiltinType *BT = E->getType()->getAsBuiltinType())
if (BT->getKind() == BuiltinType::Int)
break;
-
+
SourceLocation Loc = getLocationOfStringLiteralByte(FExpr, StrIdx);
-
+
if (Str[StrIdx-1] == '.')
Diag(Loc, diag::warn_printf_asterisk_precision_wrong_type)
<< E->getType() << E->getSourceRange();
else
Diag(Loc, diag::warn_printf_asterisk_width_wrong_type)
<< E->getType() << E->getSourceRange();
-
- break;
+
+ break;
}
}
-
+
// Characters which can terminate a format conversion
// (e.g. "%d"). Characters that specify length modifiers or
// other flags are handled by the default case below.
//
- // FIXME: additional checks will go into the following cases.
+ // FIXME: additional checks will go into the following cases.
case 'i':
case 'd':
- case 'o':
- case 'u':
+ case 'o':
+ case 'u':
case 'x':
case 'X':
case 'D':
@@ -1135,7 +1135,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
case 'C':
case 'S':
case 's':
- case 'p':
+ case 'p':
++numConversions;
CurrentState = state_OrdChr;
break;
@@ -1151,21 +1151,21 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
CurrentState = state_OrdChr;
SourceLocation Loc = getLocationOfStringLiteralByte(FExpr,
LastConversionIdx);
-
+
Diag(Loc, diag::warn_printf_write_back)<<OrigFormatExpr->getSourceRange();
break;
}
-
+
// Handle "%@"
case '@':
// %@ is allowed in ObjC format strings only.
- if(ObjCFExpr != NULL)
- CurrentState = state_OrdChr;
+ if (ObjCFExpr != NULL)
+ CurrentState = state_OrdChr;
else {
// Issue a warning: invalid format conversion.
- SourceLocation Loc =
+ SourceLocation Loc =
getLocationOfStringLiteralByte(FExpr, LastConversionIdx);
-
+
Diag(Loc, diag::warn_printf_invalid_conversion)
<< std::string(Str+LastConversionIdx,
Str+std::min(LastConversionIdx+2, StrLen))
@@ -1173,7 +1173,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
}
++numConversions;
break;
-
+
// Handle "%%"
case '%':
// Sanity check: Was the first "%" character the previous one?
@@ -1181,23 +1181,23 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
// conversion, and that the current "%" character is the start
// of a new conversion.
if (StrIdx - LastConversionIdx == 1)
- CurrentState = state_OrdChr;
+ CurrentState = state_OrdChr;
else {
// Issue a warning: invalid format conversion.
SourceLocation Loc =
getLocationOfStringLiteralByte(FExpr, LastConversionIdx);
-
+
Diag(Loc, diag::warn_printf_invalid_conversion)
<< std::string(Str+LastConversionIdx, Str+StrIdx)
<< OrigFormatExpr->getSourceRange();
-
+
// This conversion is broken. Advance to the next format
// conversion.
LastConversionIdx = StrIdx;
++numConversions;
}
break;
-
+
default:
// This case catches all other characters: flags, widths, etc.
// We should eventually process those as well.
@@ -1209,21 +1209,21 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
// Issue a warning: invalid format conversion.
SourceLocation Loc =
getLocationOfStringLiteralByte(FExpr, LastConversionIdx);
-
+
Diag(Loc, diag::warn_printf_invalid_conversion)
<< std::string(Str+LastConversionIdx,
Str+std::min(LastConversionIdx+2, StrLen))
<< OrigFormatExpr->getSourceRange();
return;
}
-
+
if (!HasVAListArg) {
// CHECK: Does the number of format conversions exceed the number
// of data arguments?
if (numConversions > numDataArgs) {
SourceLocation Loc =
getLocationOfStringLiteralByte(FExpr, LastConversionIdx);
-
+
Diag(Loc, diag::warn_printf_insufficient_data_args)
<< OrigFormatExpr->getSourceRange();
}
@@ -1246,13 +1246,13 @@ static DeclRefExpr* EvalAddr(Expr* E);
void
Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc) {
-
+
// Perform checking for returned stack addresses.
if (lhsType->isPointerType() || lhsType->isBlockPointerType()) {
if (DeclRefExpr *DR = EvalAddr(RetValExp))
Diag(DR->getLocStart(), diag::warn_ret_stack_addr)
<< DR->getDecl()->getDeclName() << RetValExp->getSourceRange();
-
+
// Skip over implicit cast expressions when checking for block expressions.
RetValExp = RetValExp->IgnoreParenCasts();
@@ -1279,7 +1279,7 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
///
/// EvalAddr processes expressions that are pointers that are used as
/// references (and not L-values). EvalVal handles all other values.
-/// At the base case of the recursion is a check for a DeclRefExpr* in
+/// At the base case of the recursion is a check for a DeclRefExpr* in
/// the refers to a stack variable.
///
/// This implementation handles:
@@ -1296,7 +1296,7 @@ static DeclRefExpr* EvalAddr(Expr *E) {
E->getType()->isBlockPointerType() ||
E->getType()->isObjCQualifiedIdType()) &&
"EvalAddr only works on pointers");
-
+
// Our "symbolic interpreter" is just a dispatch off the currently
// viewed AST node. We then recursively traverse the AST by calling
// EvalAddr and EvalVal appropriately.
@@ -1309,28 +1309,28 @@ static DeclRefExpr* EvalAddr(Expr *E) {
// The only unary operator that make sense to handle here
// is AddrOf. All others don't make sense as pointers.
UnaryOperator *U = cast<UnaryOperator>(E);
-
+
if (U->getOpcode() == UnaryOperator::AddrOf)
return EvalVal(U->getSubExpr());
else
return NULL;
}
-
+
case Stmt::BinaryOperatorClass: {
// Handle pointer arithmetic. All other binary operators are not valid
// in this context.
BinaryOperator *B = cast<BinaryOperator>(E);
BinaryOperator::Opcode op = B->getOpcode();
-
+
if (op != BinaryOperator::Add && op != BinaryOperator::Sub)
return NULL;
-
+
Expr *Base = B->getLHS();
// Determine which argument is the real pointer base. It could be
// the RHS argument instead of the LHS.
if (!Base->getType()->isPointerType()) Base = B->getRHS();
-
+
assert (Base->getType()->isPointerType());
return EvalAddr(Base);
}
@@ -1339,7 +1339,7 @@ static DeclRefExpr* EvalAddr(Expr *E) {
// valid DeclRefExpr*s. If one of them is valid, we return it.
case Stmt::ConditionalOperatorClass: {
ConditionalOperator *C = cast<ConditionalOperator>(E);
-
+
// Handle the GNU extension for missing LHS.
if (Expr *lhsExpr = C->getLHS())
if (DeclRefExpr* LHS = EvalAddr(lhsExpr))
@@ -1347,7 +1347,7 @@ static DeclRefExpr* EvalAddr(Expr *E) {
return EvalAddr(C->getRHS());
}
-
+
// For casts, we need to handle conversions from arrays to
// pointer values, and pointer-to-pointer conversions.
case Stmt::ImplicitCastExprClass:
@@ -1355,7 +1355,7 @@ static DeclRefExpr* EvalAddr(Expr *E) {
case Stmt::CXXFunctionalCastExprClass: {
Expr* SubExpr = cast<CastExpr>(E)->getSubExpr();
QualType T = SubExpr->getType();
-
+
if (SubExpr->getType()->isPointerType() ||
SubExpr->getType()->isBlockPointerType() ||
SubExpr->getType()->isObjCQualifiedIdType())
@@ -1365,7 +1365,7 @@ static DeclRefExpr* EvalAddr(Expr *E) {
else
return 0;
}
-
+
// C++ casts. For dynamic casts, static casts, and const casts, we
// are always converting from a pointer-to-pointer, so we just blow
// through the cast. In the case the dynamic cast doesn't fail (and
@@ -1373,9 +1373,9 @@ static DeclRefExpr* EvalAddr(Expr *E) {
// where we return the address of a stack variable. For Reinterpre
// FIXME: The comment about is wrong; we're not always converting
// from pointer to pointer. I'm guessing that this code should also
- // handle references to objects.
- case Stmt::CXXStaticCastExprClass:
- case Stmt::CXXDynamicCastExprClass:
+ // handle references to objects.
+ case Stmt::CXXStaticCastExprClass:
+ case Stmt::CXXDynamicCastExprClass:
case Stmt::CXXConstCastExprClass:
case Stmt::CXXReinterpretCastExprClass: {
Expr *S = cast<CXXNamedCastExpr>(E)->getSubExpr();
@@ -1384,62 +1384,62 @@ static DeclRefExpr* EvalAddr(Expr *E) {
else
return NULL;
}
-
+
// Everything else: we simply don't reason about them.
default:
return NULL;
}
}
-
+
/// EvalVal - This function is complements EvalAddr in the mutual recursion.
/// See the comments for EvalAddr for more details.
static DeclRefExpr* EvalVal(Expr *E) {
-
+
// We should only be called for evaluating non-pointer expressions, or
// expressions with a pointer type that are not used as references but instead
// are l-values (e.g., DeclRefExpr with a pointer type).
-
+
// Our "symbolic interpreter" is just a dispatch off the currently
// viewed AST node. We then recursively traverse the AST by calling
// EvalAddr and EvalVal appropriately.
switch (E->getStmtClass()) {
- case Stmt::DeclRefExprClass:
+ case Stmt::DeclRefExprClass:
case Stmt::QualifiedDeclRefExprClass: {
// DeclRefExpr: the base case. When we hit a DeclRefExpr we are looking
// at code that refers to a variable's name. We check if it has local
// storage within the function, and if so, return the expression.
DeclRefExpr *DR = cast<DeclRefExpr>(E);
-
+
if (VarDecl *V = dyn_cast<VarDecl>(DR->getDecl()))
- if(V->hasLocalStorage() && !V->getType()->isReferenceType()) return DR;
-
+ if (V->hasLocalStorage() && !V->getType()->isReferenceType()) return DR;
+
return NULL;
}
-
+
case Stmt::ParenExprClass:
// Ignore parentheses.
return EvalVal(cast<ParenExpr>(E)->getSubExpr());
-
+
case Stmt::UnaryOperatorClass: {
// The only unary operator that make sense to handle here
// is Deref. All others don't resolve to a "name." This includes
// handling all sorts of rvalues passed to a unary operator.
UnaryOperator *U = cast<UnaryOperator>(E);
-
+
if (U->getOpcode() == UnaryOperator::Deref)
return EvalAddr(U->getSubExpr());
return NULL;
}
-
+
case Stmt::ArraySubscriptExprClass: {
// Array subscripts are potential references to data on the stack. We
// retrieve the DeclRefExpr* for the array variable if it indeed
// has local storage.
return EvalAddr(cast<ArraySubscriptExpr>(E)->getBase());
}
-
+
case Stmt::ConditionalOperatorClass: {
// For conditional operators we need to see if either the LHS or RHS are
// non-NULL DeclRefExpr's. If one is non-NULL, we return it.
@@ -1452,18 +1452,18 @@ static DeclRefExpr* EvalVal(Expr *E) {
return EvalVal(C->getRHS());
}
-
+
// Accesses to members are potential references to data on the stack.
case Stmt::MemberExprClass: {
MemberExpr *M = cast<MemberExpr>(E);
-
+
// Check for indirect access. We only want direct field accesses.
if (!M->isArrow())
return EvalVal(M->getBase());
else
return NULL;
}
-
+
// Everything else: we simply don't reason about them.
default:
return NULL;
@@ -1477,7 +1477,7 @@ static DeclRefExpr* EvalVal(Expr *E) {
/// to do what the programmer intended.
void Sema::CheckFloatComparison(SourceLocation loc, Expr* lex, Expr *rex) {
bool EmitWarning = true;
-
+
Expr* LeftExprSansParen = lex->IgnoreParens();
Expr* RightExprSansParen = rex->IgnoreParens();
@@ -1487,8 +1487,8 @@ void Sema::CheckFloatComparison(SourceLocation loc, Expr* lex, Expr *rex) {
if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(RightExprSansParen))
if (DRL->getDecl() == DRR->getDecl())
EmitWarning = false;
-
-
+
+
// Special case: check for comparisons against literals that can be exactly
// represented by APFloat. In such cases, do not emit a warning. This
// is a heuristic: often comparison against such literals are used to
@@ -1504,18 +1504,18 @@ void Sema::CheckFloatComparison(SourceLocation loc, Expr* lex, Expr *rex) {
EmitWarning = false;
}
}
-
+
// Check for comparisons with builtin types.
if (EmitWarning)
if (CallExpr* CL = dyn_cast<CallExpr>(LeftExprSansParen))
if (CL->isBuiltinCall(Context))
EmitWarning = false;
-
+
if (EmitWarning)
if (CallExpr* CR = dyn_cast<CallExpr>(RightExprSansParen))
if (CR->isBuiltinCall(Context))
EmitWarning = false;
-
+
// Emit the diagnostic.
if (EmitWarning)
Diag(loc, diag::warn_floatingpoint_eq)
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 8074ab94bf..d49ba890b2 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -28,7 +28,7 @@
#include "clang/Basic/TargetInfo.h"
// FIXME: layering (ideally, Sema shouldn't be dependent on Lex API's)
#include "clang/Lex/Preprocessor.h"
-#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/HeaderSearch.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
@@ -37,7 +37,7 @@
using namespace clang;
/// getDeclName - Return a pretty name for the specified decl if possible, or
-/// an empty string if not. This is used for pretty crash reporting.
+/// an empty string if not. This is used for pretty crash reporting.
std::string Sema::getDeclName(DeclPtrTy d) {
Decl *D = d.getAs<Decl>();
if (NamedDecl *DN = dyn_cast_or_null<NamedDecl>(D))
@@ -75,16 +75,16 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
if (SS && isUnknownSpecialization(*SS)) {
if (!isClassName)
return 0;
-
- // We know from the grammar that this name refers to a type, so build a
+
+ // We know from the grammar that this name refers to a type, so build a
// TypenameType node to describe the type.
// FIXME: Record somewhere that this TypenameType node has no "typename"
// keyword associated with it.
return CheckTypenameType((NestedNameSpecifier *)SS->getScopeRep(),
II, SS->getRange()).getAsOpaquePtr();
}
-
- LookupResult Result
+
+ LookupResult Result
= LookupParsedName(S, SS, &II, LookupOrdinaryName, false, false);
NamedDecl *IIDecl = 0;
@@ -100,8 +100,8 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end();
Res != ResEnd; ++Res) {
if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) {
- if (!IIDecl ||
- (*Res)->getLocation().getRawEncoding() <
+ if (!IIDecl ||
+ (*Res)->getLocation().getRawEncoding() <
IIDecl->getLocation().getRawEncoding())
IIDecl = *Res;
}
@@ -133,11 +133,11 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
if (IIDecl) {
QualType T;
-
+
if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
// Check whether we can use this type
(void)DiagnoseUseOfDecl(IIDecl, NameLoc);
-
+
if (getLangOptions().CPlusPlus) {
// C++ [temp.local]p2:
// Within the scope of a class template specialization or
@@ -157,7 +157,7 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
} else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) {
// Check whether we can use this interface.
(void)DiagnoseUseOfDecl(IIDecl, NameLoc);
-
+
T = Context.getObjCInterfaceType(IDecl);
} else
return 0;
@@ -188,7 +188,7 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) {
case TagDecl::TK_enum: return DeclSpec::TST_enum;
}
}
-
+
return DeclSpec::TST_unspecified;
}
@@ -284,7 +284,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
// Move up the scope chain until we find the nearest enclosing
// non-transparent context. The declaration will be introduced into this
// scope.
- while (S->getEntity() &&
+ while (S->getEntity() &&
((DeclContext *)S->getEntity())->isTransparentContext())
S = S->getParent();
@@ -304,7 +304,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
// in this case the class name or enumeration name is hidden.
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
// We are pushing the name of a tag (enum or class).
- if (CurContext->getLookupContext()
+ if (CurContext->getLookupContext()
== TD->getDeclContext()->getLookupContext()) {
// We're pushing the tag into the current context, which might
// require some reshuffling in the identifier resolver.
@@ -313,7 +313,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
IEnd = IdResolver.end();
if (I != IEnd && isDeclInScope(*I, CurContext, S)) {
NamedDecl *PrevDecl = *I;
- for (; I != IEnd && isDeclInScope(*I, CurContext, S);
+ for (; I != IEnd && isDeclInScope(*I, CurContext, S);
PrevDecl = *I, ++I) {
if (TD->declarationReplaces(*I)) {
// This is a redeclaration. Remove it from the chain and
@@ -336,7 +336,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
// before we find the new declaration, so insert the new
// declaration at the end of the chain.
IdResolver.AddShadowedDecl(TD, PrevDecl);
-
+
return;
}
}
@@ -360,7 +360,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
} else if (isa<ObjCInterfaceDecl>(D)) {
// We're pushing an Objective-C interface into the current
// context. If there is already an alias declaration, remove it first.
- for (IdentifierResolver::iterator
+ for (IdentifierResolver::iterator
I = IdResolver.begin(D->getDeclName()), IEnd = IdResolver.end();
I != IEnd; ++I) {
if (isa<ObjCCompatibleAliasDecl>(*I)) {
@@ -377,7 +377,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
if (S->decl_empty()) return;
assert((S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope)) &&
- "Scope shouldn't contain decls!");
+ "Scope shouldn't contain decls!");
for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
I != E; ++I) {
@@ -400,7 +400,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
// The third "scope" argument is 0 since we aren't enabling lazy built-in
// creation from this context.
NamedDecl *IDecl = LookupName(TUScope, Id, LookupOrdinaryName);
-
+
return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl);
}
@@ -413,7 +413,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
/// struct S6 {
/// enum { BAR } e;
/// };
-///
+///
/// void test_S6() {
/// struct S6 a;
/// a.e = BAR;
@@ -429,7 +429,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
/// contain non-field names.
Scope *Sema::getNonFieldDeclScope(Scope *S) {
while (((S->getFlags() & Scope::DeclScope) == 0) ||
- (S->getEntity() &&
+ (S->getEntity() &&
((DeclContext *)S->getEntity())->isTransparentContext()) ||
(S->isClassScope() && !getLangOptions().CPlusPlus))
S = S->getParent();
@@ -439,7 +439,7 @@ Scope *Sema::getNonFieldDeclScope(Scope *S) {
void Sema::InitBuiltinVaListType() {
if (!Context.getBuiltinVaListType().isNull())
return;
-
+
IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list");
NamedDecl *VaDecl = LookupName(TUScope, VaIdent, LookupOrdinaryName);
TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);
@@ -459,7 +459,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
InitBuiltinVaListType();
ASTContext::GetBuiltinTypeError Error;
- QualType R = Context.GetBuiltinType(BID, Error);
+ QualType R = Context.GetBuiltinType(BID, Error);
switch (Error) {
case ASTContext::GE_None:
// Okay
@@ -507,9 +507,9 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
VarDecl::None, 0));
New->setParams(Context, Params.data(), Params.size());
}
-
- AddKnownFunctionAttributes(New);
-
+
+ AddKnownFunctionAttributes(New);
+
// TUScope is the translation-unit scope to insert this function into.
// FIXME: This is hideous. We need to teach PushOnScopeChains to
// relate Scopes to DeclContexts, and probably eliminate CurContext
@@ -543,14 +543,14 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
// don't bother doing any merging checks.
if (New->isInvalidDecl() || OldD->isInvalidDecl())
return New->setInvalidDecl();
-
+
// Allow multiple definitions for ObjC built-in typedefs.
// FIXME: Verify the underlying types are equivalent!
if (getLangOptions().ObjC1) {
const IdentifierInfo *TypeID = New->getIdentifier();
switch (TypeID->getLength()) {
default: break;
- case 2:
+ case 2:
if (!TypeID->isStr("id"))
break;
Context.ObjCIdRedefinitionType = New->getUnderlyingType();
@@ -580,14 +580,14 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
// Verify the old decl was also a type.
TypeDecl *Old = dyn_cast<TypeDecl>(OldD);
if (!Old) {
- Diag(New->getLocation(), diag::err_redefinition_different_kind)
+ Diag(New->getLocation(), diag::err_redefinition_different_kind)
<< New->getDeclName();
if (OldD->getLocation().isValid())
Diag(OldD->getLocation(), diag::note_previous_definition);
return New->setInvalidDecl();
}
- // Determine the "old" type we'll use for checking and diagnostics.
+ // Determine the "old" type we'll use for checking and diagnostics.
QualType OldType;
if (TypedefDecl *OldTypedef = dyn_cast<TypedefDecl>(Old))
OldType = OldTypedef->getUnderlyingType();
@@ -597,8 +597,8 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
// If the typedef types are not identical, reject them in all languages and
// with any extensions enabled.
- if (OldType != New->getUnderlyingType() &&
- Context.getCanonicalType(OldType) !=
+ if (OldType != New->getUnderlyingType() &&
+ Context.getCanonicalType(OldType) !=
Context.getCanonicalType(New->getUnderlyingType())) {
Diag(New->getLocation(), diag::err_redefinition_different_typedef)
<< New->getUnderlyingType() << OldType;
@@ -606,7 +606,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
Diag(Old->getLocation(), diag::note_previous_definition);
return New->setInvalidDecl();
}
-
+
if (getLangOptions().Microsoft)
return;
@@ -631,7 +631,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
(Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
Context.getSourceManager().isInSystemHeader(New->getLocation())))
return;
-
+
Diag(New->getLocation(), diag::warn_redefinition_of_typedef)
<< New->getDeclName();
Diag(Old->getLocation(), diag::note_previous_definition);
@@ -640,7 +640,7 @@ void Sema::MergeTypeDefDecl(TypedefDecl *New, Decl *OldD) {
/// DeclhasAttr - returns true if decl Declaration already has the target
/// attribute.
-static bool
+static bool
DeclHasAttr(const Decl *decl, const Attr *target) {
for (const Attr *attr = decl->getAttrs(); attr; attr = attr->getNext())
if (attr->getKind() == target->getKind())
@@ -680,15 +680,15 @@ struct GNUCompatibleParamWarning {
///
/// Returns true if there was an error, false otherwise.
bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
- assert(!isa<OverloadedFunctionDecl>(OldD) &&
+ assert(!isa<OverloadedFunctionDecl>(OldD) &&
"Cannot merge with an overloaded function declaration");
// Verify the old decl was also a function.
FunctionDecl *Old = 0;
- if (FunctionTemplateDecl *OldFunctionTemplate
+ if (FunctionTemplateDecl *OldFunctionTemplate
= dyn_cast<FunctionTemplateDecl>(OldD))
Old = OldFunctionTemplate->getTemplatedDecl();
- else
+ else
Old = dyn_cast<FunctionDecl>(OldD);
if (!Old) {
Diag(New->getLocation(), diag::err_redefinition_different_kind)
@@ -704,12 +704,12 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
PrevDiag = diag::note_previous_definition;
else if (Old->isImplicit())
PrevDiag = diag::note_previous_implicit_declaration;
- else
+ else
PrevDiag = diag::note_previous_declaration;
-
+
QualType OldQType = Context.getCanonicalType(Old->getType());
QualType NewQType = Context.getCanonicalType(New->getType());
-
+
if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
New->getStorageClass() == FunctionDecl::Static &&
Old->getStorageClass() != FunctionDecl::Static) {
@@ -722,11 +722,11 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
if (getLangOptions().CPlusPlus) {
// (C++98 13.1p2):
// Certain function declarations cannot be overloaded:
- // -- Function declarations that differ only in the return type
+ // -- Function declarations that differ only in the return type
// cannot be overloaded.
- QualType OldReturnType
+ QualType OldReturnType
= cast<FunctionType>(OldQType.getTypePtr())->getResultType();
- QualType NewReturnType
+ QualType NewReturnType
= cast<FunctionType>(NewQType.getTypePtr())->getResultType();
if (OldReturnType != NewReturnType) {
Diag(New->getLocation(), diag::err_ovl_diff_return_type);
@@ -738,8 +738,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
const CXXMethodDecl* NewMethod = dyn_cast<CXXMethodDecl>(New);
if (OldMethod && NewMethod && !NewMethod->getFriendObjectKind() &&
NewMethod->getLexicalDeclContext()->isRecord()) {
- // -- Member function declarations with the same name and the
- // same parameter types cannot be overloaded if any of them
+ // -- Member function declarations with the same name and the
+ // same parameter types cannot be overloaded if any of them
// is a static member function declaration.
if (OldMethod->isStatic() || NewMethod->isStatic()) {
Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member);
@@ -760,7 +760,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
NewDiag = diag::err_conv_function_redeclared;
else
NewDiag = diag::err_member_redeclared;
-
+
Diag(New->getLocation(), NewDiag);
Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
}
@@ -797,8 +797,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
// Synthesize a parameter for each argument type.
llvm::SmallVector<ParmVarDecl*, 16> Params;
- for (FunctionProtoType::arg_type_iterator
- ParamType = OldProto->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator
+ ParamType = OldProto->arg_type_begin(),
ParamEnd = OldProto->arg_type_end();
ParamType != ParamEnd; ++ParamType) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, New,
@@ -810,7 +810,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
}
New->setParams(Context, Params.data(), Params.size());
- }
+ }
return MergeCompatibleFunctionDecls(New, Old);
}
@@ -832,25 +832,25 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
Old->getNumParams() == New->getNumParams()) {
llvm::SmallVector<QualType, 16> ArgTypes;
llvm::SmallVector<GNUCompatibleParamWarning, 16> Warnings;
- const FunctionProtoType *OldProto
+ const FunctionProtoType *OldProto
= Old->getType()->getAsFunctionProtoType();
- const FunctionProtoType *NewProto
+ const FunctionProtoType *NewProto
= New->getType()->getAsFunctionProtoType();
-
+
// Determine whether this is the GNU C extension.
QualType MergedReturn = Context.mergeTypes(OldProto->getResultType(),
NewProto->getResultType());
bool LooseCompatible = !MergedReturn.isNull();
- for (unsigned Idx = 0, End = Old->getNumParams();
+ for (unsigned Idx = 0, End = Old->getNumParams();
LooseCompatible && Idx != End; ++Idx) {
ParmVarDecl *OldParm = Old->getParamDecl(Idx);
ParmVarDecl *NewParm = New->getParamDecl(Idx);
- if (Context.typesAreCompatible(OldParm->getType(),
+ if (Context.typesAreCompatible(OldParm->getType(),
NewProto->getArgType(Idx))) {
ArgTypes.push_back(NewParm->getType());
} else if (Context.typesAreCompatible(OldParm->getType(),
NewParm->getType())) {
- GNUCompatibleParamWarning Warn
+ GNUCompatibleParamWarning Warn
= { OldParm, NewParm, NewProto->getArgType(Idx) };
Warnings.push_back(Warn);
ArgTypes.push_back(NewParm->getType());
@@ -864,7 +864,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
diag::ext_param_promoted_not_compatible_with_prototype)
<< Warnings[Warn].PromotedType
<< Warnings[Warn].OldParm->getType();
- Diag(Warnings[Warn].OldParm->getLocation(),
+ Diag(Warnings[Warn].OldParm->getLocation(),
diag::note_previous_declaration);
}
@@ -904,7 +904,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
}
/// \brief Completes the merge of two function declarations that are
-/// known to be compatible.
+/// known to be compatible.
///
/// This routine handles the merging of attributes and other
/// properties of function declarations form the old declaration to
@@ -931,7 +931,7 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) {
New->setC99InlineDefinition(false);
else if (Old->isC99InlineDefinition() && !New->isC99InlineDefinition()) {
// Mark all preceding definitions as not being C99 inline definitions.
- for (const FunctionDecl *Prev = Old; Prev;
+ for (const FunctionDecl *Prev = Old; Prev;
Prev = Prev->getPreviousDeclaration())
const_cast<FunctionDecl *>(Prev)->setC99InlineDefinition(false);
}
@@ -943,7 +943,7 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) {
// Merge the "deleted" flag.
if (Old->isDeleted())
New->setDeleted();
-
+
if (getLangOptions().CPlusPlus)
return MergeCXXFunctionDecl(New, Old);
@@ -954,16 +954,16 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) {
/// and scope as a previous declaration 'Old'. Figure out how to resolve this
/// situation, merging decls or emitting diagnostics as appropriate.
///
-/// Tentative definition rules (C99 6.9.2p2) are checked by
-/// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
+/// Tentative definition rules (C99 6.9.2p2) are checked by
+/// FinalizeDeclaratorGroup. Unfortunately, we can't analyze tentative
/// definitions here, since the initializer hasn't been attached.
-///
+///
void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
// If either decl is invalid, make sure the new one is marked invalid and
// don't do any other checking.
if (New->isInvalidDecl() || OldD->isInvalidDecl())
return New->setInvalidDecl();
-
+
// Verify the old decl was also a variable.
VarDecl *Old = dyn_cast<VarDecl>(OldD);
if (!Old) {
@@ -981,14 +981,14 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
if (Context.hasSameType(New->getType(), Old->getType()))
MergedT = New->getType();
// C++ [basic.types]p7:
- // [...] The declared type of an array object might be an array of
- // unknown size and therefore be incomplete at one point in a
+ // [...] The declared type of an array object might be an array of
+ // unknown size and therefore be incomplete at one point in a
// translation unit and complete later on; [...]
- else if (Old->getType()->isIncompleteArrayType() &&
+ else if (Old->getType()->isIncompleteArrayType() &&
New->getType()->isArrayType()) {
- CanQual<ArrayType> OldArray
+ CanQual<ArrayType> OldArray
= Context.getCanonicalType(Old->getType())->getAs<ArrayType>();
- CanQual<ArrayType> NewArray
+ CanQual<ArrayType> NewArray
= Context.getCanonicalType(New->getType())->getAs<ArrayType>();
if (OldArray->getElementType() == NewArray->getElementType())
MergedT = New->getType();
@@ -997,7 +997,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
MergedT = Context.mergeTypes(New->getType(), Old->getType());
}
if (MergedT.isNull()) {
- Diag(New->getLocation(), diag::err_redefinition_different_type)
+ Diag(New->getLocation(), diag::err_redefinition_different_type)
<< New->getDeclName();
Diag(Old->getLocation(), diag::note_previous_definition);
return New->setInvalidDecl();
@@ -1011,7 +1011,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
Diag(Old->getLocation(), diag::note_previous_definition);
return New->setInvalidDecl();
}
- // C99 6.2.2p4:
+ // C99 6.2.2p4:
// For an identifier declared with the storage-class specifier
// extern in a scope in which a prior declaration of that
// identifier is visible,23) if the prior declaration specifies
@@ -1030,7 +1030,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
}
// Variables with external linkage are analyzed in FinalizeDeclaratorGroup.
-
+
// FIXME: The test for external storage here seems wrong? We still
// need to check for mismatches.
if (!New->hasExternalStorage() && !New->isFileVarDecl() &&
@@ -1063,7 +1063,7 @@ void Sema::MergeVarDecl(VarDecl *New, Decl *OldD) {
/// that functions not marked noreturn will return.
Sema::ControlFlowKind Sema::CheckFallThrough(Stmt *Root) {
llvm::OwningPtr<CFG> cfg (CFG::buildCFG(Root, &Context));
-
+
// FIXME: They should never return 0, fix that, delete this code.
if (cfg == 0)
return NeverFallThrough;
@@ -1175,7 +1175,7 @@ void Sema::CheckFallThroughForFunctionDef(Decl *D, Stmt *Body) {
if (MD->hasAttr<NoReturnAttr>())
HasNoReturn = true;
}
-
+
// Short circuit for compilation speed.
if ((Diags.getDiagnosticLevel(diag::warn_maybe_falloff_nonvoid_function)
== Diagnostic::Ignored || ReturnsVoid)
@@ -1228,7 +1228,7 @@ void Sema::CheckFallThroughForBlock(QualType BlockTy, Stmt *Body) {
if (FT->getNoReturnAttr())
HasNoReturn = true;
}
-
+
// Short circuit for compilation speed.
if (ReturnsVoid
&& !HasNoReturn
@@ -1279,10 +1279,10 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) {
Param->setInvalidDecl();
HasInvalidParm = true;
}
-
+
// C99 6.9.1p5: If the declarator includes a parameter type list, the
// declaration of each parameter shall include an identifier.
- if (Param->getIdentifier() == 0 &&
+ if (Param->getIdentifier() == 0 &&
!Param->isImplicit() &&
!getLangOptions().CPlusPlus)
Diag(Param->getLocation(), diag::err_parameter_name_omitted);
@@ -1333,7 +1333,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
return DeclPtrTy::make(Tag);
}
- if (!DS.isMissingDeclaratorOk() &&
+ if (!DS.isMissingDeclaratorOk() &&
DS.getTypeSpecType() != DeclSpec::TST_error) {
// Warn about typedefs of enums without names, since this is an
// extension in both Microsoft an GNU.
@@ -1348,7 +1348,7 @@ Sema::DeclPtrTy Sema::ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS) {
<< DS.getSourceRange();
return DeclPtrTy();
}
-
+
return DeclPtrTy::make(Tag);
}
@@ -1382,7 +1382,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
// The names of the members of an anonymous union shall be
// distinct from the names of any other entity in the
// scope in which the anonymous union is declared.
- unsigned diagKind
+ unsigned diagKind
= AnonRecord->isUnion()? diag::err_anonymous_union_member_redecl
: diag::err_anonymous_struct_member_redecl;
Diag((*F)->getLocation(), diagKind)
@@ -1403,7 +1403,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
= (*F)->getType()->getAs<RecordType>()) {
RecordDecl *InnerRecord = InnerRecordType->getDecl();
if (InnerRecord->isAnonymousStructOrUnion())
- Invalid = Invalid ||
+ Invalid = Invalid ||
InjectAnonymousStructOrUnionMembers(S, Owner, InnerRecord);
}
}
@@ -1414,7 +1414,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner,
/// ActOnAnonymousStructOrUnion - Handle the declaration of an
/// anonymous structure or union. Anonymous unions are a C++ feature
/// (C++ [class.union]) and a GNU C extension; anonymous structures
-/// are a GNU C and GNU C++ extension.
+/// are a GNU C and GNU C++ extension.
Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
RecordDecl *Record) {
DeclContext *Owner = Record->getDeclContext();
@@ -1424,7 +1424,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
Diag(Record->getLocation(), diag::ext_anonymous_union);
else if (!Record->isUnion())
Diag(Record->getLocation(), diag::ext_anonymous_struct);
-
+
// C and C++ require different kinds of checks for anonymous
// structs/unions.
bool Invalid = false;
@@ -1436,7 +1436,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
// global namespace shall be declared static.
if (DS.getStorageClassSpec() != DeclSpec::SCS_static &&
(isa<TranslationUnitDecl>(Owner) ||
- (isa<NamespaceDecl>(Owner) &&
+ (isa<NamespaceDecl>(Owner) &&
cast<NamespaceDecl>(Owner)->getDeclName()))) {
Diag(Record->getLocation(), diag::err_anonymous_union_not_static);
Invalid = true;
@@ -1444,13 +1444,13 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
// Recover by adding 'static'.
DS.SetStorageClassSpec(DeclSpec::SCS_static, SourceLocation(),
PrevSpec, DiagID);
- }
+ }
// C++ [class.union]p3:
// A storage class is not allowed in a declaration of an
// anonymous union in a class scope.
else if (DS.getStorageClassSpec() != DeclSpec::SCS_unspecified &&
isa<RecordDecl>(Owner)) {
- Diag(DS.getStorageClassSpecLoc(),
+ Diag(DS.getStorageClassSpecLoc(),
diag::err_anonymous_union_with_storage_spec);
Invalid = true;
@@ -1459,7 +1459,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
PrevSpec, DiagID);
}
- // C++ [class.union]p2:
+ // C++ [class.union]p2:
// The member-specification of an anonymous union shall only
// define non-static data members. [Note: nested types and
// functions cannot be declared within an anonymous union. ]
@@ -1505,7 +1505,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
Invalid = true;
}
}
- }
+ }
if (!Record->isUnion() && !Owner->isRecord()) {
Diag(Record->getLocation(), diag::err_anonymous_struct_not_member)
@@ -1513,11 +1513,11 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
Invalid = true;
}
- // Create a declaration for this anonymous struct/union.
+ // Create a declaration for this anonymous struct/union.
NamedDecl *Anon = 0;
if (RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(),
- /*IdentifierInfo=*/0,
+ /*IdentifierInfo=*/0,
Context.getTypeDeclType(Record),
// FIXME: Type source info.
/*DInfo=*/0,
@@ -1545,7 +1545,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
}
Anon = VarDecl::Create(Context, Owner, Record->getLocation(),
- /*IdentifierInfo=*/0,
+ /*IdentifierInfo=*/0,
Context.getTypeDeclType(Record),
// FIXME: Type source info.
/*DInfo=*/0,
@@ -1569,7 +1569,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
// members of this anonymous struct/union type, because otherwise
// the members could be injected twice: once by DeclContext when it
// builds its lookup table, and once by
- // InjectAnonymousStructOrUnionMembers.
+ // InjectAnonymousStructOrUnionMembers.
Record->setAnonymousStructOrUnion(true);
if (Invalid)
@@ -1643,8 +1643,8 @@ static bool isNearlyMatchingFunction(ASTContext &Context,
return true;
}
-Sema::DeclPtrTy
-Sema::HandleDeclarator(Scope *S, Declarator &D,
+Sema::DeclPtrTy
+Sema::HandleDeclarator(Scope *S, Declarator &D,
MultiTemplateParamsArg TemplateParamLists,
bool IsFunctionDefinition) {
DeclarationName Name = GetNameForDeclarator(D);
@@ -1658,13 +1658,13 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
<< D.getDeclSpec().getSourceRange() << D.getSourceRange();
return DeclPtrTy();
}
-
+
// The scope passed in may not be a decl scope. Zip up the scope tree until
// we find one that is.
while ((S->getFlags() & Scope::DeclScope) == 0 ||
(S->getFlags() & Scope::TemplateParamScope) != 0)
S = S->getParent();
-
+
// If this is an out-of-line definition of a member of a class template
// or class template partial specialization, we may need to rebuild the
// type specifier in the declarator. See RebuildTypeInCurrentInstantiation()
@@ -1689,7 +1689,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
DS.UpdateTypeRep(T.getAsOpaquePtr());
}
}
-
+
DeclContext *DC;
NamedDecl *PrevDecl;
NamedDecl *New;
@@ -1721,24 +1721,24 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
NameKind = LookupRedeclarationWithLinkage;
DC = CurContext;
- PrevDecl = LookupName(S, Name, NameKind, true,
+ PrevDecl = LookupName(S, Name, NameKind, true,
NameKind == LookupRedeclarationWithLinkage,
D.getIdentifierLoc());
} else { // Something like "int foo::x;"
DC = computeDeclContext(D.getCXXScopeSpec(), true);
-
+
if (!DC) {
// If we could not compute the declaration context, it's because the
// declaration context is dependent but does not refer to a class,
// class template, or class template partial specialization. Complain
// and return early, to avoid the coming semantic disaster.
- Diag(D.getIdentifierLoc(),
+ Diag(D.getIdentifierLoc(),
diag::err_template_qualified_declarator_no_match)
<< (NestedNameSpecifier*)D.getCXXScopeSpec().getScopeRep()
<< D.getCXXScopeSpec().getRange();
return DeclPtrTy();
}
-
+
PrevDecl = LookupQualifiedName(DC, Name, LookupOrdinaryName, true);
// C++ 7.3.1.2p2:
@@ -1762,11 +1762,11 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
//
// In this case, PrevDecl will point to the overload set
// containing the two f's declared in X, but neither of them
- // matches.
+ // matches.
// First check whether we named the global scope.
if (isa<TranslationUnitDecl>(DC)) {
- Diag(D.getIdentifierLoc(), diag::err_invalid_declarator_global_scope)
+ Diag(D.getIdentifierLoc(), diag::err_invalid_declarator_global_scope)
<< Name << D.getCXXScopeSpec().getRange();
} else if (!CurContext->Encloses(DC)) {
// The qualifying scope doesn't enclose the original declaration.
@@ -1775,7 +1775,7 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
SourceRange R = D.getCXXScopeSpec().getRange();
if (isa<FunctionDecl>(CurContext))
Diag(L, diag::err_invalid_declarator_in_function) << Name << R;
- else
+ else
Diag(L, diag::err_invalid_declarator_scope)
<< Name << cast<NamedDecl>(DC) << R;
D.setInvalidType();
@@ -1784,10 +1784,10 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
if (PrevDecl && PrevDecl->isTemplateParameter()) {
// Maybe we will complain about the shadowed template parameter.
- if (!D.isInvalidType())
+ if (!D.isInvalidType())
if (DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl))
D.setInvalidType();
-
+
// Just pretend that we didn't see the previous declaration.
PrevDecl = 0;
}
@@ -1806,26 +1806,26 @@ Sema::HandleDeclarator(Scope *S, Declarator &D,
Diag(D.getIdentifierLoc(), diag::err_template_typedef);
return DeclPtrTy();
}
-
+
New = ActOnTypedefDeclarator(S, D, DC, R, DInfo, PrevDecl, Redeclaration);
} else if (R->isFunctionType()) {
- New = ActOnFunctionDeclarator(S, D, DC, R, DInfo, PrevDecl,
+ New = ActOnFunctionDeclarator(S, D, DC, R, DInfo, PrevDecl,
move(TemplateParamLists),
IsFunctionDefinition, Redeclaration);
} else {
- New = ActOnVariableDeclarator(S, D, DC, R, DInfo, PrevDecl,
+ New = ActOnVariableDeclarator(S, D, DC, R, DInfo, PrevDecl,
move(TemplateParamLists),
Redeclaration);
}
if (New == 0)
return DeclPtrTy();
-
+
// If this has an identifier and is not an invalid redeclaration,
// add it to the scope stack.
if (Name && !(Redeclaration && New->isInvalidDecl()))
PushOnScopeChains(New, S);
-
+
return DeclPtrTy::make(New);
}
@@ -1857,7 +1857,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
// FIXME: We should probably handle this case
if (VLATy->getElementType()->isVariablyModifiedType())
return QualType();
-
+
Expr::EvalResult EvalResult;
if (!VLATy->getSizeExpr() ||
!VLATy->getSizeExpr()->Evaluate(EvalResult, Context) ||
@@ -1884,7 +1884,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
/// \brief Register the given locally-scoped external C declaration so
/// that it can be found later for redeclarations
-void
+void
Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl,
Scope *S) {
assert(ND->getLexicalDeclContext()->isFunctionOrMethod() &&
@@ -1915,15 +1915,15 @@ void Sema::DiagnoseFunctionSpecifiers(Declarator& D) {
// FIXME: We should probably indicate the identifier in question to avoid
// confusion for constructs like "inline int a(), b;"
if (D.getDeclSpec().isInlineSpecified())
- Diag(D.getDeclSpec().getInlineSpecLoc(),
+ Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_non_function);
if (D.getDeclSpec().isVirtualSpecified())
- Diag(D.getDeclSpec().getVirtualSpecLoc(),
+ Diag(D.getDeclSpec().getVirtualSpecLoc(),
diag::err_virtual_non_function);
if (D.getDeclSpec().isExplicitSpecified())
- Diag(D.getDeclSpec().getExplicitSpecLoc(),
+ Diag(D.getDeclSpec().getExplicitSpecLoc(),
diag::err_explicit_non_function);
}
@@ -1952,7 +1952,7 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
TypedefDecl *NewTD = ParseTypedefDecl(S, D, R);
if (!NewTD) return 0;
-
+
if (D.isInvalidType())
NewTD->setInvalidDecl();
@@ -1970,7 +1970,7 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
QualType T = NewTD->getUnderlyingType();
if (T->isVariablyModifiedType()) {
CurFunctionNeedsScopeChecking = true;
-
+
if (S->getFnParent() == 0) {
bool SizeIsNegative;
QualType FixedTy =
@@ -2017,13 +2017,13 @@ Sema::ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
///
/// \param PrevDecl the previous declaration found by name
/// lookup
-///
+///
/// \param DC the context in which the new declaration is being
/// declared.
///
/// \returns true if PrevDecl is an out-of-scope previous declaration
/// for a new delcaration with the same name.
-static bool
+static bool
isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC,
ASTContext &Context) {
if (!PrevDecl)
@@ -2057,10 +2057,10 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC,
OuterContext = OuterContext->getParent();
while (!PrevOuterContext->isFileContext())
PrevOuterContext = PrevOuterContext->getParent();
-
+
// The previous declaration is in a different namespace, so it
// isn't the same function.
- if (OuterContext->getPrimaryContext() !=
+ if (OuterContext->getPrimaryContext() !=
PrevOuterContext->getPrimaryContext())
return false;
}
@@ -2114,7 +2114,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// C99 6.9p2: The storage-class specifiers auto and register shall not
// appear in the declaration specifiers in an external declaration.
if (SC == VarDecl::Auto || SC == VarDecl::Register) {
-
+
// If this is a register variable with an asm label specified, then this
// is a GNU extension.
if (SC == VarDecl::Register && D.getAsmLabel())
@@ -2127,7 +2127,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
if (DC->isRecord() && !CurContext->isRecord()) {
// This is an out-of-line definition of a static data member.
if (SC == VarDecl::Static) {
- Diag(D.getDeclSpec().getStorageClassSpecLoc(),
+ Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_static_out_of_line)
<< CodeModificationHint::CreateRemoval(
SourceRange(D.getDeclSpec().getStorageClassSpecLoc()));
@@ -2137,12 +2137,12 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
if (SC == VarDecl::Static) {
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
if (RD->isLocalClass())
- Diag(D.getIdentifierLoc(),
+ Diag(D.getIdentifierLoc(),
diag::err_static_data_member_not_allowed_in_local_class)
<< Name << RD->getDeclName();
}
}
-
+
// Match up the template parameter lists with the scope specifier, then
// determine whether we have a template or a template specialization.
if (TemplateParameterList *TemplateParams
@@ -2161,20 +2161,20 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
} else {
// There is an extraneous 'template<>' for this variable. Complain
// about it, but allow the declaration of the variable.
- Diag(TemplateParams->getTemplateLoc(),
+ Diag(TemplateParams->getTemplateLoc(),
diag::err_template_variable_noparams)
<< II
<< SourceRange(TemplateParams->getTemplateLoc(),
- TemplateParams->getRAngleLoc());
+ TemplateParams->getRAngleLoc());
}
- }
-
- NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
+ }
+
+ NewVD = VarDecl::Create(Context, DC, D.getIdentifierLoc(),
II, R, DInfo, SC);
if (D.isInvalidType())
NewVD->setInvalidDecl();
-
+
if (D.getDeclSpec().isThreadSpecified()) {
if (NewVD->hasLocalStorage())
Diag(D.getDeclSpec().getThreadSpecLoc(), diag::err_thread_non_global);
@@ -2194,7 +2194,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Handle GNU asm-label extension (encoded as an attribute).
if (Expr *E = (Expr*) D.getAsmLabel()) {
// The parser guarantees this is a string.
- StringLiteral *SE = cast<StringLiteral>(E);
+ StringLiteral *SE = cast<StringLiteral>(E);
NewVD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(),
SE->getByteLength())));
}
@@ -2205,7 +2205,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
if (PrevDecl && !isDeclInScope(PrevDecl, DC, S) &&
!(NewVD->hasLinkage() &&
isOutOfScopePreviousDeclaration(PrevDecl, DC, Context)))
- PrevDecl = 0;
+ PrevDecl = 0;
// Merge the decl with the existing one if appropriate.
if (PrevDecl) {
@@ -2219,9 +2219,9 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
}
} else if (D.getCXXScopeSpec().isSet()) {
// No previous declaration in the qualifying scope.
- NestedNameSpecifier *NNS =
+ NestedNameSpecifier *NNS =
(NestedNameSpecifier *)D.getCXXScopeSpec().getScopeRep();
- DiagnoseMissingMember(D.getIdentifierLoc(), Name, NNS,
+ DiagnoseMissingMember(D.getIdentifierLoc(), Name, NNS,
D.getCXXScopeSpec().getRange());
NewVD->setInvalidDecl();
}
@@ -2261,17 +2261,17 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
// If the decl is already known invalid, don't check it.
if (NewVD->isInvalidDecl())
return;
-
+
QualType T = NewVD->getType();
if (T->isObjCInterfaceType()) {
Diag(NewVD->getLocation(), diag::err_statically_allocated_object);
return NewVD->setInvalidDecl();
}
-
+
// The variable can not have an abstract class type.
if (RequireNonAbstractType(NewVD->getLocation(), T,
- diag::err_abstract_type_in_decl,
+ diag::err_abstract_type_in_decl,
AbstractVariableType))
return NewVD->setInvalidDecl();
@@ -2292,19 +2292,19 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
if (isVM || NewVD->hasAttr<CleanupAttr>() ||
NewVD->hasAttr<BlocksAttr>())
CurFunctionNeedsScopeChecking = true;
-
+
if ((isVM && NewVD->hasLinkage()) ||
(T->isVariableArrayType() && NewVD->hasGlobalStorage())) {
bool SizeIsNegative;
QualType FixedTy =
TryToFixInvalidVariablyModifiedType(T, Context, SizeIsNegative);
-
+
if (FixedTy.isNull() && T->isVariableArrayType()) {
const VariableArrayType *VAT = Context.getAsVariableArrayType(T);
- // FIXME: This won't give the correct result for
- // int a[10][n];
+ // FIXME: This won't give the correct result for
+ // int a[10][n];
SourceRange SizeRange = VAT->getSizeExpr()->getSourceRange();
-
+
if (NewVD->isFileVarDecl())
Diag(NewVD->getLocation(), diag::err_vla_decl_in_file_scope)
<< SizeRange;
@@ -2315,8 +2315,8 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
Diag(NewVD->getLocation(), diag::err_vla_decl_has_extern_linkage)
<< SizeRange;
return NewVD->setInvalidDecl();
- }
-
+ }
+
if (FixedTy.isNull()) {
if (NewVD->isFileVarDecl())
Diag(NewVD->getLocation(), diag::err_vm_decl_in_file_scope);
@@ -2324,7 +2324,7 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
Diag(NewVD->getLocation(), diag::err_vm_decl_has_extern_linkage);
return NewVD->setInvalidDecl();
}
-
+
Diag(NewVD->getLocation(), diag::warn_illegal_constant_array_size);
NewVD->setType(FixedTy);
}
@@ -2349,7 +2349,7 @@ void Sema::CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl,
Diag(NewVD->getLocation(), diag::err_block_on_nonlocal);
return NewVD->setInvalidDecl();
}
-
+
if (isVM && NewVD->hasAttr<BlocksAttr>()) {
Diag(NewVD->getLocation(), diag::err_block_on_vm);
return NewVD->setInvalidDecl();
@@ -2365,7 +2365,7 @@ static bool isUsingDecl(Decl *D) {
return isa<UsingDecl>(D) || isa<UnresolvedUsingDecl>(D);
}
-NamedDecl*
+NamedDecl*
Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
QualType R, DeclaratorInfo *DInfo,
NamedDecl* PrevDecl,
@@ -2380,7 +2380,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
case DeclSpec::SCS_auto:
case DeclSpec::SCS_register:
case DeclSpec::SCS_mutable:
- Diag(D.getDeclSpec().getStorageClassSpecLoc(),
+ Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_typecheck_sclass_func);
D.setInvalidType();
break;
@@ -2393,11 +2393,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// block scope shall have no explicit storage-class specifier
// other than extern
// See also (C++ [dcl.stc]p4).
- Diag(D.getDeclSpec().getStorageClassSpecLoc(),
+ Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_static_block_func);
SC = FunctionDecl::None;
} else
- SC = FunctionDecl::Static;
+ SC = FunctionDecl::Static;
break;
}
case DeclSpec::SCS_private_extern: SC = FunctionDecl::PrivateExtern;break;
@@ -2413,14 +2413,14 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Check that the return type is not an abstract class type.
// For record types, this is done by the AbstractClassUsageDiagnoser once
- // the class has been completely parsed.
+ // the class has been completely parsed.
if (!DC->isRecord() &&
- RequireNonAbstractType(D.getIdentifierLoc(),
+ RequireNonAbstractType(D.getIdentifierLoc(),
R->getAsFunctionType()->getResultType(),
- diag::err_abstract_type_in_decl,
+ diag::err_abstract_type_in_decl,
AbstractReturnType))
D.setInvalidType();
-
+
// Do not allow returning a objc interface by-value.
if (R->getAsFunctionType()->getResultType()->isObjCInterfaceType()) {
Diag(D.getIdentifierLoc(),
@@ -2451,7 +2451,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
R = CheckConstructorDeclarator(D, R, SC);
// Create the new declaration
- NewFD = CXXConstructorDecl::Create(Context,
+ NewFD = CXXConstructorDecl::Create(Context,
cast<CXXRecordDecl>(DC),
D.getIdentifierLoc(), Name, R, DInfo,
isExplicit, isInline,
@@ -2460,10 +2460,10 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// This is a C++ destructor declaration.
if (DC->isRecord()) {
R = CheckDestructorDeclarator(D, SC);
-
+
NewFD = CXXDestructorDecl::Create(Context,
cast<CXXRecordDecl>(DC),
- D.getIdentifierLoc(), Name, R,
+ D.getIdentifierLoc(), Name, R,
isInline,
/*isImplicitlyDeclared=*/false);
@@ -2474,7 +2474,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Create a FunctionDecl to satisfy the function definition parsing
// code path.
NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(),
- Name, R, DInfo, SC, isInline,
+ Name, R, DInfo, SC, isInline,
/*hasPrototype=*/true);
D.setInvalidType();
}
@@ -2484,26 +2484,26 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
diag::err_conv_function_not_member);
return 0;
}
-
+
CheckConversionDeclarator(D, R, SC);
NewFD = CXXConversionDecl::Create(Context, cast<CXXRecordDecl>(DC),
D.getIdentifierLoc(), Name, R, DInfo,
isInline, isExplicit);
-
+
isVirtualOkay = true;
} else if (DC->isRecord()) {
// If the of the function is the same as the name of the record, then this
- // must be an invalid constructor that has a return type.
- // (The parser checks for a return type and makes the declarator a
+ // must be an invalid constructor that has a return type.
+ // (The parser checks for a return type and makes the declarator a
// constructor if it has no return type).
- // must have an invalid constructor that has a return type
+ // must have an invalid constructor that has a return type
if (Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
Diag(D.getIdentifierLoc(), diag::err_constructor_return_type)
<< SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
<< SourceRange(D.getIdentifierLoc());
return 0;
}
-
+
// This is a C++ method declaration.
NewFD = CXXMethodDecl::Create(Context, cast<CXXRecordDecl>(DC),
D.getIdentifierLoc(), Name, R, DInfo,
@@ -2517,11 +2517,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// - there is a prototype in the declarator, or
// - the type R of the function is some kind of typedef or other reference
// to a type name (which eventually refers to a function type).
- bool HasPrototype =
+ bool HasPrototype =
getLangOptions().CPlusPlus ||
(D.getNumTypeObjects() && D.getTypeObject(0).Fun.hasPrototype) ||
(!isa<FunctionType>(R.getTypePtr()) && R->isFunctionProtoType());
-
+
NewFD = FunctionDecl::Create(Context, DC,
D.getIdentifierLoc(),
Name, R, DInfo, SC, isInline, HasPrototype);
@@ -2529,7 +2529,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
if (D.isInvalidType())
NewFD->setInvalidDecl();
-
+
// Set the lexical context. If the declarator has a C++
// scope specifier, or is the object of a friend declaration, the
// lexical context will be different from the semantic context.
@@ -2549,11 +2549,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
TemplateParamLists.size())) {
if (TemplateParams->size() > 0) {
// This is a function template
-
+
// Check that we can declare a template here.
if (CheckTemplateDeclScope(S, TemplateParams))
return 0;
-
+
FunctionTemplate = FunctionTemplateDecl::Create(Context, DC,
NewFD->getLocation(),
Name, TemplateParams,
@@ -2563,11 +2563,11 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
} else {
// FIXME: Handle function template specializations
}
-
+
// FIXME: Free this memory properly.
TemplateParamLists.release();
- }
-
+ }
+
// C++ [dcl.fct.spec]p5:
// The virtual specifier shall only be used in declarations of
// nonstatic class member functions that appear within a
@@ -2575,7 +2575,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
//
if (isVirtual && !NewFD->isInvalidDecl()) {
if (!isVirtualOkay) {
- Diag(D.getDeclSpec().getVirtualSpecLoc(),
+ Diag(D.getDeclSpec().getVirtualSpecLoc(),
diag::err_virtual_non_function);
} else if (!CurContext->isRecord()) {
// 'virtual' was specified outside of the class.
@@ -2600,9 +2600,9 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Look for virtual methods in base classes that this method might override.
BasePaths Paths;
- if (LookupInBases(cast<CXXRecordDecl>(DC),
+ if (LookupInBases(cast<CXXRecordDecl>(DC),
MemberLookupCriteria(NewMD), Paths)) {
- for (BasePaths::decl_iterator I = Paths.found_decls_begin(),
+ for (BasePaths::decl_iterator I = Paths.found_decls_begin(),
E = Paths.found_decls_end(); I != E; ++I) {
if (CXXMethodDecl *OldMD = dyn_cast<CXXMethodDecl>(*I)) {
if (!CheckOverridingFunctionReturnType(NewMD, OldMD) &&
@@ -2612,8 +2612,8 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
}
}
}
-
- if (SC == FunctionDecl::Static && isa<CXXMethodDecl>(NewFD) &&
+
+ if (SC == FunctionDecl::Static && isa<CXXMethodDecl>(NewFD) &&
!CurContext->isRecord()) {
// C++ [class.static]p1:
// A data or function member of a class may be declared static
@@ -2622,7 +2622,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Complain about the 'static' specifier if it's on an out-of-line
// member function definition.
- Diag(D.getDeclSpec().getStorageClassSpecLoc(),
+ Diag(D.getDeclSpec().getStorageClassSpecLoc(),
diag::err_static_out_of_line)
<< CodeModificationHint::CreateRemoval(
SourceRange(D.getDeclSpec().getStorageClassSpecLoc()));
@@ -2631,7 +2631,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// Handle GNU asm-label extension (encoded as an attribute).
if (Expr *E = (Expr*) D.getAsmLabel()) {
// The parser guarantees this is a string.
- StringLiteral *SE = cast<StringLiteral>(E);
+ StringLiteral *SE = cast<StringLiteral>(E);
NewFD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(),
SE->getByteLength())));
}
@@ -2667,7 +2667,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Params.push_back(Param);
}
}
-
+
} else if (const FunctionProtoType *FT = R->getAsFunctionProtoType()) {
// When we're declaring a function with a typedef, typeof, etc as in the
// following example, we'll need to synthesize (unnamed)
@@ -2677,7 +2677,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
// typedef void fn(int);
// fn f;
// @endcode
-
+
// Synthesize a parameter for each argument type.
for (FunctionProtoType::arg_type_iterator AI = FT->arg_type_begin(),
AE = FT->arg_type_end(); AI != AE; ++AI) {
@@ -2694,7 +2694,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
}
// Finally, we know we have the right number of parameters, install them.
NewFD->setParams(Context, Params.data(), Params.size());
-
+
// If name lookup finds a previous declaration that is not in the
// same scope as the new declaration, this may still be an
// acceptable redeclaration.
@@ -2718,12 +2718,12 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
} else if (!Redeclaration && (!PrevDecl || !isUsingDecl(PrevDecl))) {
// The user tried to provide an out-of-line definition for a
// function that is a member of a class or namespace, but there
- // was no such member function declared (C++ [class.mfct]p2,
+ // was no such member function declared (C++ [class.mfct]p2,
// C++ [namespace.memdef]p2). For example:
- //
+ //
// class X {
// void f() const;
- // };
+ // };
//
// void X::f() { } // ill-formed
//
@@ -2733,10 +2733,10 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Diag(D.getIdentifierLoc(), diag::err_member_def_does_not_match)
<< cast<NamedDecl>(DC) << D.getCXXScopeSpec().getRange();
NewFD->setInvalidDecl();
-
- LookupResult Prev = LookupQualifiedName(DC, Name, LookupOrdinaryName,
+
+ LookupResult Prev = LookupQualifiedName(DC, Name, LookupOrdinaryName,
true);
- assert(!Prev.isAmbiguous() &&
+ assert(!Prev.isAmbiguous() &&
"Cannot have an ambiguity in previous-declaration lookup");
for (LookupResult::iterator Func = Prev.begin(), FuncEnd = Prev.end();
Func != FuncEnd; ++Func) {
@@ -2744,7 +2744,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
isNearlyMatchingFunction(Context, cast<FunctionDecl>(*Func), NewFD))
Diag((*Func)->getLocation(), diag::note_member_def_close_match);
}
-
+
PrevDecl = 0;
}
}
@@ -2772,7 +2772,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
Diag(NewFD->getLocation(), diag::err_attribute_overloadable_missing)
<< Redeclaration << NewFD;
if (PrevDecl)
- Diag(PrevDecl->getLocation(),
+ Diag(PrevDecl->getLocation(),
diag::note_attribute_overloadable_prev_overload);
NewFD->addAttr(::new (Context) OverloadableAttr());
}
@@ -2788,10 +2788,10 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
if (FunctionTemplate && NewFD->isInvalidDecl())
FunctionTemplate->setInvalidDecl();
-
+
if (FunctionTemplate)
return FunctionTemplate;
-
+
return NewFD;
}
@@ -2831,27 +2831,27 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
CXXRecordDecl *Record = cast<CXXRecordDecl>(NewFD->getParent());
QualType ClassType = Context.getTypeDeclType(Record);
if (!ClassType->isDependentType()) {
- DeclarationName Name
+ DeclarationName Name
= Context.DeclarationNames.getCXXDestructorName(
Context.getCanonicalType(ClassType));
if (NewFD->getDeclName() != Name) {
Diag(NewFD->getLocation(), diag::err_destructor_name);
- return NewFD->setInvalidDecl();
+ return NewFD->setInvalidDecl();
}
}
Record->setUserDeclaredDestructor(true);
// C++ [class]p4: A POD-struct is an aggregate class that has [...] no
// user-defined destructor.
Record->setPOD(false);
-
+
// C++ [class.dtor]p3: A destructor is trivial if it is an implicitly-
// declared destructor.
// FIXME: C++0x: don't do this for "= default" destructors
Record->setHasTrivialDestructor(false);
- } else if (CXXConversionDecl *Conversion
+ } else if (CXXConversionDecl *Conversion
= dyn_cast<CXXConversionDecl>(NewFD))
ActOnConversionDeclarator(Conversion);
-
+
// Extra checking for C++ overloaded operators (C++ [over.oper]).
if (NewFD->isOverloadedOperator() &&
CheckOverloadedOperatorDeclaration(NewFD))
@@ -2871,7 +2871,7 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
// Here we determine whether this function, in isolation, would be a
// C99 inline definition. MergeCompatibleFunctionDecls looks at
// previous declarations.
- if (NewFD->isInline() && getLangOptions().C99 &&
+ if (NewFD->isInline() && getLangOptions().C99 &&
NewFD->getStorageClass() == FunctionDecl::None &&
NewFD->getDeclContext()->getLookupContext()->isTranslationUnit())
NewFD->setC99InlineDefinition(true);
@@ -2917,7 +2917,7 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
}
if (PrevDecl &&
- (!AllowOverloadingOfFunction(PrevDecl, Context) ||
+ (!AllowOverloadingOfFunction(PrevDecl, Context) ||
!IsOverload(NewFD, PrevDecl, MatchedDecl)) && !isUsingDecl(PrevDecl)) {
Redeclaration = true;
Decl *OldDecl = PrevDecl;
@@ -2928,7 +2928,7 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl,
OldDecl = *MatchedDecl;
// NewFD and OldDecl represent declarations that need to be
- // merged.
+ // merged.
if (MergeFunctionDecl(NewFD, OldDecl))
return NewFD->setInvalidDecl();
@@ -2970,7 +2970,7 @@ void Sema::CheckMain(FunctionDecl* FD) {
QualType T = FD->getType();
assert(T->isFunctionType() && "function decl is not of function type");
const FunctionType* FT = T->getAsFunctionType();
-
+
if (!Context.hasSameUnqualifiedType(FT->getResultType(), Context.IntTy)) {
// TODO: add a replacement fixit to turn the return type into 'int'.
Diag(FD->getTypeSpecStartLoc(), diag::err_main_returns_nonint);
@@ -3061,7 +3061,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
// the initializer.
if (RealDecl == 0)
return;
-
+
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
// With declarators parsed the way they are, the parser cannot
// distinguish between a normal initializer and a pure-specifier.
@@ -3110,7 +3110,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
const VarDecl *Def = 0;
if (VDecl->getDefinition(Def)) {
- Diag(VDecl->getLocation(), diag::err_redefinition)
+ Diag(VDecl->getLocation(), diag::err_redefinition)
<< VDecl->getDeclName();
Diag(Def->getLocation(), diag::note_previous_definition);
VDecl->setInvalidDecl();
@@ -3133,7 +3133,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
VDecl->getDeclName(), DirectInit))
VDecl->setInvalidDecl();
-
+
// C++ 3.6.2p2, allow dynamic initialization of static initializers.
// Don't check invalid declarations to avoid emitting useless diagnostics.
if (!getLangOptions().CPlusPlus && !VDecl->isInvalidDecl()) {
@@ -3141,7 +3141,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
CheckForConstantInitializer(Init, DclT);
}
}
- } else if (VDecl->isStaticDataMember() &&
+ } else if (VDecl->isStaticDataMember() &&
VDecl->getLexicalDeclContext()->isRecord()) {
// This is an in-class initialization for a static data member, e.g.,
//
@@ -3157,7 +3157,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
// if it declares a static member (9.4) of const integral or
// const enumeration type, see 9.4.2.
QualType T = VDecl->getType();
- if (!T->isDependentType() &&
+ if (!T->isDependentType() &&
(!Context.getCanonicalType(T).isConstQualified() ||
!T->isIntegralType())) {
Diag(VDecl->getLocation(), diag::err_member_initialization)
@@ -3172,7 +3172,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
if (!Init->isTypeDependent() &&
!Init->getType()->isIntegralType()) {
// We have a non-dependent, non-integral or enumeration type.
- Diag(Init->getSourceRange().getBegin(),
+ Diag(Init->getSourceRange().getBegin(),
diag::err_in_class_initializer_non_integral_type)
<< Init->getType() << Init->getSourceRange();
VDecl->setInvalidDecl();
@@ -3195,7 +3195,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
if (CheckInitializerTypes(Init, DclT, VDecl->getLocation(),
VDecl->getDeclName(), DirectInit))
VDecl->setInvalidDecl();
-
+
// C++ 3.6.2p2, allow dynamic initialization of static initializers.
// Don't check invalid declarations to avoid emitting useless diagnostics.
if (!getLangOptions().CPlusPlus && !VDecl->isInvalidDecl()) {
@@ -3204,15 +3204,15 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
}
}
// If the type changed, it means we had an incomplete type that was
- // completed by the initializer. For example:
+ // completed by the initializer. For example:
// int ary[] = { 1, 3, 5 };
// "ary" transitions from a VariableArrayType to a ConstantArrayType.
if (!VDecl->isInvalidDecl() && (DclT != SavT)) {
VDecl->setType(DclT);
Init->setType(DclT);
}
-
- Init = MaybeCreateCXXExprWithTemporaries(Init,
+
+ Init = MaybeCreateCXXExprWithTemporaries(Init,
/*ShouldDestroyTemporaries=*/true);
// Attach the initializer to the decl.
VDecl->setInit(Context, Init);
@@ -3228,7 +3228,7 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) {
return;
}
-void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
+void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
bool TypeContainsUndeducedAuto) {
Decl *RealDecl = dcl.getAs<Decl>();
@@ -3242,9 +3242,9 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
// Record tentative definitions.
if (Var->isTentativeDefinition(Context)) {
std::pair<llvm::DenseMap<DeclarationName, VarDecl *>::iterator, bool>
- InsertPair =
+ InsertPair =
TentativeDefinitions.insert(std::make_pair(Var->getDeclName(), Var));
-
+
// Keep the latest definition in the map. If we see 'int i; int i;' we
// want the second one in the map.
InsertPair.first->second = Var;
@@ -3276,7 +3276,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
Var->setInvalidDecl();
return;
}
-
+
// C++ [dcl.init]p9:
//
// If no initializer is specified for an object, and the object
@@ -3290,13 +3290,13 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
InitType = Array->getElementType();
if ((!Var->hasExternalStorage() && !Var->isExternC(Context)) &&
InitType->isRecordType() && !InitType->isDependentType()) {
- CXXRecordDecl *RD =
+ CXXRecordDecl *RD =
cast<CXXRecordDecl>(InitType->getAs<RecordType>()->getDecl());
CXXConstructorDecl *Constructor = 0;
- if (!RequireCompleteType(Var->getLocation(), InitType,
+ if (!RequireCompleteType(Var->getLocation(), InitType,
diag::err_invalid_incomplete_type_use))
Constructor
- = PerformInitializationByConstructor(InitType, 0, 0,
+ = PerformInitializationByConstructor(InitType, 0, 0,
Var->getLocation(),
SourceRange(Var->getLocation(),
Var->getLocation()),
@@ -3304,13 +3304,13 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
IK_Default);
if (!Constructor)
Var->setInvalidDecl();
- else {
+ else {
if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor()) {
- if (InitializeVarWithConstructor(Var, Constructor, InitType,
+ if (InitializeVarWithConstructor(Var, Constructor, InitType,
MultiExprArg(*this)))
Var->setInvalidDecl();
}
-
+
FinalizeVarWithDestructor(Var, InitType);
}
}
@@ -3318,7 +3318,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
#if 0
// FIXME: Temporarily disabled because we are not properly parsing
- // linkage specifications on declarations, e.g.,
+ // linkage specifications on declarations, e.g.,
//
// extern "C" const CGPoint CGPointerZero;
//
@@ -3360,7 +3360,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
for (unsigned i = 0; i != NumDecls; ++i)
if (Decl *D = Group[i].getAs<Decl>())
Decls.push_back(D);
-
+
// Perform semantic analysis that depends on having fully processed both
// the declarator and initializer.
for (unsigned i = 0, e = Decls.size(); i != e; ++i) {
@@ -3368,12 +3368,12 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
if (!IDecl)
continue;
QualType T = IDecl->getType();
-
+
// Block scope. C99 6.7p7: If an identifier for an object is declared with
// no linkage (C99 6.2.2p6), the type for the object shall be complete...
if (IDecl->isBlockVarDecl() && !IDecl->hasExternalStorage()) {
if (!IDecl->isInvalidDecl() &&
- RequireCompleteType(IDecl->getLocation(), T,
+ RequireCompleteType(IDecl->getLocation(), T,
diag::err_typecheck_decl_incomplete_type))
IDecl->setInvalidDecl();
}
@@ -3412,7 +3412,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
/// ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator()
/// to introduce parameters into function prototype scope.
-Sema::DeclPtrTy
+Sema::DeclPtrTy
Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
const DeclSpec &DS = D.getDeclSpec();
@@ -3435,12 +3435,12 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// parameter (C++ only).
if (getLangOptions().CPlusPlus)
CheckExtraCXXDefaultArguments(D);
-
+
DeclaratorInfo *DInfo = 0;
TagDecl *OwnedDecl = 0;
QualType parmDeclType = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0,
&OwnedDecl);
-
+
if (getLangOptions().CPlusPlus && OwnedDecl && OwnedDecl->isDefinition()) {
// C++ [dcl.fct]p6:
// Types shall not be defined in return or parameter types.
@@ -3471,26 +3471,26 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// Parameters can not be abstract class types.
// For record types, this is done by the AbstractClassUsageDiagnoser once
- // the class has been completely parsed.
- if (!CurContext->isRecord() &&
- RequireNonAbstractType(D.getIdentifierLoc(), parmDeclType,
+ // the class has been completely parsed.
+ if (!CurContext->isRecord() &&
+ RequireNonAbstractType(D.getIdentifierLoc(), parmDeclType,
diag::err_abstract_type_in_decl,
AbstractParamType))
D.setInvalidType(true);
QualType T = adjustParameterType(parmDeclType);
-
+
ParmVarDecl *New;
if (T == parmDeclType) // parameter type did not need adjustment
- New = ParmVarDecl::Create(Context, CurContext,
+ New = ParmVarDecl::Create(Context, CurContext,
D.getIdentifierLoc(), II,
- parmDeclType, DInfo, StorageClass,
+ parmDeclType, DInfo, StorageClass,
0);
else // keep track of both the adjusted and unadjusted types
- New = OriginalParmVarDecl::Create(Context, CurContext,
+ New = OriginalParmVarDecl::Create(Context, CurContext,
D.getIdentifierLoc(), II, T, DInfo,
parmDeclType, StorageClass, 0);
-
+
if (D.isInvalidType())
New->setInvalidDecl();
@@ -3501,7 +3501,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
diag::err_object_cannot_be_passed_returned_by_value) << 1 << T;
New->setInvalidDecl();
}
-
+
// Parameter declarators cannot be qualified (C++ [dcl.meaning]p1).
if (D.getCXXScopeSpec().isSet()) {
Diag(D.getIdentifierLoc(), diag::err_qualified_param_declarator)
@@ -3546,14 +3546,14 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
DeclSpec DS;
const char* PrevSpec; // unused
unsigned DiagID; // unused
- DS.SetTypeSpecType(DeclSpec::TST_int, FTI.ArgInfo[i].IdentLoc,
+ DS.SetTypeSpecType(DeclSpec::TST_int, FTI.ArgInfo[i].IdentLoc,
PrevSpec, DiagID);
Declarator ParamD(DS, Declarator::KNRTypeListContext);
ParamD.SetIdentifier(FTI.ArgInfo[i].Ident, FTI.ArgInfo[i].IdentLoc);
FTI.ArgInfo[i].Param = ActOnParamDeclarator(S, ParamD);
}
}
- }
+ }
}
Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope,
@@ -3564,12 +3564,12 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope,
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.hasPrototype) {
- // FIXME: Diagnose arguments without names in C.
+ // FIXME: Diagnose arguments without names in C.
}
-
+
Scope *ParentScope = FnBodyScope->getParent();
- DeclPtrTy DP = HandleDeclarator(ParentScope, D,
+ DeclPtrTy DP = HandleDeclarator(ParentScope, D,
MultiTemplateParamsArg(*this),
/*IsFunctionDefinition=*/true);
return ActOnStartOfFunctionDef(FnBodyScope, DP);
@@ -3579,15 +3579,15 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
if (!D)
return D;
FunctionDecl *FD = 0;
-
- if (FunctionTemplateDecl *FunTmpl
+
+ if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>(D.getAs<Decl>()))
FD = FunTmpl->getTemplatedDecl();
else
FD = cast<FunctionDecl>(D.getAs<Decl>());
CurFunctionNeedsScopeChecking = false;
-
+
// See if this is a redefinition.
const FunctionDecl *Definition;
if (FD->getBody(Definition)) {
@@ -3653,7 +3653,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
// Checking attributes of current function definition
// dllimport attribute.
- if (FD->getAttr<DLLImportAttr>() &&
+ if (FD->getAttr<DLLImportAttr>() &&
(!FD->getAttr<DLLExportAttr>())) {
// dllimport attribute cannot be applied to definition.
if (!(FD->getAttr<DLLImportAttr>())->isInherited()) {
@@ -3698,23 +3698,23 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
FD->setHasImplicitReturnZero(true);
else
CheckFallThroughForFunctionDef(FD, Body);
-
+
if (!FD->isInvalidDecl())
DiagnoseUnusedParameters(FD->param_begin(), FD->param_end());
-
+
// C++ [basic.def.odr]p2:
// [...] A virtual member function is used if it is not pure. [...]
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FD))
if (Method->isVirtual() && !Method->isPure())
MarkDeclarationReferenced(Method->getLocation(), Method);
-
+
assert(FD == getCurFunctionDecl() && "Function parsing confused");
} else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
assert(MD == getCurMethodDecl() && "Method parsing confused");
MD->setBody(Body);
CheckFallThroughForFunctionDef(MD, Body);
MD->setEndLoc(Body->getLocEnd());
-
+
if (!MD->isInvalidDecl())
DiagnoseUnusedParameters(MD->param_begin(), MD->param_end());
} else {
@@ -3727,21 +3727,21 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
// Verify and clean out per-function state.
assert(&getLabelMap() == &FunctionLabelMap && "Didn't pop block right?");
-
+
// Check goto/label use.
for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator
I = FunctionLabelMap.begin(), E = FunctionLabelMap.end(); I != E; ++I) {
LabelStmt *L = I->second;
-
+
// Verify that we have no forward references left. If so, there was a goto
// or address of a label taken, but no definition of it. Label fwd
// definitions are indicated with a null substmt.
if (L->getSubStmt() != 0)
continue;
-
+
// Emit error.
Diag(L->getIdentLoc(), diag::err_undeclared_label_use) << L->getName();
-
+
// At this point, we have gotos that use the bogus label. Stitch it into
// the function body so that they aren't leaked and that the AST is well
// formed.
@@ -3750,7 +3750,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
L->Destroy(Context);
continue;
}
-
+
// Otherwise, the body is valid: we want to stitch the label decl into the
// function somewhere so that it is properly owned and so that the goto
// has a valid target. Do this by creating a new compound stmt with the
@@ -3773,13 +3773,13 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
// Verify that that gotos and switch cases don't jump into scopes illegally.
if (CurFunctionNeedsScopeChecking)
DiagnoseInvalidJumps(Body);
-
- // C++ constructors that have function-try-blocks can't have return
- // statements in the handlers of that block. (C++ [except.handle]p14)
+
+ // C++ constructors that have function-try-blocks can't have return
+ // statements in the handlers of that block. (C++ [except.handle]p14)
// Verify this.
if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
-
+
if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl))
computeBaseOrMembersToDestroy(Destructor);
return D;
@@ -3787,7 +3787,7 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg,
/// ImplicitlyDefineFunction - An undeclared identifier was used in a function
/// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
-NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
+NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
IdentifierInfo &II, Scope *S) {
// Before we produce a declaration for an implicitly defined
// function, see whether there was a locally-scoped declaration of
@@ -3806,7 +3806,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
Diag(Loc, diag::ext_implicit_function_decl) << &II;
else
Diag(Loc, diag::warn_implicit_function_decl) << &II;
-
+
// FIXME: handle stuff like:
// void foo() { extern float X(); }
// void bar() { X(); } <-- implicit decl for X in another scope.
@@ -3829,8 +3829,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
DeclContext *PrevDC = CurContext;
CurContext = Context.getTranslationUnitDecl();
-
- FunctionDecl *FD =
+
+ FunctionDecl *FD =
dyn_cast<FunctionDecl>(ActOnDeclarator(TUScope, D).getAs<Decl>());
FD->setImplicit();
@@ -3879,10 +3879,10 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
IdentifierInfo *Name = FD->getIdentifier();
if (!Name)
return;
- if ((!getLangOptions().CPlusPlus &&
+ if ((!getLangOptions().CPlusPlus &&
FD->getDeclContext()->isTranslationUnit()) ||
(isa<LinkageSpecDecl>(FD->getDeclContext()) &&
- cast<LinkageSpecDecl>(FD->getDeclContext())->getLanguage() ==
+ cast<LinkageSpecDecl>(FD->getDeclContext())->getLanguage() ==
LinkageSpecDecl::lang_c)) {
// Okay: this could be a libc/libm/Objective-C function we know
// about.
@@ -3894,12 +3894,12 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
if (const FormatAttr *Format = FD->getAttr<FormatAttr>()) {
// FIXME: We known better than our headers.
const_cast<FormatAttr *>(Format)->setType("printf");
- } else
+ } else
FD->addAttr(::new (Context) FormatAttr("printf", 1,
Name->isStr("NSLogv") ? 0 : 2));
} else if (Name->isStr("asprintf") || Name->isStr("vasprintf")) {
// FIXME: asprintf and vasprintf aren't C99 functions. Should they be
- // target-specific builtins, perhaps?
+ // target-specific builtins, perhaps?
if (!FD->getAttr<FormatAttr>())
FD->addAttr(::new (Context) FormatAttr("printf", 2,
Name->isStr("vasprintf") ? 0 : 3));
@@ -3909,16 +3909,16 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) {
TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T) {
assert(D.getIdentifier() && "Wrong callback for declspec without declarator");
assert(!T.isNull() && "GetTypeForDeclarator() returned null type");
-
+
// Scope manipulation handled by caller.
TypedefDecl *NewTD = TypedefDecl::Create(Context, CurContext,
D.getIdentifierLoc(),
- D.getIdentifier(),
+ D.getIdentifier(),
T);
-
+
if (const TagType *TT = T->getAs<TagType>()) {
TagDecl *TD = TT->getDecl();
-
+
// If the TagDecl that the TypedefDecl points to is an anonymous decl
// keep track of the TypedefDecl.
if (!TD->getIdentifier() && !TD->getTypedefForAnonDecl())
@@ -3935,7 +3935,7 @@ TypedefDecl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, QualType T) {
/// as a redeclaration of the given tag declaration.
///
/// \returns true if the new tag kind is acceptable, false otherwise.
-bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
+bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
TagDecl::TagKind NewTag,
SourceLocation NewTagLoc,
const IdentifierInfo &Name) {
@@ -3955,7 +3955,7 @@ bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
TagDecl::TagKind OldTag = Previous->getTagKind();
if (OldTag == NewTag)
return true;
-
+
if ((OldTag == TagDecl::TK_struct || OldTag == TagDecl::TK_class) &&
(NewTag == TagDecl::TK_struct || NewTag == TagDecl::TK_class)) {
// Warn about the struct/class tag mismatch.
@@ -3990,7 +3990,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
OwnedDecl = false;
TagDecl::TagKind Kind = TagDecl::getTagKindForTypeSpec(TagSpec);
-
+
if (TUK != TUK_Reference) {
if (TemplateParameterList *TemplateParams
= MatchTemplateParametersToScopeSpecifier(KWLoc, SS,
@@ -4011,9 +4011,9 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
// slightly better in ParseTemplate.cpp from bogus template
// parameters.
}
- }
- }
-
+ }
+ }
+
DeclContext *SearchDC = CurContext;
DeclContext *DC = CurContext;
NamedDecl *PrevDecl = 0;
@@ -4035,7 +4035,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
DC = computeDeclContext(SS, true);
SearchDC = DC;
// Look-up name inside 'foo::'.
- PrevDecl
+ PrevDecl
= dyn_cast_or_null<TagDecl>(
LookupQualifiedName(DC, Name, LookupTagName, true).getAsDecl());
@@ -4087,7 +4087,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
if (PrevDecl) {
// Check whether the previous declaration is usable.
(void)DiagnoseUseOfDecl(PrevDecl, NameLoc);
-
+
if (TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
// If this is a use of a previous tag, or if the tag is already declared
// in the same scope (so that the definition/declaration completes or
@@ -4097,11 +4097,11 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
// Make sure that this wasn't declared as an enum and now used as a
// struct or something similar.
if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind, KWLoc, *Name)) {
- bool SafeToContinue
+ bool SafeToContinue
= (PrevTagDecl->getTagKind() != TagDecl::TK_enum &&
Kind != TagDecl::TK_enum);
if (SafeToContinue)
- Diag(KWLoc, diag::err_use_with_wrong_tag)
+ Diag(KWLoc, diag::err_use_with_wrong_tag)
<< Name
<< CodeModificationHint::CreateReplacement(SourceRange(KWLoc),
PrevTagDecl->getKindName());
@@ -4109,7 +4109,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
Diag(PrevDecl->getLocation(), diag::note_previous_use);
- if (SafeToContinue)
+ if (SafeToContinue)
Kind = PrevTagDecl->getTagKind();
else {
// Recover by making this an anonymous redefinition.
@@ -4151,7 +4151,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
TagType *Tag = cast<TagType>(Context.getTagDeclType(PrevTagDecl));
if (Tag->isBeingDefined()) {
Diag(NameLoc, diag::err_nested_redefinition) << Name;
- Diag(PrevTagDecl->getLocation(),
+ Diag(PrevTagDecl->getLocation(),
diag::note_previous_definition);
Name = 0;
PrevDecl = 0;
@@ -4168,7 +4168,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
} else {
// If we get here, this is a definition of a new tag type in a nested
- // scope, e.g. "struct foo; void bar() { struct foo; }", just create a
+ // scope, e.g. "struct foo; void bar() { struct foo; }", just create a
// new decl/type. We set PrevDecl to NULL so that the entities
// have distinct types.
PrevDecl = 0;
@@ -4196,7 +4196,7 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
} else if (TUK == TUK_Reference && SS.isEmpty() && Name &&
(Kind != TagDecl::TK_enum || !getLangOptions().CPlusPlus)) {
// C++ [basic.scope.pdecl]p5:
- // -- for an elaborated-type-specifier of the form
+ // -- for an elaborated-type-specifier of the form
//
// class-key identifier
//
@@ -4217,15 +4217,15 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
//
// Find the context where we'll be declaring the tag.
// FIXME: We would like to maintain the current DeclContext as the
- // lexical context,
+ // lexical context,
while (SearchDC->isRecord())
SearchDC = SearchDC->getParent();
// Find the scope where we'll be declaring the tag.
- while (S->isClassScope() ||
+ while (S->isClassScope() ||
(getLangOptions().CPlusPlus && S->isFunctionPrototypeScope()) ||
((S->getFlags() & Scope::DeclScope) == 0) ||
- (S->getEntity() &&
+ (S->getEntity() &&
((DeclContext *)S->getEntity())->isTransparentContext()))
S = S->getParent();
@@ -4243,12 +4243,12 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
}
CreateNewDecl:
-
+
// If there is an identifier, use the location of the identifier as the
// location of the decl, otherwise use the location of the struct/union
// keyword.
SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
-
+
// Otherwise, create a new declaration. If there is a previous
// declaration of the same entity, the two will be linked via
// PrevDecl.
@@ -4342,7 +4342,7 @@ CreateNewDecl:
if (TUK == TUK_Definition)
New->startDefinition();
-
+
// If this has an identifier, add it to the scope stack.
if (TUK == TUK_Friend) {
// We might be replacing an existing declaration in the lookup tables;
@@ -4370,7 +4370,7 @@ CreateNewDecl:
New->getDeclContext()->getLookupContext()->isTranslationUnit() &&
II->isStr("FILE"))
Context.setFILEDecl(New);
-
+
OwnedDecl = true;
return DeclPtrTy::make(New);
}
@@ -4386,7 +4386,7 @@ void Sema::ActOnTagStartDefinition(Scope *S, DeclPtrTy TagD) {
FieldCollector->StartClass();
if (Record->getIdentifier()) {
- // C++ [class]p2:
+ // C++ [class]p2:
// [...] The class-name is also inserted into the scope of the
// class itself; this is known as the injected-class-name. For
// purposes of access checking, the injected-class-name is treated
@@ -4402,7 +4402,7 @@ void Sema::ActOnTagStartDefinition(Scope *S, DeclPtrTy TagD) {
if (ClassTemplateDecl *Template = Record->getDescribedClassTemplate())
InjectedClassName->setDescribedClassTemplate(Template);
PushOnScopeChains(InjectedClassName, S);
- assert(InjectedClassName->isInjectedClassName() &&
+ assert(InjectedClassName->isInjectedClassName() &&
"Broken injected-class-name");
}
}
@@ -4425,7 +4425,7 @@ void Sema::ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagD,
}
// Note that FieldName may be null for anonymous bitfields.
-bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
+bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
QualType FieldTy, const Expr *BitWidth,
bool *ZeroWidth) {
// Default to true; that shouldn't confuse checks for emptiness
@@ -4460,10 +4460,10 @@ bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
// Zero-width bitfield is ok for anonymous field.
if (Value == 0 && FieldName)
return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
-
+
if (Value.isSigned() && Value.isNegative()) {
if (FieldName)
- return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
+ return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
<< FieldName << Value.toString(10);
return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
<< Value.toString(10);
@@ -4486,7 +4486,7 @@ bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
/// ActOnField - Each field of a struct/union/class is passed into this in order
/// to create a FieldDecl object for it.
Sema::DeclPtrTy Sema::ActOnField(Scope *S, DeclPtrTy TagD,
- SourceLocation DeclStart,
+ SourceLocation DeclStart,
Declarator &D, ExprTy *BitfieldWidth) {
FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD.getAs<Decl>()),
DeclStart, D, static_cast<Expr*>(BitfieldWidth),
@@ -4503,7 +4503,7 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
IdentifierInfo *II = D.getIdentifier();
SourceLocation Loc = DeclStart;
if (II) Loc = D.getIdentifierLoc();
-
+
DeclaratorInfo *DInfo = 0;
QualType T = GetTypeForDeclarator(D, S, &DInfo);
if (getLangOptions().CPlusPlus)
@@ -4552,11 +4552,11 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record,
///
/// \returns a new FieldDecl.
///
-/// \todo The Declarator argument is a hack. It will be removed once
+/// \todo The Declarator argument is a hack. It will be removed once
FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
- DeclaratorInfo *DInfo,
+ DeclaratorInfo *DInfo,
RecordDecl *Record, SourceLocation Loc,
- bool Mutable, Expr *BitWidth,
+ bool Mutable, Expr *BitWidth,
SourceLocation TSSL,
AccessSpecifier AS, NamedDecl *PrevDecl,
Declarator *D) {
@@ -4588,12 +4588,12 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
InvalidDecl = true;
}
}
-
+
// Fields can not have abstract class types
- if (RequireNonAbstractType(Loc, T, diag::err_abstract_type_in_decl,
+ if (RequireNonAbstractType(Loc, T, diag::err_abstract_type_in_decl,
AbstractFieldType))
InvalidDecl = true;
-
+
bool ZeroWidth = false;
// If this is declared as a bit-field, check the bit-field.
if (BitWidth && VerifyBitField(Loc, II, T, BitWidth, &ZeroWidth)) {
@@ -4602,7 +4602,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
BitWidth = 0;
ZeroWidth = false;
}
-
+
FieldDecl *NewFD = FieldDecl::Create(Context, Record, Loc, II, T, DInfo,
BitWidth, Mutable);
if (InvalidDecl)
@@ -4771,7 +4771,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
}
}
}
-
+
bool (CXXRecordDecl::*hasTrivial)() const;
switch (member) {
case CXXDefaultConstructor:
@@ -4798,7 +4798,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
return;
}
}
-
+
// Check for nontrivial members (and recurse).
typedef RecordDecl::field_iterator field_iter;
for (field_iter fi = RD->field_begin(), fe = RD->field_end(); fi != fe;
@@ -4819,7 +4819,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
assert(0 && "found no explanation for non-trivial member");
}
-/// TranslateIvarVisibility - Translate visibility from a token ID to an
+/// TranslateIvarVisibility - Translate visibility from a token ID to an
/// AST enum value.
static ObjCIvarDecl::AccessControl
TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility) {
@@ -4832,25 +4832,25 @@ TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility) {
}
}
-/// ActOnIvar - Each ivar field of an objective-c class is passed into this
+/// ActOnIvar - Each ivar field of an objective-c class is passed into this
/// in order to create an IvarDecl object for it.
Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
- SourceLocation DeclStart,
+ SourceLocation DeclStart,
DeclPtrTy IntfDecl,
Declarator &D, ExprTy *BitfieldWidth,
tok::ObjCKeywordKind Visibility) {
-
+
IdentifierInfo *II = D.getIdentifier();
Expr *BitWidth = (Expr*)BitfieldWidth;
SourceLocation Loc = DeclStart;
if (II) Loc = D.getIdentifierLoc();
-
+
// FIXME: Unnamed fields can be handled in various different ways, for
// example, unnamed unions inject all members into the struct namespace!
-
+
DeclaratorInfo *DInfo = 0;
QualType T = GetTypeForDeclarator(D, S, &DInfo);
-
+
if (BitWidth) {
// 6.7.2.1p3, 6.7.2.1p4
if (VerifyBitField(Loc, II, T, BitWidth)) {
@@ -4860,26 +4860,26 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
}
} else {
// Not a bitfield.
-
+
// validate II.
-
+
}
-
+
// C99 6.7.2.1p8: A member of a structure or union may have any type other
// than a variably modified type.
if (T->isVariablyModifiedType()) {
Diag(Loc, diag::err_typecheck_ivar_variable_size);
D.setInvalidType();
}
-
+
// Get the visibility (access control) for this ivar.
- ObjCIvarDecl::AccessControl ac =
+ ObjCIvarDecl::AccessControl ac =
Visibility != tok::objc_not_keyword ? TranslateIvarVisibility(Visibility)
: ObjCIvarDecl::None;
// Must set ivar's DeclContext to its enclosing interface.
Decl *EnclosingDecl = IntfDecl.getAs<Decl>();
DeclContext *EnclosingContext;
- if (ObjCImplementationDecl *IMPDecl =
+ if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
// Case of ivar declared in an implementation. Context is that of its class.
ObjCInterfaceDecl* IDecl = IMPDecl->getClassInterface();
@@ -4888,12 +4888,12 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
} else
EnclosingContext = dyn_cast<DeclContext>(EnclosingDecl);
assert(EnclosingContext && "null DeclContext for ivar - ActOnIvar");
-
+
// Construct the decl.
- ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context,
+ ObjCIvarDecl *NewID = ObjCIvarDecl::Create(Context,
EnclosingContext, Loc, II, T,
DInfo, ac, (Expr *)BitfieldWidth);
-
+
if (II) {
NamedDecl *PrevDecl = LookupName(S, II, LookupMemberName, true);
if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
@@ -4906,7 +4906,7 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S,
// Process attributes attached to the ivar.
ProcessDeclAttributes(S, NewID, D);
-
+
if (D.isInvalidType())
NewID->setInvalidDecl();
@@ -4927,7 +4927,7 @@ void Sema::ActOnFields(Scope* S,
AttributeList *Attr) {
Decl *EnclosingDecl = RecDecl.getAs<Decl>();
assert(EnclosingDecl && "missing record or interface decl");
-
+
// If the decl this is being inserted into is invalid, then it may be a
// redeclaration or some other bogus case. Don't try to add fields to it.
if (EnclosingDecl->isInvalidDecl()) {
@@ -4935,7 +4935,7 @@ void Sema::ActOnFields(Scope* S,
return;
}
-
+
// Verify that all the fields are okay.
unsigned NumNamedMembers = 0;
llvm::SmallVector<FieldDecl*, 32> RecFields;
@@ -4943,7 +4943,7 @@ void Sema::ActOnFields(Scope* S,
RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
for (unsigned i = 0; i != NumFields; ++i) {
FieldDecl *FD = cast<FieldDecl>(Fields[i].getAs<Decl>());
-
+
// Get the type for the field.
Type *FDTy = FD->getType().getTypePtr();
@@ -4951,12 +4951,12 @@ void Sema::ActOnFields(Scope* S,
// Remember all fields written by the user.
RecFields.push_back(FD);
}
-
+
// If the field is already invalid for some reason, don't emit more
// diagnostics about it.
if (FD->isInvalidDecl())
continue;
-
+
// C99 6.7.2.1p2:
// A structure or union shall not contain a member with
// incomplete or function type (hence, a structure shall not
@@ -4988,7 +4988,7 @@ void Sema::ActOnFields(Scope* S,
if (Record)
Record->setHasFlexibleArrayMember(true);
} else if (!FDTy->isDependentType() &&
- RequireCompleteType(FD->getLocation(), FD->getType(),
+ RequireCompleteType(FD->getLocation(), FD->getType(),
diag::err_field_incomplete)) {
// Incomplete type
FD->setInvalidDecl();
@@ -5052,7 +5052,7 @@ void Sema::ActOnFields(Scope* S,
// Must enforce the rule that ivars in the base classes may not be
// duplicates.
if (ID->getSuperClass()) {
- for (ObjCInterfaceDecl::ivar_iterator IVI = ID->ivar_begin(),
+ for (ObjCInterfaceDecl::ivar_iterator IVI = ID->ivar_begin(),
IVE = ID->ivar_end(); IVI != IVE; ++IVI) {
ObjCIvarDecl* Ivar = (*IVI);
@@ -5066,7 +5066,7 @@ void Sema::ActOnFields(Scope* S,
}
}
}
- } else if (ObjCImplementationDecl *IMPDecl =
+ } else if (ObjCImplementationDecl *IMPDecl =
dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
assert(IMPDecl && "ActOnFields - missing ObjCImplementationDecl");
for (unsigned I = 0, N = RecFields.size(); I != N; ++I)
@@ -5107,7 +5107,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
EltTy = Val->getType();
}
}
-
+
if (!Val) {
if (LastEnumConst) {
// Assign the last value + 1.
@@ -5117,7 +5117,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
// Check for overflow on increment.
if (EnumVal < LastEnumConst->getInitVal())
Diag(IdLoc, diag::warn_enum_value_overflow);
-
+
EltTy = LastEnumConst->getType();
} else {
// First value, set to zero.
@@ -5125,10 +5125,10 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
EnumVal.zextOrTrunc(static_cast<uint32_t>(Context.getTypeSize(EltTy)));
}
}
-
+
val.release();
return EnumConstantDecl::Create(Context, Enum, IdLoc, Id, EltTy,
- Val, EnumVal);
+ Val, EnumVal);
}
@@ -5145,7 +5145,7 @@ Sema::DeclPtrTy Sema::ActOnEnumConstant(Scope *S, DeclPtrTy theEnumDecl,
// The scope passed in may not be a decl scope. Zip up the scope tree until
// we find one that is.
S = getNonFieldDeclScope(S);
-
+
// Verify that there isn't already something declared with this name in this
// scope.
NamedDecl *PrevDecl = LookupName(S, Id, LookupOrdinaryName);
@@ -5191,27 +5191,27 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
if (Attr)
ProcessDeclAttributeList(S, Enum, Attr);
-
+
// TODO: If the result value doesn't fit in an int, it must be a long or long
// long value. ISO C does not support this, but GCC does as an extension,
// emit a warning.
unsigned IntWidth = Context.Target.getIntWidth();
unsigned CharWidth = Context.Target.getCharWidth();
unsigned ShortWidth = Context.Target.getShortWidth();
-
+
// Verify that all the values are okay, compute the size of the values, and
// reverse the list.
unsigned NumNegativeBits = 0;
unsigned NumPositiveBits = 0;
-
+
// Keep track of whether all elements have type int.
bool AllElementsInt = true;
-
+
for (unsigned i = 0; i != NumElements; ++i) {
EnumConstantDecl *ECD =
cast_or_null<EnumConstantDecl>(Elements[i].getAs<Decl>());
if (!ECD) continue; // Already issued a diagnostic.
-
+
// If the enum value doesn't fit in an int, emit an extension warning.
const llvm::APSInt &InitVal = ECD->getInitVal();
assert(InitVal.getBitWidth() >= IntWidth &&
@@ -5224,7 +5224,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
Diag(ECD->getLocation(), diag::ext_enum_value_not_int)
<< InitVal.toString(10);
}
-
+
// Keep track of the size of positive and negative values.
if (InitVal.isUnsigned() || InitVal.isNonNegative())
NumPositiveBits = std::max(NumPositiveBits,
@@ -5235,9 +5235,9 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
// Keep track of whether every enum element has type int (very commmon).
if (AllElementsInt)
- AllElementsInt = ECD->getType() == Context.IntTy;
+ AllElementsInt = ECD->getType() == Context.IntTy;
}
-
+
// Figure out the type that should be used for this enum.
// FIXME: Support -fshort-enums.
QualType BestType;
@@ -5246,13 +5246,13 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
bool Packed = Enum->getAttr<PackedAttr>() ? true : false;
if (NumNegativeBits) {
- // If there is a negative value, figure out the smallest integer type (of
+ // If there is a negative value, figure out the smallest integer type (of
// int/long/longlong) that fits.
// If it's packed, check also if it fits a char or a short.
if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
BestType = Context.SignedCharTy;
BestWidth = CharWidth;
- } else if (Packed && NumNegativeBits <= ShortWidth &&
+ } else if (Packed && NumNegativeBits <= ShortWidth &&
NumPositiveBits < ShortWidth) {
BestType = Context.ShortTy;
BestWidth = ShortWidth;
@@ -5262,12 +5262,12 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
BestWidth = IntWidth;
} else {
BestWidth = Context.Target.getLongWidth();
-
+
if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth)
BestType = Context.LongTy;
else {
BestWidth = Context.Target.getLongLongWidth();
-
+
if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
Diag(Enum->getLocation(), diag::warn_enum_too_large);
BestType = Context.LongLongTy;
@@ -5297,7 +5297,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
BestType = Context.UnsignedLongLongTy;
}
}
-
+
// Loop over all of the enumerator constants, changing their types to match
// the type of the enum if needed.
for (unsigned i = 0; i != NumElements; ++i) {
@@ -5319,7 +5319,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
if (getLangOptions().CPlusPlus)
// C++ [dcl.enum]p4: Following the closing brace of an
// enum-specifier, each enumerator has the type of its
- // enumeration.
+ // enumeration.
ECD->setType(EnumType);
continue; // Already int type.
}
@@ -5346,7 +5346,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
if (getLangOptions().CPlusPlus)
// C++ [dcl.enum]p4: Following the closing brace of an
// enum-specifier, each enumerator has the type of its
- // enumeration.
+ // enumeration.
ECD->setType(EnumType);
continue;
} else {
@@ -5359,22 +5359,22 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
InitVal.extOrTrunc(NewWidth);
InitVal.setIsSigned(NewSign);
ECD->setInitVal(InitVal);
-
+
// Adjust the Expr initializer and type.
if (ECD->getInitExpr())
- ECD->setInitExpr(new (Context) ImplicitCastExpr(NewTy,
- CastExpr::CK_Unknown,
- ECD->getInitExpr(),
+ ECD->setInitExpr(new (Context) ImplicitCastExpr(NewTy,
+ CastExpr::CK_Unknown,
+ ECD->getInitExpr(),
/*isLvalue=*/false));
if (getLangOptions().CPlusPlus)
// C++ [dcl.enum]p4: Following the closing brace of an
// enum-specifier, each enumerator has the type of its
- // enumeration.
+ // enumeration.
ECD->setType(EnumType);
else
ECD->setType(NewTy);
}
-
+
Enum->completeDefinition(Context, BestType);
}
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index df2fa16aba..5987c96c2f 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -437,9 +437,9 @@ static void HandleMallocAttr(Decl *d, const AttributeList &Attr, Sema &S) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
+
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
- QualType RetTy = FD->getResultType();
+ QualType RetTy = FD->getResultType();
if (RetTy->isAnyPointerType() || RetTy->isBlockPointerType()) {
d->addAttr(::new (S.Context) MallocAttr());
return;
@@ -989,7 +989,7 @@ static void HandleSectionAttr(Decl *D, const AttributeList &Attr, Sema &S) {
S.Diag(ArgExpr->getLocStart(), diag::err_attribute_not_string) << "section";
return;
}
-
+
std::string SectionStr(SE->getStrData(), SE->getByteLength());
// If the target wants to validate the section specifier, make it happen.
@@ -998,10 +998,10 @@ static void HandleSectionAttr(Decl *D, const AttributeList &Attr, Sema &S) {
D->addAttr(::new (S.Context) SectionAttr(SectionStr));
return;
}
-
+
S.Diag(SE->getLocStart(), diag::err_attribute_section_invalid_for_target)
<< Error;
-
+
}
static void HandleStdCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
@@ -1277,7 +1277,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
NumArgs++;
}
}
-
+
if (Idx.getZExtValue() < FirstIdx || Idx.getZExtValue() > NumArgs) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
<< "format" << 2 << IdxExpr->getSourceRange();
@@ -1288,7 +1288,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
unsigned ArgIdx = Idx.getZExtValue() - 1;
if (HasImplicitThisParam) ArgIdx--;
-
+
// make sure the format string is really a string
QualType Ty = getFunctionOrMethodArgType(d, ArgIdx);
@@ -1867,8 +1867,7 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *Attr
/// DeclClonePragmaWeak - clone existing decl (maybe definition),
/// #pragma weak needs a non-definition decl and source may not have one
-NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II)
-{
+NamedDecl * Sema::DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II) {
assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
NamedDecl *NewD = 0;
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 1c7157c2c0..64dc41e31a 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -38,13 +38,13 @@ namespace {
/// contains any ill-formed subexpressions. For example, this will
/// diagnose the use of local variables or parameters within the
/// default argument expression.
- class VISIBILITY_HIDDEN CheckDefaultArgumentVisitor
+ class VISIBILITY_HIDDEN CheckDefaultArgumentVisitor
: public StmtVisitor<CheckDefaultArgumentVisitor, bool> {
Expr *DefaultArg;
Sema *S;
public:
- CheckDefaultArgumentVisitor(Expr *defarg, Sema *s)
+ CheckDefaultArgumentVisitor(Expr *defarg, Sema *s)
: DefaultArg(defarg), S(s) {}
bool VisitExpr(Expr *Node);
@@ -55,7 +55,7 @@ namespace {
/// VisitExpr - Visit all of the children of this expression.
bool CheckDefaultArgumentVisitor::VisitExpr(Expr *Node) {
bool IsInvalid = false;
- for (Stmt::child_iterator I = Node->child_begin(),
+ for (Stmt::child_iterator I = Node->child_begin(),
E = Node->child_end(); I != E; ++I)
IsInvalid |= Visit(*I);
return IsInvalid;
@@ -75,7 +75,7 @@ namespace {
// evaluated. Parameters of a function declared before a default
// argument expression are in scope and can hide namespace and
// class member names.
- return S->Diag(DRE->getSourceRange().getBegin(),
+ return S->Diag(DRE->getSourceRange().getBegin(),
diag::err_param_default_argument_references_param)
<< Param->getDeclName() << DefaultArg->getSourceRange();
} else if (VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
@@ -83,7 +83,7 @@ namespace {
// Local variables shall not be used in default argument
// expressions.
if (VDecl->isBlockVarDecl())
- return S->Diag(DRE->getSourceRange().getBegin(),
+ return S->Diag(DRE->getSourceRange().getBegin(),
diag::err_param_default_argument_references_local)
<< VDecl->getDeclName() << DefaultArg->getSourceRange();
}
@@ -104,8 +104,7 @@ namespace {
bool
Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
- SourceLocation EqualLoc)
-{
+ SourceLocation EqualLoc) {
QualType ParamType = Param->getType();
if (RequireCompleteType(Param->getLocation(), Param->getType(),
@@ -115,24 +114,24 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
}
Expr *Arg = (Expr *)DefaultArg.get();
-
+
// C++ [dcl.fct.default]p5
// A default argument expression is implicitly converted (clause
// 4) to the parameter type. The default argument expression has
// the same semantic constraints as the initializer expression in
// a declaration of a variable of the parameter type, using the
// copy-initialization semantics (8.5).
- if (CheckInitializerTypes(Arg, ParamType, EqualLoc,
+ if (CheckInitializerTypes(Arg, ParamType, EqualLoc,
Param->getDeclName(), /*DirectInit=*/false))
return true;
Arg = MaybeCreateCXXExprWithTemporaries(Arg, /*DestroyTemps=*/false);
-
+
// Okay: add the default argument to the parameter
Param->setDefaultArg(Arg);
-
+
DefaultArg.release();
-
+
return false;
}
@@ -140,11 +139,11 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
/// provided for a function parameter is well-formed. If so, attach it
/// to the parameter declaration.
void
-Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc,
+Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc,
ExprArg defarg) {
if (!param || !defarg.get())
return;
-
+
ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
UnparsedDefaultArgLocs.erase(Param);
@@ -165,7 +164,7 @@ Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc,
Param->setInvalidDecl();
return;
}
-
+
SetParamDefaultArgument(Param, move(DefaultArg), EqualLoc);
}
@@ -173,16 +172,16 @@ Sema::ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc,
/// argument for a function parameter, but we can't parse it yet
/// because we're inside a class definition. Note that this default
/// argument will be parsed later.
-void Sema::ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
+void Sema::ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
SourceLocation EqualLoc,
SourceLocation ArgLoc) {
if (!param)
return;
-
+
ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
if (Param)
Param->setUnparsedDefaultArg();
-
+
UnparsedDefaultArgLocs[Param] = ArgLoc;
}
@@ -191,11 +190,11 @@ void Sema::ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
void Sema::ActOnParamDefaultArgumentError(DeclPtrTy param) {
if (!param)
return;
-
+
ParmVarDecl *Param = cast<ParmVarDecl>(param.getAs<Decl>());
-
+
Param->setInvalidDecl();
-
+
UnparsedDefaultArgLocs.erase(Param);
}
@@ -258,8 +257,8 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old) {
ParmVarDecl *OldParam = Old->getParamDecl(p);
ParmVarDecl *NewParam = New->getParamDecl(p);
- if(OldParam->getDefaultArg() && NewParam->getDefaultArg()) {
- Diag(NewParam->getLocation(),
+ if (OldParam->getDefaultArg() && NewParam->getDefaultArg()) {
+ Diag(NewParam->getLocation(),
diag::err_param_default_argument_redefinition)
<< NewParam->getDefaultArg()->getSourceRange();
Diag(OldParam->getLocation(), diag::note_previous_definition);
@@ -300,19 +299,19 @@ void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
// declarations. A default argument shall not be redefined
// by a later declaration (not even to the same value).
unsigned LastMissingDefaultArg = 0;
- for(; p < NumParams; ++p) {
+ for (; p < NumParams; ++p) {
ParmVarDecl *Param = FD->getParamDecl(p);
if (!Param->hasDefaultArg()) {
if (Param->isInvalidDecl())
/* We already complained about this parameter. */;
else if (Param->getIdentifier())
- Diag(Param->getLocation(),
+ Diag(Param->getLocation(),
diag::err_param_default_argument_missing_name)
<< Param->getIdentifier();
else
- Diag(Param->getLocation(),
+ Diag(Param->getLocation(),
diag::err_param_default_argument_missing);
-
+
LastMissingDefaultArg = p;
}
}
@@ -352,7 +351,7 @@ bool Sema::isCurrentClassName(const IdentifierInfo &II, Scope *,
return false;
}
-/// \brief Check the validity of a C++ base class specifier.
+/// \brief Check the validity of a C++ base class specifier.
///
/// \returns a new CXXBaseSpecifier if well-formed, emits diagnostics
/// and returns NULL otherwise.
@@ -360,7 +359,7 @@ CXXBaseSpecifier *
Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
SourceRange SpecifierRange,
bool Virtual, AccessSpecifier Access,
- QualType BaseType,
+ QualType BaseType,
SourceLocation BaseLoc) {
// C++ [class.union]p1:
// A union shall not have base classes.
@@ -371,7 +370,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
}
if (BaseType->isDependentType())
- return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
+ return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
Class->getTagKind() == RecordDecl::TK_class,
Access, BaseType);
@@ -391,7 +390,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
// C++ [class.derived]p2:
// The class-name in a base-specifier shall not be an incompletely
// defined class.
- if (RequireCompleteType(BaseLoc, BaseType,
+ if (RequireCompleteType(BaseLoc, BaseType,
PDiag(diag::err_incomplete_base_class)
<< SpecifierRange))
return 0;
@@ -433,7 +432,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
Class->setEmpty(false);
} else {
// C++ [class.ctor]p5:
- // A constructor is trivial if all the direct base classes of its
+ // A constructor is trivial if all the direct base classes of its
// class have trivial constructors.
if (!cast<CXXRecordDecl>(BaseDecl)->hasTrivialConstructor())
Class->setHasTrivialConstructor(false);
@@ -456,20 +455,20 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
// have trivial destructors.
if (!cast<CXXRecordDecl>(BaseDecl)->hasTrivialDestructor())
Class->setHasTrivialDestructor(false);
-
+
// Create the base specifier.
// FIXME: Allocate via ASTContext?
- return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
- Class->getTagKind() == RecordDecl::TK_class,
+ return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
+ Class->getTagKind() == RecordDecl::TK_class,
Access, BaseType);
}
/// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
/// one entry in the base class list of a class specifier, for
-/// example:
-/// class foo : public bar, virtual private baz {
+/// example:
+/// class foo : public bar, virtual private baz {
/// 'public bar' and 'virtual private baz' are each base-specifiers.
-Sema::BaseResult
+Sema::BaseResult
Sema::ActOnBaseSpecifier(DeclPtrTy classdecl, SourceRange SpecifierRange,
bool Virtual, AccessSpecifier Access,
TypeTy *basetype, SourceLocation BaseLoc) {
@@ -483,7 +482,7 @@ Sema::ActOnBaseSpecifier(DeclPtrTy classdecl, SourceRange SpecifierRange,
Virtual, Access,
BaseType, BaseLoc))
return BaseSpec;
-
+
return true;
}
@@ -504,7 +503,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
unsigned NumGoodBases = 0;
bool Invalid = false;
for (unsigned idx = 0; idx < NumBases; ++idx) {
- QualType NewBaseType
+ QualType NewBaseType
= Context.getCanonicalType(Bases[idx]->getType());
NewBaseType = NewBaseType.getUnqualifiedType();
@@ -543,7 +542,7 @@ bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
/// ActOnBaseSpecifiers - Attach the given base specifiers to the
/// class, after checking whether there are any duplicate base
/// classes.
-void Sema::ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
+void Sema::ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
unsigned NumBases) {
if (!ClassDecl || !Bases || !NumBases)
return;
@@ -592,7 +591,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
Diag(DS.getStorageClassSpecLoc(), diag::err_mutable_function);
else
Diag(DS.getThreadSpecLoc(), diag::err_mutable_function);
-
+
// FIXME: It would be nicer if the keyword was ignored only for this
// declarator. Otherwise we could get follow-up errors.
D.getMutableDeclSpec().ClearStorageClassSpecs();
@@ -670,17 +669,17 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
// A function typedef ("typedef int f(); f a;").
// C++ 9.6p3: A bit-field shall have integral or enumeration type.
Diag(Loc, diag::err_not_integral_type_bitfield)
- << Name << cast<ValueDecl>(Member)->getType()
+ << Name << cast<ValueDecl>(Member)->getType()
<< BitWidth->getSourceRange();
}
-
+
DeleteExpr(BitWidth);
BitWidth = 0;
Member->setInvalidDecl();
}
Member->setAccess(AS);
-
+
// If we have declared a member function template, set the access of the
// templated declaration as well.
if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(Member))
@@ -702,7 +701,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
}
/// ActOnMemInitializer - Handle a C++ member initializer.
-Sema::MemInitResult
+Sema::MemInitResult
Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
Scope *S,
const CXXScopeSpec &SS,
@@ -715,10 +714,10 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
SourceLocation RParenLoc) {
if (!ConstructorD)
return true;
-
+
AdjustDeclIfTemplate(ConstructorD);
-
- CXXConstructorDecl *Constructor
+
+ CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(ConstructorD.getAs<Decl>());
if (!Constructor) {
// The user wrote a constructor initializer on a function that is
@@ -743,7 +742,7 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
if (!SS.getScopeRep() && !TemplateTypeTy) {
// Look for a member, first.
FieldDecl *Member = 0;
- DeclContext::lookup_result Result
+ DeclContext::lookup_result Result
= ClassDecl->lookup(MemberOrBase);
if (Result.first != Result.second)
Member = dyn_cast<FieldDecl>(*Result.first);
@@ -755,12 +754,12 @@ Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
RParenLoc);
}
// It didn't name a member, so see if it names a class.
- TypeTy *BaseTy = TemplateTypeTy ? TemplateTypeTy
+ TypeTy *BaseTy = TemplateTypeTy ? TemplateTypeTy
: getTypeName(*MemberOrBase, IdLoc, S, &SS);
if (!BaseTy)
return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
<< MemberOrBase << SourceRange(IdLoc, RParenLoc);
-
+
QualType BaseType = GetTypeFromParser(BaseTy);
return BuildBaseInitializer(BaseType, (Expr **)Args, NumArgs, IdLoc,
@@ -784,10 +783,10 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
} else if (FieldType->getAs<RecordType>()) {
if (!HasDependentArg)
C = PerformInitializationByConstructor(
- FieldType, (Expr **)Args, NumArgs, IdLoc,
+ FieldType, (Expr **)Args, NumArgs, IdLoc,
SourceRange(IdLoc, RParenLoc), Member->getDeclName(), IK_Direct);
} else if (NumArgs != 1 && NumArgs != 0) {
- return Diag(IdLoc, diag::err_mem_initializer_mismatch)
+ return Diag(IdLoc, diag::err_mem_initializer_mismatch)
<< Member->getDeclName() << SourceRange(IdLoc, RParenLoc);
} else if (!HasDependentArg) {
Expr *NewExp;
@@ -807,7 +806,7 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
Args[0] = NewExp;
}
// FIXME: Perform direct initialization of the member.
- return new (Context) CXXBaseOrMemberInitializer(Member, (Expr **)Args,
+ return new (Context) CXXBaseOrMemberInitializer(Member, (Expr **)Args,
NumArgs, C, IdLoc, RParenLoc);
}
@@ -830,12 +829,12 @@ Sema::BuildBaseInitializer(QualType BaseType, Expr **Args,
// of that class, the mem-initializer is ill-formed. A
// mem-initializer-list can initialize a base class using any
// name that denotes that base class type.
-
+
// First, check for a direct base class.
const CXXBaseSpecifier *DirectBaseSpec = 0;
for (CXXRecordDecl::base_class_const_iterator Base =
ClassDecl->bases_begin(); Base != ClassDecl->bases_end(); ++Base) {
- if (Context.getCanonicalType(BaseType).getUnqualifiedType() ==
+ if (Context.getCanonicalType(BaseType).getUnqualifiedType() ==
Context.getCanonicalType(Base->getType()).getUnqualifiedType()) {
// We found a direct base of this type. That's what we're
// initializing.
@@ -843,7 +842,7 @@ Sema::BuildBaseInitializer(QualType BaseType, Expr **Args,
break;
}
}
-
+
// Check for a virtual base class.
// FIXME: We might be able to short-circuit this if we know in advance that
// there are no virtual bases.
@@ -854,7 +853,7 @@ Sema::BuildBaseInitializer(QualType BaseType, Expr **Args,
BasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
/*DetectVirtual=*/false);
if (IsDerivedFrom(Context.getTypeDeclType(ClassDecl), BaseType, Paths)) {
- for (BasePaths::paths_iterator Path = Paths.begin();
+ for (BasePaths::paths_iterator Path = Paths.begin();
Path != Paths.end(); ++Path) {
if (Path->back().Base->isVirtual()) {
VirtualBaseSpec = Path->back().Base;
@@ -886,11 +885,11 @@ Sema::BuildBaseInitializer(QualType BaseType, Expr **Args,
DeclarationName Name = Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(BaseType));
C = PerformInitializationByConstructor(BaseType, (Expr **)Args, NumArgs,
- IdLoc, SourceRange(IdLoc, RParenLoc),
+ IdLoc, SourceRange(IdLoc, RParenLoc),
Name, IK_Direct);
}
- return new (Context) CXXBaseOrMemberInitializer(BaseType, (Expr **)Args,
+ return new (Context) CXXBaseOrMemberInitializer(BaseType, (Expr **)Args,
NumArgs, C, IdLoc, RParenLoc);
}
@@ -898,7 +897,7 @@ void
Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
CXXBaseOrMemberInitializer **Initializers,
unsigned NumInitializers,
- llvm::SmallVectorImpl<CXXBaseSpecifier *>& Bases,
+ llvm::SmallVectorImpl<CXXBaseSpecifier *>& Bases,
llvm::SmallVectorImpl<FieldDecl *>&Fields) {
// We need to build the initializer AST according to order of construction
// and not what user specified in the Initializers list.
@@ -906,7 +905,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
llvm::SmallVector<CXXBaseOrMemberInitializer*, 32> AllToInit;
llvm::DenseMap<const void *, CXXBaseOrMemberInitializer*> AllBaseFields;
bool HasDependentBaseInit = false;
-
+
for (unsigned i = 0; i < NumInitializers; i++) {
CXXBaseOrMemberInitializer *Member = Initializers[i];
if (Member->isBaseInitializer()) {
@@ -917,13 +916,13 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
AllBaseFields[Member->getMember()] = Member;
}
}
-
+
if (HasDependentBaseInit) {
// FIXME. This does not preserve the ordering of the initializers.
// Try (with -Wreorder)
// template<class X> struct A {};
- // template<class X> struct B : A<X> {
- // B() : x1(10), A<X>() {}
+ // template<class X> struct B : A<X> {
+ // B() : x1(10), A<X>() {}
// int x1;
// };
// B<int> x;
@@ -931,7 +930,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
// while preserving user-declared initializer list. When this routine is
// called during instantiatiation process, this routine will rebuild the
// oderdered initializer list correctly.
-
+
// If we have a dependent base initialization, we can't determine the
// association between initializers and bases; just dump the known
// initializers into the list, and don't try to deal with other bases.
@@ -947,9 +946,9 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
if (VBase->getType()->isDependentType())
continue;
- if (CXXBaseOrMemberInitializer *Value =
+ if (CXXBaseOrMemberInitializer *Value =
AllBaseFields.lookup(VBase->getType()->getAs<RecordType>())) {
- CXXRecordDecl *BaseDecl =
+ CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(VBase->getType()->getAs<RecordType>()->getDecl());
assert(BaseDecl && "setBaseOrMemberInitializers - BaseDecl null");
if (CXXConstructorDecl *Ctor = BaseDecl->getDefaultConstructor(Context))
@@ -957,7 +956,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
AllToInit.push_back(Value);
}
else {
- CXXRecordDecl *VBaseDecl =
+ CXXRecordDecl *VBaseDecl =
cast<CXXRecordDecl>(VBase->getType()->getAs<RecordType>()->getDecl());
assert(VBaseDecl && "setBaseOrMemberInitializers - VBaseDecl null");
CXXConstructorDecl *Ctor = VBaseDecl->getDefaultConstructor(Context);
@@ -966,7 +965,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
else
MarkDeclarationReferenced(Constructor->getLocation(), Ctor);
- CXXBaseOrMemberInitializer *Member =
+ CXXBaseOrMemberInitializer *Member =
new (Context) CXXBaseOrMemberInitializer(VBase->getType(), 0, 0,
Ctor,
SourceLocation(),
@@ -974,7 +973,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
AllToInit.push_back(Member);
}
}
-
+
for (CXXRecordDecl::base_class_iterator Base =
ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
@@ -984,9 +983,9 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
// Skip dependent types.
if (Base->getType()->isDependentType())
continue;
- if (CXXBaseOrMemberInitializer *Value =
+ if (CXXBaseOrMemberInitializer *Value =
AllBaseFields.lookup(Base->getType()->getAs<RecordType>())) {
- CXXRecordDecl *BaseDecl =
+ CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
assert(BaseDecl && "setBaseOrMemberInitializers - BaseDecl null");
if (CXXConstructorDecl *Ctor = BaseDecl->getDefaultConstructor(Context))
@@ -994,7 +993,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
AllToInit.push_back(Value);
}
else {
- CXXRecordDecl *BaseDecl =
+ CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
assert(BaseDecl && "setBaseOrMemberInitializers - BaseDecl null");
CXXConstructorDecl *Ctor = BaseDecl->getDefaultConstructor(Context);
@@ -1003,7 +1002,7 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
else
MarkDeclarationReferenced(Constructor->getLocation(), Ctor);
- CXXBaseOrMemberInitializer *Member =
+ CXXBaseOrMemberInitializer *Member =
new (Context) CXXBaseOrMemberInitializer(Base->getType(), 0, 0,
BaseDecl->getDefaultConstructor(Context),
SourceLocation(),
@@ -1012,16 +1011,16 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
}
}
}
-
+
// non-static data members.
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
E = ClassDecl->field_end(); Field != E; ++Field) {
if ((*Field)->isAnonymousStructOrUnion()) {
- if (const RecordType *FieldClassType =
+ if (const RecordType *FieldClassType =
Field->getType()->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- for(RecordDecl::field_iterator FA = FieldClassDecl->field_begin(),
+ for (RecordDecl::field_iterator FA = FieldClassDecl->field_begin(),
EA = FieldClassDecl->field_end(); FA != EA; FA++) {
if (CXXBaseOrMemberInitializer *Value = AllBaseFields.lookup(*FA)) {
// 'Member' is the anonymous union field and 'AnonUnionMember' is
@@ -1041,21 +1040,21 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
if (const RecordType* RT = FT->getAs<RecordType>()) {
CXXRecordDecl *FieldRecDecl = cast<CXXRecordDecl>(RT->getDecl());
assert(FieldRecDecl && "setBaseOrMemberInitializers - BaseDecl null");
- if (CXXConstructorDecl *Ctor =
+ if (CXXConstructorDecl *Ctor =
FieldRecDecl->getDefaultConstructor(Context))
MarkDeclarationReferenced(Value->getSourceLocation(), Ctor);
}
AllToInit.push_back(Value);
continue;
}
-
+
QualType FT = Context.getBaseElementType((*Field)->getType());
if (const RecordType* RT = FT->getAs<RecordType>()) {
CXXConstructorDecl *Ctor =
cast<CXXRecordDecl>(RT->getDecl())->getDefaultConstructor(Context);
if (!Ctor && !FT->isDependentType())
Fields.push_back(*Field);
- CXXBaseOrMemberInitializer *Member =
+ CXXBaseOrMemberInitializer *Member =
new (Context) CXXBaseOrMemberInitializer((*Field), 0, 0,
Ctor,
SourceLocation(),
@@ -1080,13 +1079,13 @@ Sema::setBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
Diag((*Field)->getLocation(), diag::note_declared_at);
}
}
-
+
NumInitializers = AllToInit.size();
if (NumInitializers > 0) {
Constructor->setNumBaseOrMemberInitializers(NumInitializers);
CXXBaseOrMemberInitializer **baseOrMemberInitializers =
new (Context) CXXBaseOrMemberInitializer*[NumInitializers];
-
+
Constructor->setBaseOrMemberInitializers(baseOrMemberInitializers);
for (unsigned Idx = 0; Idx < NumInitializers; ++Idx)
baseOrMemberInitializers[Idx] = AllToInit[Idx];
@@ -1101,14 +1100,14 @@ Sema::BuildBaseOrMemberInitializers(ASTContext &C,
) {
llvm::SmallVector<CXXBaseSpecifier *, 4>Bases;
llvm::SmallVector<FieldDecl *, 4>Members;
-
- setBaseOrMemberInitializers(Constructor,
+
+ setBaseOrMemberInitializers(Constructor,
Initializers, NumInitializers, Bases, Members);
for (unsigned int i = 0; i < Bases.size(); i++)
- Diag(Bases[i]->getSourceRange().getBegin(),
+ Diag(Bases[i]->getSourceRange().getBegin(),
diag::err_missing_default_constructor) << 0 << Bases[i]->getType();
for (unsigned int i = 0; i < Members.size(); i++)
- Diag(Members[i]->getLocation(), diag::err_missing_default_constructor)
+ Diag(Members[i]->getLocation(), diag::err_missing_default_constructor)
<< 1 << Members[i]->getType();
}
@@ -1124,20 +1123,20 @@ static void *GetKeyForTopLevelField(FieldDecl *Field) {
static void *GetKeyForBase(QualType BaseType) {
if (const RecordType *RT = BaseType->getAs<RecordType>())
return (void *)RT;
-
+
assert(0 && "Unexpected base type!");
return 0;
}
-static void *GetKeyForMember(CXXBaseOrMemberInitializer *Member,
+static void *GetKeyForMember(CXXBaseOrMemberInitializer *Member,
bool MemberMaybeAnon = false) {
// For fields injected into the class via declaration of an anonymous union,
// use its anonymous union class declaration as the unique key.
if (Member->isMemberInitializer()) {
FieldDecl *Field = Member->getMember();
-
+
// After BuildBaseOrMemberInitializers call, Field is the anonymous union
- // data member of the class. Data member used in the initializer list is
+ // data member of the class. Data member used in the initializer list is
// in AnonUnionMember field.
if (MemberMaybeAnon && Field->isAnonymousStructOrUnion())
Field = Member->getAnonUnionMember();
@@ -1148,31 +1147,31 @@ static void *GetKeyForMember(CXXBaseOrMemberInitializer *Member,
}
return static_cast<void *>(Field);
}
-
+
return GetKeyForBase(QualType(Member->getBaseClass(), 0));
}
-void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
+void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
SourceLocation ColonLoc,
MemInitTy **MemInits, unsigned NumMemInits) {
if (!ConstructorDecl)
return;
AdjustDeclIfTemplate(ConstructorDecl);
-
- CXXConstructorDecl *Constructor
+
+ CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(ConstructorDecl.getAs<Decl>());
-
+
if (!Constructor) {
Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
return;
}
-
+
if (!Constructor->isDependentContext()) {
llvm::DenseMap<void*, CXXBaseOrMemberInitializer *>Members;
bool err = false;
for (unsigned i = 0; i < NumMemInits; i++) {
- CXXBaseOrMemberInitializer *Member =
+ CXXBaseOrMemberInitializer *Member =
static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
void *KeyToMember = GetKeyForMember(Member);
CXXBaseOrMemberInitializer *&PrevMember = Members[KeyToMember];
@@ -1181,13 +1180,13 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
continue;
}
if (FieldDecl *Field = Member->getMember())
- Diag(Member->getSourceLocation(),
+ Diag(Member->getSourceLocation(),
diag::error_multiple_mem_initialization)
<< Field->getNameAsString();
else {
Type *BaseClass = Member->getBaseClass();
assert(BaseClass && "ActOnMemInitializers - neither field or base");
- Diag(Member->getSourceLocation(),
+ Diag(Member->getSourceLocation(),
diag::error_multiple_base_initialization)
<< BaseClass->getDesugaredType(true);
}
@@ -1195,28 +1194,28 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
<< 0;
err = true;
}
-
+
if (err)
return;
}
-
+
BuildBaseOrMemberInitializers(Context, Constructor,
- reinterpret_cast<CXXBaseOrMemberInitializer **>(MemInits),
+ reinterpret_cast<CXXBaseOrMemberInitializer **>(MemInits),
NumMemInits);
-
+
if (Constructor->isDependentContext())
return;
-
- if (Diags.getDiagnosticLevel(diag::warn_base_initialized) ==
+
+ if (Diags.getDiagnosticLevel(diag::warn_base_initialized) ==
Diagnostic::Ignored &&
- Diags.getDiagnosticLevel(diag::warn_field_initialized) ==
+ Diags.getDiagnosticLevel(diag::warn_field_initialized) ==
Diagnostic::Ignored)
return;
-
+
// Also issue warning if order of ctor-initializer list does not match order
// of 1) base class declarations and 2) order of non-static data members.
llvm::SmallVector<const void*, 32> AllBaseOrMembers;
-
+
CXXRecordDecl *ClassDecl
= cast<CXXRecordDecl>(Constructor->getDeclContext());
// Push virtual bases before others.
@@ -1224,7 +1223,7 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
ClassDecl->vbases_begin(),
E = ClassDecl->vbases_end(); VBase != E; ++VBase)
AllBaseOrMembers.push_back(GetKeyForBase(VBase->getType()));
-
+
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
// Virtuals are alread in the virtual base list and are constructed
@@ -1233,16 +1232,16 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
continue;
AllBaseOrMembers.push_back(GetKeyForBase(Base->getType()));
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
E = ClassDecl->field_end(); Field != E; ++Field)
AllBaseOrMembers.push_back(GetKeyForTopLevelField(*Field));
-
+
int Last = AllBaseOrMembers.size();
int curIndex = 0;
CXXBaseOrMemberInitializer *PrevMember = 0;
for (unsigned i = 0; i < NumMemInits; i++) {
- CXXBaseOrMemberInitializer *Member =
+ CXXBaseOrMemberInitializer *Member =
static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
void *MemberInCtorList = GetKeyForMember(Member, true);
@@ -1257,27 +1256,27 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
// Diagnostics is for an initialized base class.
Type *BaseClass = PrevMember->getBaseClass();
Diag(PrevMember->getSourceLocation(),
- diag::warn_base_initialized)
+ diag::warn_base_initialized)
<< BaseClass->getDesugaredType(true);
} else {
FieldDecl *Field = PrevMember->getMember();
Diag(PrevMember->getSourceLocation(),
- diag::warn_field_initialized)
+ diag::warn_field_initialized)
<< Field->getNameAsString();
}
// Also the note!
if (FieldDecl *Field = Member->getMember())
- Diag(Member->getSourceLocation(),
+ Diag(Member->getSourceLocation(),
diag::note_fieldorbase_initialized_here) << 0
<< Field->getNameAsString();
else {
Type *BaseClass = Member->getBaseClass();
- Diag(Member->getSourceLocation(),
+ Diag(Member->getSourceLocation(),
diag::note_fieldorbase_initialized_here) << 1
<< BaseClass->getDesugaredType(true);
}
for (curIndex = 0; curIndex < Last; curIndex++)
- if (MemberInCtorList == AllBaseOrMembers[curIndex])
+ if (MemberInCtorList == AllBaseOrMembers[curIndex])
break;
}
PrevMember = Member;
@@ -1288,7 +1287,7 @@ void
Sema::computeBaseOrMembersToDestroy(CXXDestructorDecl *Destructor) {
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(Destructor->getDeclContext());
llvm::SmallVector<uintptr_t, 32> AllToDestruct;
-
+
for (CXXRecordDecl::base_class_iterator VBase = ClassDecl->vbases_begin(),
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
if (VBase->getType()->isDependentType())
@@ -1299,11 +1298,11 @@ Sema::computeBaseOrMembersToDestroy(CXXDestructorDecl *Destructor) {
if (BaseClassDecl->hasTrivialDestructor())
continue;
if (const CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(Context))
- MarkDeclarationReferenced(Destructor->getLocation(),
+ MarkDeclarationReferenced(Destructor->getLocation(),
const_cast<CXXDestructorDecl*>(Dtor));
-
- uintptr_t Member =
- reinterpret_cast<uintptr_t>(VBase->getType().getTypePtr())
+
+ uintptr_t Member =
+ reinterpret_cast<uintptr_t>(VBase->getType().getTypePtr())
| CXXDestructorDecl::VBASE;
AllToDestruct.push_back(Member);
}
@@ -1320,37 +1319,37 @@ Sema::computeBaseOrMembersToDestroy(CXXDestructorDecl *Destructor) {
if (BaseClassDecl->hasTrivialDestructor())
continue;
if (const CXXDestructorDecl *Dtor = BaseClassDecl->getDestructor(Context))
- MarkDeclarationReferenced(Destructor->getLocation(),
+ MarkDeclarationReferenced(Destructor->getLocation(),
const_cast<CXXDestructorDecl*>(Dtor));
- uintptr_t Member =
- reinterpret_cast<uintptr_t>(Base->getType().getTypePtr())
+ uintptr_t Member =
+ reinterpret_cast<uintptr_t>(Base->getType().getTypePtr())
| CXXDestructorDecl::DRCTNONVBASE;
AllToDestruct.push_back(Member);
}
-
+
// non-static data members.
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
E = ClassDecl->field_end(); Field != E; ++Field) {
QualType FieldType = Context.getBaseElementType((*Field)->getType());
-
+
if (const RecordType* RT = FieldType->getAs<RecordType>()) {
// Skip over virtual bases which have trivial destructors.
CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(RT->getDecl());
if (FieldClassDecl->hasTrivialDestructor())
continue;
- if (const CXXDestructorDecl *Dtor =
+ if (const CXXDestructorDecl *Dtor =
FieldClassDecl->getDestructor(Context))
- MarkDeclarationReferenced(Destructor->getLocation(),
+ MarkDeclarationReferenced(Destructor->getLocation(),
const_cast<CXXDestructorDecl*>(Dtor));
uintptr_t Member = reinterpret_cast<uintptr_t>(*Field);
AllToDestruct.push_back(Member);
}
}
-
+
unsigned NumDestructions = AllToDestruct.size();
if (NumDestructions > 0) {
Destructor->setNumBaseOrMemberDestructions(NumDestructions);
- uintptr_t *BaseOrMemberDestructions =
+ uintptr_t *BaseOrMemberDestructions =
new (Context) uintptr_t [NumDestructions];
// Insert in reverse order.
for (int Idx = NumDestructions-1, i=0 ; Idx >= 0; --Idx)
@@ -1362,10 +1361,10 @@ Sema::computeBaseOrMembersToDestroy(CXXDestructorDecl *Destructor) {
void Sema::ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl) {
if (!CDtorDecl)
return;
-
+
AdjustDeclIfTemplate(CDtorDecl);
-
- if (CXXConstructorDecl *Constructor
+
+ if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(CDtorDecl.getAs<Decl>()))
BuildBaseOrMemberInitializers(Context,
Constructor,
@@ -1383,31 +1382,31 @@ namespace {
private:
MethodList Methods;
-
+
void Collect(const CXXRecordDecl* RD, MethodList& Methods);
-
+
public:
- PureVirtualMethodCollector(ASTContext &Ctx, const CXXRecordDecl* RD)
+ PureVirtualMethodCollector(ASTContext &Ctx, const CXXRecordDecl* RD)
: Context(Ctx) {
-
+
MethodList List;
Collect(RD, List);
-
+
// Copy the temporary list to methods, and make sure to ignore any
// null entries.
for (size_t i = 0, e = List.size(); i != e; ++i) {
if (List[i])
Methods.push_back(List[i]);
- }
+ }
}
-
+
bool empty() const { return Methods.empty(); }
-
+
MethodList::const_iterator methods_begin() { return Methods.begin(); }
MethodList::const_iterator methods_end() { return Methods.end(); }
};
-
- void PureVirtualMethodCollector::Collect(const CXXRecordDecl* RD,
+
+ void PureVirtualMethodCollector::Collect(const CXXRecordDecl* RD,
MethodList& Methods) {
// First, collect the pure virtual methods for the base classes.
for (CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(),
@@ -1418,14 +1417,14 @@ namespace {
Collect(BaseDecl, Methods);
}
}
-
+
// Next, zero out any pure virtual methods that this class overrides.
typedef llvm::SmallPtrSet<const CXXMethodDecl*, 4> MethodSetTy;
-
+
MethodSetTy OverriddenMethods;
size_t MethodsSize = Methods.size();
- for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end();
+ for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end();
i != e; ++i) {
// Traverse the record, looking for methods.
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) {
@@ -1434,7 +1433,7 @@ namespace {
Methods.push_back(MD);
continue;
}
-
+
// Otherwise, record all the overridden methods in our set.
for (CXXMethodDecl::method_iterator I = MD->begin_overridden_methods(),
E = MD->end_overridden_methods(); I != E; ++I) {
@@ -1443,19 +1442,19 @@ namespace {
}
}
}
-
- // Now go through the methods and zero out all the ones we know are
+
+ // Now go through the methods and zero out all the ones we know are
// overridden.
for (size_t i = 0, e = MethodsSize; i != e; ++i) {
if (OverriddenMethods.count(Methods[i]))
Methods[i] = 0;
}
-
+
}
}
-bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
+bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
unsigned DiagID, AbstractDiagSelID SelID,
const CXXRecordDecl *CurrentRD) {
if (SelID == -1)
@@ -1464,71 +1463,71 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
else
return RequireNonAbstractType(Loc, T,
PDiag(DiagID) << SelID, CurrentRD);
-}
-
+}
+
bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T,
const PartialDiagnostic &PD,
const CXXRecordDecl *CurrentRD) {
if (!getLangOptions().CPlusPlus)
return false;
-
+
if (const ArrayType *AT = Context.getAsArrayType(T))
return RequireNonAbstractType(Loc, AT->getElementType(), PD,
CurrentRD);
-
+
if (const PointerType *PT = T->getAs<PointerType>()) {
// Find the innermost pointer type.
while (const PointerType *T = PT->getPointeeType()->getAs<PointerType>())
PT = T;
-
+
if (const ArrayType *AT = Context.getAsArrayType(PT->getPointeeType()))
return RequireNonAbstractType(Loc, AT->getElementType(), PD, CurrentRD);
}
-
+
const RecordType *RT = T->getAs<RecordType>();
if (!RT)
return false;
-
+
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl());
if (!RD)
return false;
if (CurrentRD && CurrentRD != RD)
return false;
-
+
if (!RD->isAbstract())
return false;
-
+
Diag(Loc, PD) << RD->getDeclName();
-
+
// Check if we've already emitted the list of pure virtual functions for this
// class.
if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
return true;
-
+
PureVirtualMethodCollector Collector(Context, RD);
-
- for (PureVirtualMethodCollector::MethodList::const_iterator I =
+
+ for (PureVirtualMethodCollector::MethodList::const_iterator I =
Collector.methods_begin(), E = Collector.methods_end(); I != E; ++I) {
const CXXMethodDecl *MD = *I;
-
- Diag(MD->getLocation(), diag::note_pure_virtual_function) <<
+
+ Diag(MD->getLocation(), diag::note_pure_virtual_function) <<
MD->getDeclName();
}
if (!PureVirtualClassDiagSet)
PureVirtualClassDiagSet.reset(new RecordDeclSetTy);
PureVirtualClassDiagSet->insert(RD);
-
+
return true;
}
namespace {
- class VISIBILITY_HIDDEN AbstractClassUsageDiagnoser
+ class VISIBILITY_HIDDEN AbstractClassUsageDiagnoser
: public DeclVisitor<AbstractClassUsageDiagnoser, bool> {
Sema &SemaRef;
CXXRecordDecl *AbstractClass;
-
+
bool VisitDeclContext(const DeclContext *DC) {
bool Invalid = false;
@@ -1538,7 +1537,7 @@ namespace {
return Invalid;
}
-
+
public:
AbstractClassUsageDiagnoser(Sema& SemaRef, CXXRecordDecl *ac)
: SemaRef(SemaRef), AbstractClass(ac) {
@@ -1549,36 +1548,36 @@ namespace {
if (FD->isThisDeclarationADefinition()) {
// No need to do the check if we're in a definition, because it requires
// that the return/param types are complete.
- // because that requires
+ // because that requires
return VisitDeclContext(FD);
}
-
+
// Check the return type.
QualType RTy = FD->getType()->getAsFunctionType()->getResultType();
- bool Invalid =
+ bool Invalid =
SemaRef.RequireNonAbstractType(FD->getLocation(), RTy,
diag::err_abstract_type_in_decl,
Sema::AbstractReturnType,
AbstractClass);
- for (FunctionDecl::param_const_iterator I = FD->param_begin(),
+ for (FunctionDecl::param_const_iterator I = FD->param_begin(),
E = FD->param_end(); I != E; ++I) {
const ParmVarDecl *VD = *I;
- Invalid |=
+ Invalid |=
SemaRef.RequireNonAbstractType(VD->getLocation(),
- VD->getOriginalType(),
- diag::err_abstract_type_in_decl,
+ VD->getOriginalType(),
+ diag::err_abstract_type_in_decl,
Sema::AbstractParamType,
AbstractClass);
}
return Invalid;
}
-
+
bool VisitDecl(const Decl* D) {
if (const DeclContext *DC = dyn_cast<DeclContext>(D))
return VisitDeclContext(DC);
-
+
return false;
}
};
@@ -1590,7 +1589,7 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
SourceLocation RBrac) {
if (!TagDecl)
return;
-
+
AdjustDeclIfTemplate(TagDecl);
ActOnFields(S, RLoc, TagDecl,
(DeclPtrTy*)FieldCollector->getCurFields(),
@@ -1601,13 +1600,13 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
// Collect all the pure virtual methods and see if this is an abstract
// class after all.
PureVirtualMethodCollector Collector(Context, RD);
- if (!Collector.empty())
+ if (!Collector.empty())
RD->setAbstract(true);
}
-
- if (RD->isAbstract())
+
+ if (RD->isAbstract())
AbstractClassUsageDiagnoser(*this, RD);
-
+
if (!RD->isDependentType())
AddImplicitlyDeclaredMembersToClass(RD);
}
@@ -1618,7 +1617,7 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
/// [special]p1). This routine can only be executed just before the
/// definition of the class is complete.
void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
- CanQualType ClassType
+ CanQualType ClassType
= Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
// FIXME: Implicit declarations have exception specifications, which are
@@ -1631,9 +1630,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
// user-declared constructor for class X, a default constructor is
// implicitly declared. An implicitly-declared default constructor
// is an inline public member of its class.
- DeclarationName Name
+ DeclarationName Name
= Context.DeclarationNames.getCXXConstructorName(ClassType);
- CXXConstructorDecl *DefaultCon =
+ CXXConstructorDecl *DefaultCon =
CXXConstructorDecl::Create(Context, ClassDecl,
ClassDecl->getLocation(), Name,
Context.getFunctionType(Context.VoidTy,
@@ -1669,7 +1668,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
HasConstCopyConstructor && Base != ClassDecl->bases_end(); ++Base) {
const CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- HasConstCopyConstructor
+ HasConstCopyConstructor
= BaseClassDecl->hasConstCopyConstructor(Context);
}
@@ -1684,9 +1683,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
- const CXXRecordDecl *FieldClassDecl
+ const CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- HasConstCopyConstructor
+ HasConstCopyConstructor
= FieldClassDecl->hasConstCopyConstructor(Context);
}
}
@@ -1702,7 +1701,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
// An implicitly-declared copy constructor is an inline public
// member of its class.
- DeclarationName Name
+ DeclarationName Name
= Context.DeclarationNames.getCXXConstructorName(ClassType);
CXXConstructorDecl *CopyConstructor
= CXXConstructorDecl::Create(Context, ClassDecl,
@@ -1753,7 +1752,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
const CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
const CXXMethodDecl *MD = 0;
- HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context,
+ HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context,
MD);
}
@@ -1818,9 +1817,9 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
// If a class has no user-declared destructor, a destructor is
// declared implicitly. An implicitly-declared destructor is an
// inline public member of its class.
- DeclarationName Name
+ DeclarationName Name
= Context.DeclarationNames.getCXXDestructorName(ClassType);
- CXXDestructorDecl *Destructor
+ CXXDestructorDecl *Destructor
= CXXDestructorDecl::Create(Context, ClassDecl,
ClassDecl->getLocation(), Name,
Context.getFunctionType(Context.VoidTy,
@@ -1862,12 +1861,12 @@ void Sema::ActOnReenterTemplateScope(Scope *S, DeclPtrTy TemplateD) {
void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
if (!MethodD)
return;
-
+
AdjustDeclIfTemplate(MethodD);
-
+
CXXScopeSpec SS;
FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
- QualType ClassTy
+ QualType ClassTy
= Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
SS.setScopeRep(
NestedNameSpecifier::Create(Context, 0, false, ClassTy.getTypePtr()));
@@ -1882,7 +1881,7 @@ void Sema::ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
void Sema::ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy ParamD) {
if (!ParamD)
return;
-
+
ParmVarDecl *Param = cast<ParmVarDecl>(ParamD.getAs<Decl>());
// If this parameter has an unparsed default argument, clear it out
@@ -1904,12 +1903,12 @@ void Sema::ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy ParamD) {
void Sema::ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclPtrTy MethodD) {
if (!MethodD)
return;
-
+
AdjustDeclIfTemplate(MethodD);
-
+
FunctionDecl *Method = cast<FunctionDecl>(MethodD.getAs<Decl>());
CXXScopeSpec SS;
- QualType ClassTy
+ QualType ClassTy
= Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
SS.setScopeRep(
NestedNameSpecifier::Create(Context, 0, false, ClassTy.getTypePtr()));
@@ -1957,7 +1956,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
D.setInvalidType();
SC = FunctionDecl::None;
}
-
+
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.TypeQuals != 0) {
if (FTI.TypeQuals & QualType::Const)
@@ -1970,7 +1969,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
<< "restrict" << SourceRange(D.getIdentifierLoc());
}
-
+
// Rebuild the function type "R" without any type qualifiers (in
// case any of the errors above fired) and with "void" as the
// return type, since constructors don't have return types. We
@@ -1986,7 +1985,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
/// well-formedness, issuing any diagnostics required. Returns true if
/// the constructor declarator is invalid.
void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
- CXXRecordDecl *ClassDecl
+ CXXRecordDecl *ClassDecl
= dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
if (!ClassDecl)
return Constructor->setInvalidDecl();
@@ -1997,8 +1996,8 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
// either there are no other parameters or else all other
// parameters have default arguments.
if (!Constructor->isInvalidDecl() &&
- ((Constructor->getNumParams() == 1) ||
- (Constructor->getNumParams() > 1 &&
+ ((Constructor->getNumParams() == 1) ||
+ (Constructor->getNumParams() > 1 &&
Constructor->getParamDecl(1)->hasDefaultArg()))) {
QualType ParamType = Constructor->getParamDecl(0)->getType();
QualType ClassTy = Context.getTagDeclType(ClassDecl);
@@ -2009,12 +2008,12 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
Constructor->setInvalidDecl();
}
}
-
+
// Notify the class that we've added a constructor.
ClassDecl->addedConstructor(Context, Constructor);
}
-static inline bool
+static inline bool
FTIHasSingleVoidArgument(DeclaratorChunk::FunctionTypeInfo &FTI) {
return (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
FTI.ArgInfo[0].Param &&
@@ -2070,7 +2069,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D,
<< SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
<< SourceRange(D.getIdentifierLoc());
}
-
+
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.TypeQuals != 0 && !D.isInvalidType()) {
if (FTI.TypeQuals & QualType::Const)
@@ -2094,7 +2093,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D,
D.setInvalidType();
}
- // Make sure the destructor isn't variadic.
+ // Make sure the destructor isn't variadic.
if (FTI.isVariadic) {
Diag(D.getIdentifierLoc(), diag::err_destructor_variadic);
D.setInvalidType();
@@ -2119,7 +2118,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
// C++ [class.conv.fct]p1:
// Neither parameter types nor return type can be specified. The
// type of a conversion function (8.3.5) is "function taking no
- // parameter returning conversion-type-id."
+ // parameter returning conversion-type-id."
if (SC == FunctionDecl::Static) {
if (!D.isInvalidType())
Diag(D.getIdentifierLoc(), diag::err_conv_function_not_member)
@@ -2151,7 +2150,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
D.setInvalidType();
}
- // Make sure the conversion function isn't variadic.
+ // Make sure the conversion function isn't variadic.
if (R->getAsFunctionProtoType()->isVariadic() && !D.isInvalidType()) {
Diag(D.getIdentifierLoc(), diag::err_conv_function_variadic);
D.setInvalidType();
@@ -2173,13 +2172,13 @@ void Sema::CheckConversionDeclarator(Declarator &D, QualType &R,
// Rebuild the function type "R" without any parameters (in case any
// of the errors above fired) and with the conversion type as the
- // return type.
- R = Context.getFunctionType(ConvType, 0, 0, false,
+ // return type.
+ R = Context.getFunctionType(ConvType, 0, 0, false,
R->getAsFunctionProtoType()->getTypeQuals());
// C++0x explicit conversion operators.
if (D.getDeclSpec().isExplicitSpecified() && !getLangOptions().CPlusPlus0x)
- Diag(D.getDeclSpec().getExplicitSpecLoc(),
+ Diag(D.getDeclSpec().getExplicitSpecLoc(),
diag::warn_explicit_conversion_functions)
<< SourceRange(D.getDeclSpec().getExplicitSpecLoc());
}
@@ -2204,7 +2203,7 @@ Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
// or to (possibly cv-qualified) void.
// FIXME: Suppress this warning if the conversion function ends up being a
// virtual function that overrides a virtual function in a base class.
- QualType ClassType
+ QualType ClassType
= Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
if (const ReferenceType *ConvTypeRef = ConvType->getAs<ReferenceType>())
ConvType = ConvTypeRef->getPointeeType();
@@ -2223,11 +2222,11 @@ Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
if (Conversion->getPreviousDeclaration()) {
const NamedDecl *ExpectedPrevDecl = Conversion->getPreviousDeclaration();
- if (FunctionTemplateDecl *ConversionTemplate
+ if (FunctionTemplateDecl *ConversionTemplate
= Conversion->getDescribedFunctionTemplate())
ExpectedPrevDecl = ConversionTemplate->getPreviousDeclaration();
OverloadedFunctionDecl *Conversions = ClassDecl->getConversionFunctions();
- for (OverloadedFunctionDecl::function_iterator
+ for (OverloadedFunctionDecl::function_iterator
Conv = Conversions->function_begin(),
ConvEnd = Conversions->function_end();
Conv != ConvEnd; ++Conv) {
@@ -2237,7 +2236,7 @@ Sema::DeclPtrTy Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
}
}
assert(Conversion->isInvalidDecl() && "Conversion should not get here.");
- } else if (FunctionTemplateDecl *ConversionTemplate
+ } else if (FunctionTemplateDecl *ConversionTemplate
= Conversion->getDescribedFunctionTemplate())
ClassDecl->addConversionFunction(Context, ConversionTemplate);
else if (!Conversion->getPrimaryTemplate()) // ignore specializations
@@ -2272,7 +2271,7 @@ Sema::DeclPtrTy Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
NamedDecl *PrevDecl = LookupName(DeclRegionScope, II, LookupOrdinaryName,
true);
-
+
if (NamespaceDecl *OrigNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl)) {
// This is an extended namespace definition.
// Attach this namespace decl to the chain of extended namespace
@@ -2280,7 +2279,7 @@ Sema::DeclPtrTy Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
OrigNS->setNextNamespace(Namespc);
Namespc->setOriginalNamespace(OrigNS->getOriginalNamespace());
- // Remove the previous declaration from the scope.
+ // Remove the previous declaration from the scope.
if (DeclRegionScope->isDeclScope(DeclPtrTy::make(OrigNS))) {
IdResolver.RemoveDecl(OrigNS);
DeclRegionScope->RemoveDecl(DeclPtrTy::make(OrigNS));
@@ -2292,7 +2291,7 @@ Sema::DeclPtrTy Sema::ActOnStartNamespaceDef(Scope *NamespcScope,
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
Namespc->setInvalidDecl();
// Continue on to push Namespc as current DeclContext and return it.
- }
+ }
PushOnScopeChains(Namespc, DeclRegionScope);
} else {
@@ -2357,9 +2356,9 @@ Sema::DeclPtrTy Sema::ActOnUsingDirective(Scope *S,
while (CommonAncestor && !CommonAncestor->Encloses(CurContext))
CommonAncestor = CommonAncestor->getParent();
- UDir = UsingDirectiveDecl::Create(Context,
+ UDir = UsingDirectiveDecl::Create(Context,
CurContext, UsingLoc,
- NamespcLoc,
+ NamespcLoc,
SS.getRange(),
(NestedNameSpecifier *)SS.getScopeRep(),
IdentLoc,
@@ -2399,20 +2398,20 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
bool IsTypeName) {
assert((TargetName || Op) && "Invalid TargetName.");
assert(S->getFlags() & Scope::DeclScope && "Invalid Scope.");
-
+
DeclarationName Name;
if (TargetName)
Name = TargetName;
else
Name = Context.DeclarationNames.getCXXOperatorName(Op);
-
- NamedDecl *UD = BuildUsingDeclaration(UsingLoc, SS, IdentLoc,
+
+ NamedDecl *UD = BuildUsingDeclaration(UsingLoc, SS, IdentLoc,
Name, AttrList, IsTypeName);
if (UD) {
PushOnScopeChains(UD, S);
UD->setAccess(AS);
}
-
+
return DeclPtrTy::make(UD);
}
@@ -2427,13 +2426,13 @@ NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
// FIXME: We ignore attributes for now.
delete AttrList;
-
+
if (SS.isEmpty()) {
Diag(IdentLoc, diag::err_using_requires_qualname);
return 0;
}
-
- NestedNameSpecifier *NNS =
+
+ NestedNameSpecifier *NNS =
static_cast<NestedNameSpecifier *>(SS.getScopeRep());
if (isUnknownSpecialization(SS)) {
@@ -2441,15 +2440,15 @@ NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
SS.getRange(), NNS,
IdentLoc, Name, IsTypeName);
}
-
+
DeclContext *LookupContext = 0;
-
+
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(CurContext)) {
// C++0x N2914 [namespace.udecl]p3:
// A using-declaration used as a member-declaration shall refer to a member
// of a base class of the class being defined, shall refer to a member of an
// anonymous union that is a member of a base class of the class being
- // defined, or shall refer to an enumerator for an enumeration type that is
+ // defined, or shall refer to an enumerator for an enumeration type that is
// a member of a base class of the class being defined.
const Type *Ty = NNS->getAsType();
if (!Ty || !IsDerivedFrom(Context.getTagDeclType(RD), QualType(Ty, 0))) {
@@ -2469,7 +2468,7 @@ NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
<< SS.getRange();
return 0;
}
-
+
// C++0x N2914 [namespace.udecl]p9:
// In a using-declaration, a prefix :: refers to the global namespace.
if (NNS->getKind() == NestedNameSpecifier::Global)
@@ -2480,16 +2479,16 @@ NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
// Lookup target name.
- LookupResult R = LookupQualifiedName(LookupContext,
+ LookupResult R = LookupQualifiedName(LookupContext,
Name, LookupOrdinaryName);
-
+
if (!R) {
DiagnoseMissingMember(IdentLoc, Name, NNS, SS.getRange());
return 0;
}
NamedDecl *ND = R.getAsDecl();
-
+
if (IsTypeName && !isa<TypeDecl>(ND)) {
Diag(IdentLoc, diag::err_using_typename_non_type);
return 0;
@@ -2502,7 +2501,7 @@ NamedDecl *Sema::BuildUsingDeclaration(SourceLocation UsingLoc,
<< SS.getRange();
return 0;
}
-
+
return UsingDecl::Create(Context, CurContext, IdentLoc, SS.getRange(),
ND->getLocation(), UsingLoc, ND, NNS, IsTypeName);
}
@@ -2515,26 +2514,26 @@ static inline NamespaceDecl *getNamespaceDecl(NamedDecl *D) {
return dyn_cast_or_null<NamespaceDecl>(D);
}
-Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
+Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
SourceLocation NamespaceLoc,
SourceLocation AliasLoc,
IdentifierInfo *Alias,
const CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *Ident) {
-
+
// Lookup the namespace name.
LookupResult R = LookupParsedName(S, &SS, Ident, LookupNamespaceName, false);
// Check if we have a previous declaration with the same name.
if (NamedDecl *PrevDecl = LookupName(S, Alias, LookupOrdinaryName, true)) {
if (NamespaceAliasDecl *AD = dyn_cast<NamespaceAliasDecl>(PrevDecl)) {
- // We already have an alias with the same name that points to the same
+ // We already have an alias with the same name that points to the same
// namespace, so don't create a new one.
if (!R.isAmbiguous() && AD->getNamespace() == getNamespaceDecl(R))
return DeclPtrTy();
}
-
+
unsigned DiagID = isa<NamespaceDecl>(PrevDecl) ? diag::err_redefinition :
diag::err_redefinition_different_kind;
Diag(AliasLoc, DiagID) << Alias;
@@ -2546,18 +2545,18 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
DiagnoseAmbiguousLookup(R, Ident, IdentLoc);
return DeclPtrTy();
}
-
+
if (!R) {
Diag(NamespaceLoc, diag::err_expected_namespace_name) << SS.getRange();
return DeclPtrTy();
}
-
+
NamespaceAliasDecl *AliasDecl =
- NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc,
- Alias, SS.getRange(),
+ NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc,
+ Alias, SS.getRange(),
(NestedNameSpecifier *)SS.getScopeRep(),
IdentLoc, R);
-
+
CurContext->addDecl(AliasDecl);
return DeclPtrTy::make(AliasDecl);
}
@@ -2567,11 +2566,11 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
assert((Constructor->isImplicit() && Constructor->isDefaultConstructor() &&
!Constructor->isUsed()) &&
"DefineImplicitDefaultConstructor - call it for implicit default ctor");
-
+
CXXRecordDecl *ClassDecl
= cast<CXXRecordDecl>(Constructor->getDeclContext());
assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
- // Before the implicitly-declared default constructor for a class is
+ // Before the implicitly-declared default constructor for a class is
// implicitly defined, all the implicitly-declared default constructors
// for its base class and its non-static data members shall have been
// implicitly defined.
@@ -2581,14 +2580,14 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (!BaseClassDecl->hasTrivialConstructor()) {
- if (CXXConstructorDecl *BaseCtor =
+ if (CXXConstructorDecl *BaseCtor =
BaseClassDecl->getDefaultConstructor(Context))
MarkDeclarationReferenced(CurrentLocation, BaseCtor);
else {
- Diag(CurrentLocation, diag::err_defining_default_ctor)
- << Context.getTagDeclType(ClassDecl) << 1
+ Diag(CurrentLocation, diag::err_defining_default_ctor)
+ << Context.getTagDeclType(ClassDecl) << 1
<< Context.getTagDeclType(BaseClassDecl);
- Diag(BaseClassDecl->getLocation(), diag::note_previous_class_decl)
+ Diag(BaseClassDecl->getLocation(), diag::note_previous_class_decl)
<< Context.getTagDeclType(BaseClassDecl);
err = true;
}
@@ -2603,25 +2602,25 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (!FieldClassDecl->hasTrivialConstructor()) {
- if (CXXConstructorDecl *FieldCtor =
+ if (CXXConstructorDecl *FieldCtor =
FieldClassDecl->getDefaultConstructor(Context))
MarkDeclarationReferenced(CurrentLocation, FieldCtor);
else {
- Diag(CurrentLocation, diag::err_defining_default_ctor)
+ Diag(CurrentLocation, diag::err_defining_default_ctor)
<< Context.getTagDeclType(ClassDecl) << 0 <<
Context.getTagDeclType(FieldClassDecl);
- Diag(FieldClassDecl->getLocation(), diag::note_previous_class_decl)
+ Diag(FieldClassDecl->getLocation(), diag::note_previous_class_decl)
<< Context.getTagDeclType(FieldClassDecl);
err = true;
}
}
} else if (FieldType->isReferenceType()) {
- Diag(CurrentLocation, diag::err_unintialized_member)
+ Diag(CurrentLocation, diag::err_unintialized_member)
<< Context.getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
Diag((*Field)->getLocation(), diag::note_declared_at);
err = true;
} else if (FieldType.isConstQualified()) {
- Diag(CurrentLocation, diag::err_unintialized_member)
+ Diag(CurrentLocation, diag::err_unintialized_member)
<< Context.getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
Diag((*Field)->getLocation(), diag::note_declared_at);
err = true;
@@ -2637,12 +2636,12 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
CXXDestructorDecl *Destructor) {
assert((Destructor->isImplicit() && !Destructor->isUsed()) &&
"DefineImplicitDestructor - call it for implicit default dtor");
-
+
CXXRecordDecl *ClassDecl
= cast<CXXRecordDecl>(Destructor->getDeclContext());
assert(ClassDecl && "DefineImplicitDestructor - invalid destructor");
// C++ [class.dtor] p5
- // Before the implicitly-declared default destructor for a class is
+ // Before the implicitly-declared default destructor for a class is
// implicitly defined, all the implicitly-declared default destructors
// for its base class and its non-static data members shall have been
// implicitly defined.
@@ -2651,15 +2650,15 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (!BaseClassDecl->hasTrivialDestructor()) {
- if (CXXDestructorDecl *BaseDtor =
+ if (CXXDestructorDecl *BaseDtor =
const_cast<CXXDestructorDecl*>(BaseClassDecl->getDestructor(Context)))
MarkDeclarationReferenced(CurrentLocation, BaseDtor);
else
- assert(false &&
+ assert(false &&
"DefineImplicitDestructor - missing dtor in a base class");
}
}
-
+
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
E = ClassDecl->field_end(); Field != E; ++Field) {
QualType FieldType = Context.getCanonicalType((*Field)->getType());
@@ -2669,12 +2668,12 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (!FieldClassDecl->hasTrivialDestructor()) {
- if (CXXDestructorDecl *FieldDtor =
+ if (CXXDestructorDecl *FieldDtor =
const_cast<CXXDestructorDecl*>(
FieldClassDecl->getDestructor(Context)))
MarkDeclarationReferenced(CurrentLocation, FieldDtor);
else
- assert(false &&
+ assert(false &&
"DefineImplicitDestructor - missing dtor in class of a data member");
}
}
@@ -2688,10 +2687,10 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
MethodDecl->getOverloadedOperator() == OO_Equal &&
!MethodDecl->isUsed()) &&
"DefineImplicitOverloadedAssign - call it for implicit assignment op");
-
+
CXXRecordDecl *ClassDecl
= cast<CXXRecordDecl>(MethodDecl->getDeclContext());
-
+
// C++[class.copy] p12
// Before the implicitly-declared copy assignment operator for a class is
// implicitly defined, all implicitly-declared copy assignment operators
@@ -2702,7 +2701,7 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
E = ClassDecl->bases_end(); Base != E; ++Base) {
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (CXXMethodDecl *BaseAssignOpMethod =
+ if (CXXMethodDecl *BaseAssignOpMethod =
getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl))
MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod);
}
@@ -2714,17 +2713,17 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- if (CXXMethodDecl *FieldAssignOpMethod =
+ if (CXXMethodDecl *FieldAssignOpMethod =
getAssignOperatorMethod(MethodDecl->getParamDecl(0), FieldClassDecl))
MarkDeclarationReferenced(CurrentLocation, FieldAssignOpMethod);
} else if (FieldType->isReferenceType()) {
- Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
+ Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
<< Context.getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
Diag(Field->getLocation(), diag::note_declared_at);
Diag(CurrentLocation, diag::note_first_required_here);
err = true;
} else if (FieldType.isConstQualified()) {
- Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
+ Diag(ClassDecl->getLocation(), diag::err_uninitialized_member_for_assign)
<< Context.getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
Diag(Field->getLocation(), diag::note_declared_at);
Diag(CurrentLocation, diag::note_first_required_here);
@@ -2732,7 +2731,7 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation,
}
}
if (!err)
- MethodDecl->setUsed();
+ MethodDecl->setUsed();
}
CXXMethodDecl *
@@ -2741,24 +2740,24 @@ Sema::getAssignOperatorMethod(ParmVarDecl *ParmDecl,
QualType LHSType = Context.getTypeDeclType(ClassDecl);
QualType RHSType(LHSType);
// If class's assignment operator argument is const/volatile qualified,
- // look for operator = (const/volatile B&). Otherwise, look for
+ // look for operator = (const/volatile B&). Otherwise, look for
// operator = (B&).
if (ParmDecl->getType().isConstQualified())
RHSType.addConst();
if (ParmDecl->getType().isVolatileQualified())
RHSType.addVolatile();
- ExprOwningPtr<Expr> LHS(this, new (Context) DeclRefExpr(ParmDecl,
- LHSType,
+ ExprOwningPtr<Expr> LHS(this, new (Context) DeclRefExpr(ParmDecl,
+ LHSType,
SourceLocation()));
- ExprOwningPtr<Expr> RHS(this, new (Context) DeclRefExpr(ParmDecl,
- RHSType,
+ ExprOwningPtr<Expr> RHS(this, new (Context) DeclRefExpr(ParmDecl,
+ RHSType,
SourceLocation()));
Expr *Args[2] = { &*LHS, &*RHS };
OverloadCandidateSet CandidateSet;
- AddMemberOperatorCandidates(clang::OO_Equal, SourceLocation(), Args, 2,
+ AddMemberOperatorCandidates(clang::OO_Equal, SourceLocation(), Args, 2,
CandidateSet);
OverloadCandidateSet::iterator Best;
- if (BestViableFunction(CandidateSet,
+ if (BestViableFunction(CandidateSet,
ClassDecl->getLocation(), Best) == OR_Success)
return cast<CXXMethodDecl>(Best->Function);
assert(false &&
@@ -2769,16 +2768,16 @@ Sema::getAssignOperatorMethod(ParmVarDecl *ParmDecl,
void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
CXXConstructorDecl *CopyConstructor,
unsigned TypeQuals) {
- assert((CopyConstructor->isImplicit() &&
+ assert((CopyConstructor->isImplicit() &&
CopyConstructor->isCopyConstructor(Context, TypeQuals) &&
!CopyConstructor->isUsed()) &&
"DefineImplicitCopyConstructor - call it for implicit copy ctor");
-
+
CXXRecordDecl *ClassDecl
= cast<CXXRecordDecl>(CopyConstructor->getDeclContext());
assert(ClassDecl && "DefineImplicitCopyConstructor - invalid constructor");
// C++ [class.copy] p209
- // Before the implicitly-declared copy constructor for a class is
+ // Before the implicitly-declared copy constructor for a class is
// implicitly defined, all the implicitly-declared copy constructors
// for its base class and its non-static data members shall have been
// implicitly defined.
@@ -2786,7 +2785,7 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
Base != ClassDecl->bases_end(); ++Base) {
CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (CXXConstructorDecl *BaseCopyCtor =
+ if (CXXConstructorDecl *BaseCopyCtor =
BaseClassDecl->getCopyConstructor(Context, TypeQuals))
MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
}
@@ -2799,7 +2798,7 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
- if (CXXConstructorDecl *FieldCopyCtor =
+ if (CXXConstructorDecl *FieldCopyCtor =
FieldClassDecl->getCopyConstructor(Context, TypeQuals))
MarkDeclarationReferenced(CurrentLocation, FieldCopyCtor);
}
@@ -2809,28 +2808,28 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
Sema::OwningExprResult
Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
- CXXConstructorDecl *Constructor,
+ CXXConstructorDecl *Constructor,
MultiExprArg ExprArgs) {
bool Elidable = false;
-
+
// [class.copy]p15:
- // Whenever a temporary class object is copied using a copy constructor, and
- // this object and the copy have the same cv-unqualified type, an
+ // Whenever a temporary class object is copied using a copy constructor, and
+ // this object and the copy have the same cv-unqualified type, an
// implementation is permitted to treat the original and the copy as two
// different ways of referring to the same object and not perform a copy at
//all, even if the class copy constructor or destructor have side effects.
-
+
// FIXME: Is this enough?
if (Constructor->isCopyConstructor(Context) && ExprArgs.size() == 1) {
Expr *E = ((Expr **)ExprArgs.get())[0];
while (CXXBindTemporaryExpr *BE = dyn_cast<CXXBindTemporaryExpr>(E))
E = BE->getSubExpr();
-
+
if (isa<CallExpr>(E) || isa<CXXTemporaryObjectExpr>(E))
Elidable = true;
}
-
- return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
+
+ return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
Elidable, move(ExprArgs));
}
@@ -2839,52 +2838,52 @@ CheckConstructArgumentTypes(Sema &SemaRef, SourceLocation ConstructLoc,
CXXConstructExpr *E) {
CXXConstructorDecl *Ctor = E->getConstructor();
const FunctionProtoType *Proto = Ctor->getType()->getAsFunctionProtoType();
-
+
unsigned NumArgs = E->getNumArgs();
unsigned NumArgsInProto = Proto->getNumArgs();
unsigned NumRequiredArgs = Ctor->getMinRequiredArguments();
-
+
for (unsigned i = 0; i != NumArgsInProto; ++i) {
QualType ProtoArgType = Proto->getArgType(i);
Expr *Arg;
-
+
if (i < NumRequiredArgs) {
Arg = E->getArg(i);
-
+
// Pass the argument.
// FIXME: Do this.
} else {
// Build a default argument.
ParmVarDecl *Param = Ctor->getParamDecl(i);
-
- Sema::OwningExprResult ArgExpr =
+
+ Sema::OwningExprResult ArgExpr =
SemaRef.BuildCXXDefaultArgExpr(ConstructLoc, Ctor, Param);
if (ArgExpr.isInvalid())
return true;
Arg = ArgExpr.takeAs<Expr>();
}
-
+
E->setArg(i, Arg);
}
// If this is a variadic call, handle args passed through "...".
if (Proto->isVariadic()) {
bool Invalid = false;
-
+
// Promote the arguments (C99 6.5.2.2p7).
for (unsigned i = NumArgsInProto; i != NumArgs; i++) {
Expr *Arg = E->getArg(i);
- Invalid |=
- SemaRef.DefaultVariadicArgumentPromotion(Arg,
+ Invalid |=
+ SemaRef.DefaultVariadicArgumentPromotion(Arg,
Sema::VariadicConstructor);
E->setArg(i, Arg);
}
-
+
return Invalid;
}
-
+
return false;
}
@@ -2896,15 +2895,15 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
MultiExprArg ExprArgs) {
unsigned NumExprs = ExprArgs.size();
Expr **Exprs = (Expr **)ExprArgs.release();
-
- ExprOwningPtr<CXXConstructExpr> Temp(this,
- CXXConstructExpr::Create(Context,
- DeclInitType,
- Constructor,
+
+ ExprOwningPtr<CXXConstructExpr> Temp(this,
+ CXXConstructExpr::Create(Context,
+ DeclInitType,
+ Constructor,
Elidable,
Exprs,
NumExprs));
-
+
if (CheckConstructArgumentTypes(*this, ConstructLoc, Temp.get()))
return ExprError();
@@ -2912,16 +2911,16 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
}
Sema::OwningExprResult
-Sema::BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Constructor,
- QualType Ty,
- SourceLocation TyBeginLoc,
+Sema::BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Constructor,
+ QualType Ty,
+ SourceLocation TyBeginLoc,
MultiExprArg Args,
SourceLocation RParenLoc) {
- CXXTemporaryObjectExpr *E
- = new (Context) CXXTemporaryObjectExpr(Context, Constructor, Ty, TyBeginLoc,
+ CXXTemporaryObjectExpr *E
+ = new (Context) CXXTemporaryObjectExpr(Context, Constructor, Ty, TyBeginLoc,
(Expr **)Args.get(),
Args.size(), RParenLoc);
-
+
ExprOwningPtr<CXXTemporaryObjectExpr> Temp(this, E);
if (CheckConstructArgumentTypes(*this, TyBeginLoc, Temp.get()))
@@ -2931,35 +2930,34 @@ Sema::BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Constructor,
}
-bool Sema::InitializeVarWithConstructor(VarDecl *VD,
+bool Sema::InitializeVarWithConstructor(VarDecl *VD,
CXXConstructorDecl *Constructor,
- QualType DeclInitType,
+ QualType DeclInitType,
MultiExprArg Exprs) {
- OwningExprResult TempResult =
- BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor,
+ OwningExprResult TempResult =
+ BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor,
move(Exprs));
if (TempResult.isInvalid())
return true;
-
+
Expr *Temp = TempResult.takeAs<Expr>();
MarkDeclarationReferenced(VD->getLocation(), Constructor);
Temp = MaybeCreateCXXExprWithTemporaries(Temp, /*DestroyTemps=*/true);
VD->setInit(Context, Temp);
-
+
return false;
}
-void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType)
-{
+void Sema::FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType) {
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(
DeclInitType->getAs<RecordType>()->getDecl());
if (!ClassDecl->hasTrivialDestructor())
- if (CXXDestructorDecl *Destructor =
+ if (CXXDestructorDecl *Destructor =
const_cast<CXXDestructorDecl*>(ClassDecl->getDestructor(Context)))
MarkDeclarationReferenced(VD->getLocation(), Destructor);
}
-/// AddCXXDirectInitializerToDecl - This action is called immediately after
+/// AddCXXDirectInitializerToDecl - This action is called immediately after
/// ActOnDeclarator, when a C++ direct initializer is present.
/// e.g: "int x(1);"
void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
@@ -2975,7 +2973,7 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
// the initializer.
if (RealDecl == 0)
return;
-
+
VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
if (!VDecl) {
Diag(RealDecl->getLocation(), diag::err_illegal_initializer);
@@ -3000,16 +2998,16 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
Expr::hasAnyTypeDependentArguments((Expr **)Exprs.get(), Exprs.size())) {
// Let clients know that initialization was done with a direct initializer.
VDecl->setCXXDirectInitializer(true);
-
+
// Store the initialization expressions as a ParenListExpr.
unsigned NumExprs = Exprs.size();
- VDecl->setInit(Context,
+ VDecl->setInit(Context,
new (Context) ParenListExpr(Context, LParenLoc,
(Expr **)Exprs.release(),
NumExprs, RParenLoc));
return;
}
-
+
// C++ 8.5p11:
// The form of initialization (using parentheses or '=') is generally
@@ -3039,7 +3037,7 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
RealDecl->setInvalidDecl();
else {
VDecl->setCXXDirectInitializer(true);
- if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
+ if (InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
move(Exprs)))
RealDecl->setInvalidDecl();
FinalizeVarWithDestructor(VDecl, DeclInitType);
@@ -3086,7 +3084,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
const RecordType *ClassRec = ClassType->getAs<RecordType>();
assert(ClassRec && "Can only initialize a class type here");
- // C++ [dcl.init]p14:
+ // C++ [dcl.init]p14:
//
// If the initialization is direct-initialization, or if it is
// copy-initialization where the cv-unqualified version of the
@@ -3102,7 +3100,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
OverloadCandidateSet CandidateSet;
// Add constructors to the overload set.
- DeclarationName ConstructorName
+ DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType.getUnqualifiedType()));
DeclContext::lookup_const_iterator Con, ConEnd;
@@ -3112,17 +3110,17 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
CXXConstructorDecl *Constructor = 0;
FunctionTemplateDecl *ConstructorTmpl= dyn_cast<FunctionTemplateDecl>(*Con);
if (ConstructorTmpl)
- Constructor
+ Constructor
= cast<CXXConstructorDecl>(ConstructorTmpl->getTemplatedDecl());
else
Constructor = cast<CXXConstructorDecl>(*Con);
if ((Kind == IK_Direct) ||
- (Kind == IK_Copy &&
+ (Kind == IK_Copy &&
Constructor->isConvertingConstructor(/*AllowExplicit=*/false)) ||
(Kind == IK_Default && Constructor->isDefaultConstructor())) {
if (ConstructorTmpl)
- AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0,
+ AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0,
Args, NumArgs, CandidateSet);
else
AddOverloadCandidate(Constructor, Args, NumArgs, CandidateSet);
@@ -3137,7 +3135,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
case OR_Success:
// We found a constructor. Return it.
return cast<CXXConstructorDecl>(Best->Function);
-
+
case OR_No_Viable_Function:
if (InitEntity)
Diag(Loc, diag::err_ovl_no_viable_function_in_init)
@@ -3147,7 +3145,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
<< ClassType << Range;
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
return 0;
-
+
case OR_Ambiguous:
if (InitEntity)
Diag(Loc, diag::err_ovl_ambiguous_init) << InitEntity << Range;
@@ -3168,7 +3166,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
return 0;
}
-
+
return 0;
}
@@ -3179,8 +3177,8 @@ Sema::PerformInitializationByConstructor(QualType ClassType,
/// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
/// type, and the first type (T1) is the pointee type of the reference
/// type being initialized.
-Sema::ReferenceCompareResult
-Sema::CompareReferenceRelationship(QualType T1, QualType T2,
+Sema::ReferenceCompareResult
+Sema::CompareReferenceRelationship(QualType T1, QualType T2,
bool& DerivedToBase) {
assert(!T1->isReferenceType() &&
"T1 must be the pointee type of the reference type");
@@ -3193,7 +3191,7 @@ Sema::CompareReferenceRelationship(QualType T1, QualType T2,
// C++ [dcl.init.ref]p4:
// Given types "cv1 T1" and "cv2 T2," "cv1 T1" is
- // reference-related to "cv2 T2" if T1 is the same type as T2, or
+ // reference-related to "cv2 T2" if T1 is the same type as T2, or
// T1 is a base class of T2.
if (UnqualT1 == UnqualT2)
DerivedToBase = false;
@@ -3236,7 +3234,7 @@ Sema::CompareReferenceRelationship(QualType T1, QualType T2,
/// When @p AllowExplicit, we also permit explicit user-defined
/// conversion functions.
/// When @p ForceRValue, we unconditionally treat the initializer as an rvalue.
-bool
+bool
Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
bool SuppressUserConversions,
bool AllowExplicit, bool ForceRValue,
@@ -3250,7 +3248,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// to resolve the overloaded function. If all goes well, T2 is the
// type of the resulting function.
if (Context.getCanonicalType(T2) == Context.OverloadTy) {
- FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Init, DeclType,
+ FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Init, DeclType,
ICS != 0);
if (Fn) {
// Since we're performing this reference-initialization for
@@ -3271,7 +3269,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
bool DerivedToBase = false;
Expr::isLvalueResult InitLvalue = ForceRValue ? Expr::LV_InvalidExpression :
Init->isLvalue(Context);
- ReferenceCompareResult RefRelationship
+ ReferenceCompareResult RefRelationship
= CompareReferenceRelationship(T1, T2, DerivedToBase);
// Most paths end in a failed conversion.
@@ -3334,7 +3332,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// Perform the conversion.
// FIXME: Binding to a subobject of the lvalue is going to require more
// AST annotation than this.
- ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);
+ ImpCastExprToType(Init, T1, CastExpr::CK_Unknown, /*isLvalue=*/true);
}
}
@@ -3347,16 +3345,16 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
if (!isRValRef && !SuppressUserConversions && T2->isRecordType() &&
!RequireCompleteType(SourceLocation(), T2, 0)) {
// FIXME: Look for conversions in base classes!
- CXXRecordDecl *T2RecordDecl
+ CXXRecordDecl *T2RecordDecl
= dyn_cast<CXXRecordDecl>(T2->getAs<RecordType>()->getDecl());
OverloadCandidateSet CandidateSet;
- OverloadedFunctionDecl *Conversions
+ OverloadedFunctionDecl *Conversions
= T2RecordDecl->getConversionFunctions();
- for (OverloadedFunctionDecl::function_iterator Func
+ for (OverloadedFunctionDecl::function_iterator Func
= Conversions->function_begin();
Func != Conversions->function_end(); ++Func) {
- FunctionTemplateDecl *ConvTemplate
+ FunctionTemplateDecl *ConvTemplate
= dyn_cast<FunctionTemplateDecl>(*Func);
CXXConversionDecl *Conv;
if (ConvTemplate)
@@ -3369,7 +3367,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
if (Conv->getConversionType()->isLValueReferenceType() &&
(AllowExplicit || !Conv->isExplicit())) {
if (ConvTemplate)
- AddTemplateConversionCandidate(ConvTemplate, Init, DeclType,
+ AddTemplateConversionCandidate(ConvTemplate, Init, DeclType,
CandidateSet);
else
AddConversionCandidate(Conv, Init, DeclType, CandidateSet);
@@ -3412,7 +3410,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
case OR_Ambiguous:
assert(false && "Ambiguous reference binding conversions not implemented.");
return true;
-
+
case OR_No_Viable_Function:
case OR_Deleted:
// There was no suitable conversion, or we found a deleted
@@ -3420,7 +3418,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
break;
}
}
-
+
if (BindsDirectly) {
// C++ [dcl.init.ref]p4:
// [...] In all cases where the reference-related or
@@ -3434,8 +3432,8 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// complain about errors, because we should not be checking for
// ambiguity (or inaccessibility) unless the reference binding
// actually happens.
- if (DerivedToBase)
- return CheckDerivedToBaseConversion(T2, T1,
+ if (DerivedToBase)
+ return CheckDerivedToBaseConversion(T2, T1,
Init->getSourceRange().getBegin(),
Init->getSourceRange());
else
@@ -3535,7 +3533,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
// Actually try to convert the initializer to T1.
if (ICS) {
// C++ [over.ics.ref]p2:
- //
+ //
// When a parameter of reference type is not bound directly to
// an argument expression, the conversion sequence is the one
// required to convert the argument expression to the
@@ -3549,12 +3547,12 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
/*AllowExplicit=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
-
+
// Of course, that's still a reference binding.
if (ICS->ConversionKind == ImplicitConversionSequence::StandardConversion) {
ICS->Standard.ReferenceBinding = true;
ICS->Standard.RRefBinding = isRValRef;
- } else if(ICS->ConversionKind ==
+ } else if (ICS->ConversionKind ==
ImplicitConversionSequence::UserDefinedConversion) {
ICS->UserDefined.After.ReferenceBinding = true;
ICS->UserDefined.After.RRefBinding = isRValRef;
@@ -3574,7 +3572,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
OverloadedOperatorKind Op = FnDecl->getOverloadedOperator();
- // C++ [over.oper]p5:
+ // C++ [over.oper]p5:
// The allocation and deallocation functions, operator new,
// operator new[], operator delete and operator delete[], are
// described completely in 3.7.3. The attributes and restrictions
@@ -3617,13 +3615,13 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
// An operator function cannot have default arguments (8.3.6),
// except where explicitly stated below.
//
- // Only the function-call operator allows default arguments
+ // Only the function-call operator allows default arguments
// (C++ [over.call]p1).
if (Op != OO_Call) {
for (FunctionDecl::param_iterator Param = FnDecl->param_begin();
Param != FnDecl->param_end(); ++Param) {
if ((*Param)->hasUnparsedDefaultArg())
- return Diag((*Param)->getLocation(),
+ return Diag((*Param)->getLocation(),
diag::err_operator_overload_default_arg)
<< FnDecl->getDeclName();
else if (Expr *DefArg = (*Param)->getDefaultArg())
@@ -3648,7 +3646,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
// [...] Operator functions cannot have more or fewer parameters
// than the number required for the corresponding operator, as
// described in the rest of this subclause.
- unsigned NumParams = FnDecl->getNumParams()
+ unsigned NumParams = FnDecl->getNumParams()
+ (isa<CXXMethodDecl>(FnDecl)? 1 : 0);
if (Op != OO_Call &&
((NumParams == 1 && !CanBeUnaryOperator) ||
@@ -3702,7 +3700,7 @@ bool Sema::CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl) {
if (!ParamIsInt)
return Diag(LastParam->getLocation(),
- diag::err_operator_overload_post_incdec_must_be_int)
+ diag::err_operator_overload_post_incdec_must_be_int)
<< LastParam->getType() << (Op == OO_MinusMinus);
}
@@ -3741,11 +3739,11 @@ Sema::DeclPtrTy Sema::ActOnStartLinkageSpecification(Scope *S,
Diag(LangLoc, diag::err_bad_language);
return DeclPtrTy();
}
-
+
// FIXME: Add all the various semantics of linkage specifications
-
+
LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
- LangLoc, Language,
+ LangLoc, Language,
LBraceLoc.isValid());
CurContext->addDecl(D);
PushDeclContext(S, D);
@@ -3784,7 +3782,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
// The exception-declaration shall not denote a pointer or reference to an
// incomplete type, other than [cv] void*.
// N2844 forbids rvalue references.
- if(!ExDeclType->isDependentType() && ExDeclType->isRValueReferenceType()) {
+ if (!ExDeclType->isDependentType() && ExDeclType->isRValueReferenceType()) {
Diag(Loc, diag::err_catch_rvalue_ref) << Range;
Invalid = true;
}
@@ -3796,7 +3794,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
BaseType = Ptr->getPointeeType();
Mode = 1;
DK = diag::err_catch_incomplete_ptr;
- } else if(const ReferenceType *Ref = BaseType->getAs<ReferenceType>()) {
+ } else if (const ReferenceType *Ref = BaseType->getAs<ReferenceType>()) {
// For the purpose of error recovery, we treat rvalue refs like lvalue refs.
BaseType = Ref->getPointeeType();
Mode = 2;
@@ -3806,7 +3804,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
!BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
Invalid = true;
- if (!Invalid && !ExDeclType->isDependentType() &&
+ if (!Invalid && !ExDeclType->isDependentType() &&
RequireNonAbstractType(Loc, ExDeclType,
diag::err_abstract_type_in_decl,
AbstractVariableType))
@@ -3817,7 +3815,7 @@ VarDecl *Sema::BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
// FIXME: Need to check for abstract classes.
- VarDecl *ExDecl = VarDecl::Create(Context, CurContext, Loc,
+ VarDecl *ExDecl = VarDecl::Create(Context, CurContext, Loc,
Name, ExDeclType, DInfo, VarDecl::None);
if (Invalid)
@@ -3857,7 +3855,7 @@ Sema::DeclPtrTy Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
if (Invalid)
ExDecl->setInvalidDecl();
-
+
// Add the exception declaration into this scope.
if (II)
PushOnScopeChains(ExDecl, S);
@@ -3868,11 +3866,11 @@ Sema::DeclPtrTy Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
return DeclPtrTy::make(ExDecl);
}
-Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
+Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
ExprArg assertexpr,
ExprArg assertmessageexpr) {
Expr *AssertExpr = (Expr *)assertexpr.get();
- StringLiteral *AssertMessage =
+ StringLiteral *AssertMessage =
cast<StringLiteral>((Expr *)assertmessageexpr.get());
if (!AssertExpr->isTypeDependent() && !AssertExpr->isValueDependent()) {
@@ -3884,18 +3882,18 @@ Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
}
if (Value == 0) {
- std::string str(AssertMessage->getStrData(),
+ std::string str(AssertMessage->getStrData(),
AssertMessage->getByteLength());
- Diag(AssertLoc, diag::err_static_assert_failed)
+ Diag(AssertLoc, diag::err_static_assert_failed)
<< str << AssertExpr->getSourceRange();
}
}
-
+
assertexpr.release();
assertmessageexpr.release();
- Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc,
+ Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc,
AssertExpr, AssertMessage);
-
+
CurContext->addDecl(Decl);
return DeclPtrTy::make(Decl);
}
@@ -3944,7 +3942,7 @@ Sema::DeclPtrTy Sema::ActOnFriendTypeDecl(Scope *S,
}else {
Diag(DS.getFriendSpecLoc(), diag::err_unexpected_friend)
<< DS.getSourceRange();
- return DeclPtrTy();
+ return DeclPtrTy();
}
}
@@ -4160,7 +4158,7 @@ Sema::DeclPtrTy Sema::ActOnFriendFunctionDecl(Scope *S,
// Add the function declaration to the appropriate lookup tables,
// adjusting the redeclarations list as necessary. We don't
// want to do this yet if the friending class is dependent.
- //
+ //
// Also update the scope-based lookup if the target context's
// lookup context is in lexical scope.
if (!CurContext->isDependentContext()) {
@@ -4181,7 +4179,7 @@ Sema::DeclPtrTy Sema::ActOnFriendFunctionDecl(Scope *S,
void Sema::SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc) {
AdjustDeclIfTemplate(dcl);
-
+
Decl *Dcl = dcl.getAs<Decl>();
FunctionDecl *Fn = dyn_cast<FunctionDecl>(Dcl);
if (!Fn) {
@@ -4218,7 +4216,7 @@ void Sema::DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock) {
}
}
-bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
+bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
const CXXMethodDecl *Old) {
QualType NewTy = New->getType()->getAsFunctionType()->getResultType();
QualType OldTy = Old->getType()->getAsFunctionType()->getResultType();
@@ -4226,13 +4224,13 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
QualType CNewTy = Context.getCanonicalType(NewTy);
QualType COldTy = Context.getCanonicalType(OldTy);
- if (CNewTy == COldTy &&
+ if (CNewTy == COldTy &&
CNewTy.getCVRQualifiers() == COldTy.getCVRQualifiers())
return false;
-
+
// Check if the return types are covariant
QualType NewClassTy, OldClassTy;
-
+
/// Both types must be pointers or references to classes.
if (PointerType *NewPT = dyn_cast<PointerType>(NewTy)) {
if (PointerType *OldPT = dyn_cast<PointerType>(OldTy)) {
@@ -4245,14 +4243,14 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
OldClassTy = OldRT->getPointeeType();
}
}
-
+
// The return types aren't either both pointers or references to a class type.
if (NewClassTy.isNull()) {
- Diag(New->getLocation(),
+ Diag(New->getLocation(),
diag::err_different_return_type_for_overriding_virtual_function)
<< New->getDeclName() << NewTy << OldTy;
Diag(Old->getLocation(), diag::note_overridden_virtual_function);
-
+
return true;
}
@@ -4265,9 +4263,9 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
Diag(Old->getLocation(), diag::note_overridden_virtual_function);
return true;
}
-
+
// Check if we the conversion from derived to base is valid.
- if (CheckDerivedToBaseConversion(NewClassTy, OldClassTy,
+ if (CheckDerivedToBaseConversion(NewClassTy, OldClassTy,
diag::err_covariant_return_inaccessible_base,
diag::err_covariant_return_ambiguous_derived_to_base_conv,
// FIXME: Should this point to the return type?
@@ -4276,7 +4274,7 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
return true;
}
}
-
+
// The qualifiers of the return types must be the same.
if (CNewTy.getCVRQualifiers() != COldTy.getCVRQualifiers()) {
Diag(New->getLocation(),
@@ -4285,7 +4283,7 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
Diag(Old->getLocation(), diag::note_overridden_virtual_function);
return true;
};
-
+
// The new class type must have the same or less qualifiers as the old type.
if (NewClassTy.isMoreQualifiedThan(OldClassTy)) {
@@ -4295,13 +4293,12 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
Diag(Old->getLocation(), diag::note_overridden_virtual_function);
return true;
};
-
+
return false;
}
bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
- const CXXMethodDecl *Old)
-{
+ const CXXMethodDecl *Old) {
return CheckExceptionSpecSubset(diag::err_override_exception_spec,
diag::note_overridden_virtual_function,
Old->getType()->getAsFunctionProtoType(),
@@ -4317,7 +4314,7 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
/// class X.
void Sema::ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) {
AdjustDeclIfTemplate(Dcl);
-
+
Decl *D = Dcl.getAs<Decl>();
// If there is no declaration, there was an error parsing it.
if (D == 0)
@@ -4327,13 +4324,13 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) {
// int foo::bar;
if (!D->isOutOfLine())
return;
-
+
// C++ [basic.lookup.unqual]p13
//
// A name used in the definition of a static data member of class X
// (after the qualified-id of the static member) is looked up as if the name
// was used in a member function of X.
-
+
// Change current context into the context of the initializing declaration.
EnterDeclaratorContext(S, D->getDeclContext());
}
@@ -4342,7 +4339,7 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl) {
/// initializer for the declaration 'Dcl'.
void Sema::ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl) {
AdjustDeclIfTemplate(Dcl);
-
+
Decl *D = Dcl.getAs<Decl>();
// If there is no declaration, there was an error parsing it.
if (D == 0)
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 988680a981..5b52ba9c8c 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -28,7 +28,7 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
if (property->getType()->isObjCObjectPointerType())
result = CheckAssignmentConstraints(GetterMethod->getResultType(), property->getType());
if (result != Compatible) {
- Diag(Loc, diag::warn_accessor_property_type_mismatch)
+ Diag(Loc, diag::warn_accessor_property_type_mismatch)
<< property->getDeclName()
<< GetterMethod->getSelector();
Diag(GetterMethod->getLocation(), diag::note_declared_at);
@@ -43,7 +43,7 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
assert(getCurMethodDecl() == 0 && "Method parsing confused");
ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D.getAs<Decl>());
-
+
// If we don't have a valid method decl, simply return.
if (!MDecl)
return;
@@ -55,7 +55,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
AddInstanceMethodToGlobalPool(MDecl);
else
AddFactoryMethodToGlobalPool(MDecl);
-
+
// Allow all of Sema to see that we are entering a method definition.
PushDeclContext(FnBodyScope, MDecl);
@@ -64,7 +64,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, DeclPtrTy D) {
// Insert the invisible arguments, self and _cmd!
MDecl->createImplicitParams(Context, MDecl->getClassInterface());
-
+
PushOnScopeChains(MDecl->getSelfDecl(), FnBodyScope);
PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope);
@@ -82,7 +82,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
const DeclPtrTy *ProtoRefs, unsigned NumProtoRefs,
SourceLocation EndProtoLoc, AttributeList *AttrList) {
assert(ClassName && "Missing class identifier");
-
+
// Check for another declaration kind with the same name.
NamedDecl *PrevDecl = LookupName(TUScope, ClassName, LookupOrdinaryName);
if (PrevDecl && PrevDecl->isTemplateParameter()) {
@@ -96,7 +96,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
}
-
+
ObjCInterfaceDecl* IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (IDecl) {
// Class already seen. Is it a forward declaration?
@@ -113,14 +113,14 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
IDecl->setForwardDecl(false);
}
} else {
- IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtInterfaceLoc,
+ IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtInterfaceLoc,
ClassName, ClassLoc);
if (AttrList)
ProcessDeclAttributeList(TUScope, IDecl, AttrList);
-
+
PushOnScopeChains(IDecl, TUScope);
}
-
+
if (SuperName) {
// Check if a different kind of symbol declared in this scope.
PrevDecl = LookupName(TUScope, SuperName, LookupOrdinaryName);
@@ -129,13 +129,13 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
<< SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
IDecl->setLocEnd(ClassLoc);
} else {
- ObjCInterfaceDecl *SuperClassDecl =
+ ObjCInterfaceDecl *SuperClassDecl =
dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
// Diagnose classes that inherit from deprecated classes.
if (SuperClassDecl)
(void)DiagnoseUseOfDecl(SuperClassDecl, SuperLoc);
-
+
if (PrevDecl && SuperClassDecl == 0) {
// The previous declaration was not a class decl. Check if we have a
// typedef. If we do, get the underlying class type.
@@ -146,7 +146,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
}
}
-
+
// This handles the following case:
//
// typedef int SuperClass;
@@ -157,7 +157,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
}
}
-
+
if (!dyn_cast_or_null<TypedefDecl>(PrevDecl)) {
if (!SuperClassDecl)
Diag(SuperLoc, diag::err_undef_superclass)
@@ -174,14 +174,14 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
} else { // we have a root class.
IDecl->setLocEnd(ClassLoc);
}
-
+
/// Check then save referenced protocols.
if (NumProtoRefs) {
IDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,
Context);
IDecl->setLocEnd(EndProtoLoc);
}
-
+
CheckObjCDeclScope(IDecl);
return DeclPtrTy::make(IDecl);
}
@@ -189,7 +189,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
/// ActOnCompatiblityAlias - this action is called after complete parsing of
/// @compatibility_alias declaration. It sets up the alias relationships.
Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
- IdentifierInfo *AliasName,
+ IdentifierInfo *AliasName,
SourceLocation AliasLocation,
IdentifierInfo *ClassName,
SourceLocation ClassLocation) {
@@ -221,11 +221,11 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
Diag(CDeclU->getLocation(), diag::note_previous_declaration);
return DeclPtrTy();
}
-
+
// Everything checked out, instantiate a new alias declaration AST.
- ObjCCompatibleAliasDecl *AliasDecl =
+ ObjCCompatibleAliasDecl *AliasDecl =
ObjCCompatibleAliasDecl::Create(Context, CurContext, AtLoc, AliasName, CDecl);
-
+
if (!CheckObjCDeclScope(AliasDecl))
PushOnScopeChains(AliasDecl, TUScope);
@@ -235,17 +235,16 @@ Sema::DeclPtrTy Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
void Sema::CheckForwardProtocolDeclarationForCircularDependency(
IdentifierInfo *PName,
SourceLocation &Ploc, SourceLocation PrevLoc,
- const ObjCList<ObjCProtocolDecl> &PList)
-{
+ const ObjCList<ObjCProtocolDecl> &PList) {
for (ObjCList<ObjCProtocolDecl>::iterator I = PList.begin(),
E = PList.end(); I != E; ++I) {
-
+
if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier())) {
if (PDecl->getIdentifier() == PName) {
Diag(Ploc, diag::err_protocol_has_circular_dependency);
Diag(PrevLoc, diag::note_previous_definition);
}
- CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc,
+ CheckForwardProtocolDeclarationForCircularDependency(PName, Ploc,
PDecl->getLocation(), PDecl->getReferencedProtocols());
}
}
@@ -272,16 +271,16 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
return DeclPtrTy::make(PDecl);
}
ObjCList<ObjCProtocolDecl> PList;
- PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
+ PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
CheckForwardProtocolDeclarationForCircularDependency(
ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
PList.Destroy(Context);
-
+
// Make sure the cached decl gets a valid start location.
PDecl->setLocation(AtProtoInterfaceLoc);
PDecl->setForwardDecl(false);
} else {
- PDecl = ObjCProtocolDecl::Create(Context, CurContext,
+ PDecl = ObjCProtocolDecl::Create(Context, CurContext,
AtProtoInterfaceLoc,ProtocolName);
PushOnScopeChains(PDecl, TUScope);
PDecl->setForwardDecl(false);
@@ -293,8 +292,8 @@ Sema::ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc,
PDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context);
PDecl->setLocEnd(EndProtoLoc);
}
-
- CheckObjCDeclScope(PDecl);
+
+ CheckObjCDeclScope(PDecl);
return DeclPtrTy::make(PDecl);
}
@@ -313,7 +312,7 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations,
<< ProtocolId[i].first;
continue;
}
-
+
(void)DiagnoseUseOfDecl(PDecl, ProtocolId[i].second);
// If this is a forward declaration and we are supposed to warn in this
@@ -329,12 +328,12 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations,
/// attributes and types and warns on a variety of inconsistencies.
///
void
-Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
+Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
ObjCPropertyDecl *SuperProperty,
const IdentifierInfo *inheritedName) {
- ObjCPropertyDecl::PropertyAttributeKind CAttr =
+ ObjCPropertyDecl::PropertyAttributeKind CAttr =
Property->getPropertyAttributes();
- ObjCPropertyDecl::PropertyAttributeKind SAttr =
+ ObjCPropertyDecl::PropertyAttributeKind SAttr =
SuperProperty->getPropertyAttributes();
if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly)
&& (SAttr & ObjCPropertyDecl::OBJC_PR_readwrite))
@@ -348,23 +347,23 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
!= (SAttr & ObjCPropertyDecl::OBJC_PR_retain))
Diag(Property->getLocation(), diag::warn_property_attribute)
<< Property->getDeclName() << "retain" << inheritedName;
-
+
if ((CAttr & ObjCPropertyDecl::OBJC_PR_nonatomic)
!= (SAttr & ObjCPropertyDecl::OBJC_PR_nonatomic))
Diag(Property->getLocation(), diag::warn_property_attribute)
<< Property->getDeclName() << "atomic" << inheritedName;
if (Property->getSetterName() != SuperProperty->getSetterName())
Diag(Property->getLocation(), diag::warn_property_attribute)
- << Property->getDeclName() << "setter" << inheritedName;
+ << Property->getDeclName() << "setter" << inheritedName;
if (Property->getGetterName() != SuperProperty->getGetterName())
Diag(Property->getLocation(), diag::warn_property_attribute)
<< Property->getDeclName() << "getter" << inheritedName;
- QualType LHSType =
+ QualType LHSType =
Context.getCanonicalType(SuperProperty->getType());
- QualType RHSType =
+ QualType RHSType =
Context.getCanonicalType(Property->getType());
-
+
if (!Context.typesAreCompatible(LHSType, RHSType)) {
// FIXME: Incorporate this test with typesAreCompatible.
if (LHSType->isObjCQualifiedIdType() && RHSType->isObjCQualifiedIdType())
@@ -392,7 +391,7 @@ void Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
E = IDecl->prop_end(); I != E; ++I) {
ObjCPropertyDecl *PDecl = (*I);
if (SuperPDecl->getIdentifier() == PDecl->getIdentifier())
- DiagnosePropertyMismatch(PDecl, SuperPDecl,
+ DiagnosePropertyMismatch(PDecl, SuperPDecl,
SDecl->getIdentifier());
}
}
@@ -455,7 +454,7 @@ void Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
E = MDecl->protocol_end(); P != E; ++P)
// Merge properties of category (*P) into IDECL's
MergeOneProtocolPropertiesIntoClass(CatDecl, *P);
-
+
// Go thru the list of protocols for this category and recursively merge
// their properties into this class as well.
for (ObjCCategoryDecl::protocol_iterator P = CatDecl->protocol_begin(),
@@ -475,7 +474,7 @@ void Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
E = MDecl->protocol_end(); P != E; ++P)
// Merge properties of class (*P) into IDECL's
MergeOneProtocolPropertiesIntoClass(IDecl, *P);
-
+
// Go thru the list of protocols for this class and recursively merge
// their properties into this class as well.
for (ObjCInterfaceDecl::protocol_iterator P = IDecl->protocol_begin(),
@@ -492,7 +491,7 @@ void Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
/// DiagnoseClassExtensionDupMethods - Check for duplicate declaration of
/// a class method in its extension.
///
-void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
+void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
ObjCInterfaceDecl *ID) {
if (!ID)
return; // Possibly due to previous error
@@ -525,12 +524,12 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
unsigned NumElts,
AttributeList *attrList) {
llvm::SmallVector<ObjCProtocolDecl*, 32> Protocols;
-
+
for (unsigned i = 0; i != NumElts; ++i) {
IdentifierInfo *Ident = IdentList[i].first;
ObjCProtocolDecl *PDecl = LookupProtocol(Ident);
if (PDecl == 0) { // Not already seen?
- PDecl = ObjCProtocolDecl::Create(Context, CurContext,
+ PDecl = ObjCProtocolDecl::Create(Context, CurContext,
IdentList[i].second, Ident);
PushOnScopeChains(PDecl, TUScope);
}
@@ -538,8 +537,8 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
ProcessDeclAttributeList(TUScope, PDecl, attrList);
Protocols.push_back(PDecl);
}
-
- ObjCForwardProtocolDecl *PDecl =
+
+ ObjCForwardProtocolDecl *PDecl =
ObjCForwardProtocolDecl::Create(Context, CurContext, AtProtocolLoc,
&Protocols[0], Protocols.size());
CurContext->addDecl(PDecl);
@@ -555,7 +554,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
const DeclPtrTy *ProtoRefs,
unsigned NumProtoRefs,
SourceLocation EndProtoLoc) {
- ObjCCategoryDecl *CDecl =
+ ObjCCategoryDecl *CDecl =
ObjCCategoryDecl::Create(Context, CurContext, AtInterfaceLoc, CategoryName);
// FIXME: PushOnScopeChains?
CurContext->addDecl(CDecl);
@@ -569,7 +568,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
}
CDecl->setClassInterface(IDecl);
-
+
// If the interface is deprecated, warn about it.
(void)DiagnoseUseOfDecl(IDecl, ClassLoc);
@@ -591,7 +590,7 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
CDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context);
CDecl->setLocEnd(EndProtoLoc);
}
-
+
CheckObjCDeclScope(CDecl);
return DeclPtrTy::make(CDecl);
}
@@ -617,7 +616,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
}
}
- ObjCCategoryImplDecl *CDecl =
+ ObjCCategoryImplDecl *CDecl =
ObjCCategoryImplDecl::Create(Context, CurContext, AtCatImplLoc, CatName,
IDecl);
/// Check that class of this category is already completely declared.
@@ -637,7 +636,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
} else
CatIDecl->setImplementation(CDecl);
}
-
+
CheckObjCDeclScope(CDecl);
return DeclPtrTy::make(CDecl);
}
@@ -645,7 +644,7 @@ Sema::DeclPtrTy Sema::ActOnStartCategoryImplementation(
Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
SourceLocation AtClassImplLoc,
IdentifierInfo *ClassName, SourceLocation ClassLoc,
- IdentifierInfo *SuperClassname,
+ IdentifierInfo *SuperClassname,
SourceLocation SuperClassLoc) {
ObjCInterfaceDecl* IDecl = 0;
// Check for another declaration kind with the same name.
@@ -655,13 +654,13 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
} else {
// Is there an interface declaration of this class; if not, warn!
- IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
+ IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!IDecl || IDecl->isForwardDecl()) {
Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
IDecl = 0;
}
}
-
+
// Check that super class name is valid class name
ObjCInterfaceDecl* SDecl = 0;
if (SuperClassname) {
@@ -672,7 +671,7 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
<< SuperClassname;
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
} else {
- SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
+ SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!SDecl)
Diag(SuperClassLoc, diag::err_undef_superclass)
<< SuperClassname << ClassName;
@@ -685,14 +684,14 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
}
}
}
-
+
if (!IDecl) {
// Legacy case of @implementation with no corresponding @interface.
// Build, chain & install the interface decl into the identifier.
// FIXME: Do we support attributes on the @implementation? If so we should
// copy them over.
- IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassImplLoc,
+ IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassImplLoc,
ClassName, ClassLoc, false, true);
IDecl->setSuperClass(SDecl);
IDecl->setLocEnd(ClassLoc);
@@ -704,14 +703,14 @@ Sema::DeclPtrTy Sema::ActOnStartClassImplementation(
// declaration; the user cannot reopen it.
IDecl->setForwardDecl(false);
}
-
- ObjCImplementationDecl* IMPDecl =
- ObjCImplementationDecl::Create(Context, CurContext, AtClassImplLoc,
+
+ ObjCImplementationDecl* IMPDecl =
+ ObjCImplementationDecl::Create(Context, CurContext, AtClassImplLoc,
IDecl, SDecl);
-
+
if (CheckObjCDeclScope(IMPDecl))
return DeclPtrTy::make(IMPDecl);
-
+
// Check that there is no duplicate implementation of this class.
if (IDecl->getImplementation()) {
// FIXME: Don't leak everything!
@@ -743,21 +742,21 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
// If implementation has empty ivar list, just return.
if (numIvars == 0)
return;
-
+
assert(ivars && "missing @implementation ivars");
-
+
// Check interface's Ivar list against those in the implementation.
// names and types must match.
//
unsigned j = 0;
- ObjCInterfaceDecl::ivar_iterator
+ ObjCInterfaceDecl::ivar_iterator
IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end();
for (; numIvars > 0 && IVI != IVE; ++IVI) {
ObjCIvarDecl* ImplIvar = ivars[j++];
ObjCIvarDecl* ClsIvar = *IVI;
assert (ImplIvar && "missing implementation ivar");
assert (ClsIvar && "missing class ivar");
-
+
// First, make sure the types match.
if (Context.getCanonicalType(ImplIvar->getType()) !=
Context.getCanonicalType(ClsIvar->getType())) {
@@ -774,7 +773,7 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
<< ImplIvar->getIdentifier();
Diag(ClsBitWidth->getLocStart(), diag::note_previous_definition);
}
- }
+ }
// Make sure the names are identical.
if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) {
Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name)
@@ -783,7 +782,7 @@ void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
}
--numIvars;
}
-
+
if (numIvars > 0)
Diag(ivars[j]->getLocation(), diag::err_inconsistant_ivar_count);
else if (IVI != IVE)
@@ -805,21 +804,21 @@ void Sema::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
ImpMethodDecl->getResultType()) &&
!Context.QualifiedIdConformsQualifiedId(IntfMethodDecl->getResultType(),
ImpMethodDecl->getResultType())) {
- Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_ret_types)
+ Diag(ImpMethodDecl->getLocation(), diag::warn_conflicting_ret_types)
<< ImpMethodDecl->getDeclName() << IntfMethodDecl->getResultType()
<< ImpMethodDecl->getResultType();
Diag(IntfMethodDecl->getLocation(), diag::note_previous_definition);
}
-
+
for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(),
IF = IntfMethodDecl->param_begin(), EM = ImpMethodDecl->param_end();
IM != EM; ++IM, ++IF) {
if (Context.typesAreCompatible((*IF)->getType(), (*IM)->getType()) ||
- Context.QualifiedIdConformsQualifiedId((*IF)->getType(),
+ Context.QualifiedIdConformsQualifiedId((*IF)->getType(),
(*IM)->getType()))
continue;
-
- Diag((*IM)->getLocation(), diag::warn_conflicting_param_types)
+
+ Diag((*IM)->getLocation(), diag::warn_conflicting_param_types)
<< ImpMethodDecl->getDeclName() << (*IF)->getType()
<< (*IM)->getType();
Diag((*IF)->getLocation(), diag::note_previous_definition);
@@ -834,34 +833,34 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl,
// by far the most common case.
if (!PDecl->isReadOnly())
return false;
- // Even if property is ready only, if interface has a user defined setter,
+ // Even if property is ready only, if interface has a user defined setter,
// it is not considered read only.
if (IDecl->getInstanceMethod(PDecl->getSetterName()))
return false;
-
+
// Main class has the property as 'readonly'. Must search
- // through the category list to see if the property's
+ // through the category list to see if the property's
// attribute has been over-ridden to 'readwrite'.
for (ObjCCategoryDecl *Category = IDecl->getCategoryList();
Category; Category = Category->getNextClassCategory()) {
- // Even if property is ready only, if a category has a user defined setter,
- // it is not considered read only.
+ // Even if property is ready only, if a category has a user defined setter,
+ // it is not considered read only.
if (Category->getInstanceMethod(PDecl->getSetterName()))
return false;
- ObjCPropertyDecl *P =
+ ObjCPropertyDecl *P =
Category->FindPropertyDeclaration(PDecl->getIdentifier());
if (P && !P->isReadOnly())
return false;
}
-
+
// Also, check for definition of a setter method in the implementation if
// all else failed.
if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(CurContext)) {
- if (ObjCImplementationDecl *IMD =
+ if (ObjCImplementationDecl *IMD =
dyn_cast<ObjCImplementationDecl>(OMD->getDeclContext())) {
if (IMD->getInstanceMethod(PDecl->getSetterName()))
return false;
- } else if (ObjCCategoryImplDecl *CIMD =
+ } else if (ObjCCategoryImplDecl *CIMD =
dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext())) {
if (CIMD->getInstanceMethod(PDecl->getSetterName()))
return false;
@@ -894,11 +893,11 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
ObjCInterfaceDecl *Super = IDecl->getSuperClass();
ObjCInterfaceDecl *NSIDecl = 0;
if (getLangOptions().NeXTRuntime) {
- // check to see if class implements forwardInvocation method and objects
- // of this class are derived from 'NSProxy' so that to forward requests
+ // check to see if class implements forwardInvocation method and objects
+ // of this class are derived from 'NSProxy' so that to forward requests
// from one object to another.
- // Under such conditions, which means that every method possible is
- // implemented in the class, we should not issue "Method definition not
+ // Under such conditions, which means that every method possible is
+ // implemented in the class, we should not issue "Method definition not
// found" warnings.
// FIXME: Use a general GetUnarySelector method for this.
IdentifierInfo* II = &Context.Idents.get("forwardInvocation");
@@ -908,7 +907,7 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
// need be implemented in the implementation.
NSIDecl = IDecl->lookupInheritedClass(&Context.Idents.get("NSProxy"));
}
-
+
// If a method lookup fails locally we still need to look and see if
// the method was implemented by a base class or an inherited
// protocol. This lookup is slow, but occurs rarely in correct code
@@ -916,24 +915,24 @@ void Sema::CheckProtocolMethodDefs(SourceLocation ImpLoc,
// check unimplemented instance methods.
if (!NSIDecl)
- for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(),
+ for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(),
E = PDecl->instmeth_end(); I != E; ++I) {
ObjCMethodDecl *method = *I;
- if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
+ if (method->getImplementationControl() != ObjCMethodDecl::Optional &&
!method->isSynthesized() && !InsMap.count(method->getSelector()) &&
- (!Super ||
+ (!Super ||
!Super->lookupInstanceMethod(method->getSelector()))) {
// Ugly, but necessary. Method declared in protcol might have
// have been synthesized due to a property declared in the class which
// uses the protocol.
- ObjCMethodDecl *MethodInClass =
+ ObjCMethodDecl *MethodInClass =
IDecl->lookupInstanceMethod(method->getSelector());
if (!MethodInClass || !MethodInClass->isSynthesized())
WarnUndefinedMethod(ImpLoc, method, IncompleteImpl);
}
}
// check unimplemented class methods
- for (ObjCProtocolDecl::classmeth_iterator
+ for (ObjCProtocolDecl::classmeth_iterator
I = PDecl->classmeth_begin(), E = PDecl->classmeth_end();
I != E; ++I) {
ObjCMethodDecl *method = *I;
@@ -958,8 +957,7 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
ObjCImplDecl* IMPDecl,
ObjCContainerDecl* CDecl,
bool &IncompleteImpl,
- bool ImmediateClass)
-{
+ bool ImmediateClass) {
// Check and see if instance methods in class interface have been
// implemented in the implementation class. If so, their types match.
for (ObjCInterfaceDecl::instmeth_iterator I = CDecl->instmeth_begin(),
@@ -967,27 +965,27 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
if (InsMapSeen.count((*I)->getSelector()))
continue;
InsMapSeen.insert((*I)->getSelector());
- if (!(*I)->isSynthesized() &&
+ if (!(*I)->isSynthesized() &&
!InsMap.count((*I)->getSelector())) {
if (ImmediateClass)
WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
continue;
} else {
- ObjCMethodDecl *ImpMethodDecl =
+ ObjCMethodDecl *ImpMethodDecl =
IMPDecl->getInstanceMethod((*I)->getSelector());
- ObjCMethodDecl *IntfMethodDecl =
+ ObjCMethodDecl *IntfMethodDecl =
CDecl->getInstanceMethod((*I)->getSelector());
- assert(IntfMethodDecl &&
+ assert(IntfMethodDecl &&
"IntfMethodDecl is null in ImplMethodsVsClassMethods");
// ImpMethodDecl may be null as in a @dynamic property.
if (ImpMethodDecl)
WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
}
}
-
+
// Check and see if class methods in class interface have been
// implemented in the implementation class. If so, their types match.
- for (ObjCInterfaceDecl::classmeth_iterator
+ for (ObjCInterfaceDecl::classmeth_iterator
I = CDecl->classmeth_begin(), E = CDecl->classmeth_end(); I != E; ++I) {
if (ClsMapSeen.count((*I)->getSelector()))
continue;
@@ -998,7 +996,7 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
} else {
ObjCMethodDecl *ImpMethodDecl =
IMPDecl->getClassMethod((*I)->getSelector());
- ObjCMethodDecl *IntfMethodDecl =
+ ObjCMethodDecl *IntfMethodDecl =
CDecl->getClassMethod((*I)->getSelector());
WarnConflictingTypedMethods(ImpMethodDecl, IntfMethodDecl);
}
@@ -1007,26 +1005,26 @@ void Sema::MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
// Check for any implementation of a methods declared in protocol.
for (ObjCInterfaceDecl::protocol_iterator PI = I->protocol_begin(),
E = I->protocol_end(); PI != E; ++PI)
- MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
- IMPDecl,
+ MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
+ IMPDecl,
(*PI), IncompleteImpl, false);
if (I->getSuperClass())
MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
- IMPDecl,
+ IMPDecl,
I->getSuperClass(), IncompleteImpl, false);
}
}
-void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
- ObjCContainerDecl* CDecl,
+void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
+ ObjCContainerDecl* CDecl,
bool IncompleteImpl) {
llvm::DenseSet<Selector> InsMap;
// Check and see if instance methods in class interface have been
// implemented in the implementation class.
- for (ObjCImplementationDecl::instmeth_iterator
+ for (ObjCImplementationDecl::instmeth_iterator
I = IMPDecl->instmeth_begin(), E = IMPDecl->instmeth_end(); I!=E; ++I)
InsMap.insert((*I)->getSelector());
-
+
// Check and see if properties declared in the interface have either 1)
// an implementation or 2) there is a @synthesize/@dynamic implementation
// of the property in the @implementation.
@@ -1038,7 +1036,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
continue;
ObjCPropertyImplDecl *PI = 0;
// Is there a matching propery synthesize/dynamic?
- for (ObjCImplDecl::propimpl_iterator
+ for (ObjCImplDecl::propimpl_iterator
I = IMPDecl->propimpl_begin(),
EI = IMPDecl->propimpl_end(); I != EI; ++I)
if ((*I)->getPropertyDecl() == Prop) {
@@ -1048,44 +1046,44 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
if (PI)
continue;
if (!InsMap.count(Prop->getGetterName())) {
- Diag(Prop->getLocation(),
- diag::warn_setter_getter_impl_required)
+ Diag(Prop->getLocation(),
+ diag::warn_setter_getter_impl_required)
<< Prop->getDeclName() << Prop->getGetterName();
Diag(IMPDecl->getLocation(),
diag::note_property_impl_required);
}
-
+
if (!Prop->isReadOnly() && !InsMap.count(Prop->getSetterName())) {
- Diag(Prop->getLocation(),
- diag::warn_setter_getter_impl_required)
+ Diag(Prop->getLocation(),
+ diag::warn_setter_getter_impl_required)
<< Prop->getDeclName() << Prop->getSetterName();
Diag(IMPDecl->getLocation(),
diag::note_property_impl_required);
}
}
-
+
llvm::DenseSet<Selector> ClsMap;
- for (ObjCImplementationDecl::classmeth_iterator
+ for (ObjCImplementationDecl::classmeth_iterator
I = IMPDecl->classmeth_begin(),
E = IMPDecl->classmeth_end(); I != E; ++I)
ClsMap.insert((*I)->getSelector());
-
+
// Check for type conflict of methods declared in a class/protocol and
// its implementation; if any.
llvm::DenseSet<Selector> InsMapSeen, ClsMapSeen;
- MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
- IMPDecl, CDecl,
+ MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen,
+ IMPDecl, CDecl,
IncompleteImpl, true);
-
+
// Check the protocol list for unimplemented methods in the @implementation
// class.
// Check and see if class methods in class interface have been
// implemented in the implementation class.
-
+
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) {
for (ObjCInterfaceDecl::protocol_iterator PI = I->protocol_begin(),
E = I->protocol_end(); PI != E; ++PI)
- CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl,
+ CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl,
InsMap, ClsMap, I);
// Check class extensions (unnamed categories)
for (ObjCCategoryDecl *Categories = I->getCategoryList();
@@ -1098,19 +1096,19 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl,
} else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl)) {
for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(),
E = C->protocol_end(); PI != E; ++PI)
- CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl,
+ CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl,
InsMap, ClsMap, C->getClassInterface());
} else
assert(false && "invalid ObjCContainerDecl type.");
}
-/// ActOnForwardClassDeclaration -
+/// ActOnForwardClassDeclaration -
Action::DeclPtrTy
Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
IdentifierInfo **IdentList,
unsigned NumElts) {
llvm::SmallVector<ObjCInterfaceDecl*, 32> Interfaces;
-
+
for (unsigned i = 0; i != NumElts; ++i) {
// Check for another declaration kind with the same name.
NamedDecl *PrevDecl = LookupName(TUScope, IdentList[i], LookupOrdinaryName);
@@ -1127,7 +1125,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
// typedef NSObject < XCElementTogglerP > XCElementToggler;
// @class XCElementToggler;
//
- // FIXME: Make an extension?
+ // FIXME: Make an extension?
TypedefDecl *TDD = dyn_cast<TypedefDecl>(PrevDecl);
if (!TDD || !isa<ObjCInterfaceType>(TDD->getUnderlyingType())) {
Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
@@ -1135,21 +1133,21 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
} else if (TDD) {
// a forward class declaration matching a typedef name of a class refers
// to the underlying class.
- if (ObjCInterfaceType * OI =
+ if (ObjCInterfaceType * OI =
dyn_cast<ObjCInterfaceType>(TDD->getUnderlyingType()))
PrevDecl = OI->getDecl();
}
}
- ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
+ ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!IDecl) { // Not already seen? Make a forward decl.
- IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassLoc,
+ IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassLoc,
IdentList[i], SourceLocation(), true);
PushOnScopeChains(IDecl, TUScope);
}
Interfaces.push_back(IDecl);
}
-
+
ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc,
&Interfaces[0],
Interfaces.size());
@@ -1162,12 +1160,12 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
/// MatchTwoMethodDeclarations - Checks that two methods have matching type and
/// returns true, or false, accordingly.
/// TODO: Handle protocol list; such as id<p1,p2> in type comparisons
-bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
+bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
const ObjCMethodDecl *PrevMethod,
bool matchBasedOnSizeAndAlignment) {
QualType T1 = Context.getCanonicalType(Method->getResultType());
QualType T2 = Context.getCanonicalType(PrevMethod->getResultType());
-
+
if (T1 != T2) {
// The result types are different.
if (!matchBasedOnSizeAndAlignment)
@@ -1179,11 +1177,11 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
if (Context.getTypeInfo(T1) != Context.getTypeInfo(T2))
return false;
}
-
+
ObjCMethodDecl::param_iterator ParamI = Method->param_begin(),
E = Method->param_end();
ObjCMethodDecl::param_iterator PrevI = PrevMethod->param_begin();
-
+
for (; ParamI != E; ++ParamI, ++PrevI) {
assert(PrevI != PrevMethod->param_end() && "Param mismatch");
T1 = Context.getCanonicalType((*ParamI)->getType());
@@ -1208,7 +1206,7 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
///
/// This routine should only be called once, when neither the instance
/// nor the factory method pool has an entry for this selector.
-Sema::MethodPool::iterator Sema::ReadMethodPool(Selector Sel,
+Sema::MethodPool::iterator Sema::ReadMethodPool(Selector Sel,
bool isInstance) {
assert(ExternalSource && "We need an external AST source");
assert(InstanceMethodPool.find(Sel) == InstanceMethodPool.end() &&
@@ -1219,12 +1217,12 @@ Sema::MethodPool::iterator Sema::ReadMethodPool(Selector Sel,
// Read the method list from the external source.
std::pair<ObjCMethodList, ObjCMethodList> Methods
= ExternalSource->ReadMethodPool(Sel);
-
+
if (isInstance) {
if (Methods.second.Method)
FactoryMethodPool[Sel] = Methods.second;
return InstanceMethodPool.insert(std::make_pair(Sel, Methods.first)).first;
- }
+ }
if (Methods.first.Method)
InstanceMethodPool[Sel] = Methods.first;
@@ -1250,20 +1248,20 @@ void Sema::AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method) {
Entry.Next = 0;
return;
}
-
+
// We've seen a method with this name, see if we have already seen this type
// signature.
for (ObjCMethodList *List = &Entry; List; List = List->Next)
if (MatchTwoMethodDeclarations(Method, List->Method))
return;
-
+
// We have a new signature for an existing method - add it.
// This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
Entry.Next = new ObjCMethodList(Method, Entry.Next);
}
// FIXME: Finish implementing -Wno-strict-selector-match.
-ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel,
+ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel,
SourceRange R,
bool warn) {
llvm::DenseMap<Selector, ObjCMethodList>::iterator Pos
@@ -1277,7 +1275,7 @@ ObjCMethodDecl *Sema::LookupInstanceMethodInGlobalPool(Selector Sel,
ObjCMethodList &MethList = Pos->second;
bool issueWarning = false;
-
+
if (MethList.Method && MethList.Next) {
for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next)
// This checks if the methods differ by size & alignment.
@@ -1314,11 +1312,11 @@ void Sema::AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method) {
} else {
// We've seen a method with this name, now check the type signature(s).
bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method);
-
- for (ObjCMethodList *Next = FirstMethod.Next; !match && Next;
+
+ for (ObjCMethodList *Next = FirstMethod.Next; !match && Next;
Next = Next->Next)
match = MatchTwoMethodDeclarations(Method, Next->Method);
-
+
if (!match) {
// We have a new signature for an existing method - add it.
// This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
@@ -1328,12 +1326,12 @@ void Sema::AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method) {
}
}
-ObjCMethodDecl *Sema::LookupFactoryMethodInGlobalPool(Selector Sel,
+ObjCMethodDecl *Sema::LookupFactoryMethodInGlobalPool(Selector Sel,
SourceRange R) {
llvm::DenseMap<Selector, ObjCMethodList>::iterator Pos
= FactoryMethodPool.find(Sel);
if (Pos == FactoryMethodPool.end()) {
- if (ExternalSource && !InstanceMethodPool.count(Sel))
+ if (ExternalSource && !InstanceMethodPool.count(Sel))
Pos = ReadMethodPool(Sel, /*isInstance=*/false);
else
return 0;
@@ -1341,7 +1339,7 @@ ObjCMethodDecl *Sema::LookupFactoryMethodInGlobalPool(Selector Sel,
ObjCMethodList &MethList = Pos->second;
bool issueWarning = false;
-
+
if (MethList.Method && MethList.Next) {
for (ObjCMethodList *Next = MethList.Next; Next; Next = Next->Next)
// This checks if the methods differ by size & alignment.
@@ -1359,28 +1357,28 @@ ObjCMethodDecl *Sema::LookupFactoryMethodInGlobalPool(Selector Sel,
return MethList.Method;
}
-/// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
+/// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
/// have the property type and issue diagnostics if they don't.
/// Also synthesize a getter/setter method if none exist (and update the
/// appropriate lookup tables. FIXME: Should reconsider if adding synthesized
/// methods is the "right" thing to do.
-void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
+void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
ObjCContainerDecl *CD) {
ObjCMethodDecl *GetterMethod, *SetterMethod;
-
- GetterMethod = CD->getInstanceMethod(property->getGetterName());
+
+ GetterMethod = CD->getInstanceMethod(property->getGetterName());
SetterMethod = CD->getInstanceMethod(property->getSetterName());
- DiagnosePropertyAccessorMismatch(property, GetterMethod,
+ DiagnosePropertyAccessorMismatch(property, GetterMethod,
property->getLocation());
-
+
if (SetterMethod) {
- if (Context.getCanonicalType(SetterMethod->getResultType())
+ if (Context.getCanonicalType(SetterMethod->getResultType())
!= Context.VoidTy)
Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
if (SetterMethod->param_size() != 1 ||
((*SetterMethod->param_begin())->getType() != property->getType())) {
- Diag(property->getLocation(),
- diag::warn_accessor_property_type_mismatch)
+ Diag(property->getLocation(),
+ diag::warn_accessor_property_type_mismatch)
<< property->getDeclName()
<< SetterMethod->getSelector();
Diag(SetterMethod->getLocation(), diag::note_declared_at);
@@ -1395,14 +1393,14 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
// declarations jive in that situation (which it is not currently).
if (!GetterMethod) {
// No instance method of same name as property getter name was found.
- // Declare a getter method and add it to the list of methods
+ // Declare a getter method and add it to the list of methods
// for this class.
- GetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
- property->getLocation(), property->getGetterName(),
- property->getType(), CD, true, false, true,
- (property->getPropertyImplementation() ==
- ObjCPropertyDecl::Optional) ?
- ObjCMethodDecl::Optional :
+ GetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
+ property->getLocation(), property->getGetterName(),
+ property->getType(), CD, true, false, true,
+ (property->getPropertyImplementation() ==
+ ObjCPropertyDecl::Optional) ?
+ ObjCMethodDecl::Optional :
ObjCMethodDecl::Required);
CD->addDecl(GetterMethod);
} else
@@ -1416,20 +1414,20 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
// Find the default setter and if one not found, add one.
if (!SetterMethod) {
// No instance method of same name as property setter name was found.
- // Declare a setter method and add it to the list of methods
+ // Declare a setter method and add it to the list of methods
// for this class.
- SetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
- property->getLocation(),
- property->getSetterName(),
+ SetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(),
+ property->getLocation(),
+ property->getSetterName(),
Context.VoidTy, CD, true, false, true,
- (property->getPropertyImplementation() ==
- ObjCPropertyDecl::Optional) ?
- ObjCMethodDecl::Optional :
+ (property->getPropertyImplementation() ==
+ ObjCPropertyDecl::Optional) ?
+ ObjCMethodDecl::Optional :
ObjCMethodDecl::Required);
// Invent the arguments for the setter. We don't bother making a
// nice name for the argument.
ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterMethod,
- property->getLocation(),
+ property->getLocation(),
property->getIdentifier(),
property->getType(),
/*DInfo=*/0,
@@ -1443,7 +1441,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
SetterMethod->setSynthesized(true);
property->setSetterMethodDecl(SetterMethod);
}
- // Add any synthesized methods to the global pool. This allows us to
+ // Add any synthesized methods to the global pool. This allows us to
// handle the following, which is supported by GCC (and part of the design).
//
// @interface Foo
@@ -1456,9 +1454,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
// }
//
if (GetterMethod)
- AddInstanceMethodToGlobalPool(GetterMethod);
+ AddInstanceMethodToGlobalPool(GetterMethod);
if (SetterMethod)
- AddInstanceMethodToGlobalPool(SetterMethod);
+ AddInstanceMethodToGlobalPool(SetterMethod);
}
/// CompareMethodParamsInBaseAndSuper - This routine compares methods with
@@ -1469,9 +1467,9 @@ void Sema::CompareMethodParamsInBaseAndSuper(Decl *ClassDecl,
bool IsInstance) {
ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(ClassDecl);
if (ID == 0) return;
-
+
while (ObjCInterfaceDecl *SD = ID->getSuperClass()) {
- ObjCMethodDecl *SuperMethodDecl =
+ ObjCMethodDecl *SuperMethodDecl =
SD->lookupMethod(Method->getSelector(), IsInstance);
if (SuperMethodDecl == 0) {
ID = SD;
@@ -1488,7 +1486,7 @@ void Sema::CompareMethodParamsInBaseAndSuper(Decl *ClassDecl,
// If type of arguement of method in this class does not match its
// respective argument type in the super class method, issue warning;
if (!Context.typesAreCompatible(T1, T2)) {
- Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
+ Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
<< T1 << T2;
Diag(SuperMethodDecl->getLocation(), diag::note_previous_declaration);
return;
@@ -1511,8 +1509,8 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
// should be true.
if (!ClassDecl)
return;
-
- bool isInterfaceDeclKind =
+
+ bool isInterfaceDeclKind =
isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
|| isa<ObjCProtocolDecl>(ClassDecl);
bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
@@ -1531,9 +1529,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
if (Method->isInstanceMethod()) {
/// Check for instance method of the same name with incompatible types
const ObjCMethodDecl *&PrevMethod = InsMap[Method->getSelector()];
- bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
+ bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
: false;
- if ((isInterfaceDeclKind && PrevMethod && !match)
+ if ((isInterfaceDeclKind && PrevMethod && !match)
|| (checkIdenticalMethods && match)) {
Diag(Method->getLocation(), diag::err_duplicate_method_decl)
<< Method->getDeclName();
@@ -1543,16 +1541,16 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
InsMap[Method->getSelector()] = Method;
/// The following allows us to typecheck messages to "id".
AddInstanceMethodToGlobalPool(Method);
- // verify that the instance method conforms to the same definition of
+ // verify that the instance method conforms to the same definition of
// parent methods if it shadows one.
CompareMethodParamsInBaseAndSuper(ClassDecl, Method, true);
}
} else {
/// Check for class method of the same name with incompatible types
const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
- bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
+ bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod)
: false;
- if ((isInterfaceDeclKind && PrevMethod && !match)
+ if ((isInterfaceDeclKind && PrevMethod && !match)
|| (checkIdenticalMethods && match)) {
Diag(Method->getLocation(), diag::err_duplicate_method_decl)
<< Method->getDeclName();
@@ -1562,20 +1560,20 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
ClsMap[Method->getSelector()] = Method;
/// The following allows us to typecheck messages to "Class".
AddFactoryMethodToGlobalPool(Method);
- // verify that the class method conforms to the same definition of
+ // verify that the class method conforms to the same definition of
// parent methods if it shadows one.
CompareMethodParamsInBaseAndSuper(ClassDecl, Method, false);
}
}
}
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
- // Compares properties declared in this class to those of its
+ // Compares properties declared in this class to those of its
// super class.
ComparePropertiesInBaseAndSuper(I);
MergeProtocolPropertiesIntoClass(I, DeclPtrTy::make(I));
} else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(ClassDecl)) {
// Categories are used to extend the class by declaring new methods.
- // By the same token, they are also used to add new properties. No
+ // By the same token, they are also used to add new properties. No
// need to compare the added property to those in the class.
// Merge protocol properties into category
@@ -1597,10 +1595,10 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
IC->setAtEndLoc(AtEndLoc);
if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
ImplMethodsVsClassMethods(IC, IDecl);
- } else if (ObjCCategoryImplDecl* CatImplClass =
+ } else if (ObjCCategoryImplDecl* CatImplClass =
dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
CatImplClass->setAtEndLoc(AtEndLoc);
-
+
// Find category interface decl and then check that all methods declared
// in this interface are implemented in the category @implementation.
if (ObjCInterfaceDecl* IDecl = CatImplClass->getClassInterface()) {
@@ -1629,7 +1627,7 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl,
/// CvtQTToAstBitMask - utility routine to produce an AST bitmask for
/// objective-c's type qualifier from the parser version of the same info.
-static Decl::ObjCDeclQualifier
+static Decl::ObjCDeclQualifier
CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal) {
Decl::ObjCDeclQualifier ret = Decl::OBJC_TQ_None;
if (PQTVal & ObjCDeclSpec::DQ_In)
@@ -1668,10 +1666,10 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
return DeclPtrTy();
}
QualType resultDeclType;
-
+
if (ReturnType) {
resultDeclType = GetTypeFromParser(ReturnType);
-
+
// Methods cannot return interface types. All ObjC objects are
// passed by reference.
if (resultDeclType->isObjCInterfaceType()) {
@@ -1681,21 +1679,21 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
}
} else // get the type for "id".
resultDeclType = Context.getObjCIdType();
-
- ObjCMethodDecl* ObjCMethod =
+
+ ObjCMethodDecl* ObjCMethod =
ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
- cast<DeclContext>(ClassDecl),
+ cast<DeclContext>(ClassDecl),
MethodType == tok::minus, isVariadic,
false,
- MethodDeclKind == tok::objc_optional ?
- ObjCMethodDecl::Optional :
+ MethodDeclKind == tok::objc_optional ?
+ ObjCMethodDecl::Optional :
ObjCMethodDecl::Required);
-
+
llvm::SmallVector<ParmVarDecl*, 16> Params;
-
+
for (unsigned i = 0, e = Sel.getNumArgs(); i != e; ++i) {
QualType ArgType, UnpromotedArgType;
-
+
if (ArgInfo[i].Type == 0) {
UnpromotedArgType = ArgType = Context.getObjCIdType();
} else {
@@ -1703,7 +1701,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
// Perform the default array/function conversions (C99 6.7.5.3p[7,8]).
ArgType = adjustParameterType(ArgType);
}
-
+
ParmVarDecl* Param;
if (ArgType == UnpromotedArgType)
Param = ParmVarDecl::Create(Context, ObjCMethod, ArgInfo[i].NameLoc,
@@ -1717,20 +1715,20 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
/*DInfo=*/0, //FIXME: Pass info here.
UnpromotedArgType,
VarDecl::None, 0);
-
+
if (ArgType->isObjCInterfaceType()) {
Diag(ArgInfo[i].NameLoc,
diag::err_object_cannot_be_passed_returned_by_value)
<< 1 << ArgType;
Param->setInvalidDecl();
}
-
+
Param->setObjCDeclQualifier(
CvtQTToAstBitMask(ArgInfo[i].DeclSpec.getObjCDeclQualifier()));
-
+
// Apply the attributes to the parameter.
ProcessDeclAttributeList(TUScope, Param, ArgInfo[i].ArgAttrs);
-
+
Params.push_back(Param);
}
@@ -1741,12 +1739,12 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
if (AttrList)
ProcessDeclAttributeList(TUScope, ObjCMethod, AttrList);
-
- // For implementations (which can be very "coarse grain"), we add the
- // method now. This allows the AST to implement lookup methods that work
- // incrementally (without waiting until we parse the @end). It also allows
+
+ // For implementations (which can be very "coarse grain"), we add the
+ // method now. This allows the AST to implement lookup methods that work
+ // incrementally (without waiting until we parse the @end). It also allows
// us to flag multiple declaration errors as they occur.
- if (ObjCImplementationDecl *ImpDecl =
+ if (ObjCImplementationDecl *ImpDecl =
dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
if (MethodType == tok::minus) {
PrevMethod = ImpDecl->getInstanceMethod(Sel);
@@ -1757,7 +1755,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
}
if (AttrList)
Diag(EndLoc, diag::warn_attribute_method_def);
- } else if (ObjCCategoryImplDecl *CatImpDecl =
+ } else if (ObjCCategoryImplDecl *CatImpDecl =
dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
if (MethodType == tok::minus) {
PrevMethod = CatImpDecl->getInstanceMethod(Sel);
@@ -1774,11 +1772,11 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
<< ObjCMethod->getDeclName();
Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
- }
+ }
return DeclPtrTy::make(ObjCMethod);
}
-void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
+void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
SourceLocation Loc,
unsigned &Attributes) {
// FIXME: Improve the reported location.
@@ -1795,8 +1793,8 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
"assign" :
(Attributes & ObjCDeclSpec::DQ_PR_copy) ?
"copy" : "retain";
-
- Diag(Loc, (Attributes & (ObjCDeclSpec::DQ_PR_readwrite)) ?
+
+ Diag(Loc, (Attributes & (ObjCDeclSpec::DQ_PR_readwrite)) ?
diag::err_objc_property_attr_mutually_exclusive :
diag::warn_objc_property_attr_mutually_exclusive)
<< "readonly" << which;
@@ -1804,8 +1802,8 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
// Check for copy or retain on non-object types.
if ((Attributes & (ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain)) &&
- !PropertyTy->isObjCObjectPointerType() &&
- !PropertyTy->isBlockPointerType() &&
+ !PropertyTy->isObjCObjectPointerType() &&
+ !PropertyTy->isBlockPointerType() &&
!Context.isObjCNSObjectType(PropertyTy)) {
Diag(Loc, diag::err_objc_property_requires_object)
<< (Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain");
@@ -1818,7 +1816,7 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
<< "assign" << "copy";
Attributes &= ~ObjCDeclSpec::DQ_PR_copy;
- }
+ }
if (Attributes & ObjCDeclSpec::DQ_PR_retain) {
Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
<< "assign" << "retain";
@@ -1839,13 +1837,13 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
!(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
PropertyTy->isObjCObjectPointerType()) {
// Skip this warning in gc-only mode.
- if (getLangOptions().getGCMode() != LangOptions::GCOnly)
+ if (getLangOptions().getGCMode() != LangOptions::GCOnly)
Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
// If non-gc code warn that this is likely inappropriate.
if (getLangOptions().getGCMode() == LangOptions::NonGC)
Diag(Loc, diag::warn_objc_property_default_assign_on_object);
-
+
// FIXME: Implement warning dependent on NSCopying being
// implemented. See also:
// <rdar://5168496&4855821&5607453&5096644&4947311&5698469&4947014&5168496>
@@ -1858,7 +1856,7 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
Diag(Loc, diag::warn_objc_property_copy_missing_on_block);
}
-Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
+Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
FieldDeclarator &FD,
ObjCDeclSpec &ODS,
Selector GetterSel,
@@ -1870,11 +1868,11 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
bool isReadWrite = ((Attributes & ObjCDeclSpec::DQ_PR_readwrite) ||
// default is readwrite!
!(Attributes & ObjCDeclSpec::DQ_PR_readonly));
- // property is defaulted to 'assign' if it is readwrite and is
+ // property is defaulted to 'assign' if it is readwrite and is
// not retain or copy
bool isAssign = ((Attributes & ObjCDeclSpec::DQ_PR_assign) ||
- (isReadWrite &&
- !(Attributes & ObjCDeclSpec::DQ_PR_retain) &&
+ (isReadWrite &&
+ !(Attributes & ObjCDeclSpec::DQ_PR_retain) &&
!(Attributes & ObjCDeclSpec::DQ_PR_copy)));
QualType T = GetTypeForDeclarator(FD.D, S);
Decl *ClassDecl = ClassCategory.getAs<Decl>();
@@ -1883,20 +1881,20 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
CheckObjCPropertyAttributes(T, AtLoc, Attributes);
if (ObjCCategoryDecl *CDecl = dyn_cast<ObjCCategoryDecl>(ClassDecl))
if (!CDecl->getIdentifier()) {
- // This is a continuation class. property requires special
+ // This is a continuation class. property requires special
// handling.
if ((CCPrimary = CDecl->getClassInterface())) {
// Find the property in continuation class's primary class only.
ObjCPropertyDecl *PIDecl = 0;
IdentifierInfo *PropertyId = FD.D.getIdentifier();
- for (ObjCInterfaceDecl::prop_iterator
+ for (ObjCInterfaceDecl::prop_iterator
I = CCPrimary->prop_begin(), E = CCPrimary->prop_end();
I != E; ++I)
if ((*I)->getIdentifier() == PropertyId) {
PIDecl = *I;
break;
}
-
+
if (PIDecl) {
// property 'PIDecl's readonly attribute will be over-ridden
// with continuation class's readwrite property attribute!
@@ -1912,10 +1910,10 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
PIDecl->setSetterName(SetterSel);
} else
- Diag(AtLoc, diag::err_use_continuation_class)
+ Diag(AtLoc, diag::err_use_continuation_class)
<< CCPrimary->getDeclName();
*isOverridingProperty = true;
- // Make sure setter decl is synthesized, and added to primary
+ // Make sure setter decl is synthesized, and added to primary
// class's list.
ProcessPropertyDecl(PIDecl, CCPrimary);
return DeclPtrTy();
@@ -1927,72 +1925,72 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
Diag(CDecl->getLocation(), diag::err_continuation_class);
*isOverridingProperty = true;
return DeclPtrTy();
- }
+ }
}
-
+
// Issue a warning if property is 'assign' as default and its object, which is
- // gc'able conforms to NSCopying protocol
+ // gc'able conforms to NSCopying protocol
if (getLangOptions().getGCMode() != LangOptions::NonGC &&
isAssign && !(Attributes & ObjCDeclSpec::DQ_PR_assign))
if (T->isObjCObjectPointerType()) {
QualType InterfaceTy = T->getPointeeType();
- if (const ObjCInterfaceType *OIT =
+ if (const ObjCInterfaceType *OIT =
InterfaceTy->getAsObjCInterfaceType()) {
ObjCInterfaceDecl *IDecl = OIT->getDecl();
if (IDecl)
- if (ObjCProtocolDecl* PNSCopying =
+ if (ObjCProtocolDecl* PNSCopying =
LookupProtocol(&Context.Idents.get("NSCopying")))
if (IDecl->ClassImplementsProtocol(PNSCopying, true))
- Diag(AtLoc, diag::warn_implements_nscopying)
+ Diag(AtLoc, diag::warn_implements_nscopying)
<< FD.D.getIdentifier();
}
}
if (T->isObjCInterfaceType())
Diag(FD.D.getIdentifierLoc(), diag::err_statically_allocated_object);
-
+
DeclContext *DC = dyn_cast<DeclContext>(ClassDecl);
assert(DC && "ClassDecl is not a DeclContext");
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC,
- FD.D.getIdentifierLoc(),
+ FD.D.getIdentifierLoc(),
FD.D.getIdentifier(), T);
DC->addDecl(PDecl);
-
+
if (T->isArrayType() || T->isFunctionType()) {
Diag(AtLoc, diag::err_property_type) << T;
PDecl->setInvalidDecl();
}
-
+
ProcessDeclAttributes(S, PDecl, FD.D);
// Regardless of setter/getter attribute, we save the default getter/setter
// selector names in anticipation of declaration of setter/getter methods.
PDecl->setGetterName(GetterSel);
PDecl->setSetterName(SetterSel);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_readonly)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_getter)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_getter);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_setter)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_setter);
-
+
if (isReadWrite)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_retain)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_copy)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
-
+
if (isAssign)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_assign);
-
+
if (Attributes & ObjCDeclSpec::DQ_PR_nonatomic)
PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic);
-
+
if (MethodImplKind == tok::objc_required)
PDecl->setPropertyImplementation(ObjCPropertyDecl::Required);
else if (MethodImplKind == tok::objc_optional)
@@ -2002,7 +2000,7 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
// Make sure setter/getters are declared here.
if (CCPrimary)
ProcessPropertyDecl(PDecl, CCPrimary);
-
+
return DeclPtrTy::make(PDecl);
}
@@ -2010,9 +2008,9 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
/// builds the AST node for a property implementation declaration; declared
/// as @synthesize or @dynamic.
///
-Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
+Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
SourceLocation PropertyLoc,
- bool Synthesize,
+ bool Synthesize,
DeclPtrTy ClassCatImpDecl,
IdentifierInfo *PropertyId,
IdentifierInfo *PropertyIvar) {
@@ -2032,9 +2030,9 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
IDecl = IC->getClassInterface();
// We always synthesize an interface for an implementation
// without an interface decl. So, IDecl is always non-zero.
- assert(IDecl &&
+ assert(IDecl &&
"ActOnPropertyImplDecl - @implementation without @interface");
-
+
// Look for this property declaration in the @implementation's @interface
property = IDecl->FindPropertyDeclaration(PropertyId);
if (!property) {
@@ -2045,15 +2043,15 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
if (Synthesize) {
Diag(AtLoc, diag::error_synthesize_category_decl);
return DeclPtrTy();
- }
+ }
IDecl = CatImplClass->getClassInterface();
if (!IDecl) {
Diag(AtLoc, diag::error_missing_property_interface);
return DeclPtrTy();
}
- ObjCCategoryDecl *Category =
+ ObjCCategoryDecl *Category =
IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier());
-
+
// If category for this implementation not found, it is an error which
// has already been reported eralier.
if (!Category)
@@ -2081,10 +2079,10 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
Ivar = IDecl->lookupInstanceVariable(PropertyIvar, ClassDeclared);
if (!Ivar) {
DeclContext *EnclosingContext = cast_or_null<DeclContext>(IDecl);
- assert(EnclosingContext &&
+ assert(EnclosingContext &&
"null DeclContext for synthesized ivar - ActOnPropertyImplDecl");
- Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, PropertyLoc,
- PropertyIvar, PropType, /*Dinfo=*/0,
+ Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, PropertyLoc,
+ PropertyIvar, PropType, /*Dinfo=*/0,
ObjCIvarDecl::Public,
(Expr *)0);
Ivar->setLexicalDeclContext(IDecl);
@@ -2092,34 +2090,34 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
property->setPropertyIvarDecl(Ivar);
if (!getLangOptions().ObjCNonFragileABI)
Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;
- // Note! I deliberately want it to fall thru so, we have a
+ // Note! I deliberately want it to fall thru so, we have a
// a property implementation and to avoid future warnings.
} else if (getLangOptions().ObjCNonFragileABI &&
ClassDeclared != IDecl) {
Diag(PropertyLoc, diag::error_ivar_in_superclass_use)
- << property->getDeclName() << Ivar->getDeclName()
+ << property->getDeclName() << Ivar->getDeclName()
<< ClassDeclared->getDeclName();
Diag(Ivar->getLocation(), diag::note_previous_access_declaration)
<< Ivar << Ivar->getNameAsCString();
// Note! I deliberately want it to fall thru so more errors are caught.
}
QualType IvarType = Context.getCanonicalType(Ivar->getType());
-
+
// Check that type of property and its ivar are type compatible.
if (PropType != IvarType) {
if (CheckAssignmentConstraints(PropType, IvarType) != Compatible) {
Diag(PropertyLoc, diag::error_property_ivar_type)
<< property->getDeclName() << Ivar->getDeclName();
- // Note! I deliberately want it to fall thru so, we have a
+ // Note! I deliberately want it to fall thru so, we have a
// a property implementation and to avoid future warnings.
}
-
+
// FIXME! Rules for properties are somewhat different that those
// for assignments. Use a new routine to consolidate all cases;
// specifically for property redeclarations as well as for ivars.
QualType lhsType =Context.getCanonicalType(PropType).getUnqualifiedType();
QualType rhsType =Context.getCanonicalType(IvarType).getUnqualifiedType();
- if (lhsType != rhsType &&
+ if (lhsType != rhsType &&
lhsType->isArithmeticType()) {
Diag(PropertyLoc, diag::error_property_ivar_type)
<< property->getDeclName() << Ivar->getDeclName();
@@ -2132,36 +2130,36 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
<< property->getDeclName() << Ivar->getDeclName();
// Fall thru - see previous comment
}
- if ((property->getType()->isObjCObjectPointerType() ||
+ if ((property->getType()->isObjCObjectPointerType() ||
PropType.isObjCGCStrong()) && IvarType.isObjCGCWeak() &&
getLangOptions().getGCMode() != LangOptions::NonGC) {
Diag(PropertyLoc, diag::error_strong_property)
<< property->getDeclName() << Ivar->getDeclName();
- // Fall thru - see previous comment
+ // Fall thru - see previous comment
}
}
} else if (PropertyIvar)
// @dynamic
Diag(PropertyLoc, diag::error_dynamic_property_ivar_decl);
assert (property && "ActOnPropertyImplDecl - property declaration missing");
- ObjCPropertyImplDecl *PIDecl =
- ObjCPropertyImplDecl::Create(Context, CurContext, AtLoc, PropertyLoc,
- property,
- (Synthesize ?
- ObjCPropertyImplDecl::Synthesize
+ ObjCPropertyImplDecl *PIDecl =
+ ObjCPropertyImplDecl::Create(Context, CurContext, AtLoc, PropertyLoc,
+ property,
+ (Synthesize ?
+ ObjCPropertyImplDecl::Synthesize
: ObjCPropertyImplDecl::Dynamic),
Ivar);
if (IC) {
if (Synthesize)
- if (ObjCPropertyImplDecl *PPIDecl =
+ if (ObjCPropertyImplDecl *PPIDecl =
IC->FindPropertyImplIvarDecl(PropertyIvar)) {
- Diag(PropertyLoc, diag::error_duplicate_ivar_use)
- << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
+ Diag(PropertyLoc, diag::error_duplicate_ivar_use)
+ << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
<< PropertyIvar;
Diag(PPIDecl->getLocation(), diag::note_previous_use);
}
-
- if (ObjCPropertyImplDecl *PPIDecl
+
+ if (ObjCPropertyImplDecl *PPIDecl
= IC->FindPropertyImplDecl(PropertyId)) {
Diag(PropertyLoc, diag::error_property_implemented) << PropertyId;
Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
@@ -2170,39 +2168,39 @@ Sema::DeclPtrTy Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
IC->addPropertyImplementation(PIDecl);
} else {
if (Synthesize)
- if (ObjCPropertyImplDecl *PPIDecl =
+ if (ObjCPropertyImplDecl *PPIDecl =
CatImplClass->FindPropertyImplIvarDecl(PropertyIvar)) {
- Diag(PropertyLoc, diag::error_duplicate_ivar_use)
- << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
+ Diag(PropertyLoc, diag::error_duplicate_ivar_use)
+ << PropertyId << PPIDecl->getPropertyDecl()->getIdentifier()
<< PropertyIvar;
Diag(PPIDecl->getLocation(), diag::note_previous_use);
}
-
- if (ObjCPropertyImplDecl *PPIDecl =
+
+ if (ObjCPropertyImplDecl *PPIDecl =
CatImplClass->FindPropertyImplDecl(PropertyId)) {
Diag(PropertyLoc, diag::error_property_implemented) << PropertyId;
Diag(PPIDecl->getLocation(), diag::note_previous_declaration);
return DeclPtrTy();
- }
+ }
CatImplClass->addPropertyImplementation(PIDecl);
}
-
+
return DeclPtrTy::make(PIDecl);
}
bool Sema::CheckObjCDeclScope(Decl *D) {
if (isa<TranslationUnitDecl>(CurContext->getLookupContext()))
return false;
-
+
Diag(D->getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
D->setInvalidDecl();
-
+
return true;
}
/// Called whenever @defs(ClassName) is encountered in the source. Inserts the
/// instance variables of ClassName into Decls.
-void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
+void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
IdentifierInfo *ClassName,
llvm::SmallVectorImpl<DeclPtrTy> &Decls) {
// Check that ClassName is a valid class
@@ -2215,7 +2213,7 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
Diag(DeclStart, diag::err_atdef_nonfragile_interface);
return;
}
-
+
// Collect the instance variables
llvm::SmallVector<FieldDecl*, 32> RecFields;
Context.CollectObjCIvars(Class, RecFields);
@@ -2228,7 +2226,7 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
ID->getBitWidth());
Decls.push_back(Sema::DeclPtrTy::make(FD));
}
-
+
// Introduce all of these fields into the appropriate scope.
for (llvm::SmallVectorImpl<DeclPtrTy>::iterator D = Decls.begin();
D != Decls.end(); ++D) {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2644c1d6f7..c2a4119c53 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -46,12 +46,12 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
// stuff. Don't warn if we are implementing a deprecated
// construct.
bool isSilenced = false;
-
+
if (NamedDecl *ND = getCurFunctionOrMethodDecl()) {
// If this reference happens *in* a deprecated function or method, don't
// warn.
isSilenced = ND->getAttr<DeprecatedAttr>();
-
+
// If this is an Objective-C method implementation, check to see if the
// method was deprecated on the declaration, not the definition.
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(ND)) {
@@ -59,14 +59,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
// ObjCImplementationDecl.
if (ObjCImplementationDecl *Impl
= dyn_cast<ObjCImplementationDecl>(MD->getParent())) {
-
+
MD = Impl->getClassInterface()->getMethod(MD->getSelector(),
MD->isInstanceMethod());
isSilenced |= MD && MD->getAttr<DeprecatedAttr>();
}
}
}
-
+
if (!isSilenced)
Diag(Loc, diag::warn_deprecated) << D->getDeclName();
}
@@ -90,18 +90,17 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
}
/// DiagnoseSentinelCalls - This routine checks on method dispatch calls
-/// (and other functions in future), which have been declared with sentinel
+/// (and other functions in future), which have been declared with sentinel
/// attribute. It warns if call does not have the sentinel argument.
///
void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
- Expr **Args, unsigned NumArgs)
-{
+ Expr **Args, unsigned NumArgs) {
const SentinelAttr *attr = D->getAttr<SentinelAttr>();
- if (!attr)
+ if (!attr)
return;
int sentinelPos = attr->getSentinel();
int nullPos = attr->getNullPos();
-
+
// FIXME. ObjCMethodDecl and FunctionDecl need be derived from the same common
// base class. Then we won't be needing two versions of the same code.
unsigned int i = 0;
@@ -132,7 +131,7 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
// block or function pointer call.
QualType Ty = V->getType();
if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
- const FunctionType *FT = Ty->isFunctionPointerType()
+ const FunctionType *FT = Ty->isFunctionPointerType()
? Ty->getAs<PointerType>()->getPointeeType()->getAsFunctionType()
: Ty->getAs<BlockPointerType>()->getPointeeType()->getAsFunctionType();
if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FT)) {
@@ -196,7 +195,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) {
assert(!Ty.isNull() && "DefaultFunctionArrayConversion - missing type");
if (Ty->isFunctionType())
- ImpCastExprToType(E, Context.getPointerType(Ty),
+ ImpCastExprToType(E, Context.getPointerType(Ty),
CastExpr::CK_FunctionToPointerDecay);
else if (Ty->isArrayType()) {
// In C90 mode, arrays only promote to pointers if the array expression is
@@ -218,14 +217,14 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) {
}
/// UsualUnaryConversions - Performs various conversions that are common to most
-/// operators (C99 6.3). The conversions of array and function types are
+/// operators (C99 6.3). The conversions of array and function types are
/// sometimes surpressed. For example, the array->pointer conversion doesn't
/// apply if the array is an argument to the sizeof or address (&) operators.
/// In these instances, this routine should *not* be called.
Expr *Sema::UsualUnaryConversions(Expr *&Expr) {
QualType Ty = Expr->getType();
assert(!Ty.isNull() && "UsualUnaryConversions - missing type");
-
+
// C99 6.3.1.1p2:
//
// The following may be used in an expression wherever an int or
@@ -255,17 +254,17 @@ Expr *Sema::UsualUnaryConversions(Expr *&Expr) {
}
/// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
-/// do not have a prototype. Arguments that have type float are promoted to
+/// do not have a prototype. Arguments that have type float are promoted to
/// double. All other argument types are converted by UsualUnaryConversions().
void Sema::DefaultArgumentPromotion(Expr *&Expr) {
QualType Ty = Expr->getType();
assert(!Ty.isNull() && "DefaultArgumentPromotion - missing type");
-
+
// If this is a 'float' (CVR qualified or typedef) promote to double.
if (const BuiltinType *BT = Ty->getAsBuiltinType())
if (BT->getKind() == BuiltinType::Float)
return ImpCastExprToType(Expr, Context.DoubleTy);
-
+
UsualUnaryConversions(Expr);
}
@@ -275,14 +274,14 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) {
/// completely illegal.
bool Sema::DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT) {
DefaultArgumentPromotion(Expr);
-
+
if (Expr->getType()->isObjCInterfaceType()) {
Diag(Expr->getLocStart(),
diag::err_cannot_pass_objc_interface_to_vararg)
<< Expr->getType() << CT;
return true;
}
-
+
if (!Expr->getType()->isPODType())
Diag(Expr->getLocStart(), diag::warn_cannot_pass_non_pod_arg_to_vararg)
<< Expr->getType() << CT;
@@ -293,7 +292,7 @@ bool Sema::DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT) {
/// UsualArithmeticConversions - Performs various conversions that are common to
/// binary operators (C99 6.3.1.8). If both operands aren't arithmetic, this
-/// routine returns the first non-arithmetic type found. The client is
+/// routine returns the first non-arithmetic type found. The client is
/// responsible for emitting appropriate error diagnostics.
/// FIXME: verify the conversion rules for "complex int" are consistent with
/// GCC.
@@ -304,11 +303,11 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr,
UsualUnaryConversions(rhsExpr);
- // For conversion purposes, we ignore any qualifiers.
+ // For conversion purposes, we ignore any qualifiers.
// For example, "const float" and "float" are equivalent.
QualType lhs =
Context.getCanonicalType(lhsExpr->getType()).getUnqualifiedType();
- QualType rhs =
+ QualType rhs =
Context.getCanonicalType(rhsExpr->getType()).getUnqualifiedType();
// If both types are identical, no conversion is needed.
@@ -372,9 +371,9 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks) {
StrTy = Context.getConstantArrayType(StrTy,
llvm::APInt(32, Literal.GetNumStringChars()+1),
ArrayType::Normal, 0);
-
+
// Pass &StringTokLocs[0], StringTokLocs.size() to factory!
- return Owned(StringLiteral::Create(Context, Literal.GetString(),
+ return Owned(StringLiteral::Create(Context, Literal.GetString(),
Literal.GetStringLength(),
Literal.AnyWide, StrTy,
&StringTokLocs[0],
@@ -395,7 +394,7 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
// we wanted to.
if (CurBlock->TheDecl == VD->getDeclContext())
return false;
-
+
// If this is an enum constant or function, it is constant, don't snapshot.
if (isa<EnumConstantDecl>(VD) || isa<FunctionDecl>(VD))
return false;
@@ -406,7 +405,7 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
if (const VarDecl *Var = dyn_cast<VarDecl>(VD))
if (!Var->hasLocalStorage())
return false;
-
+
// Blocks that have these can't be constant.
CurBlock->hasBlockDeclRefExprs = true;
@@ -420,15 +419,15 @@ static bool ShouldSnapshotBlockValueReference(BlockSemaInfo *CurBlock,
// having a reference outside it.
if (NextBlock->TheDecl == VD->getDeclContext())
break;
-
+
// Otherwise, the DeclRef from the inner block causes the outer one to need
// a snapshot as well.
NextBlock->hasBlockDeclRefExprs = true;
}
-
+
return true;
-}
-
+}
+
/// ActOnIdentifierExpr - The parser read an identifier in expression context,
@@ -454,35 +453,35 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
const CXXScopeSpec *SS) {
if (Context.getCanonicalType(Ty) == Context.UndeducedAutoTy) {
Diag(Loc,
- diag::err_auto_variable_cannot_appear_in_own_initializer)
+ diag::err_auto_variable_cannot_appear_in_own_initializer)
<< D->getDeclName();
return ExprError();
}
-
+
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) {
if (const FunctionDecl *FD = MD->getParent()->isLocalClass()) {
if (VD->hasLocalStorage() && VD->getDeclContext() != CurContext) {
- Diag(Loc, diag::err_reference_to_local_var_in_enclosing_function)
+ Diag(Loc, diag::err_reference_to_local_var_in_enclosing_function)
<< D->getIdentifier() << FD->getDeclName();
- Diag(D->getLocation(), diag::note_local_variable_declared_here)
+ Diag(D->getLocation(), diag::note_local_variable_declared_here)
<< D->getIdentifier();
return ExprError();
}
}
}
}
-
+
MarkDeclarationReferenced(Loc, D);
-
+
Expr *E;
if (SS && !SS->isEmpty()) {
- E = new (Context) QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent,
+ E = new (Context) QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent,
ValueDependent, SS->getRange(),
static_cast<NestedNameSpecifier *>(SS->getScopeRep()));
} else
E = new (Context) DeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent);
-
+
return Owned(E);
}
@@ -491,14 +490,14 @@ Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
/// is Record.
static Decl *getObjectForAnonymousRecordDecl(ASTContext &Context,
RecordDecl *Record) {
- assert(Record->isAnonymousStructOrUnion() &&
+ assert(Record->isAnonymousStructOrUnion() &&
"Record must be an anonymous struct or union!");
-
+
// FIXME: Once Decls are directly linked together, this will be an O(1)
// operation rather than a slow walk through DeclContext's vector (which
// itself will be eliminated). DeclGroups might make this even better.
DeclContext *Ctx = Record->getDeclContext();
- for (DeclContext::decl_iterator D = Ctx->decls_begin(),
+ for (DeclContext::decl_iterator D = Ctx->decls_begin(),
DEnd = Ctx->decls_end();
D != DEnd; ++D) {
if (*D == Record) {
@@ -547,7 +546,7 @@ VarDecl *Sema::BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
break;
}
Ctx = Ctx->getParent();
- } while (Ctx->isRecord() &&
+ } while (Ctx->isRecord() &&
cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion());
return BaseObject;
@@ -559,7 +558,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
Expr *BaseObjectExpr,
SourceLocation OpLoc) {
llvm::SmallVector<FieldDecl *, 4> AnonFields;
- VarDecl *BaseObject = BuildAnonymousStructUnionMemberPath(Field,
+ VarDecl *BaseObject = BuildAnonymousStructUnionMemberPath(Field,
AnonFields);
// Build the expression that refers to the base object, from
@@ -575,7 +574,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
MarkDeclarationReferenced(Loc, BaseObject);
BaseObjectExpr = new (Context) DeclRefExpr(BaseObject,BaseObject->getType(),
SourceLocation());
- ExtraQuals
+ ExtraQuals
= Context.getCanonicalType(BaseObject->getType()).getCVRQualifiers();
} else if (BaseObjectExpr) {
// The caller provided the base object expression. Determine
@@ -593,11 +592,11 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
// program our base object expression is "this".
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) {
if (!MD->isStatic()) {
- QualType AnonFieldType
+ QualType AnonFieldType
= Context.getTagDeclType(
cast<RecordDecl>(AnonFields.back()->getDeclContext()));
QualType ThisType = Context.getTagDeclType(MD->getParent());
- if ((Context.getCanonicalType(AnonFieldType)
+ if ((Context.getCanonicalType(AnonFieldType)
== Context.getCanonicalType(ThisType)) ||
IsDerivedFrom(ThisType, AnonFieldType)) {
// Our base object expression is "this".
@@ -612,7 +611,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
ExtraQuals = MD->getTypeQualifiers();
}
- if (!BaseObjectExpr)
+ if (!BaseObjectExpr)
return ExprError(Diag(Loc, diag::err_invalid_non_static_member_use)
<< Field->getDeclName());
}
@@ -626,7 +625,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
FI != FIEnd; ++FI) {
QualType MemberType = (*FI)->getType();
if (!(*FI)->isMutable()) {
- unsigned combinedQualifiers
+ unsigned combinedQualifiers
= MemberType.getCVRQualifiers() | ExtraQuals;
MemberType = MemberType.getQualifiedType(combinedQualifiers);
}
@@ -665,7 +664,7 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
Sema::OwningExprResult
Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
DeclarationName Name, bool HasTrailingLParen,
- const CXXScopeSpec *SS,
+ const CXXScopeSpec *SS,
bool isAddressOfOperand) {
// Could be enum-constant, value decl, instance variable, etc.
if (SS && SS->isInvalid())
@@ -678,7 +677,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// FIXME: Member of the current instantiation.
if (SS && isDependentScopeSpecifier(*SS)) {
return Owned(new (Context) UnresolvedDeclRefExpr(Name, Context.DependentTy,
- Loc, SS->getRange(),
+ Loc, SS->getRange(),
static_cast<NestedNameSpecifier *>(SS->getScopeRep()),
isAddressOfOperand));
}
@@ -692,7 +691,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
: SourceRange());
return ExprError();
}
-
+
NamedDecl *D = Lookup.getAsDecl();
// If this reference is in an Objective-C method, then ivar lookup happens as
@@ -701,8 +700,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
if (II && getCurMethodDecl()) {
// There are two cases to handle here. 1) scoped lookup could have failed,
// in which case we should look for an ivar. 2) scoped lookup could have
- // found a decl, but that decl is outside the current instance method (i.e.
- // a global variable). In these two cases, we do a lookup for an ivar with
+ // found a decl, but that decl is outside the current instance method (i.e.
+ // a global variable). In these two cases, we do a lookup for an ivar with
// this name, if the lookup sucedes, we replace it our current decl.
if (D == 0 || D->isDefinedOutsideFunctionOrMethod()) {
ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
@@ -711,12 +710,12 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// Check if referencing a field with __attribute__((deprecated)).
if (DiagnoseUseOfDecl(IV, Loc))
return ExprError();
-
+
// If we're referencing an invalid decl, just return this as a silent
// error node. The error diagnostic was already emitted on the decl.
if (IV->isInvalidDecl())
return ExprError();
-
+
bool IsClsMethod = getCurMethodDecl()->isClassMethod();
// If a class method attemps to use a free standing ivar, this is
// an error.
@@ -735,8 +734,8 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
OwningExprResult SelfExpr = ActOnIdentifierExpr(S, SourceLocation(),
II, false);
MarkDeclarationReferenced(Loc, IV);
- return Owned(new (Context)
- ObjCIvarRefExpr(IV, IV->getType(), Loc,
+ return Owned(new (Context)
+ ObjCIvarRefExpr(IV, IV->getType(), Loc,
SelfExpr.takeAs<Expr>(), true, true));
}
}
@@ -753,7 +752,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// Needed to implement property "super.method" notation.
if (D == 0 && II->isStr("super")) {
QualType T;
-
+
if (getCurMethodDecl()->isInstanceMethod())
T = Context.getObjCObjectPointerType(Context.getObjCInterfaceType(
getCurMethodDecl()->getClassInterface()));
@@ -765,7 +764,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// Determine whether this name might be a candidate for
// argument-dependent lookup.
- bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) &&
+ bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) &&
HasTrailingLParen;
if (ADL && D == 0) {
@@ -791,7 +790,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// If this name wasn't predeclared and if this is not a function call,
// diagnose the problem.
if (SS && !SS->isEmpty()) {
- DiagnoseMissingMember(Loc, Name,
+ DiagnoseMissingMember(Loc, Name,
(NestedNameSpecifier *)SS->getScopeRep(),
SS->getRange());
return ExprError();
@@ -803,18 +802,18 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
return ExprError(Diag(Loc, diag::err_undeclared_var_use) << Name);
}
}
-
+
if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
// Warn about constructs like:
// if (void *X = foo()) { ... } else { X }.
// In the else block, the pointer is always false.
-
+
// FIXME: In a template instantiation, we don't have scope
// information to check this property.
if (Var->isDeclaredInCondition() && Var->getType()->isScalarType()) {
Scope *CheckS = S;
while (CheckS) {
- if (CheckS->isWithinElse() &&
+ if (CheckS->isWithinElse() &&
CheckS->getControlParent()->isDeclScope(DeclPtrTy::make(Var))) {
if (Var->getType()->isBooleanType())
ExprError(Diag(Loc, diag::warn_value_always_false)
@@ -824,7 +823,7 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
<< Var->getDeclName());
break;
}
-
+
// Move up one more control parent to check again.
CheckS = CheckS->getControlParent();
if (CheckS)
@@ -848,16 +847,16 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
return BuildDeclRefExpr(Func, NoProtoType, Loc, false, false, SS);
}
}
-
+
return BuildDeclarationNameExpr(Loc, D, HasTrailingLParen, SS, isAddressOfOperand);
}
/// \brief Cast member's object to its own class if necessary.
bool
Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
if (FieldDecl *FD = dyn_cast<FieldDecl>(Member))
- if (CXXRecordDecl *RD =
+ if (CXXRecordDecl *RD =
dyn_cast<CXXRecordDecl>(FD->getDeclContext())) {
- QualType DestType =
+ QualType DestType =
Context.getCanonicalType(Context.getTypeDeclType(RD));
if (DestType->isDependentType() || From->getType()->isDependentType())
return false;
@@ -880,17 +879,17 @@ Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
}
/// \brief Build a MemberExpr AST node.
-static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow,
- const CXXScopeSpec *SS, NamedDecl *Member,
+static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow,
+ const CXXScopeSpec *SS, NamedDecl *Member,
SourceLocation Loc, QualType Ty) {
if (SS && SS->isSet())
- return MemberExpr::Create(C, Base, isArrow,
+ return MemberExpr::Create(C, Base, isArrow,
(NestedNameSpecifier *)SS->getScopeRep(),
- SS->getRange(), Member, Loc,
+ SS->getRange(), Member, Loc,
// FIXME: Explicit template argument lists
false, SourceLocation(), 0, 0, SourceLocation(),
Ty);
-
+
return new (C) MemberExpr(Base, isArrow, Member, Loc, Ty);
}
@@ -898,11 +897,11 @@ static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow,
Sema::OwningExprResult
Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
bool HasTrailingLParen,
- const CXXScopeSpec *SS,
+ const CXXScopeSpec *SS,
bool isAddressOfOperand) {
assert(D && "Cannot refer to a NULL declaration");
DeclarationName Name = D->getDeclName();
-
+
// If this is an expression of the form &Class::member, don't build an
// implicit member ref, because we want a pointer to the member in general,
// not any specific instance's member.
@@ -935,7 +934,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) {
if (!MD->isStatic()) {
- // C++ [class.mfct.nonstatic]p2:
+ // C++ [class.mfct.nonstatic]p2:
// [...] if name lookup (3.4.1) resolves the name in the
// id-expression to a nonstatic nontype member of class X or of
// a base class of X, the id-expression is transformed into a
@@ -950,7 +949,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
if (const ReferenceType *RefType = MemberType->getAs<ReferenceType>())
MemberType = RefType->getPointeeType();
else if (!FD->isMutable()) {
- unsigned combinedQualifiers
+ unsigned combinedQualifiers
= MemberType.getCVRQualifiers() | MD->getTypeQualifiers();
MemberType = MemberType.getQualifiedType(combinedQualifiers);
}
@@ -959,25 +958,25 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
Ctx = Method->getParent();
MemberType = Method->getType();
}
- } else if (FunctionTemplateDecl *FunTmpl
+ } else if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>(D)) {
- if (CXXMethodDecl *Method
+ if (CXXMethodDecl *Method
= dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl())) {
- if (!Method->isStatic()) {
+ if (!Method->isStatic()) {
Ctx = Method->getParent();
MemberType = Context.OverloadTy;
}
}
- } else if (OverloadedFunctionDecl *Ovl
+ } else if (OverloadedFunctionDecl *Ovl
= dyn_cast<OverloadedFunctionDecl>(D)) {
// FIXME: We need an abstraction for iterating over one or more function
// templates or functions. This code is far too repetitive!
- for (OverloadedFunctionDecl::function_iterator
+ for (OverloadedFunctionDecl::function_iterator
Func = Ovl->function_begin(),
FuncEnd = Ovl->function_end();
Func != FuncEnd; ++Func) {
CXXMethodDecl *DMethod = 0;
- if (FunctionTemplateDecl *FunTmpl
+ if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>(*Func))
DMethod = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
else
@@ -994,7 +993,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
if (Ctx && Ctx->isRecord()) {
QualType CtxType = Context.getTagDeclType(cast<CXXRecordDecl>(Ctx));
QualType ThisType = Context.getTagDeclType(MD->getParent());
- if ((Context.getCanonicalType(CtxType)
+ if ((Context.getCanonicalType(CtxType)
== Context.getCanonicalType(ThisType)) ||
IsDerivedFrom(ThisType, CtxType)) {
// Build the implicit member access expression.
@@ -1042,8 +1041,8 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
return BuildDeclRefExpr(Template, Context.OverloadTy, Loc,
false, false, SS);
else if (UnresolvedUsingDecl *UD = dyn_cast<UnresolvedUsingDecl>(D))
- return BuildDeclRefExpr(UD, Context.DependentTy, Loc,
- /*TypeDependent=*/true,
+ return BuildDeclRefExpr(UD, Context.DependentTy, Loc,
+ /*TypeDependent=*/true,
/*ValueDependent=*/true, SS);
ValueDecl *VD = cast<ValueDecl>(D);
@@ -1052,7 +1051,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
// this check when we're going to perform argument-dependent lookup
// on this function name, because this might not be the function
// that overload resolution actually selects.
- bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) &&
+ bool ADL = getLangOptions().CPlusPlus && (!SS || !SS->isSet()) &&
HasTrailingLParen;
if (!(ADL && isa<FunctionDecl>(VD)) && DiagnoseUseOfDecl(VD, Loc))
return ExprError();
@@ -1078,9 +1077,9 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
// This is to record that a 'const' was actually synthesize and added.
bool constAdded = !ExprTy.isConstQualified();
// Variable will be bound by-copy, make it const within the closure.
-
+
ExprTy.addConst();
- return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false,
+ return Owned(new (Context) BlockDeclRefExpr(VD, ExprTy, Loc, false,
constAdded));
}
// If this reference is not in a block or if the referenced variable is
@@ -1090,7 +1089,7 @@ Sema::BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D,
bool ValueDependent = false;
if (getLangOptions().CPlusPlus) {
// C++ [temp.dep.expr]p3:
- // An id-expression is type-dependent if it contains:
+ // An id-expression is type-dependent if it contains:
// - an identifier that was declared with a dependent type,
if (VD->getType()->isDependentType())
TypeDependent = true;
@@ -1151,7 +1150,7 @@ Sema::OwningExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,
// Pre-defined identifiers are of type char[x], where x is the length of the
// string.
-
+
Decl *currentDecl = getCurFunctionOrMethodDecl();
if (!currentDecl) {
Diag(Loc, diag::ext_predef_outside_function);
@@ -1203,7 +1202,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
// Get the spelling of the token, which eliminates trigraphs, etc.
unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin);
- NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
+ NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
Tok.getLocation(), PP);
if (Literal.hadError)
return ExprError();
@@ -1316,7 +1315,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
// If this is an imaginary literal, create the ImaginaryLiteral wrapper.
if (Literal.isImaginary)
- Res = new (Context) ImaginaryLiteral(Res,
+ Res = new (Context) ImaginaryLiteral(Res,
Context.getComplexType(Res->getType()));
return Owned(Res);
@@ -1345,27 +1344,27 @@ bool Sema::CheckSizeOfAlignOfOperand(QualType exprType,
Diag(OpLoc, diag::ext_sizeof_function_type) << ExprRange;
return false;
}
-
+
// Allow sizeof(void)/alignof(void) as an extension.
if (exprType->isVoidType()) {
Diag(OpLoc, diag::ext_sizeof_void_type)
<< (isSizeof ? "sizeof" : "__alignof") << ExprRange;
return false;
}
-
+
if (RequireCompleteType(OpLoc, exprType,
- isSizeof ? diag::err_sizeof_incomplete_type :
+ isSizeof ? diag::err_sizeof_incomplete_type :
PDiag(diag::err_alignof_incomplete_type)
<< ExprRange))
return true;
-
+
// Reject sizeof(interface) and sizeof(interface<proto>) in 64-bit mode.
if (LangOpts.ObjCNonFragileABI && exprType->isObjCInterfaceType()) {
Diag(OpLoc, diag::err_sizeof_nonfragile_interface)
<< exprType << isSizeof << ExprRange;
return true;
}
-
+
return false;
}
@@ -1373,7 +1372,7 @@ bool Sema::CheckAlignOfExpr(Expr *E, SourceLocation OpLoc,
const SourceRange &ExprRange) {
E = E->IgnoreParens();
- // alignof decl is always ok.
+ // alignof decl is always ok.
if (isa<DeclRefExpr>(E))
return false;
@@ -1396,8 +1395,8 @@ bool Sema::CheckAlignOfExpr(Expr *E, SourceLocation OpLoc,
}
/// \brief Build a sizeof or alignof expression given a type operand.
-Action::OwningExprResult
-Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
+Action::OwningExprResult
+Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
bool isSizeOf, SourceRange R) {
if (T.isNull())
return ExprError();
@@ -1414,8 +1413,8 @@ Sema::CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc,
/// \brief Build a sizeof or alignof expression given an expression
/// operand.
-Action::OwningExprResult
-Sema::CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
+Action::OwningExprResult
+Sema::CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
bool isSizeOf, SourceRange R) {
// Verify that the operand is valid.
bool isInvalid = false;
@@ -1452,7 +1451,7 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
// FIXME: Preserve type source info.
QualType ArgTy = GetTypeFromParser(TyOrEx);
return CreateSizeOfAlignOfExpr(ArgTy, OpLoc, isSizeof, ArgRange);
- }
+ }
// Get the end location.
Expr *ArgEx = (Expr *)TyOrEx;
@@ -1468,15 +1467,15 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) {
if (V->isTypeDependent())
return Context.DependentTy;
-
+
// These operators return the element type of a complex type.
if (const ComplexType *CT = V->getType()->getAsComplexType())
return CT->getElementType();
-
+
// Otherwise they pass through real integer and floating point types here.
if (V->getType()->isArithmeticType())
return V->getType();
-
+
// Reject anything else.
Diag(Loc, diag::err_realimag_invalid_type) << V->getType()
<< (isReal ? "__real" : "__imag");
@@ -1514,9 +1513,9 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
// for objects of that type. When the postfix increment is
// called as a result of using the ++ operator, the int
// argument will have value zero.
- Expr *Args[2] = {
- Arg,
- new (Context) IntegerLiteral(llvm::APInt(Context.Target.getIntWidth(), 0,
+ Expr *Args[2] = {
+ Arg,
+ new (Context) IntegerLiteral(llvm::APInt(Context.Target.getIntWidth(), 0,
/*isSigned=*/true), Context.IntTy, SourceLocation())
};
@@ -1560,7 +1559,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
Input.release();
Args[0] = Arg;
return Owned(new (Context) CXXOperatorCallExpr(Context, OverOp, FnExpr,
- Args, 2, ResultTy,
+ Args, 2, ResultTy,
OpLoc));
} else {
// We matched a built-in operator. Convert the arguments, then
@@ -1613,7 +1612,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
Expr *LHSExp = static_cast<Expr*>(Base.get()),
*RHSExp = static_cast<Expr*>(Idx.get());
-
+
if (getLangOptions().CPlusPlus &&
(LHSExp->isTypeDependent() || RHSExp->isTypeDependent())) {
Base.release();
@@ -1622,12 +1621,12 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
Context.DependentTy, RLoc));
}
- if (getLangOptions().CPlusPlus &&
+ if (getLangOptions().CPlusPlus &&
(LHSExp->getType()->isRecordType() ||
LHSExp->getType()->isEnumeralType() ||
RHSExp->getType()->isRecordType() ||
RHSExp->getType()->isEnumeralType())) {
- // Add the appropriate overloaded operators (C++ [over.match.oper])
+ // Add the appropriate overloaded operators (C++ [over.match.oper])
// to the candidate set.
OverloadCandidateSet CandidateSet;
Expr *Args[2] = { LHSExp, RHSExp };
@@ -1648,7 +1647,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
if (PerformObjectArgumentInitialization(LHSExp, Method) ||
- PerformCopyInitialization(RHSExp,
+ PerformCopyInitialization(RHSExp,
FnDecl->getParamDecl(0)->getType(),
"passing"))
return ExprError();
@@ -1678,7 +1677,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
Args[0] = LHSExp;
Args[1] = RHSExp;
return Owned(new (Context) CXXOperatorCallExpr(Context, OO_Subscript,
- FnExpr, Args, 2,
+ FnExpr, Args, 2,
ResultTy, LLoc));
} else {
// We matched a built-in operator. Convert the arguments, then
@@ -1745,12 +1744,12 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
BaseExpr = RHSExp;
IndexExpr = LHSExp;
ResultType = PTy->getPointeeType();
- } else if (const ObjCObjectPointerType *PTy =
+ } else if (const ObjCObjectPointerType *PTy =
LHSTy->getAsObjCObjectPointerType()) {
BaseExpr = LHSExp;
IndexExpr = RHSExp;
ResultType = PTy->getPointeeType();
- } else if (const ObjCObjectPointerType *PTy =
+ } else if (const ObjCObjectPointerType *PTy =
RHSTy->getAsObjCObjectPointerType()) {
// Handle the uncommon case of "123[Ptr]".
BaseExpr = RHSExp;
@@ -1797,28 +1796,28 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
<< IndexExpr->getSourceRange());
// C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,
- // C++ [expr.sub]p1: The type "T" shall be a completely-defined object
- // type. Note that Functions are not objects, and that (in C99 parlance)
+ // C++ [expr.sub]p1: The type "T" shall be a completely-defined object
+ // type. Note that Functions are not objects, and that (in C99 parlance)
// incomplete types are not object types.
if (ResultType->isFunctionType()) {
Diag(BaseExpr->getLocStart(), diag::err_subscript_function_type)
<< ResultType << BaseExpr->getSourceRange();
return ExprError();
}
-
+
if (!ResultType->isDependentType() &&
- RequireCompleteType(LLoc, ResultType,
+ RequireCompleteType(LLoc, ResultType,
PDiag(diag::err_subscript_incomplete_type)
<< BaseExpr->getSourceRange()))
return ExprError();
-
+
// Diagnose bad cases where we step over interface counts.
if (ResultType->isObjCInterfaceType() && LangOpts.ObjCNonFragileABI) {
Diag(LLoc, diag::err_subscript_nonfragile_interface)
<< ResultType << BaseExpr->getSourceRange();
return ExprError();
}
-
+
Base.release();
Idx.release();
return Owned(new (Context) ArraySubscriptExpr(LHSExp, RHSExp,
@@ -1827,7 +1826,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
QualType Sema::
CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
- const IdentifierInfo *CompName,
+ const IdentifierInfo *CompName,
SourceLocation CompLoc) {
const ExtVectorType *vecType = baseType->getAsExtVectorType();
@@ -1918,15 +1917,15 @@ static Decl *FindGetterNameDeclFromProtocolList(const ObjCProtocolDecl*PDecl,
IdentifierInfo *Member,
const Selector &Sel,
ASTContext &Context) {
-
+
if (ObjCPropertyDecl *PD = PDecl->FindPropertyDeclaration(Member))
return PD;
if (ObjCMethodDecl *OMD = PDecl->getInstanceMethod(Sel))
return OMD;
-
+
for (ObjCProtocolDecl::protocol_iterator I = PDecl->protocol_begin(),
E = PDecl->protocol_end(); I != E; ++I) {
- if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel,
+ if (Decl *D = FindGetterNameDeclFromProtocolList(*I, Member, Sel,
Context))
return D;
}
@@ -1972,16 +1971,16 @@ ObjCMethodDecl *Sema::FindMethodInNestedImplementations(
ObjCMethodDecl *Method = 0;
if (ObjCImplementationDecl *ImpDecl = IFace->getImplementation())
Method = ImpDecl->getInstanceMethod(Sel);
-
+
if (!Method && IFace->getSuperClass())
return FindMethodInNestedImplementations(IFace->getSuperClass(), Sel);
return Method;
}
-
-Action::OwningExprResult
+
+Action::OwningExprResult
Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind, SourceLocation MemberLoc,
- DeclarationName MemberName,
+ DeclarationName MemberName,
bool HasExplicitTemplateArgs,
SourceLocation LAngleLoc,
const TemplateArgument *ExplicitTemplateArgs,
@@ -1997,7 +1996,7 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
Expr *BaseExpr = Base.takeAs<Expr>();
assert(BaseExpr && "no base expression");
-
+
// Perform default conversions.
DefaultFunctionArrayConversion(BaseExpr);
@@ -2028,8 +2027,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
if (!FirstQualifierInScope)
FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier);
}
-
- return Owned(CXXUnresolvedMemberExpr::Create(Context, BaseExpr, true,
+
+ return Owned(CXXUnresolvedMemberExpr::Create(Context, BaseExpr, true,
OpLoc, Qualifier,
SS? SS->getRange() : SourceRange(),
FirstQualifierInScope,
@@ -2051,17 +2050,17 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
<< BaseType << BaseExpr->getSourceRange());
} else {
if (BaseType->isDependentType()) {
- // Require that the base type isn't a pointer type
+ // Require that the base type isn't a pointer type
// (so we'll report an error for)
// T* t;
// t.f;
- //
+ //
// In Obj-C++, however, the above expression is valid, since it could be
// accessing the 'f' property if T is an Obj-C interface. The extra check
// allows this, while still reporting an error if T is a struct pointer.
const PointerType *PT = BaseType->getAs<PointerType>();
- if (!PT || (getLangOptions().ObjC1 &&
+ if (!PT || (getLangOptions().ObjC1 &&
!PT->getPointeeType()->isRecordType())) {
NestedNameSpecifier *Qualifier = 0;
if (SS) {
@@ -2069,10 +2068,10 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
if (!FirstQualifierInScope)
FirstQualifierInScope = FindFirstQualifierInScope(S, Qualifier);
}
-
+
return Owned(CXXUnresolvedMemberExpr::Create(Context,
- BaseExpr, false,
- OpLoc,
+ BaseExpr, false,
+ OpLoc,
Qualifier,
SS? SS->getRange() : SourceRange(),
FirstQualifierInScope,
@@ -2101,8 +2100,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// If the member name was a qualified-id, look into the
// nested-name-specifier.
DC = computeDeclContext(*SS, false);
-
- // FIXME: If DC is not computable, we should build a
+
+ // FIXME: If DC is not computable, we should build a
// CXXUnresolvedMemberExpr.
assert(DC && "Cannot handle non-computable dependent contexts in lookup");
}
@@ -2119,22 +2118,22 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
BaseExpr->getSourceRange());
return ExprError();
}
-
+
if (SS && SS->isSet()) {
- QualType BaseTypeCanon
+ QualType BaseTypeCanon
= Context.getCanonicalType(BaseType).getUnqualifiedType();
- QualType MemberTypeCanon
+ QualType MemberTypeCanon
= Context.getCanonicalType(
Context.getTypeDeclType(
dyn_cast<TypeDecl>(Result.getAsDecl()->getDeclContext())));
-
+
if (BaseTypeCanon != MemberTypeCanon &&
!IsDerivedFrom(BaseTypeCanon, MemberTypeCanon))
return ExprError(Diag(SS->getBeginLoc(),
diag::err_not_direct_base_or_virtual)
<< MemberTypeCanon << BaseTypeCanon);
}
-
+
NamedDecl *MemberDecl = Result;
// If the decl being referenced had an error, return an error for this
@@ -2172,10 +2171,10 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
MarkDeclarationReferenced(MemberLoc, FD);
if (PerformObjectMemberConversion(BaseExpr, FD))
return ExprError();
- return Owned(BuildMemberExpr(Context, BaseExpr, OpKind == tok::arrow, SS,
+ return Owned(BuildMemberExpr(Context, BaseExpr, OpKind == tok::arrow, SS,
FD, MemberLoc, MemberType));
}
-
+
if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
MarkDeclarationReferenced(MemberLoc, MemberDecl);
return Owned(BuildMemberExpr(Context, BaseExpr, OpKind == tok::arrow, SS,
@@ -2188,19 +2187,19 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
MemberFn, MemberLoc,
MemberFn->getType()));
}
- if (FunctionTemplateDecl *FunTmpl
+ if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>(MemberDecl)) {
MarkDeclarationReferenced(MemberLoc, MemberDecl);
-
+
if (HasExplicitTemplateArgs)
- return Owned(MemberExpr::Create(Context, BaseExpr, OpKind == tok::arrow,
- (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
+ return Owned(MemberExpr::Create(Context, BaseExpr, OpKind == tok::arrow,
+ (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
SS? SS->getRange() : SourceRange(),
- FunTmpl, MemberLoc, true,
- LAngleLoc, ExplicitTemplateArgs,
- NumExplicitTemplateArgs, RAngleLoc,
+ FunTmpl, MemberLoc, true,
+ LAngleLoc, ExplicitTemplateArgs,
+ NumExplicitTemplateArgs, RAngleLoc,
Context.OverloadTy));
-
+
return Owned(BuildMemberExpr(Context, BaseExpr, OpKind == tok::arrow, SS,
FunTmpl, MemberLoc,
Context.OverloadTy));
@@ -2208,12 +2207,12 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
if (OverloadedFunctionDecl *Ovl
= dyn_cast<OverloadedFunctionDecl>(MemberDecl)) {
if (HasExplicitTemplateArgs)
- return Owned(MemberExpr::Create(Context, BaseExpr, OpKind == tok::arrow,
- (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
+ return Owned(MemberExpr::Create(Context, BaseExpr, OpKind == tok::arrow,
+ (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
SS? SS->getRange() : SourceRange(),
- Ovl, MemberLoc, true,
- LAngleLoc, ExplicitTemplateArgs,
- NumExplicitTemplateArgs, RAngleLoc,
+ Ovl, MemberLoc, true,
+ LAngleLoc, ExplicitTemplateArgs,
+ NumExplicitTemplateArgs, RAngleLoc,
Context.OverloadTy));
return Owned(BuildMemberExpr(Context, BaseExpr, OpKind == tok::arrow, SS,
@@ -2241,13 +2240,13 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// pseudo-destructor.
if (MemberName.getNameKind() == DeclarationName::CXXDestructorName) {
// C++ [expr.pseudo]p2:
- // The left hand side of the dot operator shall be of scalar type. The
- // left hand side of the arrow operator shall be of pointer to scalar
+ // The left hand side of the dot operator shall be of scalar type. The
+ // left hand side of the arrow operator shall be of pointer to scalar
// type.
if (!BaseType->isScalarType())
return Owned(Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
<< BaseType << BaseExpr->getSourceRange());
-
+
// [...] The type designated by the pseudo-destructor-name shall be the
// same as the object type.
if (!MemberName.getCXXNameType()->isDependentType() &&
@@ -2255,28 +2254,28 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
return Owned(Diag(OpLoc, diag::err_pseudo_dtor_type_mismatch)
<< BaseType << MemberName.getCXXNameType()
<< BaseExpr->getSourceRange() << SourceRange(MemberLoc));
-
- // [...] Furthermore, the two type-names in a pseudo-destructor-name of
+
+ // [...] Furthermore, the two type-names in a pseudo-destructor-name of
// the form
//
- // ::[opt] nested-name-specifier[opt] type-name :: ̃ type-name
- //
+ // ::[opt] nested-name-specifier[opt] type-name :: ̃ type-name
+ //
// shall designate the same scalar type.
//
// FIXME: DPG can't see any way to trigger this particular clause, so it
// isn't checked here.
-
+
// FIXME: We've lost the precise spelling of the type by going through
// DeclarationName. Can we do better?
return Owned(new (Context) CXXPseudoDestructorExpr(Context, BaseExpr,
- OpKind == tok::arrow,
+ OpKind == tok::arrow,
OpLoc,
- (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
+ (NestedNameSpecifier *)(SS? SS->getScopeRep() : 0),
SS? SS->getRange() : SourceRange(),
MemberName.getCXXNameType(),
MemberLoc));
}
-
+
// Handle properties on ObjC 'Class' types.
if (OpKind == tok::period && BaseType->isObjCClassType()) {
// Also must look for a getter name which uses property syntax.
@@ -2293,8 +2292,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
}
// If we found a getter then this may be a valid dot-reference, we
// will look for the matching setter, in case it is needed.
- Selector SetterSel =
- SelectorTable::constructSetterName(PP.getIdentifierTable(),
+ Selector SetterSel =
+ SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), Member);
ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
if (!Setter) {
@@ -2330,7 +2329,7 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
if ((OpKind == tok::arrow && BaseType->isObjCObjectPointerType()) ||
(OpKind == tok::period && BaseType->isObjCInterfaceType())) {
const ObjCObjectPointerType *OPT = BaseType->getAsObjCObjectPointerType();
- const ObjCInterfaceType *IFaceT =
+ const ObjCInterfaceType *IFaceT =
OPT ? OPT->getInterfaceType() : BaseType->getAsObjCInterfaceType();
if (IFaceT) {
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
@@ -2338,7 +2337,7 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
ObjCInterfaceDecl *IDecl = IFaceT->getDecl();
ObjCInterfaceDecl *ClassDeclared;
ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
-
+
if (IV) {
// If the decl being referenced had an error, return an error for this
// sub-expr without emitting another error, in order to avoid cascading
@@ -2362,22 +2361,22 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// need be passed down in the AST node and somehow calculated from the
// AST for a function decl.
Decl *ImplDecl = ObjCImpDecl.getAs<Decl>();
- if (ObjCImplementationDecl *IMPD =
+ if (ObjCImplementationDecl *IMPD =
dyn_cast<ObjCImplementationDecl>(ImplDecl))
ClassOfMethodDecl = IMPD->getClassInterface();
else if (ObjCCategoryImplDecl* CatImplClass =
dyn_cast<ObjCCategoryImplDecl>(ImplDecl))
ClassOfMethodDecl = CatImplClass->getClassInterface();
}
-
- if (IV->getAccessControl() == ObjCIvarDecl::Private) {
- if (ClassDeclared != IDecl ||
+
+ if (IV->getAccessControl() == ObjCIvarDecl::Private) {
+ if (ClassDeclared != IDecl ||
ClassOfMethodDecl != ClassDeclared)
- Diag(MemberLoc, diag::error_private_ivar_access)
+ Diag(MemberLoc, diag::error_private_ivar_access)
<< IV->getDeclName();
} else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
// @protected
- Diag(MemberLoc, diag::error_protected_ivar_access)
+ Diag(MemberLoc, diag::error_protected_ivar_access)
<< IV->getDeclName();
}
@@ -2391,11 +2390,11 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
}
}
// Handle properties on 'id' and qualified "id".
- if (OpKind == tok::period && (BaseType->isObjCIdType() ||
+ if (OpKind == tok::period && (BaseType->isObjCIdType() ||
BaseType->isObjCQualifiedIdType())) {
const ObjCObjectPointerType *QIdTy = BaseType->getAsObjCObjectPointerType();
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
-
+
// Check protocols on qualified interfaces.
Selector Sel = PP.getSelectorTable().getNullarySelector(Member);
if (Decl *PMDecl = FindGetterNameDecl(QIdTy, Member, Sel, Context)) {
@@ -2403,7 +2402,7 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// Check the use of this declaration
if (DiagnoseUseOfDecl(PD, MemberLoc))
return ExprError();
-
+
return Owned(new (Context) ObjCPropertyRefExpr(PD, PD->getType(),
MemberLoc, BaseExpr));
}
@@ -2411,10 +2410,10 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// Check the use of this method.
if (DiagnoseUseOfDecl(OMD, MemberLoc))
return ExprError();
-
+
return Owned(new (Context) ObjCMessageExpr(BaseExpr, Sel,
- OMD->getResultType(),
- OMD, OpLoc, MemberLoc,
+ OMD->getResultType(),
+ OMD, OpLoc, MemberLoc,
NULL, 0));
}
}
@@ -2425,12 +2424,12 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// Handle Objective-C property access, which is "Obj.property" where Obj is a
// pointer to a (potentially qualified) interface type.
const ObjCObjectPointerType *OPT;
- if (OpKind == tok::period &&
+ if (OpKind == tok::period &&
(OPT = BaseType->getAsObjCInterfacePointerType())) {
const ObjCInterfaceType *IFaceT = OPT->getInterfaceType();
ObjCInterfaceDecl *IFace = IFaceT->getDecl();
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
-
+
// Search for a declared property first.
if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(Member)) {
// Check whether we can reference this property.
@@ -2488,8 +2487,8 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
}
// If we found a getter then this may be a valid dot-reference, we
// will look for the matching setter, in case it is needed.
- Selector SetterSel =
- SelectorTable::constructSetterName(PP.getIdentifierTable(),
+ Selector SetterSel =
+ SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), Member);
ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
if (!Setter) {
@@ -2519,9 +2518,9 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
return ExprError(Diag(MemberLoc, diag::err_property_not_found)
<< MemberName << BaseType);
}
-
+
// Handle the following exceptional case (*Obj).isa.
- if (OpKind == tok::period &&
+ if (OpKind == tok::period &&
BaseType->isSpecificBuiltinType(BuiltinType::ObjCId) &&
MemberName.getAsIdentifierInfo()->isStr("isa"))
return Owned(new (Context) ObjCIsaExpr(BaseExpr, false, MemberLoc,
@@ -2543,9 +2542,9 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
// If the user is trying to apply -> or . to a function or function
// pointer, it's probably because they forgot parentheses to call
// the function. Suggest the addition of those parentheses.
- if (BaseType == Context.OverloadTy ||
+ if (BaseType == Context.OverloadTy ||
BaseType->isFunctionType() ||
- (BaseType->isPointerType() &&
+ (BaseType->isPointerType() &&
BaseType->getAs<PointerType>()->isFunctionType())) {
SourceLocation Loc = PP.getLocForEndOfToken(BaseExpr->getLocEnd());
Diag(Loc, diag::note_member_reference_needs_call)
@@ -2560,7 +2559,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind, SourceLocation MemberLoc,
IdentifierInfo &Member,
DeclPtrTy ObjCImpDecl, const CXXScopeSpec *SS) {
- return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, MemberLoc,
+ return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, MemberLoc,
DeclarationName(&Member), ObjCImpDecl, SS);
}
@@ -2571,7 +2570,7 @@ Sema::OwningExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
Diag (CallLoc,
diag::err_use_of_default_argument_to_function_declared_later) <<
FD << cast<CXXRecordDecl>(FD->getDeclContext())->getDeclName();
- Diag(UnparsedDefaultArgLocs[Param],
+ Diag(UnparsedDefaultArgLocs[Param],
diag::note_default_argument_declared_here);
} else {
if (Param->hasUninstantiatedDefaultArg()) {
@@ -2580,28 +2579,28 @@ Sema::OwningExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
// Instantiate the expression.
MultiLevelTemplateArgumentList ArgList = getTemplateInstantiationArgs(FD);
- InstantiatingTemplate Inst(*this, CallLoc, Param,
- ArgList.getInnermost().getFlatArgumentList(),
+ InstantiatingTemplate Inst(*this, CallLoc, Param,
+ ArgList.getInnermost().getFlatArgumentList(),
ArgList.getInnermost().flat_size());
OwningExprResult Result = SubstExpr(UninstExpr, ArgList);
- if (Result.isInvalid())
+ if (Result.isInvalid())
return ExprError();
-
- if (SetParamDefaultArgument(Param, move(Result),
+
+ if (SetParamDefaultArgument(Param, move(Result),
/*FIXME:EqualLoc*/
UninstExpr->getSourceRange().getBegin()))
return ExprError();
}
-
+
Expr *DefaultExpr = Param->getDefaultArg();
-
+
// If the default expression creates temporaries, we need to
// push them to the current stack of expression temporaries so they'll
// be properly destroyed.
- if (CXXExprWithTemporaries *E
+ if (CXXExprWithTemporaries *E
= dyn_cast_or_null<CXXExprWithTemporaries>(DefaultExpr)) {
- assert(!E->shouldDestroyTemporaries() &&
+ assert(!E->shouldDestroyTemporaries() &&
"Can't destroy temporaries in a default argument expr!");
for (unsigned I = 0, N = E->getNumTemporaries(); I != N; ++I)
ExprTemporaries.push_back(E->getTemporary(I));
@@ -2676,16 +2675,16 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
return true;
} else {
ParmVarDecl *Param = FDecl->getParamDecl(i);
-
- OwningExprResult ArgExpr =
+
+ OwningExprResult ArgExpr =
BuildCXXDefaultArgExpr(Call->getSourceRange().getBegin(),
FDecl, Param);
if (ArgExpr.isInvalid())
return true;
-
+
Arg = ArgExpr.takeAs<Expr>();
}
-
+
Call->setArg(i, Arg);
}
@@ -2719,14 +2718,14 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
// Since this might be a postfix expression, get rid of ParenListExprs.
fn = MaybeConvertParenListExprToParenExpr(S, move(fn));
-
+
Expr *Fn = fn.takeAs<Expr>();
Expr **Args = reinterpret_cast<Expr**>(args.release());
assert(Fn && "no function call expression");
FunctionDecl *FDecl = NULL;
NamedDecl *NDecl = NULL;
DeclarationName UnqualifiedName;
-
+
if (getLangOptions().CPlusPlus) {
// If this is a pseudo-destructor expression, build the call immediately.
if (isa<CXXPseudoDestructorExpr>(Fn)) {
@@ -2736,17 +2735,17 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
<< CodeModificationHint::CreateRemoval(
SourceRange(Args[0]->getLocStart(),
Args[NumArgs-1]->getLocEnd()));
-
+
for (unsigned I = 0; I != NumArgs; ++I)
Args[I]->Destroy(Context);
-
+
NumArgs = 0;
}
-
+
return Owned(new (Context) CallExpr(Context, Fn, 0, 0, Context.VoidTy,
RParenLoc));
}
-
+
// Determine whether this is a dependent call inside a C++ template,
// in which case we won't do any semantic analysis now.
// FIXME: Will need to cache the results of name lookup (including ADL) in
@@ -2780,7 +2779,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
}
// If we're directly calling a function, get the appropriate declaration.
- // Also, in C++, keep track of whether we should perform argument-dependent
+ // Also, in C++, keep track of whether we should perform argument-dependent
// lookup and whether there were any explicitly-specified template arguments.
Expr *FnExpr = Fn;
bool ADL = true;
@@ -2808,7 +2807,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
= dyn_cast<UnresolvedFunctionNameExpr>(FnExpr)) {
UnqualifiedName = DepName->getName();
break;
- } else if (TemplateIdRefExpr *TemplateIdRef
+ } else if (TemplateIdRefExpr *TemplateIdRef
= dyn_cast<TemplateIdRefExpr>(FnExpr)) {
NDecl = TemplateIdRef->getTemplateName().getAsTemplateDecl();
if (!NDecl)
@@ -2816,17 +2815,17 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
HasExplicitTemplateArgs = true;
ExplicitTemplateArgs = TemplateIdRef->getTemplateArgs();
NumExplicitTemplateArgs = TemplateIdRef->getNumTemplateArgs();
-
+
// C++ [temp.arg.explicit]p6:
// [Note: For simple function names, argument dependent lookup (3.4.2)
- // applies even when the function name is not visible within the
+ // applies even when the function name is not visible within the
// scope of the call. This is because the call still has the syntactic
// form of a function call (3.4.1). But when a function template with
// explicit template arguments is used, the call does not have the
- // correct syntactic form unless there is a function template with
- // that name visible at the point of the call. If no such name is
- // visible, the call is not syntactically well-formed and
- // argument-dependent lookup does not apply. If some such name is
+ // correct syntactic form unless there is a function template with
+ // that name visible at the point of the call. If no such name is
+ // visible, the call is not syntactically well-formed and
+ // argument-dependent lookup does not apply. If some such name is
// visible, argument dependent lookup applies and additional function
// templates may be found in other namespaces.
//
@@ -2855,7 +2854,7 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
Ovl = dyn_cast<OverloadedFunctionDecl>(NDecl);
}
- if (Ovl || FunctionTemplate ||
+ if (Ovl || FunctionTemplate ||
(getLangOptions().CPlusPlus && (FDecl || UnqualifiedName))) {
// We don't perform ADL for implicit declarations of builtins.
if (FDecl && FDecl->getBuiltinID(Context) && FDecl->isImplicit())
@@ -2866,11 +2865,11 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
ADL = false;
if (Ovl || FunctionTemplate || ADL) {
- FDecl = ResolveOverloadedCallFn(Fn, NDecl, UnqualifiedName,
+ FDecl = ResolveOverloadedCallFn(Fn, NDecl, UnqualifiedName,
HasExplicitTemplateArgs,
ExplicitTemplateArgs,
NumExplicitTemplateArgs,
- LParenLoc, Args, NumArgs, CommaLocs,
+ LParenLoc, Args, NumArgs, CommaLocs,
RParenLoc, ADL);
if (!FDecl)
return ExprError();
@@ -2972,13 +2971,13 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
// Check for sentinels
if (NDecl)
DiagnoseSentinelCalls(NDecl, LParenLoc, Args, NumArgs);
-
+
// Do special checking on direct calls to functions.
if (FDecl) {
if (CheckFunctionCall(FDecl, TheCall.get()))
return ExprError();
-
- if (unsigned BuiltinID = FDecl->getBuiltinID(Context))
+
+ if (unsigned BuiltinID = FDecl->getBuiltinID(Context))
return CheckBuiltinFunctionCall(BuiltinID, TheCall.take());
} else if (NDecl) {
if (CheckBlockCall(NDecl, TheCall.get()))
@@ -3005,7 +3004,7 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
} else if (!literalType->isDependentType() &&
RequireCompleteType(LParenLoc, literalType,
PDiag(diag::err_typecheck_decl_incomplete_type)
- << SourceRange(LParenLoc,
+ << SourceRange(LParenLoc,
literalExpr->getSourceRange().getEnd())))
return ExprError();
@@ -3040,7 +3039,7 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg initlist,
/// CheckCastTypes - Check type constraints for casting between types.
bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr,
- CastExpr::CastKind& Kind,
+ CastExpr::CastKind& Kind,
CXXMethodDecl *& ConversionDecl,
bool FunctionalStyle) {
if (getLangOptions().CPlusPlus)
@@ -3137,7 +3136,7 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty) {
bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, QualType SrcTy) {
assert(DestTy->isExtVectorType() && "Not an extended vector type!");
-
+
// If SrcTy is a VectorType, the total size must match to explicitly cast to
// an ExtVectorType.
if (SrcTy->isVectorType()) {
@@ -3161,27 +3160,27 @@ Action::OwningExprResult
Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprArg Op) {
CastExpr::CastKind Kind = CastExpr::CK_Unknown;
-
+
assert((Ty != 0) && (Op.get() != 0) &&
"ActOnCastExpr(): missing type or expr");
Expr *castExpr = (Expr *)Op.get();
//FIXME: Preserve type source info.
QualType castType = GetTypeFromParser(Ty);
-
+
// If the Expr being casted is a ParenListExpr, handle it specially.
if (isa<ParenListExpr>(castExpr))
return ActOnCastOfParenListExpr(S, LParenLoc, RParenLoc, move(Op),castType);
CXXMethodDecl *ConversionDecl = 0;
- if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr,
+ if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr,
Kind, ConversionDecl))
return ExprError();
if (ConversionDecl) {
// encounterred a c-style cast requiring a conversion function.
if (CXXConversionDecl *CD = dyn_cast<CXXConversionDecl>(ConversionDecl)) {
- castExpr =
+ castExpr =
new (Context) CXXFunctionalCastExpr(castType.getNonReferenceType(),
- castType, LParenLoc,
+ castType, LParenLoc,
CastExpr::CK_UserDefinedConversion,
castExpr, CD,
RParenLoc);
@@ -3189,10 +3188,10 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
}
// FIXME. AST for when dealing with conversion functions (FunctionDecl).
}
-
+
Op.release();
return Owned(new (Context) CStyleCastExpr(castType.getNonReferenceType(),
- Kind, castExpr, castType,
+ Kind, castExpr, castType,
LParenLoc, RParenLoc));
}
@@ -3204,13 +3203,13 @@ Sema::MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg EA) {
ParenListExpr *E = dyn_cast<ParenListExpr>(expr);
if (!E)
return Owned(expr);
-
+
OwningExprResult Result(*this, E->getExpr(0));
-
+
for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i)
Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, move(Result),
Owned(E->getExpr(i)));
-
+
return ActOnParenExpr(E->getLParenLoc(), E->getRParenLoc(), move(Result));
}
@@ -3219,8 +3218,8 @@ Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
SourceLocation RParenLoc, ExprArg Op,
QualType Ty) {
ParenListExpr *PE = (ParenListExpr *)Op.get();
-
- // If this is an altivec initializer, '(' type ')' '(' init, ..., init ')'
+
+ // If this is an altivec initializer, '(' type ')' '(' init, ..., init ')'
// then handle it as such.
if (getLangOptions().AltiVec && Ty->isVectorType()) {
if (PE->getNumExprs() == 0) {
@@ -3235,13 +3234,13 @@ Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
// FIXME: This means that pretty-printing the final AST will produce curly
// braces instead of the original commas.
Op.release();
- InitListExpr *E = new (Context) InitListExpr(LParenLoc, &initExprs[0],
+ InitListExpr *E = new (Context) InitListExpr(LParenLoc, &initExprs[0],
initExprs.size(), RParenLoc);
E->setType(Ty);
- return ActOnCompoundLiteral(LParenLoc, Ty.getAsOpaquePtr(), RParenLoc,
+ return ActOnCompoundLiteral(LParenLoc, Ty.getAsOpaquePtr(), RParenLoc,
Owned(E));
} else {
- // This is not an AltiVec-style cast, so turn the ParenListExpr into a
+ // This is not an AltiVec-style cast, so turn the ParenListExpr into a
// sequence of BinOp comma operators.
Op = MaybeConvertParenListExprToParenExpr(S, move(Op));
return ActOnCastExpr(S, LParenLoc, Ty.getAsOpaquePtr(), RParenLoc,move(Op));
@@ -3357,7 +3356,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
if (!LHSTy->isBlockPointerType() || !RHSTy->isBlockPointerType()) {
if (LHSTy->isVoidPointerType() || RHSTy->isVoidPointerType()) {
QualType destType = Context.getPointerType(Context.VoidTy);
- ImpCastExprToType(LHS, destType);
+ ImpCastExprToType(LHS, destType);
ImpCastExprToType(RHS, destType);
return destType;
}
@@ -3393,7 +3392,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
}
// Check constraints for Objective-C object pointers types.
if (LHSTy->isObjCObjectPointerType() && RHSTy->isObjCObjectPointerType()) {
-
+
if (Context.getCanonicalType(LHSTy) == Context.getCanonicalType(RHSTy)) {
// Two identical object pointer types are always compatible.
return LHSTy;
@@ -3401,7 +3400,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
const ObjCObjectPointerType *LHSOPT = LHSTy->getAsObjCObjectPointerType();
const ObjCObjectPointerType *RHSOPT = RHSTy->getAsObjCObjectPointerType();
QualType compositeType = LHSTy;
-
+
// If both operands are interfaces and either operand can be
// assigned to the other, use that type as the composite
// type. This allows
@@ -3419,10 +3418,10 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
compositeType = RHSOPT->isObjCBuiltinType() ? RHSTy : LHSTy;
} else if (Context.canAssignObjCInterfaces(RHSOPT, LHSOPT)) {
compositeType = LHSOPT->isObjCBuiltinType() ? LHSTy : RHSTy;
- } else if ((LHSTy->isObjCQualifiedIdType() ||
+ } else if ((LHSTy->isObjCQualifiedIdType() ||
RHSTy->isObjCQualifiedIdType()) &&
Context.ObjCQualifiedIdTypesAreCompatible(LHSTy, RHSTy, true)) {
- // Need to handle "id<xx>" explicitly.
+ // Need to handle "id<xx>" explicitly.
// GCC allows qualified id and any Objective-C type to devolve to
// id. Currently localizing to here until clear this should be
// part of ObjCQualifiedIdTypesAreCompatible.
@@ -3512,7 +3511,7 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
ImpCastExprToType(RHS, LHSTy);
return LHSTy;
}
-
+
// GCC compatibility: soften pointer/integer mismatch.
if (RHSTy->isPointerType() && LHSTy->isIntegerType()) {
Diag(QuestionLoc, diag::warn_typecheck_cond_pointer_integer_mismatch)
@@ -3641,7 +3640,7 @@ Sema::CheckPointerTypesForAssignment(QualType lhsType, QualType rhsType) {
return IncompatiblePointerSign;
}
// General pointer incompatibility takes priority over qualifiers.
- return IncompatiblePointer;
+ return IncompatiblePointer;
}
return ConvTy;
}
@@ -3727,7 +3726,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
if (!rhsType->isVectorType() && rhsType->isArithmeticType())
return Compatible;
}
-
+
if (lhsType->isVectorType() || rhsType->isVectorType()) {
// If we are allowing lax vector conversions, and LHS and RHS are both
// vectors, the total size only needs to be the same. This is a bitcast;
@@ -3788,7 +3787,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
if (isa<ObjCObjectPointerType>(lhsType)) {
if (rhsType->isIntegerType())
return IntToPointer;
-
+
// In general, C pointers are not compatible with ObjC object pointers.
if (isa<PointerType>(rhsType)) {
if (rhsType->isVoidPointerType()) // an exception to the rule.
@@ -3858,7 +3857,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
/// \brief Constructs a transparent union from an expression that is
/// used to initialize the transparent union.
-static void ConstructTransparentUnion(ASTContext &C, Expr *&E,
+static void ConstructTransparentUnion(ASTContext &C, Expr *&E,
QualType UnionType, FieldDecl *Field) {
// Build an initializer list that designates the appropriate member
// of the transparent union.
@@ -3878,7 +3877,7 @@ Sema::AssignConvertType
Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) {
QualType FromType = rExpr->getType();
- // If the ArgType is a Union type, we want to handle a potential
+ // If the ArgType is a Union type, we want to handle a potential
// transparent_union GCC extension.
const RecordType *UT = ArgType->getAsUnionType();
if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>())
@@ -3901,7 +3900,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) {
InitField = *it;
break;
}
-
+
if (rExpr->isNullPointerConstant(Context)) {
ImpCastExprToType(rExpr, it->getType());
InitField = *it;
@@ -3942,8 +3941,8 @@ Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) {
// C99 6.5.16.1p1: the left operand is a pointer and the right is
// a null pointer constant.
- if ((lhsType->isPointerType() ||
- lhsType->isObjCObjectPointerType() ||
+ if ((lhsType->isPointerType() ||
+ lhsType->isObjCObjectPointerType() ||
lhsType->isBlockPointerType())
&& rExpr->isNullPointerConstant(Context)) {
ImpCastExprToType(rExpr, lhsType);
@@ -4014,7 +4013,7 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
std::swap(rex, lex);
std::swap(rhsType, lhsType);
}
-
+
// Handle the case of an ext vector and scalar.
if (const ExtVectorType *LV = lhsType->getAsExtVectorType()) {
QualType EltTy = LV->getElementType();
@@ -4034,7 +4033,7 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
}
}
}
-
+
// Vectors of different size or scalar and non-ext-vector are errors.
Diag(Loc, diag::err_typecheck_vector_not_convertable)
<< lex->getType() << rex->getType()
@@ -4043,8 +4042,7 @@ inline QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex,
}
inline QualType Sema::CheckMultiplyDivideOperands(
- Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign) {
if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
return CheckVectorOperands(Loc, lex, rex);
@@ -4056,8 +4054,7 @@ inline QualType Sema::CheckMultiplyDivideOperands(
}
inline QualType Sema::CheckRemainderOperands(
- Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign) {
if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) {
if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType())
return CheckVectorOperands(Loc, lex, rex);
@@ -4072,8 +4069,7 @@ inline QualType Sema::CheckRemainderOperands(
}
inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
- Expr *&lex, Expr *&rex, SourceLocation Loc, QualType* CompLHSTy)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc, QualType* CompLHSTy) {
if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) {
QualType compType = CheckVectorOperands(Loc, lex, rex);
if (CompLHSTy) *CompLHSTy = compType;
@@ -4095,10 +4091,10 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
std::swap(PExp, IExp);
if (PExp->getType()->isAnyPointerType()) {
-
+
if (IExp->getType()->isIntegerType()) {
QualType PointeeTy = PExp->getType()->getPointeeType();
-
+
// Check for arithmetic on pointers to incomplete types.
if (PointeeTy->isVoidType()) {
if (getLangOptions().CPlusPlus) {
@@ -4122,12 +4118,12 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
<< lex->getType() << lex->getSourceRange();
} else {
// Check if we require a complete type.
- if (((PExp->getType()->isPointerType() &&
+ if (((PExp->getType()->isPointerType() &&
!PExp->getType()->isDependentType()) ||
PExp->getType()->isObjCObjectPointerType()) &&
RequireCompleteType(Loc, PointeeTy,
- PDiag(diag::err_typecheck_arithmetic_incomplete_type)
- << PExp->getSourceRange()
+ PDiag(diag::err_typecheck_arithmetic_incomplete_type)
+ << PExp->getSourceRange()
<< PExp->getType()))
return QualType();
}
@@ -4137,7 +4133,7 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
<< PointeeTy << PExp->getSourceRange();
return QualType();
}
-
+
if (CompLHSTy) {
QualType LHSTy = Context.isPromotableBitField(lex);
if (LHSTy.isNull()) {
@@ -4173,7 +4169,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
if (CompLHSTy) *CompLHSTy = compType;
return compType;
}
-
+
// Either ptr - int or ptr - ptr.
if (lex->getType()->isAnyPointerType()) {
QualType lpointee = lex->getType()->getPointeeType();
@@ -4201,9 +4197,9 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
// GNU C extension: arithmetic on pointer to function
ComplainAboutFunc = lex;
} else if (!lpointee->isDependentType() &&
- RequireCompleteType(Loc, lpointee,
+ RequireCompleteType(Loc, lpointee,
PDiag(diag::err_typecheck_sub_ptr_object)
- << lex->getSourceRange()
+ << lex->getSourceRange()
<< lex->getType()))
return QualType();
@@ -4213,7 +4209,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
<< lpointee << lex->getSourceRange();
return QualType();
}
-
+
// The result type of a pointer-int computation is the pointer type.
if (rex->getType()->isIntegerType()) {
if (ComplainAboutVoid)
@@ -4221,7 +4217,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
<< lex->getSourceRange() << rex->getSourceRange();
if (ComplainAboutFunc)
Diag(Loc, diag::ext_gnu_ptr_func_arith)
- << ComplainAboutFunc->getType()
+ << ComplainAboutFunc->getType()
<< ComplainAboutFunc->getSourceRange();
if (CompLHSTy) *CompLHSTy = lex->getType();
@@ -4284,7 +4280,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
<< lex->getSourceRange() << rex->getSourceRange();
if (ComplainAboutFunc)
Diag(Loc, diag::ext_gnu_ptr_func_arith)
- << ComplainAboutFunc->getType()
+ << ComplainAboutFunc->getType()
<< ComplainAboutFunc->getSourceRange();
if (CompLHSTy) *CompLHSTy = lex->getType();
@@ -4356,7 +4352,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
// For non-floating point types, check for self-comparisons of the form
// x == x, x != x, x < x, etc. These always evaluate to a constant, and
// often indicate logic errors in the program.
- // NOTE: Don't warn about comparisons of enum constants. These can arise
+ // NOTE: Don't warn about comparisons of enum constants. These can arise
// from macro expansions, and are usually quite deliberate.
Expr *LHSStripped = lex->IgnoreParens();
Expr *RHSStripped = rex->IgnoreParens();
@@ -4365,12 +4361,12 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
if (DRL->getDecl() == DRR->getDecl() &&
!isa<EnumConstantDecl>(DRL->getDecl()))
Diag(Loc, diag::warn_selfcomparison);
-
+
if (isa<CastExpr>(LHSStripped))
LHSStripped = LHSStripped->IgnoreParenCasts();
if (isa<CastExpr>(RHSStripped))
RHSStripped = RHSStripped->IgnoreParenCasts();
-
+
// Warn about comparisons against a string constant (unless the other
// operand is null), the user probably wants strcmp.
Expr *literalString = 0;
@@ -4486,11 +4482,11 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
ImpCastExprToType(rex, lType); // promote the pointer to pointer
return ResultTy;
}
-
+
if (getLangOptions().CPlusPlus) {
- // Comparison of pointers with null pointer constants and equality
+ // Comparison of pointers with null pointer constants and equality
// comparisons of member pointers to null pointer constants.
- if (RHSIsNull &&
+ if (RHSIsNull &&
(lType->isPointerType() ||
(!isRelational && lType->isMemberPointerType()))) {
ImpCastExprToType(rex, lType, CastExpr::CK_NullToMemberPointer);
@@ -4504,17 +4500,17 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
}
// Comparison of member pointers.
- if (!isRelational &&
+ if (!isRelational &&
lType->isMemberPointerType() && rType->isMemberPointerType()) {
// C++ [expr.eq]p2:
- // In addition, pointers to members can be compared, or a pointer to
- // member and a null pointer constant. Pointer to member conversions
- // (4.11) and qualification conversions (4.4) are performed to bring
- // them to a common type. If one operand is a null pointer constant,
- // the common type is the type of the other operand. Otherwise, the
- // common type is a pointer to member type similar (4.4) to the type
- // of one of the operands, with a cv-qualification signature (4.4)
- // that is the union of the cv-qualification signatures of the operand
+ // In addition, pointers to members can be compared, or a pointer to
+ // member and a null pointer constant. Pointer to member conversions
+ // (4.11) and qualification conversions (4.4) are performed to bring
+ // them to a common type. If one operand is a null pointer constant,
+ // the common type is the type of the other operand. Otherwise, the
+ // common type is a pointer to member type similar (4.4) to the type
+ // of one of the operands, with a cv-qualification signature (4.4)
+ // that is the union of the cv-qualification signatures of the operand
// types.
QualType T = FindCompositePointerType(lex, rex);
if (T.isNull()) {
@@ -4522,17 +4518,17 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
return QualType();
}
-
+
ImpCastExprToType(lex, T);
ImpCastExprToType(rex, T);
return ResultTy;
}
-
+
// Comparison of nullptr_t with itself.
if (lType->isNullPtrType() && rType->isNullPtrType())
return ResultTy;
}
-
+
// Handle block pointer types.
if (!isRelational && lType->isBlockPointerType() && rType->isBlockPointerType()) {
QualType lpointee = lType->getAs<BlockPointerType>()->getPointeeType();
@@ -4596,7 +4592,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
else
DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
-
+
if (DiagID) {
Diag(Loc, DiagID)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4613,7 +4609,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
else
DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
-
+
if (DiagID) {
Diag(Loc, DiagID)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4686,8 +4682,7 @@ QualType Sema::CheckVectorCompareOperands(Expr *&lex, Expr *&rex,
}
inline QualType Sema::CheckBitwiseOperands(
- Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc, bool isCompAssign) {
if (lex->getType()->isVectorType() || rex->getType()->isVectorType())
return CheckVectorOperands(Loc, lex, rex);
@@ -4699,8 +4694,7 @@ inline QualType Sema::CheckBitwiseOperands(
}
inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14]
- Expr *&lex, Expr *&rex, SourceLocation Loc)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc) {
UsualUnaryConversions(lex);
UsualUnaryConversions(rex);
@@ -4713,13 +4707,12 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14]
/// is a read-only property; return true if so. A readonly property expression
/// depends on various declarations and thus must be treated specially.
///
-static bool IsReadonlyProperty(Expr *E, Sema &S)
-{
+static bool IsReadonlyProperty(Expr *E, Sema &S) {
if (E->getStmtClass() == Expr::ObjCPropertyRefExprClass) {
const ObjCPropertyRefExpr* PropExpr = cast<ObjCPropertyRefExpr>(E);
if (ObjCPropertyDecl *PDecl = PropExpr->getProperty()) {
QualType BaseType = PropExpr->getBase()->getType();
- if (const ObjCObjectPointerType *OPT =
+ if (const ObjCObjectPointerType *OPT =
BaseType->getAsObjCInterfacePointerType())
if (ObjCInterfaceDecl *IFace = OPT->getInterfaceDecl())
if (S.isPropertyReadonly(PDecl, IFace))
@@ -4733,7 +4726,7 @@ static bool IsReadonlyProperty(Expr *E, Sema &S)
/// emit an error and return true. If so, return false.
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
SourceLocation OrigLoc = Loc;
- Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
+ Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
&Loc);
if (IsLV == Expr::MLV_Valid && IsReadonlyProperty(E, S))
IsLV = Expr::MLV_ReadonlyProperty;
@@ -4784,7 +4777,7 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
if (NeedType)
S.Diag(Loc, Diag) << E->getType() << E->getSourceRange() << Assign;
else
- S.Diag(Loc, Diag) << E->getSourceRange() << Assign;
+ S.Diag(Loc, Diag) << E->getSourceRange() << Assign;
return true;
}
@@ -4886,7 +4879,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
// OK!
} else if (ResType->isAnyPointerType()) {
QualType PointeeTy = ResType->getPointeeType();
-
+
// C99 6.5.2.4p2, 6.5.6p2
if (PointeeTy->isVoidType()) {
if (getLangOptions().CPlusPlus) {
@@ -4908,7 +4901,7 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
<< ResType << Op->getSourceRange();
} else if (RequireCompleteType(OpLoc, PointeeTy,
PDiag(diag::err_typecheck_arithmetic_incomplete_type)
- << Op->getSourceRange()
+ << Op->getSourceRange()
<< ResType))
return QualType();
// Diagnose bad cases where we step over interface counts.
@@ -5064,12 +5057,12 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
DeclContext *Ctx = dcl->getDeclContext();
if (Ctx && Ctx->isRecord()) {
if (FD->getType()->isReferenceType()) {
- Diag(OpLoc,
+ Diag(OpLoc,
diag::err_cannot_form_pointer_to_member_of_reference_type)
<< FD->getDeclName() << FD->getType();
return QualType();
}
-
+
return Context.getMemberPointerType(op->getType(),
Context.getTypeDeclType(cast<RecordDecl>(Ctx)).getTypePtr());
}
@@ -5298,7 +5291,7 @@ Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
assert((rhs != 0) && "ActOnBinOp(): missing right expression");
if (getLangOptions().CPlusPlus &&
- (lhs->getType()->isOverloadableType() ||
+ (lhs->getType()->isOverloadableType() ||
rhs->getType()->isOverloadableType())) {
// Find all of the overloaded operators visible from this
// point. We perform both an operator-name lookup from the local
@@ -5310,7 +5303,7 @@ Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
LookupOverloadedOperatorName(OverOp, S, lhs->getType(), rhs->getType(),
Functions);
Expr *Args[2] = { lhs, rhs };
- DeclarationName OpName
+ DeclarationName OpName
= Context.DeclarationNames.getCXXOperatorName(OverOp);
ArgumentDependentLookup(OpName, Args, 2, Functions);
}
@@ -5325,7 +5318,7 @@ Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
}
Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
- unsigned OpcIn,
+ unsigned OpcIn,
ExprArg InputArg) {
UnaryOperator::Opcode Opc = static_cast<UnaryOperator::Opcode>(OpcIn);
@@ -5428,7 +5421,7 @@ Action::OwningExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
if (OverOp != OO_None) {
LookupOverloadedOperatorName(OverOp, S, Input->getType(), QualType(),
Functions);
- DeclarationName OpName
+ DeclarationName OpName
= Context.DeclarationNames.getCXXOperatorName(OverOp);
ArgumentDependentLookup(OpName, &Input, 1, Functions);
}
@@ -5533,7 +5526,7 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
if (!Dependent) {
bool DidWarnAboutNonPOD = false;
-
+
// FIXME: Dependent case loses a lot of information here. And probably
// leaks like a sieve.
for (unsigned i = 0; i != NumComponents; ++i) {
@@ -5583,7 +5576,7 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
DidWarnAboutNonPOD = true;
}
}
-
+
FieldDecl *MemberDecl
= dyn_cast_or_null<FieldDecl>(LookupQualifiedName(RD, OC.U.IdentInfo,
LookupMemberName)
@@ -5708,12 +5701,12 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
CurBlock->isVariadic = false;
// Check for a valid sentinel attribute on this block.
if (CurBlock->TheDecl->getAttr<SentinelAttr>()) {
- Diag(ParamInfo.getAttributes()->getLoc(),
+ Diag(ParamInfo.getAttributes()->getLoc(),
diag::warn_attribute_sentinel_not_variadic) << 1;
// FIXME: remove the attribute.
}
QualType RetTy = T.getTypePtr()->getAsFunctionType()->getResultType();
-
+
// Do not allow returning a objc interface by-value.
if (RetTy->isObjCInterfaceType()) {
Diag(ParamInfo.getSourceRange().getBegin(),
@@ -5755,17 +5748,17 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
PushOnScopeChains(*AI, CurBlock->TheScope);
// Check for a valid sentinel attribute on this block.
- if (!CurBlock->isVariadic &&
+ if (!CurBlock->isVariadic &&
CurBlock->TheDecl->getAttr<SentinelAttr>()) {
- Diag(ParamInfo.getAttributes()->getLoc(),
+ Diag(ParamInfo.getAttributes()->getLoc(),
diag::warn_attribute_sentinel_not_variadic) << 1;
// FIXME: remove the attribute.
}
-
+
// Analyze the return type.
QualType T = GetTypeForDeclarator(ParamInfo, CurScope);
QualType RetTy = T->getAsFunctionType()->getResultType();
-
+
// Do not allow returning a objc interface by-value.
if (RetTy->isObjCInterfaceType()) {
Diag(ParamInfo.getSourceRange().getBegin(),
@@ -5795,7 +5788,7 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
// If blocks are disabled, emit an error.
if (!LangOpts.Blocks)
Diag(CaretLoc, diag::err_blocks_disable);
-
+
// Ensure that CurBlock is deleted.
llvm::OwningPtr<BlockSemaInfo> BSI(CurBlock);
@@ -5830,7 +5823,7 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
if (CurFunctionNeedsScopeChecking)
DiagnoseInvalidJumps(static_cast<CompoundStmt*>(body.get()));
CurFunctionNeedsScopeChecking = BSI->SavedFunctionNeedsScopeChecking;
-
+
BSI->TheDecl->setBody(body.takeAs<CompoundStmt>());
CheckFallThroughForBlock(BlockTy, BSI->TheDecl->getBody());
return Owned(new (Context) BlockExpr(BSI->TheDecl, BlockTy,
@@ -5843,7 +5836,7 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
QualType T = GetTypeFromParser(type);
Expr *E = static_cast<Expr*>(expr.get());
Expr *OrigExpr = E;
-
+
InitBuiltinVaListType();
// Get the va_list type
@@ -5858,7 +5851,7 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
} else {
// Otherwise, the va_list argument must be an l-value because
// it is modified by va_arg.
- if (!E->isTypeDependent() &&
+ if (!E->isTypeDependent() &&
CheckForModifiableLvalue(E, BuiltinLoc, *this))
return ExprError();
}
@@ -5992,17 +5985,17 @@ bool Sema::VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result){
return false;
}
-Sema::ExpressionEvaluationContext
-Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext) {
+Sema::ExpressionEvaluationContext
+Sema::PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext) {
// Introduce a new set of potentially referenced declarations to the stack.
if (NewContext == PotentiallyPotentiallyEvaluated)
PotentiallyReferencedDeclStack.push_back(PotentiallyReferencedDecls());
-
+
std::swap(ExprEvalContext, NewContext);
return NewContext;
}
-void
+void
Sema::PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
ExpressionEvaluationContext NewContext) {
ExprEvalContext = NewContext;
@@ -6014,7 +6007,7 @@ Sema::PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
PotentiallyReferencedDecls RemainingDecls;
RemainingDecls.swap(PotentiallyReferencedDeclStack.back());
PotentiallyReferencedDeclStack.pop_back();
-
+
for (PotentiallyReferencedDecls::iterator I = RemainingDecls.begin(),
IEnd = RemainingDecls.end();
I != IEnd; ++I)
@@ -6034,30 +6027,30 @@ Sema::PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext,
/// \param D the declaration that has been referenced by the source code.
void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
assert(D && "No declaration?");
-
+
if (D->isUsed())
return;
-
+
// Mark a parameter declaration "used", regardless of whether we're in a
// template or not.
if (isa<ParmVarDecl>(D))
D->setUsed(true);
-
+
// Do not mark anything as "used" within a dependent context; wait for
// an instantiation.
if (CurContext->isDependentContext())
return;
-
+
switch (ExprEvalContext) {
case Unevaluated:
// We are in an expression that is not potentially evaluated; do nothing.
return;
-
+
case PotentiallyEvaluated:
// We are in a potentially-evaluated expression, so this declaration is
// "used"; handle this below.
break;
-
+
case PotentiallyPotentiallyEvaluated:
// We are in an expression that may be potentially evaluated; queue this
// declaration reference until we know whether the expression is
@@ -6065,14 +6058,14 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
PotentiallyReferencedDeclStack.back().push_back(std::make_pair(Loc, D));
return;
}
-
+
// Note that this declaration has been used.
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
unsigned TypeQuals;
if (Constructor->isImplicit() && Constructor->isDefaultConstructor()) {
if (!Constructor->isUsed())
DefineImplicitDefaultConstructor(Loc, Constructor);
- } else if (Constructor->isImplicit() &&
+ } else if (Constructor->isImplicit() &&
Constructor->isCopyConstructor(Context, TypeQuals)) {
if (!Constructor->isUsed())
DefineImplicitCopyConstructor(Loc, Constructor, TypeQuals);
@@ -6080,7 +6073,7 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
} else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
if (Destructor->isImplicit() && !Destructor->isUsed())
DefineImplicitDestructor(Loc, Destructor);
-
+
} else if (CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D)) {
if (MethodDecl->isImplicit() && MethodDecl->isOverloadedOperator() &&
MethodDecl->getOverloadedOperator() == OO_Equal) {
@@ -6089,7 +6082,7 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
}
}
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
- // Implicit instantiation of function templates and member functions of
+ // Implicit instantiation of function templates and member functions of
// class templates.
if (!Function->getBody()) {
// FIXME: distinguish between implicit instantiations of function
@@ -6099,21 +6092,21 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
Function->getPrimaryTemplate())
PendingImplicitInstantiations.push_back(std::make_pair(Function, Loc));
}
-
-
+
+
// FIXME: keep track of references to static functions
Function->setUsed(true);
return;
}
-
+
if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
// Implicit instantiation of static data members of class templates.
// FIXME: distinguish between implicit instantiations (which we need to
// actually instantiate) and explicit specializations.
- if (Var->isStaticDataMember() &&
+ if (Var->isStaticDataMember() &&
Var->getInstantiatedFromStaticDataMember())
PendingImplicitInstantiations.push_back(std::make_pair(Var, Loc));
-
+
// FIXME: keep track of references to static data?
D->setUsed(true);
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 12f60b99c6..3943ce103e 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -35,7 +35,7 @@ Sema::ActOnCXXConversionFunctionExpr(Scope *S, SourceLocation OperatorLoc,
//FIXME: Preserve type source info.
QualType ConvType = GetTypeFromParser(Ty);
CanQualType ConvTypeCanon = Context.getCanonicalType(ConvType);
- DeclarationName ConvName
+ DeclarationName ConvName
= Context.DeclarationNames.getCXXConversionFunctionName(ConvTypeCanon);
return ActOnDeclarationNameExpr(S, OperatorLoc, ConvName, HasTrailingLParen,
&SS, isAddressOfOperand);
@@ -79,10 +79,10 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
if (!isType) {
// C++0x [expr.typeid]p3:
- // When typeid is applied to an expression other than an lvalue of a
- // polymorphic class type [...] [the] expression is an unevaluated
+ // When typeid is applied to an expression other than an lvalue of a
+ // polymorphic class type [...] [the] expression is an unevaluated
// operand.
-
+
// FIXME: if the type of the expression is a class type, the class
// shall be completely defined.
bool isUnevaluatedOperand = true;
@@ -95,13 +95,13 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
isUnevaluatedOperand = false;
}
}
-
+
// If this is an unevaluated operand, clear out the set of declaration
// references we have been computing.
if (isUnevaluatedOperand)
PotentiallyReferencedDeclStack.back().clear();
}
-
+
return Owned(new (Context) CXXTypeidExpr(isType, TyOrExpr,
TypeInfoType.withConst(),
SourceRange(OpLoc, RParenLoc)));
@@ -195,9 +195,9 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
if (Ty->isDependentType() ||
CallExpr::hasAnyTypeDependentArguments(Exprs, NumExprs)) {
exprs.release();
-
- return Owned(CXXUnresolvedConstructExpr::Create(Context,
- TypeRange.getBegin(), Ty,
+
+ return Owned(CXXUnresolvedConstructExpr::Create(Context,
+ TypeRange.getBegin(), Ty,
LParenLoc,
Exprs, NumExprs,
RParenLoc));
@@ -211,12 +211,12 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
PDiag(diag::err_invalid_incomplete_type_use)
<< FullRange))
return ExprError();
-
+
if (RequireNonAbstractType(TyBeginLoc, Ty,
diag::err_allocation_of_abstract_type))
return ExprError();
-
-
+
+
// C++ [expr.type.conv]p1:
// If the expression list is a single expression, the type conversion
// expression is equivalent (in definedness, and if defined in meaning) to the
@@ -232,9 +232,9 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
if (!ConversionDecl || !isa<CXXConstructorDecl>(ConversionDecl)) {
exprs.release();
return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(),
- Ty, TyBeginLoc,
+ Ty, TyBeginLoc,
CastExpr::CK_UserDefinedConversion,
- Exprs[0], ConversionDecl,
+ Exprs[0], ConversionDecl,
RParenLoc));
}
}
@@ -242,7 +242,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
if (const RecordType *RT = Ty->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl());
- if (NumExprs > 1 || !Record->hasTrivialConstructor() ||
+ if (NumExprs > 1 || !Record->hasTrivialConstructor() ||
!Record->hasTrivialDestructor()) {
CXXConstructorDecl *Constructor
= PerformInitializationByConstructor(Ty, Exprs, NumExprs,
@@ -255,12 +255,12 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
if (!Constructor)
return ExprError();
- OwningExprResult Result =
- BuildCXXTemporaryObjectExpr(Constructor, Ty, TyBeginLoc,
+ OwningExprResult Result =
+ BuildCXXTemporaryObjectExpr(Constructor, Ty, TyBeginLoc,
move(exprs), RParenLoc);
if (Result.isInvalid())
return ExprError();
-
+
return MaybeBindToTemporary(Result.takeAs<Expr>());
}
@@ -300,8 +300,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
SourceLocation PlacementRParen, bool ParenTypeId,
Declarator &D, SourceLocation ConstructorLParen,
MultiExprArg ConstructorArgs,
- SourceLocation ConstructorRParen)
-{
+ SourceLocation ConstructorRParen) {
Expr *ArraySize = 0;
unsigned Skip = 0;
// If the specified type is an array, unwrap it and save the expression.
@@ -337,12 +336,12 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
++i;
}
- return BuildCXXNew(StartLoc, UseGlobal,
+ return BuildCXXNew(StartLoc, UseGlobal,
PlacementLParen,
- move(PlacementArgs),
+ move(PlacementArgs),
PlacementRParen,
ParenTypeId,
- AllocType,
+ AllocType,
D.getSourceRange().getBegin(),
D.getSourceRange(),
Owned(ArraySize),
@@ -351,12 +350,12 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
ConstructorRParen);
}
-Sema::OwningExprResult
+Sema::OwningExprResult
Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
SourceLocation PlacementLParen,
MultiExprArg PlacementArgs,
SourceLocation PlacementRParen,
- bool ParenTypeId,
+ bool ParenTypeId,
QualType AllocType,
SourceLocation TypeLoc,
SourceRange TypeRange,
@@ -472,15 +471,14 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
return Owned(new (Context) CXXNewExpr(UseGlobal, OperatorNew, PlaceArgs,
NumPlaceArgs, ParenTypeId, ArraySize, Constructor, Init,
ConsArgs, NumConsArgs, OperatorDelete, ResultType,
- StartLoc, Init ? ConstructorRParen : SourceLocation()));
+ StartLoc, Init ? ConstructorRParen : SourceLocation()));
}
/// CheckAllocatedType - Checks that a type is suitable as the allocated type
/// in a new-expression.
/// dimension off and stores the size expression in ArraySize.
bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc,
- SourceRange R)
-{
+ SourceRange R) {
// C++ 5.3.4p1: "[The] type shall be a complete object type, but not an
// abstract class type or array thereof.
if (AllocType->isFunctionType())
@@ -508,8 +506,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
bool IsArray, Expr **PlaceArgs,
unsigned NumPlaceArgs,
FunctionDecl *&OperatorNew,
- FunctionDecl *&OperatorDelete)
-{
+ FunctionDecl *&OperatorDelete) {
// --- Choosing an allocation function ---
// C++ 5.3.4p8 - 14 & 18
// 1) If UseGlobal is true, only look in the global scope. Else, also look
@@ -534,7 +531,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
DeclarationName NewName = Context.DeclarationNames.getCXXOperatorName(
IsArray ? OO_Array_New : OO_New);
if (AllocType->isRecordType() && !UseGlobal) {
- CXXRecordDecl *Record
+ CXXRecordDecl *Record
= cast<CXXRecordDecl>(AllocType->getAs<RecordType>()->getDecl());
// FIXME: We fail to find inherited overloads.
if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0],
@@ -556,7 +553,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
// copy them back.
if (NumPlaceArgs > 0)
std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs);
-
+
return false;
}
@@ -565,8 +562,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
DeclarationName Name, Expr** Args,
unsigned NumArgs, DeclContext *Ctx,
- bool AllowMissing, FunctionDecl *&Operator)
-{
+ bool AllowMissing, FunctionDecl *&Operator) {
DeclContext::lookup_iterator Alloc, AllocEnd;
llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Name);
if (Alloc == AllocEnd) {
@@ -639,8 +635,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
/// @endcode
/// Note that the placement and nothrow forms of new are *not* implicitly
/// declared. Their use requires including \<new\>.
-void Sema::DeclareGlobalNewDelete()
-{
+void Sema::DeclareGlobalNewDelete() {
if (GlobalNewDeleteDeclared)
return;
GlobalNewDeleteDeclared = true;
@@ -666,8 +661,7 @@ void Sema::DeclareGlobalNewDelete()
/// DeclareGlobalAllocationFunction - Declares a single implicit global
/// allocation function if it doesn't already exist.
void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
- QualType Return, QualType Argument)
-{
+ QualType Return, QualType Argument) {
DeclContext *GlobalCtx = Context.getTranslationUnitDecl();
// Check if this function is already declared.
@@ -705,15 +699,14 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name,
/// @code delete [] ptr; @endcode
Action::OwningExprResult
Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
- bool ArrayForm, ExprArg Operand)
-{
+ bool ArrayForm, ExprArg Operand) {
// C++ 5.3.5p1: "The operand shall have a pointer type, or a class type
// having a single conversion function to a pointer type. The result has
// type void."
// DR599 amends "pointer type" to "pointer to object type" in both cases.
FunctionDecl *OperatorDelete = 0;
-
+
Expr *Ex = (Expr *)Operand.get();
if (!Ex->isTypeDependent()) {
QualType Type = Ex->getType();
@@ -731,12 +724,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
return ExprError(Diag(StartLoc, diag::err_delete_operand)
<< Type << Ex->getSourceRange());
else if (!Pointee->isDependentType() &&
- RequireCompleteType(StartLoc, Pointee,
+ RequireCompleteType(StartLoc, Pointee,
PDiag(diag::warn_delete_incomplete)
<< Ex->getSourceRange()))
return ExprError();
- // FIXME: This should be shared with the code for finding the delete
+ // FIXME: This should be shared with the code for finding the delete
// operator in ActOnCXXNew.
IntegerLiteral Size(llvm::APInt::getNullValue(
Context.Target.getPointerWidth(0)),
@@ -745,12 +738,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
ImplicitCastExpr Cast(Context.getPointerType(Context.VoidTy),
CastExpr::CK_Unknown, &Size, false);
Expr *DeleteArg = &Cast;
-
+
DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName(
ArrayForm ? OO_Array_Delete : OO_Delete);
if (Pointee->isRecordType() && !UseGlobal) {
- CXXRecordDecl *Record
+ CXXRecordDecl *Record
= cast<CXXRecordDecl>(Pointee->getAs<RecordType>()->getDecl());
// FIXME: We fail to find inherited overloads.
if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName,
@@ -759,20 +752,20 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
return ExprError();
if (!Record->hasTrivialDestructor())
if (const CXXDestructorDecl *Dtor = Record->getDestructor(Context))
- MarkDeclarationReferenced(StartLoc,
+ MarkDeclarationReferenced(StartLoc,
const_cast<CXXDestructorDecl*>(Dtor));
}
-
+
if (!OperatorDelete) {
// Didn't find a member overload. Look for a global one.
DeclareGlobalNewDelete();
DeclContext *TUDecl = Context.getTranslationUnitDecl();
- if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName,
+ if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName,
&DeleteArg, 1, TUDecl, /*AllowMissing=*/false,
OperatorDelete))
return ExprError();
}
-
+
// FIXME: Check access and ambiguity of operator delete and destructor.
}
@@ -804,7 +797,7 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc,
DeclaratorInfo *DInfo = 0;
TagDecl *OwnedTag = 0;
QualType Ty = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0, &OwnedTag);
-
+
if (Ty->isFunctionType()) { // The declarator shall not specify a function...
// We exit without creating a CXXConditionDeclExpr because a FunctionDecl
// would be created and CXXConditionDeclExpr wants a VarDecl.
@@ -848,7 +841,7 @@ bool Sema::CheckCXXBooleanCondition(Expr *&CondExpr) {
/// conversion from a string literal to a pointer to non-const char or
/// non-const wchar_t (for narrow and wide string literals,
/// respectively).
-bool
+bool
Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
// Look inside the implicit cast, if it exists.
if (ImplicitCastExpr *Cast = dyn_cast<ImplicitCastExpr>(From))
@@ -860,7 +853,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
// to wchar_t" (C++ 4.2p2).
if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From))
if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
- if (const BuiltinType *ToPointeeType
+ if (const BuiltinType *ToPointeeType
= ToPtrType->getPointeeType()->getAsBuiltinType()) {
// This conversion is considered only when there is an
// explicit appropriate pointer target type (C++ 4.2p2).
@@ -886,19 +879,18 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) {
bool
Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
const char *Flavor, bool AllowExplicit,
- bool Elidable)
-{
+ bool Elidable) {
ImplicitConversionSequence ICS;
ICS.ConversionKind = ImplicitConversionSequence::BadConversion;
if (Elidable && getLangOptions().CPlusPlus0x) {
- ICS = TryImplicitConversion(From, ToType,
+ ICS = TryImplicitConversion(From, ToType,
/*SuppressUserConversions=*/false,
- AllowExplicit,
+ AllowExplicit,
/*ForceRValue=*/true,
/*InOverloadResolution=*/false);
}
if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion) {
- ICS = TryImplicitConversion(From, ToType,
+ ICS = TryImplicitConversion(From, ToType,
/*SuppressUserConversions=*/false,
AllowExplicit,
/*ForceRValue=*/false,
@@ -929,9 +921,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
CastExpr::CastKind CastKind = CastExpr::CK_Unknown;
if (CXXConversionDecl *CV = dyn_cast<CXXConversionDecl>(FD)) {
// FIXME. Get actual Source Location.
- From =
+ From =
new (Context) CXXFunctionalCastExpr(ToType.getNonReferenceType(),
- ToType, SourceLocation(),
+ ToType, SourceLocation(),
CastExpr::CK_UserDefinedConversion,
From, CV,
SourceLocation());
@@ -940,9 +932,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
else if (CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
// FIXME. Do we need to check for isLValueReferenceType?
DefaultFunctionArrayConversion(From);
- OwningExprResult InitResult =
+ OwningExprResult InitResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
- ToType.getNonReferenceType(), CD,
+ ToType.getNonReferenceType(), CD,
MultiExprArg(*this, (void**)&From, 1));
// Take ownership of this expression.
From = InitResult.takeAs<Expr>();
@@ -972,7 +964,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
/// otherwise. The expression From is replaced with the converted
/// expression. Flavor is the context in which we're performing this
/// conversion, for use in error messages.
-bool
+bool
Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
const StandardConversionSequence& SCS,
const char *Flavor) {
@@ -985,15 +977,15 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
if (SCS.CopyConstructor) {
// FIXME: When can ToType be a reference type?
assert(!ToType->isReferenceType());
-
- OwningExprResult FromResult =
- BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
- ToType, SCS.CopyConstructor,
+
+ OwningExprResult FromResult =
+ BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
+ ToType, SCS.CopyConstructor,
MultiExprArg(*this, (void**)&From, 1));
-
+
if (FromResult.isInvalid())
return true;
-
+
From = FromResult.takeAs<Expr>();
return false;
}
@@ -1054,7 +1046,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
case ICK_Pointer_Conversion:
if (SCS.IncompatibleObjC) {
// Diagnose incompatible Objective-C conversions
- Diag(From->getSourceRange().getBegin(),
+ Diag(From->getSourceRange().getBegin(),
diag::ext_typecheck_convert_incompatible_pointer)
<< From->getType() << ToType << Flavor
<< From->getSourceRange();
@@ -1090,7 +1082,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
case ICK_Qualification:
// FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue
// references.
- ImpCastExprToType(From, ToType.getNonReferenceType(),
+ ImpCastExprToType(From, ToType.getNonReferenceType(),
CastExpr::CK_Unknown,
ToType->isLValueReferenceType());
break;
@@ -1109,12 +1101,12 @@ Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
TypeTy *Ty,
SourceLocation RParen) {
QualType T = GetTypeFromParser(Ty);
-
+
// According to http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html
// all traits except __is_class, __is_enum and __is_union require a the type
// to be complete.
if (OTT != UTT_IsClass && OTT != UTT_IsEnum && OTT != UTT_IsUnion) {
- if (RequireCompleteType(KWLoc, T,
+ if (RequireCompleteType(KWLoc, T,
diag::err_incomplete_type_used_in_type_trait_expr))
return ExprError();
}
@@ -1127,8 +1119,7 @@ Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
}
QualType Sema::CheckPointerToMemberOperands(
- Expr *&lex, Expr *&rex, SourceLocation Loc, bool isIndirect)
-{
+ Expr *&lex, Expr *&rex, SourceLocation Loc, bool isIndirect) {
const char *OpSpelling = isIndirect ? "->*" : ".*";
// C++ 5.5p2
// The binary operator .* [p3: ->*] binds its second operand, which shall
@@ -1140,7 +1131,7 @@ QualType Sema::CheckPointerToMemberOperands(
Diag(Loc, diag::err_bad_memptr_rhs)
<< OpSpelling << RType << rex->getSourceRange();
return QualType();
- }
+ }
QualType Class(MemPtr->getClass(), 0);
@@ -1214,8 +1205,7 @@ static QualType TargetType(const ImplicitConversionSequence &ICS) {
/// conversion.
static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
SourceLocation QuestionLoc,
- ImplicitConversionSequence &ICS)
-{
+ ImplicitConversionSequence &ICS) {
// C++0x 5.16p3
// The process for determining whether an operand expression E1 of type T1
// can be converted to match an operand expression E2 of type T2 is defined
@@ -1262,7 +1252,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
// Could still fail if there's no copy constructor.
// FIXME: Is this a hard error then, or just a conversion failure? The
// standard doesn't say.
- ICS = Self.TryCopyInitialization(From, TTy,
+ ICS = Self.TryCopyInitialization(From, TTy,
/*SuppressUserConversions=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
@@ -1274,7 +1264,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
// First find the decayed type.
if (TTy->isFunctionType())
TTy = Self.Context.getPointerType(TTy);
- else if(TTy->isArrayType())
+ else if (TTy->isArrayType())
TTy = Self.Context.getArrayDecayedType(TTy);
// Now try the implicit conversion.
@@ -1339,8 +1329,7 @@ static bool FindConditionalOverload(Sema &Self, Expr *&LHS, Expr *&RHS,
/// second part of a standard conversion is ICK_DerivedToBase. This function
/// handles the reference binding specially.
static bool ConvertForConditional(Sema &Self, Expr *&E,
- const ImplicitConversionSequence &ICS)
-{
+ const ImplicitConversionSequence &ICS) {
if (ICS.ConversionKind == ImplicitConversionSequence::StandardConversion &&
ICS.Standard.ReferenceBinding) {
assert(ICS.Standard.DirectBinding &&
@@ -1583,13 +1572,13 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
assert(getLangOptions().CPlusPlus && "This function assumes C++");
QualType T1 = E1->getType(), T2 = E2->getType();
-
+
if (!T1->isPointerType() && !T1->isMemberPointerType() &&
!T2->isPointerType() && !T2->isMemberPointerType())
return QualType();
// FIXME: Do we need to work on the canonical types?
-
+
// C++0x 5.9p2
// Pointer conversions and qualification conversions are performed on
// pointer operands to bring them to their composite pointer type. If
@@ -1603,7 +1592,7 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
ImpCastExprToType(E2, T1);
return T1;
}
-
+
// Now both have to be pointers or member pointers.
if (!T1->isPointerType() && !T1->isMemberPointerType() &&
!T2->isPointerType() && !T2->isMemberPointerType())
@@ -1633,7 +1622,7 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
MemberOfClass.push_back(std::make_pair((const Type *)0, (const Type *)0));
continue;
}
-
+
const MemberPointerType *MemPtr1, *MemPtr2;
if ((MemPtr1 = Composite1->getAs<MemberPointerType>()) &&
(MemPtr2 = Composite2->getAs<MemberPointerType>())) {
@@ -1645,19 +1634,19 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
MemPtr2->getClass()));
continue;
}
-
+
// FIXME: block pointer types?
-
+
// Cannot unwrap any more types.
break;
} while (true);
-
+
// Rewrap the composites as pointers or member pointers with the union CVRs.
llvm::SmallVector<std::pair<const Type *, const Type *>, 4>::iterator MOC
= MemberOfClass.begin();
- for (llvm::SmallVector<unsigned, 4>::iterator
+ for (llvm::SmallVector<unsigned, 4>::iterator
I = QualifierUnion.begin(),
- E = QualifierUnion.end();
+ E = QualifierUnion.end();
I != E; (void)++I, ++MOC) {
if (MOC->first && MOC->second) {
// Rebuild member pointer type
@@ -1672,19 +1661,19 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
}
}
- ImplicitConversionSequence E1ToC1 =
+ ImplicitConversionSequence E1ToC1 =
TryImplicitConversion(E1, Composite1,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
- ImplicitConversionSequence E2ToC1 =
+ ImplicitConversionSequence E2ToC1 =
TryImplicitConversion(E2, Composite1,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
-
+
ImplicitConversionSequence E1ToC2, E2ToC2;
E1ToC2.ConversionKind = ImplicitConversionSequence::BadConversion;
E2ToC2.ConversionKind = ImplicitConversionSequence::BadConversion;
@@ -1726,16 +1715,16 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
if (!Context.getLangOptions().CPlusPlus)
return Owned(E);
-
+
const RecordType *RT = E->getType()->getAs<RecordType>();
if (!RT)
return Owned(E);
-
+
CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
if (RD->hasTrivialDestructor())
return Owned(E);
-
- CXXTemporary *Temp = CXXTemporary::Create(Context,
+
+ CXXTemporary *Temp = CXXTemporary::Create(Context,
RD->getDestructor(Context));
ExprTemporaries.push_back(Temp);
if (CXXDestructorDecl *Destructor =
@@ -1745,40 +1734,40 @@ Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E));
}
-Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
+Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr,
bool ShouldDestroyTemps) {
assert(SubExpr && "sub expression can't be null!");
-
+
if (ExprTemporaries.empty())
return SubExpr;
-
+
Expr *E = CXXExprWithTemporaries::Create(Context, SubExpr,
- &ExprTemporaries[0],
+ &ExprTemporaries[0],
ExprTemporaries.size(),
ShouldDestroyTemps);
ExprTemporaries.clear();
-
+
return E;
}
-Sema::OwningExprResult
+Sema::OwningExprResult
Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind, TypeTy *&ObjectType) {
// Since this might be a postfix expression, get rid of ParenListExprs.
Base = MaybeConvertParenListExprToParenExpr(S, move(Base));
-
+
Expr *BaseExpr = (Expr*)Base.get();
assert(BaseExpr && "no record expansion");
-
+
QualType BaseType = BaseExpr->getType();
if (BaseType->isDependentType()) {
// FIXME: member of the current instantiation
ObjectType = BaseType.getAsOpaquePtr();
return move(Base);
}
-
+
// C++ [over.match.oper]p8:
- // [...] When operator->returns, the operator-> is applied to the value
+ // [...] When operator->returns, the operator-> is applied to the value
// returned, with the original second operand.
if (OpKind == tok::arrow) {
while (BaseType->isRecordType()) {
@@ -1789,11 +1778,11 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
BaseType = BaseExpr->getType();
}
}
-
+
if (BaseType->isPointerType())
BaseType = BaseType->getPointeeType();
-
- // We could end up with various non-record types here, such as extended
+
+ // We could end up with various non-record types here, such as extended
// vector types or Objective-C interfaces. Just return early and let
// ActOnMemberReferenceExpr do the work.
if (!BaseType->isRecordType()) {
@@ -1804,14 +1793,14 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
ObjectType = 0;
return move(Base);
}
-
+
// C++ [basic.lookup.classref]p2:
- // If the id-expression in a class member access (5.2.5) is an
+ // If the id-expression in a class member access (5.2.5) is an
// unqualified-id, and the type of the object expres- sion is of a class
// type C (or of pointer to a class type C), the unqualified-id is looked
// up in the scope of class C. [...]
ObjectType = BaseType.getAsOpaquePtr();
- return move(Base);
+ return move(Base);
}
Sema::OwningExprResult
@@ -1832,16 +1821,16 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base,
else {
TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, &SS);
if (!BaseTy) {
- Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type)
+ Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type)
<< ClassName;
return ExprError();
}
-
+
BaseType = GetTypeFromParser(BaseTy);
}
-
+
CanQualType CanBaseType = Context.getCanonicalType(BaseType);
- DeclarationName DtorName =
+ DeclarationName DtorName =
Context.DeclarationNames.getCXXDestructorName(CanBaseType);
OwningExprResult Result
@@ -1849,8 +1838,8 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base,
DtorName, DeclPtrTy(), &SS);
if (Result.isInvalid() || HasTrailingLParen)
return move(Result);
-
- // The only way a reference to a destructor can be used is to
+
+ // The only way a reference to a destructor can be used is to
// immediately call them. Since the next token is not a '(', produce a
// diagnostic and build the call now.
Expr *E = (Expr *)Result.get();
@@ -1858,8 +1847,8 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base,
Diag(E->getLocStart(), diag::err_dtor_expr_without_call)
<< isa<CXXPseudoDestructorExpr>(E)
<< CodeModificationHint::CreateInsertion(ExpectedLParenLoc, "()");
-
- return ActOnCallExpr(0, move(Result), ExpectedLParenLoc,
+
+ return ActOnCallExpr(0, move(Result), ExpectedLParenLoc,
MultiExprArg(*this, 0, 0), 0, ExpectedLParenLoc);
}
@@ -1903,7 +1892,7 @@ Sema::ActOnConversionOperatorReferenceExpr(Scope *S, ExprArg Base,
Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
Expr *FullExpr = Arg.takeAs<Expr>();
if (FullExpr)
- FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr,
+ FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr,
/*ShouldDestroyTemps=*/true);
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 0fcf747847..2616c5c0bd 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -20,7 +20,7 @@
using namespace clang;
-Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
+Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
ExprTy **strings,
unsigned NumStrings) {
StringLiteral **Strings = reinterpret_cast<StringLiteral**>(strings);
@@ -30,40 +30,40 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
// each one, e.g. @"foo" "bar" @"baz" "qux" which need to be turned into one
// StringLiteral for ObjCStringLiteral to hold onto.
StringLiteral *S = Strings[0];
-
+
// If we have a multi-part string, merge it all together.
if (NumStrings != 1) {
// Concatenate objc strings.
llvm::SmallString<128> StrBuf;
llvm::SmallVector<SourceLocation, 8> StrLocs;
-
+
for (unsigned i = 0; i != NumStrings; ++i) {
S = Strings[i];
-
+
// ObjC strings can't be wide.
if (S->isWide()) {
Diag(S->getLocStart(), diag::err_cfstring_literal_not_string_constant)
<< S->getSourceRange();
return true;
}
-
+
// Get the string data.
StrBuf.append(S->getStrData(), S->getStrData()+S->getByteLength());
-
+
// Get the locations of the string tokens.
StrLocs.append(S->tokloc_begin(), S->tokloc_end());
-
+
// Free the temporary string.
S->Destroy(Context);
}
-
+
// Create the aggregate string with the appropriate content and location
// information.
S = StringLiteral::Create(Context, &StrBuf[0], StrBuf.size(), false,
Context.getPointerType(Context.CharTy),
&StrLocs[0], StrLocs.size());
}
-
+
// Verify that this composite string is acceptable for ObjC strings.
if (CheckObjCString(S))
return true;
@@ -88,15 +88,15 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs,
Ty = Context.getObjCIdType();
}
}
-
+
return new (Context) ObjCStringLiteral(S, Ty, AtLocs[0]);
}
-Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
+Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
QualType EncodedType,
SourceLocation RParenLoc) {
QualType StrTy;
- if (EncodedType->isDependentType())
+ if (EncodedType->isDependentType())
StrTy = Context.DependentTy;
else {
std::string Str;
@@ -111,7 +111,7 @@ Expr *Sema::BuildObjCEncodeExpression(SourceLocation AtLoc,
StrTy = Context.getConstantArrayType(StrTy, llvm::APInt(32, Str.size()+1),
ArrayType::Normal, 0);
}
-
+
return new (Context) ObjCEncodeExpr(StrTy, EncodedType, AtLoc, RParenLoc);
}
@@ -131,7 +131,7 @@ Sema::ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
SourceLocation SelLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc) {
- ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel,
+ ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(Sel,
SourceRange(LParenLoc, RParenLoc), false);
if (!Method)
Method = LookupFactoryMethodInGlobalPool(Sel,
@@ -153,7 +153,7 @@ Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
return true;
}
-
+
QualType Ty = Context.getObjCProtoType();
if (Ty.isNull())
return true;
@@ -161,11 +161,11 @@ Sema::ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
return new (Context) ObjCProtocolExpr(Ty, PDecl, AtLoc, RParenLoc);
}
-bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
- Selector Sel, ObjCMethodDecl *Method,
+bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
+ Selector Sel, ObjCMethodDecl *Method,
bool isClassMessage,
SourceLocation lbrac, SourceLocation rbrac,
- QualType &ReturnType) {
+ QualType &ReturnType) {
if (!Method) {
// Apply default argument promotion as for (C99 6.5.2.2p6).
for (unsigned i = 0; i != NumArgs; i++)
@@ -178,9 +178,9 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
ReturnType = Context.getObjCIdType();
return false;
}
-
+
ReturnType = Method->getResultType();
-
+
unsigned NumNamedArgs = Sel.getNumArgs();
assert(NumArgs >= NumNamedArgs && "Too few arguments for selector!");
@@ -188,22 +188,22 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
for (unsigned i = 0; i < NumNamedArgs; i++) {
Expr *argExpr = Args[i];
assert(argExpr && "CheckMessageArgumentTypes(): missing expression");
-
+
QualType lhsType = Method->param_begin()[i]->getType();
QualType rhsType = argExpr->getType();
- // If necessary, apply function/array conversion. C99 6.7.5.3p[7,8].
+ // If necessary, apply function/array conversion. C99 6.7.5.3p[7,8].
if (lhsType->isArrayType())
lhsType = Context.getArrayDecayedType(lhsType);
else if (lhsType->isFunctionType())
lhsType = Context.getPointerType(lhsType);
- AssignConvertType Result =
+ AssignConvertType Result =
CheckSingleAssignmentConstraints(lhsType, argExpr);
if (Args[i] != argExpr) // The expression was converted.
Args[i] = argExpr; // Make sure we store the converted expression.
-
- IsError |=
+
+ IsError |=
DiagnoseAssignmentResult(Result, argExpr->getLocStart(), lhsType, rhsType,
argExpr, "sending");
}
@@ -215,7 +215,7 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
} else {
// Check for extra arguments to non-variadic methods.
if (NumArgs != NumNamedArgs) {
- Diag(Args[NumNamedArgs]->getLocStart(),
+ Diag(Args[NumNamedArgs]->getLocStart(),
diag::err_typecheck_call_too_many_args)
<< 2 /*method*/ << Method->getSourceRange()
<< SourceRange(Args[NumNamedArgs]->getLocStart(),
@@ -244,22 +244,22 @@ ObjCMethodDecl *Sema::LookupPrivateClassMethod(Selector Sel,
while (ClassDecl && !Method) {
if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation())
Method = ImpDecl->getClassMethod(Sel);
-
+
// Look through local category implementations associated with the class.
if (!Method)
Method = ClassDecl->getCategoryClassMethod(Sel);
-
+
// Before we give up, check if the selector is an instance method.
// But only in the root. This matches gcc's behaviour and what the
// runtime expects.
if (!Method && !ClassDecl->getSuperClass()) {
Method = ClassDecl->lookupInstanceMethod(Sel);
- // Look through local category implementations associated
+ // Look through local category implementations associated
// with the root class.
- if (!Method)
+ if (!Method)
Method = LookupPrivateInstanceMethod(Sel, ClassDecl);
}
-
+
ClassDecl = ClassDecl->getSuperClass();
}
return Method;
@@ -272,7 +272,7 @@ ObjCMethodDecl *Sema::LookupPrivateInstanceMethod(Selector Sel,
// If we have implementations in scope, check "private" methods.
if (ObjCImplementationDecl *ImpDecl = ClassDecl->getImplementation())
Method = ImpDecl->getInstanceMethod(Sel);
-
+
// Look through local category implementations associated with the class.
if (!Method)
Method = ClassDecl->getCategoryInstanceMethod(Sel);
@@ -286,11 +286,11 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr(
IdentifierInfo &propertyName,
SourceLocation &receiverNameLoc,
SourceLocation &propertyNameLoc) {
-
+
ObjCInterfaceDecl *IFace = getObjCInterfaceDecl(&receiverName);
-
+
// Search for a declared property first.
-
+
Selector Sel = PP.getSelectorTable().getNullarySelector(&propertyName);
ObjCMethodDecl *Getter = IFace->lookupClassMethod(Sel);
@@ -307,12 +307,12 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr(
if (DiagnoseUseOfDecl(Getter, propertyNameLoc))
return ExprError();
}
-
+
// Look for the matching setter, in case it is needed.
- Selector SetterSel =
- SelectorTable::constructSetterName(PP.getIdentifierTable(),
+ Selector SetterSel =
+ SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), &propertyName);
-
+
ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
if (!Setter) {
// If this reference is in an @implementation, also check for 'private'
@@ -340,7 +340,7 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr(
PType = (*PI)->getType();
}
return Owned(new (Context) ObjCImplicitSetterGetterRefExpr(
- Getter, PType, Setter,
+ Getter, PType, Setter,
propertyNameLoc, IFace, receiverNameLoc));
}
return ExprError(Diag(propertyNameLoc, diag::err_property_not_found)
@@ -355,21 +355,20 @@ Sema::ExprResult Sema::ActOnClassMessage(
Scope *S,
IdentifierInfo *receiverName, Selector Sel,
SourceLocation lbrac, SourceLocation receiverLoc,
- SourceLocation selectorLoc, SourceLocation rbrac,
- ExprTy **Args, unsigned NumArgs)
-{
+ SourceLocation selectorLoc, SourceLocation rbrac,
+ ExprTy **Args, unsigned NumArgs) {
assert(receiverName && "missing receiver class name");
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
ObjCInterfaceDecl* ClassDecl = 0;
bool isSuper = false;
-
+
if (receiverName->isStr("super")) {
if (getCurMethodDecl()) {
isSuper = true;
ObjCInterfaceDecl *OID = getCurMethodDecl()->getClassInterface();
if (!OID)
- return Diag(lbrac, diag::error_no_super_class_message)
+ return Diag(lbrac, diag::error_no_super_class_message)
<< getCurMethodDecl()->getDeclName();
ClassDecl = OID->getSuperClass();
if (!ClassDecl)
@@ -380,7 +379,7 @@ Sema::ExprResult Sema::ActOnClassMessage(
ExprResult ReceiverExpr = new (Context) ObjCSuperExpr(SourceLocation(),
superTy);
// We are really in an instance method, redirect.
- return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac,
+ return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac,
selectorLoc, rbrac, Args, NumArgs);
}
// We are sending a message to 'super' within a class method. Do nothing,
@@ -391,17 +390,17 @@ Sema::ExprResult Sema::ActOnClassMessage(
NamedDecl *SuperDecl = LookupName(S, receiverName, LookupOrdinaryName);
ValueDecl *VD = dyn_cast_or_null<ValueDecl>(SuperDecl);
if (VD) {
- ExprResult ReceiverExpr = new (Context) DeclRefExpr(VD, VD->getType(),
+ ExprResult ReceiverExpr = new (Context) DeclRefExpr(VD, VD->getType(),
receiverLoc);
// We are really in an instance method, redirect.
- return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac,
+ return ActOnInstanceMessage(ReceiverExpr.get(), Sel, lbrac,
selectorLoc, rbrac, Args, NumArgs);
}
return Diag(receiverLoc, diag::err_undeclared_var_use) << receiverName;
- }
+ }
} else
ClassDecl = getObjCInterfaceDecl(receiverName);
-
+
// The following code allows for the following GCC-ism:
//
// typedef XCElementDisplayRect XCElementGraphicsRect;
@@ -432,25 +431,25 @@ Sema::ExprResult Sema::ActOnClassMessage(
Diag(lbrac, diag::warn_receiver_forward_class) << ClassDecl->getDeclName();
Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac,rbrac));
if (Method)
- Diag(Method->getLocation(), diag::note_method_sent_forward_class)
+ Diag(Method->getLocation(), diag::note_method_sent_forward_class)
<< Method->getDeclName();
}
if (!Method)
Method = ClassDecl->lookupClassMethod(Sel);
-
+
// If we have an implementation in scope, check "private" methods.
if (!Method)
Method = LookupPrivateClassMethod(Sel, ClassDecl);
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
-
- if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true,
+
+ if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, true,
lbrac, rbrac, returnType))
return true;
returnType = returnType.getNonReferenceType();
-
+
// If we have the ObjCInterfaceDecl* for the class that is receiving the
// message, use that to construct the ObjCMessageExpr. Otherwise pass on the
// IdentifierInfo* for the class.
@@ -469,19 +468,19 @@ Sema::ExprResult Sema::ActOnClassMessage(
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from Sel.getNumArgs().
Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
- SourceLocation lbrac,
+ SourceLocation lbrac,
SourceLocation receiverLoc,
SourceLocation rbrac,
ExprTy **Args, unsigned NumArgs) {
assert(receiver && "missing receiver expression");
-
+
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
Expr *RExpr = static_cast<Expr *>(receiver);
-
+
// If necessary, apply function/array conversion to the receiver.
// C99 6.7.5.3p[7,8].
DefaultFunctionArrayConversion(RExpr);
-
+
QualType returnType;
QualType ReceiverCType =
Context.getCanonicalType(RExpr->getType()).getUnqualifiedType();
@@ -494,8 +493,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface())
if (ObjCInterfaceDecl *SuperDecl = ClassDecl->getSuperClass()) {
Method = SuperDecl->lookupInstanceMethod(Sel);
-
- if (!Method)
+
+ if (!Method)
// If we have implementations in scope, check "private" methods.
Method = LookupPrivateInstanceMethod(Sel, SuperDecl);
}
@@ -507,41 +506,41 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
lbrac, rbrac, returnType))
return true;
-
+
returnType = returnType.getNonReferenceType();
return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac,
rbrac, ArgExprs, NumArgs);
}
- // Handle messages to id.
+ // Handle messages to id.
if (ReceiverCType->isObjCIdType() || ReceiverCType->isBlockPointerType() ||
Context.isObjCNSObjectType(RExpr->getType())) {
ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
if (!Method)
Method = LookupFactoryMethodInGlobalPool(Sel, SourceRange(lbrac, rbrac));
- if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
+ if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
lbrac, rbrac, returnType))
return true;
returnType = returnType.getNonReferenceType();
return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac,
rbrac, ArgExprs, NumArgs);
}
-
+
// Handle messages to Class.
- if (ReceiverCType->isObjCClassType() ||
+ if (ReceiverCType->isObjCClassType() ||
ReceiverCType->isObjCQualifiedClassType()) {
ObjCMethodDecl *Method = 0;
-
+
if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
if (ObjCInterfaceDecl *ClassDecl = CurMeth->getClassInterface()) {
// First check the public methods in the class interface.
Method = ClassDecl->lookupClassMethod(Sel);
-
+
if (!Method)
Method = LookupPrivateClassMethod(Sel, ClassDecl);
-
- // FIXME: if we still haven't found a method, we need to look in
+
+ // FIXME: if we still haven't found a method, we need to look in
// protocols (if we have qualifiers).
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
@@ -573,13 +572,13 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
return new (Context) ObjCMessageExpr(RExpr, Sel, returnType, Method, lbrac,
rbrac, ArgExprs, NumArgs);
}
-
+
ObjCMethodDecl *Method = 0;
ObjCInterfaceDecl* ClassDecl = 0;
-
- // We allow sending a message to a qualified ID ("id<foo>"), which is ok as
+
+ // We allow sending a message to a qualified ID ("id<foo>"), which is ok as
// long as one of the protocols implements the selector (if not, warn).
- if (const ObjCObjectPointerType *QIdTy =
+ if (const ObjCObjectPointerType *QIdTy =
ReceiverCType->getAsObjCQualifiedIdType()) {
// Search protocols for instance methods.
for (ObjCObjectPointerType::qual_iterator I = QIdTy->qual_begin(),
@@ -591,16 +590,16 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
if (PDecl && (Method = PDecl->lookupClassMethod(Sel)))
break;
}
- } else if (const ObjCObjectPointerType *OCIType =
+ } else if (const ObjCObjectPointerType *OCIType =
ReceiverCType->getAsObjCInterfacePointerType()) {
// We allow sending a message to a pointer to an interface (an object).
-
+
ClassDecl = OCIType->getInterfaceDecl();
// FIXME: consider using LookupInstanceMethodInGlobalPool, since it will be
// faster than the following method (which can do *many* linear searches).
// The idea is to add class info to InstanceMethodPool.
Method = ClassDecl->lookupInstanceMethod(Sel);
-
+
if (!Method) {
// Search protocol qualifiers.
for (ObjCObjectPointerType::qual_iterator QI = OCIType->qual_begin(),
@@ -612,7 +611,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
if (!Method) {
// If we have implementations in scope, check "private" methods.
Method = LookupPrivateInstanceMethod(Sel, ClassDecl);
-
+
if (!Method && !isSelfExpr(RExpr)) {
// If we still haven't found a method, look in the global pool. This
// behavior isn't very desirable, however we need it for GCC
@@ -621,7 +620,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
if (Method && !OCIType->getInterfaceDecl()->isForwardDecl())
- Diag(lbrac, diag::warn_maynot_respond)
+ Diag(lbrac, diag::warn_maynot_respond)
<< OCIType->getInterfaceDecl()->getIdentifier()->getName() << Sel;
}
}
@@ -630,7 +629,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
return true;
} else if (!Context.getObjCIdType().isNull() &&
(ReceiverCType->isPointerType() ||
- (ReceiverCType->isIntegerType() &&
+ (ReceiverCType->isIntegerType() &&
ReceiverCType->isScalarType()))) {
// Implicitly convert integers and pointers to 'id' but emit a warning.
Diag(lbrac, diag::warn_bad_receiver_type)
@@ -642,7 +641,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel,
<< RExpr->getType() << RExpr->getSourceRange();
return true;
}
-
+
if (Method)
DiagnoseSentinelCalls(Method, receiverLoc, ArgExprs, NumArgs);
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp
index c48e3bc79e..e6734d5176 100644
--- a/lib/Sema/SemaInherit.cpp
+++ b/lib/Sema/SemaInherit.cpp
@@ -28,9 +28,9 @@ using namespace clang;
/// \brief Computes the set of declarations referenced by these base
/// paths.
void BasePaths::ComputeDeclsFound() {
- assert(NumDeclsFound == 0 && !DeclsFound &&
+ assert(NumDeclsFound == 0 && !DeclsFound &&
"Already computed the set of declarations");
-
+
std::set<NamedDecl *> Decls;
for (BasePaths::paths_iterator Path = begin(), PathEnd = end();
Path != PathEnd; ++Path)
@@ -127,24 +127,24 @@ bool Sema::IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths) {
/// behavior of this lookup, e.g., whether it finds ambiguities,
/// records paths, or attempts to detect the use of virtual base
/// classes.
-bool Sema::LookupInBases(CXXRecordDecl *Class,
+bool Sema::LookupInBases(CXXRecordDecl *Class,
const MemberLookupCriteria& Criteria,
BasePaths &Paths) {
bool FoundPath = false;
for (CXXRecordDecl::base_class_const_iterator BaseSpec = Class->bases_begin(),
- BaseSpecEnd = Class->bases_end();
+ BaseSpecEnd = Class->bases_end();
BaseSpec != BaseSpecEnd; ++BaseSpec) {
// Find the record of the base class subobjects for this type.
QualType BaseType = Context.getCanonicalType(BaseSpec->getType());
BaseType = BaseType.getUnqualifiedType();
- // If a base class of the class template depends on a template-parameter,
+ // If a base class of the class template depends on a template-parameter,
// the base class scope is not examined during unqualified name lookup.
// [temp.dep]p3.
if (BaseType->isDependentType())
continue;
-
+
// Determine whether we need to visit this base class at all,
// updating the count of subobjects appropriately.
std::pair<bool, unsigned>& Subobjects = Paths.ClassSubobjects[BaseType];
@@ -174,7 +174,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class,
Paths.ScratchPath.push_back(Element);
}
- CXXRecordDecl *BaseRecord
+ CXXRecordDecl *BaseRecord
= cast<CXXRecordDecl>(BaseSpec->getType()->getAs<RecordType>()->getDecl());
// Either look at the base class type or look into the base class
@@ -183,7 +183,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class,
bool FoundPathToThisBase = false;
switch (Criteria.Kind) {
case MemberLookupCriteria::LK_Base:
- FoundPathToThisBase
+ FoundPathToThisBase
= (Context.getCanonicalType(BaseSpec->getType()) == Criteria.Base);
break;
case MemberLookupCriteria::LK_NamedMember:
@@ -198,19 +198,19 @@ bool Sema::LookupInBases(CXXRecordDecl *Class,
}
break;
case MemberLookupCriteria::LK_OverriddenMember:
- Paths.ScratchPath.Decls =
+ Paths.ScratchPath.Decls =
BaseRecord->lookup(Criteria.Method->getDeclName());
while (Paths.ScratchPath.Decls.first != Paths.ScratchPath.Decls.second) {
- if (CXXMethodDecl *MD =
+ if (CXXMethodDecl *MD =
dyn_cast<CXXMethodDecl>(*Paths.ScratchPath.Decls.first)) {
OverloadedFunctionDecl::function_iterator MatchedDecl;
- if (MD->isVirtual() &&
+ if (MD->isVirtual() &&
!IsOverload(Criteria.Method, MD, MatchedDecl)) {
FoundPathToThisBase = true;
break;
}
}
-
+
++Paths.ScratchPath.Decls.first;
}
break;
@@ -296,27 +296,27 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
bool StillOkay = IsDerivedFrom(Derived, Base, Paths);
assert(StillOkay && "Can only be used with a derived-to-base conversion");
(void)StillOkay;
-
+
// Build up a textual representation of the ambiguous paths, e.g.,
// D -> B -> A, that will be used to illustrate the ambiguous
// conversions in the diagnostic. We only print one of the paths
// to each base class subobject.
std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
-
+
Diag(Loc, AmbigiousBaseConvID)
<< Derived << Base << PathDisplayStr << Range << Name;
return true;
}
-bool
+bool
Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
SourceLocation Loc, SourceRange Range) {
- return CheckDerivedToBaseConversion(Derived, Base,
+ return CheckDerivedToBaseConversion(Derived, Base,
diag::err_conv_to_inaccessible_base,
diag::err_ambiguous_derived_to_base_conv,
Loc, Range, DeclarationName());
}
-
+
/// @brief Builds a string representing ambiguous paths from a
/// specific derived class to different subobjects of the same base
@@ -333,16 +333,16 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
std::string Sema::getAmbiguousPathsDisplayString(BasePaths &Paths) {
std::string PathDisplayStr;
std::set<unsigned> DisplayedPaths;
- for (BasePaths::paths_iterator Path = Paths.begin();
+ for (BasePaths::paths_iterator Path = Paths.begin();
Path != Paths.end(); ++Path) {
if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
// We haven't displayed a path to this particular base
// class subobject yet.
PathDisplayStr += "\n ";
PathDisplayStr += Paths.getOrigin().getAsString();
- for (BasePath::const_iterator Element = Path->begin();
+ for (BasePath::const_iterator Element = Path->begin();
Element != Path->end(); ++Element)
- PathDisplayStr += " -> " + Element->Base->getType().getAsString();
+ PathDisplayStr += " -> " + Element->Base->getType().getAsString();
}
}
diff --git a/lib/Sema/SemaInherit.h b/lib/Sema/SemaInherit.h
index b1e791a17b..d08d7f8a4b 100644
--- a/lib/Sema/SemaInherit.h
+++ b/lib/Sema/SemaInherit.h
@@ -41,11 +41,11 @@ namespace clang {
/// Class - The record decl of the class that the base is a base of.
const CXXRecordDecl *Class;
-
+
/// SubobjectNumber - Identifies which base class subobject (of type
- /// @c Base->getType()) this base path element refers to. This
+ /// @c Base->getType()) this base path element refers to. This
/// value is only valid if @c !Base->isVirtual(), because there
- /// is no base numbering for the zero or one virtual bases of a
+ /// is no base numbering for the zero or one virtual bases of a
/// given type.
int SubobjectNumber;
};
@@ -107,7 +107,7 @@ namespace clang {
/// while the element contains the number of non-virtual base
/// class subobjects for that class type. The key of the map is
/// the cv-unqualified canonical type of the base class subobject.
- std::map<QualType, std::pair<bool, unsigned>, QualTypeOrdering>
+ std::map<QualType, std::pair<bool, unsigned>, QualTypeOrdering>
ClassSubobjects;
/// FindAmbiguities - Whether Sema::IsDerivedFrom should try find
@@ -145,7 +145,7 @@ namespace clang {
public:
typedef std::list<BasePath>::const_iterator paths_iterator;
typedef NamedDecl **decl_iterator;
-
+
/// BasePaths - Construct a new BasePaths structure to record the
/// paths for a derived-to-base search.
explicit BasePaths(bool FindAmbiguities = true,
@@ -153,8 +153,7 @@ namespace clang {
bool DetectVirtual = true)
: FindAmbiguities(FindAmbiguities), RecordPaths(RecordPaths),
DetectVirtual(DetectVirtual), DetectedVirtual(0), DeclsFound(0),
- NumDeclsFound(0)
- {}
+ NumDeclsFound(0) { }
~BasePaths() { delete [] DeclsFound; }
@@ -208,22 +207,22 @@ namespace clang {
LK_NamedMember,
LK_OverriddenMember
};
-
+
/// MemberLookupCriteria - Constructs member lookup criteria to
/// search for a base class of type Base.
- explicit MemberLookupCriteria(QualType Base)
+ explicit MemberLookupCriteria(QualType Base)
: Kind(LK_Base), Base(Base) { }
/// MemberLookupCriteria - Constructs member lookup criteria to
/// search for a class member with the given Name.
- explicit MemberLookupCriteria(DeclarationName Name,
+ explicit MemberLookupCriteria(DeclarationName Name,
Sema::LookupNameKind NameKind,
- unsigned IDNS)
+ unsigned IDNS)
: Kind(LK_NamedMember), Name(Name), NameKind(NameKind), IDNS(IDNS) { }
explicit MemberLookupCriteria(CXXMethodDecl *MD)
: Kind(LK_OverriddenMember), Method(MD) { }
-
+
/// Kind - The kind of lookup we're doing.
/// LK_Base if we are looking for a base class (whose
/// type is Base). LK_NamedMember if we are looking for a named member of
@@ -240,7 +239,7 @@ namespace clang {
Sema::LookupNameKind NameKind;
unsigned IDNS;
-
+
CXXMethodDecl *Method;
};
}
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 877efc31b9..c1f7716330 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -36,7 +36,7 @@ static Expr *IsStringInit(Expr *Init, QualType DeclType, ASTContext &Context) {
// See if this is a string literal or @encode.
Init = Init->IgnoreParens();
-
+
// Handle @encode, which is a narrow string.
if (isa<ObjCEncodeExpr>(Init) && AT->getElementType()->isCharType())
return Init;
@@ -58,26 +58,26 @@ static Expr *IsStringInit(Expr *Init, QualType DeclType, ASTContext &Context) {
if (Context.typesAreCompatible(Context.getWCharType(),
ElemTy.getUnqualifiedType()))
return Init;
-
+
return 0;
}
-static bool CheckSingleInitializer(Expr *&Init, QualType DeclType,
+static bool CheckSingleInitializer(Expr *&Init, QualType DeclType,
bool DirectInit, Sema &S) {
// Get the type before calling CheckSingleAssignmentConstraints(), since
// it can promote the expression.
- QualType InitType = Init->getType();
-
+ QualType InitType = Init->getType();
+
if (S.getLangOptions().CPlusPlus) {
// FIXME: I dislike this error message. A lot.
if (S.PerformImplicitConversion(Init, DeclType, "initializing", DirectInit))
return S.Diag(Init->getSourceRange().getBegin(),
diag::err_typecheck_convert_incompatible)
- << DeclType << Init->getType() << "initializing"
+ << DeclType << Init->getType() << "initializing"
<< Init->getSourceRange();
return false;
}
-
+
Sema::AssignConvertType ConvTy =
S.CheckSingleAssignmentConstraints(DeclType, Init);
return S.DiagnoseAssignmentResult(ConvTy, Init->getLocStart(), DeclType,
@@ -89,10 +89,10 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) {
uint64_t StrLength =
cast<ConstantArrayType>(Str->getType())->getSize().getZExtValue();
-
+
const ArrayType *AT = S.Context.getAsArrayType(DeclT);
if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT)) {
- // C99 6.7.8p14. We have an array of character type with unknown size
+ // C99 6.7.8p14. We have an array of character type with unknown size
// being initialized to a string literal.
llvm::APSInt ConstVal(32);
ConstVal = StrLength;
@@ -102,9 +102,9 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) {
ArrayType::Normal, 0);
return;
}
-
+
const ConstantArrayType *CAT = cast<ConstantArrayType>(AT);
-
+
// C99 6.7.8p14. We have an array of character type with known size. However,
// the size may be smaller or larger than the string we are initializing.
// FIXME: Avoid truncation for 64-bit length strings.
@@ -112,7 +112,7 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) {
S.Diag(Str->getSourceRange().getBegin(),
diag::warn_initializer_string_for_char_array_too_long)
<< Str->getSourceRange();
-
+
// Set the type to the actual size that we are initializing. If we have
// something like:
// char x[1] = "foo";
@@ -123,26 +123,26 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) {
bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
SourceLocation InitLoc,
DeclarationName InitEntity, bool DirectInit) {
- if (DeclType->isDependentType() ||
+ if (DeclType->isDependentType() ||
Init->isTypeDependent() || Init->isValueDependent())
return false;
-
+
// C++ [dcl.init.ref]p1:
// A variable declared to be a T& or T&&, that is "reference to type T"
// (8.3.2), shall be initialized by an object, or function, of
// type T or by an object that can be converted into a T.
if (DeclType->isReferenceType())
- return CheckReferenceInit(Init, DeclType,
+ return CheckReferenceInit(Init, DeclType,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/DirectInit,
/*ForceRValue=*/false);
-
+
// C99 6.7.8p3: The type of the entity to be initialized shall be an array
// of unknown size ("[]") or an object type that is not a variable array type.
if (const VariableArrayType *VAT = Context.getAsVariableArrayType(DeclType))
return Diag(InitLoc, diag::err_variable_object_no_init)
<< VAT->getSizeExpr()->getSourceRange();
-
+
InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
if (!InitList) {
// FIXME: Handle wide strings
@@ -150,47 +150,47 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
CheckStringInit(Str, DeclType, *this);
return false;
}
-
+
// C++ [dcl.init]p14:
// -- If the destination type is a (possibly cv-qualified) class
// type:
if (getLangOptions().CPlusPlus && DeclType->isRecordType()) {
QualType DeclTypeC = Context.getCanonicalType(DeclType);
QualType InitTypeC = Context.getCanonicalType(Init->getType());
-
+
// -- If the initialization is direct-initialization, or if it is
// copy-initialization where the cv-unqualified version of the
// source type is the same class as, or a derived class of, the
// class of the destination, constructors are considered.
if ((DeclTypeC.getUnqualifiedType() == InitTypeC.getUnqualifiedType()) ||
IsDerivedFrom(InitTypeC, DeclTypeC)) {
- const CXXRecordDecl *RD =
+ const CXXRecordDecl *RD =
cast<CXXRecordDecl>(DeclType->getAs<RecordType>()->getDecl());
-
+
// No need to make a CXXConstructExpr if both the ctor and dtor are
// trivial.
if (RD->hasTrivialConstructor() && RD->hasTrivialDestructor())
return false;
-
- CXXConstructorDecl *Constructor
+
+ CXXConstructorDecl *Constructor
= PerformInitializationByConstructor(DeclType, &Init, 1,
InitLoc, Init->getSourceRange(),
- InitEntity,
+ InitEntity,
DirectInit? IK_Direct : IK_Copy);
if (!Constructor)
return true;
-
- OwningExprResult InitResult =
+
+ OwningExprResult InitResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
- DeclType, Constructor,
+ DeclType, Constructor,
MultiExprArg(*this, (void**)&Init, 1));
if (InitResult.isInvalid())
return true;
-
+
Init = InitResult.takeAs<Expr>();
return false;
}
-
+
// -- Otherwise (i.e., for the remaining copy-initialization
// cases), user-defined conversion sequences that can
// convert from the source type to the destination type or
@@ -207,7 +207,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
// have ASTs for such things.
if (!PerformImplicitConversion(Init, DeclType, "initializing"))
return false;
-
+
if (InitEntity)
return Diag(InitLoc, diag::err_cannot_initialize_decl)
<< InitEntity << (int)(Init->isLvalue(Context) == Expr::LV_Valid)
@@ -216,15 +216,15 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
<< DeclType << (int)(Init->isLvalue(Context) == Expr::LV_Valid)
<< Init->getType() << Init->getSourceRange();
}
-
+
// C99 6.7.8p16.
if (DeclType->isArrayType())
return Diag(Init->getLocStart(), diag::err_array_init_list_required)
<< Init->getSourceRange();
-
+
return CheckSingleInitializer(Init, DeclType, DirectInit, *this);
- }
-
+ }
+
bool hadError = CheckInitList(InitList, DeclType);
Init = InitList;
return hadError;
@@ -267,8 +267,8 @@ class InitListChecker {
bool hadError;
std::map<InitListExpr *, InitListExpr *> SyntacticToSemantic;
InitListExpr *FullyStructuredList;
-
- void CheckImplicitInitList(InitListExpr *ParentIList, QualType T,
+
+ void CheckImplicitInitList(InitListExpr *ParentIList, QualType T,
unsigned &Index, InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject = false);
@@ -276,41 +276,41 @@ class InitListChecker {
unsigned &Index, InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject = false);
- void CheckListElementTypes(InitListExpr *IList, QualType &DeclType,
- bool SubobjectIsDesignatorContext,
+ void CheckListElementTypes(InitListExpr *IList, QualType &DeclType,
+ bool SubobjectIsDesignatorContext,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject = false);
- void CheckSubElementType(InitListExpr *IList, QualType ElemType,
+ void CheckSubElementType(InitListExpr *IList, QualType ElemType,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
- void CheckScalarType(InitListExpr *IList, QualType DeclType,
+ void CheckScalarType(InitListExpr *IList, QualType DeclType,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
- void CheckReferenceType(InitListExpr *IList, QualType DeclType,
+ void CheckReferenceType(InitListExpr *IList, QualType DeclType,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
void CheckVectorType(InitListExpr *IList, QualType DeclType, unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
- void CheckStructUnionTypes(InitListExpr *IList, QualType DeclType,
- RecordDecl::field_iterator Field,
+ void CheckStructUnionTypes(InitListExpr *IList, QualType DeclType,
+ RecordDecl::field_iterator Field,
bool SubobjectIsDesignatorContext, unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject = false);
- void CheckArrayType(InitListExpr *IList, QualType &DeclType,
- llvm::APSInt elementIndex,
+ void CheckArrayType(InitListExpr *IList, QualType &DeclType,
+ llvm::APSInt elementIndex,
bool SubobjectIsDesignatorContext, unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
- bool CheckDesignatedInitializer(InitListExpr *IList, DesignatedInitExpr *DIE,
+ bool CheckDesignatedInitializer(InitListExpr *IList, DesignatedInitExpr *DIE,
unsigned DesigIdx,
- QualType &CurrentObjectType,
+ QualType &CurrentObjectType,
RecordDecl::field_iterator *NextField,
llvm::APSInt *NextElementIndex,
unsigned &Index,
@@ -344,15 +344,15 @@ public:
/// with expressions that perform value-initialization of the
/// appropriate type.
void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
- assert((ILE->getType() != SemaRef.Context.VoidTy) &&
+ assert((ILE->getType() != SemaRef.Context.VoidTy) &&
"Should not have void type");
SourceLocation Loc = ILE->getSourceRange().getBegin();
if (ILE->getSyntacticForm())
Loc = ILE->getSyntacticForm()->getSourceRange().getBegin();
-
+
if (const RecordType *RType = ILE->getType()->getAs<RecordType>()) {
unsigned Init = 0, NumInits = ILE->getNumInits();
- for (RecordDecl::field_iterator
+ for (RecordDecl::field_iterator
Field = RType->getDecl()->field_begin(),
FieldEnd = RType->getDecl()->field_end();
Field != FieldEnd; ++Field) {
@@ -364,11 +364,11 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
// C++ [dcl.init.aggr]p9:
// If an incomplete or empty initializer-list leaves a
// member of reference type uninitialized, the program is
- // ill-formed.
+ // ill-formed.
SemaRef.Diag(Loc, diag::err_init_reference_member_uninitialized)
<< Field->getType()
<< ILE->getSyntacticForm()->getSourceRange();
- SemaRef.Diag(Field->getLocation(),
+ SemaRef.Diag(Field->getLocation(),
diag::note_uninit_reference_member);
hadError = true;
return;
@@ -381,9 +381,9 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
// we make that call explicit in the representation (even when it means
// extending the initializer list)?
if (Init < NumInits && !hadError)
- ILE->setInit(Init,
+ ILE->setInit(Init,
new (SemaRef.Context) ImplicitValueInitExpr(Field->getType()));
- } else if (InitListExpr *InnerILE
+ } else if (InitListExpr *InnerILE
= dyn_cast<InitListExpr>(ILE->getInit(Init)))
FillInValueInitializations(InnerILE);
++Init;
@@ -394,10 +394,10 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
}
return;
- }
+ }
QualType ElementType;
-
+
unsigned NumInits = ILE->getNumInits();
unsigned NumElements = NumInits;
if (const ArrayType *AType = SemaRef.Context.getAsArrayType(ILE->getType())) {
@@ -407,9 +407,9 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
} else if (const VectorType *VType = ILE->getType()->getAsVectorType()) {
ElementType = VType->getElementType();
NumElements = VType->getNumElements();
- } else
+ } else
ElementType = ILE->getType();
-
+
for (unsigned Init = 0; Init != NumElements; ++Init) {
if (Init >= NumInits || !ILE->getInit(Init)) {
if (SemaRef.CheckValueInitialization(ElementType, Loc)) {
@@ -421,7 +421,7 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) {
// we make that call explicit in the representation (even when it means
// extending the initializer list)?
if (Init < NumInits && !hadError)
- ILE->setInit(Init,
+ ILE->setInit(Init,
new (SemaRef.Context) ImplicitValueInitExpr(ElementType));
} else if (InitListExpr *InnerILE
= dyn_cast<InitListExpr>(ILE->getInit(Init)))
@@ -436,7 +436,7 @@ InitListChecker::InitListChecker(Sema &S, InitListExpr *IL, QualType &T)
unsigned newIndex = 0;
unsigned newStructuredIndex = 0;
- FullyStructuredList
+ FullyStructuredList
= getStructuredSubobjectInit(IL, newIndex, T, 0, 0, IL->getSourceRange());
CheckExplicitInitList(IL, T, newIndex, FullyStructuredList, newStructuredIndex,
/*TopLevelObject=*/true);
@@ -458,7 +458,7 @@ int InitListChecker::numArrayElements(QualType DeclType) {
int InitListChecker::numStructUnionElements(QualType DeclType) {
RecordDecl *structDecl = DeclType->getAs<RecordType>()->getDecl();
int InitializableMembers = 0;
- for (RecordDecl::field_iterator
+ for (RecordDecl::field_iterator
Field = structDecl->field_begin(),
FieldEnd = structDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -470,13 +470,13 @@ int InitListChecker::numStructUnionElements(QualType DeclType) {
return InitializableMembers - structDecl->hasFlexibleArrayMember();
}
-void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
+void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
QualType T, unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject) {
int maxElements = 0;
-
+
if (T->isArrayType())
maxElements = numArrayElements(T);
else if (T->isStructureType() || T->isUnionType())
@@ -496,8 +496,8 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
// Build a structured initializer list corresponding to this subobject.
InitListExpr *StructuredSubobjectInitList
- = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
- StructuredIndex,
+ = getStructuredSubobjectInit(ParentIList, Index, T, StructuredList,
+ StructuredIndex,
SourceRange(ParentIList->getInit(Index)->getSourceRange().getBegin(),
ParentIList->getSourceRange().getEnd()));
unsigned StructuredSubobjectInitIndex = 0;
@@ -505,7 +505,7 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
// Check the element types and build the structural subobject.
unsigned StartIndex = Index;
CheckListElementTypes(ParentIList, T, false, Index,
- StructuredSubobjectInitList,
+ StructuredSubobjectInitList,
StructuredSubobjectInitIndex,
TopLevelObject);
unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
@@ -514,7 +514,7 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList,
// Update the structured sub-object initializer so that it's ending
// range corresponds with the end of the last initializer it used.
if (EndIndex < ParentIList->getNumInits()) {
- SourceLocation EndLoc
+ SourceLocation EndLoc
= ParentIList->getInit(EndIndex)->getSourceRange().getEnd();
StructuredSubobjectInitList->setRBraceLoc(EndLoc);
}
@@ -528,7 +528,7 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T,
assert(IList->isExplicit() && "Illegal Implicit InitListExpr");
SyntacticToSemantic[IList] = StructuredList;
StructuredList->setSyntacticForm(IList);
- CheckListElementTypes(IList, T, true, Index, StructuredList,
+ CheckListElementTypes(IList, T, true, Index, StructuredList,
StructuredIndex, TopLevelObject);
IList->setType(T);
StructuredList->setType(T);
@@ -551,7 +551,7 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T,
// Don't complain for incomplete types, since we'll get an error
// elsewhere
QualType CurrentObjectType = StructuredList->getType();
- int initKind =
+ int initKind =
CurrentObjectType->isArrayType()? 0 :
CurrentObjectType->isVectorType()? 1 :
CurrentObjectType->isScalarType()? 2 :
@@ -581,7 +581,7 @@ void InitListChecker::CheckExplicitInitList(InitListExpr *IList, QualType &T,
}
void InitListChecker::CheckListElementTypes(InitListExpr *IList,
- QualType &DeclType,
+ QualType &DeclType,
bool SubobjectIsDesignatorContext,
unsigned &Index,
InitListExpr *StructuredList,
@@ -594,7 +594,7 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList,
} else if (DeclType->isAggregateType()) {
if (DeclType->isRecordType()) {
RecordDecl *RD = DeclType->getAs<RecordType>()->getDecl();
- CheckStructUnionTypes(IList, DeclType, RD->field_begin(),
+ CheckStructUnionTypes(IList, DeclType, RD->field_begin(),
SubobjectIsDesignatorContext, Index,
StructuredList, StructuredIndex,
TopLevelObject);
@@ -628,13 +628,13 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList,
CheckReferenceType(IList, DeclType, Index, StructuredList, StructuredIndex);
} else {
// In C, all types are either scalars or aggregates, but
- // additional handling is needed here for C++ (and possibly others?).
+ // additional handling is needed here for C++ (and possibly others?).
assert(0 && "Unsupported initializer type");
}
}
void InitListChecker::CheckSubElementType(InitListExpr *IList,
- QualType ElemType,
+ QualType ElemType,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex) {
@@ -642,11 +642,11 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
if (InitListExpr *SubInitList = dyn_cast<InitListExpr>(expr)) {
unsigned newIndex = 0;
unsigned newStructuredIndex = 0;
- InitListExpr *newStructuredList
+ InitListExpr *newStructuredList
= getStructuredSubobjectInit(IList, Index, ElemType,
StructuredList, StructuredIndex,
SubInitList->getSourceRange());
- CheckExplicitInitList(SubInitList, ElemType, newIndex,
+ CheckExplicitInitList(SubInitList, ElemType, newIndex,
newStructuredList, newStructuredIndex);
++StructuredIndex;
++Index;
@@ -665,14 +665,14 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
// initializing the aggregate member with an ini- tializer from
// an initializer-list. If the initializer can initialize a
// member, the member is initialized. [...]
- ImplicitConversionSequence ICS
+ ImplicitConversionSequence ICS
= SemaRef.TryCopyInitialization(expr, ElemType,
/*SuppressUserConversions=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
if (ICS.ConversionKind != ImplicitConversionSequence::BadConversion) {
- if (SemaRef.PerformImplicitConversion(expr, ElemType, ICS,
+ if (SemaRef.PerformImplicitConversion(expr, ElemType, ICS,
"initializing"))
hadError = true;
UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
@@ -682,7 +682,7 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
// Fall through for subaggregate initialization
} else {
- // C99 6.7.8p13:
+ // C99 6.7.8p13:
//
// The initializer for a structure or union object that has
// automatic storage duration shall be either an initializer
@@ -701,13 +701,13 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
}
// C++ [dcl.init.aggr]p12:
- //
+ //
// [...] Otherwise, if the member is itself a non-empty
// subaggregate, brace elision is assumed and the initializer is
// considered for the initialization of the first member of
// the subaggregate.
if (ElemType->isAggregateType() || ElemType->isVectorType()) {
- CheckImplicitInitList(IList, ElemType, Index, StructuredList,
+ CheckImplicitInitList(IList, ElemType, Index, StructuredList,
StructuredIndex);
++StructuredIndex;
} else {
@@ -736,7 +736,7 @@ void InitListChecker::CheckScalarType(InitListExpr *IList, QualType DeclType,
++StructuredIndex;
return;
} else if (isa<DesignatedInitExpr>(expr)) {
- SemaRef.Diag(expr->getSourceRange().getBegin(),
+ SemaRef.Diag(expr->getSourceRange().getBegin(),
diag::err_designator_for_scalar_init)
<< DeclType << expr->getSourceRange();
hadError = true;
@@ -780,13 +780,13 @@ void InitListChecker::CheckReferenceType(InitListExpr *IList, QualType DeclType,
++Index;
++StructuredIndex;
return;
- }
+ }
Expr *savExpr = expr; // Might be promoted by CheckSingleInitializer.
if (SemaRef.CheckReferenceInit(expr, DeclType,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
- /*ForceRValue=*/false))
+ /*ForceRValue=*/false))
hadError = true;
else if (savExpr != expr) {
// The type was promoted, update initializer list.
@@ -802,7 +802,7 @@ void InitListChecker::CheckReferenceType(InitListExpr *IList, QualType DeclType,
// general, it would be useful to pass location information down the stack,
// so that we know the location (or decl) of the "current object" being
// initialized.
- SemaRef.Diag(IList->getLocStart(),
+ SemaRef.Diag(IList->getLocStart(),
diag::err_init_reference_member_uninitialized)
<< DeclType
<< IList->getSourceRange();
@@ -813,7 +813,7 @@ void InitListChecker::CheckReferenceType(InitListExpr *IList, QualType DeclType,
}
}
-void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
+void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex) {
@@ -822,7 +822,7 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
unsigned maxElements = VT->getNumElements();
unsigned numEltsInit = 0;
QualType elementType = VT->getElementType();
-
+
if (!SemaRef.getLangOptions().OpenCL) {
for (unsigned i = 0; i < maxElements; ++i, ++numEltsInit) {
// Don't attempt to go past the end of the init list
@@ -853,7 +853,7 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
}
}
}
-
+
// OpenCL & AltiVec require all elements to be initialized.
if (numEltsInit != maxElements)
if (SemaRef.getLangOptions().OpenCL || SemaRef.getLangOptions().AltiVec)
@@ -863,9 +863,9 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType,
}
}
-void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
+void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
llvm::APSInt elementIndex,
- bool SubobjectIsDesignatorContext,
+ bool SubobjectIsDesignatorContext,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex) {
@@ -924,7 +924,7 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
// Handle this designated initializer. elementIndex will be
// updated to be the next array element we'll initialize.
- if (CheckDesignatedInitializer(IList, DIE, 0,
+ if (CheckDesignatedInitializer(IList, DIE, 0,
DeclType, 0, &elementIndex, Index,
StructuredList, StructuredIndex, true,
false)) {
@@ -972,27 +972,27 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
diag::ext_typecheck_zero_array_size);
}
- DeclType = SemaRef.Context.getConstantArrayType(elementType, maxElements,
+ DeclType = SemaRef.Context.getConstantArrayType(elementType, maxElements,
ArrayType::Normal, 0);
}
}
-void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
- QualType DeclType,
+void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
+ QualType DeclType,
RecordDecl::field_iterator Field,
- bool SubobjectIsDesignatorContext,
+ bool SubobjectIsDesignatorContext,
unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject) {
RecordDecl* structDecl = DeclType->getAs<RecordType>()->getDecl();
-
+
// If the record is invalid, some of it's members are invalid. To avoid
// confusion, we forgo checking the intializer for the entire record.
if (structDecl->isInvalidDecl()) {
hadError = true;
return;
- }
+ }
if (DeclType->isUnionType() && IList->getNumInits() == 0) {
// Value-initialize the first named member of the union.
@@ -1026,7 +1026,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
// Handle this designated initializer. Field will be updated to
// the next field that we'll be initializing.
- if (CheckDesignatedInitializer(IList, DIE, 0,
+ if (CheckDesignatedInitializer(IList, DIE, 0,
DeclType, &Field, 0, Index,
StructuredList, StructuredIndex,
true, TopLevelObject))
@@ -1067,15 +1067,15 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
++Field;
}
- if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
+ if (Field == FieldEnd || !Field->getType()->isIncompleteArrayType() ||
Index >= IList->getNumInits())
return;
// Handle GNU flexible array initializers.
- if (!TopLevelObject &&
+ if (!TopLevelObject &&
(!isa<InitListExpr>(IList->getInit(Index)) ||
cast<InitListExpr>(IList->getInit(Index))->getNumInits() > 0)) {
- SemaRef.Diag(IList->getInit(Index)->getSourceRange().getBegin(),
+ SemaRef.Diag(IList->getInit(Index)->getSourceRange().getBegin(),
diag::err_flexible_array_init_nonempty)
<< IList->getInit(Index)->getSourceRange().getBegin();
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
@@ -1084,7 +1084,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
++Index;
return;
} else {
- SemaRef.Diag(IList->getInit(Index)->getSourceRange().getBegin(),
+ SemaRef.Diag(IList->getInit(Index)->getSourceRange().getBegin(),
diag::ext_flexible_array_init)
<< IList->getInit(Index)->getSourceRange().getBegin();
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
@@ -1106,8 +1106,8 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList,
/// Field/FieldIndex will be updated to point to the (new)
/// currently-designated field.
static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
- DesignatedInitExpr *DIE,
- unsigned DesigIdx,
+ DesignatedInitExpr *DIE,
+ unsigned DesigIdx,
FieldDecl *Field,
RecordDecl::field_iterator &FieldIter,
unsigned &FieldIndex) {
@@ -1117,14 +1117,14 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
// anonymous struct/union (backwards).
llvm::SmallVector<FieldDecl *, 4> Path;
SemaRef.BuildAnonymousStructUnionMemberPath(Field, Path);
-
+
// Build the replacement designators.
llvm::SmallVector<Designator, 4> Replacements;
for (llvm::SmallVector<FieldDecl *, 4>::reverse_iterator
FI = Path.rbegin(), FIEnd = Path.rend();
FI != FIEnd; ++FI) {
if (FI + 1 == FIEnd)
- Replacements.push_back(Designator((IdentifierInfo *)0,
+ Replacements.push_back(Designator((IdentifierInfo *)0,
DIE->getDesignator(DesigIdx)->getDotLoc(),
DIE->getDesignator(DesigIdx)->getFieldLoc()));
else
@@ -1136,9 +1136,9 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
// Expand the current designator into the set of replacement
// designators, so we have a full subobject path down to where the
// member of the anonymous struct/union is actually stored.
- DIE->ExpandDesignator(DesigIdx, &Replacements[0],
+ DIE->ExpandDesignator(DesigIdx, &Replacements[0],
&Replacements[0] + Replacements.size());
-
+
// Update FieldIter/FieldIndex;
RecordDecl *Record = cast<RecordDecl>(Path.back()->getDeclContext());
FieldIter = Record->field_begin();
@@ -1163,7 +1163,7 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
/// resides at the given @p Index within the initializer list @p
/// IList, is well-formed for a current object of type @p DeclType
/// (C99 6.7.8). The actual subobject that this designator refers to
-/// within the current subobject is returned in either
+/// within the current subobject is returned in either
/// @p NextField or @p NextElementIndex (whichever is appropriate).
///
/// @param IList The initializer list in which this designated
@@ -1192,9 +1192,9 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
/// actually be initialized.
///
/// @returns true if there was an error, false otherwise.
-bool
+bool
InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
- DesignatedInitExpr *DIE,
+ DesignatedInitExpr *DIE,
unsigned DesigIdx,
QualType &CurrentObjectType,
RecordDecl::field_iterator *NextField,
@@ -1227,14 +1227,14 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
}
bool IsFirstDesignator = (DesigIdx == 0);
- assert((IsFirstDesignator || StructuredList) &&
+ assert((IsFirstDesignator || StructuredList) &&
"Need a non-designated initializer list to start from");
DesignatedInitExpr::Designator *D = DIE->getDesignator(DesigIdx);
// Determine the structural initializer list that corresponds to the
// current subobject.
StructuredList = IsFirstDesignator? SyntacticToSemantic[IList]
- : getStructuredSubobjectInit(IList, Index, CurrentObjectType,
+ : getStructuredSubobjectInit(IList, Index, CurrentObjectType,
StructuredList, StructuredIndex,
SourceRange(D->getStartLocation(),
DIE->getSourceRange().getEnd()));
@@ -1249,7 +1249,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
//
// then the current object (defined below) shall have
// structure or union type and the identifier shall be the
- // name of a member of that type.
+ // name of a member of that type.
const RecordType *RT = CurrentObjectType->getAs<RecordType>();
if (!RT) {
SourceLocation Loc = D->getDotLoc();
@@ -1267,7 +1267,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
FieldDecl *KnownField = D->getField();
IdentifierInfo *FieldName = D->getFieldName();
unsigned FieldIndex = 0;
- RecordDecl::field_iterator
+ RecordDecl::field_iterator
Field = RT->getDecl()->field_begin(),
FieldEnd = RT->getDecl()->field_end();
for (; Field != FieldEnd; ++Field) {
@@ -1285,7 +1285,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// name. Perform another lookup for this name, which may find
// something that we can't designate (e.g., a member function),
// may find nothing, or may find a member of an anonymous
- // struct/union.
+ // struct/union.
DeclContext::lookup_result Lookup = RT->getDecl()->lookup(FieldName);
if (Lookup.first == Lookup.second) {
// Name lookup didn't find anything.
@@ -1298,7 +1298,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
->isAnonymousStructOrUnion()) {
// Handle an field designator that refers to a member of an
// anonymous struct or union.
- ExpandAnonymousFieldDesignator(SemaRef, DIE, DesigIdx,
+ ExpandAnonymousFieldDesignator(SemaRef, DIE, DesigIdx,
cast<FieldDecl>(*Lookup.first),
Field, FieldIndex);
D = DIE->getDesignator(DesigIdx);
@@ -1306,7 +1306,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// Name lookup found something, but it wasn't a field.
SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield)
<< FieldName;
- SemaRef.Diag((*Lookup.first)->getLocation(),
+ SemaRef.Diag((*Lookup.first)->getLocation(),
diag::note_field_designator_found);
++Index;
return true;
@@ -1328,7 +1328,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// Update the designator with the field declaration.
D->setField(*Field);
-
+
// Make sure that our non-designated initializer list has space
// for a subobject corresponding to this field.
if (FieldIndex >= StructuredList->getNumInits())
@@ -1340,11 +1340,11 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
if ((DesigIdx + 1) != DIE->size()) {
// We can't designate an object within the flexible array
// member (because GCC doesn't allow it).
- DesignatedInitExpr::Designator *NextD
+ DesignatedInitExpr::Designator *NextD
= DIE->getDesignator(DesigIdx + 1);
- SemaRef.Diag(NextD->getStartLocation(),
+ SemaRef.Diag(NextD->getStartLocation(),
diag::err_designator_into_flexible_array_member)
- << SourceRange(NextD->getStartLocation(),
+ << SourceRange(NextD->getStartLocation(),
DIE->getSourceRange().getEnd());
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
<< *Field;
@@ -1362,9 +1362,9 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
}
// Handle GNU flexible array initializers.
- if (!Invalid && !TopLevelObject &&
+ if (!Invalid && !TopLevelObject &&
cast<InitListExpr>(DIE->getInit())->getNumInits() > 0) {
- SemaRef.Diag(DIE->getSourceRange().getBegin(),
+ SemaRef.Diag(DIE->getSourceRange().getBegin(),
diag::err_flexible_array_init_nonempty)
<< DIE->getSourceRange().getBegin();
SemaRef.Diag(Field->getLocation(), diag::note_flexible_array_member)
@@ -1382,7 +1382,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
unsigned newStructuredIndex = FieldIndex;
unsigned OldIndex = Index;
IList->setInit(Index, DIE->getInit());
- CheckSubElementType(IList, Field->getType(), Index,
+ CheckSubElementType(IList, Field->getType(), Index,
StructuredList, newStructuredIndex);
IList->setInit(OldIndex, DIE);
if (hadError && !prevHadError) {
@@ -1463,10 +1463,10 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
} else {
assert(D->isArrayRangeDesignator() && "Need array-range designator");
-
- DesignatedStartIndex =
+
+ DesignatedStartIndex =
DIE->getArrayRangeStart(*D)->EvaluateAsInt(SemaRef.Context);
- DesignatedEndIndex =
+ DesignatedEndIndex =
DIE->getArrayRangeEnd(*D)->EvaluateAsInt(SemaRef.Context);
IndexExpr = DIE->getArrayRangeEnd(*D);
@@ -1498,11 +1498,11 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
DesignatedStartIndex.setIsUnsigned(true);
DesignatedEndIndex.setIsUnsigned(true);
}
-
+
// Make sure that our non-designated initializer list has space
// for a subobject corresponding to this array element.
if (DesignatedEndIndex.getZExtValue() >= StructuredList->getNumInits())
- StructuredList->resizeInits(SemaRef.Context,
+ StructuredList->resizeInits(SemaRef.Context,
DesignatedEndIndex.getZExtValue() + 1);
// Repeatedly perform subobject initializations in the range
@@ -1534,7 +1534,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
StructuredIndex = ElementIndex;
return false;
}
-
+
if (!FinishSubobjectInit)
return false;
@@ -1542,7 +1542,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
bool prevHadError = hadError;
CheckArrayType(IList, CurrentObjectType, DesignatedStartIndex, false, Index,
StructuredList, ElementIndex);
- return hadError && !prevHadError;
+ return hadError && !prevHadError;
}
// Get the structured initializer list for a subobject of type
@@ -1558,7 +1558,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
ExistingInit = SyntacticToSemantic[IList];
else if (StructuredIndex < StructuredList->getNumInits())
ExistingInit = StructuredList->getInit(StructuredIndex);
-
+
if (InitListExpr *Result = dyn_cast_or_null<InitListExpr>(ExistingInit))
return Result;
@@ -1567,24 +1567,24 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
// subobjects of the current object, but there was already an
// initialization that completely initialized the current
// subobject, e.g., by a compound literal:
- //
+ //
// struct X { int a, b; };
// struct X xs[] = { [0] = (struct X) { 1, 2 }, [0].b = 3 };
- //
+ //
// Here, xs[0].a == 0 and xs[0].b == 3, since the second,
// designated initializer re-initializes the whole
// subobject [0], overwriting previous initializers.
- SemaRef.Diag(InitRange.getBegin(),
+ SemaRef.Diag(InitRange.getBegin(),
diag::warn_subobject_initializer_overrides)
<< InitRange;
- SemaRef.Diag(ExistingInit->getSourceRange().getBegin(),
+ SemaRef.Diag(ExistingInit->getSourceRange().getBegin(),
diag::note_previous_initializer)
<< /*FIXME:has side effects=*/0
<< ExistingInit->getSourceRange();
}
- InitListExpr *Result
- = new (SemaRef.Context) InitListExpr(InitRange.getBegin(), 0, 0,
+ InitListExpr *Result
+ = new (SemaRef.Context) InitListExpr(InitRange.getBegin(), 0, 0,
InitRange.getEnd());
Result->setType(CurrentObjectType);
@@ -1599,7 +1599,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
NumInits = SubList->getNumInits();
}
- if (const ArrayType *AType
+ if (const ArrayType *AType
= SemaRef.Context.getAsArrayType(CurrentObjectType)) {
if (const ConstantArrayType *CAType = dyn_cast<ConstantArrayType>(AType)) {
NumElements = CAType->getSize().getZExtValue();
@@ -1615,7 +1615,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index,
if (RDecl->isUnion())
NumElements = 1;
else
- NumElements = std::distance(RDecl->field_begin(),
+ NumElements = std::distance(RDecl->field_begin(),
RDecl->field_end());
}
@@ -1647,15 +1647,15 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList,
if (Expr *PrevInit = StructuredList->updateInit(StructuredIndex, expr)) {
// This initializer overwrites a previous initializer. Warn.
- SemaRef.Diag(expr->getSourceRange().getBegin(),
+ SemaRef.Diag(expr->getSourceRange().getBegin(),
diag::warn_initializer_overrides)
<< expr->getSourceRange();
- SemaRef.Diag(PrevInit->getSourceRange().getBegin(),
+ SemaRef.Diag(PrevInit->getSourceRange().getBegin(),
diag::note_previous_initializer)
<< /*FIXME:has side effects=*/0
<< PrevInit->getSourceRange();
}
-
+
++StructuredIndex;
}
@@ -1666,7 +1666,7 @@ void InitListChecker::UpdateStructuredListElement(InitListExpr *StructuredList,
/// failure. Returns true if there was an error, false otherwise. If
/// everything went okay, Value will receive the value of the constant
/// expression.
-static bool
+static bool
CheckArrayDesignatorExpr(Sema &S, Expr *Index, llvm::APSInt &Value) {
SourceLocation Loc = Index->getSourceRange().getBegin();
@@ -1697,7 +1697,7 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
const Designator &D = Desig.getDesignator(Idx);
switch (D.getKind()) {
case Designator::FieldDesignator:
- Designators.push_back(ASTDesignator(D.getField(), D.getDotLoc(),
+ Designators.push_back(ASTDesignator(D.getField(), D.getDotLoc(),
D.getFieldLoc()));
break;
@@ -1710,7 +1710,7 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
Invalid = true;
else {
Designators.push_back(ASTDesignator(InitExpressions.size(),
- D.getLBracketLoc(),
+ D.getLBracketLoc(),
D.getRBracketLoc()));
InitExpressions.push_back(Index);
}
@@ -1742,12 +1742,12 @@ Sema::OwningExprResult Sema::ActOnDesignatedInitializer(Designation &Desig,
if (!StartDependent && !EndDependent && EndValue < StartValue) {
Diag(D.getEllipsisLoc(), diag::err_array_designator_empty_range)
- << StartValue.toString(10) << EndValue.toString(10)
+ << StartValue.toString(10) << EndValue.toString(10)
<< StartIndex->getSourceRange() << EndIndex->getSourceRange();
Invalid = true;
} else {
Designators.push_back(ASTDesignator(InitExpressions.size(),
- D.getLBracketLoc(),
+ D.getLBracketLoc(),
D.getEllipsisLoc(),
D.getRBracketLoc()));
InitExpressions.push_back(StartIndex);
@@ -1792,7 +1792,7 @@ bool Sema::CheckInitList(InitListExpr *&InitList, QualType &DeclType) {
/// accessible, non-deleted default constructor. In C, everything can
/// be value-initialized, which corresponds to C's notion of
/// initializing objects with static storage duration when no
-/// initializer is provided for that object.
+/// initializer is provided for that object.
///
/// \returns true if there was an error, false otherwise.
bool Sema::CheckValueInitialization(QualType Type, SourceLocation Loc) {
@@ -1814,7 +1814,7 @@ bool Sema::CheckValueInitialization(QualType Type, SourceLocation Loc) {
// FIXME: Eventually, we'll need to put the constructor decl into the
// AST.
return PerformInitializationByConstructor(Type, 0, 0, Loc,
- SourceRange(Loc),
+ SourceRange(Loc),
DeclarationName(),
IK_Direct);
}
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 38abd1641d..44c76a86e0 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -60,7 +60,7 @@ struct UsingDirAncestorCompare {
/// AddNamespaceUsingDirectives - Adds all UsingDirectiveDecl's to heap UDirs
/// (ordered by common ancestors), found in namespace NS,
/// including all found (recursively) in their nominated namespaces.
-void AddNamespaceUsingDirectives(ASTContext &Context,
+void AddNamespaceUsingDirectives(ASTContext &Context,
DeclContext *NS,
UsingDirectivesTy &UDirs,
NamespaceSet &Visited) {
@@ -77,7 +77,7 @@ void AddNamespaceUsingDirectives(ASTContext &Context,
/// AddScopeUsingDirectives - Adds all UsingDirectiveDecl's found in Scope S,
/// including all found in the namespaces they nominate.
-static void AddScopeUsingDirectives(ASTContext &Context, Scope *S,
+static void AddScopeUsingDirectives(ASTContext &Context, Scope *S,
UsingDirectivesTy &UDirs) {
NamespaceSet VisitedNS;
@@ -100,7 +100,7 @@ static void AddScopeUsingDirectives(ASTContext &Context, Scope *S,
NamespaceDecl *Nominated = UD->getNominatedNamespace();
if (!VisitedNS.count(Nominated)) {
VisitedNS.insert(Nominated);
- AddNamespaceUsingDirectives(Context, Nominated, UDirs,
+ AddNamespaceUsingDirectives(Context, Nominated, UDirs,
/*ref*/ VisitedNS);
}
}
@@ -112,7 +112,7 @@ static void AddScopeUsingDirectives(ASTContext &Context, Scope *S,
/// *I is a match for the namespace. This routine returns an
/// appropriate Decl for name lookup, which may either be *I or an
/// OverloadedFunctionDecl that represents the overloaded functions in
-/// [I, IEnd).
+/// [I, IEnd).
///
/// The existance of this routine is temporary; users of LookupResult
/// should be able to handle multiple results, to deal with cases of
@@ -120,10 +120,10 @@ static void AddScopeUsingDirectives(ASTContext &Context, Scope *S,
/// Decl node.
template<typename DeclIterator>
static NamedDecl *
-MaybeConstructOverloadSet(ASTContext &Context,
+MaybeConstructOverloadSet(ASTContext &Context,
DeclIterator I, DeclIterator IEnd) {
assert(I != IEnd && "Iterator range cannot be empty");
- assert(!isa<OverloadedFunctionDecl>(*I) &&
+ assert(!isa<OverloadedFunctionDecl>(*I) &&
"Cannot have an overloaded function");
if ((*I)->isFunctionOrFunctionTemplate()) {
@@ -131,8 +131,8 @@ MaybeConstructOverloadSet(ASTContext &Context,
// so, collect them into an overload set.
DeclIterator Last = I;
OverloadedFunctionDecl *Ovl = 0;
- for (++Last;
- Last != IEnd && (*Last)->isFunctionOrFunctionTemplate();
+ for (++Last;
+ Last != IEnd && (*Last)->isFunctionOrFunctionTemplate();
++Last) {
if (!Ovl) {
// FIXME: We leak this overload set. Eventually, we want to stop
@@ -153,13 +153,13 @@ MaybeConstructOverloadSet(ASTContext &Context,
else
Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
}
-
+
// If we had more than one function, we built an overload
// set. Return it.
if (Ovl)
return Ovl;
}
-
+
return *I;
}
@@ -215,7 +215,7 @@ MergeLookupResults(ASTContext &Context, LookupResultsTy &Results) {
case LResult::Found: {
NamedDecl *ND = I->getAsDecl()->getUnderlyingDecl();
-
+
if (TagDecl *TD = dyn_cast<TagDecl>(ND)) {
TagFound = TD->getCanonicalDecl();
TagNames += FoundDecls.insert(TagFound)? 1 : 0;
@@ -234,7 +234,7 @@ MergeLookupResults(ASTContext &Context, LookupResultsTy &Results) {
}
OrdinaryNonFunc = FoundDecls.size() - TagNames - Functions;
bool Ambiguous = false, NameHidesTags = false;
-
+
if (FoundDecls.size() == 1) {
// 1) Exactly one result.
} else if (TagNames > 1) {
@@ -264,7 +264,7 @@ MergeLookupResults(ASTContext &Context, LookupResultsTy &Results) {
}
if (Ambiguous)
- return LResult::CreateLookupResult(Context,
+ return LResult::CreateLookupResult(Context,
FoundDecls.begin(), FoundDecls.size());
if (NameHidesTags) {
// There's only one tag, TagFound. Remove it.
@@ -281,8 +281,8 @@ MergeLookupResults(ASTContext &Context, LookupResultsTy &Results) {
// Retrieve the set of identifier namespaces that correspond to a
// specific kind of name lookup.
-inline unsigned
-getIdentifierNamespacesFromLookupNameKind(Sema::LookupNameKind NameKind,
+inline unsigned
+getIdentifierNamespacesFromLookupNameKind(Sema::LookupNameKind NameKind,
bool CPlusPlus) {
unsigned IDNS = 0;
switch (NameKind) {
@@ -301,7 +301,7 @@ getIdentifierNamespacesFromLookupNameKind(Sema::LookupNameKind NameKind,
case Sema::LookupMemberName:
IDNS = Decl::IDNS_Member;
if (CPlusPlus)
- IDNS |= Decl::IDNS_Tag | Decl::IDNS_Ordinary;
+ IDNS |= Decl::IDNS_Tag | Decl::IDNS_Ordinary;
break;
case Sema::LookupNestedNameSpecifierName:
@@ -328,7 +328,7 @@ Sema::LookupResult
Sema::LookupResult::CreateLookupResult(ASTContext &Context, NamedDecl *D) {
if (D)
D = D->getUnderlyingDecl();
-
+
LookupResult Result;
Result.StoredKind = (D && isa<OverloadedFunctionDecl>(D))?
OverloadedDeclSingleDecl : SingleDecl;
@@ -340,8 +340,8 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context, NamedDecl *D) {
/// @brief Moves the name-lookup results from Other to this LookupResult.
Sema::LookupResult
-Sema::LookupResult::CreateLookupResult(ASTContext &Context,
- IdentifierResolver::iterator F,
+Sema::LookupResult::CreateLookupResult(ASTContext &Context,
+ IdentifierResolver::iterator F,
IdentifierResolver::iterator L) {
LookupResult Result;
Result.Context = &Context;
@@ -355,7 +355,7 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context,
Result.Last = L.getAsOpaqueValue();
return Result;
}
- }
+ }
NamedDecl *D = *F;
if (D)
@@ -368,8 +368,8 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context,
}
Sema::LookupResult
-Sema::LookupResult::CreateLookupResult(ASTContext &Context,
- DeclContext::lookup_iterator F,
+Sema::LookupResult::CreateLookupResult(ASTContext &Context,
+ DeclContext::lookup_iterator F,
DeclContext::lookup_iterator L) {
LookupResult Result;
Result.Context = &Context;
@@ -388,7 +388,7 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context,
NamedDecl *D = *F;
if (D)
D = D->getUnderlyingDecl();
-
+
Result.StoredKind = SingleDecl;
Result.First = reinterpret_cast<uintptr_t>(D);
Result.Last = 0;
@@ -424,7 +424,7 @@ Sema::LookupResult::LookupKind Sema::LookupResult::getKind() const {
/// (if only a single declaration was found), an
/// OverloadedFunctionDecl (if an overloaded function was found), or
/// NULL (if no declaration was found). This conversion must not be
-/// used anywhere where name lookup could result in an ambiguity.
+/// used anywhere where name lookup could result in an ambiguity.
///
/// The OverloadedFunctionDecl conversion is meant as a stop-gap
/// solution, since it causes the OverloadedFunctionDecl to be
@@ -441,7 +441,7 @@ NamedDecl *Sema::LookupResult::getAsDecl() const {
IdentifierResolver::iterator::getFromOpaqueValue(Last));
case OverloadedDeclFromDeclContext:
- return MaybeConstructOverloadSet(*Context,
+ return MaybeConstructOverloadSet(*Context,
reinterpret_cast<DeclContext::lookup_iterator>(First),
reinterpret_cast<DeclContext::lookup_iterator>(Last));
@@ -450,7 +450,7 @@ NamedDecl *Sema::LookupResult::getAsDecl() const {
case AmbiguousLookupStoresDecls:
case AmbiguousLookupStoresBasePaths:
- assert(false &&
+ assert(false &&
"Name lookup returned an ambiguity that could not be handled");
break;
}
@@ -466,7 +466,7 @@ BasePaths *Sema::LookupResult::getBasePaths() const {
return 0;
}
-Sema::LookupResult::iterator::reference
+Sema::LookupResult::iterator::reference
Sema::LookupResult::iterator::operator*() const {
switch (Result->StoredKind) {
case SingleDecl:
@@ -507,14 +507,14 @@ Sema::LookupResult::iterator& Sema::LookupResult::iterator::operator++() {
}
case OverloadedDeclFromIdResolver: {
- IdentifierResolver::iterator I
+ IdentifierResolver::iterator I
= IdentifierResolver::iterator::getFromOpaqueValue(Current);
++I;
Current = I.getAsOpaqueValue();
break;
}
- case AmbiguousLookupStoresBasePaths:
+ case AmbiguousLookupStoresBasePaths:
if (Result->Last) {
NamedDecl ** I = reinterpret_cast<NamedDecl**>(Current);
++I;
@@ -526,7 +526,7 @@ Sema::LookupResult::iterator& Sema::LookupResult::iterator::operator++() {
case OverloadedDeclFromDeclContext:
case AmbiguousLookupStoresDecls: {
- DeclContext::lookup_iterator I
+ DeclContext::lookup_iterator I
= reinterpret_cast<DeclContext::lookup_iterator>(Current);
++I;
Current = reinterpret_cast<uintptr_t>(I);
@@ -548,13 +548,13 @@ Sema::LookupResult::iterator Sema::LookupResult::begin() {
case OverloadedDeclSingleDecl: {
OverloadedFunctionDecl * Ovl =
reinterpret_cast<OverloadedFunctionDecl*>(First);
- return iterator(this,
+ return iterator(this,
reinterpret_cast<uintptr_t>(&(*Ovl->function_begin())));
}
case AmbiguousLookupStoresBasePaths:
if (Last)
- return iterator(this,
+ return iterator(this,
reinterpret_cast<uintptr_t>(getBasePaths()->found_decls_begin()));
else
return iterator(this,
@@ -576,13 +576,13 @@ Sema::LookupResult::iterator Sema::LookupResult::end() {
case OverloadedDeclSingleDecl: {
OverloadedFunctionDecl * Ovl =
reinterpret_cast<OverloadedFunctionDecl*>(First);
- return iterator(this,
+ return iterator(this,
reinterpret_cast<uintptr_t>(&(*Ovl->function_end())));
}
case AmbiguousLookupStoresBasePaths:
if (Last)
- return iterator(this,
+ return iterator(this,
reinterpret_cast<uintptr_t>(getBasePaths()->found_decls_end()));
else
return iterator(this, reinterpret_cast<uintptr_t>(
@@ -623,7 +623,7 @@ CppNamespaceLookup(ASTContext &Context, DeclContext *NS,
llvm::tie(UI, UEnd) =
std::equal_range(UDirs->begin(), UDirs->end(), NS,
UsingDirAncestorCompare());
-
+
for (; UI != UEnd; ++UI)
CppNamespaceLookup(Context, (*UI)->getNominatedNamespace(),
Name, NameKind, IDNS, Results);
@@ -641,7 +641,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
LookupNameKind NameKind, bool RedeclarationOnly) {
assert(getLangOptions().CPlusPlus &&
"Can perform only C++ lookup");
- unsigned IDNS
+ unsigned IDNS
= getIdentifierNamespacesFromLookupNameKind(NameKind, /*CPlusPlus*/ true);
// If we're testing for redeclarations, also look in the friend namespaces.
@@ -652,7 +652,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
Scope *Initial = S;
DeclContext *OutOfLineCtx = 0;
- IdentifierResolver::iterator
+ IdentifierResolver::iterator
I = IdResolver.begin(Name),
IEnd = IdResolver.end();
@@ -662,7 +662,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
// they were declared in the nearest enclosing namespace which contains
// both the using-directive and the nominated namespace.
// [Note: in this context, "contains" means "contains directly or
- // indirectly".
+ // indirectly".
//
// For example:
// namespace A { int i; }
@@ -705,7 +705,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
if (R)
return std::make_pair(true, R);
}
- if (Ctx->getParent() != Ctx->getLexicalParent()
+ if (Ctx->getParent() != Ctx->getLexicalParent()
|| isa<CXXMethodDecl>(Ctx)) {
// It is out of line defined C++ method or struct, we continue
// doing name lookup in parent context. Once we will find namespace
@@ -780,7 +780,7 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
if (!S->isDeclScope(DeclPtrTy::make(*LastI)))
break;
}
-
+
// We store name lookup result, and continue trying to look into
// associated context, and maybe namespaces nominated by
// using-directives.
@@ -834,13 +834,13 @@ Sema::CppLookupName(Scope *S, DeclarationName Name,
/// @param Name The name of the entity that we are searching for.
///
/// @param Loc If provided, the source location where we're performing
-/// name lookup. At present, this is only used to produce diagnostics when
+/// name lookup. At present, this is only used to produce diagnostics when
/// C library functions (like "malloc") are implicitly declared.
///
/// @returns The result of name lookup, which includes zero or more
/// declarations and possibly additional information used to diagnose
/// ambiguities.
-Sema::LookupResult
+Sema::LookupResult
Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
bool RedeclarationOnly, bool AllowBuiltinCreation,
SourceLocation Loc) {
@@ -872,7 +872,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
case Sema::LookupRedeclarationWithLinkage:
// Find the nearest non-transparent declaration scope.
while (!(S->getFlags() & Scope::DeclScope) ||
- (S->getEntity() &&
+ (S->getEntity() &&
static_cast<DeclContext *>(S->getEntity())
->isTransparentContext()))
S = S->getParent();
@@ -886,7 +886,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
case Sema::LookupObjCImplementationName:
IDNS = Decl::IDNS_ObjCImplementation;
break;
-
+
case Sema::LookupObjCCategoryImplName:
IDNS = Decl::IDNS_ObjCCategoryImpl;
break;
@@ -899,7 +899,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
bool LeftStartingScope = false;
for (IdentifierResolver::iterator I = IdResolver.begin(Name),
- IEnd = IdResolver.end();
+ IEnd = IdResolver.end();
I != IEnd; ++I)
if ((*I)->isInIdentifierNamespace(IDNS)) {
if (NameKind == LookupRedeclarationWithLinkage) {
@@ -948,7 +948,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
// If we didn't find a use of this identifier, and if the identifier
// corresponds to a compiler builtin, create the decl object for the builtin
// now, injecting it into translation unit scope, and return it.
- if (NameKind == LookupOrdinaryName ||
+ if (NameKind == LookupOrdinaryName ||
NameKind == LookupRedeclarationWithLinkage) {
IdentifierInfo *II = Name.getAsIdentifierInfo();
if (II && AllowBuiltinCreation) {
@@ -956,7 +956,7 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind,
if (unsigned BuiltinID = II->getBuiltinID()) {
// In C++, we don't have any predefined library functions like
// 'malloc'. Instead, we'll just error.
- if (getLangOptions().CPlusPlus &&
+ if (getLangOptions().CPlusPlus &&
Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
return LookupResult::CreateLookupResult(Context, 0);
@@ -1003,18 +1003,18 @@ Sema::LookupResult
Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
LookupNameKind NameKind, bool RedeclarationOnly) {
assert(LookupCtx && "Sema::LookupQualifiedName requires a lookup context");
-
- if (!Name)
+
+ if (!Name)
return LookupResult::CreateLookupResult(Context, 0);
-
+
// If we're performing qualified name lookup (e.g., lookup into a
// struct), find fields as part of ordinary name lookup.
unsigned IDNS
- = getIdentifierNamespacesFromLookupNameKind(NameKind,
+ = getIdentifierNamespacesFromLookupNameKind(NameKind,
getLangOptions().CPlusPlus);
if (NameKind == LookupOrdinaryName)
IDNS |= Decl::IDNS_Member;
-
+
// Make sure that the declaration context is complete.
assert((!isa<TagDecl>(LookupCtx) ||
LookupCtx->isDependentContext() ||
@@ -1022,7 +1022,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
Context.getTypeDeclType(cast<TagDecl>(LookupCtx))->getAs<TagType>()
->isBeingDefined()) &&
"Declaration context must already be complete!");
-
+
// Perform qualified name lookup into the LookupCtx.
DeclContext::lookup_iterator I, E;
for (llvm::tie(I, E) = LookupCtx->lookup(Name); I != E; ++I)
@@ -1031,7 +1031,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
// If this isn't a C++ class, we aren't allowed to look into base
// classes, we're done, or the lookup context is dependent, we're done.
- if (RedeclarationOnly || !isa<CXXRecordDecl>(LookupCtx) ||
+ if (RedeclarationOnly || !isa<CXXRecordDecl>(LookupCtx) ||
LookupCtx->isDependentContext())
return LookupResult::CreateLookupResult(Context, 0);
@@ -1040,7 +1040,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
Paths.setOrigin(Context.getTypeDeclType(cast<RecordDecl>(LookupCtx)));
// Look for this member in our base classes
- if (!LookupInBases(cast<CXXRecordDecl>(LookupCtx),
+ if (!LookupInBases(cast<CXXRecordDecl>(LookupCtx),
MemberLookupCriteria(Name, NameKind, IDNS), Paths))
return LookupResult::CreateLookupResult(Context, 0);
@@ -1062,7 +1062,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
// This is the first subobject we've looked at. Record it's type.
SubobjectType = Context.getCanonicalType(PathElement.Base->getType());
SubobjectNumber = PathElement.SubobjectNumber;
- } else if (SubobjectType
+ } else if (SubobjectType
!= Context.getCanonicalType(PathElement.Base->getType())) {
// We found members of the given name in two subobjects of
// different types. This lookup is ambiguous.
@@ -1075,7 +1075,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
// C++ [class.member.lookup]p5:
// A static member, a nested type or an enumerator defined in
// a base class T can unambiguously be found even if an object
- // has more than one base class subobject of type T.
+ // has more than one base class subobject of type T.
Decl *FirstDecl = *Path->Decls.first;
if (isa<VarDecl>(FirstDecl) ||
isa<TypeDecl>(FirstDecl) ||
@@ -1114,7 +1114,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
// If we found a function declaration, return an overload set.
if ((*Paths.front().Decls.first)->isFunctionOrFunctionTemplate())
- return LookupResult::CreateLookupResult(Context,
+ return LookupResult::CreateLookupResult(Context,
Paths.front().Decls.first, Paths.front().Decls.second);
// We found a non-function declaration; return a single declaration.
@@ -1132,14 +1132,14 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
///
/// @param S The scope from which unqualified name lookup will
/// begin.
-///
+///
/// @param SS An optional C++ scope-specifier, e.g., "::N::M".
///
/// @param Name The name of the entity that name lookup will
/// search for.
///
/// @param Loc If provided, the source location where we're performing
-/// name lookup. At present, this is only used to produce diagnostics when
+/// name lookup. At present, this is only used to produce diagnostics when
/// C library functions (like "malloc") are implicitly declared.
///
/// @param EnteringContext Indicates whether we are going to enter the
@@ -1147,7 +1147,7 @@ Sema::LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name,
///
/// @returns The result of qualified or unqualified name lookup.
Sema::LookupResult
-Sema::LookupParsedName(Scope *S, const CXXScopeSpec *SS,
+Sema::LookupParsedName(Scope *S, const CXXScopeSpec *SS,
DeclarationName Name, LookupNameKind NameKind,
bool RedeclarationOnly, bool AllowBuiltinCreation,
SourceLocation Loc,
@@ -1157,25 +1157,25 @@ Sema::LookupParsedName(Scope *S, const CXXScopeSpec *SS,
// anything.
return LookupResult::CreateLookupResult(Context, 0);
}
-
+
if (SS && SS->isSet()) {
if (DeclContext *DC = computeDeclContext(*SS, EnteringContext)) {
- // We have resolved the scope specifier to a particular declaration
+ // We have resolved the scope specifier to a particular declaration
// contex, and will perform name lookup in that context.
if (!DC->isDependentContext() && RequireCompleteDeclContext(*SS))
return LookupResult::CreateLookupResult(Context, 0);
-
+
return LookupQualifiedName(DC, Name, NameKind, RedeclarationOnly);
}
// We could not resolve the scope specified to a specific declaration
- // context, which means that SS refers to an unknown specialization.
+ // context, which means that SS refers to an unknown specialization.
// Name lookup can't find anything in this case.
return LookupResult::CreateLookupResult(Context, 0);
}
- // Perform unqualified name lookup starting in the given scope.
- return LookupName(S, Name, NameKind, RedeclarationOnly, AllowBuiltinCreation,
+ // Perform unqualified name lookup starting in the given scope.
+ return LookupName(S, Name, NameKind, RedeclarationOnly, AllowBuiltinCreation,
Loc);
}
@@ -1184,7 +1184,7 @@ Sema::LookupParsedName(Scope *S, const CXXScopeSpec *SS,
/// from name lookup.
///
/// @param Result The ambiguous name lookup result.
-///
+///
/// @param Name The name of the entity that name lookup was
/// searching for.
///
@@ -1197,7 +1197,7 @@ Sema::LookupParsedName(Scope *S, const CXXScopeSpec *SS,
///
/// @returns true
bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
- SourceLocation NameLoc,
+ SourceLocation NameLoc,
SourceRange LookupRange) {
assert(Result.isAmbiguous() && "Lookup result must be ambiguous");
@@ -1209,7 +1209,7 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
<< LookupRange;
DeclContext::lookup_iterator Found = Paths->front().Decls.first;
- while (isa<CXXMethodDecl>(*Found) &&
+ while (isa<CXXMethodDecl>(*Found) &&
cast<CXXMethodDecl>(*Found)->isStatic())
++Found;
@@ -1217,7 +1217,7 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
Result.Destroy();
return true;
- }
+ }
assert(Result.getKind() == LookupResult::AmbiguousBaseSubobjectTypes &&
"Unhandled form of name lookup ambiguity");
@@ -1254,8 +1254,8 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,
return true;
}
-static void
-addAssociatedClassesAndNamespaces(QualType T,
+static void
+addAssociatedClassesAndNamespaces(QualType T,
ASTContext &Context,
Sema::AssociatedNamespaceSet &AssociatedNamespaces,
Sema::AssociatedClassSet &AssociatedClasses);
@@ -1266,19 +1266,19 @@ static void CollectNamespace(Sema::AssociatedNamespaceSet &Namespaces,
Namespaces.insert(Ctx);
}
-// \brief Add the associated classes and namespaces for argument-dependent
+// \brief Add the associated classes and namespaces for argument-dependent
// lookup that involves a template argument (C++ [basic.lookup.koenig]p2).
-static void
-addAssociatedClassesAndNamespaces(const TemplateArgument &Arg,
+static void
+addAssociatedClassesAndNamespaces(const TemplateArgument &Arg,
ASTContext &Context,
Sema::AssociatedNamespaceSet &AssociatedNamespaces,
Sema::AssociatedClassSet &AssociatedClasses) {
// C++ [basic.lookup.koenig]p2, last bullet:
- // -- [...] ;
+ // -- [...] ;
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
-
+
case TemplateArgument::Type:
// [...] the namespaces and classes associated with the types of the
// template arguments provided for template type parameters (excluding
@@ -1287,12 +1287,12 @@ addAssociatedClassesAndNamespaces(const TemplateArgument &Arg,
AssociatedNamespaces,
AssociatedClasses);
break;
-
+
case TemplateArgument::Declaration:
- // [...] the namespaces in which any template template arguments are
- // defined; and the classes in which any member templates used as
+ // [...] the namespaces in which any template template arguments are
+ // defined; and the classes in which any member templates used as
// template template arguments are defined.
- if (ClassTemplateDecl *ClassTemplate
+ if (ClassTemplateDecl *ClassTemplate
= dyn_cast<ClassTemplateDecl>(Arg.getAsDecl())) {
DeclContext *Ctx = ClassTemplate->getDeclContext();
if (CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
@@ -1303,13 +1303,13 @@ addAssociatedClassesAndNamespaces(const TemplateArgument &Arg,
CollectNamespace(AssociatedNamespaces, Ctx);
}
break;
-
+
case TemplateArgument::Integral:
case TemplateArgument::Expression:
- // [Note: non-type template arguments do not contribute to the set of
+ // [Note: non-type template arguments do not contribute to the set of
// associated namespaces. ]
break;
-
+
case TemplateArgument::Pack:
for (TemplateArgument::pack_iterator P = Arg.pack_begin(),
PEnd = Arg.pack_end();
@@ -1322,10 +1322,10 @@ addAssociatedClassesAndNamespaces(const TemplateArgument &Arg,
}
// \brief Add the associated classes and namespaces for
-// argument-dependent lookup with an argument of class type
-// (C++ [basic.lookup.koenig]p2).
-static void
-addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
+// argument-dependent lookup with an argument of class type
+// (C++ [basic.lookup.koenig]p2).
+static void
+addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
ASTContext &Context,
Sema::AssociatedNamespaceSet &AssociatedNamespaces,
Sema::AssociatedClassSet &AssociatedClasses) {
@@ -1335,7 +1335,7 @@ addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
// classes are: the class itself; the class of which it is a
// member, if any; and its direct and indirect base
// classes. Its associated namespaces are the namespaces in
- // which its associated classes are defined.
+ // which its associated classes are defined.
// Add the class of which it is a member, if any.
DeclContext *Ctx = Class->getDeclContext();
@@ -1345,22 +1345,22 @@ addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
while (Ctx->isRecord())
Ctx = Ctx->getParent();
CollectNamespace(AssociatedNamespaces, Ctx);
-
+
// Add the class itself. If we've already seen this class, we don't
// need to visit base classes.
if (!AssociatedClasses.insert(Class))
return;
- // -- If T is a template-id, its associated namespaces and classes are
- // the namespace in which the template is defined; for member
+ // -- If T is a template-id, its associated namespaces and classes are
+ // the namespace in which the template is defined; for member
// templates, the member template’s class; the namespaces and classes
- // associated with the types of the template arguments provided for
+ // associated with the types of the template arguments provided for
// template type parameters (excluding template template parameters); the
- // namespaces in which any template template arguments are defined; and
- // the classes in which any member templates used as template template
- // arguments are defined. [Note: non-type template arguments do not
+ // namespaces in which any template template arguments are defined; and
+ // the classes in which any member templates used as template template
+ // arguments are defined. [Note: non-type template arguments do not
// contribute to the set of associated namespaces. ]
- if (ClassTemplateSpecializationDecl *Spec
+ if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
if (CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
@@ -1369,14 +1369,14 @@ addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
while (Ctx->isRecord())
Ctx = Ctx->getParent();
CollectNamespace(AssociatedNamespaces, Ctx);
-
+
const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
addAssociatedClassesAndNamespaces(TemplateArgs[I], Context,
AssociatedNamespaces,
AssociatedClasses);
}
-
+
// Add direct and indirect base classes along with their associated
// namespaces.
llvm::SmallVector<CXXRecordDecl *, 32> Bases;
@@ -1409,9 +1409,9 @@ addAssociatedClassesAndNamespaces(CXXRecordDecl *Class,
// \brief Add the associated classes and namespaces for
// argument-dependent lookup with an argument of type T
-// (C++ [basic.lookup.koenig]p2).
-static void
-addAssociatedClassesAndNamespaces(QualType T,
+// (C++ [basic.lookup.koenig]p2).
+static void
+addAssociatedClassesAndNamespaces(QualType T,
ASTContext &Context,
Sema::AssociatedNamespaceSet &AssociatedNamespaces,
Sema::AssociatedClassSet &AssociatedClasses) {
@@ -1428,7 +1428,7 @@ addAssociatedClassesAndNamespaces(QualType T,
T = Context.getCanonicalType(T).getUnqualifiedType();
// -- If T is a pointer to U or an array of U, its associated
- // namespaces and classes are those associated with U.
+ // namespaces and classes are those associated with U.
//
// We handle this by unwrapping pointer and array types immediately,
// to avoid unnecessary recursion.
@@ -1437,7 +1437,7 @@ addAssociatedClassesAndNamespaces(QualType T,
T = Ptr->getPointeeType();
else if (const ArrayType *Ptr = Context.getAsArrayType(T))
T = Ptr->getElementType();
- else
+ else
break;
}
@@ -1450,12 +1450,12 @@ addAssociatedClassesAndNamespaces(QualType T,
// classes are: the class itself; the class of which it is a
// member, if any; and its direct and indirect base
// classes. Its associated namespaces are the namespaces in
- // which its associated classes are defined.
+ // which its associated classes are defined.
if (const RecordType *ClassType = T->getAs<RecordType>())
- if (CXXRecordDecl *ClassDecl
+ if (CXXRecordDecl *ClassDecl
= dyn_cast<CXXRecordDecl>(ClassType->getDecl())) {
- addAssociatedClassesAndNamespaces(ClassDecl, Context,
- AssociatedNamespaces,
+ addAssociatedClassesAndNamespaces(ClassDecl, Context,
+ AssociatedNamespaces,
AssociatedClasses);
return;
}
@@ -1463,7 +1463,7 @@ addAssociatedClassesAndNamespaces(QualType T,
// -- If T is an enumeration type, its associated namespace is
// the namespace in which it is defined. If it is class
// member, its associated class is the member’s class; else
- // it has no associated class.
+ // it has no associated class.
if (const EnumType *EnumT = T->getAsEnumType()) {
EnumDecl *Enum = EnumT->getDecl();
@@ -1484,7 +1484,7 @@ addAssociatedClassesAndNamespaces(QualType T,
// types and those associated with the return type.
if (const FunctionType *FunctionType = T->getAsFunctionType()) {
// Return type
- addAssociatedClassesAndNamespaces(FunctionType->getResultType(),
+ addAssociatedClassesAndNamespaces(FunctionType->getResultType(),
Context,
AssociatedNamespaces, AssociatedClasses);
@@ -1494,23 +1494,23 @@ addAssociatedClassesAndNamespaces(QualType T,
// Argument types
for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
- ArgEnd = Proto->arg_type_end();
+ ArgEnd = Proto->arg_type_end();
Arg != ArgEnd; ++Arg)
addAssociatedClassesAndNamespaces(*Arg, Context,
AssociatedNamespaces, AssociatedClasses);
-
+
return;
}
// -- If T is a pointer to a member function of a class X, its
// associated namespaces and classes are those associated
// with the function parameter types and return type,
- // together with those associated with X.
+ // together with those associated with X.
//
// -- If T is a pointer to a data member of class X, its
// associated namespaces and classes are those associated
// with the member type together with those associated with
- // X.
+ // X.
if (const MemberPointerType *MemberPtr = T->getAs<MemberPointerType>()) {
// Handle the type that the pointer to member points to.
addAssociatedClassesAndNamespaces(MemberPtr->getPointeeType(),
@@ -1537,9 +1537,9 @@ addAssociatedClassesAndNamespaces(QualType T,
/// arguments.
///
/// This routine computes the sets of associated classes and associated
-/// namespaces searched by argument-dependent lookup
+/// namespaces searched by argument-dependent lookup
/// (C++ [basic.lookup.argdep]) for a given set of arguments.
-void
+void
Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
AssociatedNamespaceSet &AssociatedNamespaces,
AssociatedClassSet &AssociatedClasses) {
@@ -1552,7 +1552,7 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
// associated classes to be considered. The sets of namespaces and
// classes is determined entirely by the types of the function
// arguments (and the namespace of any template template
- // argument).
+ // argument).
for (unsigned ArgIdx = 0; ArgIdx != NumArgs; ++ArgIdx) {
Expr *Arg = Args[ArgIdx];
@@ -1582,7 +1582,7 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
DRE = dyn_cast<DeclRefExpr>(Arg);
TIRE = dyn_cast<TemplateIdRefExpr>(Arg);
}
-
+
OverloadedFunctionDecl *Ovl = 0;
if (DRE)
Ovl = dyn_cast<OverloadedFunctionDecl>(DRE->getDecl());
@@ -1618,7 +1618,7 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
/// arguments have types T1 (and, if non-empty, T2). This routine
/// implements the check in C++ [over.match.oper]p3b2 concerning
/// enumeration types.
-static bool
+static bool
IsAcceptableNonMemberOperatorCandidate(FunctionDecl *Fn,
QualType T1, QualType T2,
ASTContext &Context) {
@@ -1686,7 +1686,7 @@ Decl *Sema::LookupQualifiedNameWithType(DeclContext *DC,
}
void Sema::LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
- QualType T1, QualType T2,
+ QualType T1, QualType T2,
FunctionSet &Functions) {
// C++ [over.match.oper]p3:
// -- The set of non-member candidates is the result of the
@@ -1702,7 +1702,7 @@ void Sema::LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
// when T2 is an enumeration type, are candidate functions.
DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(Op);
LookupResult Operators = LookupName(S, OpName, LookupOperatorName);
-
+
assert(!Operators.isAmbiguous() && "Operator lookup cannot be ambiguous");
if (!Operators)
@@ -1713,10 +1713,10 @@ void Sema::LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*Op)) {
if (IsAcceptableNonMemberOperatorCandidate(FD, T1, T2, Context))
Functions.insert(FD); // FIXME: canonical FD
- } else if (FunctionTemplateDecl *FunTmpl
+ } else if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>(*Op)) {
// FIXME: friend operators?
- // FIXME: do we need to check IsAcceptableNonMemberOperatorCandidate,
+ // FIXME: do we need to check IsAcceptableNonMemberOperatorCandidate,
// later?
if (!FunTmpl->getDeclContext()->isRecord())
Functions.insert(FunTmpl);
@@ -1739,7 +1739,7 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
// arguments we have.
AssociatedNamespaceSet AssociatedNamespaces;
AssociatedClassSet AssociatedClasses;
- FindAssociatedClassesAndNamespaces(Args, NumArgs,
+ FindAssociatedClassesAndNamespaces(Args, NumArgs,
AssociatedNamespaces,
AssociatedClasses);
@@ -1755,8 +1755,8 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
// Here, we compute Y and add its members to the overloaded
// candidate set.
for (AssociatedNamespaceSet::iterator NS = AssociatedNamespaces.begin(),
- NSEnd = AssociatedNamespaces.end();
- NS != NSEnd; ++NS) {
+ NSEnd = AssociatedNamespaces.end();
+ NS != NSEnd; ++NS) {
// When considering an associated namespace, the lookup is the
// same as the lookup performed when the associated namespace is
// used as a qualifier (3.4.3.2) except that:
@@ -1778,7 +1778,7 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
if (!AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)))
continue;
}
-
+
CollectFunctionDecl(Functions, D);
}
}
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 1427d48bc2..c5bbd34af8 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -30,7 +30,7 @@ namespace clang {
/// GetConversionCategory - Retrieve the implicit conversion
/// category corresponding to the given implicit conversion kind.
-ImplicitConversionCategory
+ImplicitConversionCategory
GetConversionCategory(ImplicitConversionKind Kind) {
static const ImplicitConversionCategory
Category[(int)ICK_Num_Conversion_Kinds] = {
@@ -138,10 +138,9 @@ ImplicitConversionRank StandardConversionSequence::getRank() const {
/// isPointerConversionToBool - Determines whether this conversion is
/// a conversion of a pointer or pointer-to-member to bool. This is
-/// used as part of the ranking of standard conversion sequences
+/// used as part of the ranking of standard conversion sequences
/// (C++ 13.3.3.2p4).
-bool StandardConversionSequence::isPointerConversionToBool() const
-{
+bool StandardConversionSequence::isPointerConversionToBool() const {
QualType FromType = QualType::getFromOpaquePtr(FromTypePtr);
QualType ToType = QualType::getFromOpaquePtr(ToTypePtr);
@@ -161,10 +160,9 @@ bool StandardConversionSequence::isPointerConversionToBool() const
/// conversion is a conversion of a pointer to a void pointer. This is
/// used as part of the ranking of standard conversion sequences (C++
/// 13.3.3.2p4).
-bool
+bool
StandardConversionSequence::
-isPointerConversionToVoidPointer(ASTContext& Context) const
-{
+isPointerConversionToVoidPointer(ASTContext& Context) const {
QualType FromType = QualType::getFromOpaquePtr(FromTypePtr);
QualType ToType = QualType::getFromOpaquePtr(ToTypePtr);
@@ -262,7 +260,7 @@ void ImplicitConversionSequence::DebugPrint() const {
// same signature (C++ 1.3.10) or if the Old declaration isn't a
// function (or overload set). When it does return false and Old is an
// OverloadedFunctionDecl, MatchedDecl will be set to point to the
-// FunctionDecl that New cannot be overloaded with.
+// FunctionDecl that New cannot be overloaded with.
//
// Example: Given the following input:
//
@@ -271,7 +269,7 @@ void ImplicitConversionSequence::DebugPrint() const {
// int f(int, int); // #3
//
// When we process #1, there is no previous declaration of "f",
-// so IsOverload will not be used.
+// so IsOverload will not be used.
//
// When we process #2, Old is a FunctionDecl for #1. By comparing the
// parameter types, we see that #1 and #2 are overloaded (since they
@@ -285,9 +283,8 @@ void ImplicitConversionSequence::DebugPrint() const {
// signature), IsOverload returns false and MatchedDecl will be set to
// point to the FunctionDecl for #2.
bool
-Sema::IsOverload(FunctionDecl *New, Decl* OldD,
- OverloadedFunctionDecl::function_iterator& MatchedDecl)
-{
+Sema::IsOverload(FunctionDecl *New, Decl* OldD,
+ OverloadedFunctionDecl::function_iterator& MatchedDecl) {
if (OverloadedFunctionDecl* Ovl = dyn_cast<OverloadedFunctionDecl>(OldD)) {
// Is this new function an overload of every function in the
// overload set?
@@ -306,8 +303,8 @@ Sema::IsOverload(FunctionDecl *New, Decl* OldD,
return IsOverload(New, Old->getTemplatedDecl(), MatchedDecl);
else if (FunctionDecl* Old = dyn_cast<FunctionDecl>(OldD)) {
FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate();
- FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
-
+ FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate();
+
// C++ [temp.fct]p2:
// A function template can be overloaded with other function templates
// and with normal (non-template) functions.
@@ -342,21 +339,21 @@ Sema::IsOverload(FunctionDecl *New, Decl* OldD,
return true;
// C++ [temp.over.link]p4:
- // The signature of a function template consists of its function
+ // The signature of a function template consists of its function
// signature, its return type and its template parameter list. The names
// of the template parameters are significant only for establishing the
- // relationship between the template parameters and the rest of the
+ // relationship between the template parameters and the rest of the
// signature.
//
// We check the return type and template parameter lists for function
// templates first; the remaining checks follow.
if (NewTemplate &&
- (!TemplateParameterListsAreEqual(NewTemplate->getTemplateParameters(),
- OldTemplate->getTemplateParameters(),
+ (!TemplateParameterListsAreEqual(NewTemplate->getTemplateParameters(),
+ OldTemplate->getTemplateParameters(),
false, false, SourceLocation()) ||
OldType->getResultType() != NewType->getResultType()))
return true;
-
+
// If the function is a class member, its signature includes the
// cv-qualifiers (if any) on the function itself.
//
@@ -367,7 +364,7 @@ Sema::IsOverload(FunctionDecl *New, Decl* OldD,
// can be overloaded.
CXXMethodDecl* OldMethod = dyn_cast<CXXMethodDecl>(Old);
CXXMethodDecl* NewMethod = dyn_cast<CXXMethodDecl>(New);
- if (OldMethod && NewMethod &&
+ if (OldMethod && NewMethod &&
!OldMethod->isStatic() && !NewMethod->isStatic() &&
OldMethod->getTypeQualifiers() != NewMethod->getTypeQualifiers())
return true;
@@ -411,13 +408,12 @@ ImplicitConversionSequence
Sema::TryImplicitConversion(Expr* From, QualType ToType,
bool SuppressUserConversions,
bool AllowExplicit, bool ForceRValue,
- bool InOverloadResolution)
-{
+ bool InOverloadResolution) {
ImplicitConversionSequence ICS;
if (IsStandardConversion(From, ToType, InOverloadResolution, ICS.Standard))
ICS.ConversionKind = ImplicitConversionSequence::StandardConversion;
else if (getLangOptions().CPlusPlus &&
- IsUserDefinedConversion(From, ToType, ICS.UserDefined,
+ IsUserDefinedConversion(From, ToType, ICS.UserDefined,
!SuppressUserConversions, AllowExplicit,
ForceRValue)) {
ICS.ConversionKind = ImplicitConversionSequence::UserDefinedConversion;
@@ -428,9 +424,9 @@ Sema::TryImplicitConversion(Expr* From, QualType ToType,
// given Conversion rank, in spite of the fact that a copy
// constructor (i.e., a user-defined conversion function) is
// called for those cases.
- if (CXXConstructorDecl *Constructor
+ if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) {
- QualType FromCanon
+ QualType FromCanon
= Context.getCanonicalType(From->getType().getUnqualifiedType());
QualType ToCanon = Context.getCanonicalType(ToType).getUnqualifiedType();
if (FromCanon == ToCanon || IsDerivedFrom(FromCanon, ToCanon)) {
@@ -470,11 +466,10 @@ Sema::TryImplicitConversion(Expr* From, QualType ToType,
/// contain the standard conversion sequence required to perform this
/// conversion and this routine will return true. Otherwise, this
/// routine will return false and the value of SCS is unspecified.
-bool
-Sema::IsStandardConversion(Expr* From, QualType ToType,
+bool
+Sema::IsStandardConversion(Expr* From, QualType ToType,
bool InOverloadResolution,
- StandardConversionSequence &SCS)
-{
+ StandardConversionSequence &SCS) {
QualType FromType = From->getType();
// Standard conversions (C++ [conv])
@@ -485,23 +480,23 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
SCS.CopyConstructor = 0;
// There are no standard conversions for class types in C++, so
- // abort early. When overloading in C, however, we do permit
+ // abort early. When overloading in C, however, we do permit
if (FromType->isRecordType() || ToType->isRecordType()) {
if (getLangOptions().CPlusPlus)
return false;
- // When we're overloading in C, we allow, as standard conversions,
+ // When we're overloading in C, we allow, as standard conversions,
}
// The first conversion can be an lvalue-to-rvalue conversion,
// array-to-pointer conversion, or function-to-pointer conversion
// (C++ 4p1).
- // Lvalue-to-rvalue conversion (C++ 4.1):
+ // Lvalue-to-rvalue conversion (C++ 4.1):
// An lvalue (3.10) of a non-function, non-array type T can be
// converted to an rvalue.
Expr::isLvalueResult argIsLvalue = From->isLvalue(Context);
- if (argIsLvalue == Expr::LV_Valid &&
+ if (argIsLvalue == Expr::LV_Valid &&
!FromType->isFunctionType() && !FromType->isArrayType() &&
Context.getCanonicalType(FromType) != Context.OverloadTy) {
SCS.First = ICK_Lvalue_To_Rvalue;
@@ -543,7 +538,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
// type "pointer to T." The result is a pointer to the
// function. (C++ 4.3p1).
FromType = Context.getPointerType(FromType);
- } else if (FunctionDecl *Fn
+ } else if (FunctionDecl *Fn
= ResolveAddressOfOverloadedFunction(From, ToType, false)) {
// Address of overloaded function (C++ [over.over]).
SCS.First = ICK_Function_To_Pointer;
@@ -584,7 +579,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
// conversion to do.
SCS.Second = ICK_Identity;
} else if (IsIntegralPromotion(From, FromType, ToType)) {
- // Integral promotion (C++ 4.5).
+ // Integral promotion (C++ 4.5).
SCS.Second = ICK_Integral_Promotion;
FromType = ToType.getUnqualifiedType();
} else if (IsFloatingPointPromotion(FromType, ToType)) {
@@ -612,7 +607,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
} else if ((FromType->isFloatingType() &&
ToType->isIntegralType() && (!ToType->isBooleanType() &&
!ToType->isEnumeralType())) ||
- ((FromType->isIntegralType() || FromType->isEnumeralType()) &&
+ ((FromType->isIntegralType() || FromType->isEnumeralType()) &&
ToType->isFloatingType())) {
// Floating-integral conversions (C++ 4.9).
// FIXME: isIntegralType shouldn't be true for enums in C++.
@@ -641,7 +636,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
// Boolean conversions (C++ 4.12).
SCS.Second = ICK_Boolean_Conversion;
FromType = Context.BoolTy;
- } else if (!getLangOptions().CPlusPlus &&
+ } else if (!getLangOptions().CPlusPlus &&
Context.typesAreCompatible(ToType, FromType)) {
// Compatible conversions (Clang extension for C function overloading)
SCS.Second = ICK_Compatible_Conversion;
@@ -662,12 +657,12 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
// No conversion required
SCS.Third = ICK_Identity;
- // C++ [over.best.ics]p6:
+ // C++ [over.best.ics]p6:
// [...] Any difference in top-level cv-qualification is
// subsumed by the initialization itself and does not constitute
// a conversion. [...]
CanonFrom = Context.getCanonicalType(FromType);
- CanonTo = Context.getCanonicalType(ToType);
+ CanonTo = Context.getCanonicalType(ToType);
if (CanonFrom.getUnqualifiedType() == CanonTo.getUnqualifiedType() &&
CanonFrom.getCVRQualifiers() != CanonTo.getCVRQualifiers()) {
FromType = ToType;
@@ -688,8 +683,7 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
/// expression From (whose potentially-adjusted type is FromType) to
/// ToType is an integral promotion (C++ 4.5). If so, returns true and
/// sets PromotedType to the promoted type.
-bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
-{
+bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
const BuiltinType *To = ToType->getAsBuiltinType();
// All integers are built-in.
if (!To) {
@@ -706,7 +700,7 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
(FromType->isSignedIntegerType() ||
// We can promote any unsigned integer type whose size is
// less than int to an int.
- (!FromType->isSignedIntegerType() &&
+ (!FromType->isSignedIntegerType() &&
Context.getTypeSize(FromType) < Context.getTypeSize(ToType)))) {
return To->getKind() == BuiltinType::Int;
}
@@ -734,15 +728,15 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
// The types we'll try to promote to, in the appropriate
// order. Try each of these types.
- QualType PromoteTypes[6] = {
- Context.IntTy, Context.UnsignedIntTy,
+ QualType PromoteTypes[6] = {
+ Context.IntTy, Context.UnsignedIntTy,
Context.LongTy, Context.UnsignedLongTy ,
Context.LongLongTy, Context.UnsignedLongLongTy
};
for (int Idx = 0; Idx < 6; ++Idx) {
uint64_t ToSize = Context.getTypeSize(PromoteTypes[Idx]);
if (FromSize < ToSize ||
- (FromSize == ToSize &&
+ (FromSize == ToSize &&
FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
// We found the type that we can promote to. If this is the
// type we wanted, we have a promotion. Otherwise, no
@@ -770,23 +764,23 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
ToSize = Context.getTypeSize(ToType);
-
+
// Are we promoting to an int from a bitfield that fits in an int?
if (BitWidth < ToSize ||
(FromType->isSignedIntegerType() && BitWidth <= ToSize)) {
return To->getKind() == BuiltinType::Int;
}
-
+
// Are we promoting to an unsigned int from an unsigned bitfield
// that fits into an unsigned int?
if (FromType->isUnsignedIntegerType() && BitWidth <= ToSize) {
return To->getKind() == BuiltinType::UInt;
}
-
+
return false;
}
}
-
+
// An rvalue of type bool can be converted to an rvalue of type int,
// with false becoming zero and true becoming one (C++ 4.5p4).
if (FromType->isBooleanType() && To->getKind() == BuiltinType::Int) {
@@ -799,8 +793,7 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
/// IsFloatingPointPromotion - Determines whether the conversion from
/// FromType to ToType is a floating point promotion (C++ 4.6). If so,
/// returns true and sets PromotedType to the promoted type.
-bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType)
-{
+bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
/// An rvalue of type float can be converted to an rvalue of type
/// double. (C++ 4.6p1).
if (const BuiltinType *FromBuiltin = FromType->getAsBuiltinType())
@@ -847,15 +840,15 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
/// same type qualifiers as FromPtr has on its pointee type. ToType,
/// if non-empty, will be a pointer to ToType that may or may not have
/// the right set of qualifiers on its pointee.
-static QualType
-BuildSimilarlyQualifiedPointerType(const PointerType *FromPtr,
+static QualType
+BuildSimilarlyQualifiedPointerType(const PointerType *FromPtr,
QualType ToPointee, QualType ToType,
ASTContext &Context) {
QualType CanonFromPointee = Context.getCanonicalType(FromPtr->getPointeeType());
QualType CanonToPointee = Context.getCanonicalType(ToPointee);
unsigned Quals = CanonFromPointee.getCVRQualifiers();
-
- // Exact qualifier match -> return the pointer type we're converting to.
+
+ // Exact qualifier match -> return the pointer type we're converting to.
if (CanonToPointee.getCVRQualifiers() == Quals) {
// ToType is exactly what we need. Return it.
if (ToType.getTypePtr())
@@ -870,7 +863,7 @@ BuildSimilarlyQualifiedPointerType(const PointerType *FromPtr,
return Context.getPointerType(CanonToPointee.getQualifiedType(Quals));
}
-static bool isNullPointerConstantForConversion(Expr *Expr,
+static bool isNullPointerConstantForConversion(Expr *Expr,
bool InOverloadResolution,
ASTContext &Context) {
// Handle value-dependent integral null pointer constants correctly.
@@ -881,7 +874,7 @@ static bool isNullPointerConstantForConversion(Expr *Expr,
return Expr->isNullPointerConstant(Context);
}
-
+
/// IsPointerConversion - Determines whether the conversion of the
/// expression From, which has the (possibly adjusted) type FromType,
/// can be converted to the type ToType via a pointer conversion (C++
@@ -901,14 +894,13 @@ static bool isNullPointerConstantForConversion(Expr *Expr,
bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
bool InOverloadResolution,
QualType& ConvertedType,
- bool &IncompatibleObjC)
-{
+ bool &IncompatibleObjC) {
IncompatibleObjC = false;
if (isObjCPointerConversion(FromType, ToType, ConvertedType, IncompatibleObjC))
return true;
- // Conversion from a null pointer constant to any Objective-C pointer type.
- if (ToType->isObjCObjectPointerType() &&
+ // Conversion from a null pointer constant to any Objective-C pointer type.
+ if (ToType->isObjCObjectPointerType() &&
isNullPointerConstantForConversion(From, InOverloadResolution, Context)) {
ConvertedType = ToType;
return true;
@@ -922,7 +914,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
}
// Blocks: A null pointer constant can be converted to a block
// pointer type.
- if (ToType->isBlockPointerType() &&
+ if (ToType->isBlockPointerType() &&
isNullPointerConstantForConversion(From, InOverloadResolution, Context)) {
ConvertedType = ToType;
return true;
@@ -930,7 +922,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
// If the left-hand-side is nullptr_t, the right side can be a null
// pointer constant.
- if (ToType->isNullPtrType() &&
+ if (ToType->isNullPtrType() &&
isNullPointerConstantForConversion(From, InOverloadResolution, Context)) {
ConvertedType = ToType;
return true;
@@ -958,7 +950,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
// can be converted to an rvalue of type "pointer to cv void" (C++
// 4.10p2).
if (FromPointeeType->isObjectType() && ToPointeeType->isVoidType()) {
- ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
return true;
@@ -966,16 +958,16 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
// When we're overloading in C, we allow a special kind of pointer
// conversion for compatible-but-not-identical pointee types.
- if (!getLangOptions().CPlusPlus &&
+ if (!getLangOptions().CPlusPlus &&
Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
- ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
- ToType, Context);
+ ToType, Context);
return true;
}
// C++ [conv.ptr]p3:
- //
+ //
// An rvalue of type "pointer to cv D," where D is a class type,
// can be converted to an rvalue of type "pointer to cv B," where
// B is a base class (clause 10) of D. If B is an inaccessible
@@ -990,7 +982,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
if (getLangOptions().CPlusPlus &&
FromPointeeType->isRecordType() && ToPointeeType->isRecordType() &&
IsDerivedFrom(FromPointeeType, ToPointeeType)) {
- ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
return true;
@@ -1002,7 +994,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
/// isObjCPointerConversion - Determines whether this is an
/// Objective-C pointer conversion. Subroutine of IsPointerConversion,
/// with the same arguments and return values.
-bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
+bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
QualType& ConvertedType,
bool &IncompatibleObjC) {
if (!getLangOptions().ObjC1)
@@ -1010,7 +1002,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
// First, we handle all conversions on ObjC object pointer types.
const ObjCObjectPointerType* ToObjCPtr = ToType->getAsObjCObjectPointerType();
- const ObjCObjectPointerType *FromObjCPtr =
+ const ObjCObjectPointerType *FromObjCPtr =
FromType->getAsObjCObjectPointerType();
if (ToObjCPtr && FromObjCPtr) {
@@ -1021,9 +1013,9 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
return true;
}
// Conversions with Objective-C's id<...>.
- if ((FromObjCPtr->isObjCQualifiedIdType() ||
+ if ((FromObjCPtr->isObjCQualifiedIdType() ||
ToObjCPtr->isObjCQualifiedIdType()) &&
- Context.ObjCQualifiedIdTypesAreCompatible(ToType, FromType,
+ Context.ObjCQualifiedIdTypesAreCompatible(ToType, FromType,
/*compare=*/false)) {
ConvertedType = ToType;
return true;
@@ -1043,7 +1035,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
ConvertedType = FromType;
return true;
}
- }
+ }
// Beyond this point, both types need to be C pointers or block pointers.
QualType ToPointeeType;
if (const PointerType *ToCPtr = ToType->getAs<PointerType>())
@@ -1075,7 +1067,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
// differences in the argument and result types are in Objective-C
// pointer conversions. If so, we permit the conversion (but
// complain about it).
- const FunctionProtoType *FromFunctionType
+ const FunctionProtoType *FromFunctionType
= FromPointeeType->getAsFunctionProtoType();
const FunctionProtoType *ToFunctionType
= ToPointeeType->getAsFunctionProtoType();
@@ -1106,7 +1098,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
// Function types are too different. Abort.
return false;
}
-
+
// Check argument types.
for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumArgs();
ArgIdx != NumArgs; ++ArgIdx) {
@@ -1160,9 +1152,9 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType) {
From->getSourceRange());
}
}
- if (const ObjCObjectPointerType *FromPtrType =
+ if (const ObjCObjectPointerType *FromPtrType =
FromType->getAsObjCObjectPointerType())
- if (const ObjCObjectPointerType *ToPtrType =
+ if (const ObjCObjectPointerType *ToPtrType =
ToType->getAsObjCObjectPointerType()) {
// Objective-C++ conversions are always okay.
// FIXME: We should have a different class of conversions for the
@@ -1180,8 +1172,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType) {
/// If so, returns true and places the converted type (that might differ from
/// ToType in its cv-qualifiers at some level) into ConvertedType.
bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType,
- QualType ToType, QualType &ConvertedType)
-{
+ QualType ToType, QualType &ConvertedType) {
const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>();
if (!ToTypePtr)
return false;
@@ -1218,13 +1209,13 @@ bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType,
/// for which IsMemberPointerConversion has already returned true. It returns
/// true and produces a diagnostic if there was an error, or returns false
/// otherwise.
-bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType,
+bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType,
CastExpr::CastKind &Kind) {
QualType FromType = From->getType();
const MemberPointerType *FromPtrType = FromType->getAs<MemberPointerType>();
if (!FromPtrType) {
// This must be a null pointer to member pointer conversion
- assert(From->isNullPointerConstant(Context) &&
+ assert(From->isNullPointerConstant(Context) &&
"Expr must be null pointer constant!");
Kind = CastExpr::CK_NullToMemberPointer;
return false;
@@ -1278,9 +1269,8 @@ bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType,
/// IsQualificationConversion - Determines whether the conversion from
/// an rvalue of type FromType to ToType is a qualification conversion
/// (C++ 4.4).
-bool
-Sema::IsQualificationConversion(QualType FromType, QualType ToType)
-{
+bool
+Sema::IsQualificationConversion(QualType FromType, QualType ToType) {
FromType = Context.getCanonicalType(FromType);
ToType = Context.getCanonicalType(ToType);
@@ -1307,16 +1297,16 @@ Sema::IsQualificationConversion(QualType FromType, QualType ToType)
// 2,j, and similarly for volatile.
if (!ToType.isAtLeastAsQualifiedAs(FromType))
return false;
-
+
// -- if the cv 1,j and cv 2,j are different, then const is in
// every cv for 0 < k < j.
if (FromType.getCVRQualifiers() != ToType.getCVRQualifiers()
&& !PreviousToQualsIncludeConst)
return false;
-
+
// Keep track of whether all prior cv-qualifiers in the "to" type
// include const.
- PreviousToQualsIncludeConst
+ PreviousToQualsIncludeConst
= PreviousToQualsIncludeConst && ToType.isConstQualified();
}
@@ -1359,14 +1349,13 @@ static void GetFunctionAndTemplate(AnyFunctionDecl Orig, T *&Function,
///
/// \param ForceRValue true if the expression should be treated as an rvalue
/// for overload resolution.
-bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
+bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
UserDefinedConversionSequence& User,
bool AllowConversionFunctions,
- bool AllowExplicit, bool ForceRValue)
-{
+ bool AllowExplicit, bool ForceRValue) {
OverloadCandidateSet CandidateSet;
if (const RecordType *ToRecordType = ToType->getAs<RecordType>()) {
- if (CXXRecordDecl *ToRecordDecl
+ if (CXXRecordDecl *ToRecordDecl
= dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
// C++ [over.match.ctor]p1:
// When objects of class type are direct-initialized (8.5), or
@@ -1376,11 +1365,11 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
// functions are all the converting constructors (12.3.1) of
// that class. The argument list is the expression-list within
// the parentheses of the initializer.
- DeclarationName ConstructorName
+ DeclarationName ConstructorName
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ToType).getUnqualifiedType());
DeclContext::lookup_iterator Con, ConEnd;
- for (llvm::tie(Con, ConEnd)
+ for (llvm::tie(Con, ConEnd)
= ToRecordDecl->lookup(ConstructorName);
Con != ConEnd; ++Con) {
// Find the constructor (which may be a template).
@@ -1388,17 +1377,17 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
FunctionTemplateDecl *ConstructorTmpl
= dyn_cast<FunctionTemplateDecl>(*Con);
if (ConstructorTmpl)
- Constructor
+ Constructor
= cast<CXXConstructorDecl>(ConstructorTmpl->getTemplatedDecl());
else
Constructor = cast<CXXConstructorDecl>(*Con);
-
+
if (!Constructor->isInvalidDecl() &&
Constructor->isConvertingConstructor(AllowExplicit)) {
if (ConstructorTmpl)
- AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
+ AddTemplateOverloadCandidate(ConstructorTmpl, false, 0, 0, &From,
1, CandidateSet,
- /*SuppressUserConversions=*/true,
+ /*SuppressUserConversions=*/true,
ForceRValue);
else
AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
@@ -1410,19 +1399,19 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
if (!AllowConversionFunctions) {
// Don't allow any conversion functions to enter the overload set.
- } else if (RequireCompleteType(From->getLocStart(), From->getType(),
- PDiag(0)
+ } else if (RequireCompleteType(From->getLocStart(), From->getType(),
+ PDiag(0)
<< From->getSourceRange())) {
// No conversion functions from incomplete types.
- } else if (const RecordType *FromRecordType
+ } else if (const RecordType *FromRecordType
= From->getType()->getAs<RecordType>()) {
- if (CXXRecordDecl *FromRecordDecl
+ if (CXXRecordDecl *FromRecordDecl
= dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
// Add all of the conversion functions as candidates.
// FIXME: Look for conversions in base classes!
- OverloadedFunctionDecl *Conversions
+ OverloadedFunctionDecl *Conversions
= FromRecordDecl->getConversionFunctions();
- for (OverloadedFunctionDecl::function_iterator Func
+ for (OverloadedFunctionDecl::function_iterator Func
= Conversions->function_begin();
Func != Conversions->function_end(); ++Func) {
CXXConversionDecl *Conv;
@@ -1430,12 +1419,12 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
GetFunctionAndTemplate(*Func, Conv, ConvTemplate);
if (ConvTemplate)
Conv = dyn_cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl());
- else
+ else
Conv = dyn_cast<CXXConversionDecl>(*Func);
if (AllowExplicit || !Conv->isExplicit()) {
if (ConvTemplate)
- AddTemplateConversionCandidate(ConvTemplate, From, ToType,
+ AddTemplateConversionCandidate(ConvTemplate, From, ToType,
CandidateSet);
else
AddConversionCandidate(Conv, From, ToType, CandidateSet);
@@ -1448,7 +1437,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
switch (BestViableFunction(CandidateSet, From->getLocStart(), Best)) {
case OR_Success:
// Record the standard conversion we used and the conversion function.
- if (CXXConstructorDecl *Constructor
+ if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(Best->Function)) {
// C++ [over.ics.user]p1:
// If the user-defined conversion is specified by a
@@ -1461,7 +1450,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
User.Before = Best->Conversions[0].Standard;
User.ConversionFunction = Constructor;
User.After.setAsIdentityConversion();
- User.After.FromTypePtr
+ User.After.FromTypePtr
= ThisType->getAs<PointerType>()->getPointeeType().getAsOpaquePtr();
User.After.ToTypePtr = ToType.getAsOpaquePtr();
return true;
@@ -1475,8 +1464,8 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
// implicit object parameter of the conversion function.
User.Before = Best->Conversions[0].Standard;
User.ConversionFunction = Conversion;
-
- // C++ [over.ics.user]p2:
+
+ // C++ [over.ics.user]p2:
// The second standard conversion sequence converts the
// result of the user-defined conversion to the target type
// for the sequence. Since an implicit conversion sequence
@@ -1491,7 +1480,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
assert(false && "Not a constructor or conversion function?");
return false;
}
-
+
case OR_No_Viable_Function:
case OR_Deleted:
// No conversion here! We're done.
@@ -1509,7 +1498,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
/// CompareImplicitConversionSequences - Compare two implicit
/// conversion sequences to determine whether one is better than the
/// other or if they are indistinguishable (C++ 13.3.3.2).
-ImplicitConversionSequence::CompareKind
+ImplicitConversionSequence::CompareKind
Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
const ImplicitConversionSequence& ICS2)
{
@@ -1521,7 +1510,7 @@ Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
// -- a user-defined conversion sequence (13.3.3.1.2) is a better
// conversion sequence than an ellipsis conversion sequence
// (13.3.3.1.3).
- //
+ //
if (ICS1.ConversionKind < ICS2.ConversionKind)
return ImplicitConversionSequence::Better;
else if (ICS2.ConversionKind < ICS1.ConversionKind)
@@ -1532,7 +1521,7 @@ Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
// following rules apply: (C++ 13.3.3.2p3):
if (ICS1.ConversionKind == ImplicitConversionSequence::StandardConversion)
return CompareStandardConversionSequences(ICS1.Standard, ICS2.Standard);
- else if (ICS1.ConversionKind ==
+ else if (ICS1.ConversionKind ==
ImplicitConversionSequence::UserDefinedConversion) {
// User-defined conversion sequence U1 is a better conversion
// sequence than another user-defined conversion sequence U2 if
@@ -1540,7 +1529,7 @@ Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
// constructor and if the second standard conversion sequence of
// U1 is better than the second standard conversion sequence of
// U2 (C++ 13.3.3.2p3).
- if (ICS1.UserDefined.ConversionFunction ==
+ if (ICS1.UserDefined.ConversionFunction ==
ICS2.UserDefined.ConversionFunction)
return CompareStandardConversionSequences(ICS1.UserDefined.After,
ICS2.UserDefined.After);
@@ -1552,7 +1541,7 @@ Sema::CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
/// CompareStandardConversionSequences - Compare two standard
/// conversion sequences to determine whether one is better than the
/// other or if they are indistinguishable (C++ 13.3.3.2p3).
-ImplicitConversionSequence::CompareKind
+ImplicitConversionSequence::CompareKind
Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
const StandardConversionSequence& SCS2)
{
@@ -1569,13 +1558,13 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
;
else if ((SCS1.Second == ICK_Identity && SCS1.Third == SCS2.Third) ||
(SCS1.Third == ICK_Identity && SCS1.Second == SCS2.Second) ||
- (SCS1.Second == ICK_Identity &&
+ (SCS1.Second == ICK_Identity &&
SCS1.Third == ICK_Identity))
// SCS1 is a proper subsequence of SCS2.
return ImplicitConversionSequence::Better;
else if ((SCS2.Second == ICK_Identity && SCS2.Third == SCS1.Third) ||
(SCS2.Third == ICK_Identity && SCS2.Second == SCS1.Second) ||
- (SCS2.Second == ICK_Identity &&
+ (SCS2.Second == ICK_Identity &&
SCS2.Third == ICK_Identity))
// SCS2 is a proper subsequence of SCS1.
return ImplicitConversionSequence::Worse;
@@ -1592,7 +1581,7 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
// (C++ 13.3.3.2p4): Two conversion sequences with the same rank
// are indistinguishable unless one of the following rules
// applies:
-
+
// A conversion that is not a conversion of a pointer, or
// pointer to member, to bool is better than another conversion
// that is such a conversion.
@@ -1607,9 +1596,9 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
// conversion of B* to A* is better than conversion of B* to
// void*, and conversion of A* to void* is better than conversion
// of B* to void*.
- bool SCS1ConvertsToVoid
+ bool SCS1ConvertsToVoid
= SCS1.isPointerConversionToVoidPointer(Context);
- bool SCS2ConvertsToVoid
+ bool SCS2ConvertsToVoid
= SCS2.isPointerConversionToVoidPointer(Context);
if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
// Exactly one of the conversion sequences is a conversion to
@@ -1636,7 +1625,7 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
if (SCS2.First == ICK_Array_To_Pointer)
FromType2 = Context.getArrayDecayedType(FromType2);
- QualType FromPointee1
+ QualType FromPointee1
= FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
QualType FromPointee2
= FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
@@ -1660,7 +1649,7 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
// Compare based on qualification conversions (C++ 13.3.3.2p3,
// bullet 3).
- if (ImplicitConversionSequence::CompareKind QualCK
+ if (ImplicitConversionSequence::CompareKind QualCK
= CompareQualificationConversions(SCS1, SCS2))
return QualCK;
@@ -1700,11 +1689,10 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
/// CompareQualificationConversions - Compares two standard conversion
/// sequences to determine whether they can be ranked based on their
-/// qualification conversions (C++ 13.3.3.2p3 bullet 3).
-ImplicitConversionSequence::CompareKind
+/// qualification conversions (C++ 13.3.3.2p3 bullet 3).
+ImplicitConversionSequence::CompareKind
Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
- const StandardConversionSequence& SCS2)
-{
+ const StandardConversionSequence& SCS2) {
// C++ 13.3.3.2p3:
// -- S1 and S2 differ only in their qualification conversion and
// yield similar types T1 and T2 (C++ 4.4), respectively, and the
@@ -1727,7 +1715,7 @@ Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
if (T1.getUnqualifiedType() == T2.getUnqualifiedType())
return ImplicitConversionSequence::Indistinguishable;
- ImplicitConversionSequence::CompareKind Result
+ ImplicitConversionSequence::CompareKind Result
= ImplicitConversionSequence::Indistinguishable;
while (UnwrapSimilarPointerTypes(T1, T2)) {
// Within each iteration of the loop, we check the qualifiers to
@@ -1748,7 +1736,7 @@ Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
// Neither has qualifiers that are a subset of the other's
// qualifiers.
return ImplicitConversionSequence::Indistinguishable;
-
+
Result = ImplicitConversionSequence::Better;
} else if (T1.isMoreQualifiedThan(T2)) {
// T2 has fewer qualifiers, so it could be the better sequence.
@@ -1756,7 +1744,7 @@ Sema::CompareQualificationConversions(const StandardConversionSequence& SCS1,
// Neither has qualifiers that are a subset of the other's
// qualifiers.
return ImplicitConversionSequence::Indistinguishable;
-
+
Result = ImplicitConversionSequence::Worse;
} else {
// Qualifiers are disjoint.
@@ -1823,14 +1811,14 @@ Sema::CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
// interfaces.
// Compare based on pointer conversions.
- if (SCS1.Second == ICK_Pointer_Conversion &&
+ if (SCS1.Second == ICK_Pointer_Conversion &&
SCS2.Second == ICK_Pointer_Conversion &&
/*FIXME: Remove if Objective-C id conversions get their own rank*/
FromType1->isPointerType() && FromType2->isPointerType() &&
ToType1->isPointerType() && ToType2->isPointerType()) {
- QualType FromPointee1
+ QualType FromPointee1
= FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
- QualType ToPointee1
+ QualType ToPointee1
= ToType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
QualType FromPointee2
= FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
@@ -1863,7 +1851,7 @@ Sema::CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
return ImplicitConversionSequence::Better;
else if (IsDerivedFrom(FromPointee1, FromPointee2))
return ImplicitConversionSequence::Worse;
-
+
if (FromIface1 && FromIface2) {
if (Context.canAssignObjCInterfaces(FromIface1, FromIface2))
return ImplicitConversionSequence::Better;
@@ -1937,20 +1925,20 @@ Sema::CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
/// a parameter of this type). If @p SuppressUserConversions, then we
/// do not permit any user-defined conversion sequences. If @p ForceRValue,
/// then we treat @p From as an rvalue, even if it is an lvalue.
-ImplicitConversionSequence
-Sema::TryCopyInitialization(Expr *From, QualType ToType,
+ImplicitConversionSequence
+Sema::TryCopyInitialization(Expr *From, QualType ToType,
bool SuppressUserConversions, bool ForceRValue,
bool InOverloadResolution) {
if (ToType->isReferenceType()) {
ImplicitConversionSequence ICS;
- CheckReferenceInit(From, ToType,
+ CheckReferenceInit(From, ToType,
SuppressUserConversions,
/*AllowExplicit=*/false,
ForceRValue,
&ICS);
return ICS;
} else {
- return TryImplicitConversion(From, ToType,
+ return TryImplicitConversion(From, ToType,
SuppressUserConversions,
/*AllowExplicit=*/false,
ForceRValue,
@@ -1963,18 +1951,18 @@ Sema::TryCopyInitialization(Expr *From, QualType ToType,
/// an error, returns false if the initialization succeeded. Elidable should
/// be true when the copy may be elided (C++ 12.8p15). Overload resolution works
/// differently in C++0x for this case.
-bool Sema::PerformCopyInitialization(Expr *&From, QualType ToType,
+bool Sema::PerformCopyInitialization(Expr *&From, QualType ToType,
const char* Flavor, bool Elidable) {
if (!getLangOptions().CPlusPlus) {
// In C, argument passing is the same as performing an assignment.
QualType FromType = From->getType();
-
+
AssignConvertType ConvTy =
CheckSingleAssignmentConstraints(ToType, From);
if (ConvTy != Compatible &&
CheckTransparentUnionArgumentConstraints(ToType, From) == Compatible)
ConvTy = Compatible;
-
+
return DiagnoseAssignmentResult(ConvTy, From->getLocStart(), ToType,
FromType, From, Flavor);
}
@@ -2020,7 +2008,7 @@ Sema::TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method) {
// where X is the class of which the function is a member
// (C++ [over.match.funcs]p4). However, when finding an implicit
// conversion sequence for the argument, we are not allowed to
- // create temporaries or perform user-defined conversions
+ // create temporaries or perform user-defined conversions
// (C++ [over.match.funcs]p5). We perform a simplified version of
// reference binding here, that allows class rvalues to bind to
// non-constant references.
@@ -2058,9 +2046,9 @@ Sema::TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method) {
bool
Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
QualType FromRecordType, DestType;
- QualType ImplicitParamRecordType =
+ QualType ImplicitParamRecordType =
Method->getThisType(Context)->getAs<PointerType>()->getPointeeType();
-
+
if (const PointerType *PT = From->getType()->getAs<PointerType>()) {
FromRecordType = PT->getPointeeType();
DestType = Method->getThisType(Context);
@@ -2069,13 +2057,13 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
DestType = ImplicitParamRecordType;
}
- ImplicitConversionSequence ICS
+ ImplicitConversionSequence ICS
= TryObjectArgumentInitialization(From, Method);
if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion)
return Diag(From->getSourceRange().getBegin(),
diag::err_implicit_object_parameter_init)
<< ImplicitParamRecordType << FromRecordType << From->getSourceRange();
-
+
if (ICS.Standard.Second == ICK_Derived_To_Base &&
CheckDerivedToBaseConversion(FromRecordType,
ImplicitParamRecordType,
@@ -2083,7 +2071,7 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
From->getSourceRange()))
return true;
- ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase,
+ ImpCastExprToType(From, DestType, CastExpr::CK_DerivedToBase,
/*isLvalue=*/true);
return false;
}
@@ -2091,10 +2079,10 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method) {
/// TryContextuallyConvertToBool - Attempt to contextually convert the
/// expression From to bool (C++0x [conv]p3).
ImplicitConversionSequence Sema::TryContextuallyConvertToBool(Expr *From) {
- return TryImplicitConversion(From, Context.BoolTy,
+ return TryImplicitConversion(From, Context.BoolTy,
// FIXME: Are these flags correct?
/*SuppressUserConversions=*/false,
- /*AllowExplicit=*/true,
+ /*AllowExplicit=*/true,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
}
@@ -2106,7 +2094,7 @@ bool Sema::PerformContextuallyConvertToBool(Expr *&From) {
if (!PerformImplicitConversion(From, Context.BoolTy, ICS, "converting"))
return false;
- return Diag(From->getSourceRange().getBegin(),
+ return Diag(From->getSourceRange().getBegin(),
diag::err_typecheck_bool_condition)
<< From->getType() << From->getSourceRange();
}
@@ -2118,21 +2106,20 @@ bool Sema::PerformContextuallyConvertToBool(Expr *&From) {
/// If @p ForceRValue, treat all arguments as rvalues. This is a slightly
/// hacky way to implement the overloading rules for elidable copy
/// initialization in C++0x (C++0x 12.8p15).
-void
-Sema::AddOverloadCandidate(FunctionDecl *Function,
+void
+Sema::AddOverloadCandidate(FunctionDecl *Function,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions,
- bool ForceRValue)
-{
- const FunctionProtoType* Proto
+ bool ForceRValue) {
+ const FunctionProtoType* Proto
= dyn_cast<FunctionProtoType>(Function->getType()->getAsFunctionType());
assert(Proto && "Functions without a prototype cannot be overloaded");
- assert(!isa<CXXConversionDecl>(Function) &&
+ assert(!isa<CXXConversionDecl>(Function) &&
"Use AddConversionCandidate for conversion functions");
- assert(!Function->getDescribedFunctionTemplate() &&
+ assert(!Function->getDescribedFunctionTemplate() &&
"Use AddTemplateOverloadCandidate for function templates");
-
+
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
if (!isa<CXXConstructorDecl>(Method)) {
// If we get here, it's because we're calling a member function
@@ -2141,7 +2128,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
// implicitly. This can happen with a qualified call to a member
// function, e.g., X::f(). We use a NULL object as the implied
// object argument (C++ [over.call.func]p3).
- AddMethodCandidate(Method, 0, Args, NumArgs, CandidateSet,
+ AddMethodCandidate(Method, 0, Args, NumArgs, CandidateSet,
SuppressUserConversions, ForceRValue);
return;
}
@@ -2190,11 +2177,11 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
// (13.3.3.1) that converts that argument to the corresponding
// parameter of F.
QualType ParamType = Proto->getArgType(ArgIdx);
- Candidate.Conversions[ArgIdx]
- = TryCopyInitialization(Args[ArgIdx], ParamType,
+ Candidate.Conversions[ArgIdx]
+ = TryCopyInitialization(Args[ArgIdx], ParamType,
SuppressUserConversions, ForceRValue,
/*InOverloadResolution=*/true);
- if (Candidate.Conversions[ArgIdx].ConversionKind
+ if (Candidate.Conversions[ArgIdx].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
break;
@@ -2203,7 +2190,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function,
// (C++ 13.3.2p2): For the purposes of overload resolution, any
// argument for which there is no corresponding parameter is
// considered to ""match the ellipsis" (C+ 13.3.3.1.3).
- Candidate.Conversions[ArgIdx].ConversionKind
+ Candidate.Conversions[ArgIdx].ConversionKind
= ImplicitConversionSequence::EllipsisConversion;
}
}
@@ -2215,16 +2202,16 @@ void Sema::AddFunctionCandidates(const FunctionSet &Functions,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions) {
- for (FunctionSet::const_iterator F = Functions.begin(),
+ for (FunctionSet::const_iterator F = Functions.begin(),
FEnd = Functions.end();
F != FEnd; ++F) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*F))
- AddOverloadCandidate(FD, Args, NumArgs, CandidateSet,
+ AddOverloadCandidate(FD, Args, NumArgs, CandidateSet,
SuppressUserConversions);
else
AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*F),
/*FIXME: explicit args */false, 0, 0,
- Args, NumArgs, CandidateSet,
+ Args, NumArgs, CandidateSet,
SuppressUserConversions);
}
}
@@ -2238,13 +2225,12 @@ void Sema::AddFunctionCandidates(const FunctionSet &Functions,
/// operators. If @p ForceRValue, treat all arguments as rvalues. This is
/// a slightly hacky way to implement the overloading rules for elidable copy
/// initialization in C++0x (C++0x 12.8p15).
-void
+void
Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
- bool SuppressUserConversions, bool ForceRValue)
-{
- const FunctionProtoType* Proto
+ bool SuppressUserConversions, bool ForceRValue) {
+ const FunctionProtoType* Proto
= dyn_cast<FunctionProtoType>(Method->getType()->getAsFunctionType());
assert(Proto && "Methods without a prototype cannot be overloaded");
assert(!isa<CXXConversionDecl>(Method) &&
@@ -2291,7 +2277,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
// Determine the implicit conversion sequence for the object
// parameter.
Candidate.Conversions[0] = TryObjectArgumentInitialization(Object, Method);
- if (Candidate.Conversions[0].ConversionKind
+ if (Candidate.Conversions[0].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
return;
@@ -2307,11 +2293,11 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
// (13.3.3.1) that converts that argument to the corresponding
// parameter of F.
QualType ParamType = Proto->getArgType(ArgIdx);
- Candidate.Conversions[ArgIdx + 1]
- = TryCopyInitialization(Args[ArgIdx], ParamType,
+ Candidate.Conversions[ArgIdx + 1]
+ = TryCopyInitialization(Args[ArgIdx], ParamType,
SuppressUserConversions, ForceRValue,
/*InOverloadResolution=*/true);
- if (Candidate.Conversions[ArgIdx + 1].ConversionKind
+ if (Candidate.Conversions[ArgIdx + 1].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
break;
@@ -2320,7 +2306,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
// (C++ 13.3.2p2): For the purposes of overload resolution, any
// argument for which there is no corresponding parameter is
// considered to ""match the ellipsis" (C+ 13.3.3.1.3).
- Candidate.Conversions[ArgIdx + 1].ConversionKind
+ Candidate.Conversions[ArgIdx + 1].ConversionKind
= ImplicitConversionSequence::EllipsisConversion;
}
}
@@ -2329,7 +2315,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, Expr *Object,
/// \brief Add a C++ member function template as a candidate to the candidate
/// set, using template argument deduction to produce an appropriate member
/// function template specialization.
-void
+void
Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
bool HasExplicitTemplateArgs,
const TemplateArgument *ExplicitTemplateArgs,
@@ -2339,9 +2325,9 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
bool SuppressUserConversions,
bool ForceRValue) {
// C++ [over.match.funcs]p7:
- // In each case where a candidate is a function template, candidate
+ // In each case where a candidate is a function template, candidate
// function template specializations are generated using template argument
- // deduction (14.8.3, 14.8.2). Those candidates are then handled as
+ // deduction (14.8.3, 14.8.2). Those candidates are then handled as
// candidate functions in the usual way.113) A given name can refer to one
// or more function templates and also to a set of overloaded non-template
// functions. In such a case, the candidate functions generated from each
@@ -2358,20 +2344,20 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
(void)Result;
return;
}
-
+
// Add the function template specialization produced by template argument
// deduction as a candidate.
assert(Specialization && "Missing member function template specialization?");
- assert(isa<CXXMethodDecl>(Specialization) &&
+ assert(isa<CXXMethodDecl>(Specialization) &&
"Specialization is not a member function?");
- AddMethodCandidate(cast<CXXMethodDecl>(Specialization), Object, Args, NumArgs,
+ AddMethodCandidate(cast<CXXMethodDecl>(Specialization), Object, Args, NumArgs,
CandidateSet, SuppressUserConversions, ForceRValue);
}
/// \brief Add a C++ function template specialization as a candidate
/// in the candidate set, using template argument deduction to produce
/// an appropriate function template specialization.
-void
+void
Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
bool HasExplicitTemplateArgs,
const TemplateArgument *ExplicitTemplateArgs,
@@ -2381,9 +2367,9 @@ Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
bool SuppressUserConversions,
bool ForceRValue) {
// C++ [over.match.funcs]p7:
- // In each case where a candidate is a function template, candidate
+ // In each case where a candidate is a function template, candidate
// function template specializations are generated using template argument
- // deduction (14.8.3, 14.8.2). Those candidates are then handled as
+ // deduction (14.8.3, 14.8.2). Those candidates are then handled as
// candidate functions in the usual way.113) A given name can refer to one
// or more function templates and also to a set of overloaded non-template
// functions. In such a case, the candidate functions generated from each
@@ -2400,18 +2386,18 @@ Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
(void)Result;
return;
}
-
+
// Add the function template specialization produced by template argument
// deduction as a candidate.
assert(Specialization && "Missing function template specialization?");
AddOverloadCandidate(Specialization, Args, NumArgs, CandidateSet,
SuppressUserConversions, ForceRValue);
}
-
+
/// AddConversionCandidate - Add a C++ conversion function as a
-/// candidate in the candidate set (C++ [over.match.conv],
+/// candidate in the candidate set (C++ [over.match.conv],
/// C++ [over.match.copy]). From is the expression we're converting from,
-/// and ToType is the type that we're eventually trying to convert to
+/// and ToType is the type that we're eventually trying to convert to
/// (which may or may not be the same type as the type that the
/// conversion function produces).
void
@@ -2428,7 +2414,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
Candidate.IsSurrogate = false;
Candidate.IgnoreObjectArgument = false;
Candidate.FinalConversion.setAsIdentityConversion();
- Candidate.FinalConversion.FromTypePtr
+ Candidate.FinalConversion.FromTypePtr
= Conversion->getConversionType().getAsOpaquePtr();
Candidate.FinalConversion.ToTypePtr = ToType.getAsOpaquePtr();
@@ -2438,7 +2424,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
Candidate.Conversions.resize(1);
Candidate.Conversions[0] = TryObjectArgumentInitialization(From, Conversion);
- if (Candidate.Conversions[0].ConversionKind
+ if (Candidate.Conversions[0].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
return;
@@ -2452,24 +2438,24 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
// lvalues/rvalues and the type. Fortunately, we can allocate this
// call on the stack and we don't need its arguments to be
// well-formed.
- DeclRefExpr ConversionRef(Conversion, Conversion->getType(),
+ DeclRefExpr ConversionRef(Conversion, Conversion->getType(),
SourceLocation());
ImplicitCastExpr ConversionFn(Context.getPointerType(Conversion->getType()),
CastExpr::CK_Unknown,
&ConversionRef, false);
-
- // Note that it is safe to allocate CallExpr on the stack here because
+
+ // Note that it is safe to allocate CallExpr on the stack here because
// there are 0 arguments (i.e., nothing is allocated using ASTContext's
// allocator).
- CallExpr Call(Context, &ConversionFn, 0, 0,
+ CallExpr Call(Context, &ConversionFn, 0, 0,
Conversion->getConversionType().getNonReferenceType(),
SourceLocation());
- ImplicitConversionSequence ICS =
- TryCopyInitialization(&Call, ToType,
+ ImplicitConversionSequence ICS =
+ TryCopyInitialization(&Call, ToType,
/*SuppressUserConversions=*/true,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
-
+
switch (ICS.ConversionKind) {
case ImplicitConversionSequence::StandardConversion:
Candidate.FinalConversion = ICS.Standard;
@@ -2480,7 +2466,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
break;
default:
- assert(false &&
+ assert(false &&
"Can only end up with a standard conversion sequence or failure");
}
}
@@ -2490,7 +2476,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
/// to deduce the template arguments of the conversion function
/// template from the type that we are converting to (C++
/// [temp.deduct.conv]).
-void
+void
Sema::AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
Expr *From, QualType ToType,
OverloadCandidateSet &CandidateSet) {
@@ -2500,14 +2486,14 @@ Sema::AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
TemplateDeductionInfo Info(Context);
CXXConversionDecl *Specialization = 0;
if (TemplateDeductionResult Result
- = DeduceTemplateArguments(FunctionTemplate, ToType,
+ = DeduceTemplateArguments(FunctionTemplate, ToType,
Specialization, Info)) {
// FIXME: Record what happened with template argument deduction, so
// that we can give the user a beautiful diagnostic.
(void)Result;
return;
}
-
+
// Add the conversion function template specialization produced by
// template argument deduction as a candidate.
assert(Specialization && "Missing function template specialization?");
@@ -2534,7 +2520,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
// Determine the implicit conversion sequence for the implicit
// object parameter.
- ImplicitConversionSequence ObjectInit
+ ImplicitConversionSequence ObjectInit
= TryObjectArgumentInitialization(Object, Conversion);
if (ObjectInit.ConversionKind == ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
@@ -2544,15 +2530,15 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
// The first conversion is actually a user-defined conversion whose
// first conversion is ObjectInit's standard conversion (which is
// effectively a reference binding). Record it as such.
- Candidate.Conversions[0].ConversionKind
+ Candidate.Conversions[0].ConversionKind
= ImplicitConversionSequence::UserDefinedConversion;
Candidate.Conversions[0].UserDefined.Before = ObjectInit.Standard;
Candidate.Conversions[0].UserDefined.ConversionFunction = Conversion;
- Candidate.Conversions[0].UserDefined.After
+ Candidate.Conversions[0].UserDefined.After
= Candidate.Conversions[0].UserDefined.Before;
Candidate.Conversions[0].UserDefined.After.setAsIdentityConversion();
- // Find the
+ // Find the
unsigned NumArgsInProto = Proto->getNumArgs();
// (C++ 13.3.2p2): A candidate function having fewer than m
@@ -2580,12 +2566,12 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
// (13.3.3.1) that converts that argument to the corresponding
// parameter of F.
QualType ParamType = Proto->getArgType(ArgIdx);
- Candidate.Conversions[ArgIdx + 1]
- = TryCopyInitialization(Args[ArgIdx], ParamType,
+ Candidate.Conversions[ArgIdx + 1]
+ = TryCopyInitialization(Args[ArgIdx], ParamType,
/*SuppressUserConversions=*/false,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
- if (Candidate.Conversions[ArgIdx + 1].ConversionKind
+ if (Candidate.Conversions[ArgIdx + 1].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
break;
@@ -2594,7 +2580,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
// (C++ 13.3.2p2): For the purposes of overload resolution, any
// argument for which there is no corresponding parameter is
// considered to ""match the ellipsis" (C+ 13.3.3.1.3).
- Candidate.Conversions[ArgIdx + 1].ConversionKind
+ Candidate.Conversions[ArgIdx + 1].ConversionKind
= ImplicitConversionSequence::EllipsisConversion;
}
}
@@ -2661,14 +2647,14 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
// Complete the type if it can be completed. Otherwise, we're done.
if (RequireCompleteType(OpLoc, T1, PartialDiagnostic(0)))
return;
-
- LookupResult Operators = LookupQualifiedName(T1Rec->getDecl(), OpName,
+
+ LookupResult Operators = LookupQualifiedName(T1Rec->getDecl(), OpName,
LookupOrdinaryName, false);
- for (LookupResult::iterator Oper = Operators.begin(),
+ for (LookupResult::iterator Oper = Operators.begin(),
OperEnd = Operators.end();
Oper != OperEnd;
++Oper)
- AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Args[0],
+ AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Args[0],
Args+1, NumArgs - 1, CandidateSet,
/*SuppressUserConversions=*/false);
}
@@ -2682,7 +2668,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
/// operator. NumContextualBoolArguments is the number of arguments
/// (at the beginning of the argument list) that will be contextually
/// converted to bool.
-void Sema::AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
+void Sema::AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet,
bool IsAssignmentOperator,
@@ -2708,24 +2694,24 @@ void Sema::AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
// -- no temporaries are introduced to hold the left operand, and
// -- no user-defined conversions are applied to the left
// operand to achieve a type match with the left-most
- // parameter of a built-in candidate.
+ // parameter of a built-in candidate.
//
// We block these conversions by turning off user-defined
// conversions, since that is the only way that initialization of
// a reference to a non-class type can occur from something that
// is not of the same type.
if (ArgIdx < NumContextualBoolArguments) {
- assert(ParamTys[ArgIdx] == Context.BoolTy &&
+ assert(ParamTys[ArgIdx] == Context.BoolTy &&
"Contextual conversion to bool requires bool type");
Candidate.Conversions[ArgIdx] = TryContextuallyConvertToBool(Args[ArgIdx]);
} else {
- Candidate.Conversions[ArgIdx]
- = TryCopyInitialization(Args[ArgIdx], ParamTys[ArgIdx],
+ Candidate.Conversions[ArgIdx]
+ = TryCopyInitialization(Args[ArgIdx], ParamTys[ArgIdx],
ArgIdx == 0 && IsAssignmentOperator,
/*ForceRValue=*/false,
/*InOverloadResolution=*/false);
}
- if (Candidate.Conversions[ArgIdx].ConversionKind
+ if (Candidate.Conversions[ArgIdx].ConversionKind
== ImplicitConversionSequence::BadConversion) {
Candidate.Viable = false;
break;
@@ -2756,7 +2742,7 @@ class BuiltinCandidateTypeSet {
/// Sema - The semantic analysis instance where we are building the
/// candidate type set.
Sema &SemaRef;
-
+
/// Context - The AST context in which we will build the type sets.
ASTContext &Context;
@@ -2767,7 +2753,7 @@ public:
/// iterator - Iterates through the types that are part of the set.
typedef TypeSet::iterator iterator;
- BuiltinCandidateTypeSet(Sema &SemaRef)
+ BuiltinCandidateTypeSet(Sema &SemaRef)
: SemaRef(SemaRef), Context(SemaRef.Context) { }
void AddTypesConvertedFrom(QualType Ty, bool AllowUserConversions,
@@ -2866,7 +2852,7 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
/// functions of a class type, and AllowExplicitConversions if we
/// should also include the explicit conversion functions of a class
/// type.
-void
+void
BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
bool AllowUserConversions,
bool AllowExplicitConversions) {
@@ -2891,7 +2877,7 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
// Add 'cv void*' to our set of types.
if (!Ty->isVoidType()) {
- QualType QualVoid
+ QualType QualVoid
= Context.VoidTy.getQualifiedType(PointeeTy.getCVRQualifiers());
AddPointerWithMoreQualifiedTypeVariants(Context.getPointerType(QualVoid));
}
@@ -2923,19 +2909,19 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
// No conversion functions in incomplete types.
return;
}
-
+
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(TyRec->getDecl());
// FIXME: Visit conversion functions in the base classes, too.
- OverloadedFunctionDecl *Conversions
+ OverloadedFunctionDecl *Conversions
= ClassDecl->getConversionFunctions();
- for (OverloadedFunctionDecl::function_iterator Func
+ for (OverloadedFunctionDecl::function_iterator Func
= Conversions->function_begin();
Func != Conversions->function_end(); ++Func) {
CXXConversionDecl *Conv;
FunctionTemplateDecl *ConvTemplate;
GetFunctionAndTemplate(*Func, Conv, ConvTemplate);
- // Skip conversion function templates; they don't tell us anything
+ // Skip conversion function templates; they don't tell us anything
// about which builtin types we can convert to.
if (ConvTemplate)
continue;
@@ -2952,33 +2938,33 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
/// given type to the candidate set.
static void AddBuiltinAssignmentOperatorCandidates(Sema &S,
QualType T,
- Expr **Args,
+ Expr **Args,
unsigned NumArgs,
OverloadCandidateSet &CandidateSet) {
QualType ParamTypes[2];
-
+
// T& operator=(T&, T)
ParamTypes[0] = S.Context.getLValueReferenceType(T);
ParamTypes[1] = T;
S.AddBuiltinCandidate(ParamTypes[0], ParamTypes, Args, 2, CandidateSet,
/*IsAssignmentOperator=*/true);
-
+
if (!S.Context.getCanonicalType(T).isVolatileQualified()) {
// volatile T& operator=(volatile T&, T)
ParamTypes[0] = S.Context.getLValueReferenceType(T.withVolatile());
ParamTypes[1] = T;
S.AddBuiltinCandidate(ParamTypes[0], ParamTypes, Args, 2, CandidateSet,
- /*IsAssignmentOperator=*/true);
+ /*IsAssignmentOperator=*/true);
}
}
-
+
/// AddBuiltinOperatorCandidates - Add the appropriate built-in
/// operator overloads to the candidate set (C++ [over.built]), based
/// on the operator @p Op and the arguments given. For example, if the
/// operator is a binary '+', this routine might add "int
/// operator+(int, int)" to cover integer addition.
void
-Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
+Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet) {
// The set of "promoted arithmetic types", which are the arithmetic
@@ -2988,14 +2974,14 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// FIXME: What about complex?
const unsigned FirstIntegralType = 0;
const unsigned LastIntegralType = 13;
- const unsigned FirstPromotedIntegralType = 7,
+ const unsigned FirstPromotedIntegralType = 7,
LastPromotedIntegralType = 13;
const unsigned FirstPromotedArithmeticType = 7,
LastPromotedArithmeticType = 16;
const unsigned NumArithmeticTypes = 16;
QualType ArithmeticTypes[NumArithmeticTypes] = {
- Context.BoolTy, Context.CharTy, Context.WCharTy,
-// FIXME: Context.Char16Ty, Context.Char32Ty,
+ Context.BoolTy, Context.CharTy, Context.WCharTy,
+// FIXME: Context.Char16Ty, Context.Char32Ty,
Context.SignedCharTy, Context.ShortTy,
Context.UnsignedCharTy, Context.UnsignedShortTy,
Context.IntTy, Context.LongTy, Context.LongLongTy,
@@ -3029,7 +3015,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
break;
case OO_Star: // '*' is either unary or binary
- if (NumArgs == 1)
+ if (NumArgs == 1)
goto UnaryStar;
else
goto BinaryStar;
@@ -3074,10 +3060,10 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// VQ T& operator--(VQ T&);
// T operator--(VQ T&, int);
- for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
+ for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
Arith < NumArithmeticTypes; ++Arith) {
QualType ArithTy = ArithmeticTypes[Arith];
- QualType ParamTypes[2]
+ QualType ParamTypes[2]
= { Context.getLValueReferenceType(ArithTy), Context.IntTy };
// Non-volatile version.
@@ -3110,10 +3096,10 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
if (!(*Ptr)->getAs<PointerType>()->getPointeeType()->isObjectType())
continue;
- QualType ParamTypes[2] = {
- Context.getLValueReferenceType(*Ptr), Context.IntTy
+ QualType ParamTypes[2] = {
+ Context.getLValueReferenceType(*Ptr), Context.IntTy
};
-
+
// Without volatile
if (NumArgs == 1)
AddBuiltinCandidate(ParamTypes[0], ParamTypes, Args, 1, CandidateSet);
@@ -3146,7 +3132,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
Ptr != CandidateTypes.pointer_end(); ++Ptr) {
QualType ParamTy = *Ptr;
QualType PointeeTy = ParamTy->getAs<PointerType>()->getPointeeType();
- AddBuiltinCandidate(Context.getLValueReferenceType(PointeeTy),
+ AddBuiltinCandidate(Context.getLValueReferenceType(PointeeTy),
&ParamTy, Args, 1, CandidateSet);
}
break;
@@ -3162,7 +3148,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
QualType ParamTy = *Ptr;
AddBuiltinCandidate(ParamTy, &ParamTy, Args, 1, CandidateSet);
}
-
+
// Fall through
UnaryMinus:
@@ -3172,7 +3158,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// T operator+(T);
// T operator-(T);
- for (unsigned Arith = FirstPromotedArithmeticType;
+ for (unsigned Arith = FirstPromotedArithmeticType;
Arith < LastPromotedArithmeticType; ++Arith) {
QualType ArithTy = ArithmeticTypes[Arith];
AddBuiltinCandidate(ArithTy, &ArithTy, Args, 1, CandidateSet);
@@ -3185,7 +3171,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// operator functions of the form
//
// T operator~(T);
- for (unsigned Int = FirstPromotedIntegralType;
+ for (unsigned Int = FirstPromotedIntegralType;
Int < LastPromotedIntegralType; ++Int) {
QualType IntTy = ArithmeticTypes[Int];
AddBuiltinCandidate(IntTy, &IntTy, Args, 1, CandidateSet);
@@ -3211,12 +3197,12 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
case OO_EqualEqual:
case OO_ExclaimEqual:
// C++ [over.match.oper]p16:
- // For every pointer to member type T, there exist candidate operator
- // functions of the form
+ // For every pointer to member type T, there exist candidate operator
+ // functions of the form
//
// bool operator==(T,T);
// bool operator!=(T,T);
- for (BuiltinCandidateTypeSet::iterator
+ for (BuiltinCandidateTypeSet::iterator
MemPtr = CandidateTypes.member_pointer_begin(),
MemPtrEnd = CandidateTypes.member_pointer_end();
MemPtr != MemPtrEnd;
@@ -3224,9 +3210,9 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
QualType ParamTypes[2] = { *MemPtr, *MemPtr };
AddBuiltinCandidate(Context.BoolTy, ParamTypes, Args, 2, CandidateSet);
}
-
+
// Fall through
-
+
case OO_Less:
case OO_Greater:
case OO_LessEqual:
@@ -3235,7 +3221,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// For every pointer or enumeration type T, there exist
// candidate operator functions of the form
- //
+ //
// bool operator<(T, T);
// bool operator>(T, T);
// bool operator<=(T, T);
@@ -3247,7 +3233,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
QualType ParamTypes[2] = { *Ptr, *Ptr };
AddBuiltinCandidate(Context.BoolTy, ParamTypes, Args, 2, CandidateSet);
}
- for (BuiltinCandidateTypeSet::iterator Enum
+ for (BuiltinCandidateTypeSet::iterator Enum
= CandidateTypes.enumeration_begin();
Enum != CandidateTypes.enumeration_end(); ++Enum) {
QualType ParamTypes[2] = { *Enum, *Enum };
@@ -3266,7 +3252,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// For every cv-qualified or cv-unqualified object type T
// there exist candidate operator functions of the form
- //
+ //
// T* operator+(T*, ptrdiff_t);
// T& operator[](T*, ptrdiff_t); [BELOW]
// T* operator-(T*, ptrdiff_t);
@@ -3279,7 +3265,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// exist candidate operator functions of the form
//
// ptrdiff_t operator-(T, T);
- for (BuiltinCandidateTypeSet::iterator Ptr
+ for (BuiltinCandidateTypeSet::iterator Ptr
= CandidateTypes.pointer_begin();
Ptr != CandidateTypes.pointer_end(); ++Ptr) {
QualType ParamTypes[2] = { *Ptr, Context.getPointerDiffType() };
@@ -3334,9 +3320,9 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// where LR is the result of the usual arithmetic conversions
// between types L and R.
// Our candidates ignore the first parameter.
- for (unsigned Left = FirstPromotedArithmeticType;
+ for (unsigned Left = FirstPromotedArithmeticType;
Left < LastPromotedArithmeticType; ++Left) {
- for (unsigned Right = FirstPromotedArithmeticType;
+ for (unsigned Right = FirstPromotedArithmeticType;
Right < LastPromotedArithmeticType; ++Right) {
QualType LandR[2] = { ArithmeticTypes[Left], ArithmeticTypes[Right] };
QualType Result
@@ -3368,9 +3354,9 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// where LR is the result of the usual arithmetic conversions
// between types L and R.
- for (unsigned Left = FirstPromotedIntegralType;
+ for (unsigned Left = FirstPromotedIntegralType;
Left < LastPromotedIntegralType; ++Left) {
- for (unsigned Right = FirstPromotedIntegralType;
+ for (unsigned Right = FirstPromotedIntegralType;
Right < LastPromotedIntegralType; ++Right) {
QualType LandR[2] = { ArithmeticTypes[Left], ArithmeticTypes[Right] };
QualType Result = (Op == OO_LessLess || Op == OO_GreaterGreater)
@@ -3393,13 +3379,13 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
Enum = CandidateTypes.enumeration_begin(),
EnumEnd = CandidateTypes.enumeration_end();
Enum != EnumEnd; ++Enum)
- AddBuiltinAssignmentOperatorCandidates(*this, *Enum, Args, 2,
+ AddBuiltinAssignmentOperatorCandidates(*this, *Enum, Args, 2,
CandidateSet);
for (BuiltinCandidateTypeSet::iterator
MemPtr = CandidateTypes.member_pointer_begin(),
MemPtrEnd = CandidateTypes.member_pointer_end();
MemPtr != MemPtrEnd; ++MemPtr)
- AddBuiltinAssignmentOperatorCandidates(*this, *MemPtr, Args, 2,
+ AddBuiltinAssignmentOperatorCandidates(*this, *MemPtr, Args, 2,
CandidateSet);
// Fall through.
@@ -3455,7 +3441,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// VQ L& operator+=(VQ L&, R);
// VQ L& operator-=(VQ L&, R);
for (unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
- for (unsigned Right = FirstPromotedArithmeticType;
+ for (unsigned Right = FirstPromotedArithmeticType;
Right < LastPromotedArithmeticType; ++Right) {
QualType ParamTypes[2];
ParamTypes[1] = ArithmeticTypes[Right];
@@ -3493,7 +3479,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
// VQ L& operator^=(VQ L&, R);
// VQ L& operator|=(VQ L&, R);
for (unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
- for (unsigned Right = FirstPromotedIntegralType;
+ for (unsigned Right = FirstPromotedIntegralType;
Right < LastPromotedIntegralType; ++Right) {
QualType ParamTypes[2];
ParamTypes[1] = ArithmeticTypes[Right];
@@ -3516,7 +3502,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// There also exist candidate operator functions of the form
//
- // bool operator!(bool);
+ // bool operator!(bool);
// bool operator&&(bool, bool); [BELOW]
// bool operator||(bool, bool); [BELOW]
QualType ParamTy = Context.BoolTy;
@@ -3547,7 +3533,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
//
// For every cv-qualified or cv-unqualified object type T there
// exist candidate operator functions of the form
- //
+ //
// T* operator+(T*, ptrdiff_t); [ABOVE]
// T& operator[](T*, ptrdiff_t);
// T* operator-(T*, ptrdiff_t); [ABOVE]
@@ -3606,7 +3592,7 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
/// given function name (which may also be an operator name) and adds
/// all of the overload candidates found by ADL to the overload
/// candidate set (C++ [basic.lookup.argdep]).
-void
+void
Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet) {
@@ -3645,7 +3631,7 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*Func))
AddOverloadCandidate(FD, Args, NumArgs, CandidateSet);
else
- AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*Func),
+ AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*Func),
/*FIXME: explicit args */false, 0, 0,
Args, NumArgs, CandidateSet);
}
@@ -3653,10 +3639,9 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
/// isBetterOverloadCandidate - Determines whether the first overload
/// candidate is a better candidate than the second (C++ 13.3.3p1).
-bool
+bool
Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
- const OverloadCandidate& Cand2)
-{
+ const OverloadCandidate& Cand2) {
// Define viable functions to be better candidates than non-viable
// functions.
if (!Cand2.Viable)
@@ -3675,8 +3660,8 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
StartArg = 1;
// C++ [over.match.best]p1:
- // A viable function F1 is defined to be a better function than another
- // viable function F2 if for all arguments i, ICSi(F1) is not a worse
+ // A viable function F1 is defined to be a better function than another
+ // viable function F2 if for all arguments i, ICSi(F1) is not a worse
// conversion sequence than ICSi(F2), and then...
unsigned NumArgs = Cand1.Conversions.size();
assert(Cand2.Conversions.size() == NumArgs && "Overload candidate mismatch");
@@ -3699,20 +3684,20 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
}
}
- // -- for some argument j, ICSj(F1) is a better conversion sequence than
+ // -- for some argument j, ICSj(F1) is a better conversion sequence than
// ICSj(F2), or, if not that,
if (HasBetterConversion)
return true;
- // - F1 is a non-template function and F2 is a function template
+ // - F1 is a non-template function and F2 is a function template
// specialization, or, if not that,
if (Cand1.Function && !Cand1.Function->getPrimaryTemplate() &&
Cand2.Function && Cand2.Function->getPrimaryTemplate())
return true;
-
- // -- F1 and F2 are function template specializations, and the function
- // template for F1 is more specialized than the template for F2
- // according to the partial ordering rules described in 14.5.5.2, or,
+
+ // -- F1 and F2 are function template specializations, and the function
+ // template for F1 is more specialized than the template for F2
+ // according to the partial ordering rules described in 14.5.5.2, or,
// if not that,
if (Cand1.Function && Cand1.Function->getPrimaryTemplate() &&
Cand2.Function && Cand2.Function->getPrimaryTemplate())
@@ -3728,8 +3713,8 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
// the type of the entity being initialized) is a better
// conversion sequence than the standard conversion sequence
// from the return type of F2 to the destination type.
- if (Cand1.Function && Cand2.Function &&
- isa<CXXConversionDecl>(Cand1.Function) &&
+ if (Cand1.Function && Cand2.Function &&
+ isa<CXXConversionDecl>(Cand1.Function) &&
isa<CXXConversionDecl>(Cand2.Function)) {
switch (CompareStandardConversionSequences(Cand1.FinalConversion,
Cand2.FinalConversion)) {
@@ -3750,7 +3735,7 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
return false;
}
-/// \brief Computes the best viable function (C++ 13.3.3)
+/// \brief Computes the best viable function (C++ 13.3.3)
/// within an overload candidate set.
///
/// \param CandidateSet the set of candidate functions.
@@ -3758,15 +3743,14 @@ Sema::isBetterOverloadCandidate(const OverloadCandidate& Cand1,
/// \param Loc the location of the function name (or operator symbol) for
/// which overload resolution occurs.
///
-/// \param Best f overload resolution was successful or found a deleted
+/// \param Best f overload resolution was successful or found a deleted
/// function, Best points to the candidate function found.
///
/// \returns The result of overload resolution.
-Sema::OverloadingResult
+Sema::OverloadingResult
Sema::BestViableFunction(OverloadCandidateSet& CandidateSet,
SourceLocation Loc,
- OverloadCandidateSet::iterator& Best)
-{
+ OverloadCandidateSet::iterator& Best) {
// Find the best viable function.
Best = CandidateSet.end();
for (OverloadCandidateSet::iterator Cand = CandidateSet.begin();
@@ -3785,24 +3769,24 @@ Sema::BestViableFunction(OverloadCandidateSet& CandidateSet,
// function. If not, we have an ambiguity.
for (OverloadCandidateSet::iterator Cand = CandidateSet.begin();
Cand != CandidateSet.end(); ++Cand) {
- if (Cand->Viable &&
+ if (Cand->Viable &&
Cand != Best &&
!isBetterOverloadCandidate(*Best, *Cand)) {
Best = CandidateSet.end();
return OR_Ambiguous;
}
}
-
+
// Best is the best viable function.
if (Best->Function &&
- (Best->Function->isDeleted() ||
+ (Best->Function->isDeleted() ||
Best->Function->getAttr<UnavailableAttr>()))
return OR_Deleted;
// C++ [basic.def.odr]p2:
// An overloaded function is used if it is selected by overload resolution
- // when referred to from a potentially-evaluated expression. [Note: this
- // covers calls to named functions (5.2.2), operator overloading
+ // when referred to from a potentially-evaluated expression. [Note: this
+ // covers calls to named functions (5.2.2), operator overloading
// (clause 13), user-defined conversions (12.3.2), allocation function for
// placement new (5.3.4), as well as non-default initialization (8.5).
if (Best->Function)
@@ -3813,10 +3797,9 @@ Sema::BestViableFunction(OverloadCandidateSet& CandidateSet,
/// PrintOverloadCandidates - When overload resolution fails, prints
/// diagnostic messages containing the candidates in the candidate
/// set. If OnlyViable is true, only viable candidates will be printed.
-void
+void
Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
- bool OnlyViable)
-{
+ bool OnlyViable) {
OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
LastCand = CandidateSet.end();
for (; Cand != LastCand; ++Cand) {
@@ -3866,7 +3849,7 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
// FIXME: We need to get the identifier in here
// FIXME: Do we want the error message to point at the operator?
// (built-ins won't have a location)
- QualType FnType
+ QualType FnType
= Context.getFunctionType(Cand->BuiltinTypes.ResultTy,
Cand->BuiltinTypes.ParamTypes,
Cand->Conversions.size(),
@@ -3886,7 +3869,7 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
/// @code
/// int f(double);
/// int f(int);
-///
+///
/// int (*pfd)(double) = f; // selects f(double)
/// @endcode
///
@@ -3915,7 +3898,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
// Find the actual overloaded function declaration.
OverloadedFunctionDecl *Ovl = 0;
-
+
// C++ [over.over]p1:
// [...] [Note: any redundant set of parentheses surrounding the
// overloaded function name is ignored (5.1). ]
@@ -3936,21 +3919,21 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
FunctionTemplate = dyn_cast<FunctionTemplateDecl>(DR->getDecl());
}
- // If there's no overloaded function declaration or function template,
+ // If there's no overloaded function declaration or function template,
// we're done.
if (!Ovl && !FunctionTemplate)
return 0;
-
+
OverloadIterator Fun;
if (Ovl)
Fun = Ovl;
else
Fun = FunctionTemplate;
-
+
// Look through all of the overloaded functions, searching for one
// whose type matches exactly.
llvm::SmallPtrSet<FunctionDecl *, 4> Matches;
-
+
bool FoundNonTemplateFunction = false;
for (OverloadIterator FunEnd; Fun != FunEnd; ++Fun) {
// C++ [over.over]p3:
@@ -3960,22 +3943,22 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
// type "pointer-to-member-function."
// Note that according to DR 247, the containing class does not matter.
- if (FunctionTemplateDecl *FunctionTemplate
+ if (FunctionTemplateDecl *FunctionTemplate
= dyn_cast<FunctionTemplateDecl>(*Fun)) {
- if (CXXMethodDecl *Method
+ if (CXXMethodDecl *Method
= dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) {
- // Skip non-static function templates when converting to pointer, and
+ // Skip non-static function templates when converting to pointer, and
// static when converting to member pointer.
if (Method->isStatic() == IsMember)
continue;
} else if (IsMember)
continue;
-
+
// C++ [over.over]p2:
- // If the name is a function template, template argument deduction is
- // done (14.8.2.2), and if the argument deduction succeeds, the
- // resulting template argument list is used to generate a single
- // function template specialization, which is added to the set of
+ // If the name is a function template, template argument deduction is
+ // done (14.8.2.2), and if the argument deduction succeeds, the
+ // resulting template argument list is used to generate a single
+ // function template specialization, which is added to the set of
// overloaded functions considered.
FunctionDecl *Specialization = 0;
TemplateDeductionInfo Info(Context);
@@ -3986,13 +3969,13 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
// FIXME: make a note of the failed deduction for diagnostics.
(void)Result;
} else {
- assert(FunctionType
+ assert(FunctionType
== Context.getCanonicalType(Specialization->getType()));
Matches.insert(
cast<FunctionDecl>(Specialization->getCanonicalDecl()));
}
}
-
+
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*Fun)) {
// Skip non-static functions when converting to pointer, and static
// when converting to member pointer.
@@ -4006,7 +3989,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
Matches.insert(cast<FunctionDecl>(Fun->getCanonicalDecl()));
FoundNonTemplateFunction = true;
}
- }
+ }
}
// If there were 0 or 1 matches, we're done.
@@ -4042,7 +4025,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
for (++M; M != MEnd; ++M)
if (getMoreSpecializedTemplate((*M)->getPrimaryTemplate(),
(*Best)->getPrimaryTemplate(),
- false)
+ false)
== (*M)->getPrimaryTemplate())
Best = M;
@@ -4074,12 +4057,12 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
// candidates output later.
RemainingMatches.append(Matches.begin(), Matches.end());
}
-
- // [...] After such eliminations, if any, there shall remain exactly one
+
+ // [...] After such eliminations, if any, there shall remain exactly one
// selected function.
if (RemainingMatches.size() == 1)
return RemainingMatches.front();
-
+
// FIXME: We should probably return the same thing that BestViableFunction
// returns (even if we issue the diagnostics here).
Diag(From->getLocStart(), diag::err_addr_ovl_ambiguous)
@@ -4103,7 +4086,7 @@ FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
unsigned NumExplicitTemplateArgs,
SourceLocation LParenLoc,
Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
+ SourceLocation *CommaLocs,
SourceLocation RParenLoc,
bool &ArgumentDependentLookup) {
OverloadCandidateSet CandidateSet;
@@ -4117,16 +4100,16 @@ FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
// and let Y be the lookup set produced by argument dependent
// lookup (defined as follows). If X contains
//
- // -- a declaration of a class member, or
+ // -- a declaration of a class member, or
//
// -- a block-scope function declaration that is not a
- // using-declaration, or
- //
+ // using-declaration, or
+ //
// -- a declaration that is neither a function or a function
// template
//
- // then Y is empty.
- if (OverloadedFunctionDecl *Ovl
+ // then Y is empty.
+ if (OverloadedFunctionDecl *Ovl
= dyn_cast_or_null<OverloadedFunctionDecl>(Callee)) {
for (OverloadedFunctionDecl::function_iterator Func = Ovl->function_begin(),
FuncEnd = Ovl->function_end();
@@ -4135,7 +4118,7 @@ FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(*Func)) {
if (HasExplicitTemplateArgs)
continue;
-
+
AddOverloadCandidate(FunDecl, Args, NumArgs, CandidateSet);
Ctx = FunDecl->getDeclContext();
} else {
@@ -4158,11 +4141,11 @@ FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
if (Func->getDeclContext()->isRecord() ||
Func->getDeclContext()->isFunctionOrMethod())
ArgumentDependentLookup = false;
- } else if (FunctionTemplateDecl *FuncTemplate
+ } else if (FunctionTemplateDecl *FuncTemplate
= dyn_cast_or_null<FunctionTemplateDecl>(Callee)) {
AddTemplateOverloadCandidate(FuncTemplate, HasExplicitTemplateArgs,
ExplicitTemplateArgs,
- NumExplicitTemplateArgs,
+ NumExplicitTemplateArgs,
Args, NumArgs, CandidateSet);
if (FuncTemplate->getDeclContext()->isRecord())
@@ -4231,7 +4214,7 @@ FunctionDecl *Sema::ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee,
Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
unsigned OpcIn,
FunctionSet &Functions,
- ExprArg input) {
+ ExprArg input) {
UnaryOperator::Opcode Opc = static_cast<UnaryOperator::Opcode>(OpcIn);
Expr *Input = (Expr *)input.get();
@@ -4241,28 +4224,28 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
Expr *Args[2] = { Input, 0 };
unsigned NumArgs = 1;
-
+
// For post-increment and post-decrement, add the implicit '0' as
// the second argument, so that we know this is a post-increment or
// post-decrement.
if (Opc == UnaryOperator::PostInc || Opc == UnaryOperator::PostDec) {
llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
- Args[1] = new (Context) IntegerLiteral(Zero, Context.IntTy,
+ Args[1] = new (Context) IntegerLiteral(Zero, Context.IntTy,
SourceLocation());
NumArgs = 2;
}
if (Input->isTypeDependent()) {
- OverloadedFunctionDecl *Overloads
+ OverloadedFunctionDecl *Overloads
= OverloadedFunctionDecl::Create(Context, CurContext, OpName);
- for (FunctionSet::iterator Func = Functions.begin(),
+ for (FunctionSet::iterator Func = Functions.begin(),
FuncEnd = Functions.end();
Func != FuncEnd; ++Func)
Overloads->addOverload(*Func);
DeclRefExpr *Fn = new (Context) DeclRefExpr(Overloads, Context.OverloadTy,
OpLoc, false, false);
-
+
input.release();
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
&Args[0], NumArgs,
@@ -4288,11 +4271,11 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
case OR_Success: {
// We found a built-in operator or an overloaded operator.
FunctionDecl *FnDecl = Best->Function;
-
+
if (FnDecl) {
// We matched an overloaded operator. Build a call to that
// operator.
-
+
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
if (PerformObjectArgumentInitialization(Input, Method))
@@ -4309,15 +4292,15 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
QualType ResultTy
= FnDecl->getType()->getAsFunctionType()->getResultType();
ResultTy = ResultTy.getNonReferenceType();
-
+
// Build the actual expression node.
Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
SourceLocation());
UsualUnaryConversions(FnExpr);
-
+
input.release();
-
- Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+
+ Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
&Input, 1, ResultTy, OpLoc);
return MaybeBindToTemporary(CE);
} else {
@@ -4377,9 +4360,9 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
///
/// \param LHS Left-hand argument.
/// \param RHS Right-hand argument.
-Sema::OwningExprResult
+Sema::OwningExprResult
Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
- unsigned OpcIn,
+ unsigned OpcIn,
FunctionSet &Functions,
Expr *LHS, Expr *RHS) {
Expr *Args[2] = { LHS, RHS };
@@ -4397,18 +4380,18 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
return Owned(new (Context) BinaryOperator(Args[0], Args[1], Opc,
Context.DependentTy, OpLoc));
- OverloadedFunctionDecl *Overloads
+ OverloadedFunctionDecl *Overloads
= OverloadedFunctionDecl::Create(Context, CurContext, OpName);
- for (FunctionSet::iterator Func = Functions.begin(),
+ for (FunctionSet::iterator Func = Functions.begin(),
FuncEnd = Functions.end();
Func != FuncEnd; ++Func)
Overloads->addOverload(*Func);
DeclRefExpr *Fn = new (Context) DeclRefExpr(Overloads, Context.OverloadTy,
OpLoc, false, false);
-
+
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
- Args, 2,
+ Args, 2,
Context.DependentTy,
OpLoc));
}
@@ -4473,7 +4456,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
OpLoc);
UsualUnaryConversions(FnExpr);
- Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+ Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
Args, 2, ResultTy, OpLoc);
return MaybeBindToTemporary(CE);
} else {
@@ -4534,8 +4517,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
/// expression refers to a member function or an overloaded member
/// function.
Sema::ExprResult
-Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
- SourceLocation LParenLoc, Expr **Args,
+Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
+ SourceLocation LParenLoc, Expr **Args,
unsigned NumArgs, SourceLocation *CommaLocs,
SourceLocation RParenLoc) {
// Dig out the member expression. This holds both the object
@@ -4556,11 +4539,11 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
// Add overload candidates
OverloadCandidateSet CandidateSet;
DeclarationName DeclName = MemExpr->getMemberDecl()->getDeclName();
-
+
for (OverloadIterator Func(MemExpr->getMemberDecl()), FuncEnd;
Func != FuncEnd; ++Func) {
if ((Method = dyn_cast<CXXMethodDecl>(*Func)))
- AddMethodCandidate(Method, ObjectArg, Args, NumArgs, CandidateSet,
+ AddMethodCandidate(Method, ObjectArg, Args, NumArgs, CandidateSet,
/*SuppressUserConversions=*/false);
else
AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(*Func),
@@ -4571,7 +4554,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
CandidateSet,
/*SuppressUsedConversions=*/false);
}
-
+
OverloadCandidateSet::iterator Best;
switch (BestViableFunction(CandidateSet, MemExpr->getLocStart(), Best)) {
case OR_Success:
@@ -4579,7 +4562,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
break;
case OR_No_Viable_Function:
- Diag(MemExpr->getSourceRange().getBegin(),
+ Diag(MemExpr->getSourceRange().getBegin(),
diag::err_ovl_no_viable_member_function_in_call)
<< DeclName << MemExprE->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
@@ -4587,7 +4570,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
return true;
case OR_Ambiguous:
- Diag(MemExpr->getSourceRange().getBegin(),
+ Diag(MemExpr->getSourceRange().getBegin(),
diag::err_ovl_ambiguous_member_call)
<< DeclName << MemExprE->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
@@ -4595,7 +4578,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
return true;
case OR_Deleted:
- Diag(MemExpr->getSourceRange().getBegin(),
+ Diag(MemExpr->getSourceRange().getBegin(),
diag::err_ovl_deleted_member_call)
<< Best->Function->isDeleted()
<< DeclName << MemExprE->getSourceRange();
@@ -4610,21 +4593,21 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
}
assert(Method && "Member call to something that isn't a method?");
- ExprOwningPtr<CXXMemberCallExpr>
+ ExprOwningPtr<CXXMemberCallExpr>
TheCall(this, new (Context) CXXMemberCallExpr(Context, MemExpr, Args,
- NumArgs,
+ NumArgs,
Method->getResultType().getNonReferenceType(),
RParenLoc));
// Convert the object argument (for a non-static member function call).
- if (!Method->isStatic() &&
+ if (!Method->isStatic() &&
PerformObjectArgumentInitialization(ObjectArg, Method))
return true;
MemExpr->setBase(ObjectArg);
// Convert the rest of the arguments
const FunctionProtoType *Proto = cast<FunctionProtoType>(Method->getType());
- if (ConvertArgumentsForCall(&*TheCall, MemExpr, Method, Proto, Args, NumArgs,
+ if (ConvertArgumentsForCall(&*TheCall, MemExpr, Method, Proto, Args, NumArgs,
RParenLoc))
return true;
@@ -4638,15 +4621,15 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
/// type (C++ [over.call.object]), which can end up invoking an
/// overloaded function call operator (@c operator()) or performing a
/// user-defined conversion on the object argument.
-Sema::ExprResult
-Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
+Sema::ExprResult
+Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
SourceLocation LParenLoc,
Expr **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
+ SourceLocation *CommaLocs,
SourceLocation RParenLoc) {
assert(Object->getType()->isRecordType() && "Requires object type argument");
const RecordType *Record = Object->getType()->getAs<RecordType>();
-
+
// C++ [over.call.object]p1:
// If the primary-expression E in the function call syntax
// evaluates to a class object of type "cv T", then the set of
@@ -4659,7 +4642,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
DeclContext::lookup_const_iterator Oper, OperEnd;
for (llvm::tie(Oper, OperEnd) = Record->getDecl()->lookup(OpName);
Oper != OperEnd; ++Oper)
- AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Object, Args, NumArgs,
+ AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Object, Args, NumArgs,
CandidateSet, /*SuppressUserConversions=*/false);
// C++ [over.call.object]p2:
@@ -4679,12 +4662,12 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
// functions for each conversion function declared in an
// accessible base class provided the function is not hidden
// within T by another intervening declaration.
-
+
if (!RequireCompleteType(SourceLocation(), Object->getType(), 0)) {
// FIXME: Look in base classes for more conversion operators!
- OverloadedFunctionDecl *Conversions
+ OverloadedFunctionDecl *Conversions
= cast<CXXRecordDecl>(Record->getDecl())->getConversionFunctions();
- for (OverloadedFunctionDecl::function_iterator
+ for (OverloadedFunctionDecl::function_iterator
Func = Conversions->function_begin(),
FuncEnd = Conversions->function_end();
Func != FuncEnd; ++Func) {
@@ -4707,7 +4690,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
AddSurrogateCandidate(Conv, Proto, Object, Args, NumArgs, CandidateSet);
}
}
-
+
// Perform overload resolution.
OverloadCandidateSet::iterator Best;
switch (BestViableFunction(CandidateSet, Object->getLocStart(), Best)) {
@@ -4717,7 +4700,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
break;
case OR_No_Viable_Function:
- Diag(Object->getSourceRange().getBegin(),
+ Diag(Object->getSourceRange().getBegin(),
diag::err_ovl_no_viable_object_call)
<< Object->getType() << Object->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
@@ -4737,7 +4720,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
<< Object->getType() << Object->getSourceRange();
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/true);
break;
- }
+ }
if (Best == CandidateSet.end()) {
// We had an error; delete all of the subexpressions and return
@@ -4751,7 +4734,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
if (Best->Function == 0) {
// Since there is no function declaration, this is one of the
// surrogate candidates. Dig out the conversion function.
- CXXConversionDecl *Conv
+ CXXConversionDecl *Conv
= cast<CXXConversionDecl>(
Best->Conversions[0].UserDefined.ConversionFunction);
@@ -4790,16 +4773,16 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
MethodArgs[0] = Object;
for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx)
MethodArgs[ArgIdx + 1] = Args[ArgIdx];
-
- Expr *NewFn = new (Context) DeclRefExpr(Method, Method->getType(),
+
+ Expr *NewFn = new (Context) DeclRefExpr(Method, Method->getType(),
SourceLocation());
UsualUnaryConversions(NewFn);
// Once we've built TheCall, all of the expressions are properly
// owned.
QualType ResultTy = Method->getResultType().getNonReferenceType();
- ExprOwningPtr<CXXOperatorCallExpr>
- TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn,
+ ExprOwningPtr<CXXOperatorCallExpr>
+ TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn,
MethodArgs, NumArgs + 1,
ResultTy, RParenLoc));
delete [] MethodArgs;
@@ -4823,7 +4806,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
Expr *Arg;
if (i < NumArgs) {
Arg = Args[i];
-
+
// Pass the argument.
QualType ProtoArgType = Proto->getArgType(i);
IsError |= PerformCopyInitialization(Arg, ProtoArgType, "passing");
@@ -4853,13 +4836,13 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
}
/// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
-/// (if one exists), where @c Base is an expression of class type and
+/// (if one exists), where @c Base is an expression of class type and
/// @c Member is the name of the member we're trying to find.
Sema::OwningExprResult
Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) {
Expr *Base = static_cast<Expr *>(BaseIn.get());
assert(Base->getType()->isRecordType() && "left-hand side must have class type");
-
+
// C++ [over.ref]p1:
//
// [...] An expression x->m is interpreted as (x.operator->())->m
@@ -4872,7 +4855,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) {
const RecordType *BaseRecord = Base->getType()->getAs<RecordType>();
DeclContext::lookup_const_iterator Oper, OperEnd;
- for (llvm::tie(Oper, OperEnd)
+ for (llvm::tie(Oper, OperEnd)
= BaseRecord->getDecl()->lookup(OpName); Oper != OperEnd; ++Oper)
AddMethodCandidate(cast<CXXMethodDecl>(*Oper), Base, 0, 0, CandidateSet,
/*SuppressUserConversions=*/false);
@@ -4920,7 +4903,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) {
Expr *FnExpr = new (Context) DeclRefExpr(Method, Method->getType(),
SourceLocation());
UsualUnaryConversions(FnExpr);
- Base = new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, &Base, 1,
+ Base = new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, &Base, 1,
Method->getResultType().getNonReferenceType(),
OpLoc);
return Owned(Base);
@@ -4936,13 +4919,13 @@ void Sema::FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn) {
FixOverloadedFunctionReference(PE->getSubExpr(), Fn);
E->setType(PE->getSubExpr()->getType());
} else if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(E)) {
- assert(UnOp->getOpcode() == UnaryOperator::AddrOf &&
+ assert(UnOp->getOpcode() == UnaryOperator::AddrOf &&
"Can only take the address of an overloaded function");
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) {
if (Method->isStatic()) {
// Do nothing: static member functions aren't any different
// from non-member functions.
- } else if (QualifiedDeclRefExpr *DRE
+ } else if (QualifiedDeclRefExpr *DRE
= dyn_cast<QualifiedDeclRefExpr>(UnOp->getSubExpr())) {
// We have taken the address of a pointer to member
// function. Perform the computation here so that we get the
@@ -4951,7 +4934,7 @@ void Sema::FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn) {
DRE->setType(Fn->getType());
QualType ClassType
= Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
- E->setType(Context.getMemberPointerType(Fn->getType(),
+ E->setType(Context.getMemberPointerType(Fn->getType(),
ClassType.getTypePtr()));
return;
}
@@ -4960,7 +4943,7 @@ void Sema::FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn) {
E->setType(Context.getPointerType(UnOp->getSubExpr()->getType()));
} else if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E)) {
assert((isa<OverloadedFunctionDecl>(DR->getDecl()) ||
- isa<FunctionTemplateDecl>(DR->getDecl())) &&
+ isa<FunctionTemplateDecl>(DR->getDecl())) &&
"Expected overloaded function or function template");
DR->setDecl(Fn);
E->setType(Fn->getType());
diff --git a/lib/Sema/SemaOverload.h b/lib/Sema/SemaOverload.h
index 9de3806576..1f3e4df7cb 100644
--- a/lib/Sema/SemaOverload.h
+++ b/lib/Sema/SemaOverload.h
@@ -59,7 +59,7 @@ namespace clang {
ICC_Conversion ///< Conversion
};
- ImplicitConversionCategory
+ ImplicitConversionCategory
GetConversionCategory(ImplicitConversionKind Kind);
/// ImplicitConversionRank - The rank of an implicit conversion
@@ -98,7 +98,7 @@ namespace clang {
ImplicitConversionKind Third : 8;
/// Deprecated - Whether this the deprecated conversion of a
- /// string literal to a pointer to non-const character data
+ /// string literal to a pointer to non-const character data
/// (C++ 4.2p2).
bool Deprecated : 1;
@@ -106,11 +106,11 @@ namespace clang {
/// that we should warn about (if we actually use it).
bool IncompatibleObjC : 1;
- /// ReferenceBinding - True when this is a reference binding
+ /// ReferenceBinding - True when this is a reference binding
/// (C++ [over.ics.ref]).
bool ReferenceBinding : 1;
- /// DirectBinding - True when this is a reference binding that is a
+ /// DirectBinding - True when this is a reference binding that is a
/// direct binding (C++ [dcl.init.ref]).
bool DirectBinding : 1;
@@ -134,7 +134,7 @@ namespace clang {
/// conversions.
CXXConstructorDecl *CopyConstructor;
- void setAsIdentityConversion();
+ void setAsIdentityConversion();
ImplicitConversionRank getRank() const;
bool isPointerConversionToBool() const;
bool isPointerConversionToVoidPointer(ASTContext& Context) const;
@@ -159,7 +159,7 @@ namespace clang {
/// After - Represents the standard conversion that occurs after
/// the actual user-defined conversion.
StandardConversionSequence After;
-
+
/// ConversionFunction - The function that will perform the
/// user-defined conversion.
FunctionDecl* ConversionFunction;
@@ -168,7 +168,7 @@ namespace clang {
};
/// ImplicitConversionSequence - Represents an implicit conversion
- /// sequence, which may be a standard conversion sequence
+ /// sequence, which may be a standard conversion sequence
/// (C++ 13.3.3.1.1), user-defined conversion sequence (C++ 13.3.3.1.2),
/// or an ellipsis conversion sequence (C++ 13.3.3.1.3).
struct ImplicitConversionSequence {
@@ -211,8 +211,8 @@ namespace clang {
/// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
struct OverloadCandidate {
/// Function - The actual function that this candidate
- /// represents. When NULL, this is a built-in candidate
- /// (C++ [over.oper]) or a surrogate for a conversion to a
+ /// represents. When NULL, this is a built-in candidate
+ /// (C++ [over.oper]) or a surrogate for a conversion to a
/// function pointer or reference (C++ [over.call.object]).
FunctionDecl *Function;
@@ -222,7 +222,7 @@ namespace clang {
QualType ResultTy;
QualType ParamTypes[3];
} BuiltinTypes;
-
+
/// Surrogate - The conversion function for which this candidate
/// is a surrogate, but only if IsSurrogate is true.
CXXConversionDecl *Surrogate;
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 76113107ba..4ffca8c8f5 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -52,10 +52,10 @@ Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg,
SourceLocation StartLoc,
SourceLocation EndLoc) {
DeclGroupRef DG = dg.getAsVal<DeclGroupRef>();
-
+
// If we have an invalid decl, just return an error.
if (DG.isNull()) return StmtError();
-
+
return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc));
}
@@ -67,12 +67,12 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
// Ignore expressions that have void type.
if (E->getType()->isVoidType())
return;
-
+
SourceLocation Loc;
SourceRange R1, R2;
if (!E->isUnusedResultAWarning(Loc, R1, R2))
return;
-
+
// Okay, we have an unused result. Depending on what the base expression is,
// we might want to make a more specific diagnostic. Check for one of these
// cases now.
@@ -80,7 +80,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) {
E = E->IgnoreParens();
if (isa<ObjCImplicitSetterGetterRefExpr>(E))
DiagID = diag::warn_unused_property_expr;
-
+
Diag(Loc, DiagID) << R1 << R2;
}
@@ -101,7 +101,7 @@ Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R,
// We found the end of the list or a statement. Scan for another declstmt.
for (; i != NumElts && !isa<DeclStmt>(Elts[i]); ++i)
/*empty*/;
-
+
if (i != NumElts) {
Decl *D = *cast<DeclStmt>(Elts[i])->decl_begin();
Diag(D->getLocation(), diag::ext_mixed_decls_code);
@@ -112,7 +112,7 @@ Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R,
// Ignore statements that are last in a statement expression.
if (isStmtExpr && i == NumElts - 1)
continue;
-
+
DiagnoseUnusedExprResult(Elts[i]);
}
@@ -126,9 +126,9 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval,
assert((lhsval.get() != 0) && "missing expression in case statement");
// C99 6.8.4.2p3: The expression shall be an integer constant.
- // However, GCC allows any evaluatable integer expression.
+ // However, GCC allows any evaluatable integer expression.
Expr *LHSVal = static_cast<Expr*>(lhsval.get());
- if (!LHSVal->isTypeDependent() && !LHSVal->isValueDependent() &&
+ if (!LHSVal->isTypeDependent() && !LHSVal->isValueDependent() &&
VerifyIntegerConstantExpression(LHSVal))
return StmtError();
@@ -163,7 +163,7 @@ void Sema::ActOnCaseStmtBody(StmtTy *caseStmt, StmtArg subStmt) {
}
Action::OwningStmtResult
-Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
+Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
StmtArg subStmt, Scope *CurScope) {
Stmt *SubStmt = subStmt.takeAs<Stmt>();
@@ -210,7 +210,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal,
StmtArg ThenVal, SourceLocation ElseLoc,
StmtArg ElseVal) {
OwningExprResult CondResult(CondVal.release());
-
+
Expr *condExpr = CondResult.takeAs<Expr>();
assert(condExpr && "ActOnIfStmt(): missing expression");
@@ -220,12 +220,12 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal,
// Take ownership again until we're past the error checking.
CondResult = condExpr;
QualType condType = condExpr->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
return StmtError();
} else if (!condType->isScalarType()) // C99 6.8.4.1p1
- return StmtError(Diag(IfLoc,
+ return StmtError(Diag(IfLoc,
diag::err_typecheck_statement_requires_scalar)
<< condType << condExpr->getSourceRange());
}
@@ -237,14 +237,14 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal,
// this helps prevent bugs due to typos, such as
// if (condition);
// do_stuff();
- if (!ElseVal.get()) {
+ if (!ElseVal.get()) {
if (NullStmt* stmt = dyn_cast<NullStmt>(thenStmt))
Diag(stmt->getSemiLoc(), diag::warn_empty_if_body);
}
Stmt *elseStmt = ElseVal.takeAs<Stmt>();
DiagnoseUnusedExprResult(elseStmt);
-
+
CondResult.release();
return Owned(new (Context) IfStmt(IfLoc, condExpr, thenStmt,
ElseLoc, elseStmt));
@@ -264,9 +264,9 @@ Sema::ActOnStartOfSwitchStmt(ExprArg cond) {
// of this section. Integral promotions are performed.
if (!Cond->isTypeDependent()) {
QualType Ty = Cond->getType();
-
+
// FIXME: Handle class types.
-
+
// If the type is wrong a diagnostic will be emitted later at
// ActOnFinishSwitchStmt.
if (Ty->isIntegralType() || Ty->isEnumeralType()) {
@@ -290,19 +290,19 @@ Sema::ActOnStartOfSwitchStmt(ExprArg cond) {
/// the specified diagnostic.
void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
unsigned NewWidth, bool NewSign,
- SourceLocation Loc,
+ SourceLocation Loc,
unsigned DiagID) {
// Perform a conversion to the promoted condition type if needed.
if (NewWidth > Val.getBitWidth()) {
// If this is an extension, just do it.
llvm::APSInt OldVal(Val);
Val.extend(NewWidth);
-
+
// If the input was signed and negative and the output is unsigned,
// warn.
if (!NewSign && OldVal.isSigned() && OldVal.isNegative())
Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
-
+
Val.setIsSigned(NewSign);
} else if (NewWidth < Val.getBitWidth()) {
// If this is a truncation, check for overflow.
@@ -313,7 +313,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
ConvVal.setIsSigned(Val.isSigned());
if (ConvVal != Val)
Diag(Loc, DiagID) << Val.toString(10) << ConvVal.toString(10);
-
+
// Regardless of whether a diagnostic was emitted, really do the
// truncation.
Val.trunc(NewWidth);
@@ -323,7 +323,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
// overflow as well: unsigned(INTMIN)
llvm::APSInt OldVal(Val);
Val.setIsSigned(NewSign);
-
+
if (Val.isNegative()) // Sign bit changes meaning.
Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
}
@@ -369,12 +369,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
assert(SS == (SwitchStmt*)Switch.get() && "switch stack missing push/pop!");
SS->setBody(BodyStmt, SwitchLoc);
- getSwitchStack().pop_back();
+ getSwitchStack().pop_back();
Expr *CondExpr = SS->getCond();
QualType CondType = CondExpr->getType();
- if (!CondExpr->isTypeDependent() &&
+ if (!CondExpr->isTypeDependent() &&
!CondType->isIntegerType()) { // C99 6.8.4.2p1
Diag(SwitchLoc, diag::err_typecheck_statement_requires_integer)
<< CondType << CondExpr->getSourceRange();
@@ -383,29 +383,29 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
// Get the bitwidth of the switched-on value before promotions. We must
// convert the integer case values to this width before comparison.
- bool HasDependentValue
+ bool HasDependentValue
= CondExpr->isTypeDependent() || CondExpr->isValueDependent();
- unsigned CondWidth
+ unsigned CondWidth
= HasDependentValue? 0
: static_cast<unsigned>(Context.getTypeSize(CondType));
bool CondIsSigned = CondType->isSignedIntegerType();
-
+
// Accumulate all of the case values in a vector so that we can sort them
// and detect duplicates. This vector contains the APInt for the case after
// it has been converted to the condition type.
typedef llvm::SmallVector<std::pair<llvm::APSInt, CaseStmt*>, 64> CaseValsTy;
CaseValsTy CaseVals;
-
+
// Keep track of any GNU case ranges we see. The APSInt is the low value.
std::vector<std::pair<llvm::APSInt, CaseStmt*> > CaseRanges;
-
+
DefaultStmt *TheDefaultStmt = 0;
-
+
bool CaseListIsErroneous = false;
-
+
for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
SC = SC->getNextSwitchCase()) {
-
+
if (DefaultStmt *DS = dyn_cast<DefaultStmt>(SC)) {
if (TheDefaultStmt) {
Diag(DS->getDefaultLoc(), diag::err_multiple_default_labels_defined);
@@ -418,10 +418,10 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
CaseListIsErroneous = true;
}
TheDefaultStmt = DS;
-
+
} else {
CaseStmt *CS = cast<CaseStmt>(SC);
-
+
// We already verified that the expression has a i-c-e value (C99
// 6.8.4.2p3) - get that value now.
Expr *Lo = CS->getLHS();
@@ -430,9 +430,9 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
HasDependentValue = true;
break;
}
-
+
llvm::APSInt LoVal = Lo->EvaluateAsInt(Context);
-
+
// Convert the value to the same width/sign as the condition.
ConvertIntegerToTypeWarnOnOverflow(LoVal, CondWidth, CondIsSigned,
CS->getLHS()->getLocStart(),
@@ -442,16 +442,16 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
// cast.
ImpCastExprToType(Lo, CondType);
CS->setLHS(Lo);
-
+
// If this is a case range, remember it in CaseRanges, otherwise CaseVals.
if (CS->getRHS()) {
- if (CS->getRHS()->isTypeDependent() ||
+ if (CS->getRHS()->isTypeDependent() ||
CS->getRHS()->isValueDependent()) {
HasDependentValue = true;
break;
}
CaseRanges.push_back(std::make_pair(LoVal, CS));
- } else
+ } else
CaseVals.push_back(std::make_pair(LoVal, CS));
}
}
@@ -466,7 +466,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
// If we have a duplicate, report it.
Diag(CaseVals[i+1].second->getLHS()->getLocStart(),
diag::err_duplicate_case) << CaseVals[i].first.toString(10);
- Diag(CaseVals[i].second->getLHS()->getLocStart(),
+ Diag(CaseVals[i].second->getLHS()->getLocStart(),
diag::note_duplicate_case_prev);
// FIXME: We really want to remove the bogus case stmt from the
// substmt, but we have no way to do this right now.
@@ -474,31 +474,31 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
}
}
}
-
+
// Detect duplicate case ranges, which usually don't exist at all in
// the first place.
if (!CaseRanges.empty()) {
// Sort all the case ranges by their low value so we can easily detect
// overlaps between ranges.
std::stable_sort(CaseRanges.begin(), CaseRanges.end());
-
+
// Scan the ranges, computing the high values and removing empty ranges.
std::vector<llvm::APSInt> HiVals;
for (unsigned i = 0, e = CaseRanges.size(); i != e; ++i) {
CaseStmt *CR = CaseRanges[i].second;
Expr *Hi = CR->getRHS();
llvm::APSInt HiVal = Hi->EvaluateAsInt(Context);
-
+
// Convert the value to the same width/sign as the condition.
ConvertIntegerToTypeWarnOnOverflow(HiVal, CondWidth, CondIsSigned,
CR->getRHS()->getLocStart(),
diag::warn_case_value_overflow);
-
+
// If the LHS is not the same type as the condition, insert an implicit
// cast.
ImpCastExprToType(Hi, CondType);
CR->setRHS(Hi);
-
+
// If the low value is bigger than the high value, the case is empty.
if (CaseRanges[i].first > HiVal) {
Diag(CR->getLHS()->getLocStart(), diag::warn_case_empty_range)
@@ -510,7 +510,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
}
HiVals.push_back(HiVal);
}
-
+
// Rescan the ranges, looking for overlap with singleton values and other
// ranges. Since the range list is sorted, we only need to compare case
// ranges with their neighbors.
@@ -518,12 +518,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
llvm::APSInt &CRLo = CaseRanges[i].first;
llvm::APSInt &CRHi = HiVals[i];
CaseStmt *CR = CaseRanges[i].second;
-
+
// Check to see whether the case range overlaps with any
// singleton cases.
CaseStmt *OverlapStmt = 0;
llvm::APSInt OverlapVal(32);
-
+
// Find the smallest value >= the lower bound. If I is in the
// case range, then we have overlap.
CaseValsTy::iterator I = std::lower_bound(CaseVals.begin(),
@@ -533,26 +533,26 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
OverlapVal = I->first; // Found overlap with scalar.
OverlapStmt = I->second;
}
-
+
// Find the smallest value bigger than the upper bound.
I = std::upper_bound(I, CaseVals.end(), CRHi, CaseCompareFunctor());
if (I != CaseVals.begin() && (I-1)->first >= CRLo) {
OverlapVal = (I-1)->first; // Found overlap with scalar.
OverlapStmt = (I-1)->second;
}
-
+
// Check to see if this case stmt overlaps with the subsequent
// case range.
if (i && CRLo <= HiVals[i-1]) {
OverlapVal = HiVals[i-1]; // Found overlap with range.
OverlapStmt = CaseRanges[i-1].second;
}
-
+
if (OverlapStmt) {
// If we have a duplicate, report it.
Diag(CR->getLHS()->getLocStart(), diag::err_duplicate_case)
<< OverlapVal.toString(10);
- Diag(OverlapStmt->getLHS()->getLocStart(),
+ Diag(OverlapStmt->getLHS()->getLocStart(),
diag::note_duplicate_case_prev);
// FIXME: We really want to remove the bogus case stmt from the
// substmt, but we have no way to do this right now.
@@ -581,7 +581,7 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, StmtArg Body) {
DefaultFunctionArrayConversion(condExpr);
CondArg = condExpr;
QualType condType = condExpr->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
return StmtError();
@@ -593,7 +593,7 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, StmtArg Body) {
Stmt *bodyStmt = Body.takeAs<Stmt>();
DiagnoseUnusedExprResult(bodyStmt);
-
+
CondArg.release();
return Owned(new (Context) WhileStmt(condExpr, bodyStmt, WhileLoc));
}
@@ -609,12 +609,12 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
DefaultFunctionArrayConversion(condExpr);
Cond = condExpr;
QualType condType = condExpr->getType();
-
+
if (getLangOptions().CPlusPlus) {
if (CheckCXXBooleanCondition(condExpr)) // C++ 6.4p4
return StmtError();
} else if (!condType->isScalarType()) // C99 6.8.5p2
- return StmtError(Diag(DoLoc,
+ return StmtError(Diag(DoLoc,
diag::err_typecheck_statement_requires_scalar)
<< condType << condExpr->getSourceRange());
}
@@ -664,7 +664,7 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
diag::err_typecheck_statement_requires_scalar)
<< SecondType << Second->getSourceRange());
}
-
+
DiagnoseUnusedExprResult(First);
DiagnoseUnusedExprResult(Third);
DiagnoseUnusedExprResult(Body);
@@ -707,9 +707,9 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
diag::err_selector_element_not_lvalue)
<< First->getSourceRange());
- FirstType = static_cast<Expr*>(First)->getType();
+ FirstType = static_cast<Expr*>(First)->getType();
}
- if (!FirstType->isObjCObjectPointerType() &&
+ if (!FirstType->isObjCObjectPointerType() &&
!FirstType->isBlockPointerType())
Diag(ForLoc, diag::err_selector_element_type)
<< FirstType << First->getSourceRange();
@@ -832,8 +832,8 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
// we have a non-void block with an expression, continue checking
QualType RetValType = RetValExp->getType();
- // C99 6.8.6.4p3(136): The return statement is not an assignment. The
- // overlap restriction of subclause 6.5.16.1 does not apply to the case of
+ // C99 6.8.6.4p3(136): The return statement is not an assignment. The
+ // overlap restriction of subclause 6.5.16.1 does not apply to the case of
// function return.
// In C++ the return statement is handled via a copy initialization.
@@ -890,7 +890,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
FnRetType = MD->getResultType();
else // If we don't have a function/method context, bail.
return StmtError();
-
+
if (FnRetType->isVoidType()) {
if (RetValExp) {// C99 6.8.6.4p1 (ext_ since GCC warns)
unsigned D = diag::ext_return_has_expr;
@@ -905,7 +905,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
<< CurDecl->getDeclName() << isa<ObjCMethodDecl>(CurDecl)
<< RetValExp->getSourceRange();
}
-
+
RetValExp = MaybeCreateCXXExprWithTemporaries(RetValExp, true);
}
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
@@ -926,8 +926,8 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
if (!FnRetType->isDependentType() && !RetValExp->isTypeDependent()) {
// we have a non-void function with an expression, continue checking
- // C99 6.8.6.4p3(136): The return statement is not an assignment. The
- // overlap restriction of subclause 6.5.16.1 does not apply to the case of
+ // C99 6.8.6.4p3(136): The return statement is not an assignment. The
+ // overlap restriction of subclause 6.5.16.1 does not apply to the case of
// function return.
// C++0x 12.8p15: When certain criteria are met, an implementation is
@@ -1009,7 +1009,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers.get());
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
-
+
// The parser verifies that there is a string literal here.
if (AsmString->isWide())
return StmtError(Diag(AsmString->getLocStart(),diag::err_asm_wide_character)
@@ -1021,7 +1021,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
<< Literal->getSourceRange());
- TargetInfo::ConstraintInfo Info(Literal->getStrData(),
+ TargetInfo::ConstraintInfo Info(Literal->getStrData(),
Literal->getByteLength(),
Names[i]);
if (!Context.Target.validateOutputConstraint(Info))
@@ -1036,7 +1036,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
diag::err_asm_invalid_lvalue_in_output)
<< OutputExpr->getSourceRange());
}
-
+
OutputConstraintInfos.push_back(Info);
}
@@ -1048,7 +1048,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
<< Literal->getSourceRange());
- TargetInfo::ConstraintInfo Info(Literal->getStrData(),
+ TargetInfo::ConstraintInfo Info(Literal->getStrData(),
Literal->getByteLength(),
Names[i]);
if (!Context.Target.validateInputConstraint(OutputConstraintInfos.data(),
@@ -1073,13 +1073,13 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
if (InputExpr->getType()->isVoidType()) {
return StmtError(Diag(InputExpr->getLocStart(),
diag::err_asm_invalid_type_in_input)
- << InputExpr->getType() << Info.getConstraintStr()
+ << InputExpr->getType() << Info.getConstraintStr()
<< InputExpr->getSourceRange());
}
}
-
+
DefaultFunctionArrayConversion(Exprs[i]);
-
+
InputConstraintInfos.push_back(Info);
}
@@ -1117,16 +1117,16 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
DeleteStmt(NS);
return StmtError();
}
-
+
// Validate tied input operands for type mismatches.
for (unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
-
+
// If this is a tied constraint, verify that the output and input have
// either exactly the same type, or that they are int/ptr operands with the
// same size (int/long, int*/long, are ok etc).
if (!Info.hasTiedOperand()) continue;
-
+
unsigned TiedTo = Info.getTiedOperand();
Expr *OutputExpr = Exprs[TiedTo];
Expr *InputExpr = Exprs[i+NumOutputs];
@@ -1134,11 +1134,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
QualType OutTy = OutputExpr->getType();
if (Context.hasSameType(InTy, OutTy))
continue; // All types can be tied to themselves.
-
+
// Int/ptr operands have some special cases that we allow.
if ((OutTy->isIntegerType() || OutTy->isPointerType()) &&
(InTy->isIntegerType() || InTy->isPointerType())) {
-
+
// They are ok if they are the same size. Tying void* to int is ok if
// they are the same size, for example. This also allows tying void* to
// int*.
@@ -1146,7 +1146,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
uint64_t InSize = Context.getTypeSize(InTy);
if (OutSize == InSize)
continue;
-
+
// If the smaller input/output operand is not mentioned in the asm string,
// then we can promote it and the asm string won't notice. Check this
// case now.
@@ -1154,7 +1154,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
for (unsigned p = 0, e = Pieces.size(); p != e; ++p) {
AsmStmt::AsmStringPiece &Piece = Pieces[p];
if (!Piece.isOperand()) continue;
-
+
// If this is a reference to the input and if the input was the smaller
// one, then we have to reject this asm.
if (Piece.getOperandNo() == i+NumOutputs) {
@@ -1173,7 +1173,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
}
}
}
-
+
// If the smaller value wasn't mentioned in the asm string, and if the
// output was a register, just extend the shorter one to the size of the
// larger one.
@@ -1181,7 +1181,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
OutputConstraintInfos[TiedTo].allowsRegister())
continue;
}
-
+
Diag(InputExpr->getLocStart(),
diag::err_asm_tying_incompatible_types)
<< InTy << OutTy << OutputExpr->getSourceRange()
@@ -1189,7 +1189,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
DeleteStmt(NS);
return StmtError();
}
-
+
return Owned(NS);
}
@@ -1199,18 +1199,18 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
StmtArg Body, StmtArg catchList) {
Stmt *CatchList = catchList.takeAs<Stmt>();
ParmVarDecl *PVD = cast_or_null<ParmVarDecl>(Parm.getAs<Decl>());
-
+
// PVD == 0 implies @catch(...).
if (PVD) {
// If we already know the decl is invalid, reject it.
if (PVD->isInvalidDecl())
return StmtError();
-
+
if (!PVD->getType()->isObjCObjectPointerType())
- return StmtError(Diag(PVD->getLocation(),
+ return StmtError(Diag(PVD->getLocation(),
diag::err_catch_param_not_objc_type));
if (PVD->getType()->isObjCQualifiedIdType())
- return StmtError(Diag(PVD->getLocation(),
+ return StmtError(Diag(PVD->getLocation(),
diag::err_illegal_qualifiers_on_catch_parm));
}
@@ -1271,8 +1271,8 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
return StmtError(Diag(AtLoc, diag::error_objc_synchronized_expects_object)
<< SyncExpr->getType() << SyncExpr->getSourceRange());
}
-
- return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
+
+ return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
SynchExpr.takeAs<Stmt>(),
SynchBody.takeAs<Stmt>()));
}
@@ -1307,12 +1307,12 @@ public:
else
return getTypeSpecStartLoc() < y.getTypeSpecStartLoc();
}
-
+
bool operator==(const TypeWithHandler& other) const {
return t.getTypePtr() == other.t.getTypePtr()
&& t.getCVRQualifiers() == other.t.getCVRQualifiers();
}
-
+
QualType getQualType() const { return t; }
CXXCatchStmt *getCatchStmt() const { return stmt; }
SourceLocation getTypeSpecStartLoc() const {
@@ -1331,17 +1331,17 @@ Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock,
Stmt **Handlers = reinterpret_cast<Stmt**>(RawHandlers.get());
llvm::SmallVector<TypeWithHandler, 8> TypesWithHandlers;
-
- for(unsigned i = 0; i < NumHandlers; ++i) {
+
+ for (unsigned i = 0; i < NumHandlers; ++i) {
CXXCatchStmt *Handler = llvm::cast<CXXCatchStmt>(Handlers[i]);
if (!Handler->getExceptionDecl()) {
if (i < NumHandlers - 1)
return StmtError(Diag(Handler->getLocStart(),
diag::err_early_catch_all));
-
+
continue;
}
-
+
const QualType CaughtType = Handler->getCaughtType();
const QualType CanonicalCaughtType = Context.getCanonicalType(CaughtType);
TypesWithHandlers.push_back(TypeWithHandler(CanonicalCaughtType, Handler));
@@ -1350,11 +1350,11 @@ Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock,
// Detect handlers for the same type as an earlier one.
if (NumHandlers > 1) {
llvm::array_pod_sort(TypesWithHandlers.begin(), TypesWithHandlers.end());
-
+
TypeWithHandler prev = TypesWithHandlers[0];
for (unsigned i = 1; i < TypesWithHandlers.size(); ++i) {
TypeWithHandler curr = TypesWithHandlers[i];
-
+
if (curr == prev) {
Diag(curr.getTypeSpecStartLoc(),
diag::warn_exception_caught_by_earlier_handler)
@@ -1363,11 +1363,11 @@ Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock,
diag::note_previous_exception_handler)
<< prev.getCatchStmt()->getCaughtType().getAsString();
}
-
+
prev = curr;
}
}
-
+
// FIXME: We should detect handlers that cannot catch anything because an
// earlier handler catches a superclass. Need to find a method that is not
// quadratic for this.
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index dc455185fe..fceac854ee 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -27,10 +27,10 @@ using namespace clang;
static NamedDecl *isAcceptableTemplateName(ASTContext &Context, NamedDecl *D) {
if (!D)
return 0;
-
+
if (isa<TemplateDecl>(D))
return D;
-
+
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {
// C++ [temp.local]p1:
// Like normal (non-template) classes, class templates have an
@@ -52,14 +52,14 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, NamedDecl *D) {
= dyn_cast<ClassTemplateSpecializationDecl>(Record))
return Spec->getSpecializedTemplate();
}
-
+
return 0;
}
-
+
OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D);
if (!Ovl)
return 0;
-
+
for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
FEnd = Ovl->function_end();
F != FEnd; ++F) {
@@ -71,11 +71,11 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, NamedDecl *D) {
if (isa<FunctionTemplateDecl>(*F))
break;
}
-
+
if (F != FEnd) {
// Build an overloaded function decl containing only the
// function templates in Ovl.
- OverloadedFunctionDecl *OvlTemplate
+ OverloadedFunctionDecl *OvlTemplate
= OverloadedFunctionDecl::Create(Context,
Ovl->getDeclContext(),
Ovl->getDeclName());
@@ -85,19 +85,19 @@ static NamedDecl *isAcceptableTemplateName(ASTContext &Context, NamedDecl *D) {
if (isa<FunctionTemplateDecl>(*F))
OvlTemplate->addOverload(*F);
}
-
+
return OvlTemplate;
}
return FuncTmpl;
}
}
-
+
return 0;
}
TemplateNameKind Sema::isTemplateName(Scope *S,
- const IdentifierInfo &II,
+ const IdentifierInfo &II,
SourceLocation IdLoc,
const CXXScopeSpec *SS,
TypeTy *ObjectTypePtr,
@@ -109,7 +109,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
if (ObjectTypePtr) {
// This nested-name-specifier occurs in a member access expression, e.g.,
// x->B::f, and we are looking into the type of the object.
- assert((!SS || !SS->isSet()) &&
+ assert((!SS || !SS->isSet()) &&
"ObjectType and scope specifier cannot coexist");
QualType ObjectType = QualType::getFromOpaquePtr(ObjectTypePtr);
LookupCtx = computeDeclContext(ObjectType);
@@ -121,29 +121,29 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
LookupCtx = computeDeclContext(*SS, EnteringContext);
isDependent = isDependentScopeSpecifier(*SS);
}
-
+
LookupResult Found;
bool ObjectTypeSearchedInScope = false;
if (LookupCtx) {
// Perform "qualified" name lookup into the declaration context we
// computed, which is either the type of the base of a member access
- // expression or the declaration context associated with a prior
+ // expression or the declaration context associated with a prior
// nested-name-specifier.
// The declaration context must be complete.
if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(*SS))
return TNK_Non_template;
-
+
Found = LookupQualifiedName(LookupCtx, &II, LookupOrdinaryName);
-
+
if (ObjectTypePtr && Found.getKind() == LookupResult::NotFound) {
// C++ [basic.lookup.classref]p1:
// In a class member access expression (5.2.5), if the . or -> token is
- // immediately followed by an identifier followed by a <, the
- // identifier must be looked up to determine whether the < is the
+ // immediately followed by an identifier followed by a <, the
+ // identifier must be looked up to determine whether the < is the
// beginning of a template argument list (14.2) or a less-than operator.
- // The identifier is first looked up in the class of the object
- // expression. If the identifier is not found, it is then looked up in
+ // The identifier is first looked up in the class of the object
+ // expression. If the identifier is not found, it is then looked up in
// the context of the entire postfix-expression and shall name a class
// or function template.
//
@@ -153,15 +153,15 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
ObjectTypeSearchedInScope = true;
}
} else if (isDependent) {
- // We cannot look into a dependent object type or
+ // We cannot look into a dependent object type or
return TNK_Non_template;
} else {
// Perform unqualified name lookup in the current scope.
Found = LookupName(S, &II, LookupOrdinaryName);
}
-
+
// FIXME: Cope with ambiguous name-lookup results.
- assert(!Found.isAmbiguous() &&
+ assert(!Found.isAmbiguous() &&
"Cannot handle template name-lookup ambiguities");
NamedDecl *Template = isAcceptableTemplateName(Context, Found);
@@ -170,24 +170,24 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
if (ObjectTypePtr && !ObjectTypeSearchedInScope) {
// C++ [basic.lookup.classref]p1:
- // [...] If the lookup in the class of the object expression finds a
+ // [...] If the lookup in the class of the object expression finds a
// template, the name is also looked up in the context of the entire
// postfix-expression and [...]
//
LookupResult FoundOuter = LookupName(S, &II, LookupOrdinaryName);
// FIXME: Handle ambiguities in this lookup better
NamedDecl *OuterTemplate = isAcceptableTemplateName(Context, FoundOuter);
-
+
if (!OuterTemplate) {
- // - if the name is not found, the name found in the class of the
+ // - if the name is not found, the name found in the class of the
// object expression is used, otherwise
} else if (!isa<ClassTemplateDecl>(OuterTemplate)) {
- // - if the name is found in the context of the entire
- // postfix-expression and does not name a class template, the name
+ // - if the name is found in the context of the entire
+ // postfix-expression and does not name a class template, the name
// found in the class of the object expression is used, otherwise
} else {
// - if the name found is a class template, it must refer to the same
- // entity as the one found in the class of the object expression,
+ // entity as the one found in the class of the object expression,
// otherwise the program is ill-formed.
if (OuterTemplate->getCanonicalDecl() != Template->getCanonicalDecl()) {
Diag(IdLoc, diag::err_nested_name_member_ref_lookup_ambiguous)
@@ -195,38 +195,38 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
Diag(Template->getLocation(), diag::note_ambig_member_ref_object_type)
<< QualType::getFromOpaquePtr(ObjectTypePtr);
Diag(OuterTemplate->getLocation(), diag::note_ambig_member_ref_scope);
-
- // Recover by taking the template that we found in the object
+
+ // Recover by taking the template that we found in the object
// expression's type.
}
- }
+ }
}
-
+
if (SS && SS->isSet() && !SS->isInvalid()) {
- NestedNameSpecifier *Qualifier
+ NestedNameSpecifier *Qualifier
= static_cast<NestedNameSpecifier *>(SS->getScopeRep());
- if (OverloadedFunctionDecl *Ovl
+ if (OverloadedFunctionDecl *Ovl
= dyn_cast<OverloadedFunctionDecl>(Template))
- TemplateResult
+ TemplateResult
= TemplateTy::make(Context.getQualifiedTemplateName(Qualifier, false,
Ovl));
else
- TemplateResult
+ TemplateResult
= TemplateTy::make(Context.getQualifiedTemplateName(Qualifier, false,
- cast<TemplateDecl>(Template)));
- } else if (OverloadedFunctionDecl *Ovl
+ cast<TemplateDecl>(Template)));
+ } else if (OverloadedFunctionDecl *Ovl
= dyn_cast<OverloadedFunctionDecl>(Template)) {
TemplateResult = TemplateTy::make(TemplateName(Ovl));
} else {
TemplateResult = TemplateTy::make(
TemplateName(cast<TemplateDecl>(Template)));
}
-
- if (isa<ClassTemplateDecl>(Template) ||
+
+ if (isa<ClassTemplateDecl>(Template) ||
isa<TemplateTemplateParmDecl>(Template))
return TNK_Type_template;
-
- assert((isa<FunctionTemplateDecl>(Template) ||
+
+ assert((isa<FunctionTemplateDecl>(Template) ||
isa<OverloadedFunctionDecl>(Template)) &&
"Unhandled template kind in Sema::isTemplateName");
return TNK_Function_template;
@@ -246,7 +246,7 @@ bool Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
// C++ [temp.local]p4:
// A template-parameter shall not be redeclared within its
// scope (including nested scopes).
- Diag(Loc, diag::err_template_param_shadow)
+ Diag(Loc, diag::err_template_param_shadow)
<< cast<NamedDecl>(PrevDecl)->getDeclName();
Diag(PrevDecl->getLocation(), diag::note_template_param_here);
return true;
@@ -269,24 +269,24 @@ TemplateDecl *Sema::AdjustDeclIfTemplate(DeclPtrTy &D) {
/// (otherwise, "class" was used), and KeyLoc is the location of the
/// "class" or "typename" keyword. ParamName is the name of the
/// parameter (NULL indicates an unnamed template parameter) and
-/// ParamName is the location of the parameter name (if any).
+/// ParamName is the location of the parameter name (if any).
/// If the type parameter has a default argument, it will be added
/// later via ActOnTypeParameterDefault.
-Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
+Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
SourceLocation EllipsisLoc,
SourceLocation KeyLoc,
IdentifierInfo *ParamName,
SourceLocation ParamNameLoc,
unsigned Depth, unsigned Position) {
- assert(S->isTemplateParamScope() &&
- "Template type parameter not in template parameter scope!");
+ assert(S->isTemplateParamScope() &&
+ "Template type parameter not in template parameter scope!");
bool Invalid = false;
if (ParamName) {
NamedDecl *PrevDecl = LookupName(S, ParamName, LookupTagName);
if (PrevDecl && PrevDecl->isTemplateParameter())
Invalid = Invalid || DiagnoseTemplateParameterShadow(ParamNameLoc,
- PrevDecl);
+ PrevDecl);
}
SourceLocation Loc = ParamNameLoc;
@@ -294,8 +294,8 @@ Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
Loc = KeyLoc;
TemplateTypeParmDecl *Param
- = TemplateTypeParmDecl::Create(Context, CurContext, Loc,
- Depth, Position, ParamName, Typename,
+ = TemplateTypeParmDecl::Create(Context, CurContext, Loc,
+ Depth, Position, ParamName, Typename,
Ellipsis);
if (Invalid)
Param->setInvalidDecl();
@@ -310,28 +310,28 @@ Sema::DeclPtrTy Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
}
/// ActOnTypeParameterDefault - Adds a default argument (the type
-/// Default) to the given template type parameter (TypeParam).
-void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam,
+/// Default) to the given template type parameter (TypeParam).
+void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam,
SourceLocation EqualLoc,
- SourceLocation DefaultLoc,
+ SourceLocation DefaultLoc,
TypeTy *DefaultT) {
- TemplateTypeParmDecl *Parm
+ TemplateTypeParmDecl *Parm
= cast<TemplateTypeParmDecl>(TypeParam.getAs<Decl>());
// FIXME: Preserve type source info.
QualType Default = GetTypeFromParser(DefaultT);
// C++0x [temp.param]p9:
// A default template-argument may be specified for any kind of
- // template-parameter that is not a template parameter pack.
+ // template-parameter that is not a template parameter pack.
if (Parm->isParameterPack()) {
Diag(DefaultLoc, diag::err_template_param_pack_default_arg);
return;
}
-
+
// C++ [temp.param]p14:
// A template-parameter shall not be used in its own default argument.
// FIXME: Implement this check! Needs a recursive walk over the types.
-
+
// Check the template argument itself.
if (CheckTemplateArgument(Parm, Default, DefaultLoc)) {
Parm->setInvalidDecl();
@@ -346,7 +346,7 @@ void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam,
///
/// \returns the (possibly-promoted) parameter type if valid;
/// otherwise, produces a diagnostic and returns a NULL type.
-QualType
+QualType
Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
// C++ [temp.param]p4:
//
@@ -355,11 +355,11 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
//
// -- integral or enumeration type,
if (T->isIntegralType() || T->isEnumeralType() ||
- // -- pointer to object or pointer to function,
- (T->isPointerType() &&
+ // -- pointer to object or pointer to function,
+ (T->isPointerType() &&
(T->getAs<PointerType>()->getPointeeType()->isObjectType() ||
T->getAs<PointerType>()->getPointeeType()->isFunctionType())) ||
- // -- reference to object or reference to function,
+ // -- reference to object or reference to function,
T->isReferenceType() ||
// -- pointer to member.
T->isMemberPointerType() ||
@@ -390,7 +390,7 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) {
/// class Array") has been parsed. S is the current scope and D is
/// the parsed declarator.
Sema::DeclPtrTy Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
- unsigned Depth,
+ unsigned Depth,
unsigned Position) {
DeclaratorInfo *DInfo = 0;
QualType T = GetTypeForDeclarator(D, S, &DInfo);
@@ -432,14 +432,14 @@ Sema::DeclPtrTy Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
void Sema::ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParamD,
SourceLocation EqualLoc,
ExprArg DefaultE) {
- NonTypeTemplateParmDecl *TemplateParm
+ NonTypeTemplateParmDecl *TemplateParm
= cast<NonTypeTemplateParmDecl>(TemplateParamD.getAs<Decl>());
Expr *Default = static_cast<Expr *>(DefaultE.get());
-
+
// C++ [temp.param]p14:
// A template-parameter shall not be used in its own default argument.
// FIXME: Implement this check! Needs a recursive walk over the types.
-
+
// Check the well-formedness of the default template argument.
TemplateArgument Converted;
if (CheckTemplateArgument(TemplateParm, TemplateParm->getType(), Default,
@@ -461,8 +461,7 @@ Sema::DeclPtrTy Sema::ActOnTemplateTemplateParameter(Scope* S,
IdentifierInfo *Name,
SourceLocation NameLoc,
unsigned Depth,
- unsigned Position)
-{
+ unsigned Position) {
assert(S->isTemplateParamScope() &&
"Template template parameter not in template parameter scope!");
@@ -496,12 +495,12 @@ Sema::DeclPtrTy Sema::ActOnTemplateTemplateParameter(Scope* S,
void Sema::ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParamD,
SourceLocation EqualLoc,
ExprArg DefaultE) {
- TemplateTemplateParmDecl *TemplateParm
+ TemplateTemplateParmDecl *TemplateParm
= cast<TemplateTemplateParmDecl>(TemplateParamD.getAs<Decl>());
// Since a template-template parameter's default argument is an
// id-expression, it must be a DeclRefExpr.
- DeclRefExpr *Default
+ DeclRefExpr *Default
= cast<DeclRefExpr>(static_cast<Expr *>(DefaultE.get()));
// C++ [temp.param]p14:
@@ -510,12 +509,12 @@ void Sema::ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParamD,
// Check the well-formedness of the template argument.
if (!isa<TemplateDecl>(Default->getDecl())) {
- Diag(Default->getSourceRange().getBegin(),
+ Diag(Default->getSourceRange().getBegin(),
diag::err_template_arg_must_be_template)
<< Default->getSourceRange();
TemplateParm->setInvalidDecl();
return;
- }
+ }
if (CheckTemplateArgument(TemplateParm, Default)) {
TemplateParm->setInvalidDecl();
return;
@@ -530,7 +529,7 @@ void Sema::ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParamD,
Sema::TemplateParamsTy *
Sema::ActOnTemplateParameterList(unsigned Depth,
SourceLocation ExportLoc,
- SourceLocation TemplateLoc,
+ SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
DeclPtrTy *Params, unsigned NumParams,
SourceLocation RAngleLoc) {
@@ -548,7 +547,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
AttributeList *Attr,
TemplateParameterList *TemplateParams,
AccessSpecifier AS) {
- assert(TemplateParams && TemplateParams->size() > 0 &&
+ assert(TemplateParams && TemplateParams->size() > 0 &&
"No template parameters");
assert(TUK != TUK_Reference && "Can only declare or define class templates");
bool Invalid = false;
@@ -580,14 +579,14 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
// FIXME: Produce a reasonable diagnostic here
return true;
}
-
- Previous = LookupQualifiedName(SemanticContext, Name, LookupOrdinaryName,
+
+ Previous = LookupQualifiedName(SemanticContext, Name, LookupOrdinaryName,
true);
} else {
SemanticContext = CurContext;
Previous = LookupName(S, Name, LookupOrdinaryName, true);
}
-
+
assert(!Previous.isAmbiguous() && "Ambiguity in class template redecl?");
NamedDecl *PrevDecl = 0;
if (Previous.begin() != Previous.end())
@@ -595,10 +594,10 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
if (PrevDecl && !isDeclInScope(PrevDecl, SemanticContext, S))
PrevDecl = 0;
-
+
// If there is a previous declaration with the same name, check
// whether this is a valid redeclaration.
- ClassTemplateDecl *PrevClassTemplate
+ ClassTemplateDecl *PrevClassTemplate
= dyn_cast_or_null<ClassTemplateDecl>(PrevDecl);
if (PrevClassTemplate) {
// Ensure that the template parameter lists are compatible.
@@ -614,9 +613,9 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
// template declaration (7.1.5.3).
RecordDecl *PrevRecordDecl = PrevClassTemplate->getTemplatedDecl();
if (!isAcceptableTagRedeclaration(PrevRecordDecl, Kind, KWLoc, *Name)) {
- Diag(KWLoc, diag::err_use_with_wrong_tag)
+ Diag(KWLoc, diag::err_use_with_wrong_tag)
<< Name
- << CodeModificationHint::CreateReplacement(KWLoc,
+ << CodeModificationHint::CreateReplacement(KWLoc,
PrevRecordDecl->getKindName());
Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
Kind = PrevRecordDecl->getTagKind();
@@ -654,13 +653,13 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
if (CheckTemplateParameterList(TemplateParams,
PrevClassTemplate? PrevClassTemplate->getTemplateParameters() : 0))
Invalid = true;
-
+
// FIXME: If we had a scope specifier, we better have a previous template
// declaration!
- CXXRecordDecl *NewClass =
+ CXXRecordDecl *NewClass =
CXXRecordDecl::Create(Context, Kind, SemanticContext, NameLoc, Name, KWLoc,
- PrevClassTemplate?
+ PrevClassTemplate?
PrevClassTemplate->getTemplatedDecl() : 0,
/*DelayTypeCreation=*/true);
@@ -671,16 +670,16 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
NewClass->setDescribedClassTemplate(NewTemplate);
// Build the type for the class template declaration now.
- QualType T =
- Context.getTypeDeclType(NewClass,
- PrevClassTemplate?
- PrevClassTemplate->getTemplatedDecl() : 0);
+ QualType T =
+ Context.getTypeDeclType(NewClass,
+ PrevClassTemplate?
+ PrevClassTemplate->getTemplatedDecl() : 0);
assert(T->isDependentType() && "Class template type is not dependent?");
(void)T;
// Set the access specifier.
SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);
-
+
// Set the lexical context of these templates
NewClass->setLexicalDeclContext(CurContext);
NewTemplate->setLexicalDeclContext(CurContext);
@@ -722,7 +721,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
TemplateParameterList *OldParams) {
bool Invalid = false;
-
+
// C++ [temp.param]p10:
// The set of default template-arguments available for use with a
// template declaration or definition is obtained by merging the
@@ -755,7 +754,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
// If a template parameter of a class template is a template parameter pack,
// it must be the last template parameter.
if (SawParameterPack) {
- Diag(ParameterPackLoc,
+ Diag(ParameterPackLoc,
diag::err_template_param_pack_must_be_last_template_parameter);
Invalid = true;
}
@@ -763,15 +762,15 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
// Merge default arguments for template type parameters.
if (TemplateTypeParmDecl *NewTypeParm
= dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
- TemplateTypeParmDecl *OldTypeParm
+ TemplateTypeParmDecl *OldTypeParm
= OldParams? cast<TemplateTypeParmDecl>(*OldParam) : 0;
-
+
if (NewTypeParm->isParameterPack()) {
assert(!NewTypeParm->hasDefaultArgument() &&
"Parameter packs can't have a default argument!");
SawParameterPack = true;
ParameterPackLoc = NewTypeParm->getLocation();
- } else if (OldTypeParm && OldTypeParm->hasDefaultArgument() &&
+ } else if (OldTypeParm && OldTypeParm->hasDefaultArgument() &&
NewTypeParm->hasDefaultArgument()) {
OldDefaultLoc = OldTypeParm->getDefaultArgumentLoc();
NewDefaultLoc = NewTypeParm->getDefaultArgumentLoc();
@@ -796,7 +795,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
// Merge default arguments for non-type template parameters
NonTypeTemplateParmDecl *OldNonTypeParm
= OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) : 0;
- if (OldNonTypeParm && OldNonTypeParm->hasDefaultArgument() &&
+ if (OldNonTypeParm && OldNonTypeParm->hasDefaultArgument() &&
NewNonTypeParm->hasDefaultArgument()) {
OldDefaultLoc = OldNonTypeParm->getDefaultArgumentLoc();
NewDefaultLoc = NewNonTypeParm->getDefaultArgumentLoc();
@@ -817,14 +816,14 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
SawDefaultArgument = true;
PreviousDefaultArgLoc = NewNonTypeParm->getDefaultArgumentLoc();
} else if (SawDefaultArgument)
- MissingDefaultArg = true;
+ MissingDefaultArg = true;
} else {
// Merge default arguments for template template parameters
TemplateTemplateParmDecl *NewTemplateParm
= cast<TemplateTemplateParmDecl>(*NewParam);
TemplateTemplateParmDecl *OldTemplateParm
= OldParams? cast<TemplateTemplateParmDecl>(*OldParam) : 0;
- if (OldTemplateParm && OldTemplateParm->hasDefaultArgument() &&
+ if (OldTemplateParm && OldTemplateParm->hasDefaultArgument() &&
NewTemplateParm->hasDefaultArgument()) {
OldDefaultLoc = OldTemplateParm->getDefaultArgumentLoc();
NewDefaultLoc = NewTemplateParm->getDefaultArgumentLoc();
@@ -844,7 +843,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
SawDefaultArgument = true;
PreviousDefaultArgLoc = NewTemplateParm->getDefaultArgumentLoc();
} else if (SawDefaultArgument)
- MissingDefaultArg = true;
+ MissingDefaultArg = true;
}
if (RedundantDefaultArg) {
@@ -859,7 +858,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
// If a template-parameter has a default template-argument,
// all subsequent template-parameters shall have a default
// template-argument supplied.
- Diag((*NewParam)->getLocation(),
+ Diag((*NewParam)->getLocation(),
diag::err_template_param_default_arg_missing);
Diag(PreviousDefaultArgLoc, diag::note_template_param_prev_default_arg);
Invalid = true;
@@ -874,13 +873,13 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
return Invalid;
}
-/// \brief Match the given template parameter lists to the given scope
+/// \brief Match the given template parameter lists to the given scope
/// specifier, returning the template parameter list that applies to the
/// name.
///
/// \param DeclStartLoc the start of the declaration that has a scope
/// specifier or a template parameter list.
-///
+///
/// \param SS the scope specifier that will be matched to the given template
/// parameter lists. This scope specifier precedes a qualified name that is
/// being declared.
@@ -890,10 +889,10 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
///
/// \param NumParamLists the number of template parameter lists in ParamLists.
///
-/// \returns the template parameter list, if any, that corresponds to the
+/// \returns the template parameter list, if any, that corresponds to the
/// name that is preceded by the scope specifier @p SS. This template
/// parameter list may be have template parameters (if we're declaring a
-/// template) or may have no template parameters (if we're declaring a
+/// template) or may have no template parameters (if we're declaring a
/// template specialization), or may be NULL (if we were's declaring isn't
/// itself a template).
TemplateParameterList *
@@ -907,35 +906,35 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
TemplateIdsInSpecifier;
for (NestedNameSpecifier *NNS = (NestedNameSpecifier *)SS.getScopeRep();
NNS; NNS = NNS->getPrefix()) {
- if (const TemplateSpecializationType *SpecType
+ if (const TemplateSpecializationType *SpecType
= dyn_cast_or_null<TemplateSpecializationType>(NNS->getAsType())) {
TemplateDecl *Template = SpecType->getTemplateName().getAsTemplateDecl();
if (!Template)
continue; // FIXME: should this be an error? probably...
-
+
if (const RecordType *Record = SpecType->getAs<RecordType>()) {
ClassTemplateSpecializationDecl *SpecDecl
= cast<ClassTemplateSpecializationDecl>(Record->getDecl());
// If the nested name specifier refers to an explicit specialization,
// we don't need a template<> header.
- // FIXME: revisit this approach once we cope with specialization
+ // FIXME: revisit this approach once we cope with specialization
// properly.
if (SpecDecl->getSpecializationKind() == TSK_ExplicitSpecialization)
continue;
}
-
+
TemplateIdsInSpecifier.push_back(SpecType);
}
}
-
+
// Reverse the list of template-ids in the scope specifier, so that we can
// more easily match up the template-ids and the template parameter lists.
std::reverse(TemplateIdsInSpecifier.begin(), TemplateIdsInSpecifier.end());
-
+
SourceLocation FirstTemplateLoc = DeclStartLoc;
if (NumParamLists)
FirstTemplateLoc = ParamLists[0]->getTemplateLoc();
-
+
// Match the template-ids found in the specifier to the template parameter
// lists.
unsigned Idx = 0;
@@ -947,8 +946,8 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
// We have a template-id without a corresponding template parameter
// list.
if (DependentTemplateId) {
- // FIXME: the location information here isn't great.
- Diag(SS.getRange().getBegin(),
+ // FIXME: the location information here isn't great.
+ Diag(SS.getRange().getBegin(),
diag::err_template_spec_needs_template_parameters)
<< TemplateId
<< SS.getRange();
@@ -960,13 +959,13 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
}
return 0;
}
-
+
// Check the template parameter list against its corresponding template-id.
if (DependentTemplateId) {
- TemplateDecl *Template
+ TemplateDecl *Template
= TemplateIdsInSpecifier[Idx]->getTemplateName().getAsTemplateDecl();
- if (ClassTemplateDecl *ClassTemplate
+ if (ClassTemplateDecl *ClassTemplate
= dyn_cast<ClassTemplateDecl>(Template)) {
TemplateParameterList *ExpectedTemplateParams = 0;
// Is this template-id naming the primary template?
@@ -979,34 +978,34 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
ExpectedTemplateParams = PartialSpec->getTemplateParameters();
if (ExpectedTemplateParams)
- TemplateParameterListsAreEqual(ParamLists[Idx],
+ TemplateParameterListsAreEqual(ParamLists[Idx],
ExpectedTemplateParams,
true);
- }
+ }
} else if (ParamLists[Idx]->size() > 0)
- Diag(ParamLists[Idx]->getTemplateLoc(),
+ Diag(ParamLists[Idx]->getTemplateLoc(),
diag::err_template_param_list_matches_nontemplate)
<< TemplateId
<< ParamLists[Idx]->getSourceRange();
}
-
+
// If there were at least as many template-ids as there were template
// parameter lists, then there are no template parameter lists remaining for
// the declaration itself.
if (Idx >= NumParamLists)
return 0;
-
+
// If there were too many template parameter lists, complain about that now.
if (Idx != NumParamLists - 1) {
while (Idx < NumParamLists - 1) {
- Diag(ParamLists[Idx]->getTemplateLoc(),
+ Diag(ParamLists[Idx]->getTemplateLoc(),
diag::err_template_spec_extra_headers)
<< SourceRange(ParamLists[Idx]->getTemplateLoc(),
ParamLists[Idx]->getRAngleLoc());
++Idx;
}
}
-
+
// Return the last template parameter list, which corresponds to the
// entity being declared.
return ParamLists[NumParamLists - 1];
@@ -1014,8 +1013,8 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
/// \brief Translates template arguments as provided by the parser
/// into template arguments used by semantic analysis.
-static void
-translateTemplateArguments(ASTTemplateArgsPtr &TemplateArgsIn,
+static void
+translateTemplateArguments(ASTTemplateArgsPtr &TemplateArgsIn,
SourceLocation *TemplateArgLocs,
llvm::SmallVector<TemplateArgument, 16> &TemplateArgs) {
TemplateArgs.reserve(TemplateArgsIn.size());
@@ -1049,12 +1048,12 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
// template.
TemplateArgumentListBuilder Converted(Template->getTemplateParameters(),
NumTemplateArgs);
- if (CheckTemplateArgumentList(Template, TemplateLoc, LAngleLoc,
+ if (CheckTemplateArgumentList(Template, TemplateLoc, LAngleLoc,
TemplateArgs, NumTemplateArgs, RAngleLoc,
false, Converted))
return QualType();
- assert((Converted.structuredSize() ==
+ assert((Converted.structuredSize() ==
Template->getTemplateParameters()->size()) &&
"Converted template argument list is too short!");
@@ -1071,21 +1070,21 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
//
// template<typename T, typename U = T> struct A;
TemplateName CanonName = Context.getCanonicalTemplateName(Name);
- CanonType = Context.getTemplateSpecializationType(CanonName,
+ CanonType = Context.getTemplateSpecializationType(CanonName,
Converted.getFlatArguments(),
Converted.flatSize());
-
+
// FIXME: CanonType is not actually the canonical type, and unfortunately
// it is a TemplateTypeSpecializationType that we will never use again.
// In the future, we need to teach getTemplateSpecializationType to only
// build the canonical type and return that to us.
CanonType = Context.getCanonicalType(CanonType);
- } else if (ClassTemplateDecl *ClassTemplate
+ } else if (ClassTemplateDecl *ClassTemplate
= dyn_cast<ClassTemplateDecl>(Template)) {
// Find the class template specialization declaration that
// corresponds to these arguments.
llvm::FoldingSetNodeID ID;
- ClassTemplateSpecializationDecl::Profile(ID,
+ ClassTemplateSpecializationDecl::Profile(ID,
Converted.getFlatArguments(),
Converted.flatSize(),
Context);
@@ -1096,7 +1095,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
// This is the first time we have referenced this class template
// specialization. Create the canonical declaration and add it to
// the set of specializations.
- Decl = ClassTemplateSpecializationDecl::Create(Context,
+ Decl = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getDeclContext(),
TemplateLoc,
ClassTemplate,
@@ -1107,7 +1106,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
CanonType = Context.getTypeDeclType(Decl);
}
-
+
// Build the fully-sugared type for this class template
// specialization, which refers back to the class template
// specialization we created or found.
@@ -1118,7 +1117,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
Action::TypeResult
Sema::ActOnTemplateIdType(TemplateTy TemplateD, SourceLocation TemplateLoc,
- SourceLocation LAngleLoc,
+ SourceLocation LAngleLoc,
ASTTemplateArgsPtr TemplateArgsIn,
SourceLocation *TemplateArgLocs,
SourceLocation RAngleLoc) {
@@ -1151,7 +1150,7 @@ Sema::TypeResult Sema::ActOnTagTemplateIdType(TypeResult TypeResult,
// Verify the tag specifier.
TagDecl::TagKind TagKind = TagDecl::getTagKindForTypeSpec(TagSpec);
-
+
if (const RecordType *RT = Type->getAs<RecordType>()) {
RecordDecl *D = RT->getDecl();
@@ -1179,14 +1178,14 @@ Sema::OwningExprResult Sema::BuildTemplateIdExpr(TemplateName Template,
SourceLocation RAngleLoc) {
// FIXME: Can we do any checking at this point? I guess we could check the
// template arguments that we have against the template name, if the template
- // name refers to a single template. That's not a terribly common case,
+ // name refers to a single template. That's not a terribly common case,
// though.
- return Owned(TemplateIdRefExpr::Create(Context,
+ return Owned(TemplateIdRefExpr::Create(Context,
/*FIXME: New type?*/Context.OverloadTy,
/*FIXME: Necessary?*/0,
/*FIXME: Necessary?*/SourceRange(),
Template, TemplateNameLoc, LAngleLoc,
- TemplateArgs,
+ TemplateArgs,
NumTemplateArgs, RAngleLoc));
}
@@ -1197,12 +1196,12 @@ Sema::OwningExprResult Sema::ActOnTemplateIdExpr(TemplateTy TemplateD,
SourceLocation *TemplateArgLocs,
SourceLocation RAngleLoc) {
TemplateName Template = TemplateD.getAsVal<TemplateName>();
-
+
// Translate the parser's template argument list in our AST format.
llvm::SmallVector<TemplateArgument, 16> TemplateArgs;
translateTemplateArguments(TemplateArgsIn, TemplateArgLocs, TemplateArgs);
TemplateArgsIn.release();
-
+
return BuildTemplateIdExpr(Template, TemplateNameLoc, LAngleLoc,
TemplateArgs.data(), TemplateArgs.size(),
RAngleLoc);
@@ -1220,7 +1219,7 @@ Sema::ActOnMemberTemplateIdReferenceExpr(Scope *S, ExprArg Base,
SourceLocation *TemplateArgLocs,
SourceLocation RAngleLoc) {
TemplateName Template = TemplateD.getAsVal<TemplateName>();
-
+
// FIXME: We're going to end up looking up the template based on its name,
// twice!
DeclarationName Name;
@@ -1230,17 +1229,17 @@ Sema::ActOnMemberTemplateIdReferenceExpr(Scope *S, ExprArg Base,
Name = Ovl->getDeclName();
else
Name = Template.getAsDependentTemplateName()->getName();
-
+
// Translate the parser's template argument list in our AST format.
llvm::SmallVector<TemplateArgument, 16> TemplateArgs;
translateTemplateArguments(TemplateArgsIn, TemplateArgLocs, TemplateArgs);
TemplateArgsIn.release();
-
+
// Do we have the save the actual template name? We might need it...
return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, TemplateNameLoc,
Name, true, LAngleLoc,
TemplateArgs.data(), TemplateArgs.size(),
- RAngleLoc, DeclPtrTy(), &SS);
+ RAngleLoc, DeclPtrTy(), &SS);
}
/// \brief Form a dependent template name.
@@ -1250,13 +1249,13 @@ Sema::ActOnMemberTemplateIdReferenceExpr(Scope *S, ExprArg Base,
/// example, given "MetaFun::template apply", the scope specifier \p
/// SS will be "MetaFun::", \p TemplateKWLoc contains the location
/// of the "template" keyword, and "apply" is the \p Name.
-Sema::TemplateTy
+Sema::TemplateTy
Sema::ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
const IdentifierInfo &Name,
SourceLocation NameLoc,
const CXXScopeSpec &SS,
TypeTy *ObjectType) {
- if ((ObjectType &&
+ if ((ObjectType &&
computeDeclContext(QualType::getFromOpaquePtr(ObjectType))) ||
(SS.isSet() && computeDeclContext(SS, false))) {
// C++0x [temp.names]p5:
@@ -1276,7 +1275,7 @@ Sema::ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
// "template" keyword is now permitted). We follow the C++0x
// rules, even in C++03 mode, retroactively applying the DR.
TemplateTy Template;
- TemplateNameKind TNK = isTemplateName(0, Name, NameLoc, &SS, ObjectType,
+ TemplateNameKind TNK = isTemplateName(0, Name, NameLoc, &SS, ObjectType,
false, Template);
if (TNK == TNK_Non_template) {
Diag(NameLoc, diag::err_template_kw_refers_to_non_template)
@@ -1287,12 +1286,12 @@ Sema::ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
return Template;
}
- NestedNameSpecifier *Qualifier
+ NestedNameSpecifier *Qualifier
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return TemplateTy::make(Context.getDependentTemplateName(Qualifier, &Name));
}
-bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
+bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
const TemplateArgument &Arg,
TemplateArgumentListBuilder &Converted) {
// Check template type parameter.
@@ -1305,13 +1304,13 @@ bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
// is not a type.
Diag(Arg.getLocation(), diag::err_template_arg_must_be_type);
Diag(Param->getLocation(), diag::note_template_param_here);
-
+
return true;
- }
+ }
if (CheckTemplateArgument(Param, Arg.getAsType(), Arg.getLocation()))
return true;
-
+
// Add the converted template type argument.
Converted.Append(
TemplateArgument(Arg.getLocation(),
@@ -1334,9 +1333,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
unsigned NumArgs = NumTemplateArgs;
bool Invalid = false;
- bool HasParameterPack =
+ bool HasParameterPack =
NumParams > 0 && Params->getParam(NumParams - 1)->isTemplateParameterPack();
-
+
if ((NumArgs > NumParams && !HasParameterPack) ||
(NumArgs < Params->getMinRequiredArguments() &&
!PartialTemplateArgs)) {
@@ -1356,8 +1355,8 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
<< Params->getSourceRange();
Invalid = true;
}
-
- // C++ [temp.arg]p1:
+
+ // C++ [temp.arg]p1:
// [...] The type and form of each template-argument specified in
// a template-id shall match the type and form specified for the
// corresponding parameter declared by the template in its
@@ -1368,7 +1367,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
Param != ParamEnd; ++Param, ++ArgIdx) {
if (ArgIdx > NumArgs && PartialTemplateArgs)
break;
-
+
// Decode the template argument
TemplateArgument Arg;
if (ArgIdx >= NumArgs) {
@@ -1381,7 +1380,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
Converted.EndPack();
break;
}
-
+
if (!TTP->hasDefaultArgument())
break;
@@ -1390,14 +1389,14 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
// If the argument type is dependent, instantiate it now based
// on the previously-computed template arguments.
if (ArgType->isDependentType()) {
- InstantiatingTemplate Inst(*this, TemplateLoc,
+ InstantiatingTemplate Inst(*this, TemplateLoc,
Template, Converted.getFlatArguments(),
Converted.flatSize(),
SourceRange(TemplateLoc, RAngleLoc));
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
- ArgType = SubstType(ArgType,
+ ArgType = SubstType(ArgType,
MultiLevelTemplateArgumentList(TemplateArgs),
TTP->getDefaultArgumentLoc(),
TTP->getDeclName());
@@ -1407,29 +1406,29 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
return true;
Arg = TemplateArgument(TTP->getLocation(), ArgType);
- } else if (NonTypeTemplateParmDecl *NTTP
+ } else if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
if (!NTTP->hasDefaultArgument())
break;
- InstantiatingTemplate Inst(*this, TemplateLoc,
+ InstantiatingTemplate Inst(*this, TemplateLoc,
Template, Converted.getFlatArguments(),
Converted.flatSize(),
SourceRange(TemplateLoc, RAngleLoc));
-
+
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
- Sema::OwningExprResult E
- = SubstExpr(NTTP->getDefaultArgument(),
+ Sema::OwningExprResult E
+ = SubstExpr(NTTP->getDefaultArgument(),
MultiLevelTemplateArgumentList(TemplateArgs));
if (E.isInvalid())
return true;
-
+
Arg = TemplateArgument(E.takeAs<Expr>());
} else {
- TemplateTemplateParmDecl *TempParm
- = cast<TemplateTemplateParmDecl>(*Param);
+ TemplateTemplateParmDecl *TempParm
+ = cast<TemplateTemplateParmDecl>(*Param);
if (!TempParm->hasDefaultArgument())
break;
@@ -1451,13 +1450,13 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
if (CheckTemplateTypeArgument(TTP, TemplateArgs[ArgIdx], Converted))
Invalid = true;
}
-
+
Converted.EndPack();
} else {
if (CheckTemplateTypeArgument(TTP, Arg, Converted))
Invalid = true;
}
- } else if (NonTypeTemplateParmDecl *NTTP
+ } else if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
// Check non-type template parameters.
@@ -1466,21 +1465,21 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
QualType NTTPType = NTTP->getType();
if (NTTPType->isDependentType()) {
// Do substitution on the type of the non-type template parameter.
- InstantiatingTemplate Inst(*this, TemplateLoc,
+ InstantiatingTemplate Inst(*this, TemplateLoc,
Template, Converted.getFlatArguments(),
Converted.flatSize(),
SourceRange(TemplateLoc, RAngleLoc));
TemplateArgumentList TemplateArgs(Context, Converted,
/*TakeArgs=*/false);
- NTTPType = SubstType(NTTPType,
+ NTTPType = SubstType(NTTPType,
MultiLevelTemplateArgumentList(TemplateArgs),
NTTP->getLocation(),
NTTP->getDeclName());
// If that worked, check the non-type template parameter type
// for validity.
if (!NTTPType.isNull())
- NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
+ NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
NTTP->getLocation());
if (NTTPType.isNull()) {
Invalid = true;
@@ -1492,7 +1491,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
case TemplateArgument::Null:
assert(false && "Should never see a NULL template argument here");
break;
-
+
case TemplateArgument::Expression: {
Expr *E = Arg.getAsExpr();
TemplateArgument Result;
@@ -1513,7 +1512,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
case TemplateArgument::Type:
// We have a non-type template parameter but the template
// argument is a type.
-
+
// C++ [temp.arg]p2:
// In a template-argument, an ambiguity between a type-id and
// an expression is resolved to a type-id, regardless of the
@@ -1529,37 +1528,37 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
Diag((*Param)->getLocation(), diag::note_template_param_here);
Invalid = true;
break;
-
+
case TemplateArgument::Pack:
assert(0 && "FIXME: Implement!");
break;
}
- } else {
+ } else {
// Check template template parameters.
- TemplateTemplateParmDecl *TempParm
+ TemplateTemplateParmDecl *TempParm
= cast<TemplateTemplateParmDecl>(*Param);
-
+
switch (Arg.getKind()) {
case TemplateArgument::Null:
assert(false && "Should never see a NULL template argument here");
break;
-
+
case TemplateArgument::Expression: {
Expr *ArgExpr = Arg.getAsExpr();
if (ArgExpr && isa<DeclRefExpr>(ArgExpr) &&
isa<TemplateDecl>(cast<DeclRefExpr>(ArgExpr)->getDecl())) {
if (CheckTemplateArgument(TempParm, cast<DeclRefExpr>(ArgExpr)))
Invalid = true;
-
+
// Add the converted template argument.
- Decl *D
+ Decl *D
= cast<DeclRefExpr>(ArgExpr)->getDecl()->getCanonicalDecl();
Converted.Append(TemplateArgument(Arg.getLocation(), D));
continue;
}
}
// fall through
-
+
case TemplateArgument::Type: {
// We have a template template parameter but the template
// argument does not refer to a template.
@@ -1573,11 +1572,11 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
// it to the list of converted arguments.
Converted.Append(Arg);
break;
-
+
case TemplateArgument::Integral:
assert(false && "Integral argument with template template parameter");
break;
-
+
case TemplateArgument::Pack:
assert(0 && "FIXME: Implement!");
break;
@@ -1593,7 +1592,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template,
///
/// This routine implements the semantics of C++ [temp.arg.type]. It
/// returns true if an error occurred, and false otherwise.
-bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
+bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
QualType Arg, SourceLocation ArgLoc) {
// C++ [temp.arg.type]p2:
// A local type, a type with no linkage, an unnamed type or a type
@@ -1609,7 +1608,7 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param,
if (Tag && Tag->getDecl()->getDeclContext()->isFunctionOrMethod())
return Diag(ArgLoc, diag::err_template_arg_local_type)
<< QualType(Tag, 0);
- else if (Tag && !Tag->getDecl()->getDeclName() &&
+ else if (Tag && !Tag->getDecl()->getDeclName() &&
!Tag->getDecl()->getTypedefForAnonDecl()) {
Diag(ArgLoc, diag::err_template_arg_unnamed_type);
Diag(Tag->getDecl()->getLocation(), diag::note_template_unnamed_type_here);
@@ -1634,7 +1633,7 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
return false;
// C++ [temp.arg.nontype]p1:
- //
+ //
// A template-argument for a non-type, non-template
// template-parameter shall be one of: [...]
//
@@ -1645,11 +1644,11 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
// the name refers to a function or array, or if the
// corresponding template-parameter is a reference; or
DeclRefExpr *DRE = 0;
-
+
// Ignore (and complain about) any excess parentheses.
while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
if (!Invalid) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_extra_parens)
<< Arg->getSourceRange();
Invalid = true;
@@ -1665,7 +1664,7 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
DRE = dyn_cast<DeclRefExpr>(Arg);
if (!DRE || !isa<ValueDecl>(DRE->getDecl()))
- return Diag(Arg->getSourceRange().getBegin(),
+ return Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_object_or_func_form)
<< Arg->getSourceRange();
@@ -1677,14 +1676,14 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
// Cannot refer to non-static member functions
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(DRE->getDecl()))
if (!Method->isStatic())
- return Diag(Arg->getSourceRange().getBegin(),
+ return Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_method)
<< Method << Arg->getSourceRange();
-
+
// Functions must have external linkage.
if (FunctionDecl *Func = dyn_cast<FunctionDecl>(DRE->getDecl())) {
if (Func->getStorageClass() == FunctionDecl::Static) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_function_not_extern)
<< Func << Arg->getSourceRange();
Diag(Func->getLocation(), diag::note_template_arg_internal_object)
@@ -1699,7 +1698,7 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
if (VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
if (!Var->hasGlobalStorage()) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_object_not_extern)
<< Var << Arg->getSourceRange();
Diag(Var->getLocation(), diag::note_template_arg_internal_object)
@@ -1711,19 +1710,19 @@ bool Sema::CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg,
Entity = Var;
return Invalid;
}
-
+
// We found something else, but we don't know specifically what it is.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_object_or_func)
<< Arg->getSourceRange();
- Diag(DRE->getDecl()->getLocation(),
+ Diag(DRE->getDecl()->getLocation(),
diag::note_template_arg_refers_here);
return true;
}
/// \brief Checks whether the given template argument is a pointer to
/// member constant according to C++ [temp.arg.nontype]p1.
-bool
+bool
Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member) {
bool Invalid = false;
@@ -1736,7 +1735,7 @@ Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member) {
return false;
// C++ [temp.arg.nontype]p1:
- //
+ //
// A template-argument for a non-type, non-template
// template-parameter shall be one of: [...]
//
@@ -1746,7 +1745,7 @@ Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member) {
// Ignore (and complain about) any excess parentheses.
while (ParenExpr *Parens = dyn_cast<ParenExpr>(Arg)) {
if (!Invalid) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_extra_parens)
<< Arg->getSourceRange();
Invalid = true;
@@ -1776,10 +1775,10 @@ Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member) {
}
// We found something else, but we don't know specifically what it is.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_pointer_to_member_form)
<< Arg->getSourceRange();
- Diag(DRE->getDecl()->getLocation(),
+ Diag(DRE->getDecl()->getLocation(),
diag::note_template_arg_refers_here);
return true;
}
@@ -1794,7 +1793,7 @@ Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member) {
///
/// If no error was detected, Converted receives the converted template argument.
bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
- QualType InstantiatedParamType, Expr *&Arg,
+ QualType InstantiatedParamType, Expr *&Arg,
TemplateArgument &Converted) {
SourceLocation StartLoc = Arg->getSourceRange().getBegin();
@@ -1830,7 +1829,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
SourceLocation NonConstantLoc;
llvm::APSInt Value;
if (!ArgType->isIntegralType() && !ArgType->isEnumeralType()) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_integral_or_enumeral)
<< ArgType << Arg->getSourceRange();
Diag(Param->getLocation(), diag::note_template_param_here);
@@ -1859,7 +1858,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
ImpCastExprToType(Arg, ParamType);
} else {
// We can't perform this conversion.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
<< Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
Diag(Param->getLocation(), diag::note_template_param_here);
@@ -1885,7 +1884,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
// Check that we don't overflow the template parameter type.
unsigned AllowedBits = Context.getTypeSize(IntegerType);
if (Value.getActiveBits() > AllowedBits) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_too_large)
<< Value.toString(10) << Param->getType()
<< Arg->getSourceRange();
@@ -1909,7 +1908,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
}
Converted = TemplateArgument(StartLoc, Value,
- ParamType->isEnumeralType() ? ParamType
+ ParamType->isEnumeralType() ? ParamType
: IntegerType);
return false;
}
@@ -1939,7 +1938,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
(ParamType->isMemberPointerType() &&
ParamType->getAs<MemberPointerType>()->getPointeeType()
->isFunctionType())) {
- if (Context.hasSameUnqualifiedType(ArgType,
+ if (Context.hasSameUnqualifiedType(ArgType,
ParamType.getNonReferenceType())) {
// We don't have to do anything: the types already match.
} else if (ArgType->isNullPtrType() && (ParamType->isPointerType() ||
@@ -1949,7 +1948,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
} else if (ArgType->isFunctionType() && ParamType->isPointerType()) {
ArgType = Context.getPointerType(ArgType);
ImpCastExprToType(Arg, ArgType);
- } else if (FunctionDecl *Fn
+ } else if (FunctionDecl *Fn
= ResolveAddressOfOverloadedFunction(Arg, ParamType, true)) {
if (DiagnoseUseOfDecl(Fn, Arg->getSourceRange().getBegin()))
return true;
@@ -1962,16 +1961,16 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
}
}
- if (!Context.hasSameUnqualifiedType(ArgType,
+ if (!Context.hasSameUnqualifiedType(ArgType,
ParamType.getNonReferenceType())) {
// We can't perform this conversion.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
<< Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
Diag(Param->getLocation(), diag::note_template_param_here);
return true;
}
-
+
if (ParamType->isMemberPointerType()) {
NamedDecl *Member = 0;
if (CheckTemplateArgumentPointerToMember(Arg, Member))
@@ -1982,7 +1981,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
Converted = TemplateArgument(StartLoc, Member);
return false;
}
-
+
NamedDecl *Entity = 0;
if (CheckTemplateArgumentAddressOfObjectOrFunction(Arg, Entity))
return true;
@@ -2013,16 +2012,16 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
ArgType = ParamType;
ImpCastExprToType(Arg, ParamType);
}
-
+
if (!Context.hasSameUnqualifiedType(ArgType, ParamType)) {
// We can't perform this conversion.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
<< Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
Diag(Param->getLocation(), diag::note_template_param_here);
return true;
}
-
+
NamedDecl *Entity = 0;
if (CheckTemplateArgumentAddressOfObjectOrFunction(Arg, Entity))
return true;
@@ -2032,7 +2031,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
Converted = TemplateArgument(StartLoc, Entity);
return false;
}
-
+
if (const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>()) {
// -- For a non-type template-parameter of type reference to
// object, no conversions apply. The type referred to by the
@@ -2044,7 +2043,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
"Only object references allowed here");
if (!Context.hasSameUnqualifiedType(ParamRefType->getPointeeType(), ArgType)) {
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_no_ref_bind)
<< InstantiatedParamType << Arg->getType()
<< Arg->getSourceRange();
@@ -2052,10 +2051,10 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
return true;
}
- unsigned ParamQuals
+ unsigned ParamQuals
= Context.getCanonicalType(ParamType).getCVRQualifiers();
unsigned ArgQuals = Context.getCanonicalType(ArgType).getCVRQualifiers();
-
+
if ((ParamQuals | ArgQuals) != ParamQuals) {
Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_ref_bind_ignores_quals)
@@ -2064,7 +2063,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
Diag(Param->getLocation(), diag::note_template_param_here);
return true;
}
-
+
NamedDecl *Entity = 0;
if (CheckTemplateArgumentAddressOfObjectOrFunction(Arg, Entity))
return true;
@@ -2087,17 +2086,17 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
ImpCastExprToType(Arg, ParamType);
} else {
// We can't perform this conversion.
- Diag(Arg->getSourceRange().getBegin(),
+ Diag(Arg->getSourceRange().getBegin(),
diag::err_template_arg_not_convertible)
<< Arg->getType() << InstantiatedParamType << Arg->getSourceRange();
Diag(Param->getLocation(), diag::note_template_param_here);
- return true;
+ return true;
}
NamedDecl *Member = 0;
if (CheckTemplateArgumentPointerToMember(Arg, Member))
return true;
-
+
if (Member)
Member = cast<NamedDecl>(Member->getCanonicalDecl());
Converted = TemplateArgument(StartLoc, Member);
@@ -2125,9 +2124,9 @@ bool Sema::CheckTemplateArgument(TemplateTemplateParmDecl *Param,
// Note that we also allow template template parameters here, which
// will happen when we are dealing with, e.g., class template
// partial specializations.
- if (!isa<ClassTemplateDecl>(Template) &&
+ if (!isa<ClassTemplateDecl>(Template) &&
!isa<TemplateTemplateParmDecl>(Template)) {
- assert(isa<FunctionTemplateDecl>(Template) &&
+ assert(isa<FunctionTemplateDecl>(Template) &&
"Only function templates are possible here");
Diag(Arg->getLocStart(), diag::err_template_arg_not_class_template);
Diag(Template->getLocation(), diag::note_template_arg_refers_here_func)
@@ -2143,7 +2142,7 @@ bool Sema::CheckTemplateArgument(TemplateTemplateParmDecl *Param,
/// \brief Determine whether the given template parameter lists are
/// equivalent.
///
-/// \param New The new template parameter list, typically written in the
+/// \param New The new template parameter list, typically written in the
/// source code as part of a new template declaration.
///
/// \param Old The old template parameter list, typically found via
@@ -2165,7 +2164,7 @@ bool Sema::CheckTemplateArgument(TemplateTemplateParmDecl *Param,
///
/// \returns True if the template parameter lists are equal, false
/// otherwise.
-bool
+bool
Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
TemplateParameterList *Old,
bool Complain,
@@ -2177,7 +2176,7 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
if (TemplateArgLoc.isValid()) {
Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
NextDiag = diag::note_template_param_list_different_arity;
- }
+ }
Diag(New->getTemplateLoc(), NextDiag)
<< (New->size() > Old->size())
<< IsTemplateTemplateParm
@@ -2218,15 +2217,15 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
// types within the template parameter list of the template template
// parameter can be checked, and (2) the template type parameter depths
// will match up.
- QualType OldParmType
+ QualType OldParmType
= Context.getTypeDeclType(cast<TemplateTypeParmDecl>(*OldParm));
- QualType NewParmType
+ QualType NewParmType
= Context.getTypeDeclType(cast<TemplateTypeParmDecl>(*NewParm));
- assert(Context.getCanonicalType(OldParmType) ==
- Context.getCanonicalType(NewParmType) &&
+ assert(Context.getCanonicalType(OldParmType) ==
+ Context.getCanonicalType(NewParmType) &&
"type parameter mismatch?");
#endif
- } else if (NonTypeTemplateParmDecl *OldNTTP
+ } else if (NonTypeTemplateParmDecl *OldNTTP
= dyn_cast<NonTypeTemplateParmDecl>(*OldParm)) {
// The types of non-type template parameters must agree.
NonTypeTemplateParmDecl *NewNTTP
@@ -2236,14 +2235,14 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
if (Complain) {
unsigned NextDiag = diag::err_template_nontype_parm_different_type;
if (TemplateArgLoc.isValid()) {
- Diag(TemplateArgLoc,
+ Diag(TemplateArgLoc,
diag::err_template_arg_template_params_mismatch);
NextDiag = diag::note_template_nontype_parm_different_type;
}
Diag(NewNTTP->getLocation(), NextDiag)
<< NewNTTP->getType()
<< IsTemplateTemplateParm;
- Diag(OldNTTP->getLocation(),
+ Diag(OldNTTP->getLocation(),
diag::note_template_nontype_parm_prev_declaration)
<< OldNTTP->getType();
}
@@ -2253,9 +2252,9 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
// The template parameter lists of template template
// parameters must agree.
// FIXME: Could we perform a faster "type" comparison here?
- assert(isa<TemplateTemplateParmDecl>(*OldParm) &&
+ assert(isa<TemplateTemplateParmDecl>(*OldParm) &&
"Only template template parameters handled here");
- TemplateTemplateParmDecl *OldTTP
+ TemplateTemplateParmDecl *OldTTP
= cast<TemplateTemplateParmDecl>(*OldParm);
TemplateTemplateParmDecl *NewTTP
= cast<TemplateTemplateParmDecl>(*NewParm);
@@ -2275,29 +2274,29 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New,
///
/// If the template declaration is valid in this scope, returns
/// false. Otherwise, issues a diagnostic and returns true.
-bool
+bool
Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
// Find the nearest enclosing declaration scope.
while ((S->getFlags() & Scope::DeclScope) == 0 ||
(S->getFlags() & Scope::TemplateParamScope) != 0)
S = S->getParent();
-
+
// C++ [temp]p2:
// A template-declaration can appear only as a namespace scope or
// class scope declaration.
DeclContext *Ctx = static_cast<DeclContext *>(S->getEntity());
if (Ctx && isa<LinkageSpecDecl>(Ctx) &&
cast<LinkageSpecDecl>(Ctx)->getLanguage() != LinkageSpecDecl::lang_cxx)
- return Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage)
+ return Diag(TemplateParams->getTemplateLoc(), diag::err_template_linkage)
<< TemplateParams->getSourceRange();
-
+
while (Ctx && isa<LinkageSpecDecl>(Ctx))
Ctx = Ctx->getParent();
if (Ctx && (Ctx->isFileContext() || Ctx->isRecord()))
return false;
- return Diag(TemplateParams->getTemplateLoc(),
+ return Diag(TemplateParams->getTemplateLoc(),
diag::err_template_outside_namespace_or_class_scope)
<< TemplateParams->getSourceRange();
}
@@ -2306,11 +2305,11 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
/// instantiation in the current context is well-formed.
///
/// This routine determines whether a class template specialization or
-/// explicit instantiation can be declared in the current context
-/// (C++ [temp.expl.spec]p2, C++0x [temp.explicit]p2) and emits
-/// appropriate diagnostics if there was an error. It returns true if
+/// explicit instantiation can be declared in the current context
+/// (C++ [temp.expl.spec]p2, C++0x [temp.explicit]p2) and emits
+/// appropriate diagnostics if there was an error. It returns true if
// there was an error that we cannot recover from, and false otherwise.
-bool
+bool
Sema::CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate,
ClassTemplateSpecializationDecl *PrevDecl,
SourceLocation TemplateNameLoc,
@@ -2338,7 +2337,7 @@ Sema::CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate,
}
DeclContext *DC = CurContext->getEnclosingNamespaceContext();
- DeclContext *TemplateContext
+ DeclContext *TemplateContext
= ClassTemplate->getDeclContext()->getEnclosingNamespaceContext();
if ((!PrevDecl || PrevDecl->getSpecializationKind() == TSK_Undeclared) &&
!ExplicitInstantiation) {
@@ -2352,7 +2351,7 @@ Sema::CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate,
<< ClassTemplate << ScopeSpecifierRange;
else if (isa<NamespaceDecl>(TemplateContext))
Diag(TemplateNameLoc, diag::err_template_spec_decl_out_of_scope)
- << PartialSpecialization << ClassTemplate
+ << PartialSpecialization << ClassTemplate
<< cast<NamedDecl>(TemplateContext) << ScopeSpecifierRange;
Diag(ClassTemplate->getLocation(), diag::note_template_decl_here);
@@ -2379,10 +2378,10 @@ Sema::CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate,
Diag(TemplateNameLoc, diag::err_template_spec_redecl_out_of_scope)
<< Kind << ClassTemplate
<< cast<NamedDecl>(TemplateContext) << ScopeSpecifierRange;
- else
+ else
SuppressedDiag = true;
}
-
+
if (!SuppressedDiag)
Diag(ClassTemplate->getLocation(), diag::note_template_decl_here);
}
@@ -2413,16 +2412,16 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
// FIXME: the interface to this function will have to change to
// accommodate variadic templates.
MirrorsPrimaryTemplate = true;
-
+
const TemplateArgument *ArgList = TemplateArgs.getFlatArguments();
-
+
for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
// Determine whether the template argument list of the partial
// specialization is identical to the implicit argument list of
// the primary template. The caller may need to diagnostic this as
// an error per C++ [temp.class.spec]p9b3.
if (MirrorsPrimaryTemplate) {
- if (TemplateTypeParmDecl *TTP
+ if (TemplateTypeParmDecl *TTP
= dyn_cast<TemplateTypeParmDecl>(TemplateParams->getParam(I))) {
if (Context.getCanonicalType(Context.getTypeDeclType(TTP)) !=
Context.getCanonicalType(ArgList[I].getAsType()))
@@ -2432,11 +2431,11 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
TemplateParams->getParam(I))) {
// FIXME: We should settle on either Declaration storage or
// Expression storage for template template parameters.
- TemplateTemplateParmDecl *ArgDecl
+ TemplateTemplateParmDecl *ArgDecl
= dyn_cast_or_null<TemplateTemplateParmDecl>(
ArgList[I].getAsDecl());
if (!ArgDecl)
- if (DeclRefExpr *DRE
+ if (DeclRefExpr *DRE
= dyn_cast_or_null<DeclRefExpr>(ArgList[I].getAsExpr()))
ArgDecl = dyn_cast<TemplateTemplateParmDecl>(DRE->getDecl());
@@ -2447,7 +2446,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
}
}
- NonTypeTemplateParmDecl *Param
+ NonTypeTemplateParmDecl *Param
= dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->getParam(I));
if (!Param) {
continue;
@@ -2468,9 +2467,9 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
// specialized non-type arguments, so skip any non-specialized
// arguments.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ArgExpr))
- if (NonTypeTemplateParmDecl *NTTP
+ if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl())) {
- if (MirrorsPrimaryTemplate &&
+ if (MirrorsPrimaryTemplate &&
(Param->getIndex() != NTTP->getIndex() ||
Param->getDepth() != NTTP->getDepth()))
MirrorsPrimaryTemplate = false;
@@ -2486,7 +2485,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
// specialization except when the argument expression is a
// simple identifier.
if (ArgExpr->isTypeDependent() || ArgExpr->isValueDependent()) {
- Diag(ArgExpr->getLocStart(),
+ Diag(ArgExpr->getLocStart(),
diag::err_dependent_non_type_arg_in_partial_spec)
<< ArgExpr->getSourceRange();
return true;
@@ -2496,7 +2495,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
// specialized non-type argument shall not be dependent on a
// parameter of the specialization.
if (Param->getType()->isDependentType()) {
- Diag(ArgExpr->getLocStart(),
+ Diag(ArgExpr->getLocStart(),
diag::err_dependent_typed_non_type_arg_in_partial_spec)
<< Param->getType()
<< ArgExpr->getSourceRange();
@@ -2513,7 +2512,7 @@ bool Sema::CheckClassTemplatePartialSpecializationArgs(
Sema::DeclResult
Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
TagUseKind TUK,
- SourceLocation KWLoc,
+ SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy TemplateD,
SourceLocation TemplateNameLoc,
@@ -2527,7 +2526,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// Find the class template we're specializing
TemplateName Name = TemplateD.getAsVal<TemplateName>();
- ClassTemplateDecl *ClassTemplate
+ ClassTemplateDecl *ClassTemplate
= cast<ClassTemplateDecl>(Name.getAsTemplateDecl());
bool isPartialSpecialization = false;
@@ -2535,8 +2534,8 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// Check the validity of the template headers that introduce this
// template.
TemplateParameterList *TemplateParams
- = MatchTemplateParametersToScopeSpecifier(TemplateNameLoc, SS,
- (TemplateParameterList**)TemplateParameterLists.get(),
+ = MatchTemplateParametersToScopeSpecifier(TemplateNameLoc, SS,
+ (TemplateParameterList**)TemplateParameterLists.get(),
TemplateParameterLists.size());
if (TemplateParams && TemplateParams->size() > 0) {
isPartialSpecialization = true;
@@ -2548,14 +2547,14 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
Decl *Param = TemplateParams->getParam(I);
if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(Param)) {
if (TTP->hasDefaultArgument()) {
- Diag(TTP->getDefaultArgumentLoc(),
+ Diag(TTP->getDefaultArgumentLoc(),
diag::err_default_arg_in_partial_spec);
TTP->setDefaultArgument(QualType(), SourceLocation(), false);
}
} else if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(Param)) {
if (Expr *DefArg = NTTP->getDefaultArgument()) {
- Diag(NTTP->getDefaultArgumentLoc(),
+ Diag(NTTP->getDefaultArgumentLoc(),
diag::err_default_arg_in_partial_spec)
<< DefArg->getSourceRange();
NTTP->setDefaultArgument(0);
@@ -2564,7 +2563,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
} else {
TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(Param);
if (Expr *DefArg = TTP->getDefaultArgument()) {
- Diag(TTP->getDefaultArgumentLoc(),
+ Diag(TTP->getDefaultArgumentLoc(),
diag::err_default_arg_in_partial_spec)
<< DefArg->getSourceRange();
TTP->setDefaultArgument(0);
@@ -2586,13 +2585,13 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
case DeclSpec::TST_class: Kind = TagDecl::TK_class; break;
}
if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
- Kind, KWLoc,
+ Kind, KWLoc,
*ClassTemplate->getIdentifier())) {
- Diag(KWLoc, diag::err_use_with_wrong_tag)
+ Diag(KWLoc, diag::err_use_with_wrong_tag)
<< ClassTemplate
- << CodeModificationHint::CreateReplacement(KWLoc,
+ << CodeModificationHint::CreateReplacement(KWLoc,
ClassTemplate->getTemplatedDecl()->getKindName());
- Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
+ Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
diag::note_previous_use);
Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
}
@@ -2605,15 +2604,15 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// template.
TemplateArgumentListBuilder Converted(ClassTemplate->getTemplateParameters(),
TemplateArgs.size());
- if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
+ if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
TemplateArgs.data(), TemplateArgs.size(),
RAngleLoc, false, Converted))
return true;
- assert((Converted.structuredSize() ==
+ assert((Converted.structuredSize() ==
ClassTemplate->getTemplateParameters()->size()) &&
"Converted template argument list is too short!");
-
+
// Find the class template (partial) specialization declaration that
// corresponds to these arguments.
llvm::FoldingSetNodeID ID;
@@ -2627,11 +2626,11 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
if (MirrorsPrimaryTemplate) {
// C++ [temp.class.spec]p9b3:
//
- // -- The argument list of the specialization shall not be identical
- // to the implicit argument list of the primary template.
+ // -- The argument list of the specialization shall not be identical
+ // to the implicit argument list of the primary template.
Diag(TemplateNameLoc, diag::err_partial_spec_args_match_primary_template)
<< (TUK == TUK_Definition)
- << CodeModificationHint::CreateRemoval(SourceRange(LAngleLoc,
+ << CodeModificationHint::CreateRemoval(SourceRange(LAngleLoc,
RAngleLoc));
return CheckClassTemplate(S, TagSpec, TUK, KWLoc, SS,
ClassTemplate->getIdentifier(),
@@ -2642,7 +2641,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
}
// FIXME: Template parameter list matters, too
- ClassTemplatePartialSpecializationDecl::Profile(ID,
+ ClassTemplatePartialSpecializationDecl::Profile(ID,
Converted.getFlatArguments(),
Converted.flatSize(),
Context);
@@ -2656,7 +2655,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
if (isPartialSpecialization)
PrevDecl
- = ClassTemplate->getPartialSpecializations().FindNodeOrInsertPos(ID,
+ = ClassTemplate->getPartialSpecializations().FindNodeOrInsertPos(ID,
InsertPos);
else
PrevDecl
@@ -2667,7 +2666,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// Check whether we can declare a class template specialization in
// the current scope.
if (CheckClassTemplateSpecializationScope(ClassTemplate, PrevDecl,
- TemplateNameLoc,
+ TemplateNameLoc,
SS.getRange(),
isPartialSpecialization,
/*ExplicitInstantiation=*/false))
@@ -2693,12 +2692,12 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
Converted.flatSize());
// Create a new class template partial specialization declaration node.
- TemplateParameterList *TemplateParams
+ TemplateParameterList *TemplateParams
= static_cast<TemplateParameterList*>(*TemplateParameterLists.get());
ClassTemplatePartialSpecializationDecl *PrevPartial
= cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl);
- ClassTemplatePartialSpecializationDecl *Partial
- = ClassTemplatePartialSpecializationDecl::Create(Context,
+ ClassTemplatePartialSpecializationDecl *Partial
+ = ClassTemplatePartialSpecializationDecl::Create(Context,
ClassTemplate->getDeclContext(),
TemplateNameLoc,
TemplateParams,
@@ -2734,11 +2733,11 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
if (!DeducibleParams[I]) {
NamedDecl *Param = cast<NamedDecl>(TemplateParams->getParam(I));
if (Param->getDeclName())
- Diag(Param->getLocation(),
+ Diag(Param->getLocation(),
diag::note_partial_spec_unused_parameter)
<< Param->getDeclName();
else
- Diag(Param->getLocation(),
+ Diag(Param->getLocation(),
diag::note_partial_spec_unused_parameter)
<< std::string("<anonymous>");
}
@@ -2748,10 +2747,10 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// Create a new class template specialization declaration node for
// this explicit specialization.
Specialization
- = ClassTemplateSpecializationDecl::Create(Context,
+ = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getDeclContext(),
TemplateNameLoc,
- ClassTemplate,
+ ClassTemplate,
Converted,
PrevDecl);
@@ -2759,7 +2758,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
ClassTemplate->getSpecializations().RemoveNode(PrevDecl);
ClassTemplate->getSpecializations().GetOrInsertNode(Specialization);
} else {
- ClassTemplate->getSpecializations().InsertNode(Specialization,
+ ClassTemplate->getSpecializations().InsertNode(Specialization,
InsertPos);
}
@@ -2775,7 +2774,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// FIXME: Should also handle explicit specialization after implicit
// instantiation with a special diagnostic.
SourceRange Range(TemplateNameLoc, RAngleLoc);
- Diag(TemplateNameLoc, diag::err_redefinition)
+ Diag(TemplateNameLoc, diag::err_redefinition)
<< Context.getTypeDeclType(Specialization) << Range;
Diag(Def->getLocation(), diag::note_previous_definition);
Specialization->setInvalidDecl();
@@ -2790,8 +2789,8 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// actually wrote the specialization, rather than formatting the
// name based on the "canonical" representation used to store the
// template arguments in the specialization.
- QualType WrittenTy
- = Context.getTemplateSpecializationType(Name,
+ QualType WrittenTy
+ = Context.getTemplateSpecializationType(Name,
TemplateArgs.data(),
TemplateArgs.size(),
CanonType);
@@ -2807,7 +2806,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
// but we also maintain the lexical context where the actual
// definition occurs.
Specialization->setLexicalDeclContext(CurContext);
-
+
// We may be starting the definition of this specialization.
if (TUK == TUK_Definition)
Specialization->startDefinition();
@@ -2819,34 +2818,34 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
return DeclPtrTy::make(Specialization);
}
-Sema::DeclPtrTy
-Sema::ActOnTemplateDeclarator(Scope *S,
+Sema::DeclPtrTy
+Sema::ActOnTemplateDeclarator(Scope *S,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D) {
return HandleDeclarator(S, D, move(TemplateParameterLists), false);
}
-Sema::DeclPtrTy
-Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
+Sema::DeclPtrTy
+Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
MultiTemplateParamsArg TemplateParameterLists,
Declarator &D) {
assert(getCurFunctionDecl() == 0 && "Function parsing confused");
assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
"Not a function declarator!");
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
-
+
if (FTI.hasPrototype) {
- // FIXME: Diagnose arguments without names in C.
+ // FIXME: Diagnose arguments without names in C.
}
-
+
Scope *ParentScope = FnBodyScope->getParent();
-
- DeclPtrTy DP = HandleDeclarator(ParentScope, D,
+
+ DeclPtrTy DP = HandleDeclarator(ParentScope, D,
move(TemplateParameterLists),
/*IsFunctionDefinition=*/true);
- if (FunctionTemplateDecl *FunctionTemplate
+ if (FunctionTemplateDecl *FunctionTemplate
= dyn_cast_or_null<FunctionTemplateDecl>(DP.getAs<Decl>()))
- return ActOnStartOfFunctionDef(FnBodyScope,
+ return ActOnStartOfFunctionDef(FnBodyScope,
DeclPtrTy::make(FunctionTemplate->getTemplatedDecl()));
if (FunctionDecl *Function = dyn_cast_or_null<FunctionDecl>(DP.getAs<Decl>()))
return ActOnStartOfFunctionDef(FnBodyScope, DeclPtrTy::make(Function));
@@ -2856,10 +2855,10 @@ Sema::ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
// Explicit instantiation of a class template specialization
// FIXME: Implement extern template semantics
Sema::DeclResult
-Sema::ActOnExplicitInstantiation(Scope *S,
+Sema::ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
TemplateTy TemplateD,
@@ -2871,7 +2870,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
AttributeList *Attr) {
// Find the class template we're specializing
TemplateName Name = TemplateD.getAsVal<TemplateName>();
- ClassTemplateDecl *ClassTemplate
+ ClassTemplateDecl *ClassTemplate
= cast<ClassTemplateDecl>(Name.getAsTemplateDecl());
// Check that the specialization uses the same tag kind as the
@@ -2884,13 +2883,13 @@ Sema::ActOnExplicitInstantiation(Scope *S,
case DeclSpec::TST_class: Kind = TagDecl::TK_class; break;
}
if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
- Kind, KWLoc,
+ Kind, KWLoc,
*ClassTemplate->getIdentifier())) {
- Diag(KWLoc, diag::err_use_with_wrong_tag)
+ Diag(KWLoc, diag::err_use_with_wrong_tag)
<< ClassTemplate
- << CodeModificationHint::CreateReplacement(KWLoc,
+ << CodeModificationHint::CreateReplacement(KWLoc,
ClassTemplate->getTemplatedDecl()->getKindName());
- Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
+ Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
diag::note_previous_use);
Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
}
@@ -2901,7 +2900,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
//
// This is C++ DR 275.
if (CheckClassTemplateSpecializationScope(ClassTemplate, 0,
- TemplateNameLoc,
+ TemplateNameLoc,
SS.getRange(),
/*PartialSpecialization=*/false,
/*ExplicitInstantiation=*/true))
@@ -2915,19 +2914,19 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// template.
TemplateArgumentListBuilder Converted(ClassTemplate->getTemplateParameters(),
TemplateArgs.size());
- if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
+ if (CheckTemplateArgumentList(ClassTemplate, TemplateNameLoc, LAngleLoc,
TemplateArgs.data(), TemplateArgs.size(),
RAngleLoc, false, Converted))
return true;
- assert((Converted.structuredSize() ==
+ assert((Converted.structuredSize() ==
ClassTemplate->getTemplateParameters()->size()) &&
"Converted template argument list is too short!");
-
+
// Find the class template specialization declaration that
// corresponds to these arguments.
llvm::FoldingSetNodeID ID;
- ClassTemplateSpecializationDecl::Profile(ID,
+ ClassTemplateSpecializationDecl::Profile(ID,
Converted.getFlatArguments(),
Converted.flatSize(),
Context);
@@ -2939,13 +2938,13 @@ Sema::ActOnExplicitInstantiation(Scope *S,
bool SpecializationRequiresInstantiation = true;
if (PrevDecl) {
- if (PrevDecl->getSpecializationKind()
+ if (PrevDecl->getSpecializationKind()
== TSK_ExplicitInstantiationDefinition) {
// This particular specialization has already been declared or
// instantiated. We cannot explicitly instantiate it.
Diag(TemplateNameLoc, diag::err_explicit_instantiation_duplicate)
<< Context.getTypeDeclType(PrevDecl);
- Diag(PrevDecl->getLocation(),
+ Diag(PrevDecl->getLocation(),
diag::note_previous_explicit_instantiation);
return DeclPtrTy::make(PrevDecl);
}
@@ -2957,10 +2956,10 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// an explicit specialization for that template, the explicit
// instantiation has no effect.
if (!getLangOptions().CPlusPlus0x) {
- Diag(TemplateNameLoc,
+ Diag(TemplateNameLoc,
diag::ext_explicit_instantiation_after_specialization)
<< Context.getTypeDeclType(PrevDecl);
- Diag(PrevDecl->getLocation(),
+ Diag(PrevDecl->getLocation(),
diag::note_previous_template_specialization);
}
@@ -2970,7 +2969,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// accurate reproduction of the source code; we don't actually
// use it for anything, since it is semantically irrelevant.
Specialization
- = ClassTemplateSpecializationDecl::Create(Context,
+ = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getDeclContext(),
TemplateNameLoc,
ClassTemplate,
@@ -2996,13 +2995,13 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// Create a new class template specialization declaration node for
// this explicit specialization.
Specialization
- = ClassTemplateSpecializationDecl::Create(Context,
+ = ClassTemplateSpecializationDecl::Create(Context,
ClassTemplate->getDeclContext(),
TemplateNameLoc,
ClassTemplate,
Converted, 0);
- ClassTemplate->getSpecializations().InsertNode(Specialization,
+ ClassTemplate->getSpecializations().InsertNode(Specialization,
InsertPos);
}
@@ -3013,8 +3012,8 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// the explicit instantiation, rather than formatting the name based
// on the "canonical" representation used to store the template
// arguments in the specialization.
- QualType WrittenTy
- = Context.getTemplateSpecializationType(Name,
+ QualType WrittenTy
+ = Context.getTemplateSpecializationType(Name,
TemplateArgs.data(),
TemplateArgs.size(),
Context.getTypeDeclType(Specialization));
@@ -3035,7 +3034,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// This check comes when we actually try to perform the
// instantiation.
TemplateSpecializationKind TSK
- = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
+ = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
: TSK_ExplicitInstantiationDeclaration;
if (SpecializationRequiresInstantiation)
InstantiateClassTemplateSpecialization(Specialization, TSK);
@@ -3048,10 +3047,10 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// Explicit instantiation of a member class of a class template.
Sema::DeclResult
-Sema::ActOnExplicitInstantiation(Scope *S,
+Sema::ActOnExplicitInstantiation(Scope *S,
SourceLocation ExternLoc,
SourceLocation TemplateLoc,
- unsigned TagSpec,
+ unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
IdentifierInfo *Name,
@@ -3092,7 +3091,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
if (getLangOptions().CPlusPlus0x) {
// FIXME: In C++98, we would like to turn these errors into warnings,
// dependent on a -Wc++0x flag.
- DeclContext *PatternContext
+ DeclContext *PatternContext
= Pattern->getDeclContext()->getEnclosingNamespaceContext();
if (!CurContext->Encloses(PatternContext)) {
Diag(TemplateLoc, diag::err_explicit_instantiation_out_of_scope)
@@ -3102,19 +3101,19 @@ Sema::ActOnExplicitInstantiation(Scope *S,
}
TemplateSpecializationKind TSK
- = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
+ = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
: TSK_ExplicitInstantiationDeclaration;
-
+
if (!Record->getDefinition(Context)) {
// If the class has a definition, instantiate it (and all of its
// members, recursively).
Pattern = cast_or_null<CXXRecordDecl>(Pattern->getDefinition(Context));
- if (Pattern && InstantiateClass(TemplateLoc, Record, Pattern,
+ if (Pattern && InstantiateClass(TemplateLoc, Record, Pattern,
getTemplateInstantiationArgs(Record),
TSK))
return true;
} else // Instantiate all of the members of the class.
- InstantiateClassMembers(TemplateLoc, Record,
+ InstantiateClassMembers(TemplateLoc, Record,
getTemplateInstantiationArgs(Record), TSK);
// FIXME: We don't have any representation for explicit instantiations of
@@ -3127,7 +3126,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
Sema::TypeResult
Sema::ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
const IdentifierInfo &II, SourceLocation IdLoc) {
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
if (!NNS)
return true;
@@ -3142,9 +3141,9 @@ Sema::TypeResult
Sema::ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
SourceLocation TemplateLoc, TypeTy *Ty) {
QualType T = GetTypeFromParser(Ty);
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
- const TemplateSpecializationType *TemplateId
+ const TemplateSpecializationType *TemplateId
= T->getAsTemplateSpecializationType();
assert(TemplateId && "Expected a template specialization type");
@@ -3152,11 +3151,11 @@ Sema::ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS,
// If we can compute a declaration context, then the "typename"
// keyword was superfluous. Just build a QualifiedNameType to keep
// track of the nested-name-specifier.
-
+
// FIXME: Note that the QualifiedNameType had the "typename" keyword!
return Context.getQualifiedNameType(NNS, T).getAsOpaquePtr();
}
-
+
return Context.getTypenameType(NNS, TemplateId).getAsOpaquePtr();
}
@@ -3173,10 +3172,10 @@ Sema::CheckTypenameType(NestedNameSpecifier *NNS, const IdentifierInfo &II,
// instantiation, then build a typename type.
if (!CurrentInstantiation)
return Context.getTypenameType(NNS, &II);
-
+
// The nested-name-specifier refers to the current instantiation, so the
// "typename" keyword itself is superfluous. In C++03, the program is
- // actually ill-formed. However, DR 382 (in C++0x CD1) allows such
+ // actually ill-formed. However, DR 382 (in C++0x CD1) allows such
// extraneous "typename" keywords, and we retroactively apply this DR to
// C++03 code.
}
@@ -3197,7 +3196,7 @@ Sema::CheckTypenameType(NestedNameSpecifier *NNS, const IdentifierInfo &II,
assert(Ctx && "No declaration context?");
DeclarationName Name(&II);
- LookupResult Result = LookupQualifiedName(Ctx, Name, LookupOrdinaryName,
+ LookupResult Result = LookupQualifiedName(Ctx, Name, LookupOrdinaryName,
false);
unsigned DiagID = 0;
Decl *Referenced = 0;
@@ -3247,20 +3246,19 @@ Sema::CheckTypenameType(NestedNameSpecifier *NNS, const IdentifierInfo &II,
namespace {
// See Sema::RebuildTypeInCurrentInstantiation
- class VISIBILITY_HIDDEN CurrentInstantiationRebuilder
- : public TreeTransform<CurrentInstantiationRebuilder>
- {
+ class VISIBILITY_HIDDEN CurrentInstantiationRebuilder
+ : public TreeTransform<CurrentInstantiationRebuilder> {
SourceLocation Loc;
DeclarationName Entity;
-
+
public:
- CurrentInstantiationRebuilder(Sema &SemaRef,
+ CurrentInstantiationRebuilder(Sema &SemaRef,
SourceLocation Loc,
- DeclarationName Entity)
- : TreeTransform<CurrentInstantiationRebuilder>(SemaRef),
+ DeclarationName Entity)
+ : TreeTransform<CurrentInstantiationRebuilder>(SemaRef),
Loc(Loc), Entity(Entity) { }
-
- /// \brief Determine whether the given type \p T has already been
+
+ /// \brief Determine whether the given type \p T has already been
/// transformed.
///
/// For the purposes of type reconstruction, a type has already been
@@ -3268,14 +3266,14 @@ namespace {
bool AlreadyTransformed(QualType T) {
return T.isNull() || !T->isDependentType();
}
-
- /// \brief Returns the location of the entity whose type is being
+
+ /// \brief Returns the location of the entity whose type is being
/// rebuilt.
SourceLocation getBaseLocation() { return Loc; }
-
+
/// \brief Returns the name of the entity whose type is being rebuilt.
DeclarationName getBaseEntity() { return Entity; }
-
+
/// \brief Transforms an expression by returning the expression itself
/// (an identity function).
///
@@ -3284,7 +3282,7 @@ namespace {
Sema::OwningExprResult TransformExpr(Expr *E) {
return getSema().Owned(E);
}
-
+
/// \brief Transforms a typename type by determining whether the type now
/// refers to a member of the current instantiation, and then
/// type-checking and building a QualifiedNameType (when possible).
@@ -3292,7 +3290,7 @@ namespace {
};
}
-QualType
+QualType
CurrentInstantiationRebuilder::TransformTypenameType(const TypenameType *T) {
NestedNameSpecifier *NNS
= TransformNestedNameSpecifier(T->getQualifier(),
@@ -3308,30 +3306,30 @@ CurrentInstantiationRebuilder::TransformTypenameType(const TypenameType *T) {
SS.setScopeRep(NNS);
if (NNS == T->getQualifier() && getSema().computeDeclContext(SS) == 0)
return QualType(T, 0);
-
- // Rebuild the typename type, which will probably turn into a
+
+ // Rebuild the typename type, which will probably turn into a
// QualifiedNameType.
if (const TemplateSpecializationType *TemplateId = T->getTemplateId()) {
- QualType NewTemplateId
+ QualType NewTemplateId
= TransformType(QualType(TemplateId, 0));
if (NewTemplateId.isNull())
return QualType();
-
+
if (NNS == T->getQualifier() &&
NewTemplateId == QualType(TemplateId, 0))
return QualType(T, 0);
-
+
return getDerived().RebuildTypenameType(NNS, NewTemplateId);
}
-
+
return getDerived().RebuildTypenameType(NNS, T->getIdentifier());
}
/// \brief Rebuilds a type within the context of the current instantiation.
///
-/// The type \p T is part of the type of an out-of-line member definition of
+/// The type \p T is part of the type of an out-of-line member definition of
/// a class template (or class template partial specialization) that was parsed
-/// and constructed before we entered the scope of the class template (or
+/// and constructed before we entered the scope of the class template (or
/// partial specialization thereof). This routine will rebuild that type now
/// that we have entered the declarator's scope, which may produce different
/// canonical types, e.g.,
@@ -3357,7 +3355,7 @@ QualType Sema::RebuildTypeInCurrentInstantiation(QualType T, SourceLocation Loc,
DeclarationName Name) {
if (T.isNull() || !T->isDependentType())
return T;
-
+
CurrentInstantiationRebuilder Rebuilder(*this, Loc, Name);
return Rebuilder.TransformType(T);
}
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 2253a4e6a7..b861dcabfe 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -45,7 +45,7 @@ namespace clang {
using namespace clang;
static Sema::TemplateDeductionResult
-DeduceTemplateArguments(ASTContext &Context,
+DeduceTemplateArguments(ASTContext &Context,
TemplateParameterList *TemplateParams,
const TemplateArgument &Param,
const TemplateArgument &Arg,
@@ -58,27 +58,27 @@ DeduceTemplateArguments(ASTContext &Context,
static NonTypeTemplateParmDecl *getDeducedParameterFromExpr(Expr *E) {
if (ImplicitCastExpr *IC = dyn_cast<ImplicitCastExpr>(E))
E = IC->getSubExpr();
-
+
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
return dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
-
+
return 0;
}
-/// \brief Deduce the value of the given non-type template parameter
+/// \brief Deduce the value of the given non-type template parameter
/// from the given constant.
static Sema::TemplateDeductionResult
-DeduceNonTypeTemplateArgument(ASTContext &Context,
- NonTypeTemplateParmDecl *NTTP,
+DeduceNonTypeTemplateArgument(ASTContext &Context,
+ NonTypeTemplateParmDecl *NTTP,
llvm::APSInt Value,
Sema::TemplateDeductionInfo &Info,
llvm::SmallVectorImpl<TemplateArgument> &Deduced) {
- assert(NTTP->getDepth() == 0 &&
+ assert(NTTP->getDepth() == 0 &&
"Cannot deduce non-type template argument with depth > 0");
-
+
if (Deduced[NTTP->getIndex()].isNull()) {
QualType T = NTTP->getType();
-
+
// FIXME: Make sure we didn't overflow our data type!
unsigned AllowedBits = Context.getTypeSize(T);
if (Value.getBitWidth() != AllowedBits)
@@ -88,10 +88,10 @@ DeduceNonTypeTemplateArgument(ASTContext &Context,
Deduced[NTTP->getIndex()] = TemplateArgument(SourceLocation(), Value, T);
return Sema::TDK_Success;
}
-
+
assert(Deduced[NTTP->getIndex()].getKind() == TemplateArgument::Integral);
-
- // If the template argument was previously deduced to a negative value,
+
+ // If the template argument was previously deduced to a negative value,
// then our deduction fails.
const llvm::APSInt *PrevValuePtr = Deduced[NTTP->getIndex()].getAsIntegral();
if (PrevValuePtr->isNegative()) {
@@ -117,35 +117,35 @@ DeduceNonTypeTemplateArgument(ASTContext &Context,
return Sema::TDK_Success;
}
-/// \brief Deduce the value of the given non-type template parameter
+/// \brief Deduce the value of the given non-type template parameter
/// from the given type- or value-dependent expression.
///
/// \returns true if deduction succeeded, false otherwise.
static Sema::TemplateDeductionResult
-DeduceNonTypeTemplateArgument(ASTContext &Context,
+DeduceNonTypeTemplateArgument(ASTContext &Context,
NonTypeTemplateParmDecl *NTTP,
Expr *Value,
Sema::TemplateDeductionInfo &Info,
llvm::SmallVectorImpl<TemplateArgument> &Deduced) {
- assert(NTTP->getDepth() == 0 &&
+ assert(NTTP->getDepth() == 0 &&
"Cannot deduce non-type template argument with depth > 0");
assert((Value->isTypeDependent() || Value->isValueDependent()) &&
"Expression template argument must be type- or value-dependent.");
-
+
if (Deduced[NTTP->getIndex()].isNull()) {
// FIXME: Clone the Value?
Deduced[NTTP->getIndex()] = TemplateArgument(Value);
return Sema::TDK_Success;
}
-
+
if (Deduced[NTTP->getIndex()].getKind() == TemplateArgument::Integral) {
- // Okay, we deduced a constant in one case and a dependent expression
- // in another case. FIXME: Later, we will check that instantiating the
+ // Okay, we deduced a constant in one case and a dependent expression
+ // in another case. FIXME: Later, we will check that instantiating the
// dependent expression gives us the constant value.
return Sema::TDK_Success;
}
-
+
// FIXME: Compare the expressions for equality!
return Sema::TDK_Success;
}
@@ -164,7 +164,7 @@ DeduceTemplateArguments(ASTContext &Context,
TemplateDecl *ParamDecl = Param.getAsTemplateDecl();
TemplateDecl *ArgDecl = Arg.getAsTemplateDecl();
-
+
if (!ParamDecl || !ArgDecl) {
// FIXME: fill in Info.Param/Info.FirstArg
return Sema::TDK_Inconsistent;
@@ -180,7 +180,7 @@ DeduceTemplateArguments(ASTContext &Context,
return Sema::TDK_Success;
}
-/// \brief Deduce the template arguments by comparing the template parameter
+/// \brief Deduce the template arguments by comparing the template parameter
/// type (which is a template-id) with the template argument type.
///
/// \param Context the AST context in which this deduction occurs.
@@ -206,11 +206,11 @@ DeduceTemplateArguments(ASTContext &Context,
Sema::TemplateDeductionInfo &Info,
llvm::SmallVectorImpl<TemplateArgument> &Deduced) {
assert(Arg->isCanonical() && "Argument type must be canonical");
-
+
// Check whether the template argument is a dependent template-id.
// FIXME: This is untested code; it can be tested when we implement
// partial ordering of class template partial specializations.
- if (const TemplateSpecializationType *SpecArg
+ if (const TemplateSpecializationType *SpecArg
= dyn_cast<TemplateSpecializationType>(Arg)) {
// Perform template argument deduction for the template name.
if (Sema::TemplateDeductionResult Result
@@ -219,9 +219,9 @@ DeduceTemplateArguments(ASTContext &Context,
SpecArg->getTemplateName(),
Info, Deduced))
return Result;
-
+
unsigned NumArgs = Param->getNumArgs();
-
+
// FIXME: When one of the template-names refers to a
// declaration with default template arguments, do we need to
// fill in those default template arguments here? Most likely,
@@ -231,7 +231,7 @@ DeduceTemplateArguments(ASTContext &Context,
// the template-id.
if (SpecArg->getNumArgs() != NumArgs)
return Sema::TDK_NonDeducedMismatch;
-
+
// Perform template argument deduction on each template
// argument.
for (unsigned I = 0; I != NumArgs; ++I)
@@ -241,49 +241,49 @@ DeduceTemplateArguments(ASTContext &Context,
SpecArg->getArg(I),
Info, Deduced))
return Result;
-
+
return Sema::TDK_Success;
}
-
+
// If the argument type is a class template specialization, we
// perform template argument deduction using its template
// arguments.
const RecordType *RecordArg = dyn_cast<RecordType>(Arg);
if (!RecordArg)
return Sema::TDK_NonDeducedMismatch;
-
- ClassTemplateSpecializationDecl *SpecArg
+
+ ClassTemplateSpecializationDecl *SpecArg
= dyn_cast<ClassTemplateSpecializationDecl>(RecordArg->getDecl());
if (!SpecArg)
return Sema::TDK_NonDeducedMismatch;
-
+
// Perform template argument deduction for the template name.
if (Sema::TemplateDeductionResult Result
- = DeduceTemplateArguments(Context,
+ = DeduceTemplateArguments(Context,
Param->getTemplateName(),
TemplateName(SpecArg->getSpecializedTemplate()),
Info, Deduced))
return Result;
-
+
// FIXME: Can the # of arguments in the parameter and the argument
// differ due to default arguments?
unsigned NumArgs = Param->getNumArgs();
const TemplateArgumentList &ArgArgs = SpecArg->getTemplateArgs();
if (NumArgs != ArgArgs.size())
return Sema::TDK_NonDeducedMismatch;
-
+
for (unsigned I = 0; I != NumArgs; ++I)
- if (Sema::TemplateDeductionResult Result
+ if (Sema::TemplateDeductionResult Result
= DeduceTemplateArguments(Context, TemplateParams,
Param->getArg(I),
ArgArgs.get(I),
Info, Deduced))
return Result;
-
+
return Sema::TDK_Success;
}
-/// \brief Returns a completely-unqualified array type, capturing the
+/// \brief Returns a completely-unqualified array type, capturing the
/// qualifiers in CVRQuals.
///
/// \param Context the AST context in which the array type was built.
@@ -302,32 +302,32 @@ static QualType getUnqualifiedArrayType(ASTContext &Context, QualType T,
CVRQuals = T.getCVRQualifiers();
return T.getUnqualifiedType();
}
-
+
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(T)) {
QualType Elt = getUnqualifiedArrayType(Context, CAT->getElementType(),
CVRQuals);
if (Elt == CAT->getElementType())
return T;
- return Context.getConstantArrayType(Elt, CAT->getSize(),
+ return Context.getConstantArrayType(Elt, CAT->getSize(),
CAT->getSizeModifier(), 0);
}
-
+
if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(T)) {
QualType Elt = getUnqualifiedArrayType(Context, IAT->getElementType(),
CVRQuals);
if (Elt == IAT->getElementType())
return T;
-
+
return Context.getIncompleteArrayType(Elt, IAT->getSizeModifier(), 0);
}
-
+
const DependentSizedArrayType *DSAT = cast<DependentSizedArrayType>(T);
QualType Elt = getUnqualifiedArrayType(Context, DSAT->getElementType(),
CVRQuals);
if (Elt == DSAT->getElementType())
return T;
-
+
return Context.getDependentSizedArrayType(Elt, DSAT->getSizeExpr()->Retain(),
DSAT->getSizeModifier(), 0,
SourceRange());
@@ -349,13 +349,13 @@ static QualType getUnqualifiedArrayType(ASTContext &Context, QualType T,
/// \param Deduced the deduced template arguments
///
/// \param TDF bitwise OR of the TemplateDeductionFlags bits that describe
-/// how template argument deduction is performed.
+/// how template argument deduction is performed.
///
/// \returns the result of template argument deduction so far. Note that a
/// "success" result means that template argument deduction has not yet failed,
/// but it may still fail, later, for other reasons.
static Sema::TemplateDeductionResult
-DeduceTemplateArguments(ASTContext &Context,
+DeduceTemplateArguments(ASTContext &Context,
TemplateParameterList *TemplateParams,
QualType ParamIn, QualType ArgIn,
Sema::TemplateDeductionInfo &Info,
@@ -368,30 +368,30 @@ DeduceTemplateArguments(ASTContext &Context,
// C++0x [temp.deduct.call]p4 bullet 1:
// - If the original P is a reference type, the deduced A (i.e., the type
- // referred to by the reference) can be more cv-qualified than the
+ // referred to by the reference) can be more cv-qualified than the
// transformed A.
if (TDF & TDF_ParamWithReferenceType) {
- unsigned ExtraQualsOnParam
+ unsigned ExtraQualsOnParam
= Param.getCVRQualifiers() & ~Arg.getCVRQualifiers();
Param.setCVRQualifiers(Param.getCVRQualifiers() & ~ExtraQualsOnParam);
}
-
+
// If the parameter type is not dependent, there is nothing to deduce.
if (!Param->isDependentType())
return Sema::TDK_Success;
// C++ [temp.deduct.type]p9:
- // A template type argument T, a template template argument TT or a
- // template non-type argument i can be deduced if P and A have one of
+ // A template type argument T, a template template argument TT or a
+ // template non-type argument i can be deduced if P and A have one of
// the following forms:
//
// T
// cv-list T
- if (const TemplateTypeParmType *TemplateTypeParm
+ if (const TemplateTypeParmType *TemplateTypeParm
= Param->getAsTemplateTypeParmType()) {
unsigned Index = TemplateTypeParm->getIndex();
bool RecanonicalizeArg = false;
-
+
// If the argument type is an array type, move the qualifiers up to the
// top level, so they can be matched with the qualifiers on the parameter.
// FIXME: address spaces, ObjC GC qualifiers
@@ -403,7 +403,7 @@ DeduceTemplateArguments(ASTContext &Context,
RecanonicalizeArg = true;
}
}
-
+
// The argument type can not be less qualified than the parameter
// type.
if (Param.isMoreQualifiedThan(Arg) && !(TDF & TDF_IgnoreQualifiers)) {
@@ -414,23 +414,23 @@ DeduceTemplateArguments(ASTContext &Context,
}
assert(TemplateTypeParm->getDepth() == 0 && "Can't deduce with depth > 0");
-
+
unsigned Quals = Arg.getCVRQualifiers() & ~Param.getCVRQualifiers();
QualType DeducedType = Arg.getQualifiedType(Quals);
if (RecanonicalizeArg)
DeducedType = Context.getCanonicalType(DeducedType);
-
+
if (Deduced[Index].isNull())
Deduced[Index] = TemplateArgument(SourceLocation(), DeducedType);
else {
- // C++ [temp.deduct.type]p2:
+ // C++ [temp.deduct.type]p2:
// [...] If type deduction cannot be done for any P/A pair, or if for
- // any pair the deduction leads to more than one possible set of
- // deduced values, or if different pairs yield different deduced
- // values, or if any template argument remains neither deduced nor
+ // any pair the deduction leads to more than one possible set of
+ // deduced values, or if different pairs yield different deduced
+ // values, or if any template argument remains neither deduced nor
// explicitly specified, template argument deduction fails.
if (Deduced[Index].getAsType() != DeducedType) {
- Info.Param
+ Info.Param
= cast<TemplateTypeParmDecl>(TemplateParams->getParam(Index));
Info.FirstArg = Deduced[Index];
Info.SecondArg = TemplateArgument(SourceLocation(), Arg);
@@ -451,7 +451,7 @@ DeduceTemplateArguments(ASTContext &Context,
return Sema::TDK_NonDeducedMismatch;
} else {
if (Param.getCVRQualifiers() != Arg.getCVRQualifiers())
- return Sema::TDK_NonDeducedMismatch;
+ return Sema::TDK_NonDeducedMismatch;
}
}
@@ -459,26 +459,26 @@ DeduceTemplateArguments(ASTContext &Context,
// No deduction possible for these types
case Type::Builtin:
return Sema::TDK_NonDeducedMismatch;
-
+
// T *
case Type::Pointer: {
const PointerType *PointerArg = Arg->getAs<PointerType>();
if (!PointerArg)
return Sema::TDK_NonDeducedMismatch;
-
+
unsigned SubTDF = TDF & (TDF_IgnoreQualifiers | TDF_DerivedClass);
return DeduceTemplateArguments(Context, TemplateParams,
cast<PointerType>(Param)->getPointeeType(),
PointerArg->getPointeeType(),
Info, Deduced, SubTDF);
}
-
+
// T &
case Type::LValueReference: {
const LValueReferenceType *ReferenceArg = Arg->getAs<LValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
-
+
return DeduceTemplateArguments(Context, TemplateParams,
cast<LValueReferenceType>(Param)->getPointeeType(),
ReferenceArg->getPointeeType(),
@@ -490,20 +490,20 @@ DeduceTemplateArguments(ASTContext &Context,
const RValueReferenceType *ReferenceArg = Arg->getAs<RValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
-
+
return DeduceTemplateArguments(Context, TemplateParams,
cast<RValueReferenceType>(Param)->getPointeeType(),
ReferenceArg->getPointeeType(),
Info, Deduced, 0);
}
-
+
// T [] (implied, but not stated explicitly)
case Type::IncompleteArray: {
- const IncompleteArrayType *IncompleteArrayArg =
+ const IncompleteArrayType *IncompleteArrayArg =
Context.getAsIncompleteArrayType(Arg);
if (!IncompleteArrayArg)
return Sema::TDK_NonDeducedMismatch;
-
+
return DeduceTemplateArguments(Context, TemplateParams,
Context.getAsIncompleteArrayType(Param)->getElementType(),
IncompleteArrayArg->getElementType(),
@@ -512,16 +512,16 @@ DeduceTemplateArguments(ASTContext &Context,
// T [integer-constant]
case Type::ConstantArray: {
- const ConstantArrayType *ConstantArrayArg =
+ const ConstantArrayType *ConstantArrayArg =
Context.getAsConstantArrayType(Arg);
if (!ConstantArrayArg)
return Sema::TDK_NonDeducedMismatch;
-
- const ConstantArrayType *ConstantArrayParm =
+
+ const ConstantArrayType *ConstantArrayParm =
Context.getAsConstantArrayType(Param);
if (ConstantArrayArg->getSize() != ConstantArrayParm->getSize())
return Sema::TDK_NonDeducedMismatch;
-
+
return DeduceTemplateArguments(Context, TemplateParams,
ConstantArrayParm->getElementType(),
ConstantArrayArg->getElementType(),
@@ -533,7 +533,7 @@ DeduceTemplateArguments(ASTContext &Context,
const ArrayType *ArrayArg = dyn_cast<ArrayType>(Arg);
if (!ArrayArg)
return Sema::TDK_NonDeducedMismatch;
-
+
// Check the element type of the arrays
const DependentSizedArrayType *DependentArrayParm
= cast<DependentSizedArrayType>(Param);
@@ -543,18 +543,18 @@ DeduceTemplateArguments(ASTContext &Context,
ArrayArg->getElementType(),
Info, Deduced, 0))
return Result;
-
+
// Determine the array bound is something we can deduce.
- NonTypeTemplateParmDecl *NTTP
+ NonTypeTemplateParmDecl *NTTP
= getDeducedParameterFromExpr(DependentArrayParm->getSizeExpr());
if (!NTTP)
return Sema::TDK_Success;
-
- // We can perform template argument deduction for the given non-type
+
+ // We can perform template argument deduction for the given non-type
// template parameter.
- assert(NTTP->getDepth() == 0 &&
+ assert(NTTP->getDepth() == 0 &&
"Cannot deduce non-type template argument at depth > 0");
- if (const ConstantArrayType *ConstantArrayArg
+ if (const ConstantArrayType *ConstantArrayArg
= dyn_cast<ConstantArrayType>(ArrayArg)) {
llvm::APSInt Size(ConstantArrayArg->getSize());
return DeduceNonTypeTemplateArgument(Context, NTTP, Size,
@@ -565,30 +565,30 @@ DeduceTemplateArguments(ASTContext &Context,
return DeduceNonTypeTemplateArgument(Context, NTTP,
DependentArrayArg->getSizeExpr(),
Info, Deduced);
-
+
// Incomplete type does not match a dependently-sized array type
return Sema::TDK_NonDeducedMismatch;
}
-
- // type(*)(T)
- // T(*)()
- // T(*)(T)
+
+ // type(*)(T)
+ // T(*)()
+ // T(*)(T)
case Type::FunctionProto: {
- const FunctionProtoType *FunctionProtoArg =
+ const FunctionProtoType *FunctionProtoArg =
dyn_cast<FunctionProtoType>(Arg);
if (!FunctionProtoArg)
return Sema::TDK_NonDeducedMismatch;
-
- const FunctionProtoType *FunctionProtoParam =
+
+ const FunctionProtoType *FunctionProtoParam =
cast<FunctionProtoType>(Param);
- if (FunctionProtoParam->getTypeQuals() !=
+ if (FunctionProtoParam->getTypeQuals() !=
FunctionProtoArg->getTypeQuals())
return Sema::TDK_NonDeducedMismatch;
-
+
if (FunctionProtoParam->getNumArgs() != FunctionProtoArg->getNumArgs())
return Sema::TDK_NonDeducedMismatch;
-
+
if (FunctionProtoParam->isVariadic() != FunctionProtoArg->isVariadic())
return Sema::TDK_NonDeducedMismatch;
@@ -599,7 +599,7 @@ DeduceTemplateArguments(ASTContext &Context,
FunctionProtoArg->getResultType(),
Info, Deduced, 0))
return Result;
-
+
for (unsigned I = 0, N = FunctionProtoParam->getNumArgs(); I != N; ++I) {
// Check argument types.
if (Sema::TemplateDeductionResult Result
@@ -609,10 +609,10 @@ DeduceTemplateArguments(ASTContext &Context,
Info, Deduced, 0))
return Result;
}
-
+
return Sema::TDK_Success;
}
-
+
// template-name<T> (where template-name refers to a class template)
// template-name<i>
// TT<T> (TODO)
@@ -621,26 +621,26 @@ DeduceTemplateArguments(ASTContext &Context,
case Type::TemplateSpecialization: {
const TemplateSpecializationType *SpecParam
= cast<TemplateSpecializationType>(Param);
-
+
// Try to deduce template arguments from the template-id.
Sema::TemplateDeductionResult Result
- = DeduceTemplateArguments(Context, TemplateParams, SpecParam, Arg,
+ = DeduceTemplateArguments(Context, TemplateParams, SpecParam, Arg,
Info, Deduced);
-
- if (Result && (TDF & TDF_DerivedClass) &&
+
+ if (Result && (TDF & TDF_DerivedClass) &&
Result != Sema::TDK_Inconsistent) {
// C++ [temp.deduct.call]p3b3:
// If P is a class, and P has the form template-id, then A can be a
// derived class of the deduced A. Likewise, if P is a pointer to a
- // class of the form template-id, A can be a pointer to a derived
+ // class of the form template-id, A can be a pointer to a derived
// class pointed to by the deduced A.
//
// More importantly:
- // These alternatives are considered only if type deduction would
+ // These alternatives are considered only if type deduction would
// otherwise fail.
if (const RecordType *RecordT = dyn_cast<RecordType>(Arg)) {
// Use data recursion to crawl through the list of base classes.
- // Visited contains the set of nodes we have already visited, while
+ // Visited contains the set of nodes we have already visited, while
// ToVisit is our stack of records that we still need to visit.
llvm::SmallPtrSet<const RecordType *, 8> Visited;
llvm::SmallVector<const RecordType *, 8> ToVisit;
@@ -650,18 +650,18 @@ DeduceTemplateArguments(ASTContext &Context,
// Retrieve the next class in the inheritance hierarchy.
const RecordType *NextT = ToVisit.back();
ToVisit.pop_back();
-
+
// If we have already seen this type, skip it.
if (!Visited.insert(NextT))
continue;
-
+
// If this is a base class, try to perform template argument
// deduction from it.
if (NextT != RecordT) {
Sema::TemplateDeductionResult BaseResult
= DeduceTemplateArguments(Context, TemplateParams, SpecParam,
QualType(NextT, 0), Info, Deduced);
-
+
// If template argument deduction for this base was successful,
// note that we had some success.
if (BaseResult == Sema::TDK_Success)
@@ -672,24 +672,24 @@ DeduceTemplateArguments(ASTContext &Context,
else if (BaseResult == Sema::TDK_Inconsistent)
return BaseResult;
}
-
+
// Visit base classes
CXXRecordDecl *Next = cast<CXXRecordDecl>(NextT->getDecl());
for (CXXRecordDecl::base_class_iterator Base = Next->bases_begin(),
BaseEnd = Next->bases_end();
Base != BaseEnd; ++Base) {
- assert(Base->getType()->isRecordType() &&
+ assert(Base->getType()->isRecordType() &&
"Base class that isn't a record?");
ToVisit.push_back(Base->getType()->getAs<RecordType>());
}
}
-
+
if (Successful)
return Sema::TDK_Success;
}
-
+
}
-
+
return Result;
}
@@ -724,16 +724,16 @@ DeduceTemplateArguments(ASTContext &Context,
// (clang extension)
//
- // type(^)(T)
- // T(^)()
- // T(^)(T)
+ // type(^)(T)
+ // T(^)()
+ // T(^)(T)
case Type::BlockPointer: {
const BlockPointerType *BlockPtrParam = cast<BlockPointerType>(Param);
const BlockPointerType *BlockPtrArg = dyn_cast<BlockPointerType>(Arg);
-
+
if (!BlockPtrArg)
return Sema::TDK_NonDeducedMismatch;
-
+
return DeduceTemplateArguments(Context, TemplateParams,
BlockPtrParam->getPointeeType(),
BlockPtrArg->getPointeeType(), Info,
@@ -755,7 +755,7 @@ DeduceTemplateArguments(ASTContext &Context,
}
static Sema::TemplateDeductionResult
-DeduceTemplateArguments(ASTContext &Context,
+DeduceTemplateArguments(ASTContext &Context,
TemplateParameterList *TemplateParams,
const TemplateArgument &Param,
const TemplateArgument &Arg,
@@ -765,8 +765,8 @@ DeduceTemplateArguments(ASTContext &Context,
case TemplateArgument::Null:
assert(false && "Null template argument in parameter list");
break;
-
- case TemplateArgument::Type:
+
+ case TemplateArgument::Type:
assert(Arg.getKind() == TemplateArgument::Type && "Type/value mismatch");
return DeduceTemplateArguments(Context, TemplateParams, Param.getAsType(),
Arg.getAsType(), Info, Deduced, 0);
@@ -777,7 +777,7 @@ DeduceTemplateArguments(ASTContext &Context,
Info.FirstArg = Param;
Info.SecondArg = Arg;
return Sema::TDK_NonDeducedMismatch;
-
+
case TemplateArgument::Integral:
if (Arg.getKind() == TemplateArgument::Integral) {
// FIXME: Zero extension + sign checking here?
@@ -799,25 +799,25 @@ DeduceTemplateArguments(ASTContext &Context,
Info.FirstArg = Param;
Info.SecondArg = Arg;
return Sema::TDK_NonDeducedMismatch;
-
+
case TemplateArgument::Expression: {
- if (NonTypeTemplateParmDecl *NTTP
+ if (NonTypeTemplateParmDecl *NTTP
= getDeducedParameterFromExpr(Param.getAsExpr())) {
if (Arg.getKind() == TemplateArgument::Integral)
// FIXME: Sign problems here
- return DeduceNonTypeTemplateArgument(Context, NTTP,
- *Arg.getAsIntegral(),
+ return DeduceNonTypeTemplateArgument(Context, NTTP,
+ *Arg.getAsIntegral(),
Info, Deduced);
if (Arg.getKind() == TemplateArgument::Expression)
return DeduceNonTypeTemplateArgument(Context, NTTP, Arg.getAsExpr(),
Info, Deduced);
-
+
assert(false && "Type/value mismatch");
Info.FirstArg = Param;
Info.SecondArg = Arg;
return Sema::TDK_NonDeducedMismatch;
}
-
+
// Can't deduce anything, but that's okay.
return Sema::TDK_Success;
}
@@ -825,11 +825,11 @@ DeduceTemplateArguments(ASTContext &Context,
assert(0 && "FIXME: Implement!");
break;
}
-
+
return Sema::TDK_Success;
}
-static Sema::TemplateDeductionResult
+static Sema::TemplateDeductionResult
DeduceTemplateArguments(ASTContext &Context,
TemplateParameterList *TemplateParams,
const TemplateArgumentList &ParamList,
@@ -840,7 +840,7 @@ DeduceTemplateArguments(ASTContext &Context,
for (unsigned I = 0, N = ParamList.size(); I != N; ++I) {
if (Sema::TemplateDeductionResult Result
= DeduceTemplateArguments(Context, TemplateParams,
- ParamList[I], ArgList[I],
+ ParamList[I], ArgList[I],
Info, Deduced))
return Result;
}
@@ -848,41 +848,41 @@ DeduceTemplateArguments(ASTContext &Context,
}
/// \brief Determine whether two template arguments are the same.
-static bool isSameTemplateArg(ASTContext &Context,
+static bool isSameTemplateArg(ASTContext &Context,
const TemplateArgument &X,
const TemplateArgument &Y) {
if (X.getKind() != Y.getKind())
return false;
-
+
switch (X.getKind()) {
case TemplateArgument::Null:
assert(false && "Comparing NULL template argument");
break;
-
+
case TemplateArgument::Type:
return Context.getCanonicalType(X.getAsType()) ==
Context.getCanonicalType(Y.getAsType());
-
+
case TemplateArgument::Declaration:
return X.getAsDecl()->getCanonicalDecl() ==
Y.getAsDecl()->getCanonicalDecl();
-
+
case TemplateArgument::Integral:
return *X.getAsIntegral() == *Y.getAsIntegral();
-
+
case TemplateArgument::Expression:
// FIXME: We assume that all expressions are distinct, but we should
// really check their canonical forms.
return false;
-
+
case TemplateArgument::Pack:
if (X.pack_size() != Y.pack_size())
return false;
-
- for (TemplateArgument::pack_iterator XP = X.pack_begin(),
- XPEnd = X.pack_end(),
+
+ for (TemplateArgument::pack_iterator XP = X.pack_begin(),
+ XPEnd = X.pack_end(),
YP = Y.pack_begin();
- XP != XPEnd; ++XP, ++YP)
+ XP != XPEnd; ++XP, ++YP)
if (!isSameTemplateArg(Context, *XP, *YP))
return false;
@@ -899,7 +899,7 @@ static TemplateParameter makeTemplateParameter(Decl *D) {
return TemplateParameter(TTP);
else if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D))
return TemplateParameter(NTTP);
-
+
return TemplateParameter(cast<TemplateTemplateParmDecl>(D));
}
@@ -919,9 +919,9 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
llvm::SmallVector<TemplateArgument, 4> Deduced;
Deduced.resize(Partial->getTemplateParameters()->size());
if (TemplateDeductionResult Result
- = ::DeduceTemplateArguments(Context,
+ = ::DeduceTemplateArguments(Context,
Partial->getTemplateParameters(),
- Partial->getTemplateArgs(),
+ Partial->getTemplateArgs(),
TemplateArgs, Info, Deduced))
return Result;
@@ -937,11 +937,11 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
Deduced.size());
for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
if (Deduced[I].isNull()) {
- Decl *Param
+ Decl *Param
= const_cast<Decl *>(Partial->getTemplateParameters()->getParam(I));
if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
Info.Param = TTP;
- else if (NonTypeTemplateParmDecl *NTTP
+ else if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(Param))
Info.Param = NTTP;
else
@@ -953,7 +953,7 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
}
// Form the template argument list from the deduced template arguments.
- TemplateArgumentList *DeducedArgumentList
+ TemplateArgumentList *DeducedArgumentList
= new (Context) TemplateArgumentList(Context, Builder, /*TakeArgs=*/true);
Info.reset(DeducedArgumentList);
@@ -961,45 +961,45 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
// arguments of the class template partial specialization, and
// verify that the instantiated template arguments are both valid
// and are equivalent to the template arguments originally provided
- // to the class template.
+ // to the class template.
ClassTemplateDecl *ClassTemplate = Partial->getSpecializedTemplate();
const TemplateArgumentList &PartialTemplateArgs = Partial->getTemplateArgs();
for (unsigned I = 0, N = PartialTemplateArgs.flat_size(); I != N; ++I) {
Decl *Param = const_cast<Decl *>(
ClassTemplate->getTemplateParameters()->getParam(I));
- TemplateArgument InstArg
+ TemplateArgument InstArg
= Subst(PartialTemplateArgs[I],
MultiLevelTemplateArgumentList(*DeducedArgumentList));
if (InstArg.isNull()) {
Info.Param = makeTemplateParameter(Param);
Info.FirstArg = PartialTemplateArgs[I];
- return TDK_SubstitutionFailure;
+ return TDK_SubstitutionFailure;
}
-
+
if (InstArg.getKind() == TemplateArgument::Expression) {
- // When the argument is an expression, check the expression result
+ // When the argument is an expression, check the expression result
// against the actual template parameter to get down to the canonical
// template argument.
Expr *InstExpr = InstArg.getAsExpr();
- if (NonTypeTemplateParmDecl *NTTP
+ if (NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(Param)) {
if (CheckTemplateArgument(NTTP, NTTP->getType(), InstExpr, InstArg)) {
Info.Param = makeTemplateParameter(Param);
Info.FirstArg = PartialTemplateArgs[I];
- return TDK_SubstitutionFailure;
+ return TDK_SubstitutionFailure;
}
- } else if (TemplateTemplateParmDecl *TTP
+ } else if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(Param)) {
// FIXME: template template arguments should really resolve to decls
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InstExpr);
if (!DRE || CheckTemplateArgument(TTP, DRE)) {
Info.Param = makeTemplateParameter(Param);
Info.FirstArg = PartialTemplateArgs[I];
- return TDK_SubstitutionFailure;
+ return TDK_SubstitutionFailure;
}
}
}
-
+
if (!isSameTemplateArg(Context, TemplateArgs[I], InstArg)) {
Info.Param = makeTemplateParameter(Param);
Info.FirstArg = TemplateArgs[I];
@@ -1016,10 +1016,10 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
/// \brief Determine whether the given type T is a simple-template-id type.
static bool isSimpleTemplateIdType(QualType T) {
- if (const TemplateSpecializationType *Spec
+ if (const TemplateSpecializationType *Spec
= T->getAsTemplateSpecializationType())
return Spec->getTemplateName().getAsTemplateDecl() != 0;
-
+
return false;
}
@@ -1029,16 +1029,16 @@ static bool isSimpleTemplateIdType(QualType T) {
/// \param FunctionTemplate the function template into which the explicit
/// template arguments will be substituted.
///
-/// \param ExplicitTemplateArguments the explicitly-specified template
+/// \param ExplicitTemplateArguments the explicitly-specified template
/// arguments.
///
-/// \param NumExplicitTemplateArguments the number of explicitly-specified
+/// \param NumExplicitTemplateArguments the number of explicitly-specified
/// template arguments in @p ExplicitTemplateArguments. This value may be zero.
///
-/// \param Deduced the deduced template arguments, which will be populated
+/// \param Deduced the deduced template arguments, which will be populated
/// with the converted and checked explicit template arguments.
///
-/// \param ParamTypes will be populated with the instantiated function
+/// \param ParamTypes will be populated with the instantiated function
/// parameters.
///
/// \param FunctionType if non-NULL, the result type of the function template
@@ -1071,33 +1071,33 @@ Sema::SubstituteExplicitTemplateArguments(
P != PEnd;
++P)
ParamTypes.push_back((*P)->getType());
-
+
if (FunctionType)
*FunctionType = Function->getType();
return TDK_Success;
}
-
+
// Substitution of the explicit template arguments into a function template
/// is a SFINAE context. Trap any errors that might occur.
- SFINAETrap Trap(*this);
-
+ SFINAETrap Trap(*this);
+
// C++ [temp.arg.explicit]p3:
- // Template arguments that are present shall be specified in the
- // declaration order of their corresponding template-parameters. The
+ // Template arguments that are present shall be specified in the
+ // declaration order of their corresponding template-parameters. The
// template argument list shall not specify more template-arguments than
- // there are corresponding template-parameters.
- TemplateArgumentListBuilder Builder(TemplateParams,
+ // there are corresponding template-parameters.
+ TemplateArgumentListBuilder Builder(TemplateParams,
NumExplicitTemplateArgs);
-
- // Enter a new template instantiation context where we check the
+
+ // Enter a new template instantiation context where we check the
// explicitly-specified template arguments against this function template,
// and then substitute them into the function parameter types.
- InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
+ InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
FunctionTemplate, Deduced.data(), Deduced.size(),
ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution);
if (Inst)
return TDK_InstantiationDepth;
-
+
if (CheckTemplateArgumentList(FunctionTemplate,
SourceLocation(), SourceLocation(),
ExplicitTemplateArgs,
@@ -1106,26 +1106,26 @@ Sema::SubstituteExplicitTemplateArguments(
true,
Builder) || Trap.hasErrorOccurred())
return TDK_InvalidExplicitArguments;
-
+
// Form the template argument list from the explicitly-specified
// template arguments.
- TemplateArgumentList *ExplicitArgumentList
+ TemplateArgumentList *ExplicitArgumentList
= new (Context) TemplateArgumentList(Context, Builder, /*TakeArgs=*/true);
Info.reset(ExplicitArgumentList);
-
+
// Instantiate the types of each of the function parameters given the
// explicitly-specified template arguments.
for (FunctionDecl::param_iterator P = Function->param_begin(),
PEnd = Function->param_end();
P != PEnd;
++P) {
- QualType ParamType
- = SubstType((*P)->getType(),
+ QualType ParamType
+ = SubstType((*P)->getType(),
MultiLevelTemplateArgumentList(*ExplicitArgumentList),
(*P)->getLocation(), (*P)->getDeclName());
if (ParamType.isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
-
+
ParamTypes.push_back(ParamType);
}
@@ -1133,19 +1133,19 @@ Sema::SubstituteExplicitTemplateArguments(
// type and form that function type.
if (FunctionType) {
// FIXME: exception-specifications?
- const FunctionProtoType *Proto
+ const FunctionProtoType *Proto
= Function->getType()->getAsFunctionProtoType();
assert(Proto && "Function template does not have a prototype?");
-
- QualType ResultType
+
+ QualType ResultType
= SubstType(Proto->getResultType(),
MultiLevelTemplateArgumentList(*ExplicitArgumentList),
Function->getTypeSpecStartLoc(),
Function->getDeclName());
if (ResultType.isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
-
- *FunctionType = BuildFunctionType(ResultType,
+
+ *FunctionType = BuildFunctionType(ResultType,
ParamTypes.data(), ParamTypes.size(),
Proto->isVariadic(),
Proto->getTypeQuals(),
@@ -1154,33 +1154,33 @@ Sema::SubstituteExplicitTemplateArguments(
if (FunctionType->isNull() || Trap.hasErrorOccurred())
return TDK_SubstitutionFailure;
}
-
+
// C++ [temp.arg.explicit]p2:
- // Trailing template arguments that can be deduced (14.8.2) may be
- // omitted from the list of explicit template-arguments. If all of the
+ // Trailing template arguments that can be deduced (14.8.2) may be
+ // omitted from the list of explicit template-arguments. If all of the
// template arguments can be deduced, they may all be omitted; in this
// case, the empty template argument list <> itself may also be omitted.
//
// Take all of the explicitly-specified arguments and put them into the
- // set of deduced template arguments.
+ // set of deduced template arguments.
Deduced.reserve(TemplateParams->size());
for (unsigned I = 0, N = ExplicitArgumentList->size(); I != N; ++I)
- Deduced.push_back(ExplicitArgumentList->get(I));
-
+ Deduced.push_back(ExplicitArgumentList->get(I));
+
return TDK_Success;
}
-/// \brief Finish template argument deduction for a function template,
+/// \brief Finish template argument deduction for a function template,
/// checking the deduced template arguments for completeness and forming
/// the function template specialization.
-Sema::TemplateDeductionResult
+Sema::TemplateDeductionResult
Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
llvm::SmallVectorImpl<TemplateArgument> &Deduced,
FunctionDecl *&Specialization,
TemplateDeductionInfo &Info) {
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
-
+
// C++ [temp.deduct.type]p2:
// [...] or if any template argument remains neither deduced nor
// explicitly specified, template argument deduction fails.
@@ -1191,28 +1191,28 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
const_cast<Decl *>(TemplateParams->getParam(I)));
return TDK_Incomplete;
}
-
+
Builder.Append(Deduced[I]);
}
-
+
// Form the template argument list from the deduced template arguments.
- TemplateArgumentList *DeducedArgumentList
+ TemplateArgumentList *DeducedArgumentList
= new (Context) TemplateArgumentList(Context, Builder, /*TakeArgs=*/true);
Info.reset(DeducedArgumentList);
-
+
// Template argument deduction for function templates in a SFINAE context.
// Trap any errors that might occur.
- SFINAETrap Trap(*this);
-
+ SFINAETrap Trap(*this);
+
// Enter a new template instantiation context while we instantiate the
// actual function declaration.
- InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
+ InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
FunctionTemplate, Deduced.data(), Deduced.size(),
ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution);
if (Inst)
- return TDK_InstantiationDepth;
-
- // Substitute the deduced template arguments into the function template
+ return TDK_InstantiationDepth;
+
+ // Substitute the deduced template arguments into the function template
// declaration to produce the function template specialization.
Specialization = cast_or_null<FunctionDecl>(
SubstDecl(FunctionTemplate->getTemplatedDecl(),
@@ -1220,12 +1220,12 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
MultiLevelTemplateArgumentList(*DeducedArgumentList)));
if (!Specialization)
return TDK_SubstitutionFailure;
-
- // If the template argument list is owned by the function template
+
+ // If the template argument list is owned by the function template
// specialization, release it.
if (Specialization->getTemplateSpecializationArgs() == DeducedArgumentList)
Info.take();
-
+
// There may have been an error that did not prevent us from constructing a
// declaration. Mark the declaration invalid and return with a substitution
// failure.
@@ -1233,8 +1233,8 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
Specialization->setInvalidDecl(true);
return TDK_SubstitutionFailure;
}
-
- return TDK_Success;
+
+ return TDK_Success;
}
/// \brief Perform template argument deduction from a function call
@@ -1243,14 +1243,14 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
/// \param FunctionTemplate the function template for which we are performing
/// template argument deduction.
///
-/// \param HasExplicitTemplateArgs whether any template arguments were
+/// \param HasExplicitTemplateArgs whether any template arguments were
/// explicitly specified.
///
/// \param ExplicitTemplateArguments when @p HasExplicitTemplateArgs is true,
/// the explicitly-specified template arguments.
///
/// \param NumExplicitTemplateArguments when @p HasExplicitTemplateArgs is true,
-/// the number of explicitly-specified template arguments in
+/// the number of explicitly-specified template arguments in
/// @p ExplicitTemplateArguments. This value may be zero.
///
/// \param Args the function call arguments
@@ -1258,7 +1258,7 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
/// \param NumArgs the number of arguments in Args
///
/// \param Specialization if template argument deduction was successful,
-/// this will be set to the function template specialization produced by
+/// this will be set to the function template specialization produced by
/// template argument deduction.
///
/// \param Info the argument will be updated to provide additional information
@@ -1283,14 +1283,14 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
if (NumArgs < Function->getMinRequiredArguments())
return TDK_TooFewArguments;
else if (NumArgs > Function->getNumParams()) {
- const FunctionProtoType *Proto
+ const FunctionProtoType *Proto
= Function->getType()->getAsFunctionProtoType();
if (!Proto->isVariadic())
return TDK_TooManyArguments;
-
+
CheckArgs = Function->getNumParams();
}
-
+
// The types of the parameters from which we will perform template argument
// deduction.
TemplateParameterList *TemplateParams
@@ -1313,25 +1313,25 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
for (unsigned I = 0; I != CheckArgs; ++I)
ParamTypes.push_back(Function->getParamDecl(I)->getType());
}
-
+
// Deduce template arguments from the function parameters.
- Deduced.resize(TemplateParams->size());
+ Deduced.resize(TemplateParams->size());
for (unsigned I = 0; I != CheckArgs; ++I) {
QualType ParamType = ParamTypes[I];
QualType ArgType = Args[I]->getType();
-
+
// C++ [temp.deduct.call]p2:
// If P is not a reference type:
QualType CanonParamType = Context.getCanonicalType(ParamType);
bool ParamWasReference = isa<ReferenceType>(CanonParamType);
if (!ParamWasReference) {
- // - If A is an array type, the pointer type produced by the
- // array-to-pointer standard conversion (4.2) is used in place of
+ // - If A is an array type, the pointer type produced by the
+ // array-to-pointer standard conversion (4.2) is used in place of
// A for type deduction; otherwise,
if (ArgType->isArrayType())
ArgType = Context.getArrayDecayedType(ArgType);
- // - If A is a function type, the pointer type produced by the
- // function-to-pointer standard conversion (4.3) is used in place
+ // - If A is a function type, the pointer type produced by the
+ // function-to-pointer standard conversion (4.3) is used in place
// of A for type deduction; otherwise,
else if (ArgType->isFunctionType())
ArgType = Context.getPointerType(ArgType);
@@ -1343,67 +1343,67 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
ArgType = CanonArgType.getUnqualifiedType();
}
}
-
+
// C++0x [temp.deduct.call]p3:
// If P is a cv-qualified type, the top level cv-qualifiers of P’s type
- // are ignored for type deduction.
+ // are ignored for type deduction.
if (CanonParamType.getCVRQualifiers())
ParamType = CanonParamType.getUnqualifiedType();
if (const ReferenceType *ParamRefType = ParamType->getAs<ReferenceType>()) {
- // [...] If P is a reference type, the type referred to by P is used
- // for type deduction.
+ // [...] If P is a reference type, the type referred to by P is used
+ // for type deduction.
ParamType = ParamRefType->getPointeeType();
-
- // [...] If P is of the form T&&, where T is a template parameter, and
- // the argument is an lvalue, the type A& is used in place of A for
+
+ // [...] If P is of the form T&&, where T is a template parameter, and
+ // the argument is an lvalue, the type A& is used in place of A for
// type deduction.
if (isa<RValueReferenceType>(ParamRefType) &&
ParamRefType->getAsTemplateTypeParmType() &&
Args[I]->isLvalue(Context) == Expr::LV_Valid)
ArgType = Context.getLValueReferenceType(ArgType);
}
-
+
// C++0x [temp.deduct.call]p4:
// In general, the deduction process attempts to find template argument
// values that will make the deduced A identical to A (after the type A
// is transformed as described above). [...]
unsigned TDF = 0;
-
+
// - If the original P is a reference type, the deduced A (i.e., the
// type referred to by the reference) can be more cv-qualified than
// the transformed A.
if (ParamWasReference)
TDF |= TDF_ParamWithReferenceType;
- // - The transformed A can be another pointer or pointer to member
- // type that can be converted to the deduced A via a qualification
+ // - The transformed A can be another pointer or pointer to member
+ // type that can be converted to the deduced A via a qualification
// conversion (4.4).
if (ArgType->isPointerType() || ArgType->isMemberPointerType())
TDF |= TDF_IgnoreQualifiers;
- // - If P is a class and P has the form simple-template-id, then the
+ // - If P is a class and P has the form simple-template-id, then the
// transformed A can be a derived class of the deduced A. Likewise,
// if P is a pointer to a class of the form simple-template-id, the
// transformed A can be a pointer to a derived class pointed to by
// the deduced A.
if (isSimpleTemplateIdType(ParamType) ||
- (isa<PointerType>(ParamType) &&
+ (isa<PointerType>(ParamType) &&
isSimpleTemplateIdType(
ParamType->getAs<PointerType>()->getPointeeType())))
TDF |= TDF_DerivedClass;
-
+
if (TemplateDeductionResult Result
= ::DeduceTemplateArguments(Context, TemplateParams,
ParamType, ArgType, Info, Deduced,
TDF))
return Result;
-
+
// FIXME: C++0x [temp.deduct.call] paragraphs 6-9 deal with function
- // pointer parameters.
+ // pointer parameters.
// FIXME: we need to check that the deduced A is the same as A,
// modulo the various allowed differences.
}
- return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
+ return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
Specialization, Info);
}
@@ -1413,14 +1413,14 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
/// \param FunctionTemplate the function template for which we are performing
/// template argument deduction.
///
-/// \param HasExplicitTemplateArgs whether any template arguments were
+/// \param HasExplicitTemplateArgs whether any template arguments were
/// explicitly specified.
///
/// \param ExplicitTemplateArguments when @p HasExplicitTemplateArgs is true,
/// the explicitly-specified template arguments.
///
/// \param NumExplicitTemplateArguments when @p HasExplicitTemplateArgs is true,
-/// the number of explicitly-specified template arguments in
+/// the number of explicitly-specified template arguments in
/// @p ExplicitTemplateArguments. This value may be zero.
///
/// \param ArgFunctionType the function type that will be used as the
@@ -1428,7 +1428,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
/// function template's function type.
///
/// \param Specialization if template argument deduction was successful,
-/// this will be set to the function template specialization produced by
+/// this will be set to the function template specialization produced by
/// template argument deduction.
///
/// \param Info the argument will be updated to provide additional information
@@ -1447,33 +1447,33 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
QualType FunctionType = Function->getType();
-
+
// Substitute any explicit template arguments.
llvm::SmallVector<TemplateArgument, 4> Deduced;
llvm::SmallVector<QualType, 4> ParamTypes;
if (HasExplicitTemplateArgs) {
- if (TemplateDeductionResult Result
- = SubstituteExplicitTemplateArguments(FunctionTemplate,
- ExplicitTemplateArgs,
+ if (TemplateDeductionResult Result
+ = SubstituteExplicitTemplateArguments(FunctionTemplate,
+ ExplicitTemplateArgs,
NumExplicitTemplateArgs,
- Deduced, ParamTypes,
+ Deduced, ParamTypes,
&FunctionType, Info))
return Result;
}
// Template argument deduction for function templates in a SFINAE context.
// Trap any errors that might occur.
- SFINAETrap Trap(*this);
-
+ SFINAETrap Trap(*this);
+
// Deduce template arguments from the function type.
- Deduced.resize(TemplateParams->size());
+ Deduced.resize(TemplateParams->size());
if (TemplateDeductionResult Result
= ::DeduceTemplateArguments(Context, TemplateParams,
- FunctionType, ArgFunctionType, Info,
+ FunctionType, ArgFunctionType, Info,
Deduced, 0))
return Result;
-
- return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
+
+ return FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
Specialization, Info);
}
@@ -1485,7 +1485,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
QualType ToType,
CXXConversionDecl *&Specialization,
TemplateDeductionInfo &Info) {
- CXXConversionDecl *Conv
+ CXXConversionDecl *Conv
= cast<CXXConversionDecl>(FunctionTemplate->getTemplatedDecl());
QualType FromType = Conv->getConversionType();
@@ -1506,12 +1506,12 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
A = ARef->getPointeeType();
// C++ [temp.deduct.conv]p2:
//
- // If A is not a reference type:
+ // If A is not a reference type:
else {
assert(!A->isReferenceType() && "Reference types were handled above");
// - If P is an array type, the pointer type produced by the
- // array-to-pointer standard conversion (4.2) is used in place
+ // array-to-pointer standard conversion (4.2) is used in place
// of P for type deduction; otherwise,
if (P->isArrayType())
P = Context.getArrayDecayedType(P);
@@ -1533,7 +1533,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
// Template argument deduction for function templates in a SFINAE context.
// Trap any errors that might occur.
- SFINAETrap Trap(*this);
+ SFINAETrap Trap(*this);
// C++ [temp.deduct.conv]p1:
// Template argument deduction is done by comparing the return
@@ -1543,7 +1543,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
llvm::SmallVector<TemplateArgument, 4> Deduced;
- Deduced.resize(TemplateParams->size());
+ Deduced.resize(TemplateParams->size());
// C++0x [temp.deduct.conv]p4:
// In general, the deduction process attempts to find template
@@ -1572,7 +1572,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
// FIXME: we need to check that the deduced A is the same as A,
// modulo the various allowed differences.
-
+
// Finish template argument deduction.
FunctionDecl *Spec = 0;
TemplateDeductionResult Result
@@ -1591,7 +1591,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
/// \param isCallContext whether partial ordering is being performed
/// for a function call (which ignores the return types of the
/// functions).
-///
+///
/// \returns the more specialization function template. If neither
/// template is more specialized, returns NULL.
FunctionTemplateDecl *
@@ -1613,21 +1613,21 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
#endif
}
-static void
+static void
MarkDeducedTemplateParameters(Sema &SemaRef,
const TemplateArgument &TemplateArg,
llvm::SmallVectorImpl<bool> &Deduced);
/// \brief Mark the template arguments that are deduced by the given
/// expression.
-static void
-MarkDeducedTemplateParameters(const Expr *E,
+static void
+MarkDeducedTemplateParameters(const Expr *E,
llvm::SmallVectorImpl<bool> &Deduced) {
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
if (!E)
return;
- const NonTypeTemplateParmDecl *NTTP
+ const NonTypeTemplateParmDecl *NTTP
= dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl());
if (!NTTP)
return;
@@ -1637,7 +1637,7 @@ MarkDeducedTemplateParameters(const Expr *E,
/// \brief Mark the template parameters that are deduced by the given
/// type.
-static void
+static void
MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
llvm::SmallVectorImpl<bool> &Deduced) {
// Non-dependent types have nothing deducible
@@ -1647,7 +1647,7 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
T = SemaRef.Context.getCanonicalType(T);
switch (T->getTypeClass()) {
case Type::ExtQual:
- MarkDeducedTemplateParameters(SemaRef,
+ MarkDeducedTemplateParameters(SemaRef,
QualType(cast<ExtQualType>(T)->getBaseType(), 0),
Deduced);
break;
@@ -1719,13 +1719,13 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
break;
case Type::TemplateSpecialization: {
- const TemplateSpecializationType *Spec
+ const TemplateSpecializationType *Spec
= cast<TemplateSpecializationType>(T);
if (TemplateDecl *Template = Spec->getTemplateName().getAsTemplateDecl())
- if (TemplateTemplateParmDecl *TTP
+ if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(Template))
Deduced[TTP->getIndex()] = true;
-
+
for (unsigned I = 0, N = Spec->getNumArgs(); I != N; ++I)
MarkDeducedTemplateParameters(SemaRef, Spec->getArg(I), Deduced);
@@ -1754,7 +1754,7 @@ MarkDeducedTemplateParameters(Sema &SemaRef, QualType T,
/// \brief Mark the template parameters that are deduced by this
/// template argument.
-static void
+static void
MarkDeducedTemplateParameters(Sema &SemaRef,
const TemplateArgument &TemplateArg,
llvm::SmallVectorImpl<bool> &Deduced) {
@@ -1762,13 +1762,13 @@ MarkDeducedTemplateParameters(Sema &SemaRef,
case TemplateArgument::Null:
case TemplateArgument::Integral:
break;
-
+
case TemplateArgument::Type:
MarkDeducedTemplateParameters(SemaRef, TemplateArg.getAsType(), Deduced);
break;
case TemplateArgument::Declaration:
- if (TemplateTemplateParmDecl *TTP
+ if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(TemplateArg.getAsDecl()))
Deduced[TTP->getIndex()] = true;
break;
@@ -1791,7 +1791,7 @@ MarkDeducedTemplateParameters(Sema &SemaRef,
/// \param Deduced a bit vector whose elements will be set to \c true
/// to indicate when the corresponding template parameter will be
/// deduced.
-void
+void
Sema::MarkDeducedTemplateParameters(const TemplateArgumentList &TemplateArgs,
llvm::SmallVectorImpl<bool> &Deduced) {
for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I)
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 97b58adb06..912b965507 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -32,22 +32,22 @@ MultiLevelTemplateArgumentList
Sema::getTemplateInstantiationArgs(NamedDecl *D) {
// Accumulate the set of template argument lists in this structure.
MultiLevelTemplateArgumentList Result;
-
+
DeclContext *Ctx = dyn_cast<DeclContext>(D);
if (!Ctx)
Ctx = D->getDeclContext();
-
+
while (!Ctx->isFileContext()) {
// Add template arguments from a class template instantiation.
- if (ClassTemplateSpecializationDecl *Spec
+ if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) {
// We're done when we hit an explicit specialization.
if (Spec->getSpecializationKind() == TSK_ExplicitSpecialization)
break;
-
+
Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs());
- }
-
+ }
+
// Add template arguments from a function template specialization.
else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) {
// FIXME: Check whether this is an explicit specialization.
@@ -67,7 +67,7 @@ Sema::getTemplateInstantiationArgs(NamedDecl *D) {
Ctx = Ctx->getParent();
}
-
+
return Result;
}
@@ -92,7 +92,7 @@ InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
}
}
-Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
+Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
SourceLocation PointOfInstantiation,
TemplateDecl *Template,
const TemplateArgument *TemplateArgs,
@@ -104,7 +104,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
InstantiationRange);
if (!Invalid) {
ActiveTemplateInstantiation Inst;
- Inst.Kind
+ Inst.Kind
= ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation;
Inst.PointOfInstantiation = PointOfInstantiation;
Inst.Entity = reinterpret_cast<uintptr_t>(Template);
@@ -116,7 +116,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
}
}
-Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
+Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
SourceLocation PointOfInstantiation,
FunctionTemplateDecl *FunctionTemplate,
const TemplateArgument *TemplateArgs,
@@ -124,7 +124,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
ActiveTemplateInstantiation::InstantiationKind Kind,
SourceRange InstantiationRange)
: SemaRef(SemaRef) {
-
+
Invalid = CheckInstantiationDepth(PointOfInstantiation,
InstantiationRange);
if (!Invalid) {
@@ -140,7 +140,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
}
}
-Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
+Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
SourceLocation PointOfInstantiation,
ClassTemplatePartialSpecializationDecl *PartialSpec,
const TemplateArgument *TemplateArgs,
@@ -152,7 +152,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
InstantiationRange);
if (!Invalid) {
ActiveTemplateInstantiation Inst;
- Inst.Kind
+ Inst.Kind
= ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution;
Inst.PointOfInstantiation = PointOfInstantiation;
Inst.Entity = reinterpret_cast<uintptr_t>(PartialSpec);
@@ -164,14 +164,14 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
}
}
-Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
+Sema::InstantiatingTemplate::InstantiatingTemplate(Sema &SemaRef,
SourceLocation PointOfInstantation,
ParmVarDecl *Param,
const TemplateArgument *TemplateArgs,
unsigned NumTemplateArgs,
SourceRange InstantiationRange)
: SemaRef(SemaRef) {
-
+
Invalid = CheckInstantiationDepth(PointOfInstantation, InstantiationRange);
if (!Invalid) {
@@ -198,11 +198,11 @@ void Sema::InstantiatingTemplate::Clear() {
bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
SourceLocation PointOfInstantiation,
SourceRange InstantiationRange) {
- if (SemaRef.ActiveTemplateInstantiations.size()
+ if (SemaRef.ActiveTemplateInstantiations.size()
<= SemaRef.getLangOptions().InstantiationDepth)
return false;
- SemaRef.Diag(PointOfInstantiation,
+ SemaRef.Diag(PointOfInstantiation,
diag::err_template_recursion_depth_exceeded)
<< SemaRef.getLangOptions().InstantiationDepth
<< InstantiationRange;
@@ -227,7 +227,7 @@ void Sema::PrintInstantiationStack() {
unsigned DiagID = diag::note_template_member_class_here;
if (isa<ClassTemplateSpecializationDecl>(Record))
DiagID = diag::note_template_class_instantiation_here;
- Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
+ Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
DiagID)
<< Context.getTypeDeclType(Record)
<< Active->InstantiationRange;
@@ -237,7 +237,7 @@ void Sema::PrintInstantiationStack() {
DiagID = diag::note_function_template_spec_here;
else
DiagID = diag::note_template_member_function_here;
- Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
+ Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
DiagID)
<< Function
<< Active->InstantiationRange;
@@ -254,7 +254,7 @@ void Sema::PrintInstantiationStack() {
TemplateDecl *Template = cast<TemplateDecl>((Decl *)Active->Entity);
std::string TemplateArgsStr
= TemplateSpecializationType::PrintTemplateArgumentList(
- Active->TemplateArgs,
+ Active->TemplateArgs,
Active->NumTemplateArgs,
Context.PrintingPolicy);
Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
@@ -265,14 +265,14 @@ void Sema::PrintInstantiationStack() {
}
case ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution: {
- FunctionTemplateDecl *FnTmpl
+ FunctionTemplateDecl *FnTmpl
= cast<FunctionTemplateDecl>((Decl *)Active->Entity);
Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
diag::note_explicit_template_arg_substitution_here)
<< FnTmpl << Active->InstantiationRange;
break;
}
-
+
case ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution:
if (ClassTemplatePartialSpecializationDecl *PartialSpec
= dyn_cast<ClassTemplatePartialSpecializationDecl>(
@@ -293,10 +293,10 @@ void Sema::PrintInstantiationStack() {
case ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation: {
ParmVarDecl *Param = cast<ParmVarDecl>((Decl *)Active->Entity);
FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
-
+
std::string TemplateArgsStr
= TemplateSpecializationType::PrintTemplateArgumentList(
- Active->TemplateArgs,
+ Active->TemplateArgs,
Active->NumTemplateArgs,
Context.PrintingPolicy);
Diags.Report(FullSourceLoc(Active->PointOfInstantiation, SourceMgr),
@@ -305,7 +305,7 @@ void Sema::PrintInstantiationStack() {
<< Active->InstantiationRange;
break;
}
-
+
}
}
}
@@ -324,12 +324,12 @@ bool Sema::isSFINAEContext() const {
// This is a template instantiation, so there is no SFINAE.
return false;
-
+
case ActiveTemplateInstantiation::DefaultTemplateArgumentInstantiation:
// A default template argument instantiation may or may not be a
// SFINAE context; look further up the stack.
break;
-
+
case ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution:
case ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution:
// We're either substitution explicitly-specified template arguments
@@ -345,24 +345,23 @@ bool Sema::isSFINAEContext() const {
// Template Instantiation for Types
//===----------------------------------------------------------------------===/
namespace {
- class VISIBILITY_HIDDEN TemplateInstantiator
- : public TreeTransform<TemplateInstantiator>
- {
+ class VISIBILITY_HIDDEN TemplateInstantiator
+ : public TreeTransform<TemplateInstantiator> {
const MultiLevelTemplateArgumentList &TemplateArgs;
SourceLocation Loc;
DeclarationName Entity;
public:
typedef TreeTransform<TemplateInstantiator> inherited;
-
- TemplateInstantiator(Sema &SemaRef,
+
+ TemplateInstantiator(Sema &SemaRef,
const MultiLevelTemplateArgumentList &TemplateArgs,
SourceLocation Loc,
- DeclarationName Entity)
- : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
+ DeclarationName Entity)
+ : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
Entity(Entity) { }
- /// \brief Determine whether the given type \p T has already been
+ /// \brief Determine whether the given type \p T has already been
/// transformed.
///
/// For the purposes of template instantiation, a type has already been
@@ -370,31 +369,31 @@ namespace {
bool AlreadyTransformed(QualType T) {
return T.isNull() || !T->isDependentType();
}
-
+
/// \brief Returns the location of the entity being instantiated, if known.
SourceLocation getBaseLocation() { return Loc; }
-
+
/// \brief Returns the name of the entity being instantiated, if any.
DeclarationName getBaseEntity() { return Entity; }
-
+
/// \brief Transform the given declaration by instantiating a reference to
/// this declaration.
Decl *TransformDecl(Decl *D);
- /// \brief Transform the definition of the given declaration by
+ /// \brief Transform the definition of the given declaration by
/// instantiating it.
Decl *TransformDefinition(Decl *D);
-
+
/// \brief Rebuild the exception declaration and register the declaration
/// as an instantiated local.
- VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
+ VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
DeclaratorInfo *Declarator,
IdentifierInfo *Name,
SourceLocation Loc, SourceRange TypeRange);
-
+
Sema::OwningExprResult TransformDeclRefExpr(DeclRefExpr *E);
-
- /// \brief Transforms a template type parameter type by performing
+
+ /// \brief Transforms a template type parameter type by performing
/// substitution of the corresponding template type argument.
QualType TransformTemplateTypeParmType(const TemplateTypeParmType *T);
};
@@ -403,28 +402,28 @@ namespace {
Decl *TemplateInstantiator::TransformDecl(Decl *D) {
if (!D)
return 0;
-
+
if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
assert(TemplateArgs(TTP->getDepth(), TTP->getPosition()).getAsDecl() &&
"Wrong kind of template template argument");
- return cast<TemplateDecl>(TemplateArgs(TTP->getDepth(),
+ return cast<TemplateDecl>(TemplateArgs(TTP->getDepth(),
TTP->getPosition()).getAsDecl());
}
-
- // If the corresponding template argument is NULL or non-existent, it's
- // because we are performing instantiation from explicitly-specified
+
+ // If the corresponding template argument is NULL or non-existent, it's
+ // because we are performing instantiation from explicitly-specified
// template arguments in a function template, but there were some
// arguments left unspecified.
- if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
+ if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
TTP->getPosition()))
return D;
-
+
// FIXME: Implement depth reduction of template template parameters
- assert(false &&
+ assert(false &&
"Reducing depth of template template parameters is not yet implemented");
}
-
+
return SemaRef.FindInstantiatedDecl(cast<NamedDecl>(D));
}
@@ -432,17 +431,17 @@ Decl *TemplateInstantiator::TransformDefinition(Decl *D) {
Decl *Inst = getSema().SubstDecl(D, getSema().CurContext, TemplateArgs);
if (!Inst)
return 0;
-
+
getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
return Inst;
}
VarDecl *
TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
- QualType T,
+ QualType T,
DeclaratorInfo *Declarator,
IdentifierInfo *Name,
- SourceLocation Loc,
+ SourceLocation Loc,
SourceRange TypeRange) {
VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, T, Declarator,
Name, Loc, TypeRange);
@@ -451,7 +450,7 @@ TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
return Var;
}
-Sema::OwningExprResult
+Sema::OwningExprResult
TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
// FIXME: Clean this up a bit
NamedDecl *D = E->getDecl();
@@ -460,91 +459,91 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
assert(false && "Cannot reduce non-type template parameter depth yet");
return getSema().ExprError();
}
-
- // If the corresponding template argument is NULL or non-existent, it's
- // because we are performing instantiation from explicitly-specified
+
+ // If the corresponding template argument is NULL or non-existent, it's
+ // because we are performing instantiation from explicitly-specified
// template arguments in a function template, but there were some
// arguments left unspecified.
- if (!TemplateArgs.hasTemplateArgument(NTTP->getDepth(),
+ if (!TemplateArgs.hasTemplateArgument(NTTP->getDepth(),
NTTP->getPosition()))
return SemaRef.Owned(E->Retain());
-
- const TemplateArgument &Arg = TemplateArgs(NTTP->getDepth(),
+
+ const TemplateArgument &Arg = TemplateArgs(NTTP->getDepth(),
NTTP->getPosition());
-
+
// The template argument itself might be an expression, in which
// case we just return that expression.
if (Arg.getKind() == TemplateArgument::Expression)
return SemaRef.Owned(Arg.getAsExpr()->Retain());
-
+
if (Arg.getKind() == TemplateArgument::Declaration) {
ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl());
-
+
VD = cast_or_null<ValueDecl>(getSema().FindInstantiatedDecl(VD));
if (!VD)
return SemaRef.ExprError();
-
- return SemaRef.BuildDeclRefExpr(VD, VD->getType(), E->getLocation(),
+
+ return SemaRef.BuildDeclRefExpr(VD, VD->getType(), E->getLocation(),
/*FIXME:*/false, /*FIXME:*/false);
}
-
+
assert(Arg.getKind() == TemplateArgument::Integral);
QualType T = Arg.getIntegralType();
if (T->isCharType() || T->isWideCharType())
return SemaRef.Owned(new (SemaRef.Context) CharacterLiteral(
Arg.getAsIntegral()->getZExtValue(),
T->isWideCharType(),
- T,
+ T,
E->getSourceRange().getBegin()));
if (T->isBooleanType())
return SemaRef.Owned(new (SemaRef.Context) CXXBoolLiteralExpr(
Arg.getAsIntegral()->getBoolValue(),
- T,
+ T,
E->getSourceRange().getBegin()));
-
+
assert(Arg.getAsIntegral()->getBitWidth() == SemaRef.Context.getIntWidth(T));
return SemaRef.Owned(new (SemaRef.Context) IntegerLiteral(
*Arg.getAsIntegral(),
- T,
+ T,
E->getSourceRange().getBegin()));
}
-
+
NamedDecl *InstD = SemaRef.FindInstantiatedDecl(D);
if (!InstD)
return SemaRef.ExprError();
-
+
// If we instantiated an UnresolvedUsingDecl and got back an UsingDecl,
- // we need to get the underlying decl.
+ // we need to get the underlying decl.
// FIXME: Is this correct? Maybe FindInstantiatedDecl should do this?
InstD = InstD->getUnderlyingDecl();
-
+
// FIXME: nested-name-specifier for QualifiedDeclRefExpr
- return SemaRef.BuildDeclarationNameExpr(E->getLocation(), InstD,
+ return SemaRef.BuildDeclarationNameExpr(E->getLocation(), InstD,
/*FIXME:*/false,
- /*FIXME:*/0,
- /*FIXME:*/false);
+ /*FIXME:*/0,
+ /*FIXME:*/false);
}
-QualType
+QualType
TemplateInstantiator::TransformTemplateTypeParmType(
const TemplateTypeParmType *T) {
if (T->getDepth() < TemplateArgs.getNumLevels()) {
// Replace the template type parameter with its corresponding
// template argument.
-
- // If the corresponding template argument is NULL or doesn't exist, it's
- // because we are performing instantiation from explicitly-specified
- // template arguments in a function template class, but there were some
+
+ // If the corresponding template argument is NULL or doesn't exist, it's
+ // because we are performing instantiation from explicitly-specified
+ // template arguments in a function template class, but there were some
// arguments left unspecified.
if (!TemplateArgs.hasTemplateArgument(T->getDepth(), T->getIndex()))
return QualType(T, 0);
-
- assert(TemplateArgs(T->getDepth(), T->getIndex()).getKind()
+
+ assert(TemplateArgs(T->getDepth(), T->getIndex()).getKind()
== TemplateArgument::Type &&
"Template argument kind mismatch");
return TemplateArgs(T->getDepth(), T->getIndex()).getAsType();
- }
+ }
// The template type parameter comes from an inner template (e.g.,
// the template parameter list of a member template inside the
@@ -584,7 +583,7 @@ TemplateInstantiator::TransformTemplateTypeParmType(
///
/// \returns If the instantiation succeeds, the instantiated
/// type. Otherwise, produces diagnostics and returns a NULL type.
-QualType Sema::SubstType(QualType T,
+QualType Sema::SubstType(QualType T,
const MultiLevelTemplateArgumentList &TemplateArgs,
SourceLocation Loc, DeclarationName Entity) {
assert(!ActiveTemplateInstantiations.empty() &&
@@ -605,13 +604,13 @@ QualType Sema::SubstType(QualType T,
/// Produces a diagnostic and returns true on error, returns false and
/// attaches the instantiated base classes to the class template
/// specialization if successful.
-bool
+bool
Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
CXXRecordDecl *Pattern,
const MultiLevelTemplateArgumentList &TemplateArgs) {
bool Invalid = false;
llvm::SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
- for (ClassTemplateSpecializationDecl::base_class_iterator
+ for (ClassTemplateSpecializationDecl::base_class_iterator
Base = Pattern->bases_begin(), BaseEnd = Pattern->bases_end();
Base != BaseEnd; ++Base) {
if (!Base->getType()->isDependentType()) {
@@ -619,8 +618,8 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
continue;
}
- QualType BaseType = SubstType(Base->getType(),
- TemplateArgs,
+ QualType BaseType = SubstType(Base->getType(),
+ TemplateArgs,
Base->getSourceRange().getBegin(),
DeclarationName());
if (BaseType.isNull()) {
@@ -679,7 +678,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
bool Complain) {
bool Invalid = false;
- CXXRecordDecl *PatternDef
+ CXXRecordDecl *PatternDef
= cast_or_null<CXXRecordDecl>(Pattern->getDefinition(Context));
if (!PatternDef) {
if (!Complain) {
@@ -717,7 +716,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
llvm::SmallVector<DeclPtrTy, 4> Fields;
for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
- MemberEnd = Pattern->decls_end();
+ MemberEnd = Pattern->decls_end();
Member != MemberEnd; ++Member) {
Decl *NewMember = SubstDecl(*Member, Instantiation, TemplateArgs);
if (NewMember) {
@@ -758,7 +757,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
return Invalid;
}
-bool
+bool
Sema::InstantiateClassTemplateSpecialization(
ClassTemplateSpecializationDecl *ClassTemplateSpec,
TemplateSpecializationKind TSK,
@@ -787,14 +786,14 @@ Sema::InstantiateClassTemplateSpecialization(
typedef std::pair<ClassTemplatePartialSpecializationDecl *,
TemplateArgumentList *> MatchResult;
llvm::SmallVector<MatchResult, 4> Matched;
- for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator
+ for (llvm::FoldingSet<ClassTemplatePartialSpecializationDecl>::iterator
Partial = Template->getPartialSpecializations().begin(),
PartialEnd = Template->getPartialSpecializations().end();
Partial != PartialEnd;
++Partial) {
TemplateDeductionInfo Info(Context);
if (TemplateDeductionResult Result
- = DeduceTemplateArguments(&*Partial,
+ = DeduceTemplateArguments(&*Partial,
ClassTemplateSpec->getTemplateArgs(),
Info)) {
// FIXME: Store the failed-deduction information for use in
@@ -820,14 +819,14 @@ Sema::InstantiateClassTemplateSpecialization(
// ambiguous and the program is ill-formed.
// FIXME: Implement partial ordering of class template partial
// specializations.
- Diag(ClassTemplateSpec->getLocation(),
+ Diag(ClassTemplateSpec->getLocation(),
diag::unsup_template_partial_spec_ordering);
// FIXME: Temporary hack to fall back to the primary template
ClassTemplateDecl *OrigTemplate = Template;
while (OrigTemplate->getInstantiatedFromMemberTemplate())
OrigTemplate = OrigTemplate->getInstantiatedFromMemberTemplate();
-
+
Pattern = OrigTemplate->getTemplatedDecl();
} else {
// -- If no matches are found, the instantiation is generated
@@ -835,7 +834,7 @@ Sema::InstantiateClassTemplateSpecialization(
ClassTemplateDecl *OrigTemplate = Template;
while (OrigTemplate->getInstantiatedFromMemberTemplate())
OrigTemplate = OrigTemplate->getInstantiatedFromMemberTemplate();
-
+
Pattern = OrigTemplate->getTemplatedDecl();
}
@@ -843,17 +842,17 @@ Sema::InstantiateClassTemplateSpecialization(
ClassTemplateSpec->setSpecializationKind(TSK);
bool Result = InstantiateClass(ClassTemplateSpec->getLocation(),
- ClassTemplateSpec, Pattern,
+ ClassTemplateSpec, Pattern,
getTemplateInstantiationArgs(ClassTemplateSpec),
TSK,
Complain);
-
+
for (unsigned I = 0, N = Matched.size(); I != N; ++I) {
// FIXME: Implement TemplateArgumentList::Destroy!
// if (Matched[I].first != Pattern)
// Matched[I].second->Destroy(Context);
}
-
+
return Result;
}
@@ -877,7 +876,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
InstantiateStaticDataMemberDefinition(PointOfInstantiation, Var);
} else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(*D)) {
if (!Record->isInjectedClassName() && !Record->getDefinition(Context)) {
- assert(Record->getInstantiatedFromMemberClass() &&
+ assert(Record->getInstantiatedFromMemberClass() &&
"Missing instantiated-from-template information");
InstantiateClass(PointOfInstantiation, Record,
Record->getInstantiatedFromMemberClass(),
@@ -891,7 +890,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
/// \brief Instantiate the definitions of all of the members of the
/// given class template specialization, which was named as part of an
/// explicit instantiation.
-void
+void
Sema::InstantiateClassTemplateSpecializationMembers(
SourceLocation PointOfInstantiation,
ClassTemplateSpecializationDecl *ClassTemplateSpec,
@@ -909,7 +908,7 @@ Sema::InstantiateClassTemplateSpecializationMembers(
TSK);
}
-Sema::OwningStmtResult
+Sema::OwningStmtResult
Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) {
if (!S)
return Owned(S);
@@ -920,11 +919,11 @@ Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) {
return Instantiator.TransformStmt(S);
}
-Sema::OwningExprResult
+Sema::OwningExprResult
Sema::SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs) {
if (!E)
return Owned(E);
-
+
TemplateInstantiator Instantiator(*this, TemplateArgs,
SourceLocation(),
DeclarationName());
@@ -949,7 +948,7 @@ Sema::SubstTemplateName(TemplateName Name, SourceLocation Loc,
return Instantiator.TransformTemplateName(Name);
}
-TemplateArgument Sema::Subst(TemplateArgument Arg,
+TemplateArgument Sema::Subst(TemplateArgument Arg,
const MultiLevelTemplateArgumentList &TemplateArgs) {
TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
DeclarationName());
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index b63fc400a5..f0597be879 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -22,19 +22,19 @@
using namespace clang;
namespace {
- class VISIBILITY_HIDDEN TemplateDeclInstantiator
+ class VISIBILITY_HIDDEN TemplateDeclInstantiator
: public DeclVisitor<TemplateDeclInstantiator, Decl *> {
Sema &SemaRef;
DeclContext *Owner;
const MultiLevelTemplateArgumentList &TemplateArgs;
-
+
public:
typedef Sema::OwningExprResult OwningExprResult;
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,
const MultiLevelTemplateArgumentList &TemplateArgs)
: SemaRef(SemaRef), Owner(Owner), TemplateArgs(TemplateArgs) { }
-
+
// FIXME: Once we get closer to completion, replace these manually-written
// declarations with automatically-generated ones from
// clang/AST/DeclNodes.def.
@@ -60,9 +60,9 @@ namespace {
Decl *VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
Decl *VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
Decl *VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D);
-
+
// Base case. FIXME: Remove once we can instantiate everything.
- Decl *VisitDecl(Decl *) {
+ Decl *VisitDecl(Decl *) {
assert(false && "Template instantiation of unknown declaration kind!");
return 0;
}
@@ -98,14 +98,14 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
bool Invalid = false;
QualType T = D->getUnderlyingType();
if (T->isDependentType()) {
- T = SemaRef.SubstType(T, TemplateArgs,
+ T = SemaRef.SubstType(T, TemplateArgs,
D->getLocation(), D->getDeclName());
if (T.isNull()) {
Invalid = true;
T = SemaRef.Context.IntTy;
}
}
-
+
// Create the new typedef
TypedefDecl *Typedef
= TypedefDecl::Create(SemaRef.Context, Owner, D->getLocation(),
@@ -114,7 +114,7 @@ Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
Typedef->setInvalidDecl();
Owner->addDecl(Typedef);
-
+
return Typedef;
}
@@ -134,32 +134,32 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
Var->setThreadSpecified(D->isThreadSpecified());
Var->setCXXDirectInitializer(D->hasCXXDirectInitializer());
Var->setDeclaredInCondition(D->isDeclaredInCondition());
-
- // If we are instantiating a static data member defined
+
+ // If we are instantiating a static data member defined
// out-of-line, the instantiation will have the same lexical
// context (which will be a namespace scope) as the template.
if (D->isOutOfLine())
Var->setLexicalDeclContext(D->getLexicalDeclContext());
-
+
// FIXME: In theory, we could have a previous declaration for variables that
// are not static data members.
bool Redeclaration = false;
SemaRef.CheckVariableDeclaration(Var, 0, Redeclaration);
-
+
if (D->isOutOfLine()) {
D->getLexicalDeclContext()->addDecl(Var);
Owner->makeDeclVisibleInContext(Var);
} else {
Owner->addDecl(Var);
}
-
+
if (D->getInit()) {
- OwningExprResult Init
+ OwningExprResult Init
= SemaRef.SubstExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
Var->setInvalidDecl();
else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {
- // FIXME: We're faking all of the comma locations, which is suboptimal.
+ // FIXME: We're faking all of the comma locations, which is suboptimal.
// Do we even need these comma locations?
llvm::SmallVector<SourceLocation, 4> FakeCommaLocs;
if (PLE->getNumExprs() > 0) {
@@ -171,16 +171,16 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
}
PLE->getExpr(PLE->getNumExprs() - 1)->Retain();
}
-
+
// Add the direct initializer to the declaration.
SemaRef.AddCXXDirectInitializerToDecl(Sema::DeclPtrTy::make(Var),
- PLE->getLParenLoc(),
+ PLE->getLParenLoc(),
Sema::MultiExprArg(SemaRef,
(void**)PLE->getExprs(),
PLE->getNumExprs()),
FakeCommaLocs.data(),
PLE->getRParenLoc());
-
+
// When Init is destroyed, it will destroy the instantiated ParenListExpr;
// we've explicitly retained all of its subexpressions already.
} else
@@ -193,7 +193,7 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
// which they were instantiated.
if (Var->isStaticDataMember())
SemaRef.Context.setInstantiatedFromStaticDataMember(Var, D);
-
+
return Var;
}
@@ -223,7 +223,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
else if (BitWidth) {
// The bit-width expression is not potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
OwningExprResult InstantiatedBitWidth
= SemaRef.SubstExpr(BitWidth, TemplateArgs);
if (InstantiatedBitWidth.isInvalid()) {
@@ -235,7 +235,7 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
FieldDecl *Field = SemaRef.CheckFieldDecl(D->getDeclName(), T,
D->getDeclaratorInfo(),
- cast<RecordDecl>(Owner),
+ cast<RecordDecl>(Owner),
D->getLocation(),
D->isMutable(),
BitWidth,
@@ -244,15 +244,15 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
0);
if (!Field)
return 0;
-
+
if (Invalid)
Field->setInvalidDecl();
-
+
if (!Field->getDeclName()) {
// Keep track of where this decl came from.
SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
}
-
+
Field->setImplicit(D->isImplicit());
Owner->addDecl(Field);
@@ -282,7 +282,7 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) {
FU = cast<NamedDecl>(NewND);
}
-
+
FriendDecl *FD =
FriendDecl::Create(SemaRef.Context, Owner, D->getLocation(), FU,
D->getFriendLoc());
@@ -293,10 +293,10 @@ Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) {
Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
Expr *AssertExpr = D->getAssertExpr();
-
+
// The expression in a static assertion is not potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
OwningExprResult InstantiatedAssertExpr
= SemaRef.SubstExpr(AssertExpr, TemplateArgs);
if (InstantiatedAssertExpr.isInvalid())
@@ -304,15 +304,15 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
OwningExprResult Message(SemaRef, D->getMessage());
D->getMessage()->Retain();
- Decl *StaticAssert
- = SemaRef.ActOnStaticAssertDeclaration(D->getLocation(),
+ Decl *StaticAssert
+ = SemaRef.ActOnStaticAssertDeclaration(D->getLocation(),
move(InstantiatedAssertExpr),
move(Message)).getAs<Decl>();
return StaticAssert;
}
Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
- EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner,
+ EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner,
D->getLocation(), D->getIdentifier(),
D->getTagKeywordLoc(),
/*PrevDecl=*/0);
@@ -331,9 +331,9 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
OwningExprResult Value = SemaRef.Owned((Expr *)0);
if (Expr *UninstValue = EC->getInitExpr()) {
// The enumerator's value expression is not potentially evaluated.
- EnterExpressionEvaluationContext Unevaluated(SemaRef,
+ EnterExpressionEvaluationContext Unevaluated(SemaRef,
Action::Unevaluated);
-
+
Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
}
@@ -344,7 +344,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
isInvalid = true;
}
- EnumConstantDecl *EnumConst
+ EnumConstantDecl *EnumConst
= SemaRef.CheckEnumConstant(Enum, LastEnumConst,
EC->getLocation(), EC->getIdentifier(),
move(Value));
@@ -361,7 +361,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
LastEnumConst = EnumConst;
}
}
-
+
// FIXME: Fixup LBraceLoc and RBraceLoc
// FIXME: Empty Scope and AttributeList (required to handle attribute packed).
SemaRef.ActOnEnumBody(Enum->getLocation(), SourceLocation(), SourceLocation(),
@@ -380,7 +380,7 @@ Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
TemplateParameterList *TempParams = D->getTemplateParameters();
TemplateParameterList *InstParams = SubstTemplateParams(TempParams);
- if (!InstParams)
+ if (!InstParams)
return NULL;
CXXRecordDecl *Pattern = D->getTemplatedDecl();
@@ -403,23 +403,23 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
Decl *
TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
// FIXME: Dig out the out-of-line definition of this function template?
-
+
TemplateParameterList *TempParams = D->getTemplateParameters();
TemplateParameterList *InstParams = SubstTemplateParams(TempParams);
- if (!InstParams)
+ if (!InstParams)
return NULL;
-
- // FIXME: Handle instantiation of nested function templates that aren't
+
+ // FIXME: Handle instantiation of nested function templates that aren't
// member function templates. This could happen inside a FriendDecl.
assert(isa<CXXMethodDecl>(D->getTemplatedDecl()));
- CXXMethodDecl *InstMethod
+ CXXMethodDecl *InstMethod
= cast_or_null<CXXMethodDecl>(
- VisitCXXMethodDecl(cast<CXXMethodDecl>(D->getTemplatedDecl()),
+ VisitCXXMethodDecl(cast<CXXMethodDecl>(D->getTemplatedDecl()),
InstParams));
if (!InstMethod)
return 0;
- // Link the instantiated function template declaration to the function
+ // Link the instantiated function template declaration to the function
// template from which it was instantiated.
FunctionTemplateDecl *InstTemplate = InstMethod->getDescribedFunctionTemplate();
assert(InstTemplate && "VisitCXXMethodDecl didn't create a template!");
@@ -434,7 +434,7 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
PrevDecl = cast<CXXRecordDecl>(Owner);
CXXRecordDecl *Record
- = CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner,
+ = CXXRecordDecl::Create(SemaRef.Context, D->getTagKind(), Owner,
D->getLocation(), D->getIdentifier(),
D->getTagKeywordLoc(), PrevDecl);
Record->setImplicit(D->isImplicit());
@@ -469,22 +469,22 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {
void *InsertPos = 0;
if (FunctionTemplate) {
llvm::FoldingSetNodeID ID;
- FunctionTemplateSpecializationInfo::Profile(ID,
+ FunctionTemplateSpecializationInfo::Profile(ID,
TemplateArgs.getInnermost().getFlatArgumentList(),
TemplateArgs.getInnermost().flat_size(),
SemaRef.Context);
-
- FunctionTemplateSpecializationInfo *Info
- = FunctionTemplate->getSpecializations().FindNodeOrInsertPos(ID,
+
+ FunctionTemplateSpecializationInfo *Info
+ = FunctionTemplate->getSpecializations().FindNodeOrInsertPos(ID,
InsertPos);
-
+
// If we already have a function template specialization, return it.
if (Info)
return Info->Function;
}
-
+
Sema::LocalInstantiationScope Scope(SemaRef);
-
+
llvm::SmallVector<ParmVarDecl *, 4> Params;
QualType T = SubstFunctionType(D, Params);
if (T.isNull())
@@ -493,12 +493,12 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {
// Build the instantiated method declaration.
DeclContext *DC = SemaRef.FindInstantiatedContext(D->getDeclContext());
FunctionDecl *Function =
- FunctionDecl::Create(SemaRef.Context, DC, D->getLocation(),
+ FunctionDecl::Create(SemaRef.Context, DC, D->getLocation(),
D->getDeclName(), T, D->getDeclaratorInfo(),
D->getStorageClass(),
D->isInline(), D->hasWrittenPrototype());
Function->setLexicalDeclContext(Owner);
-
+
// Attach the parameters
for (unsigned P = 0; P < Params.size(); ++P)
Params[P]->setOwningFunction(Function);
@@ -514,10 +514,10 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D) {
Function->setInstantiationOfMemberFunction(D);
}
-
+
if (InitFunctionInstantiation(Function, D))
Function->setInvalidDecl();
-
+
bool Redeclaration = false;
bool OverloadableAttrRequired = false;
NamedDecl *PrevDecl = 0;
@@ -541,19 +541,19 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
FunctionTemplateDecl *FunctionTemplate = D->getDescribedFunctionTemplate();
void *InsertPos = 0;
if (FunctionTemplate && !TemplateParams) {
- // We are creating a function template specialization from a function
- // template. Check whether there is already a function template
+ // We are creating a function template specialization from a function
+ // template. Check whether there is already a function template
// specialization for this particular set of template arguments.
llvm::FoldingSetNodeID ID;
- FunctionTemplateSpecializationInfo::Profile(ID,
+ FunctionTemplateSpecializationInfo::Profile(ID,
TemplateArgs.getInnermost().getFlatArgumentList(),
TemplateArgs.getInnermost().flat_size(),
SemaRef.Context);
-
- FunctionTemplateSpecializationInfo *Info
- = FunctionTemplate->getSpecializations().FindNodeOrInsertPos(ID,
+
+ FunctionTemplateSpecializationInfo *Info
+ = FunctionTemplate->getSpecializations().FindNodeOrInsertPos(ID,
InsertPos);
-
+
// If we already have a function template specialization, return it.
if (Info)
return Info->Function;
@@ -569,17 +569,17 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
// Build the instantiated method declaration.
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
CXXMethodDecl *Method = 0;
-
+
DeclarationName Name = D->getDeclName();
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
Name = SemaRef.Context.DeclarationNames.getCXXConstructorName(
SemaRef.Context.getCanonicalType(ClassTy));
- Method = CXXConstructorDecl::Create(SemaRef.Context, Record,
- Constructor->getLocation(),
- Name, T,
+ Method = CXXConstructorDecl::Create(SemaRef.Context, Record,
+ Constructor->getLocation(),
+ Name, T,
Constructor->getDeclaratorInfo(),
- Constructor->isExplicit(),
+ Constructor->isExplicit(),
Constructor->isInline(), false);
} else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
QualType ClassTy = SemaRef.Context.getTypeDeclType(Record);
@@ -589,7 +589,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
Destructor->getLocation(), Name,
T, Destructor->isInline(), false);
} else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) {
- CanQualType ConvTy
+ CanQualType ConvTy
= SemaRef.Context.getCanonicalType(
T->getAsFunctionType()->getResultType());
Name = SemaRef.Context.DeclarationNames.getCXXConversionFunctionName(
@@ -597,10 +597,10 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
Method = CXXConversionDecl::Create(SemaRef.Context, Record,
Conversion->getLocation(), Name,
T, Conversion->getDeclaratorInfo(),
- Conversion->isInline(),
+ Conversion->isInline(),
Conversion->isExplicit());
} else {
- Method = CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(),
+ Method = CXXMethodDecl::Create(SemaRef.Context, Record, D->getLocation(),
D->getDeclName(), T, D->getDeclaratorInfo(),
D->isStatic(), D->isInline());
}
@@ -608,7 +608,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
if (TemplateParams) {
// Our resulting instantiation is actually a function template, since we
// are substituting only the outer template parameters. For example, given
- //
+ //
// template<typename T>
// struct X {
// template<typename U> void f(T, U);
@@ -621,20 +621,20 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
// Build the function template itself.
FunctionTemplate = FunctionTemplateDecl::Create(SemaRef.Context, Record,
Method->getLocation(),
- Method->getDeclName(),
+ Method->getDeclName(),
TemplateParams, Method);
if (D->isOutOfLine())
- FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext());
+ FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext());
Method->setDescribedFunctionTemplate(FunctionTemplate);
} else if (!FunctionTemplate)
Method->setInstantiationOfMemberFunction(D);
- // If we are instantiating a member function defined
+ // If we are instantiating a member function defined
// out-of-line, the instantiation will have the same lexical
// context (which will be a namespace scope) as the template.
if (D->isOutOfLine())
Method->setLexicalDeclContext(D->getLexicalDeclContext());
-
+
// Attach the parameters
for (unsigned P = 0; P < Params.size(); ++P)
Params[P]->setOwningFunction(Method);
@@ -644,11 +644,11 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
Method->setInvalidDecl();
NamedDecl *PrevDecl = 0;
-
+
if (!FunctionTemplate || TemplateParams) {
- PrevDecl = SemaRef.LookupQualifiedName(Owner, Name,
+ PrevDecl = SemaRef.LookupQualifiedName(Owner, Name,
Sema::LookupOrdinaryName, true);
-
+
// In C++, the previous declaration we find might be a tag type
// (class or enum). In this case, the new declaration will hide the
// tag type. Note that this does does not apply if we're declaring a
@@ -663,7 +663,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
FunctionTemplate,
&TemplateArgs.getInnermost(),
InsertPos);
-
+
bool Redeclaration = false;
bool OverloadableAttrRequired = false;
SemaRef.CheckFunctionDeclaration(Method, PrevDecl, Redeclaration,
@@ -671,7 +671,7 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
if (!FunctionTemplate && (!Method->isInvalidDecl() || !PrevDecl))
Owner->addDecl(Method);
-
+
return Method;
}
@@ -702,7 +702,7 @@ ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
D->getIdentifier(), T, D->getDeclaratorInfo(),
D->getStorageClass(), 0);
else
- Param = OriginalParmVarDecl::Create(SemaRef.Context, Owner,
+ Param = OriginalParmVarDecl::Create(SemaRef.Context, Owner,
D->getLocation(), D->getIdentifier(),
T, D->getDeclaratorInfo(), OrigT,
D->getStorageClass(), 0);
@@ -710,7 +710,7 @@ ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
// Mark the default argument as being uninstantiated.
if (Expr *Arg = D->getDefaultArg())
Param->setUninstantiatedDefaultArg(Arg);
-
+
// Note: we don't try to instantiate function parameters until after
// we've instantiated the function's type. Therefore, we don't have
// to check for 'void' parameter types here.
@@ -733,7 +733,7 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
const Type* T = D->getTypeForDecl();
assert(T->isTemplateTypeParmType());
const TemplateTypeParmType *TTPT = T->getAs<TemplateTypeParmType>();
-
+
TemplateTypeParmDecl *Inst =
TemplateTypeParmDecl::Create(SemaRef.Context, Owner, D->getLocation(),
TTPT->getDepth(), TTPT->getIndex(),
@@ -747,7 +747,7 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
= SemaRef.SubstType(DefaultPattern, TemplateArgs,
D->getDefaultArgumentLoc(),
D->getDeclName());
-
+
Inst->setDefaultArgument(DefaultInst,
D->getDefaultArgumentLoc(),
D->defaultArgumentWasInherited() /* preserve? */);
@@ -758,23 +758,23 @@ Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
Decl *
TemplateDeclInstantiator::VisitUnresolvedUsingDecl(UnresolvedUsingDecl *D) {
- NestedNameSpecifier *NNS =
- SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameSpecifier(),
- D->getTargetNestedNameRange(),
+ NestedNameSpecifier *NNS =
+ SemaRef.SubstNestedNameSpecifier(D->getTargetNestedNameSpecifier(),
+ D->getTargetNestedNameRange(),
TemplateArgs);
if (!NNS)
return 0;
-
+
CXXScopeSpec SS;
SS.setRange(D->getTargetNestedNameRange());
SS.setScopeRep(NNS);
-
- NamedDecl *UD =
- SemaRef.BuildUsingDeclaration(D->getLocation(), SS,
- D->getTargetNameLocation(),
+
+ NamedDecl *UD =
+ SemaRef.BuildUsingDeclaration(D->getLocation(), SS,
+ D->getTargetNameLocation(),
D->getTargetName(), 0, D->isTypeName());
if (UD)
- SemaRef.Context.setInstantiatedFromUnresolvedUsingDecl(cast<UsingDecl>(UD),
+ SemaRef.Context.setInstantiatedFromUnresolvedUsingDecl(cast<UsingDecl>(UD),
D);
return UD;
}
@@ -821,7 +821,7 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {
L->getLAngleLoc(), &Params.front(), N,
L->getRAngleLoc());
return InstL;
-}
+}
/// \brief Does substitution on the type of the given function, including
/// all of the function parameters.
@@ -832,7 +832,7 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {
/// \returns the instantiated function's type if successful, a NULL
/// type if there was an error.
-QualType
+QualType
TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
llvm::SmallVectorImpl<ParmVarDecl *> &Params) {
bool InvalidDecl = false;
@@ -840,14 +840,14 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
// Substitute all of the function's formal parameter types.
TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
llvm::SmallVector<QualType, 4> ParamTys;
- for (FunctionDecl::param_iterator P = D->param_begin(),
+ for (FunctionDecl::param_iterator P = D->param_begin(),
PEnd = D->param_end();
P != PEnd; ++P) {
if (ParmVarDecl *PInst = ParamInstantiator.VisitParmVarDecl(*P)) {
if (PInst->getType()->isVoidType()) {
SemaRef.Diag(PInst->getLocation(), diag::err_param_with_void_type);
PInst->setInvalidDecl();
- } else if (SemaRef.RequireNonAbstractType(PInst->getLocation(),
+ } else if (SemaRef.RequireNonAbstractType(PInst->getLocation(),
PInst->getType(),
diag::err_abstract_type_in_decl,
Sema::AbstractParamType))
@@ -858,7 +858,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
if (PInst->isInvalidDecl())
InvalidDecl = true;
- } else
+ } else
InvalidDecl = true;
}
@@ -868,7 +868,7 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
assert(Proto && "Missing prototype?");
- QualType ResultType
+ QualType ResultType
= SemaRef.SubstType(Proto->getResultType(), TemplateArgs,
D->getLocation(), D->getDeclName());
if (ResultType.isNull())
@@ -879,21 +879,21 @@ TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
D->getLocation(), D->getDeclName());
}
-/// \brief Initializes the common fields of an instantiation function
+/// \brief Initializes the common fields of an instantiation function
/// declaration (New) from the corresponding fields of its template (Tmpl).
///
/// \returns true if there was an error
-bool
-TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
+bool
+TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
FunctionDecl *Tmpl) {
if (Tmpl->isDeleted())
New->setDeleted();
-
+
// If we are performing substituting explicitly-specified template arguments
// or deduced template arguments into a function template and we reach this
// point, we are now past the point where SFINAE applies and have committed
- // to keeping the new function template specialization. We therefore
- // convert the active template instantiation for the function template
+ // to keeping the new function template specialization. We therefore
+ // convert the active template instantiation for the function template
// into a template instantiation for this specific function template
// specialization, which is not a SFINAE context, so that we diagnose any
// further errors in the declaration itself.
@@ -901,16 +901,16 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
ActiveInstType &ActiveInst = SemaRef.ActiveTemplateInstantiations.back();
if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
- if (FunctionTemplateDecl *FunTmpl
+ if (FunctionTemplateDecl *FunTmpl
= dyn_cast<FunctionTemplateDecl>((Decl *)ActiveInst.Entity)) {
- assert(FunTmpl->getTemplatedDecl() == Tmpl &&
+ assert(FunTmpl->getTemplatedDecl() == Tmpl &&
"Deduction from the wrong function template?");
(void) FunTmpl;
ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
ActiveInst.Entity = reinterpret_cast<uintptr_t>(New);
}
}
-
+
return false;
}
@@ -919,12 +919,12 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New,
/// (Tmpl).
///
/// \returns true if there was an error
-bool
-TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New,
+bool
+TemplateDeclInstantiator::InitMethodInstantiation(CXXMethodDecl *New,
CXXMethodDecl *Tmpl) {
if (InitFunctionInstantiation(New, Tmpl))
return true;
-
+
CXXRecordDecl *Record = cast<CXXRecordDecl>(Owner);
New->setAccess(Tmpl->getAccess());
if (Tmpl->isVirtualAsWritten()) {
@@ -964,15 +964,15 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
return;
assert(!Function->getBody() && "Already instantiated!");
-
+
// Find the function body that we'll be substituting.
const FunctionDecl *PatternDecl = 0;
if (FunctionTemplateDecl *Primary = Function->getPrimaryTemplate()) {
while (Primary->getInstantiatedFromMemberTemplate())
Primary = Primary->getInstantiatedFromMemberTemplate();
-
+
PatternDecl = Primary->getTemplatedDecl();
- } else
+ } else
PatternDecl = Function->getInstantiatedFromMemberFunction();
Stmt *Pattern = 0;
if (PatternDecl)
@@ -983,13 +983,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
// C++0x [temp.explicit]p9:
// Except for inline functions, other explicit instantiation declarations
- // have the effect of suppressing the implicit instantiation of the entity
+ // have the effect of suppressing the implicit instantiation of the entity
// to which they refer.
- if (Function->getTemplateSpecializationKind()
+ if (Function->getTemplateSpecializationKind()
== TSK_ExplicitInstantiationDeclaration &&
PatternDecl->isOutOfLine() && !PatternDecl->isInline())
return;
-
+
InstantiatingTemplate Inst(*this, PointOfInstantiation, Function);
if (Inst)
return;
@@ -1000,13 +1000,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
std::deque<PendingImplicitInstantiation> SavedPendingImplicitInstantiations;
if (Recursive)
PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations);
-
+
ActOnStartOfFunctionDef(0, DeclPtrTy::make(Function));
// Introduce a new scope where local variable instantiations will be
// recorded.
LocalInstantiationScope Scope(*this);
-
+
// Introduce the instantiated function parameters into the local
// instantiation scope.
for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I)
@@ -1018,32 +1018,32 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
DeclContext *PreviousContext = CurContext;
CurContext = Function;
- MultiLevelTemplateArgumentList TemplateArgs =
+ MultiLevelTemplateArgumentList TemplateArgs =
getTemplateInstantiationArgs(Function);
// If this is a constructor, instantiate the member initializers.
- if (const CXXConstructorDecl *Ctor =
+ if (const CXXConstructorDecl *Ctor =
dyn_cast<CXXConstructorDecl>(PatternDecl)) {
InstantiateMemInitializers(cast<CXXConstructorDecl>(Function), Ctor,
TemplateArgs);
- }
-
+ }
+
// Instantiate the function body.
OwningStmtResult Body = SubstStmt(Pattern, TemplateArgs);
- ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body),
+ ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body),
/*IsInstantiation=*/true);
CurContext = PreviousContext;
DeclGroupRef DG(Function);
Consumer.HandleTopLevelDecl(DG);
-
+
if (Recursive) {
// Instantiate any pending implicit instantiations found during the
- // instantiation of this template.
+ // instantiation of this template.
PerformPendingImplicitInstantiations();
-
+
// Restore the set of pending implicit instantiations.
PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations);
}
@@ -1067,14 +1067,14 @@ void Sema::InstantiateStaticDataMemberDefinition(
bool Recursive) {
if (Var->isInvalidDecl())
return;
-
+
// Find the out-of-line definition of this static data member.
// FIXME: Do we have to look for specializations separately?
VarDecl *Def = Var->getInstantiatedFromStaticDataMember();
bool FoundOutOfLineDef = false;
assert(Def && "This data member was not instantiated from a template?");
- assert(Def->isStaticDataMember() && "Not a static data member?");
- for (VarDecl::redecl_iterator RD = Def->redecls_begin(),
+ assert(Def->isStaticDataMember() && "Not a static data member?");
+ for (VarDecl::redecl_iterator RD = Def->redecls_begin(),
RDEnd = Def->redecls_end();
RD != RDEnd; ++RD) {
if (RD->getLexicalDeclContext()->isFileContext()) {
@@ -1082,58 +1082,58 @@ void Sema::InstantiateStaticDataMemberDefinition(
FoundOutOfLineDef = true;
}
}
-
+
if (!FoundOutOfLineDef) {
// We did not find an out-of-line definition of this static data member,
// so we won't perform any instantiation. Rather, we rely on the user to
- // instantiate this definition (or provide a specialization for it) in
- // another translation unit.
+ // instantiate this definition (or provide a specialization for it) in
+ // another translation unit.
return;
}
// FIXME: extern templates
-
+
InstantiatingTemplate Inst(*this, PointOfInstantiation, Var);
if (Inst)
return;
-
+
// If we're performing recursive template instantiation, create our own
// queue of pending implicit instantiations that we will instantiate later,
// while we're still within our own instantiation context.
std::deque<PendingImplicitInstantiation> SavedPendingImplicitInstantiations;
if (Recursive)
PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations);
-
+
// Enter the scope of this instantiation. We don't use
// PushDeclContext because we don't have a scope.
DeclContext *PreviousContext = CurContext;
CurContext = Var->getDeclContext();
-
+
Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->getDeclContext(),
getTemplateInstantiationArgs(Var)));
-
+
CurContext = PreviousContext;
if (Var) {
DeclGroupRef DG(Var);
Consumer.HandleTopLevelDecl(DG);
}
-
+
if (Recursive) {
// Instantiate any pending implicit instantiations found during the
- // instantiation of this template.
+ // instantiation of this template.
PerformPendingImplicitInstantiations();
-
+
// Restore the set of pending implicit instantiations.
PendingImplicitInstantiations.swap(SavedPendingImplicitInstantiations);
- }
+ }
}
void
Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
const CXXConstructorDecl *Tmpl,
const MultiLevelTemplateArgumentList &TemplateArgs) {
-
+
llvm::SmallVector<MemInitTy*, 4> NewInits;
// Instantiate all the initializers.
@@ -1143,7 +1143,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
CXXBaseOrMemberInitializer *Init = *Inits;
ASTOwningVector<&ActionBase::DeleteExpr> NewArgs(*this);
-
+
// Instantiate all the arguments.
for (ExprIterator Args = Init->arg_begin(), ArgsEnd = Init->arg_end();
Args != ArgsEnd; ++Args) {
@@ -1163,21 +1163,21 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
New->getDeclName());
NewInit = BuildBaseInitializer(BaseType,
- (Expr **)NewArgs.data(),
+ (Expr **)NewArgs.data(),
NewArgs.size(),
Init->getSourceLocation(),
Init->getRParenLoc(),
New->getParent());
} else if (Init->isMemberInitializer()) {
FieldDecl *Member;
-
+
// Is this an anonymous union?
if (FieldDecl *UnionInit = Init->getAnonUnionMember())
Member = cast<FieldDecl>(FindInstantiatedDecl(UnionInit));
else
Member = cast<FieldDecl>(FindInstantiatedDecl(Init->getMember()));
-
- NewInit = BuildMemberInitializer(Member, (Expr **)NewArgs.data(),
+
+ NewInit = BuildMemberInitializer(Member, (Expr **)NewArgs.data(),
NewArgs.size(),
Init->getSourceLocation(),
Init->getRParenLoc());
@@ -1188,16 +1188,16 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
else {
// FIXME: It would be nice if ASTOwningVector had a release function.
NewArgs.take();
-
+
NewInits.push_back((MemInitTy *)NewInit.get());
}
}
-
+
// Assign all the initializers to the new constructor.
- ActOnMemInitializers(DeclPtrTy::make(New),
+ ActOnMemInitializers(DeclPtrTy::make(New),
/*FIXME: ColonLoc */
SourceLocation(),
- NewInits.data(), NewInits.size());
+ NewInits.data(), NewInits.size());
}
// TODO: this could be templated if the various decl types used the
@@ -1285,10 +1285,10 @@ static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) {
return false;
}
-
+
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Other))
return isInstantiationOf(cast<CXXRecordDecl>(D), Record);
-
+
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Other))
return isInstantiationOf(cast<FunctionDecl>(D), Function);
@@ -1305,17 +1305,17 @@ static bool isInstantiationOf(ASTContext &Ctx, NamedDecl *D, Decl *Other) {
if (FieldDecl *Field = dyn_cast<FieldDecl>(Other)) {
if (!Field->getDeclName()) {
// This is an unnamed field.
- return Ctx.getInstantiatedFromUnnamedFieldDecl(Field) ==
+ return Ctx.getInstantiatedFromUnnamedFieldDecl(Field) ==
cast<FieldDecl>(D);
}
}
-
+
return D->getDeclName() && isa<NamedDecl>(Other) &&
D->getDeclName() == cast<NamedDecl>(Other)->getDeclName();
}
template<typename ForwardIterator>
-static NamedDecl *findInstantiationOf(ASTContext &Ctx,
+static NamedDecl *findInstantiationOf(ASTContext &Ctx,
NamedDecl *D,
ForwardIterator first,
ForwardIterator last) {
@@ -1366,19 +1366,19 @@ DeclContext *Sema::FindInstantiatedContext(DeclContext* DC) {
NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D) {
if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
// Transform all of the elements of the overloaded function set.
- OverloadedFunctionDecl *Result
+ OverloadedFunctionDecl *Result
= OverloadedFunctionDecl::Create(Context, CurContext, Ovl->getDeclName());
-
+
for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
FEnd = Ovl->function_end();
F != FEnd; ++F) {
Result->addOverload(
AnyFunctionDecl::getFromNamedDecl(FindInstantiatedDecl(*F)));
}
-
+
return Result;
- }
-
+ }
+
DeclContext *ParentDC = D->getDeclContext();
if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) {
// D is a local of some kind. Look into the map of local
@@ -1387,7 +1387,7 @@ NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D) {
}
if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D))
- if (ClassTemplateDecl *ClassTemplate
+ if (ClassTemplateDecl *ClassTemplate
= Record->getDescribedClassTemplate()) {
// When the declaration D was parsed, it referred to the current
// instantiation. Therefore, look through the current context,
@@ -1396,22 +1396,22 @@ NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D) {
// to. Alternatively, we could just instantiate the
// injected-class-name with the current template arguments, but
// such an instantiation is far more expensive.
- for (DeclContext *DC = CurContext; !DC->isFileContext();
+ for (DeclContext *DC = CurContext; !DC->isFileContext();
DC = DC->getParent()) {
- if (ClassTemplateSpecializationDecl *Spec
+ if (ClassTemplateSpecializationDecl *Spec
= dyn_cast<ClassTemplateSpecializationDecl>(DC))
if (isInstantiationOf(ClassTemplate, Spec->getSpecializedTemplate()))
return Spec;
}
- assert(false &&
+ assert(false &&
"Unable to find declaration for the current instantiation");
}
ParentDC = FindInstantiatedContext(ParentDC);
- if (!ParentDC)
+ if (!ParentDC)
return 0;
-
+
if (ParentDC != D->getDeclContext()) {
// We performed some kind of instantiation in the parent context,
// so now we need to look into the instantiated parent context to
@@ -1429,11 +1429,11 @@ NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D) {
// - unnamed class/struct/union/enum within a template
//
// FIXME: Find a better way to find these instantiations!
- Result = findInstantiationOf(Context, D,
+ Result = findInstantiationOf(Context, D,
ParentDC->decls_begin(),
ParentDC->decls_end());
}
-
+
assert(Result && "Unable to find instantiation of declaration!");
D = Result;
}
@@ -1441,35 +1441,35 @@ NamedDecl *Sema::FindInstantiatedDecl(NamedDecl *D) {
return D;
}
-/// \brief Performs template instantiation for all implicit template
+/// \brief Performs template instantiation for all implicit template
/// instantiations we have seen until this point.
void Sema::PerformPendingImplicitInstantiations() {
while (!PendingImplicitInstantiations.empty()) {
PendingImplicitInstantiation Inst = PendingImplicitInstantiations.front();
PendingImplicitInstantiations.pop_front();
-
+
// Instantiate function definitions
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) {
- PrettyStackTraceActionsDecl CrashInfo(DeclPtrTy::make(Function),
+ PrettyStackTraceActionsDecl CrashInfo(DeclPtrTy::make(Function),
Function->getLocation(), *this,
Context.getSourceManager(),
"instantiating function definition");
-
+
if (!Function->getBody())
InstantiateFunctionDefinition(/*FIXME:*/Inst.second, Function, true);
continue;
}
-
+
// Instantiate static data member definitions.
VarDecl *Var = cast<VarDecl>(Inst.first);
assert(Var->isStaticDataMember() && "Not a static data member?");
- PrettyStackTraceActionsDecl CrashInfo(DeclPtrTy::make(Var),
+ PrettyStackTraceActionsDecl CrashInfo(DeclPtrTy::make(Var),
Var->getLocation(), *this,
Context.getSourceManager(),
"instantiating static data member "
"definition");
-
+
InstantiateStaticDataMemberDefinition(/*FIXME:*/Inst.second, Var, true);
}
}
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index b6db829de6..c4064e135e 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -26,8 +26,8 @@ using namespace clang;
/// \brief Perform adjustment on the parameter type of a function.
///
/// This routine adjusts the given parameter type @p T to the actual
-/// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
-/// C++ [dcl.fct]p3). The adjusted parameter type is returned.
+/// parameter type used by semantic analysis (C99 6.7.5.3p[7,8],
+/// C++ [dcl.fct]p3). The adjusted parameter type is returned.
QualType Sema::adjustParameterType(QualType T) {
// C99 6.7.5.3p7:
if (T->isArrayType()) {
@@ -59,7 +59,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
// FIXME: Should move the logic from DeclSpec::Finish to here for validity
// checking.
QualType Result;
-
+
switch (DS.getTypeSpecType()) {
case DeclSpec::TST_void:
Result = Context.VoidTy;
@@ -103,12 +103,12 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
case DeclSpec::TST_unspecified:
// "<proto1,proto2>" is an objc qualified ID with a missing id.
if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
- Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
break;
}
-
+
// Unspecified typespec defaults to int in C90. However, the C90 grammar
// [C90 6.5] only allows a decl-spec if there was *some* type-specifier,
// type-qualifier, or storage-class-specifier. If not, emit an extwarn.
@@ -139,7 +139,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
if (getLangOptions().CPlusPlus && !getLangOptions().Microsoft) {
Diag(DeclLoc, diag::err_missing_type_specifier)
<< DS.getSourceRange();
-
+
// When this occurs in C++ code, often something is very broken with the
// value being declared, poison it as invalid so we don't get chains of
// errors.
@@ -149,8 +149,8 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
<< DS.getSourceRange();
}
}
-
- // FALL THROUGH.
+
+ // FALL THROUGH.
case DeclSpec::TST_int: {
if (DS.getTypeSpecSign() != DeclSpec::TSS_unsigned) {
switch (DS.getTypeSpecWidth()) {
@@ -202,11 +202,11 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
= TagDecl::getTagKindForTypeSpec(DS.getTypeSpecType());
Result = Context.getElaboratedType(Result, Tag);
}
-
+
if (D->isInvalidDecl())
isInvalid = true;
break;
- }
+ }
case DeclSpec::TST_typename: {
assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
DS.getTypeSpecSign() == 0 &&
@@ -218,7 +218,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
// It would be nice if protocol qualifiers were only stored with the
// ObjCObjectPointerType. Unfortunately, this isn't possible due
// to the following typedef idiom (which is uncommon, but allowed):
- //
+ //
// typedef Foo<P> T;
// static void func() {
// Foo<P> *yy;
@@ -229,13 +229,13 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
DS.getNumProtocolQualifiers());
else if (Result->isObjCIdType())
// id<protocol-list>
- Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
else if (Result->isObjCClassType()) {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
// Class<protocol-list>
- Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy,
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy,
(ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
} else {
if (DeclLoc.isInvalid())
@@ -245,12 +245,12 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
isInvalid = true;
}
}
-
+
// If this is a reference to an invalid typedef, propagate the invalidity.
if (TypedefType *TDT = dyn_cast<TypedefType>(Result))
if (TDT->getDecl()->isInvalidDecl())
isInvalid = true;
-
+
// TypeQuals handled by caller.
break;
}
@@ -284,28 +284,28 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
Result = Context.UndeducedAutoTy;
break;
}
-
+
case DeclSpec::TST_error:
Result = Context.IntTy;
isInvalid = true;
break;
}
-
+
// Handle complex types.
if (DS.getTypeSpecComplex() == DeclSpec::TSC_complex) {
if (getLangOptions().Freestanding)
Diag(DS.getTypeSpecComplexLoc(), diag::ext_freestanding_complex);
Result = Context.getComplexType(Result);
}
-
+
assert(DS.getTypeSpecComplex() != DeclSpec::TSC_imaginary &&
"FIXME: imaginary types not supported yet!");
-
+
// See if there are any attributes on the declspec that apply to the type (as
// opposed to the decl).
if (const AttributeList *AL = DS.getAttributes())
ProcessTypeAttributeList(Result, AL);
-
+
// Apply const/volatile/restrict qualifiers to T.
if (unsigned TypeQuals = DS.getTypeQualifiers()) {
@@ -314,10 +314,10 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
// restrict-qualified references.
if (TypeQuals & QualType::Restrict) {
if (Result->isPointerType() || Result->isReferenceType()) {
- QualType EltTy = Result->isPointerType() ?
+ QualType EltTy = Result->isPointerType() ?
Result->getAs<PointerType>()->getPointeeType() :
Result->getAs<ReferenceType>()->getPointeeType();
-
+
// If we have a pointer or reference, the pointee must have an object
// incomplete type.
if (!EltTy->isIncompleteOrObjectType()) {
@@ -333,7 +333,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier.
}
}
-
+
// Warn about CV qualifiers on functions: C99 6.7.3p8: "If the specification
// of a function type includes any type qualifiers, the behavior is
// undefined."
@@ -350,7 +350,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
Diag(Loc, diag::warn_typecheck_function_qualifiers)
<< Result << DS.getSourceRange();
}
-
+
// C++ [dcl.ref]p1:
// Cv-qualified references are ill-formed except when the
// cv-qualifiers are introduced through the use of a typedef
@@ -361,8 +361,8 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
TypeQuals && Result->isReferenceType()) {
TypeQuals &= ~QualType::Const;
TypeQuals &= ~QualType::Volatile;
- }
-
+ }
+
Result = Result.getQualifiedType(TypeQuals);
}
return Result;
@@ -371,7 +371,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
static std::string getPrintableNameForEntity(DeclarationName Entity) {
if (Entity)
return Entity.getAsString();
-
+
return "type name";
}
@@ -390,7 +390,7 @@ static std::string getPrintableNameForEntity(DeclarationName Entity) {
///
/// \returns A suitable pointer type, if there are no
/// errors. Otherwise, returns a NULL type.
-QualType Sema::BuildPointerType(QualType T, unsigned Quals,
+QualType Sema::BuildPointerType(QualType T, unsigned Quals,
SourceLocation Loc, DeclarationName Entity) {
if (T->isReferenceType()) {
// C++ 8.3.2p4: There shall be no ... pointers to references ...
@@ -441,7 +441,7 @@ QualType Sema::BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
}
if (T->isReferenceType()) {
// C++ [dcl.ref]p4: There shall be no references to references.
- //
+ //
// According to C++ DR 106, references to references are only
// diagnosed when they are written directly (e.g., "int & &"),
// but not when they happen via a typedef:
@@ -495,8 +495,8 @@ QualType Sema::BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
/// \param T The type of each element in the array.
///
/// \param ASM C99 array size modifier (e.g., '*', 'static').
-///
-/// \param ArraySize Expression describing the size of the array.
+///
+/// \param ArraySize Expression describing the size of the array.
///
/// \param Quals The cvr-qualifiers to be applied to the array's
/// element type.
@@ -514,9 +514,9 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
Expr *ArraySize, unsigned Quals,
SourceRange Brackets, DeclarationName Entity) {
SourceLocation Loc = Brackets.getBegin();
- // C99 6.7.5.2p1: If the element type is an incomplete or function type,
+ // C99 6.7.5.2p1: If the element type is an incomplete or function type,
// reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
- if (RequireCompleteType(Loc, T,
+ if (RequireCompleteType(Loc, T,
diag::err_illegal_decl_array_incomplete_type))
return QualType();
@@ -525,20 +525,20 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
<< getPrintableNameForEntity(Entity);
return QualType();
}
-
+
// C++ 8.3.2p4: There shall be no ... arrays of references ...
if (T->isReferenceType()) {
Diag(Loc, diag::err_illegal_decl_array_of_references)
<< getPrintableNameForEntity(Entity);
return QualType();
- }
+ }
if (Context.getCanonicalType(T) == Context.UndeducedAutoTy) {
- Diag(Loc, diag::err_illegal_decl_array_of_auto)
+ Diag(Loc, diag::err_illegal_decl_array_of_auto)
<< getPrintableNameForEntity(Entity);
return QualType();
}
-
+
if (const RecordType *EltTy = T->getAs<RecordType>()) {
// If the element type is a struct or union that contains a variadic
// array, accept it as a GNU extension: C99 6.7.2.1p2.
@@ -548,7 +548,7 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
Diag(Loc, diag::err_objc_array_of_interfaces) << T;
return QualType();
}
-
+
// C99 6.7.5.2p1: The size expression shall have integer type.
if (ArraySize && !ArraySize->isTypeDependent() &&
!ArraySize->getType()->isIntegerType()) {
@@ -584,14 +584,14 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
Diag(ArraySize->getLocStart(), diag::ext_typecheck_zero_array_size)
<< ArraySize->getSourceRange();
}
- }
+ }
T = Context.getConstantArrayWithExprType(T, ConstVal, ArraySize,
ASM, Quals, Brackets);
}
// If this is not C99, extwarn about VLA's and C99 array size modifiers.
if (!getLangOptions().C99) {
- if (ArraySize && !ArraySize->isTypeDependent() &&
- !ArraySize->isValueDependent() &&
+ if (ArraySize && !ArraySize->isTypeDependent() &&
+ !ArraySize->isValueDependent() &&
!ArraySize->isIntegerConstantExpr(Context))
Diag(Loc, diag::ext_vla);
else if (ASM != ArrayType::Normal || Quals != 0)
@@ -604,14 +604,14 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
/// \brief Build an ext-vector type.
///
/// Run the required checks for the extended vector type.
-QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
+QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
SourceLocation AttrLoc) {
Expr *Arg = (Expr *)ArraySize.get();
// unlike gcc's vector_size attribute, we do not allow vectors to be defined
// in conjunction with complex types (pointers, arrays, functions, etc.).
- if (!T->isDependentType() &&
+ if (!T->isDependentType() &&
!T->isIntegerType() && !T->isRealFloatingType()) {
Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T;
return QualType();
@@ -624,25 +624,25 @@ QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
<< "ext_vector_type" << Arg->getSourceRange();
return QualType();
}
-
- // unlike gcc's vector_size attribute, the size is specified as the
+
+ // unlike gcc's vector_size attribute, the size is specified as the
// number of elements, not the number of bytes.
- unsigned vectorSize = static_cast<unsigned>(vecSize.getZExtValue());
-
+ unsigned vectorSize = static_cast<unsigned>(vecSize.getZExtValue());
+
if (vectorSize == 0) {
Diag(AttrLoc, diag::err_attribute_zero_size)
<< Arg->getSourceRange();
return QualType();
}
-
+
if (!T->isDependentType())
return Context.getExtVectorType(T, vectorSize);
- }
-
- return Context.getDependentSizedExtVectorType(T, ArraySize.takeAs<Expr>(),
+ }
+
+ return Context.getDependentSizedExtVectorType(T, ArraySize.takeAs<Expr>(),
AttrLoc);
}
-
+
/// \brief Build a function type.
///
/// This routine checks the function type according to C++ rules and
@@ -673,7 +673,7 @@ QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
/// \returns A suitable function type, if there are no
/// errors. Otherwise, returns a NULL type.
QualType Sema::BuildFunctionType(QualType T,
- QualType *ParamTypes,
+ QualType *ParamTypes,
unsigned NumParamTypes,
bool Variadic, unsigned Quals,
SourceLocation Loc, DeclarationName Entity) {
@@ -681,7 +681,7 @@ QualType Sema::BuildFunctionType(QualType T,
Diag(Loc, diag::err_func_returning_array_function) << T;
return QualType();
}
-
+
bool Invalid = false;
for (unsigned Idx = 0; Idx < NumParamTypes; ++Idx) {
QualType ParamType = adjustParameterType(ParamTypes[Idx]);
@@ -696,10 +696,10 @@ QualType Sema::BuildFunctionType(QualType T,
if (Invalid)
return QualType();
- return Context.getFunctionType(T, ParamTypes, NumParamTypes, Variadic,
+ return Context.getFunctionType(T, ParamTypes, NumParamTypes, Variadic,
Quals);
}
-
+
/// \brief Build a member pointer type \c T Class::*.
///
/// \param T the type to which the member pointer refers.
@@ -710,8 +710,8 @@ QualType Sema::BuildFunctionType(QualType T,
///
/// \returns a member pointer type, if successful, or a NULL type if there was
/// an error.
-QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
- unsigned Quals, SourceLocation Loc,
+QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
+ unsigned Quals, SourceLocation Loc,
DeclarationName Entity) {
// Verify that we're not building a pointer to pointer to function with
// exception specification.
@@ -757,9 +757,9 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
}
return Context.getMemberPointerType(T, Class.getTypePtr())
- .getQualifiedType(Quals);
+ .getQualifiedType(Quals);
}
-
+
/// \brief Build a block pointer type.
///
/// \param T The type to which we'll be building a block pointer.
@@ -776,13 +776,13 @@ QualType Sema::BuildMemberPointerType(QualType T, QualType Class,
/// \returns A suitable block pointer type, if there are no
/// errors. Otherwise, returns a NULL type.
QualType Sema::BuildBlockPointerType(QualType T, unsigned Quals,
- SourceLocation Loc,
+ SourceLocation Loc,
DeclarationName Entity) {
if (!T.getTypePtr()->isFunctionType()) {
Diag(Loc, diag::err_nonfunction_block_type);
return QualType();
}
-
+
return Context.getBlockPointerType(T).getQualifiedType(Quals);
}
@@ -793,7 +793,7 @@ QualType Sema::GetTypeFromParser(TypeTy *Ty, DeclaratorInfo **DInfo) {
QT = LIT->getType();
DI = LIT->getDeclaratorInfo();
}
-
+
if (DInfo) *DInfo = DI;
return QT;
}
@@ -858,7 +858,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
if (T == Context.UndeducedAutoTy) {
int Error = -1;
-
+
switch (D.getContext()) {
case Declarator::KNRTypeListContext:
assert(0 && "K&R type lists aren't allowed in C++");
@@ -872,7 +872,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
case TagDecl::TK_struct: Error = 1; /* Struct member */ break;
case TagDecl::TK_union: Error = 2; /* Union member */ break;
case TagDecl::TK_class: Error = 3; /* Class member */ break;
- }
+ }
break;
case Declarator::CXXCatchContext:
Error = 4; // Exception declaration
@@ -898,12 +898,12 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
D.setInvalidType(true);
}
}
-
+
// The name we're declaring, if any.
DeclarationName Name;
if (D.getIdentifier())
Name = D.getIdentifier();
-
+
bool ShouldBuildInfo = DInfo != 0;
// The QualType referring to the type as written in source code. We can't use
// T because it can change due to semantic analysis.
@@ -930,8 +930,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
// If blocks are disabled, emit an error.
if (!LangOpts.Blocks)
Diag(DeclType.Loc, diag::err_blocks_disable);
-
- T = BuildBlockPointerType(T, DeclType.Cls.TypeQuals, D.getIdentifierLoc(),
+
+ T = BuildBlockPointerType(T, DeclType.Cls.TypeQuals, D.getIdentifierLoc(),
Name);
break;
case DeclaratorChunk::Pointer:
@@ -961,7 +961,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
SourceTy = Context.getLValueReferenceType(SourceTy);
else
SourceTy = Context.getRValueReferenceType(SourceTy);
- unsigned Quals = DeclType.Ref.HasRestrict ? QualType::Restrict : 0;
+ unsigned Quals = DeclType.Ref.HasRestrict ? QualType::Restrict : 0;
SourceTy = SourceTy.getQualifiedType(Quals);
}
@@ -1015,7 +1015,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
if (ShouldBuildInfo) {
const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
llvm::SmallVector<QualType, 16> ArgTys;
-
+
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
ParmVarDecl *Param = FTI.ArgInfo[i].Param.getAs<ParmVarDecl>();
if (Param)
@@ -1059,7 +1059,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
// function takes no arguments.
llvm::SmallVector<QualType, 4> Exceptions;
Exceptions.reserve(FTI.NumExceptions);
- for(unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
+ for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
// FIXME: Preserve type source info.
QualType ET = GetTypeFromParser(FTI.Exceptions[ei].Ty);
// Check that the type is valid for an exception spec, and drop it
@@ -1093,12 +1093,12 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
}
} else if (FTI.ArgInfo[0].Param == 0) {
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
- Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
+ Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
} else {
// Otherwise, we have a function with an argument list that is
// potentially variadic.
llvm::SmallVector<QualType, 16> ArgTys;
-
+
for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
ParmVarDecl *Param =
cast<ParmVarDecl>(FTI.ArgInfo[i].Param.getAs<Decl>());
@@ -1129,7 +1129,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
// Reject, but continue to parse 'float(const void)'.
if (ArgTy.getCVRQualifiers())
Diag(DeclType.Loc, diag::err_void_param_qualified);
-
+
// Do not add 'void' to the ArgTys list.
break;
}
@@ -1141,13 +1141,13 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
ArgTy = Context.DoubleTy;
}
}
-
+
ArgTys.push_back(ArgTy);
}
llvm::SmallVector<QualType, 4> Exceptions;
Exceptions.reserve(FTI.NumExceptions);
- for(unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
+ for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
// FIXME: Preserve type source info.
QualType ET = GetTypeFromParser(FTI.Exceptions[ei].Ty);
// Check that the type is valid for an exception spec, and drop it if
@@ -1175,11 +1175,11 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
// The scope spec must refer to a class, or be dependent.
QualType ClsType;
if (isDependentScopeSpecifier(DeclType.Mem.Scope())) {
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= (NestedNameSpecifier *)DeclType.Mem.Scope().getScopeRep();
assert(NNS->getAsType() && "Nested-name-specifier must name a type");
ClsType = QualType(NNS->getAsType(), 0);
- } else if (CXXRecordDecl *RD
+ } else if (CXXRecordDecl *RD
= dyn_cast_or_null<CXXRecordDecl>(
computeDeclContext(DeclType.Mem.Scope()))) {
ClsType = Context.getTagDeclType(RD);
@@ -1243,7 +1243,7 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
FnTy->getNumArgs(), FnTy->isVariadic(), 0);
}
}
-
+
// If there were any type attributes applied to the decl itself (not the
// type, apply the type attribute to the type!)
if (const AttributeList *Attrs = D.getAttributes())
@@ -1315,12 +1315,12 @@ Sema::GetDeclaratorInfoForDeclarator(Declarator &D, QualType T, unsigned Skip) {
//FIXME: Class location.
break;
}
-
+
}
CurrTL = CurrTL.getNextTypeLoc();
}
-
+
if (TypedefLoc *TL = dyn_cast<TypedefLoc>(&CurrTL)) {
TL->setNameLoc(D.getDeclSpec().getTypeSpecTypeLoc());
} else {
@@ -1446,8 +1446,7 @@ bool Sema::CheckEquivalentExceptionSpec(
/// type. This is used by override and pointer assignment checks.
bool Sema::CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID,
const FunctionProtoType *Superset, SourceLocation SuperLoc,
- const FunctionProtoType *Subset, SourceLocation SubLoc)
-{
+ const FunctionProtoType *Subset, SourceLocation SubLoc) {
// FIXME: As usual, we could be more specific in our error messages, but
// that better waits until we've got types with source locations.
@@ -1537,7 +1536,7 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclPtrTy D) {
ObjCMethodDecl *MDecl = cast<ObjCMethodDecl>(D.getAs<Decl>());
QualType T = MDecl->getResultType();
llvm::SmallVector<QualType, 16> ArgTys;
-
+
// Add the first two invisible argument types for self and _cmd.
if (MDecl->isInstanceMethod()) {
QualType selfTy = Context.getObjCInterfaceType(MDecl->getClassInterface());
@@ -1546,7 +1545,7 @@ QualType Sema::ObjCGetTypeForMethodDefinition(DeclPtrTy D) {
} else
ArgTys.push_back(Context.getObjCIdType());
ArgTys.push_back(Context.getObjCSelType());
-
+
for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(),
E = MDecl->param_end(); PI != E; ++PI) {
QualType ArgTy = (*PI)->getType();
@@ -1592,7 +1591,7 @@ Sema::TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) {
// C99 6.7.6: Type names have no identifier. This is already validated by
// the parser.
assert(D.getIdentifier() == 0 && "Type name should have no identifier!");
-
+
DeclaratorInfo *DInfo = 0;
TagDecl *OwnedTag = 0;
QualType T = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0, &OwnedTag);
@@ -1627,7 +1626,7 @@ Sema::TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) {
/// HandleAddressSpaceTypeAttribute - Process an address_space attribute on the
/// specified type. The attribute contains 1 argument, the id of the address
/// space for the type.
-static void HandleAddressSpaceTypeAttribute(QualType &Type,
+static void HandleAddressSpaceTypeAttribute(QualType &Type,
const AttributeList &Attr, Sema &S){
// If this type is already address space qualified, reject it.
// Clause 6.7.3 - Type qualifiers: "No type shall be qualified by qualifiers
@@ -1636,7 +1635,7 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
S.Diag(Attr.getLoc(), diag::err_attribute_address_multiple_qualifiers);
return;
}
-
+
// Check the attribute arguments.
if (Attr.getNumArgs() != 1) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
@@ -1667,21 +1666,21 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type,
return;
}
- unsigned ASIdx = static_cast<unsigned>(addrSpace.getZExtValue());
+ unsigned ASIdx = static_cast<unsigned>(addrSpace.getZExtValue());
Type = S.Context.getAddrSpaceQualType(Type, ASIdx);
}
/// HandleObjCGCTypeAttribute - Process an objc's gc attribute on the
/// specified type. The attribute contains 1 argument, weak or strong.
-static void HandleObjCGCTypeAttribute(QualType &Type,
+static void HandleObjCGCTypeAttribute(QualType &Type,
const AttributeList &Attr, Sema &S) {
if (Type.getObjCGCAttr() != QualType::GCNone) {
S.Diag(Attr.getLoc(), diag::err_attribute_multiple_objc_gc);
return;
}
-
+
// Check the attribute arguments.
- if (!Attr.getParameterName()) {
+ if (!Attr.getParameterName()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string)
<< "objc_gc" << 1;
return;
@@ -1691,7 +1690,7 @@ static void HandleObjCGCTypeAttribute(QualType &Type,
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1;
return;
}
- if (Attr.getParameterName()->isStr("weak"))
+ if (Attr.getParameterName()->isStr("weak"))
GCAttr = QualType::Weak;
else if (Attr.getParameterName()->isStr("strong"))
GCAttr = QualType::Strong;
@@ -1700,13 +1699,13 @@ static void HandleObjCGCTypeAttribute(QualType &Type,
<< "objc_gc" << Attr.getParameterName();
return;
}
-
+
Type = S.Context.getObjCGCQualType(Type, GCAttr);
}
/// HandleNoReturnTypeAttribute - Process the noreturn attribute on the
/// specified type. The attribute contains 0 arguments.
-static void HandleNoReturnTypeAttribute(QualType &Type,
+static void HandleNoReturnTypeAttribute(QualType &Type,
const AttributeList &Attr, Sema &S) {
if (Attr.getNumArgs() != 0)
return;
@@ -1743,7 +1742,7 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) {
}
}
-/// @brief Ensure that the type T is a complete type.
+/// @brief Ensure that the type T is a complete type.
///
/// This routine checks whether the type @p T is complete in any
/// context where a complete type is required. If @p T is a complete
@@ -1758,7 +1757,7 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) {
///
/// @param T The type that this routine is examining for completeness.
///
-/// @param PD The partial diagnostic that will be printed out if T is not a
+/// @param PD The partial diagnostic that will be printed out if T is not a
/// complete type.
///
/// @returns @c true if @p T is incomplete and a diagnostic was emitted,
@@ -1766,11 +1765,11 @@ void Sema::ProcessTypeAttributeList(QualType &Result, const AttributeList *AL) {
bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
const PartialDiagnostic &PD) {
unsigned diag = PD.getDiagID();
-
+
// FIXME: Add this assertion to help us flush out problems with
// checking for dependent types and type-dependent expressions.
//
- // assert(!T->isDependentType() &&
+ // assert(!T->isDependentType() &&
// "Can't ask whether a dependent type is complete");
// If we have a complete type, we're done.
@@ -1791,11 +1790,11 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
TSK_ImplicitInstantiation,
/*Complain=*/diag != 0);
}
- } else if (CXXRecordDecl *Rec
+ } else if (CXXRecordDecl *Rec
= dyn_cast<CXXRecordDecl>(Record->getDecl())) {
if (CXXRecordDecl *Pattern = Rec->getInstantiatedFromMemberClass()) {
// This record was instantiated from a class within a template.
- return InstantiateClass(Loc, Rec, Pattern,
+ return InstantiateClass(Loc, Rec, Pattern,
getTemplateInstantiationArgs(Rec),
TSK_ImplicitInstantiation,
/*Complain=*/diag != 0);
@@ -1805,12 +1804,12 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
if (diag == 0)
return true;
-
+
// We have an incomplete type. Produce a diagnostic.
Diag(Loc, PD) << T;
// If the type was a forward declaration of a class/struct/union
- // type, produce
+ // type, produce
const TagType *Tag = 0;
if (const RecordType *Record = T->getAs<RecordType>())
Tag = Record;
@@ -1818,7 +1817,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
Tag = Enum;
if (Tag && !Tag->getDecl()->isInvalidDecl())
- Diag(Tag->getDecl()->getLocation(),
+ Diag(Tag->getDecl()->getLocation(),
Tag->isBeingDefined() ? diag::note_type_being_defined
: diag::note_forward_declaration)
<< QualType(Tag, 0);
@@ -1831,7 +1830,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
QualType Sema::getQualifiedNameType(const CXXScopeSpec &SS, QualType T) {
if (!SS.isSet() || SS.isInvalid() || T.isNull())
return T;
-
+
NestedNameSpecifier *NNS
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
return Context.getQualifiedNameType(NNS, T);
@@ -1843,7 +1842,7 @@ QualType Sema::BuildTypeofExprType(Expr *E) {
QualType Sema::BuildDecltypeType(Expr *E) {
if (E->getType() == Context.OverloadTy) {
- Diag(E->getLocStart(),
+ Diag(E->getLocStart(),
diag::err_cannot_determine_declared_type_of_overloaded_function);
return QualType();
}
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index d19653d157..bd7fb4f2f8 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -28,13 +28,13 @@
#include <algorithm>
namespace clang {
-
+
/// \brief A semantic tree transformation that allows one to transform one
/// abstract syntax tree into another.
///
-/// A new tree transformation is defined by creating a new subclass \c X of
-/// \c TreeTransform<X> and then overriding certain operations to provide
-/// behavior specific to that transformation. For example, template
+/// A new tree transformation is defined by creating a new subclass \c X of
+/// \c TreeTransform<X> and then overriding certain operations to provide
+/// behavior specific to that transformation. For example, template
/// instantiation is implemented as a tree transformation where the
/// transformation of TemplateTypeParmType nodes involves substituting the
/// template arguments for their corresponding template parameters; a similar
@@ -42,7 +42,7 @@ namespace clang {
/// template template parameters.
///
/// This tree-transformation template uses static polymorphism to allow
-/// subclasses to customize any of its operations. Thus, a subclass can
+/// subclasses to customize any of its operations. Thus, a subclass can
/// override any of the transformation or rebuild operators by providing an
/// operation with the same signature as the default implementation. The
/// overridding function should not be virtual.
@@ -57,7 +57,7 @@ namespace clang {
/// were changed by the transformation, invokes the rebuild operation to create
/// a new AST node.
///
-/// Subclasses can customize the transformation at various levels. The
+/// Subclasses can customize the transformation at various levels. The
/// most coarse-grained transformations involve replacing TransformType(),
/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifier(),
/// TransformTemplateName(), or TransformTemplateArgument() with entirely
@@ -67,7 +67,7 @@ namespace clang {
/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
/// replacing TransformTemplateTypeParmType() allows template instantiation
-/// to substitute template arguments for their corresponding template
+/// to substitute template arguments for their corresponding template
/// parameters. Additionally, subclasses can override the \c RebuildXXX
/// functions to control how AST nodes are rebuilt when their operands change.
/// By default, \c TreeTransform will invoke semantic analysis to rebuild
@@ -75,7 +75,7 @@ namespace clang {
/// be able to use more efficient rebuild steps.
///
/// There are a handful of other functions that can be overridden, allowing one
-/// to avoid traversing nodes that don't need any transformation
+/// to avoid traversing nodes that don't need any transformation
/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
/// operands have not changed (\c AlwaysRebuild()), and customize the
/// default locations and entity names used for type-checking
@@ -84,45 +84,45 @@ template<typename Derived>
class TreeTransform {
protected:
Sema &SemaRef;
-
-public:
+
+public:
typedef Sema::OwningStmtResult OwningStmtResult;
typedef Sema::OwningExprResult OwningExprResult;
typedef Sema::StmtArg StmtArg;
typedef Sema::ExprArg ExprArg;
typedef Sema::MultiExprArg MultiExprArg;
typedef Sema::MultiStmtArg MultiStmtArg;
-
+
/// \brief Initializes a new tree transformer.
TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
-
+
/// \brief Retrieves a reference to the derived class.
Derived &getDerived() { return static_cast<Derived&>(*this); }
/// \brief Retrieves a reference to the derived class.
- const Derived &getDerived() const {
- return static_cast<const Derived&>(*this);
+ const Derived &getDerived() const {
+ return static_cast<const Derived&>(*this);
}
/// \brief Retrieves a reference to the semantic analysis object used for
/// this tree transform.
Sema &getSema() const { return SemaRef; }
-
+
/// \brief Whether the transformation should always rebuild AST nodes, even
/// if none of the children have changed.
///
/// Subclasses may override this function to specify when the transformation
/// should rebuild all AST nodes.
bool AlwaysRebuild() { return false; }
-
+
/// \brief Returns the location of the entity being transformed, if that
/// information was not available elsewhere in the AST.
///
- /// By default, returns no source-location information. Subclasses can
+ /// By default, returns no source-location information. Subclasses can
/// provide an alternative implementation that provides better location
/// information.
SourceLocation getBaseLocation() { return SourceLocation(); }
-
+
/// \brief Returns the name of the entity being transformed, if that
/// information was not available elsewhere in the AST.
///
@@ -136,33 +136,32 @@ public:
/// By default, the source location and entity are ignored. Subclasses can
/// override this function to provide a customized implementation.
void setBase(SourceLocation Loc, DeclarationName Entity) { }
-
+
/// \brief RAII object that temporarily sets the base location and entity
/// used for reporting diagnostics in types.
class TemporaryBase {
TreeTransform &Self;
SourceLocation OldLocation;
DeclarationName OldEntity;
-
+
public:
TemporaryBase(TreeTransform &Self, SourceLocation Location,
- DeclarationName Entity) : Self(Self)
- {
+ DeclarationName Entity) : Self(Self) {
OldLocation = Self.getDerived().getBaseLocation();
OldEntity = Self.getDerived().getBaseEntity();
Self.getDerived().setBase(Location, Entity);
}
-
+
~TemporaryBase() {
Self.getDerived().setBase(OldLocation, OldEntity);
}
};
-
- /// \brief Determine whether the given type \p T has already been
+
+ /// \brief Determine whether the given type \p T has already been
/// transformed.
///
/// Subclasses can provide an alternative implementation of this routine
- /// to short-circuit evaluation when it is known that a given type will
+ /// to short-circuit evaluation when it is known that a given type will
/// not change. For example, template instantiation need not traverse
/// non-dependent types.
bool AlreadyTransformed(QualType T) {
@@ -172,15 +171,15 @@ public:
/// \brief Transforms the given type into another type.
///
/// By default, this routine transforms a type by delegating to the
- /// appropriate TransformXXXType to build a new type, then applying
- /// the qualifiers on \p T to the resulting type with AddTypeQualifiers.
- /// Subclasses may override this function (to take over all type
+ /// appropriate TransformXXXType to build a new type, then applying
+ /// the qualifiers on \p T to the resulting type with AddTypeQualifiers.
+ /// Subclasses may override this function (to take over all type
/// transformations), some set of the TransformXXXType functions, or
/// the AddTypeQualifiers function to alter the transformation.
///
/// \returns the transformed type.
QualType TransformType(QualType T);
-
+
/// \brief Transform the given type by adding the given set of qualifiers
/// and returning the result.
///
@@ -190,10 +189,10 @@ public:
/// is the right thing for template instantiation, but probably not for
/// other clients.
QualType AddTypeQualifiers(QualType T, unsigned CVRQualifiers);
-
+
/// \brief Transform the given statement.
///
- /// By default, this routine transforms a statement by delegating to the
+ /// By default, this routine transforms a statement by delegating to the
/// appropriate TransformXXXStmt function to transform a specific kind of
/// statement or the TransformExpr() function to transform an expression.
/// Subclasses may override this function to transform statements using some
@@ -201,7 +200,7 @@ public:
///
/// \returns the transformed statement.
OwningStmtResult TransformStmt(Stmt *S);
-
+
/// \brief Transform the given expression.
///
/// By default, this routine transforms an expression by delegating to the
@@ -223,7 +222,7 @@ public:
///
/// \returns the transformed expression.
OwningExprResult TransformExpr(Expr *E, bool isAddressOfOperand);
-
+
/// \brief Transform the given declaration, which is referenced from a type
/// or expression.
///
@@ -233,20 +232,20 @@ public:
/// \brief Transform the definition of the given declaration.
///
- /// By default, invokes TransformDecl() to transform the declaration.
+ /// By default, invokes TransformDecl() to transform the declaration.
/// Subclasses may override this function to provide alternate behavior.
Decl *TransformDefinition(Decl *D) { return getDerived().TransformDecl(D); }
-
+
/// \brief Transform the given nested-name-specifier.
///
- /// By default, transforms all of the types and declarations within the
+ /// By default, transforms all of the types and declarations within the
/// nested-name-specifier. Subclasses may override this function to provide
/// alternate behavior.
NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
QualType ObjectType = QualType(),
NamedDecl *FirstQualifierInScope = 0);
-
+
/// \brief Transform the given declaration name.
///
/// By default, transforms the types of conversion function, constructor,
@@ -255,37 +254,37 @@ public:
/// override this function to provide alternate behavior.
DeclarationName TransformDeclarationName(DeclarationName Name,
SourceLocation Loc);
-
+
/// \brief Transform the given template name.
- ///
+ ///
/// By default, transforms the template name by transforming the declarations
- /// and nested-name-specifiers that occur within the template name.
+ /// and nested-name-specifiers that occur within the template name.
/// Subclasses may override this function to provide alternate behavior.
TemplateName TransformTemplateName(TemplateName Name,
QualType ObjectType = QualType());
-
+
/// \brief Transform the given template argument.
///
- /// By default, this operation transforms the type, expression, or
- /// declaration stored within the template argument and constructs a
+ /// By default, this operation transforms the type, expression, or
+ /// declaration stored within the template argument and constructs a
/// new template argument from the transformed result. Subclasses may
/// override this function to provide alternate behavior.
TemplateArgument TransformTemplateArgument(const TemplateArgument &Arg);
-
+
#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) \
QualType Transform##CLASS##Type(const CLASS##Type *T);
-#include "clang/AST/TypeNodes.def"
+#include "clang/AST/TypeNodes.def"
OwningStmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
-
+
#define STMT(Node, Parent) \
OwningStmtResult Transform##Node(Node *S);
#define EXPR(Node, Parent) \
OwningExprResult Transform##Node(Node *E);
#define ABSTRACT_EXPR(Node, Parent)
#include "clang/AST/StmtNodes.def"
-
+
/// \brief Build a new pointer type given its pointee type.
///
/// By default, performs semantic analysis when building the pointer type.
@@ -294,7 +293,7 @@ public:
/// \brief Build a new block pointer type given its pointee type.
///
- /// By default, performs semantic analysis when building the block pointer
+ /// By default, performs semantic analysis when building the block pointer
/// type. Subclasses may override this routine to provide different behavior.
QualType RebuildBlockPointerType(QualType PointeeType);
@@ -309,45 +308,45 @@ public:
/// By default, performs semantic analysis when building the rvalue reference
/// type. Subclasses may override this routine to provide different behavior.
QualType RebuildRValueReferenceType(QualType ReferentType);
-
+
/// \brief Build a new member pointer type given the pointee type and the
/// class type it refers into.
///
/// By default, performs semantic analysis when building the member pointer
/// type. Subclasses may override this routine to provide different behavior.
QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType);
-
+
/// \brief Build a new array type given the element type, size
/// modifier, size of the array (if known), size expression, and index type
/// qualifiers.
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- /// Also by default, all of the other Rebuild*Array
+ /// Also by default, all of the other Rebuild*Array
QualType RebuildArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt *Size,
Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
-
+
/// \brief Build a new constant array type given the element type, size
/// modifier, (known) size of the array, and index type qualifiers.
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildConstantArrayType(QualType ElementType,
+ QualType RebuildConstantArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
unsigned IndexTypeQuals);
/// \brief Build a new constant array type given the element type, size
- /// modifier, (known) size of the array, size expression, and index type
+ /// modifier, (known) size of the array, size expression, and index type
/// qualifiers.
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildConstantArrayWithExprType(QualType ElementType,
+ QualType RebuildConstantArrayWithExprType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
Expr *SizeExpr,
@@ -359,7 +358,7 @@ public:
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildConstantArrayWithoutExprType(QualType ElementType,
+ QualType RebuildConstantArrayWithoutExprType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
unsigned IndexTypeQuals);
@@ -369,27 +368,27 @@ public:
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildIncompleteArrayType(QualType ElementType,
+ QualType RebuildIncompleteArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
unsigned IndexTypeQuals);
- /// \brief Build a new variable-length array type given the element type,
+ /// \brief Build a new variable-length array type given the element type,
/// size modifier, size expression, and index type qualifiers.
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildVariableArrayType(QualType ElementType,
+ QualType RebuildVariableArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
ExprArg SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange);
- /// \brief Build a new dependent-sized array type given the element type,
+ /// \brief Build a new dependent-sized array type given the element type,
/// size modifier, size expression, and index type qualifiers.
///
/// By default, performs semantic analysis when building the array type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildDependentSizedArrayType(QualType ElementType,
+ QualType RebuildDependentSizedArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
ExprArg SizeExpr,
unsigned IndexTypeQuals,
@@ -401,7 +400,7 @@ public:
/// By default, performs semantic analysis when building the vector type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements);
-
+
/// \brief Build a new extended vector type given the element type and
/// number of elements.
///
@@ -409,25 +408,25 @@ public:
/// Subclasses may override this routine to provide different behavior.
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
SourceLocation AttributeLoc);
-
- /// \brief Build a new potentially dependently-sized extended vector type
+
+ /// \brief Build a new potentially dependently-sized extended vector type
/// given the element type and number of elements.
///
/// By default, performs semantic analysis when building the vector type.
/// Subclasses may override this routine to provide different behavior.
- QualType RebuildDependentSizedExtVectorType(QualType ElementType,
+ QualType RebuildDependentSizedExtVectorType(QualType ElementType,
ExprArg SizeExpr,
SourceLocation AttributeLoc);
-
+
/// \brief Build a new function type.
///
/// By default, performs semantic analysis when building the function type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildFunctionProtoType(QualType T,
- QualType *ParamTypes,
+ QualType *ParamTypes,
unsigned NumParamTypes,
bool Variadic, unsigned Quals);
-
+
/// \brief Build a new typedef type.
QualType RebuildTypedefType(TypedefDecl *Typedef) {
return SemaRef.Context.getTypeDeclType(Typedef);
@@ -447,24 +446,24 @@ public:
QualType RebuildElaboratedType(QualType T, ElaboratedType::TagKind Tag) {
return SemaRef.Context.getElaboratedType(T, Tag);
}
-
- /// \brief Build a new typeof(expr) type.
+
+ /// \brief Build a new typeof(expr) type.
///
/// By default, performs semantic analysis when building the typeof type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildTypeOfExprType(ExprArg Underlying);
- /// \brief Build a new typeof(type) type.
+ /// \brief Build a new typeof(type) type.
///
/// By default, builds a new TypeOfType with the given underlying type.
QualType RebuildTypeOfType(QualType Underlying);
- /// \brief Build a new C++0x decltype type.
+ /// \brief Build a new C++0x decltype type.
///
/// By default, performs semantic analysis when building the decltype type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildDecltypeType(ExprArg Underlying);
-
+
/// \brief Build a new template specialization type.
///
/// By default, performs semantic analysis when building the template
@@ -473,40 +472,40 @@ public:
QualType RebuildTemplateSpecializationType(TemplateName Template,
const TemplateArgument *Args,
unsigned NumArgs);
-
+
/// \brief Build a new qualified name type.
///
- /// By default, builds a new QualifiedNameType type from the
- /// nested-name-specifier and the named type. Subclasses may override
+ /// By default, builds a new QualifiedNameType type from the
+ /// nested-name-specifier and the named type. Subclasses may override
/// this routine to provide different behavior.
QualType RebuildQualifiedNameType(NestedNameSpecifier *NNS, QualType Named) {
return SemaRef.Context.getQualifiedNameType(NNS, Named);
- }
+ }
/// \brief Build a new typename type that refers to a template-id.
///
/// By default, builds a new TypenameType type from the nested-name-specifier
- /// and the given type. Subclasses may override this routine to provide
+ /// and the given type. Subclasses may override this routine to provide
/// different behavior.
QualType RebuildTypenameType(NestedNameSpecifier *NNS, QualType T) {
if (NNS->isDependent())
- return SemaRef.Context.getTypenameType(NNS,
+ return SemaRef.Context.getTypenameType(NNS,
cast<TemplateSpecializationType>(T));
-
+
return SemaRef.Context.getQualifiedNameType(NNS, T);
- }
+ }
/// \brief Build a new typename type that refers to an identifier.
///
/// By default, performs semantic analysis when building the typename type
- /// (or qualified name type). Subclasses may override this routine to provide
+ /// (or qualified name type). Subclasses may override this routine to provide
/// different behavior.
- QualType RebuildTypenameType(NestedNameSpecifier *NNS,
+ QualType RebuildTypenameType(NestedNameSpecifier *NNS,
const IdentifierInfo *Id) {
return SemaRef.CheckTypenameType(NNS, *Id,
SourceRange(getDerived().getBaseLocation()));
}
-
+
/// \brief Build a new nested-name-specifier given the prefix and an
/// identifier that names the next step in the nested-name-specifier.
///
@@ -559,7 +558,7 @@ public:
TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
bool TemplateKW,
OverloadedFunctionDecl *Ovl);
-
+
/// \brief Build a new template name given a nested name specifier and the
/// name that is referred to as a template.
///
@@ -570,8 +569,8 @@ public:
TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
const IdentifierInfo &II,
QualType ObjectType);
-
-
+
+
/// \brief Build a new compound statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -593,10 +592,10 @@ public:
SourceLocation EllipsisLoc,
ExprArg RHS,
SourceLocation ColonLoc) {
- return getSema().ActOnCaseStmt(CaseLoc, move(LHS), EllipsisLoc, move(RHS),
+ return getSema().ActOnCaseStmt(CaseLoc, move(LHS), EllipsisLoc, move(RHS),
ColonLoc);
}
-
+
/// \brief Attach the body to a new case statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -605,39 +604,39 @@ public:
getSema().ActOnCaseStmtBody(S.get(), move(Body));
return move(S);
}
-
+
/// \brief Build a new default statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
- OwningStmtResult RebuildDefaultStmt(SourceLocation DefaultLoc,
+ OwningStmtResult RebuildDefaultStmt(SourceLocation DefaultLoc,
SourceLocation ColonLoc,
StmtArg SubStmt) {
- return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, move(SubStmt),
+ return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, move(SubStmt),
/*CurScope=*/0);
}
-
+
/// \brief Build a new label statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
- OwningStmtResult RebuildLabelStmt(SourceLocation IdentLoc,
+ OwningStmtResult RebuildLabelStmt(SourceLocation IdentLoc,
IdentifierInfo *Id,
SourceLocation ColonLoc,
StmtArg SubStmt) {
return SemaRef.ActOnLabelStmt(IdentLoc, Id, ColonLoc, move(SubStmt));
}
-
+
/// \brief Build a new "if" statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
- OwningStmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond,
- StmtArg Then, SourceLocation ElseLoc,
+ OwningStmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond,
+ StmtArg Then, SourceLocation ElseLoc,
StmtArg Else) {
return getSema().ActOnIfStmt(IfLoc, Cond, move(Then), ElseLoc, move(Else));
}
-
+
/// \brief Start building a new switch statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -645,12 +644,12 @@ public:
OwningStmtResult RebuildSwitchStmtStart(ExprArg Cond) {
return getSema().ActOnStartOfSwitchStmt(move(Cond));
}
-
+
/// \brief Attach the body to the switch statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
- OwningStmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc,
+ OwningStmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc,
StmtArg Switch, StmtArg Body) {
return getSema().ActOnFinishSwitchStmt(SwitchLoc, move(Switch),
move(Body));
@@ -665,7 +664,7 @@ public:
StmtArg Body) {
return getSema().ActOnWhileStmt(WhileLoc, Cond, move(Body));
}
-
+
/// \brief Build a new do-while statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -675,7 +674,7 @@ public:
SourceLocation LParenLoc,
ExprArg Cond,
SourceLocation RParenLoc) {
- return getSema().ActOnDoStmt(DoLoc, move(Body), WhileLoc, LParenLoc,
+ return getSema().ActOnDoStmt(DoLoc, move(Body), WhileLoc, LParenLoc,
move(Cond), RParenLoc);
}
@@ -683,14 +682,14 @@ public:
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
- OwningStmtResult RebuildForStmt(SourceLocation ForLoc,
+ OwningStmtResult RebuildForStmt(SourceLocation ForLoc,
SourceLocation LParenLoc,
StmtArg Init, ExprArg Cond, ExprArg Inc,
SourceLocation RParenLoc, StmtArg Body) {
- return getSema().ActOnForStmt(ForLoc, LParenLoc, move(Init), move(Cond),
+ return getSema().ActOnForStmt(ForLoc, LParenLoc, move(Init), move(Cond),
move(Inc), RParenLoc, move(Body));
}
-
+
/// \brief Build a new goto statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -710,23 +709,23 @@ public:
ExprArg Target) {
return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, move(Target));
}
-
+
/// \brief Build a new return statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
OwningStmtResult RebuildReturnStmt(SourceLocation ReturnLoc,
ExprArg Result) {
-
+
return getSema().ActOnReturnStmt(ReturnLoc, move(Result));
}
-
+
/// \brief Build a new declaration statement.
///
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
OwningStmtResult RebuildDeclStmt(Decl **Decls, unsigned NumDecls,
- SourceLocation StartLoc,
+ SourceLocation StartLoc,
SourceLocation EndLoc) {
return getSema().Owned(
new (getSema().Context) DeclStmt(
@@ -734,17 +733,17 @@ public:
Decls, NumDecls),
StartLoc, EndLoc));
}
-
+
/// \brief Build a new C++ exception declaration.
///
/// By default, performs semantic analysis to build the new decaration.
/// Subclasses may override this routine to provide different behavior.
- VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
+ VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
DeclaratorInfo *Declarator,
IdentifierInfo *Name,
SourceLocation Loc,
SourceRange TypeRange) {
- return getSema().BuildExceptionDeclaration(0, T, Declarator, Name, Loc,
+ return getSema().BuildExceptionDeclaration(0, T, Declarator, Name, Loc,
TypeRange);
}
@@ -756,10 +755,10 @@ public:
VarDecl *ExceptionDecl,
StmtArg Handler) {
return getSema().Owned(
- new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
+ new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
Handler.takeAs<Stmt>()));
}
-
+
/// \brief Build a new C++ try statement.
///
/// By default, performs semantic analysis to build the new statement.
@@ -769,7 +768,7 @@ public:
MultiStmtArg Handlers) {
return getSema().ActOnCXXTryBlock(TryLoc, move(TryBlock), move(Handlers));
}
-
+
/// \brief Build a new expression that references a declaration.
///
/// By default, performs semantic analysis to build the new expression.
@@ -780,9 +779,9 @@ public:
/*SS=*/0,
/*FIXME:*/false);
}
-
+
/// \brief Build a new expression in parentheses.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildParenExpr(ExprArg SubExpr, SourceLocation LParen,
@@ -791,7 +790,7 @@ public:
}
/// \brief Build a new pseudo-destructor expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCXXPseudoDestructorExpr(ExprArg Base,
@@ -807,21 +806,21 @@ public:
SS.setScopeRep(Qualifier);
}
- DeclarationName Name
+ DeclarationName Name
= SemaRef.Context.DeclarationNames.getCXXDestructorName(
SemaRef.Context.getCanonicalType(DestroyedType));
-
- return getSema().BuildMemberReferenceExpr(/*Scope=*/0, move(Base),
+
+ return getSema().BuildMemberReferenceExpr(/*Scope=*/0, move(Base),
OperatorLoc,
isArrow? tok::arrow : tok::period,
DestroyedTypeLoc,
Name,
Sema::DeclPtrTy::make((Decl *)0),
&SS);
- }
-
+ }
+
/// \brief Build a new unary operator expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildUnaryOperator(SourceLocation OpLoc,
@@ -829,9 +828,9 @@ public:
ExprArg SubExpr) {
return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, move(SubExpr));
}
-
+
/// \brief Build a new sizeof or alignof expression with a type argument.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildSizeOfAlignOf(QualType T, SourceLocation OpLoc,
@@ -839,38 +838,38 @@ public:
return getSema().CreateSizeOfAlignOfExpr(T, OpLoc, isSizeOf, R);
}
- /// \brief Build a new sizeof or alignof expression with an expression
+ /// \brief Build a new sizeof or alignof expression with an expression
/// argument.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildSizeOfAlignOf(ExprArg SubExpr, SourceLocation OpLoc,
bool isSizeOf, SourceRange R) {
- OwningExprResult Result
+ OwningExprResult Result
= getSema().CreateSizeOfAlignOfExpr((Expr *)SubExpr.get(),
OpLoc, isSizeOf, R);
if (Result.isInvalid())
return getSema().ExprError();
-
+
SubExpr.release();
return move(Result);
}
-
+
/// \brief Build a new array subscript expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildArraySubscriptExpr(ExprArg LHS,
+ OwningExprResult RebuildArraySubscriptExpr(ExprArg LHS,
SourceLocation LBracketLoc,
ExprArg RHS,
SourceLocation RBracketLoc) {
return getSema().ActOnArraySubscriptExpr(/*Scope=*/0, move(LHS),
- LBracketLoc, move(RHS),
+ LBracketLoc, move(RHS),
RBracketLoc);
}
/// \brief Build a new call expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCallExpr(ExprArg Callee, SourceLocation LParenLoc,
@@ -882,11 +881,11 @@ public:
}
/// \brief Build a new member access expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildMemberExpr(ExprArg Base, SourceLocation OpLoc,
- bool isArrow,
+ bool isArrow,
NestedNameSpecifier *Qualifier,
SourceRange QualifierRange,
SourceLocation MemberLoc,
@@ -894,14 +893,14 @@ public:
if (!Member->getDeclName()) {
// We have a reference to an unnamed field.
assert(!Qualifier && "Can't have an unnamed field with a qualifier!");
-
- MemberExpr *ME =
+
+ MemberExpr *ME =
new (getSema().Context) MemberExpr(Base.takeAs<Expr>(), isArrow,
Member, MemberLoc,
cast<FieldDecl>(Member)->getType());
return getSema().Owned(ME);
}
-
+
CXXScopeSpec SS;
if (Qualifier) {
SS.setRange(QualifierRange);
@@ -915,27 +914,27 @@ public:
/*FIXME?*/Sema::DeclPtrTy::make((Decl*)0),
&SS);
}
-
+
/// \brief Build a new binary operator expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildBinaryOperator(SourceLocation OpLoc,
BinaryOperator::Opcode Opc,
ExprArg LHS, ExprArg RHS) {
OwningExprResult Result
- = getSema().CreateBuiltinBinOp(OpLoc, Opc, (Expr *)LHS.get(),
+ = getSema().CreateBuiltinBinOp(OpLoc, Opc, (Expr *)LHS.get(),
(Expr *)RHS.get());
if (Result.isInvalid())
return SemaRef.ExprError();
-
+
LHS.release();
RHS.release();
return move(Result);
}
/// \brief Build a new conditional operator expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildConditionalOperator(ExprArg Cond,
@@ -943,25 +942,25 @@ public:
ExprArg LHS,
SourceLocation ColonLoc,
ExprArg RHS) {
- return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, move(Cond),
+ return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, move(Cond),
move(LHS), move(RHS));
}
/// \brief Build a new implicit cast expression.
- ///
+ ///
/// By default, builds a new implicit cast without any semantic analysis.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildImplicitCastExpr(QualType T, CastExpr::CastKind Kind,
ExprArg SubExpr, bool isLvalue) {
ImplicitCastExpr *ICE
- = new (getSema().Context) ImplicitCastExpr(T, Kind,
+ = new (getSema().Context) ImplicitCastExpr(T, Kind,
(Expr *)SubExpr.release(),
isLvalue);
return getSema().Owned(ICE);
}
/// \brief Build a new C-style cast expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCStyleCaseExpr(SourceLocation LParenLoc,
@@ -974,9 +973,9 @@ public:
RParenLoc,
move(SubExpr));
}
-
+
/// \brief Build a new compound literal expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc,
@@ -986,12 +985,12 @@ public:
return getSema().ActOnCompoundLiteral(LParenLoc, T.getAsOpaquePtr(),
RParenLoc, move(Init));
}
-
+
/// \brief Build a new extended vector element access expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildExtVectorElementExpr(ExprArg Base,
+ OwningExprResult RebuildExtVectorElementExpr(ExprArg Base,
SourceLocation OpLoc,
SourceLocation AccessorLoc,
IdentifierInfo &Accessor) {
@@ -1000,9 +999,9 @@ public:
Accessor,
/*FIXME?*/Sema::DeclPtrTy::make((Decl*)0));
}
-
+
/// \brief Build a new initializer list expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildInitList(SourceLocation LBraceLoc,
@@ -1010,9 +1009,9 @@ public:
SourceLocation RBraceLoc) {
return SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc);
}
-
+
/// \brief Build a new designated initializer expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildDesignatedInitExpr(Designation &Desig,
@@ -1025,32 +1024,32 @@ public:
move(Init));
if (Result.isInvalid())
return SemaRef.ExprError();
-
+
ArrayExprs.release();
return move(Result);
}
-
+
/// \brief Build a new value-initialized expression.
- ///
+ ///
/// By default, builds the implicit value initialization without performing
/// any semantic analysis. Subclasses may override this routine to provide
/// different behavior.
OwningExprResult RebuildImplicitValueInitExpr(QualType T) {
return SemaRef.Owned(new (SemaRef.Context) ImplicitValueInitExpr(T));
}
-
+
/// \brief Build a new \c va_arg expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, ExprArg SubExpr,
QualType T, SourceLocation RParenLoc) {
- return getSema().ActOnVAArg(BuiltinLoc, move(SubExpr), T.getAsOpaquePtr(),
+ return getSema().ActOnVAArg(BuiltinLoc, move(SubExpr), T.getAsOpaquePtr(),
RParenLoc);
}
/// \brief Build a new expression list in parentheses.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildParenListExpr(SourceLocation LParenLoc,
@@ -1058,10 +1057,10 @@ public:
SourceLocation RParenLoc) {
return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, move(SubExprs));
}
-
+
/// \brief Build a new address-of-label expression.
- ///
- /// By default, performs semantic analysis, using the name of the label
+ ///
+ /// By default, performs semantic analysis, using the name of the label
/// rather than attempting to map the label statement itself.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc,
@@ -1069,9 +1068,9 @@ public:
LabelStmt *Label) {
return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label->getID());
}
-
+
/// \brief Build a new GNU statement expression.
- ///
+ ///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildStmtExpr(SourceLocation LParenLoc,
@@ -1079,7 +1078,7 @@ public:
SourceLocation RParenLoc) {
return getSema().ActOnStmtExpr(LParenLoc, move(SubStmt), RParenLoc);
}
-
+
/// \brief Build a new __builtin_types_compatible_p expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1092,7 +1091,7 @@ public:
T2.getAsOpaquePtr(),
RParenLoc);
}
-
+
/// \brief Build a new __builtin_choose_expr expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1104,13 +1103,13 @@ public:
move(Cond), move(LHS), move(RHS),
RParenLoc);
}
-
+
/// \brief Build a new overloaded operator call expression.
///
/// By default, performs semantic analysis to build the new expression.
/// The semantic analysis provides the behavior of template instantiation,
/// copying with transformations that turn what looks like an overloaded
- /// operator call into a use of a builtin operator, performing
+ /// operator call into a use of a builtin operator, performing
/// argument-dependent lookup, etc. Subclasses may override this routine to
/// provide different behavior.
OwningExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
@@ -1118,12 +1117,12 @@ public:
ExprArg Callee,
ExprArg First,
ExprArg Second);
-
- /// \brief Build a new C++ "named" cast expression, such as static_cast or
+
+ /// \brief Build a new C++ "named" cast expression, such as static_cast or
/// reinterpret_cast.
///
/// By default, this routine dispatches to one of the more-specific routines
- /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
+ /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc,
Stmt::StmtClass Class,
@@ -1135,34 +1134,34 @@ public:
SourceLocation RParenLoc) {
switch (Class) {
case Stmt::CXXStaticCastExprClass:
- return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, T,
- RAngleLoc, LParenLoc,
+ return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, T,
+ RAngleLoc, LParenLoc,
move(SubExpr), RParenLoc);
case Stmt::CXXDynamicCastExprClass:
- return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, T,
- RAngleLoc, LParenLoc,
+ return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, T,
+ RAngleLoc, LParenLoc,
move(SubExpr), RParenLoc);
-
+
case Stmt::CXXReinterpretCastExprClass:
- return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, T,
- RAngleLoc, LParenLoc,
- move(SubExpr),
+ return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, T,
+ RAngleLoc, LParenLoc,
+ move(SubExpr),
RParenLoc);
-
+
case Stmt::CXXConstCastExprClass:
- return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, T,
- RAngleLoc, LParenLoc,
+ return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, T,
+ RAngleLoc, LParenLoc,
move(SubExpr), RParenLoc);
-
+
default:
assert(false && "Invalid C++ named cast");
break;
}
-
+
return getSema().ExprError();
}
-
+
/// \brief Build a new C++ static_cast expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1175,7 +1174,7 @@ public:
ExprArg SubExpr,
SourceLocation RParenLoc) {
return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_static_cast,
- LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
+ LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
LParenLoc, move(SubExpr), RParenLoc);
}
@@ -1191,7 +1190,7 @@ public:
ExprArg SubExpr,
SourceLocation RParenLoc) {
return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
- LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
+ LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
LParenLoc, move(SubExpr), RParenLoc);
}
@@ -1223,10 +1222,10 @@ public:
ExprArg SubExpr,
SourceLocation RParenLoc) {
return getSema().ActOnCXXNamedCast(OpLoc, tok::kw_const_cast,
- LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
+ LAngleLoc, T.getAsOpaquePtr(), RAngleLoc,
LParenLoc, move(SubExpr), RParenLoc);
}
-
+
/// \brief Build a new C++ functional-style cast expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1241,10 +1240,10 @@ public:
T.getAsOpaquePtr(),
LParenLoc,
Sema::MultiExprArg(getSema(), &Sub, 1),
- /*CommaLocs=*/0,
+ /*CommaLocs=*/0,
RParenLoc);
}
-
+
/// \brief Build a new C++ typeid(type) expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1253,10 +1252,10 @@ public:
SourceLocation LParenLoc,
QualType T,
SourceLocation RParenLoc) {
- return getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, true,
+ return getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, true,
T.getAsOpaquePtr(), RParenLoc);
}
-
+
/// \brief Build a new C++ typeid(expr) expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1265,22 +1264,22 @@ public:
SourceLocation LParenLoc,
ExprArg Operand,
SourceLocation RParenLoc) {
- OwningExprResult Result
+ OwningExprResult Result
= getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, false, Operand.get(),
RParenLoc);
if (Result.isInvalid())
return getSema().ExprError();
-
+
Operand.release(); // FIXME: since ActOnCXXTypeid silently took ownership
return move(Result);
- }
-
+ }
+
/// \brief Build a new C++ "this" expression.
///
/// By default, builds a new "this" expression without performing any
- /// semantic analysis. Subclasses may override this routine to provide
+ /// semantic analysis. Subclasses may override this routine to provide
/// different behavior.
- OwningExprResult RebuildCXXThisExpr(SourceLocation ThisLoc,
+ OwningExprResult RebuildCXXThisExpr(SourceLocation ThisLoc,
QualType ThisType) {
return getSema().Owned(
new (getSema().Context) CXXThisExpr(ThisLoc, ThisType));
@@ -1307,38 +1306,38 @@ public:
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildCXXZeroInitValueExpr(SourceLocation TypeStartLoc,
+ OwningExprResult RebuildCXXZeroInitValueExpr(SourceLocation TypeStartLoc,
SourceLocation LParenLoc,
QualType T,
SourceLocation RParenLoc) {
- return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeStartLoc),
- T.getAsOpaquePtr(), LParenLoc,
- MultiExprArg(getSema(), 0, 0),
+ return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeStartLoc),
+ T.getAsOpaquePtr(), LParenLoc,
+ MultiExprArg(getSema(), 0, 0),
0, RParenLoc);
}
-
+
/// \brief Build a new C++ conditional declaration expression.
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildCXXConditionDeclExpr(SourceLocation StartLoc,
+ OwningExprResult RebuildCXXConditionDeclExpr(SourceLocation StartLoc,
SourceLocation EqLoc,
VarDecl *Var) {
return SemaRef.Owned(new (SemaRef.Context) CXXConditionDeclExpr(StartLoc,
EqLoc,
Var));
}
-
+
/// \brief Build a new C++ "new" expression.
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
- OwningExprResult RebuildCXXNewExpr(SourceLocation StartLoc,
+ OwningExprResult RebuildCXXNewExpr(SourceLocation StartLoc,
bool UseGlobal,
SourceLocation PlacementLParen,
MultiExprArg PlacementArgs,
SourceLocation PlacementRParen,
- bool ParenTypeId,
+ bool ParenTypeId,
QualType AllocType,
SourceLocation TypeLoc,
SourceRange TypeRange,
@@ -1346,7 +1345,7 @@ public:
SourceLocation ConstructorLParen,
MultiExprArg ConstructorArgs,
SourceLocation ConstructorRParen) {
- return getSema().BuildCXXNew(StartLoc, UseGlobal,
+ return getSema().BuildCXXNew(StartLoc, UseGlobal,
PlacementLParen,
move(PlacementArgs),
PlacementRParen,
@@ -1359,7 +1358,7 @@ public:
move(ConstructorArgs),
ConstructorRParen);
}
-
+
/// \brief Build a new C++ "delete" expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1371,7 +1370,7 @@ public:
return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
move(Operand));
}
-
+
/// \brief Build a new unary type trait expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1381,7 +1380,7 @@ public:
SourceLocation LParenLoc,
QualType T,
SourceLocation RParenLoc) {
- return getSema().ActOnUnaryTypeTrait(Trait, StartLoc, LParenLoc,
+ return getSema().ActOnUnaryTypeTrait(Trait, StartLoc, LParenLoc,
T.getAsOpaquePtr(), RParenLoc);
}
@@ -1397,7 +1396,7 @@ public:
CXXScopeSpec SS;
SS.setRange(QualifierRange);
SS.setScopeRep(NNS);
- return getSema().ActOnDeclarationNameExpr(/*Scope=*/0,
+ return getSema().ActOnDeclarationNameExpr(/*Scope=*/0,
Location,
ND->getDeclName(),
/*Trailing lparen=*/false,
@@ -1405,7 +1404,7 @@ public:
IsAddressOfOperand);
}
- /// \brief Build a new (previously unresolved) declaration reference
+ /// \brief Build a new (previously unresolved) declaration reference
/// expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1418,7 +1417,7 @@ public:
CXXScopeSpec SS;
SS.setRange(QualifierRange);
SS.setScopeRep(NNS);
- return getSema().ActOnDeclarationNameExpr(/*Scope=*/0,
+ return getSema().ActOnDeclarationNameExpr(/*Scope=*/0,
Location,
Name,
/*Trailing lparen=*/false,
@@ -1492,7 +1491,7 @@ public:
Commas,
RParenLoc);
}
-
+
/// \brief Build a new member reference expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1511,7 +1510,7 @@ public:
CXXScopeSpec SS;
SS.setRange(QualifierRange);
SS.setScopeRep(Qualifier);
-
+
return SemaRef.BuildMemberReferenceExpr(/*Scope=*/0,
move(Base), OperatorLoc, OpKind,
MemberLoc,
@@ -1540,30 +1539,30 @@ public:
SourceLocation RAngleLoc) {
OwningExprResult Base = move(BaseE);
tok::TokenKind OpKind = IsArrow? tok::arrow : tok::period;
-
+
CXXScopeSpec SS;
SS.setRange(QualifierRange);
SS.setScopeRep(Qualifier);
-
+
// FIXME: We're going to end up looking up the template based on its name,
// twice! Also, duplicates part of Sema::ActOnMemberTemplateIdReferenceExpr.
DeclarationName Name;
if (TemplateDecl *ActualTemplate = Template.getAsTemplateDecl())
Name = ActualTemplate->getDeclName();
- else if (OverloadedFunctionDecl *Ovl
+ else if (OverloadedFunctionDecl *Ovl
= Template.getAsOverloadedFunctionDecl())
Name = Ovl->getDeclName();
else
Name = Template.getAsDependentTemplateName()->getName();
-
- return SemaRef.BuildMemberReferenceExpr(/*Scope=*/0, move(Base),
+
+ return SemaRef.BuildMemberReferenceExpr(/*Scope=*/0, move(Base),
OperatorLoc, OpKind,
TemplateNameLoc, Name, true,
LAngleLoc, TemplateArgs,
NumTemplateArgs, RAngleLoc,
Sema::DeclPtrTy(), &SS);
}
-
+
/// \brief Build a new Objective-C @encode expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1573,7 +1572,7 @@ public:
SourceLocation RParenLoc) {
return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, T,
RParenLoc));
- }
+ }
/// \brief Build a new Objective-C protocol expression.
///
@@ -1589,9 +1588,9 @@ public:
AtLoc,
ProtoLoc,
LParenLoc,
- RParenLoc));
+ RParenLoc));
}
-
+
/// \brief Build a new shuffle vector expression.
///
/// By default, performs semantic analysis to build the new expression.
@@ -1600,20 +1599,20 @@ public:
MultiExprArg SubExprs,
SourceLocation RParenLoc) {
// Find the declaration for __builtin_shufflevector
- const IdentifierInfo &Name
+ const IdentifierInfo &Name
= SemaRef.Context.Idents.get("__builtin_shufflevector");
TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
assert(Lookup.first != Lookup.second && "No __builtin_shufflevector?");
-
+
// Build a reference to the __builtin_shufflevector builtin
FunctionDecl *Builtin = cast<FunctionDecl>(*Lookup.first);
- Expr *Callee
+ Expr *Callee
= new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(),
BuiltinLoc, false, false);
SemaRef.UsualUnaryConversions(Callee);
-
- // Build the CallExpr
+
+ // Build the CallExpr
unsigned NumSubExprs = SubExprs.size();
Expr **Subs = (Expr **)SubExprs.release();
CallExpr *TheCall = new (SemaRef.Context) CallExpr(SemaRef.Context, Callee,
@@ -1621,14 +1620,14 @@ public:
Builtin->getResultType(),
RParenLoc);
OwningExprResult OwnedCall(SemaRef.Owned(TheCall));
-
+
// Type-check the __builtin_shufflevector expression.
OwningExprResult Result = SemaRef.SemaBuiltinShuffleVector(TheCall);
if (Result.isInvalid())
return SemaRef.ExprError();
-
+
OwnedCall.release();
- return move(Result);
+ return move(Result);
}
};
@@ -1636,16 +1635,16 @@ template<typename Derived>
Sema::OwningStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
if (!S)
return SemaRef.Owned(S);
-
+
switch (S->getStmtClass()) {
case Stmt::NoStmtClass: break;
-
+
// Transform individual statement nodes
#define STMT(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
#define EXPR(Node, Parent)
#include "clang/AST/StmtNodes.def"
-
+
// Transform expressions by calling TransformExpr.
#define STMT(Node, Parent)
#define EXPR(Node, Parent) case Stmt::Node##Class:
@@ -1654,15 +1653,15 @@ Sema::OwningStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
Sema::OwningExprResult E = getDerived().TransformExpr(cast<Expr>(S));
if (E.isInvalid())
return getSema().StmtError();
-
+
return getSema().Owned(E.takeAs<Stmt>());
}
- }
-
+ }
+
return SemaRef.Owned(S->Retain());
}
-
-
+
+
template<typename Derived>
Sema::OwningExprResult TreeTransform<Derived>::TransformExpr(Expr *E,
bool isAddressOfOperand) {
@@ -1675,8 +1674,8 @@ Sema::OwningExprResult TreeTransform<Derived>::TransformExpr(Expr *E,
#define EXPR(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
#include "clang/AST/StmtNodes.def"
- }
-
+ }
+
return SemaRef.Owned(E->Retain());
}
@@ -1688,75 +1687,75 @@ TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
NamedDecl *FirstQualifierInScope) {
if (!NNS)
return 0;
-
+
// Transform the prefix of this nested name specifier.
NestedNameSpecifier *Prefix = NNS->getPrefix();
if (Prefix) {
- Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range,
+ Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range,
ObjectType,
FirstQualifierInScope);
if (!Prefix)
return 0;
-
- // Clear out the object type and the first qualifier in scope; they only
+
+ // Clear out the object type and the first qualifier in scope; they only
// apply to the first element in the nested-name-specifier.
ObjectType = QualType();
FirstQualifierInScope = 0;
}
-
+
switch (NNS->getKind()) {
case NestedNameSpecifier::Identifier:
- assert((Prefix || !ObjectType.isNull()) &&
+ assert((Prefix || !ObjectType.isNull()) &&
"Identifier nested-name-specifier with no prefix or object type");
if (!getDerived().AlwaysRebuild() && Prefix == NNS->getPrefix() &&
ObjectType.isNull())
return NNS;
-
- return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
+
+ return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
*NNS->getAsIdentifier(),
ObjectType,
FirstQualifierInScope);
-
+
case NestedNameSpecifier::Namespace: {
- NamespaceDecl *NS
+ NamespaceDecl *NS
= cast_or_null<NamespaceDecl>(
getDerived().TransformDecl(NNS->getAsNamespace()));
- if (!getDerived().AlwaysRebuild() &&
+ if (!getDerived().AlwaysRebuild() &&
Prefix == NNS->getPrefix() &&
NS == NNS->getAsNamespace())
return NNS;
-
+
return getDerived().RebuildNestedNameSpecifier(Prefix, Range, NS);
}
-
+
case NestedNameSpecifier::Global:
// There is no meaningful transformation that one could perform on the
// global scope.
return NNS;
-
+
case NestedNameSpecifier::TypeSpecWithTemplate:
case NestedNameSpecifier::TypeSpec: {
QualType T = getDerived().TransformType(QualType(NNS->getAsType(), 0));
if (T.isNull())
return 0;
-
+
if (!getDerived().AlwaysRebuild() &&
Prefix == NNS->getPrefix() &&
T == QualType(NNS->getAsType(), 0))
return NNS;
-
- return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
- NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
+
+ return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
+ NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
T);
}
}
-
+
// Required to silence a GCC warning
- return 0;
+ return 0;
}
template<typename Derived>
-DeclarationName
+DeclarationName
TreeTransform<Derived>::TransformDeclarationName(DeclarationName Name,
SourceLocation Loc) {
if (!Name)
@@ -1770,7 +1769,7 @@ TreeTransform<Derived>::TransformDeclarationName(DeclarationName Name,
case DeclarationName::CXXOperatorName:
case DeclarationName::CXXUsingDirective:
return Name;
-
+
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName: {
@@ -1778,151 +1777,151 @@ TreeTransform<Derived>::TransformDeclarationName(DeclarationName Name,
QualType T = getDerived().TransformType(Name.getCXXNameType());
if (T.isNull())
return DeclarationName();
-
+
return SemaRef.Context.DeclarationNames.getCXXSpecialName(
- Name.getNameKind(),
+ Name.getNameKind(),
SemaRef.Context.getCanonicalType(T));
- }
}
-
+ }
+
return DeclarationName();
}
template<typename Derived>
-TemplateName
+TemplateName
TreeTransform<Derived>::TransformTemplateName(TemplateName Name,
QualType ObjectType) {
if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(QTN->getQualifier(),
/*FIXME:*/SourceRange(getDerived().getBaseLocation()));
if (!NNS)
return TemplateName();
-
+
if (TemplateDecl *Template = QTN->getTemplateDecl()) {
- TemplateDecl *TransTemplate
+ TemplateDecl *TransTemplate
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(Template));
if (!TransTemplate)
return TemplateName();
-
+
if (!getDerived().AlwaysRebuild() &&
NNS == QTN->getQualifier() &&
TransTemplate == Template)
return Name;
-
+
return getDerived().RebuildTemplateName(NNS, QTN->hasTemplateKeyword(),
TransTemplate);
}
-
+
OverloadedFunctionDecl *Ovl = QTN->getOverloadedFunctionDecl();
assert(Ovl && "Not a template name or an overload set?");
- OverloadedFunctionDecl *TransOvl
+ OverloadedFunctionDecl *TransOvl
= cast_or_null<OverloadedFunctionDecl>(getDerived().TransformDecl(Ovl));
if (!TransOvl)
return TemplateName();
-
+
if (!getDerived().AlwaysRebuild() &&
NNS == QTN->getQualifier() &&
TransOvl == Ovl)
return Name;
-
+
return getDerived().RebuildTemplateName(NNS, QTN->hasTemplateKeyword(),
TransOvl);
}
-
+
if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
- NestedNameSpecifier *NNS
+ NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(DTN->getQualifier(),
/*FIXME:*/SourceRange(getDerived().getBaseLocation()));
if (!NNS && DTN->getQualifier())
return TemplateName();
-
+
if (!getDerived().AlwaysRebuild() &&
NNS == DTN->getQualifier())
return Name;
-
+
return getDerived().RebuildTemplateName(NNS, *DTN->getName(), ObjectType);
}
-
+
if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
- TemplateDecl *TransTemplate
+ TemplateDecl *TransTemplate
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(Template));
if (!TransTemplate)
return TemplateName();
-
+
if (!getDerived().AlwaysRebuild() &&
TransTemplate == Template)
return Name;
-
+
return TemplateName(TransTemplate);
}
-
+
OverloadedFunctionDecl *Ovl = Name.getAsOverloadedFunctionDecl();
assert(Ovl && "Not a template name or an overload set?");
- OverloadedFunctionDecl *TransOvl
+ OverloadedFunctionDecl *TransOvl
= cast_or_null<OverloadedFunctionDecl>(getDerived().TransformDecl(Ovl));
if (!TransOvl)
return TemplateName();
-
+
if (!getDerived().AlwaysRebuild() &&
TransOvl == Ovl)
return Name;
-
+
return TemplateName(TransOvl);
}
template<typename Derived>
-TemplateArgument
+TemplateArgument
TreeTransform<Derived>::TransformTemplateArgument(const TemplateArgument &Arg) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
case TemplateArgument::Integral:
return Arg;
-
+
case TemplateArgument::Type: {
QualType T = getDerived().TransformType(Arg.getAsType());
if (T.isNull())
return TemplateArgument();
return TemplateArgument(Arg.getLocation(), T);
}
-
+
case TemplateArgument::Declaration: {
Decl *D = getDerived().TransformDecl(Arg.getAsDecl());
if (!D)
return TemplateArgument();
return TemplateArgument(Arg.getLocation(), D);
}
-
+
case TemplateArgument::Expression: {
// Template argument expressions are not potentially evaluated.
- EnterExpressionEvaluationContext Unevaluated(getSema(),
+ EnterExpressionEvaluationContext Unevaluated(getSema(),
Action::Unevaluated);
-
+
Sema::OwningExprResult E = getDerived().TransformExpr(Arg.getAsExpr());
if (E.isInvalid())
return TemplateArgument();
return TemplateArgument(E.takeAs<Expr>());
}
-
+
case TemplateArgument::Pack: {
llvm::SmallVector<TemplateArgument, 4> TransformedArgs;
TransformedArgs.reserve(Arg.pack_size());
- for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
+ for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
AEnd = Arg.pack_end();
A != AEnd; ++A) {
TemplateArgument TA = getDerived().TransformTemplateArgument(*A);
if (TA.isNull())
return TA;
-
+
TransformedArgs.push_back(TA);
}
TemplateArgument Result;
- Result.setArgumentPack(TransformedArgs.data(), TransformedArgs.size(),
+ Result.setArgumentPack(TransformedArgs.data(), TransformedArgs.size(),
true);
return Result;
}
}
-
+
// Work around bogus GCC warning
return TemplateArgument();
}
@@ -1935,126 +1934,126 @@ template<typename Derived>
QualType TreeTransform<Derived>::TransformType(QualType T) {
if (getDerived().AlreadyTransformed(T))
return T;
-
+
QualType Result;
switch (T->getTypeClass()) {
-#define ABSTRACT_TYPE(CLASS, PARENT)
+#define ABSTRACT_TYPE(CLASS, PARENT)
#define TYPE(CLASS, PARENT) \
case Type::CLASS: \
Result = getDerived().Transform##CLASS##Type( \
static_cast<CLASS##Type*>(T.getTypePtr())); \
break;
-#include "clang/AST/TypeNodes.def"
+#include "clang/AST/TypeNodes.def"
}
-
+
if (Result.isNull() || T == Result)
return Result;
-
+
return getDerived().AddTypeQualifiers(Result, T.getCVRQualifiers());
}
-
+
template<typename Derived>
-QualType
+QualType
TreeTransform<Derived>::AddTypeQualifiers(QualType T, unsigned CVRQualifiers) {
if (CVRQualifiers && !T->isFunctionType() && !T->isReferenceType())
return T.getWithAdditionalQualifiers(CVRQualifiers);
-
+
return T;
}
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformExtQualType(const ExtQualType *T) {
+template<typename Derived>
+QualType TreeTransform<Derived>::TransformExtQualType(const ExtQualType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
+
template<typename Derived>
-QualType TreeTransform<Derived>::TransformBuiltinType(const BuiltinType *T) {
+QualType TreeTransform<Derived>::TransformBuiltinType(const BuiltinType *T) {
// Nothing to do
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformFixedWidthIntType(
- const FixedWidthIntType *T) {
+ const FixedWidthIntType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
+
template<typename Derived>
-QualType TreeTransform<Derived>::TransformComplexType(const ComplexType *T) {
+QualType TreeTransform<Derived>::TransformComplexType(const ComplexType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformPointerType(const PointerType *T) {
QualType PointeeType = getDerived().TransformType(T->getPointeeType());
if (PointeeType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
PointeeType == T->getPointeeType())
return QualType(T, 0);
return getDerived().RebuildPointerType(PointeeType);
}
-
-template<typename Derived>
-QualType
-TreeTransform<Derived>::TransformBlockPointerType(const BlockPointerType *T) {
+
+template<typename Derived>
+QualType
+TreeTransform<Derived>::TransformBlockPointerType(const BlockPointerType *T) {
QualType PointeeType = getDerived().TransformType(T->getPointeeType());
if (PointeeType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
PointeeType == T->getPointeeType())
return QualType(T, 0);
-
+
return getDerived().RebuildBlockPointerType(PointeeType);
}
-template<typename Derived>
-QualType
+template<typename Derived>
+QualType
TreeTransform<Derived>::TransformLValueReferenceType(
- const LValueReferenceType *T) {
+ const LValueReferenceType *T) {
QualType PointeeType = getDerived().TransformType(T->getPointeeType());
if (PointeeType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
PointeeType == T->getPointeeType())
return QualType(T, 0);
-
+
return getDerived().RebuildLValueReferenceType(PointeeType);
}
-template<typename Derived>
-QualType
+template<typename Derived>
+QualType
TreeTransform<Derived>::TransformRValueReferenceType(
- const RValueReferenceType *T) {
+ const RValueReferenceType *T) {
QualType PointeeType = getDerived().TransformType(T->getPointeeType());
if (PointeeType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
PointeeType == T->getPointeeType())
return QualType(T, 0);
-
+
return getDerived().RebuildRValueReferenceType(PointeeType);
}
-
+
template<typename Derived>
-QualType
-TreeTransform<Derived>::TransformMemberPointerType(const MemberPointerType *T) {
+QualType
+TreeTransform<Derived>::TransformMemberPointerType(const MemberPointerType *T) {
QualType PointeeType = getDerived().TransformType(T->getPointeeType());
if (PointeeType.isNull())
return QualType();
-
+
QualType ClassType = getDerived().TransformType(QualType(T->getClass(), 0));
if (ClassType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
PointeeType == T->getPointeeType() &&
ClassType == QualType(T->getClass(), 0))
@@ -2063,76 +2062,76 @@ TreeTransform<Derived>::TransformMemberPointerType(const MemberPointerType *T) {
return getDerived().RebuildMemberPointerType(PointeeType, ClassType);
}
-template<typename Derived>
-QualType
-TreeTransform<Derived>::TransformConstantArrayType(const ConstantArrayType *T) {
+template<typename Derived>
+QualType
+TreeTransform<Derived>::TransformConstantArrayType(const ConstantArrayType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType())
return QualType(T, 0);
-
- return getDerived().RebuildConstantArrayType(ElementType,
+
+ return getDerived().RebuildConstantArrayType(ElementType,
T->getSizeModifier(),
T->getSize(),
T->getIndexTypeQualifier());
}
-
+
template<typename Derived>
-QualType
+QualType
TreeTransform<Derived>::TransformConstantArrayWithExprType(
- const ConstantArrayWithExprType *T) {
+ const ConstantArrayWithExprType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
// Array bounds are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
Sema::OwningExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
if (Size.isInvalid())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType() &&
Size.get() == T->getSizeExpr())
return QualType(T, 0);
-
- return getDerived().RebuildConstantArrayWithExprType(ElementType,
+
+ return getDerived().RebuildConstantArrayWithExprType(ElementType,
T->getSizeModifier(),
T->getSize(),
Size.takeAs<Expr>(),
T->getIndexTypeQualifier(),
T->getBracketsRange());
}
-
-template<typename Derived>
-QualType
+
+template<typename Derived>
+QualType
TreeTransform<Derived>::TransformConstantArrayWithoutExprType(
- const ConstantArrayWithoutExprType *T) {
+ const ConstantArrayWithoutExprType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType())
return QualType(T, 0);
-
- return getDerived().RebuildConstantArrayWithoutExprType(ElementType,
+
+ return getDerived().RebuildConstantArrayWithoutExprType(ElementType,
T->getSizeModifier(),
T->getSize(),
T->getIndexTypeQualifier());
}
-template<typename Derived>
+template<typename Derived>
QualType TreeTransform<Derived>::TransformIncompleteArrayType(
- const IncompleteArrayType *T) {
+ const IncompleteArrayType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType())
return QualType(T, 0);
@@ -2141,91 +2140,91 @@ QualType TreeTransform<Derived>::TransformIncompleteArrayType(
T->getSizeModifier(),
T->getIndexTypeQualifier());
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::TransformVariableArrayType(
- const VariableArrayType *T) {
+ const VariableArrayType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
// Array bounds are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
Sema::OwningExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
if (Size.isInvalid())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType() &&
Size.get() == T->getSizeExpr()) {
Size.take();
return QualType(T, 0);
}
-
- return getDerived().RebuildVariableArrayType(ElementType,
+
+ return getDerived().RebuildVariableArrayType(ElementType,
T->getSizeModifier(),
move(Size),
T->getIndexTypeQualifier(),
T->getBracketsRange());
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformDependentSizedArrayType(
- const DependentSizedArrayType *T) {
+ const DependentSizedArrayType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
// Array bounds are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
Sema::OwningExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
if (Size.isInvalid())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType() &&
Size.get() == T->getSizeExpr()) {
Size.take();
return QualType(T, 0);
}
-
- return getDerived().RebuildDependentSizedArrayType(ElementType,
+
+ return getDerived().RebuildDependentSizedArrayType(ElementType,
T->getSizeModifier(),
move(Size),
T->getIndexTypeQualifier(),
T->getBracketsRange());
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
- const DependentSizedExtVectorType *T) {
+ const DependentSizedExtVectorType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
// Vector sizes are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
Sema::OwningExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
if (Size.isInvalid())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType() &&
Size.get() == T->getSizeExpr()) {
Size.take();
return QualType(T, 0);
}
-
- return getDerived().RebuildDependentSizedExtVectorType(ElementType,
+
+ return getDerived().RebuildDependentSizedExtVectorType(ElementType,
move(Size),
T->getAttributeLoc());
}
-
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformVectorType(const VectorType *T) {
+
+template<typename Derived>
+QualType TreeTransform<Derived>::TransformVectorType(const VectorType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
@@ -2233,80 +2232,80 @@ QualType TreeTransform<Derived>::TransformVectorType(const VectorType *T) {
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType())
return QualType(T, 0);
-
+
return getDerived().RebuildVectorType(ElementType, T->getNumElements());
}
-
-template<typename Derived>
-QualType
-TreeTransform<Derived>::TransformExtVectorType(const ExtVectorType *T) {
+
+template<typename Derived>
+QualType
+TreeTransform<Derived>::TransformExtVectorType(const ExtVectorType *T) {
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
ElementType == T->getElementType())
return QualType(T, 0);
-
+
return getDerived().RebuildExtVectorType(ElementType, T->getNumElements(),
/*FIXME*/SourceLocation());
}
-template<typename Derived>
+template<typename Derived>
QualType TreeTransform<Derived>::TransformFunctionProtoType(
- const FunctionProtoType *T) {
+ const FunctionProtoType *T) {
QualType ResultType = getDerived().TransformType(T->getResultType());
if (ResultType.isNull())
return QualType();
-
+
llvm::SmallVector<QualType, 4> ParamTypes;
for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(),
- ParamEnd = T->arg_type_end();
+ ParamEnd = T->arg_type_end();
Param != ParamEnd; ++Param) {
QualType P = getDerived().TransformType(*Param);
if (P.isNull())
return QualType();
-
+
ParamTypes.push_back(P);
}
-
+
if (!getDerived().AlwaysRebuild() &&
ResultType == T->getResultType() &&
std::equal(T->arg_type_begin(), T->arg_type_end(), ParamTypes.begin()))
return QualType(T, 0);
-
- return getDerived().RebuildFunctionProtoType(ResultType, ParamTypes.data(),
+
+ return getDerived().RebuildFunctionProtoType(ResultType, ParamTypes.data(),
ParamTypes.size(), T->isVariadic(),
T->getTypeQuals());
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
- const FunctionNoProtoType *T) {
+ const FunctionNoProtoType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
+
template<typename Derived>
-QualType TreeTransform<Derived>::TransformTypedefType(const TypedefType *T) {
+QualType TreeTransform<Derived>::TransformTypedefType(const TypedefType *T) {
TypedefDecl *Typedef
= cast_or_null<TypedefDecl>(getDerived().TransformDecl(T->getDecl()));
if (!Typedef)
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
Typedef == T->getDecl())
return QualType(T, 0);
-
+
return getDerived().RebuildTypedefType(Typedef);
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::TransformTypeOfExprType(
- const TypeOfExprType *T) {
+ const TypeOfExprType *T) {
// typeof expressions are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
Sema::OwningExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
if (E.isInvalid())
return QualType();
@@ -2316,66 +2315,66 @@ QualType TreeTransform<Derived>::TransformTypeOfExprType(
E.take();
return QualType(T, 0);
}
-
+
return getDerived().RebuildTypeOfExprType(move(E));
}
-
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformTypeOfType(const TypeOfType *T) {
+
+template<typename Derived>
+QualType TreeTransform<Derived>::TransformTypeOfType(const TypeOfType *T) {
QualType Underlying = getDerived().TransformType(T->getUnderlyingType());
if (Underlying.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
Underlying == T->getUnderlyingType())
return QualType(T, 0);
-
+
return getDerived().RebuildTypeOfType(Underlying);
}
-
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformDecltypeType(const DecltypeType *T) {
+
+template<typename Derived>
+QualType TreeTransform<Derived>::TransformDecltypeType(const DecltypeType *T) {
// decltype expressions are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
Sema::OwningExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
if (E.isInvalid())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
E.get() == T->getUnderlyingExpr()) {
E.take();
return QualType(T, 0);
}
-
+
return getDerived().RebuildDecltypeType(move(E));
}
template<typename Derived>
-QualType TreeTransform<Derived>::TransformRecordType(const RecordType *T) {
+QualType TreeTransform<Derived>::TransformRecordType(const RecordType *T) {
RecordDecl *Record
= cast_or_null<RecordDecl>(getDerived().TransformDecl(T->getDecl()));
if (!Record)
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
Record == T->getDecl())
return QualType(T, 0);
-
+
return getDerived().RebuildRecordType(Record);
}
-
-template<typename Derived>
-QualType TreeTransform<Derived>::TransformEnumType(const EnumType *T) {
+
+template<typename Derived>
+QualType TreeTransform<Derived>::TransformEnumType(const EnumType *T) {
EnumDecl *Enum
= cast_or_null<EnumDecl>(getDerived().TransformDecl(T->getDecl()));
if (!Enum)
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
Enum == T->getDecl())
return QualType(T, 0);
-
+
return getDerived().RebuildEnumType(Enum);
}
@@ -2385,30 +2384,30 @@ QualType TreeTransform<Derived>::TransformElaboratedType(
QualType Underlying = getDerived().TransformType(T->getUnderlyingType());
if (Underlying.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
Underlying == T->getUnderlyingType())
return QualType(T, 0);
-
+
return getDerived().RebuildElaboratedType(Underlying, T->getTagKind());
}
-
-
+
+
template<typename Derived>
QualType TreeTransform<Derived>::TransformTemplateTypeParmType(
- const TemplateTypeParmType *T) {
+ const TemplateTypeParmType *T) {
// Nothing to do
- return QualType(T, 0);
+ return QualType(T, 0);
}
-template<typename Derived>
+template<typename Derived>
QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
- const TemplateSpecializationType *T) {
- TemplateName Template
+ const TemplateSpecializationType *T) {
+ TemplateName Template
= getDerived().TransformTemplateName(T->getTemplateName());
if (Template.isNull())
return QualType();
-
+
llvm::SmallVector<TemplateArgument, 4> NewTemplateArgs;
NewTemplateArgs.reserve(T->getNumArgs());
for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end();
@@ -2416,20 +2415,20 @@ QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
TemplateArgument NewArg = getDerived().TransformTemplateArgument(*Arg);
if (NewArg.isNull())
return QualType();
-
+
NewTemplateArgs.push_back(NewArg);
}
-
+
// FIXME: early abort if all of the template arguments and such are the
// same.
-
+
// FIXME: We're missing the locations of the template name, '<', and '>'.
return getDerived().RebuildTemplateSpecializationType(Template,
NewTemplateArgs.data(),
NewTemplateArgs.size());
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformQualifiedNameType(
const QualifiedNameType *T) {
NestedNameSpecifier *NNS
@@ -2437,11 +2436,11 @@ QualType TreeTransform<Derived>::TransformQualifiedNameType(
SourceRange());
if (!NNS)
return QualType();
-
+
QualType Named = getDerived().TransformType(T->getNamedType());
if (Named.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
NNS == T->getQualifier() &&
Named == T->getNamedType())
@@ -2449,44 +2448,44 @@ QualType TreeTransform<Derived>::TransformQualifiedNameType(
return getDerived().RebuildQualifiedNameType(NNS, Named);
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformTypenameType(const TypenameType *T) {
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
SourceRange(/*FIXME:*/getDerived().getBaseLocation()));
if (!NNS)
return QualType();
-
+
if (const TemplateSpecializationType *TemplateId = T->getTemplateId()) {
- QualType NewTemplateId
+ QualType NewTemplateId
= getDerived().TransformType(QualType(TemplateId, 0));
if (NewTemplateId.isNull())
return QualType();
-
+
if (!getDerived().AlwaysRebuild() &&
NNS == T->getQualifier() &&
NewTemplateId == QualType(TemplateId, 0))
return QualType(T, 0);
-
+
return getDerived().RebuildTypenameType(NNS, NewTemplateId);
}
return getDerived().RebuildTypenameType(NNS, T->getIdentifier());
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::TransformObjCInterfaceType(
- const ObjCInterfaceType *T) {
+ const ObjCInterfaceType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
-
-template<typename Derived>
+
+template<typename Derived>
QualType TreeTransform<Derived>::TransformObjCObjectPointerType(
- const ObjCObjectPointerType *T) {
+ const ObjCObjectPointerType *T) {
// FIXME: Implement
- return QualType(T, 0);
+ return QualType(T, 0);
}
//===----------------------------------------------------------------------===//
@@ -2494,8 +2493,8 @@ QualType TreeTransform<Derived>::TransformObjCObjectPointerType(
//===----------------------------------------------------------------------===//
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
- return SemaRef.Owned(S->Retain());
+TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
+ return SemaRef.Owned(S->Retain());
}
template<typename Derived>
@@ -2506,7 +2505,7 @@ TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S) {
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
+TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
bool IsStmtExpr) {
bool SubStmtChanged = false;
ASTOwningVector<&ActionBase::DeleteStmt> Statements(getSema());
@@ -2515,37 +2514,37 @@ TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
OwningStmtResult Result = getDerived().TransformStmt(*B);
if (Result.isInvalid())
return getSema().StmtError();
-
+
SubStmtChanged = SubStmtChanged || Result.get() != *B;
Statements.push_back(Result.takeAs<Stmt>());
}
-
+
if (!getDerived().AlwaysRebuild() &&
!SubStmtChanged)
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
move_arg(Statements),
S->getRBracLoc(),
IsStmtExpr);
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
+TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
// The case value expressions are not potentially evaluated.
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
// Transform the left-hand case value.
OwningExprResult LHS = getDerived().TransformExpr(S->getLHS());
if (LHS.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the right-hand case value (for the GNU case-range extension).
OwningExprResult RHS = getDerived().TransformExpr(S->getRHS());
if (RHS.isInvalid())
return SemaRef.StmtError();
-
+
// Build the case statement.
// Case statements are always rebuilt so that they will attached to their
// transformed switch statement.
@@ -2556,118 +2555,118 @@ TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
S->getColonLoc());
if (Case.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the statement following the case
OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
if (SubStmt.isInvalid())
return SemaRef.StmtError();
-
+
// Attach the body to the case statement
return getDerived().RebuildCaseStmtBody(move(Case), move(SubStmt));
}
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
+TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
// Transform the statement following the default case
OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
if (SubStmt.isInvalid())
return SemaRef.StmtError();
-
+
// Default statements are always rebuilt
return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
move(SubStmt));
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) {
+TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) {
OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
if (SubStmt.isInvalid())
return SemaRef.StmtError();
-
+
// FIXME: Pass the real colon location in.
SourceLocation ColonLoc = SemaRef.PP.getLocForEndOfToken(S->getIdentLoc());
return getDerived().RebuildLabelStmt(S->getIdentLoc(), S->getID(), ColonLoc,
move(SubStmt));
}
-
+
template<typename Derived>
-Sema::OwningStmtResult
-TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
+Sema::OwningStmtResult
+TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
// Transform the condition
OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
-
+
Sema::FullExprArg FullCond(getSema().FullExpr(Cond));
-
+
// Transform the "then" branch.
OwningStmtResult Then = getDerived().TransformStmt(S->getThen());
if (Then.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the "else" branch.
OwningStmtResult Else = getDerived().TransformStmt(S->getElse());
if (Else.isInvalid())
return SemaRef.StmtError();
-
+
if (!getDerived().AlwaysRebuild() &&
FullCond->get() == S->getCond() &&
Then.get() == S->getThen() &&
Else.get() == S->getElse())
- return SemaRef.Owned(S->Retain());
-
+ return SemaRef.Owned(S->Retain());
+
return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, move(Then),
- S->getElseLoc(), move(Else));
+ S->getElseLoc(), move(Else));
}
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
+TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
// Transform the condition.
OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
-
+
// Rebuild the switch statement.
OwningStmtResult Switch = getDerived().RebuildSwitchStmtStart(move(Cond));
if (Switch.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the body of the switch statement.
OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
if (Body.isInvalid())
return SemaRef.StmtError();
-
+
// Complete the switch statement.
return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), move(Switch),
move(Body));
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
+TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
// Transform the condition
OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
-
+
Sema::FullExprArg FullCond(getSema().FullExpr(Cond));
-
+
// Transform the body
OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
if (Body.isInvalid())
return SemaRef.StmtError();
-
+
if (!getDerived().AlwaysRebuild() &&
FullCond->get() == S->getCond() &&
Body.get() == S->getBody())
- return SemaRef.Owned(S->Retain());
-
+ return SemaRef.Owned(S->Retain());
+
return getDerived().RebuildWhileStmt(S->getWhileLoc(), FullCond, move(Body));
}
-
+
template<typename Derived>
Sema::OwningStmtResult
TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
@@ -2675,75 +2674,75 @@ TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the body
OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
if (Body.isInvalid())
return SemaRef.StmtError();
-
+
if (!getDerived().AlwaysRebuild() &&
Cond.get() == S->getCond() &&
Body.get() == S->getBody())
- return SemaRef.Owned(S->Retain());
-
+ return SemaRef.Owned(S->Retain());
+
return getDerived().RebuildDoStmt(S->getDoLoc(), move(Body), S->getWhileLoc(),
/*FIXME:*/S->getWhileLoc(), move(Cond),
S->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
+TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
// Transform the initialization statement
OwningStmtResult Init = getDerived().TransformStmt(S->getInit());
if (Init.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the condition
OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the increment
OwningExprResult Inc = getDerived().TransformExpr(S->getInc());
if (Inc.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the body
OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
if (Body.isInvalid())
return SemaRef.StmtError();
-
+
if (!getDerived().AlwaysRebuild() &&
Init.get() == S->getInit() &&
Cond.get() == S->getCond() &&
Inc.get() == S->getInc() &&
Body.get() == S->getBody())
- return SemaRef.Owned(S->Retain());
-
+ return SemaRef.Owned(S->Retain());
+
return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
move(Init), move(Cond), move(Inc),
S->getRParenLoc(), move(Body));
}
template<typename Derived>
-Sema::OwningStmtResult
-TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
+Sema::OwningStmtResult
+TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
// Goto statements must always be rebuilt, to resolve the label.
- return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
+ return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
S->getLabel());
}
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
+TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
OwningExprResult Target = getDerived().TransformExpr(S->getTarget());
if (Target.isInvalid())
return SemaRef.StmtError();
-
+
if (!getDerived().AlwaysRebuild() &&
Target.get() == S->getTarget())
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
move(Target));
@@ -2751,31 +2750,31 @@ TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
- return SemaRef.Owned(S->Retain());
+TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
+ return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
- return SemaRef.Owned(S->Retain());
+TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
+ return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
+TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
Sema::OwningExprResult Result = getDerived().TransformExpr(S->getRetValue());
if (Result.isInvalid())
return SemaRef.StmtError();
- // FIXME: We always rebuild the return statement because there is no way
+ // FIXME: We always rebuild the return statement because there is no way
// to tell whether the return type of the function has changed.
return getDerived().RebuildReturnStmt(S->getReturnLoc(), move(Result));
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
+TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
bool DeclChanged = false;
llvm::SmallVector<Decl *, 4> Decls;
for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
@@ -2783,25 +2782,25 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
Decl *Transformed = getDerived().TransformDefinition(*D);
if (!Transformed)
return SemaRef.StmtError();
-
+
if (Transformed != *D)
DeclChanged = true;
-
+
Decls.push_back(Transformed);
}
-
+
if (!getDerived().AlwaysRebuild() && !DeclChanged)
- return SemaRef.Owned(S->Retain());
-
- return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(),
+ return SemaRef.Owned(S->Retain());
+
+ return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(),
S->getStartLoc(), S->getEndLoc());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) {
+TreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) {
assert(false && "SwitchCase is abstract and cannot be transformed");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
template<typename Derived>
@@ -2809,58 +2808,58 @@ Sema::OwningStmtResult
TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
// FIXME: Implement!
assert(false && "Inline assembly cannot be transformed");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
+TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C @try statement");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
+TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C @catch statement");
return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
+TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C @finally statement");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
-TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
+TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C @throw statement");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
-
+
template<typename Derived>
Sema::OwningStmtResult
TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
- ObjCAtSynchronizedStmt *S) {
+ ObjCAtSynchronizedStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C @synchronized statement");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
template<typename Derived>
Sema::OwningStmtResult
TreeTransform<Derived>::TransformObjCForCollectionStmt(
- ObjCForCollectionStmt *S) {
+ ObjCForCollectionStmt *S) {
// FIXME: Implement this
assert(false && "Cannot transform an Objective-C for-each statement");
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
}
@@ -2877,7 +2876,7 @@ TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
QualType T = getDerived().TransformType(ExceptionDecl->getType());
if (T.isNull())
return SemaRef.StmtError();
-
+
Var = getDerived().RebuildExceptionDecl(ExceptionDecl,
T,
ExceptionDecl->getDeclaratorInfo(),
@@ -2891,7 +2890,7 @@ TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
return SemaRef.StmtError();
}
}
-
+
// Transform the actual exception handler.
OwningStmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
if (Handler.isInvalid()) {
@@ -2899,191 +2898,191 @@ TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
Var->Destroy(SemaRef.Context);
return SemaRef.StmtError();
}
-
+
if (!getDerived().AlwaysRebuild() &&
!Var &&
Handler.get() == S->getHandlerBlock())
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(),
Var,
move(Handler));
}
-
+
template<typename Derived>
Sema::OwningStmtResult
TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
// Transform the try block itself.
- OwningStmtResult TryBlock
+ OwningStmtResult TryBlock
= getDerived().TransformCompoundStmt(S->getTryBlock());
if (TryBlock.isInvalid())
return SemaRef.StmtError();
-
+
// Transform the handlers.
bool HandlerChanged = false;
ASTOwningVector<&ActionBase::DeleteStmt> Handlers(SemaRef);
for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
- OwningStmtResult Handler
+ OwningStmtResult Handler
= getDerived().TransformCXXCatchStmt(S->getHandler(I));
if (Handler.isInvalid())
return SemaRef.StmtError();
-
+
HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
Handlers.push_back(Handler.takeAs<Stmt>());
}
-
+
if (!getDerived().AlwaysRebuild() &&
TryBlock.get() == S->getTryBlock() &&
!HandlerChanged)
- return SemaRef.Owned(S->Retain());
+ return SemaRef.Owned(S->Retain());
return getDerived().RebuildCXXTryStmt(S->getTryLoc(), move(TryBlock),
- move_arg(Handlers));
+ move_arg(Handlers));
}
-
+
//===----------------------------------------------------------------------===//
// Expression transformation
//===----------------------------------------------------------------------===//
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
- return SemaRef.Owned(E->Retain());
-}
-
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
- NamedDecl *ND
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
+ return SemaRef.Owned(E->Retain());
+}
+
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
+ NamedDecl *ND
= dyn_cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getDecl()));
if (!ND)
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() && ND == E->getDecl())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildDeclRefExpr(ND, E->getLocation());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
- return SemaRef.Owned(E->Retain());
+
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildParenExpr(move(SubExpr), E->getLParen(),
+ return SemaRef.Owned(E->Retain());
+
+ return getDerived().RebuildParenExpr(move(SubExpr), E->getLParen(),
E->getRParen());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
E->getOpcode(),
move(SubExpr));
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
if (E->isArgumentType()) {
QualType T = getDerived().TransformType(E->getArgumentType());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() && T == E->getArgumentType())
return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildSizeOfAlignOf(T, E->getOperatorLoc(),
- E->isSizeOf(),
+
+ return getDerived().RebuildSizeOfAlignOf(T, E->getOperatorLoc(),
+ E->isSizeOf(),
E->getSourceRange());
}
-
+
Sema::OwningExprResult SubExpr(SemaRef);
- {
+ {
// C++0x [expr.sizeof]p1:
// The operand is either an expression, which is an unevaluated operand
// [...]
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
-
+
SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
return SemaRef.Owned(E->Retain());
}
-
+
return getDerived().RebuildSizeOfAlignOf(move(SubExpr), E->getOperatorLoc(),
E->isSizeOf(),
E->getSourceRange());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) {
OwningExprResult LHS = getDerived().TransformExpr(E->getLHS());
if (LHS.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult RHS = getDerived().TransformExpr(E->getRHS());
if (RHS.isInvalid())
return SemaRef.ExprError();
-
-
+
+
if (!getDerived().AlwaysRebuild() &&
LHS.get() == E->getLHS() &&
RHS.get() == E->getRHS())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildArraySubscriptExpr(move(LHS),
/*FIXME:*/E->getLHS()->getLocStart(),
move(RHS),
E->getRBracketLoc());
}
-
-template<typename Derived>
-Sema::OwningExprResult
+
+template<typename Derived>
+Sema::OwningExprResult
TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
// Transform the callee.
OwningExprResult Callee = getDerived().TransformExpr(E->getCallee());
@@ -3098,55 +3097,55 @@ TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
OwningExprResult Arg = getDerived().TransformExpr(E->getArg(I));
if (Arg.isInvalid())
return SemaRef.ExprError();
-
+
// FIXME: Wrong source location information for the ','.
FakeCommaLocs.push_back(
SemaRef.PP.getLocForEndOfToken(E->getArg(I)->getSourceRange().getEnd()));
-
- ArgChanged = ArgChanged || Arg.get() != E->getArg(I);
+
+ ArgChanged = ArgChanged || Arg.get() != E->getArg(I);
Args.push_back(Arg.takeAs<Expr>());
}
-
+
if (!getDerived().AlwaysRebuild() &&
Callee.get() == E->getCallee() &&
!ArgChanged)
return SemaRef.Owned(E->Retain());
-
+
// FIXME: Wrong source location information for the '('.
- SourceLocation FakeLParenLoc
+ SourceLocation FakeLParenLoc
= ((Expr *)Callee.get())->getSourceRange().getBegin();
return getDerived().RebuildCallExpr(move(Callee), FakeLParenLoc,
move_arg(Args),
FakeCommaLocs.data(),
E->getRParenLoc());
}
-
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
+
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
OwningExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return SemaRef.ExprError();
-
+
NestedNameSpecifier *Qualifier = 0;
if (E->hasQualifier()) {
- Qualifier
+ Qualifier
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange());
if (Qualifier == 0)
return SemaRef.ExprError();
}
-
- NamedDecl *Member
+
+ NamedDecl *Member
= cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getMemberDecl()));
if (!Member)
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
Base.get() == E->getBase() &&
Qualifier == E->getQualifier() &&
Member == E->getMemberDecl())
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
// FIXME: Bogus source location for the operator
SourceLocation FakeOperatorLoc
@@ -3157,208 +3156,208 @@ TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
Qualifier,
E->getQualifierRange(),
E->getMemberLoc(),
- Member);
+ Member);
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformCastExpr(CastExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformCastExpr(CastExpr *E) {
assert(false && "Cannot transform abstract class");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-
-template<typename Derived>
+
+template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
+TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
OwningExprResult LHS = getDerived().TransformExpr(E->getLHS());
if (LHS.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult RHS = getDerived().TransformExpr(E->getRHS());
if (RHS.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
LHS.get() == E->getLHS() &&
RHS.get() == E->getRHS())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
move(LHS), move(RHS));
}
-template<typename Derived>
+template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCompoundAssignOperator(
CompoundAssignOperator *E) {
return getDerived().TransformBinaryOperator(E);
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
OwningExprResult Cond = getDerived().TransformExpr(E->getCond());
if (Cond.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult LHS = getDerived().TransformExpr(E->getLHS());
if (LHS.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult RHS = getDerived().TransformExpr(E->getRHS());
if (RHS.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
Cond.get() == E->getCond() &&
LHS.get() == E->getLHS() &&
RHS.get() == E->getRHS())
return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildConditionalOperator(move(Cond),
+
+ return getDerived().RebuildConditionalOperator(move(Cond),
E->getQuestionLoc(),
- move(LHS),
+ move(LHS),
E->getColonLoc(),
move(RHS));
}
-
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
+
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
QualType T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType() &&
SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildImplicitCastExpr(T, E->getCastKind(),
- move(SubExpr),
+ move(SubExpr),
E->isLvalueCast());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformExplicitCastExpr(ExplicitCastExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformExplicitCastExpr(ExplicitCastExpr *E) {
assert(false && "Cannot transform abstract class");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
+TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
QualType T;
{
// FIXME: Source location isn't quite accurate.
- SourceLocation TypeStartLoc
+ SourceLocation TypeStartLoc
= SemaRef.PP.getLocForEndOfToken(E->getLParenLoc());
TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
-
+
T = getDerived().TransformType(E->getTypeAsWritten());
if (T.isNull())
return SemaRef.ExprError();
}
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getTypeAsWritten() &&
SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCStyleCaseExpr(E->getLParenLoc(), T,
E->getRParenLoc(),
move(SubExpr));
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
QualType T;
{
// FIXME: Source location isn't quite accurate.
- SourceLocation FakeTypeLoc
+ SourceLocation FakeTypeLoc
= SemaRef.PP.getLocForEndOfToken(E->getLParenLoc());
TemporaryBase Rebase(*this, FakeTypeLoc, DeclarationName());
-
+
T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
}
-
+
OwningExprResult Init = getDerived().TransformExpr(E->getInitializer());
if (Init.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType() &&
Init.get() == E->getInitializer())
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), T,
/*FIXME:*/E->getInitializer()->getLocEnd(),
move(Init));
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
+TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
OwningExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
Base.get() == E->getBase())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
// FIXME: Bad source location
- SourceLocation FakeOperatorLoc
+ SourceLocation FakeOperatorLoc
= SemaRef.PP.getLocForEndOfToken(E->getBase()->getLocEnd());
return getDerived().RebuildExtVectorElementExpr(move(Base), FakeOperatorLoc,
E->getAccessorLoc(),
E->getAccessor());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
bool InitChanged = false;
-
+
ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef);
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) {
OwningExprResult Init = getDerived().TransformExpr(E->getInit(I));
if (Init.isInvalid())
return SemaRef.ExprError();
-
+
InitChanged = InitChanged || Init.get() != E->getInit(I);
Inits.push_back(Init.takeAs<Expr>());
}
-
+
if (!getDerived().AlwaysRebuild() && !InitChanged)
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildInitList(E->getLBraceLoc(), move_arg(Inits),
E->getRBraceLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
+TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
Designation Desig;
-
+
// transform the initializer value
OwningExprResult Init = getDerived().TransformExpr(E->getInit());
if (Init.isInvalid())
return SemaRef.ExprError();
-
+
// transform the designators.
ASTOwningVector<&ActionBase::DeleteExpr, 4> ArrayExprs(SemaRef);
bool ExprChanged = false;
@@ -3371,73 +3370,73 @@ TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
D->getFieldLoc()));
continue;
}
-
+
if (D->isArrayDesignator()) {
OwningExprResult Index = getDerived().TransformExpr(E->getArrayIndex(*D));
if (Index.isInvalid())
return SemaRef.ExprError();
-
- Desig.AddDesignator(Designator::getArray(Index.get(),
+
+ Desig.AddDesignator(Designator::getArray(Index.get(),
D->getLBracketLoc()));
-
+
ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(*D);
ArrayExprs.push_back(Index.release());
continue;
}
-
+
assert(D->isArrayRangeDesignator() && "New kind of designator?");
- OwningExprResult Start
+ OwningExprResult Start
= getDerived().TransformExpr(E->getArrayRangeStart(*D));
if (Start.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(*D));
if (End.isInvalid())
return SemaRef.ExprError();
-
- Desig.AddDesignator(Designator::getArrayRange(Start.get(),
+
+ Desig.AddDesignator(Designator::getArrayRange(Start.get(),
End.get(),
D->getLBracketLoc(),
D->getEllipsisLoc()));
-
+
ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(*D) ||
End.get() != E->getArrayRangeEnd(*D);
-
+
ArrayExprs.push_back(Start.release());
ArrayExprs.push_back(End.release());
}
-
+
if (!getDerived().AlwaysRebuild() &&
Init.get() == E->getInit() &&
!ExprChanged)
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildDesignatedInitExpr(Desig, move_arg(ArrayExprs),
E->getEqualOrColonLoc(),
E->usesGNUSyntax(), move(Init));
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformImplicitValueInitExpr(
- ImplicitValueInitExpr *E) {
+ ImplicitValueInitExpr *E) {
QualType T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildImplicitValueInitExpr(T);
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
// FIXME: Do we want the type as written?
QualType T;
-
+
{
// FIXME: Source location isn't quite accurate.
TemporaryBase Rebase(*this, E->getBuiltinLoc(), DeclarationName());
@@ -3445,22 +3444,22 @@ TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
if (T.isNull())
return SemaRef.ExprError();
}
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType() &&
SubExpr.get() == E->getSubExpr())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), move(SubExpr),
T, E->getRParenLoc());
}
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef);
@@ -3468,16 +3467,16 @@ TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
OwningExprResult Init = getDerived().TransformExpr(E->getExpr(I));
if (Init.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || Init.get() != E->getExpr(I);
Inits.push_back(Init.takeAs<Expr>());
}
-
+
return getDerived().RebuildParenListExpr(E->getLParenLoc(),
move_arg(Inits),
E->getRParenLoc());
}
-
+
/// \brief Transform an address-of-label expression.
///
/// By default, the transformation of an address-of-label expression always
@@ -3485,39 +3484,39 @@ TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
/// the corresponding label statement by semantic analysis.
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
+TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
E->getLabel());
}
-
-template<typename Derived>
+
+template<typename Derived>
Sema::OwningExprResult TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
- OwningStmtResult SubStmt
+ OwningStmtResult SubStmt
= getDerived().TransformCompoundStmt(E->getSubStmt(), true);
if (SubStmt.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
SubStmt.get() == E->getSubStmt())
return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildStmtExpr(E->getLParenLoc(),
+
+ return getDerived().RebuildStmtExpr(E->getLParenLoc(),
move(SubStmt),
E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
+TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
QualType T1, T2;
{
// FIXME: Source location isn't quite accurate.
TemporaryBase Rebase(*this, E->getBuiltinLoc(), DeclarationName());
-
+
T1 = getDerived().TransformType(E->getArgType1());
if (T1.isNull())
return SemaRef.ExprError();
-
+
T2 = getDerived().TransformType(E->getArgType2());
if (T2.isNull())
return SemaRef.ExprError();
@@ -3526,42 +3525,42 @@ TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
if (!getDerived().AlwaysRebuild() &&
T1 == E->getArgType1() &&
T2 == E->getArgType2())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildTypesCompatibleExpr(E->getBuiltinLoc(),
T1, T2, E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
+TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
OwningExprResult Cond = getDerived().TransformExpr(E->getCond());
if (Cond.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult LHS = getDerived().TransformExpr(E->getLHS());
if (LHS.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult RHS = getDerived().TransformExpr(E->getRHS());
if (RHS.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
Cond.get() == E->getCond() &&
LHS.get() == E->getLHS() &&
RHS.get() == E->getRHS())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
move(Cond), move(LHS), move(RHS),
E->getRParenLoc());
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
+ return SemaRef.Owned(E->Retain());
}
template<typename Derived>
@@ -3570,7 +3569,7 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
OwningExprResult Callee = getDerived().TransformExpr(E->getCallee());
if (Callee.isInvalid())
return SemaRef.ExprError();
-
+
OwningExprResult First = getDerived().TransformExpr(E->getArg(0));
if (First.isInvalid())
return SemaRef.ExprError();
@@ -3581,59 +3580,59 @@ TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
if (Second.isInvalid())
return SemaRef.ExprError();
}
-
+
if (!getDerived().AlwaysRebuild() &&
Callee.get() == E->getCallee() &&
First.get() == E->getArg(0) &&
- (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
- return SemaRef.Owned(E->Retain());
-
+ (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
E->getOperatorLoc(),
- move(Callee),
+ move(Callee),
move(First),
move(Second));
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
+TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
return getDerived().TransformCallExpr(E);
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) {
QualType ExplicitTy;
{
// FIXME: Source location isn't quite accurate.
- SourceLocation TypeStartLoc
+ SourceLocation TypeStartLoc
= SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc());
TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
-
+
ExplicitTy = getDerived().TransformType(E->getTypeAsWritten());
if (ExplicitTy.isNull())
return SemaRef.ExprError();
}
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
ExplicitTy == E->getTypeAsWritten() &&
SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
// FIXME: Poor source location information here.
- SourceLocation FakeLAngleLoc
+ SourceLocation FakeLAngleLoc
= SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc());
SourceLocation FakeRAngleLoc = E->getSubExpr()->getSourceRange().getBegin();
SourceLocation FakeRParenLoc
= SemaRef.PP.getLocForEndOfToken(
E->getSubExpr()->getSourceRange().getEnd());
return getDerived().RebuildCXXNamedCastExpr(E->getOperatorLoc(),
- E->getStmtClass(),
+ E->getStmtClass(),
FakeLAngleLoc,
ExplicitTy,
FakeRAngleLoc,
@@ -3641,54 +3640,54 @@ TreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) {
move(SubExpr),
FakeRParenLoc);
}
-
+
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
return getDerived().TransformCXXNamedCastExpr(E);
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
+TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
return getDerived().TransformCXXNamedCastExpr(E);
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXReinterpretCastExpr(
- CXXReinterpretCastExpr *E) {
+ CXXReinterpretCastExpr *E) {
return getDerived().TransformCXXNamedCastExpr(E);
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
+TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
return getDerived().TransformCXXNamedCastExpr(E);
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
- CXXFunctionalCastExpr *E) {
+ CXXFunctionalCastExpr *E) {
QualType ExplicitTy;
{
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
-
+
ExplicitTy = getDerived().TransformType(E->getTypeAsWritten());
if (ExplicitTy.isNull())
return SemaRef.ExprError();
}
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
ExplicitTy == E->getTypeAsWritten() &&
SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
// FIXME: The end of the type's source range is wrong
return getDerived().RebuildCXXFunctionalCastExpr(
/*FIXME:*/SourceRange(E->getTypeBeginLoc()),
@@ -3697,41 +3696,41 @@ TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
move(SubExpr),
E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
+TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
if (E->isTypeOperand()) {
TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
-
+
QualType T = getDerived().TransformType(E->getTypeOperand());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getTypeOperand())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildCXXTypeidExpr(E->getLocStart(),
/*FIXME:*/E->getLocStart(),
T,
E->getLocEnd());
}
-
+
// We don't know whether the expression is potentially evaluated until
// after we perform semantic analysis, so the expression is potentially
// potentially evaluated.
- EnterExpressionEvaluationContext Unevaluated(SemaRef,
+ EnterExpressionEvaluationContext Unevaluated(SemaRef,
Action::PotentiallyPotentiallyEvaluated);
-
+
OwningExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
SubExpr.get() == E->getExprOperand())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCXXTypeidExpr(E->getLocStart(),
/*FIXME:*/E->getLocStart(),
move(SubExpr),
@@ -3739,63 +3738,63 @@ TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
}
template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
- return SemaRef.Owned(E->Retain());
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr(
- CXXNullPtrLiteralExpr *E) {
- return SemaRef.Owned(E->Retain());
+ CXXNullPtrLiteralExpr *E) {
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
-
+
QualType T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildCXXThisExpr(E->getLocStart(), T);
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
+TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
SubExpr.get() == E->getSubExpr())
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), move(SubExpr));
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
- ParmVarDecl *Param
+TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+ ParmVarDecl *Param
= cast_or_null<ParmVarDecl>(getDerived().TransformDecl(E->getParam()));
if (!Param)
return SemaRef.ExprError();
-
+
if (getDerived().AlwaysRebuild() &&
Param == E->getParam())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildCXXDefaultArgExpr(Param);
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) {
@@ -3804,48 +3803,48 @@ TreeTransform<Derived>::TransformCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) {
QualType T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType())
- return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildCXXZeroInitValueExpr(E->getTypeBeginLoc(),
+ return SemaRef.Owned(E->Retain());
+
+ return getDerived().RebuildCXXZeroInitValueExpr(E->getTypeBeginLoc(),
/*FIXME:*/E->getTypeBeginLoc(),
T,
E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXConditionDeclExpr(CXXConditionDeclExpr *E) {
- VarDecl *Var
+ VarDecl *Var
= cast_or_null<VarDecl>(getDerived().TransformDefinition(E->getVarDecl()));
if (!Var)
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
- Var == E->getVarDecl())
+ Var == E->getVarDecl())
return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildCXXConditionDeclExpr(E->getStartLoc(),
+
+ return getDerived().RebuildCXXConditionDeclExpr(E->getStartLoc(),
/*FIXME:*/E->getStartLoc(),
Var);
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
+TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
// Transform the type that we're allocating
TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
QualType AllocType = getDerived().TransformType(E->getAllocatedType());
if (AllocType.isNull())
return SemaRef.ExprError();
-
+
// Transform the size of the array we're allocating (if any).
OwningExprResult ArraySize = getDerived().TransformExpr(E->getArraySize());
if (ArraySize.isInvalid())
return SemaRef.ExprError();
-
+
// Transform the placement arguments (if any).
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> PlacementArgs(SemaRef);
@@ -3853,28 +3852,28 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
OwningExprResult Arg = getDerived().TransformExpr(E->getPlacementArg(I));
if (Arg.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || Arg.get() != E->getPlacementArg(I);
PlacementArgs.push_back(Arg.take());
}
-
+
// transform the constructor arguments (if any).
ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(SemaRef);
for (unsigned I = 0, N = E->getNumConstructorArgs(); I != N; ++I) {
OwningExprResult Arg = getDerived().TransformExpr(E->getConstructorArg(I));
if (Arg.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || Arg.get() != E->getConstructorArg(I);
ConstructorArgs.push_back(Arg.take());
}
-
+
if (!getDerived().AlwaysRebuild() &&
AllocType == E->getAllocatedType() &&
ArraySize.get() == E->getArraySize() &&
!ArgumentChanged)
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCXXNewExpr(E->getLocStart(),
E->isGlobalNew(),
/*FIXME:*/E->getLocStart(),
@@ -3887,26 +3886,26 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
move(ArraySize),
/*FIXME:*/E->getLocStart(),
move_arg(ConstructorArgs),
- E->getLocEnd());
+ E->getLocEnd());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
+TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
OwningExprResult Operand = getDerived().TransformExpr(E->getArgument());
if (Operand.isInvalid())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
- Operand.get() == E->getArgument())
- return SemaRef.Owned(E->Retain());
-
+ Operand.get() == E->getArgument())
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCXXDeleteExpr(E->getLocStart(),
E->isGlobalDelete(),
E->isArrayForm(),
move(Operand));
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
@@ -3914,13 +3913,13 @@ TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
OwningExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return SemaRef.ExprError();
-
+
NestedNameSpecifier *Qualifier
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange());
if (E->getQualifier() && !Qualifier)
return SemaRef.ExprError();
-
+
QualType DestroyedType;
{
TemporaryBase Rebase(*this, E->getDestroyedTypeLoc(), DeclarationName());
@@ -3928,13 +3927,13 @@ TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
if (DestroyedType.isNull())
return SemaRef.ExprError();
}
-
+
if (!getDerived().AlwaysRebuild() &&
Base.get() == E->getBase() &&
Qualifier == E->getQualifier() &&
DestroyedType == E->getDestroyedType())
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildCXXPseudoDestructorExpr(move(Base),
E->getOperatorLoc(),
E->isArrow(),
@@ -3943,39 +3942,39 @@ TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
Qualifier,
E->getQualifierRange());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformUnresolvedFunctionNameExpr(
- UnresolvedFunctionNameExpr *E) {
+ UnresolvedFunctionNameExpr *E) {
// There is no transformation we can apply to an unresolved function name.
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
+TreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
-
+
QualType T = getDerived().TransformType(E->getQueriedType());
if (T.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getQueriedType())
return SemaRef.Owned(E->Retain());
-
+
// FIXME: Bad location information
SourceLocation FakeLParenLoc
= SemaRef.PP.getLocForEndOfToken(E->getLocStart());
-
- return getDerived().RebuildUnaryTypeTrait(E->getTrait(),
+
+ return getDerived().RebuildUnaryTypeTrait(E->getTrait(),
E->getLocStart(),
/*FIXME:*/FakeLParenLoc,
T,
E->getLocEnd());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformQualifiedDeclRefExpr(QualifiedDeclRefExpr *E) {
@@ -3984,45 +3983,45 @@ TreeTransform<Derived>::TransformQualifiedDeclRefExpr(QualifiedDeclRefExpr *E) {
E->getQualifierRange());
if (!NNS)
return SemaRef.ExprError();
-
- NamedDecl *ND
+
+ NamedDecl *ND
= dyn_cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getDecl()));
if (!ND)
return SemaRef.ExprError();
-
- if (!getDerived().AlwaysRebuild() &&
+
+ if (!getDerived().AlwaysRebuild() &&
NNS == E->getQualifier() &&
ND == E->getDecl())
- return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildQualifiedDeclRefExpr(NNS,
+ return SemaRef.Owned(E->Retain());
+
+ return getDerived().RebuildQualifiedDeclRefExpr(NNS,
E->getQualifierRange(),
ND,
E->getLocation(),
/*FIXME:*/false);
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformUnresolvedDeclRefExpr(
- UnresolvedDeclRefExpr *E) {
+ UnresolvedDeclRefExpr *E) {
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange());
if (!NNS)
return SemaRef.ExprError();
-
- DeclarationName Name
+
+ DeclarationName Name
= getDerived().TransformDeclarationName(E->getDeclName(), E->getLocation());
if (!Name)
return SemaRef.ExprError();
-
- if (!getDerived().AlwaysRebuild() &&
+
+ if (!getDerived().AlwaysRebuild() &&
NNS == E->getQualifier() &&
Name == E->getDeclName())
- return SemaRef.Owned(E->Retain());
-
- return getDerived().RebuildUnresolvedDeclRefExpr(NNS,
+ return SemaRef.Owned(E->Retain());
+
+ return getDerived().RebuildUnresolvedDeclRefExpr(NNS,
E->getQualifierRange(),
Name,
E->getLocation(),
@@ -4031,15 +4030,15 @@ TreeTransform<Derived>::TransformUnresolvedDeclRefExpr(
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformTemplateIdRefExpr(TemplateIdRefExpr *E) {
- TemplateName Template
+TreeTransform<Derived>::TransformTemplateIdRefExpr(TemplateIdRefExpr *E) {
+ TemplateName Template
= getDerived().TransformTemplateName(E->getTemplateName());
if (Template.isNull())
return SemaRef.ExprError();
-
+
llvm::SmallVector<TemplateArgument, 4> TransArgs;
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
- TemplateArgument TransArg
+ TemplateArgument TransArg
= getDerived().TransformTemplateArgument(E->getTemplateArgs()[I]);
if (TransArg.isNull())
return SemaRef.ExprError();
@@ -4049,8 +4048,8 @@ TreeTransform<Derived>::TransformTemplateIdRefExpr(TemplateIdRefExpr *E) {
// FIXME: Would like to avoid rebuilding if nothing changed, but we can't
// compare template arguments (yet).
-
- // FIXME: It's possible that we'll find out now that the template name
+
+ // FIXME: It's possible that we'll find out now that the template name
// actually refers to a type, in which case the caller is actually dealing
// with a functional cast. Give a reasonable error message!
return getDerived().RebuildTemplateIdExpr(Template, E->getTemplateNameLoc(),
@@ -4062,7 +4061,7 @@ TreeTransform<Derived>::TransformTemplateIdRefExpr(TemplateIdRefExpr *E) {
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
+TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
QualType T = getDerived().TransformType(E->getType());
@@ -4074,16 +4073,16 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
getDerived().TransformDecl(E->getConstructor()));
if (!Constructor)
return SemaRef.ExprError();
-
+
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef);
- for (CXXConstructExpr::arg_iterator Arg = E->arg_begin(),
+ for (CXXConstructExpr::arg_iterator Arg = E->arg_begin(),
ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg) {
OwningExprResult TransArg = getDerived().TransformExpr(*Arg);
if (TransArg.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
Args.push_back(TransArg.takeAs<Expr>());
}
@@ -4093,15 +4092,15 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
Constructor == E->getConstructor() &&
!ArgumentChanged)
return SemaRef.Owned(E->Retain());
-
+
return getDerived().RebuildCXXConstructExpr(T, Constructor, E->isElidable(),
move_arg(Args));
}
-
+
/// \brief Transform a C++ temporary-binding expression.
///
-/// The transformation of a temporary-binding expression always attempts to
-/// bind a new temporary variable to its subexpression, even if the
+/// The transformation of a temporary-binding expression always attempts to
+/// bind a new temporary variable to its subexpression, even if the
/// subexpression itself did not change, because the temporary variable itself
/// must be unique.
template<typename Derived>
@@ -4110,70 +4109,70 @@ TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
return SemaRef.MaybeBindToTemporary(SubExpr.takeAs<Expr>());
}
-
-/// \brief Transform a C++ expression that contains temporaries that should
+
+/// \brief Transform a C++ expression that contains temporaries that should
/// be destroyed after the expression is evaluated.
///
-/// The transformation of a full expression always attempts to build a new
-/// CXXExprWithTemporaries expression, even if the
+/// The transformation of a full expression always attempts to build a new
+/// CXXExprWithTemporaries expression, even if the
/// subexpression itself did not change, because it will need to capture the
/// the new temporary variables introduced in the subexpression.
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXExprWithTemporaries(
- CXXExprWithTemporaries *E) {
+ CXXExprWithTemporaries *E) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
return SemaRef.Owned(
SemaRef.MaybeCreateCXXExprWithTemporaries(SubExpr.takeAs<Expr>(),
E->shouldDestroyTemporaries()));
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
- CXXTemporaryObjectExpr *E) {
+ CXXTemporaryObjectExpr *E) {
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
QualType T = getDerived().TransformType(E->getType());
if (T.isNull())
return SemaRef.ExprError();
-
+
CXXConstructorDecl *Constructor
= cast_or_null<CXXConstructorDecl>(
getDerived().TransformDecl(E->getConstructor()));
if (!Constructor)
return SemaRef.ExprError();
-
+
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef);
Args.reserve(E->getNumArgs());
- for (CXXTemporaryObjectExpr::arg_iterator Arg = E->arg_begin(),
+ for (CXXTemporaryObjectExpr::arg_iterator Arg = E->arg_begin(),
ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg) {
OwningExprResult TransArg = getDerived().TransformExpr(*Arg);
if (TransArg.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
Args.push_back((Expr *)TransArg.release());
}
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getType() &&
Constructor == E->getConstructor() &&
!ArgumentChanged)
return SemaRef.Owned(E->Retain());
-
+
// FIXME: Bogus location information
SourceLocation CommaLoc;
if (Args.size() > 1) {
Expr *First = (Expr *)Args[0];
- CommaLoc
+ CommaLoc
= SemaRef.PP.getLocForEndOfToken(First->getSourceRange().getEnd());
}
return getDerived().RebuildCXXTemporaryObjectExpr(E->getTypeBeginLoc(),
@@ -4183,16 +4182,16 @@ TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
&CommaLoc,
E->getLocEnd());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
- CXXUnresolvedConstructExpr *E) {
+ CXXUnresolvedConstructExpr *E) {
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
QualType T = getDerived().TransformType(E->getTypeAsWritten());
if (T.isNull())
return SemaRef.ExprError();
-
+
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> Args(SemaRef);
llvm::SmallVector<SourceLocation, 8> FakeCommaLocs;
@@ -4202,18 +4201,18 @@ TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
OwningExprResult TransArg = getDerived().TransformExpr(*Arg);
if (TransArg.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
FakeCommaLocs.push_back(
SemaRef.PP.getLocForEndOfToken((*Arg)->getLocEnd()));
Args.push_back(TransArg.takeAs<Expr>());
}
-
+
if (!getDerived().AlwaysRebuild() &&
T == E->getTypeAsWritten() &&
!ArgumentChanged)
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
// FIXME: we're faking the locations of the commas
return getDerived().RebuildCXXUnresolvedConstructExpr(E->getTypeBeginLoc(),
T,
@@ -4222,31 +4221,31 @@ TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
FakeCommaLocs.data(),
E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCXXUnresolvedMemberExpr(
- CXXUnresolvedMemberExpr *E) {
+ CXXUnresolvedMemberExpr *E) {
// Transform the base of the expression.
OwningExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return SemaRef.ExprError();
-
+
Sema::TypeTy *ObjectType = 0;
- Base = SemaRef.ActOnStartCXXMemberReference(0, move(Base),
+ Base = SemaRef.ActOnStartCXXMemberReference(0, move(Base),
E->getOperatorLoc(),
E->isArrow()? tok::arrow : tok::period,
ObjectType);
if (Base.isInvalid())
return SemaRef.ExprError();
-
+
// FIXME: The first qualifier found might be a template type parameter,
// in which case there is no transformed declaration to refer to (it might
// refer to a built-in type!).
NamedDecl *FirstQualifierInScope
= cast_or_null<NamedDecl>(
getDerived().TransformDecl(E->getFirstQualifierFoundInScope()));
-
+
NestedNameSpecifier *Qualifier = 0;
if (E->getQualifier()) {
Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
@@ -4256,12 +4255,12 @@ TreeTransform<Derived>::TransformCXXUnresolvedMemberExpr(
if (!Qualifier)
return SemaRef.ExprError();
}
-
- DeclarationName Name
+
+ DeclarationName Name
= getDerived().TransformDeclarationName(E->getMember(), E->getMemberLoc());
if (!Name)
return SemaRef.ExprError();
-
+
if (!E->hasExplicitTemplateArgumentList()) {
// This is a reference to a member without an explicitly-specified
// template argument list. Optimize for this common case.
@@ -4270,8 +4269,8 @@ TreeTransform<Derived>::TransformCXXUnresolvedMemberExpr(
Qualifier == E->getQualifier() &&
Name == E->getMember() &&
FirstQualifierInScope == E->getFirstQualifierFoundInScope())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildCXXUnresolvedMemberExpr(move(Base),
E->isArrow(),
E->getOperatorLoc(),
@@ -4287,23 +4286,23 @@ TreeTransform<Derived>::TransformCXXUnresolvedMemberExpr(
// FIXME: This also won't work for, e.g., x->template operator+<int>
TemplateName OrigTemplateName
= SemaRef.Context.getDependentTemplateName(0, Name.getAsIdentifierInfo());
-
- TemplateName Template
- = getDerived().TransformTemplateName(OrigTemplateName,
+
+ TemplateName Template
+ = getDerived().TransformTemplateName(OrigTemplateName,
QualType::getFromOpaquePtr(ObjectType));
if (Template.isNull())
return SemaRef.ExprError();
-
+
llvm::SmallVector<TemplateArgument, 4> TransArgs;
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
- TemplateArgument TransArg
+ TemplateArgument TransArg
= getDerived().TransformTemplateArgument(E->getTemplateArgs()[I]);
if (TransArg.isNull())
return SemaRef.ExprError();
-
+
TransArgs.push_back(TransArg);
}
-
+
return getDerived().RebuildCXXUnresolvedMemberExpr(move(Base),
E->isArrow(),
E->getOperatorLoc(),
@@ -4320,46 +4319,46 @@ TreeTransform<Derived>::TransformCXXUnresolvedMemberExpr(
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
- return SemaRef.Owned(E->Retain());
+TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
// FIXME: poor source location
TemporaryBase Rebase(*this, E->getAtLoc(), DeclarationName());
QualType EncodedType = getDerived().TransformType(E->getEncodedType());
if (EncodedType.isNull())
return SemaRef.ExprError();
-
+
if (!getDerived().AlwaysRebuild() &&
EncodedType == E->getEncodedType())
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
EncodedType,
E->getRParenLoc());
}
-
+
template<typename Derived>
Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
+TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
- return SemaRef.Owned(E->Retain());
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
- ObjCProtocolDecl *Protocol
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
+ ObjCProtocolDecl *Protocol
= cast_or_null<ObjCProtocolDecl>(
getDerived().TransformDecl(E->getProtocol()));
if (!Protocol)
@@ -4367,140 +4366,140 @@ TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
if (!getDerived().AlwaysRebuild() &&
Protocol == E->getProtocol())
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildObjCProtocolExpr(Protocol,
E->getAtLoc(),
/*FIXME:*/E->getAtLoc(),
/*FIXME:*/E->getAtLoc(),
E->getRParenLoc());
-
+
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
+template<typename Derived>
+Sema::OwningExprResult
TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
+template<typename Derived>
+Sema::OwningExprResult
TreeTransform<Derived>::TransformObjCImplicitSetterGetterRefExpr(
- ObjCImplicitSetterGetterRefExpr *E) {
+ ObjCImplicitSetterGetterRefExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCSuperExpr(ObjCSuperExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCSuperExpr(ObjCSuperExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform Objective-C expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
bool ArgumentChanged = false;
ASTOwningVector<&ActionBase::DeleteExpr> SubExprs(SemaRef);
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) {
OwningExprResult SubExpr = getDerived().TransformExpr(E->getExpr(I));
if (SubExpr.isInvalid())
return SemaRef.ExprError();
-
+
ArgumentChanged = ArgumentChanged || SubExpr.get() != E->getExpr(I);
SubExprs.push_back(SubExpr.takeAs<Expr>());
}
-
+
if (!getDerived().AlwaysRebuild() &&
!ArgumentChanged)
- return SemaRef.Owned(E->Retain());
-
+ return SemaRef.Owned(E->Retain());
+
return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
move_arg(SubExprs),
E->getRParenLoc());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform block expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-template<typename Derived>
-Sema::OwningExprResult
-TreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) {
+template<typename Derived>
+Sema::OwningExprResult
+TreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) {
// FIXME: Implement this!
assert(false && "Cannot transform block-related expressions yet");
- return SemaRef.Owned(E->Retain());
+ return SemaRef.Owned(E->Retain());
}
-
+
//===----------------------------------------------------------------------===//
// Type reconstruction
//===----------------------------------------------------------------------===//
-template<typename Derived>
+template<typename Derived>
QualType TreeTransform<Derived>::RebuildPointerType(QualType PointeeType) {
- return SemaRef.BuildPointerType(PointeeType, 0,
+ return SemaRef.BuildPointerType(PointeeType, 0,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
-template<typename Derived>
+template<typename Derived>
QualType TreeTransform<Derived>::RebuildBlockPointerType(QualType PointeeType) {
- return SemaRef.BuildBlockPointerType(PointeeType, 0,
+ return SemaRef.BuildBlockPointerType(PointeeType, 0,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
-template<typename Derived>
-QualType
+template<typename Derived>
+QualType
TreeTransform<Derived>::RebuildLValueReferenceType(QualType ReferentType) {
- return SemaRef.BuildReferenceType(ReferentType, true, 0,
+ return SemaRef.BuildReferenceType(ReferentType, true, 0,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
-template<typename Derived>
-QualType
+template<typename Derived>
+QualType
TreeTransform<Derived>::RebuildRValueReferenceType(QualType ReferentType) {
- return SemaRef.BuildReferenceType(ReferentType, false, 0,
+ return SemaRef.BuildReferenceType(ReferentType, false, 0,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
template<typename Derived>
-QualType TreeTransform<Derived>::RebuildMemberPointerType(QualType PointeeType,
+QualType TreeTransform<Derived>::RebuildMemberPointerType(QualType PointeeType,
QualType ClassType) {
- return SemaRef.BuildMemberPointerType(PointeeType, ClassType, 0,
+ return SemaRef.BuildMemberPointerType(PointeeType, ClassType, 0,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
template<typename Derived>
-QualType
+QualType
TreeTransform<Derived>::RebuildArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt *Size,
@@ -4511,11 +4510,11 @@ TreeTransform<Derived>::RebuildArrayType(QualType ElementType,
return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
IndexTypeQuals, BracketsRange,
getDerived().getBaseEntity());
-
- QualType Types[] = {
- SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
- SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
- SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
+
+ QualType Types[] = {
+ SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
+ SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
+ SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
};
const unsigned NumTypes = sizeof(Types) / sizeof(QualType);
QualType SizeType;
@@ -4524,78 +4523,78 @@ TreeTransform<Derived>::RebuildArrayType(QualType ElementType,
SizeType = Types[I];
break;
}
-
+
if (SizeType.isNull())
SizeType = SemaRef.Context.getFixedWidthIntType(Size->getBitWidth(), false);
-
+
IntegerLiteral ArraySize(*Size, SizeType, /*FIXME*/BracketsRange.getBegin());
- return SemaRef.BuildArrayType(ElementType, SizeMod, &ArraySize,
+ return SemaRef.BuildArrayType(ElementType, SizeMod, &ArraySize,
IndexTypeQuals, BracketsRange,
- getDerived().getBaseEntity());
+ getDerived().getBaseEntity());
}
-
+
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
unsigned IndexTypeQuals) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0,
IndexTypeQuals, SourceRange());
}
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildConstantArrayWithExprType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildConstantArrayWithExprType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
Expr *SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
IndexTypeQuals, BracketsRange);
}
template<typename Derived>
-QualType
+QualType
TreeTransform<Derived>::RebuildConstantArrayWithoutExprType(
- QualType ElementType,
+ QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
const llvm::APInt &Size,
unsigned IndexTypeQuals) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0,
IndexTypeQuals, SourceRange());
}
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
unsigned IndexTypeQuals) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 0,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 0,
IndexTypeQuals, SourceRange());
}
-
+
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
ExprArg SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
SizeExpr.takeAs<Expr>(),
IndexTypeQuals, BracketsRange);
}
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType,
ArrayType::ArraySizeModifier SizeMod,
ExprArg SizeExpr,
unsigned IndexTypeQuals,
SourceRange BracketsRange) {
- return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
+ return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
SizeExpr.takeAs<Expr>(),
IndexTypeQuals, BracketsRange);
}
@@ -4606,7 +4605,7 @@ QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
// FIXME: semantic checking!
return SemaRef.Context.getVectorType(ElementType, NumElements);
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::RebuildExtVectorType(QualType ElementType,
unsigned NumElements,
@@ -4614,32 +4613,32 @@ QualType TreeTransform<Derived>::RebuildExtVectorType(QualType ElementType,
llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
NumElements, true);
IntegerLiteral *VectorSize
- = new (SemaRef.Context) IntegerLiteral(numElements, SemaRef.Context.IntTy,
+ = new (SemaRef.Context) IntegerLiteral(numElements, SemaRef.Context.IntTy,
AttributeLoc);
return SemaRef.BuildExtVectorType(ElementType, SemaRef.Owned(VectorSize),
AttributeLoc);
}
-
+
template<typename Derived>
-QualType
-TreeTransform<Derived>::RebuildDependentSizedExtVectorType(QualType ElementType,
+QualType
+TreeTransform<Derived>::RebuildDependentSizedExtVectorType(QualType ElementType,
ExprArg SizeExpr,
SourceLocation AttributeLoc) {
return SemaRef.BuildExtVectorType(ElementType, move(SizeExpr), AttributeLoc);
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::RebuildFunctionProtoType(QualType T,
- QualType *ParamTypes,
+ QualType *ParamTypes,
unsigned NumParamTypes,
- bool Variadic,
+ bool Variadic,
unsigned Quals) {
- return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
+ return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
Quals,
getDerived().getBaseLocation(),
getDerived().getBaseEntity());
}
-
+
template<typename Derived>
QualType TreeTransform<Derived>::RebuildTypeOfExprType(ExprArg E) {
return SemaRef.BuildTypeofExprType(E.takeAs<Expr>());
@@ -4662,10 +4661,10 @@ QualType TreeTransform<Derived>::RebuildTemplateSpecializationType(
unsigned NumArgs) {
// FIXME: Missing source locations for the template name, <, >.
return SemaRef.CheckTemplateIdType(Template, getDerived().getBaseLocation(),
- SourceLocation(), Args, NumArgs,
- SourceLocation());
+ SourceLocation(), Args, NumArgs,
+ SourceLocation());
}
-
+
template<typename Derived>
NestedNameSpecifier *
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
@@ -4678,7 +4677,7 @@ TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
SS.setRange(Range);
SS.setScopeRep(Prefix);
return static_cast<NestedNameSpecifier *>(
- SemaRef.BuildCXXNestedNameSpecifier(0, SS, Range.getEnd(),
+ SemaRef.BuildCXXNestedNameSpecifier(0, SS, Range.getEnd(),
Range.getEnd(), II,
ObjectType,
FirstQualifierInScope,
@@ -4705,22 +4704,22 @@ TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
return NestedNameSpecifier::Create(SemaRef.Context, Prefix, TemplateKW,
T.getTypePtr());
}
-
+
SemaRef.Diag(Range.getBegin(), diag::err_nested_name_spec_non_tag) << T;
return 0;
}
-
+
template<typename Derived>
-TemplateName
+TemplateName
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
bool TemplateKW,
TemplateDecl *Template) {
- return SemaRef.Context.getQualifiedTemplateName(Qualifier, TemplateKW,
+ return SemaRef.Context.getQualifiedTemplateName(Qualifier, TemplateKW,
Template);
}
template<typename Derived>
-TemplateName
+TemplateName
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
bool TemplateKW,
OverloadedFunctionDecl *Ovl) {
@@ -4728,13 +4727,13 @@ TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
}
template<typename Derived>
-TemplateName
+TemplateName
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
const IdentifierInfo &II,
QualType ObjectType) {
CXXScopeSpec SS;
SS.setRange(SourceRange(getDerived().getBaseLocation()));
- SS.setScopeRep(Qualifier);
+ SS.setScopeRep(Qualifier);
return getSema().ActOnDependentTemplateName(
/*FIXME:*/getDerived().getBaseLocation(),
II,
@@ -4743,9 +4742,9 @@ TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
ObjectType.getAsOpaquePtr())
.template getAsVal<TemplateName>();
}
-
+
template<typename Derived>
-Sema::OwningExprResult
+Sema::OwningExprResult
TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
SourceLocation OpLoc,
ExprArg Callee,
@@ -4754,73 +4753,73 @@ TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
Expr *FirstExpr = (Expr *)First.get();
Expr *SecondExpr = (Expr *)Second.get();
bool isPostIncDec = SecondExpr && (Op == OO_PlusPlus || Op == OO_MinusMinus);
-
+
// Determine whether this should be a builtin operation.
if (SecondExpr == 0 || isPostIncDec) {
if (!FirstExpr->getType()->isOverloadableType()) {
// The argument is not of overloadable type, so try to create a
// built-in unary operation.
- UnaryOperator::Opcode Opc
+ UnaryOperator::Opcode Opc
= UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
-
+
return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, move(First));
}
} else {
- if (!FirstExpr->getType()->isOverloadableType() &&
+ if (!FirstExpr->getType()->isOverloadableType() &&
!SecondExpr->getType()->isOverloadableType()) {
// Neither of the arguments is an overloadable type, so try to
// create a built-in binary operation.
BinaryOperator::Opcode Opc = BinaryOperator::getOverloadedOpcode(Op);
- OwningExprResult Result
+ OwningExprResult Result
= SemaRef.CreateBuiltinBinOp(OpLoc, Opc, FirstExpr, SecondExpr);
if (Result.isInvalid())
return SemaRef.ExprError();
-
+
First.release();
Second.release();
return move(Result);
}
}
-
- // Compute the transformed set of functions (and function templates) to be
+
+ // Compute the transformed set of functions (and function templates) to be
// used during overload resolution.
Sema::FunctionSet Functions;
-
- DeclRefExpr *DRE
+
+ DeclRefExpr *DRE
= cast<DeclRefExpr>(((Expr *)Callee.get())->IgnoreParenCasts());
-
+
// FIXME: Do we have to check
// IsAcceptableNonMemberOperatorCandidate for each of these?
for (OverloadIterator F(DRE->getDecl()), FEnd; F != FEnd; ++F)
Functions.insert(*F);
-
+
// Add any functions found via argument-dependent lookup.
Expr *Args[2] = { FirstExpr, SecondExpr };
unsigned NumArgs = 1 + (SecondExpr != 0);
- DeclarationName OpName
+ DeclarationName OpName
= SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
SemaRef.ArgumentDependentLookup(OpName, Args, NumArgs, Functions);
-
+
// Create the overloaded operator invocation for unary operators.
if (NumArgs == 1 || isPostIncDec) {
- UnaryOperator::Opcode Opc
+ UnaryOperator::Opcode Opc
= UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, move(First));
}
-
+
// Create the overloaded operator invocation for binary operators.
- BinaryOperator::Opcode Opc =
+ BinaryOperator::Opcode Opc =
BinaryOperator::getOverloadedOpcode(Op);
- OwningExprResult Result
+ OwningExprResult Result
= SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions, Args[0], Args[1]);
if (Result.isInvalid())
return SemaRef.ExprError();
-
+
First.release();
Second.release();
- return move(Result);
+ return move(Result);
}
-
+
} // end namespace clang
#endif // LLVM_CLANG_SEMA_TREETRANSFORM_H
diff --git a/test/Analysis/cfref_rdar6080742.c b/test/Analysis/cfref_rdar6080742.c
index 5d957615d0..9bbaf9b5ae 100644
--- a/test/Analysis/cfref_rdar6080742.c
+++ b/test/Analysis/cfref_rdar6080742.c
@@ -44,15 +44,15 @@ Boolean DebugDisplayOSStatusMsg(OSStatus status, const char *statusStr,
#define AssertNoErr(err){ DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__); }
#define RequireNoErr(err, action){ if( DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__) ) { action }}
-void DebugStop(const char *format,...); /* Not an abort function. */
+void DebugStop(const char *format,...); /* Not an abort function. */
int main(int argc, char *argv[]) {
- CFStringRef cfString;
- OSStatus status = noErr;
- cfString = CFStringCreateWithCString(0, "hello", kCFStringEncodingUTF8);
- RequireAction(cfString != 0, return memFullErr;) //no - warning
- printf("cfstring %p\n", cfString);
-Exit:
- CFRelease(cfString);
- return 0;
+ CFStringRef cfString;
+ OSStatus status = noErr;
+ cfString = CFStringCreateWithCString(0, "hello", kCFStringEncodingUTF8);
+ RequireAction(cfString != 0, return memFullErr;) //no - warning
+ printf("cfstring %p\n", cfString);
+ Exit:
+ CFRelease(cfString);
+ return 0;
}
diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c
index f400e9347a..46563213b1 100644
--- a/test/CodeGen/asm.c
+++ b/test/CodeGen/asm.c
@@ -15,7 +15,7 @@ void t4() {
unsigned long long a;
struct reg { unsigned long long a, b; } b;
- __asm__ volatile ("":: "m"(a), "m"(b));
+ __asm__ volatile ("":: "m"(a), "m"(b));
}
// PR3417
diff --git a/test/CodeGen/attr-cleanup.c b/test/CodeGen/attr-cleanup.c
index 03dde3341e..9105ededa2 100644
--- a/test/CodeGen/attr-cleanup.c
+++ b/test/CodeGen/attr-cleanup.c
@@ -3,6 +3,6 @@
// <rdar://problem/6827047>
void f(void* arg);
void g() {
- __attribute__((cleanup(f))) void *g;
+ __attribute__((cleanup(f))) void *g;
}
diff --git a/test/CodeGen/conditional.c b/test/CodeGen/conditional.c
index 22286705c8..8a30463cb7 100644
--- a/test/CodeGen/conditional.c
+++ b/test/CodeGen/conditional.c
@@ -1,11 +1,10 @@
// RUN: clang-cc -emit-llvm %s -o %t
-float test1(int cond, float a, float b)
-{
+float test1(int cond, float a, float b) {
return cond ? a : b;
}
-double test2(int cond, float a, double b)
-{
+
+double test2(int cond, float a, double b) {
return cond ? a : b;
}
@@ -16,8 +15,8 @@ void test3(){
}
void test4() {
-int i; short j;
-float* k = 1 ? &i : &j;
+ int i; short j;
+ float* k = 1 ? &i : &j;
}
void test5() {
@@ -33,12 +32,10 @@ void* test8() {return 1 ? test6 : test7;}
void _efree(void *ptr);
-void _php_stream_free3()
-{
- (1 ? free(0) : _efree(0));
+void _php_stream_free3() {
+ (1 ? free(0) : _efree(0));
}
-void _php_stream_free4()
-{
- 1 ? _efree(0) : free(0);
+void _php_stream_free4() {
+ 1 ? _efree(0) : free(0);
}
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index e0ec2c9027..beee7ac9b6 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -24,14 +24,14 @@ char xpto[];
// PR3427
struct foo {
- int a;
- void *ptrs[];
+ int a;
+ void *ptrs[];
};
struct foo bar;
// PR4143
struct foo2 {
- enum bar *bar;
+ enum bar *bar;
};
struct foo2 foo2;
diff --git a/test/CodeGen/exprs.c b/test/CodeGen/exprs.c
index 599e541d94..a0e5b7644a 100644
--- a/test/CodeGen/exprs.c
+++ b/test/CodeGen/exprs.c
@@ -48,9 +48,9 @@ int ola() {
// this one shouldn't fold as well
void eMaisUma() {
- double t[1];
- if (*t)
- return;
+ double t[1];
+ if (*t)
+ return;
}
// rdar://6520707
diff --git a/test/CodeGen/functions.c b/test/CodeGen/functions.c
index 685afb2225..dba29316e1 100644
--- a/test/CodeGen/functions.c
+++ b/test/CodeGen/functions.c
@@ -3,11 +3,11 @@
int g();
int foo(int i) {
- return g(i);
+ return g(i);
}
int g(int i) {
- return g(i);
+ return g(i);
}
// rdar://6110827
diff --git a/test/CodeGen/global-with-initialiser.c b/test/CodeGen/global-with-initialiser.c
index 29b4e21b91..d253782f66 100644
--- a/test/CodeGen/global-with-initialiser.c
+++ b/test/CodeGen/global-with-initialiser.c
@@ -17,9 +17,9 @@ long double globalLongDouble = 1;
long double globalLongDoubleArray[5] = { 1.0, 2.0 };
struct Struct {
- int member1;
- float member2;
- char *member3;
+ int member1;
+ float member2;
+ char *member3;
};
struct Struct globalStruct = { 1, 2.0f, "foobar"};
diff --git a/test/CodeGen/globalinit.c b/test/CodeGen/globalinit.c
index 2798cae712..b3d0cb54d1 100644
--- a/test/CodeGen/globalinit.c
+++ b/test/CodeGen/globalinit.c
@@ -37,7 +37,7 @@ static int a = { 1 };
// References to enums.
enum {
- EnumA, EnumB
+ EnumA, EnumB
};
int c[] = { EnumA, EnumB };
diff --git a/test/CodeGen/init-with-member-expr.c b/test/CodeGen/init-with-member-expr.c
index 7750dbf986..197a9ab4e3 100644
--- a/test/CodeGen/init-with-member-expr.c
+++ b/test/CodeGen/init-with-member-expr.c
@@ -14,7 +14,7 @@ typedef struct mark_header_tag {
} mark_header_t;
int is_rar_archive(int fd) {
const mark_header_t rar_hdr[2] = {{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, {'U', 'n', 'i', 'q', 'u', 'E', '!'}};
- foo(rar_hdr);
+ foo(rar_hdr);
return 0;
}
diff --git a/test/CodeGen/regparm.c b/test/CodeGen/regparm.c
index fdf07ead6d..28dfae7f62 100644
--- a/test/CodeGen/regparm.c
+++ b/test/CodeGen/regparm.c
@@ -9,11 +9,10 @@ typedef struct {
} foo;
static void FASTCALL
-reduced(char b, double c, foo* d, double e, int f)
-{
+reduced(char b, double c, foo* d, double e, int f) {
}
int
main(void) {
- reduced(0, 0.0, 0, 0.0, 0);
+ reduced(0, 0.0, 0, 0.0, 0);
}
diff --git a/test/CodeGen/staticinit.c b/test/CodeGen/staticinit.c
index 91fcdcf69f..c68366f2ea 100644
--- a/test/CodeGen/staticinit.c
+++ b/test/CodeGen/staticinit.c
@@ -2,9 +2,9 @@
// RUN: grep "g.b = internal global i8. getelementptr" %t &&
struct AStruct {
- int i;
- char *s;
- double d;
+ int i;
+ char *s;
+ double d;
};
void f() {
diff --git a/test/CodeGen/struct-init.c b/test/CodeGen/struct-init.c
index a38442b1a8..cb84fef4d1 100644
--- a/test/CodeGen/struct-init.c
+++ b/test/CodeGen/struct-init.c
@@ -2,11 +2,11 @@
typedef struct _zend_ini_entry zend_ini_entry;
struct _zend_ini_entry {
- void *mh_arg1;
+ void *mh_arg1;
};
char a;
const zend_ini_entry ini_entries[] = {
- { ((char*)&((zend_ini_entry*)0)->mh_arg1 - (char*)(void*)0)},
+ { ((char*)&((zend_ini_entry*)0)->mh_arg1 - (char*)(void*)0)},
};
diff --git a/test/CodeGen/struct.c b/test/CodeGen/struct.c
index ed3684280e..d1e58a2445 100644
--- a/test/CodeGen/struct.c
+++ b/test/CodeGen/struct.c
@@ -70,8 +70,7 @@ typedef struct {
int length;
} range;
extern range f6();
-void f7()
-{
+void f7() {
range r = f6();
}
@@ -81,27 +80,23 @@ typedef struct {
range range2;
} rangepair;
-void f8()
-{
+void f8() {
rangepair p;
range r = p.range1;
}
-void f9(range *p)
-{
+void f9(range *p) {
range r = *p;
}
-void f10(range *p)
-{
+void f10(range *p) {
range r = p[0];
}
/* _Bool types */
-struct _w
-{
+struct _w {
short a,b;
short c,d;
short e,f;
@@ -113,27 +108,24 @@ struct _w
} ws;
/* Implicit casts (due to typedefs) */
-typedef struct _a
-{
+typedef struct _a {
int a;
} a;
-void f11()
-{
- struct _a a1;
- a a2;
+void f11() {
+ struct _a a1;
+ a a2;
- a1 = a2;
- a2 = a1;
+ a1 = a2;
+ a2 = a1;
}
/* Implicit casts (due to const) */
-void f12()
-{
- struct _a a1;
- const struct _a a2;
-
- a1 = a2;
+void f12() {
+ struct _a a1;
+ const struct _a a2;
+
+ a1 = a2;
}
/* struct initialization */
@@ -147,8 +139,7 @@ struct a15 {char a; int b[];} c15;
int a16(void) {c15.a = 1;}
/* compound literals */
-void f13()
-{
+void f13() {
a13 x; x = (a13){1,2};
}
diff --git a/test/CodeGen/union-init.c b/test/CodeGen/union-init.c
index c882d3180c..f4e9e9a08f 100644
--- a/test/CodeGen/union-init.c
+++ b/test/CodeGen/union-init.c
@@ -4,19 +4,19 @@
typedef int Py_ssize_t;
typedef union _gc_head {
- struct {
- union _gc_head *gc_next;
- union _gc_head *gc_prev;
- Py_ssize_t gc_refs;
- } gc;
- long double dummy; /* force worst-case alignment */
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ Py_ssize_t gc_refs;
+ } gc;
+ long double dummy; /* force worst-case alignment */
} PyGC_Head;
struct gc_generation {
- PyGC_Head head;
- int threshold; /* collection threshold */
- int count; /* count of allocations or collections of younger
- generations */
+ PyGC_Head head;
+ int threshold; /* collection threshold */
+ int count; /* count of allocations or collections of younger
+ generations */
};
#define NUM_GENERATIONS 3
@@ -24,8 +24,8 @@ struct gc_generation {
/* linked lists of container objects */
struct gc_generation generations[NUM_GENERATIONS] = {
- /* PyGC_Head, threshold, count */
- {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
- {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
- {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
+ /* PyGC_Head, threshold, count */
+ {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
+ {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
+ {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
};
diff --git a/test/CodeGen/vector.c b/test/CodeGen/vector.c
index 1084f6d20b..5e48fd42b1 100644
--- a/test/CodeGen/vector.c
+++ b/test/CodeGen/vector.c
@@ -1,9 +1,8 @@
// RUN: clang-cc -emit-llvm %s -o -
typedef short __v4hi __attribute__ ((__vector_size__ (8)));
-void f()
-{
- __v4hi A = (__v4hi)0LL;
+void f() {
+ __v4hi A = (__v4hi)0LL;
}
__v4hi x = {1,2,3};
@@ -15,7 +14,6 @@ int a() { vty b; return b[2LL]; }
// PR4339
typedef float vec4 __attribute__((vector_size(16)));
-void vac ( vec4* a, char b, float c )
-{
- (*a)[b] = c;
+void vac ( vec4* a, char b, float c ) {
+ (*a)[b] = c;
}
diff --git a/test/CodeGenCXX/constructor-conversion.cpp b/test/CodeGenCXX/constructor-conversion.cpp
index 3fafe61769..980b230118 100644
--- a/test/CodeGenCXX/constructor-conversion.cpp
+++ b/test/CodeGenCXX/constructor-conversion.cpp
@@ -8,16 +8,16 @@ extern "C" int printf(...);
class X { // ...
public:
- X(int) : iX(2), fX(2.3) , name("HELLO\n") { }
-
- X(const char* arg, int ix=0) { iX = ix; fX = 6.0; name = arg+ix; }
- X(): iX(100), fX(1.2) {}
- int iX;
- float fX;
- const char *name;
- void pr(void) {
- printf("iX = %d fX = %f name = %s\n", iX, fX, name);
- }
+ X(int) : iX(2), fX(2.3) , name("HELLO\n") { }
+
+ X(const char* arg, int ix=0) { iX = ix; fX = 6.0; name = arg+ix; }
+ X(): iX(100), fX(1.2) {}
+ int iX;
+ float fX;
+ const char *name;
+ void pr(void) {
+ printf("iX = %d fX = %f name = %s\n", iX, fX, name);
+ }
};
void g(X arg) {
@@ -25,8 +25,7 @@ void g(X arg) {
}
void f(X arg) {
-
- X a = 1; // a = X(1)
+ X a = 1; // a = X(1)
a.pr();
@@ -35,18 +34,16 @@ void f(X arg) {
b.pr();
- a = 2; // a = X(2)
+ a = 2; // a = X(2)
a.pr();
-
}
-int main()
-{
- X x;
- f(x);
- g(3); // g(X(3))
+int main() {
+ X x;
+ f(x);
+ g(3); // g(X(3))
}
// CHECK-LP64: call __ZN1XC1Ei
diff --git a/test/CodeGenCXX/constructor-default-arg.cpp b/test/CodeGenCXX/constructor-default-arg.cpp
index fe5b360d0b..6691912b6f 100644
--- a/test/CodeGenCXX/constructor-default-arg.cpp
+++ b/test/CodeGenCXX/constructor-default-arg.cpp
@@ -8,8 +8,8 @@ extern "C" int printf(...);
struct C {
- C() : iC(6) {}
- int iC;
+ C() : iC(6) {}
+ int iC;
};
int foo() {
@@ -18,23 +18,23 @@ int foo() {
class X { // ...
public:
- X(int) {}
- X(const X&, int i = 1, int j = 2, int k = foo()) {
- printf("X(const X&, %d, %d, %d)\n", i, j, k);
- }
+ X(int) {}
+ X(const X&, int i = 1, int j = 2, int k = foo()) {
+ printf("X(const X&, %d, %d, %d)\n", i, j, k);
+ }
};
-int main()
-{
- X a(1);
- X b(a, 2);
- X c = b;
- X d(a, 5, 6);
+int main() {
+ X a(1);
+ X b(a, 2);
+ X c = b;
+ X d(a, 5, 6);
}
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
-// CHECK-LP64: call __ZN1XC1ERK1Xiii
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
-// CHECK-LP32: call L__ZN1XC1ERK1Xiii
+// CHECK-LP64: call __ZN1XC1ERK1Xiii
+// CHECK-LP64: call __ZN1XC1ERK1Xiii
+// CHECK-LP64: call __ZN1XC1ERK1Xiii
+
+// CHECK-LP32: call L__ZN1XC1ERK1Xiii
+// CHECK-LP32: call L__ZN1XC1ERK1Xiii
+// CHECK-LP32: call L__ZN1XC1ERK1Xiii
diff --git a/test/CodeGenCXX/constructor-for-array-members.cpp b/test/CodeGenCXX/constructor-for-array-members.cpp
index 9d9e2c8290..fbb13e0aa3 100644
--- a/test/CodeGenCXX/constructor-for-array-members.cpp
+++ b/test/CodeGenCXX/constructor-for-array-members.cpp
@@ -35,11 +35,10 @@ struct M {
};
int main() {
- M m1;
- m1.pr();
-
+ M m1;
+ m1.pr();
}
-// CHECK-LP64: call __ZN1SC1Ev
+// CHECK-LP64: call __ZN1SC1Ev
-// CHECK-LP32: call L__ZN1SC1Ev
+// CHECK-LP32: call L__ZN1SC1Ev
diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp
index de86d41552..1b025126a3 100644
--- a/test/CodeGenCXX/constructor-init.cpp
+++ b/test/CodeGenCXX/constructor-init.cpp
@@ -31,19 +31,20 @@ struct N : M , P, Q {
float f1;
int i1;
float d1;
- void PR() { printf("f1 = %f d1 = %f i1 = %d ld = %f \n", f1,d1,i1, ld);
- MPR();
- PPR();
- QPR();
- printf("iQ = %d\n", iQ);
- printf("iP = %d\n", iP);
- printf("iM = %d\n", iM);
- // FIXME. We don't yet support this syntax.
- // printf("iQ = %d\n", (*this).iQ);
- printf("iQ = %d\n", this->iQ);
- printf("iP = %d\n", this->iP);
- printf("iM = %d\n", this->iM);
- }
+ void PR() {
+ printf("f1 = %f d1 = %f i1 = %d ld = %f \n", f1,d1,i1, ld);
+ MPR();
+ PPR();
+ QPR();
+ printf("iQ = %d\n", iQ);
+ printf("iP = %d\n", iP);
+ printf("iM = %d\n", iM);
+ // FIXME. We don't yet support this syntax.
+ // printf("iQ = %d\n", (*this).iQ);
+ printf("iQ = %d\n", this->iQ);
+ printf("iP = %d\n", this->iP);
+ printf("iM = %d\n", this->iM);
+ }
float ld;
float ff;
M arr_m[3];
diff --git a/test/CodeGenCXX/constructor-template.cpp b/test/CodeGenCXX/constructor-template.cpp
index 84e77d43da..8c4f2c9127 100644
--- a/test/CodeGenCXX/constructor-template.cpp
+++ b/test/CodeGenCXX/constructor-template.cpp
@@ -21,7 +21,7 @@ struct B {
// PR4853
template <typename T> class List {
public:
- List(){ } // List<BinomialNode<int>*>::List() remains undefined.
+ List(){ } // List<BinomialNode<int>*>::List() remains undefined.
~List() {}
};
@@ -47,7 +47,7 @@ int main() {
// CHECK-LP64: __ZN4ListIP12BinomialNodeIiEED1Ev:
// CHECK-LP64: __ZN4ListIP12BinomialNodeIiEED2Ev:
-// CHECK-LP64: __ZN4NodeIP12BinomialNodeIiEEC1Ev:
+// CHECK-LP64: __ZN4NodeIP12BinomialNodeIiEEC1Ev:
// CHECK-LP64: __ZN4ListIP12BinomialNodeIiEEC1Ev:
// CHECK-LP32: __ZN4ListIP12BinomialNodeIiEED1Ev:
diff --git a/test/CodeGenCXX/conversion-function.cpp b/test/CodeGenCXX/conversion-function.cpp
index e7820bb44f..0d21180530 100644
--- a/test/CodeGenCXX/conversion-function.cpp
+++ b/test/CodeGenCXX/conversion-function.cpp
@@ -6,11 +6,11 @@
extern "C" int printf(...);
struct S {
- operator int();
+ operator int();
};
S::operator int() {
- return 10;
+ return 10;
}
@@ -42,51 +42,51 @@ Y y;
int count=0;
class O { // ...
public:
- operator int(){ return ++iO; }
- O() : iO(count++) {}
- int iO;
+ operator int(){ return ++iO; }
+ O() : iO(count++) {}
+ int iO;
};
-void g(O a, O b)
-{
- int i = (a) ? 1+a : 0;
- int j = (a&&b) ? a+b : i;
- if (a) { }
- printf("i = %d j = %d a.iO = %d b.iO = %d\n", i, j, a.iO, b.iO);
+void g(O a, O b) {
+ int i = (a) ? 1+a : 0;
+ int j = (a&&b) ? a+b : i;
+ if (a) { }
+ printf("i = %d j = %d a.iO = %d b.iO = %d\n", i, j, a.iO, b.iO);
}
int main() {
- int c = X(Z(y)); // OK: y.operator Z().operator X().operator int()
- printf("c = %d\n", c);
- float f = X(Z(y));
- printf("f = %f\n", f);
- int i = x;
- printf("i = %d float = %f\n", i, float(x));
- i = int(X(Z(y)));
- f = float(X(Z(y)));
- printf("i = %d float = %f\n", i,f);
- f = (float)x;
- i = (int)x;
- printf("i = %d float = %f\n", i,f);
-
- int d = (X)((Z)y);
- printf("d = %d\n", d);
-
- int e = (int)((X)((Z)y));
- printf("e = %d\n", e);
- O o1, o2;
- g(o1, o2);
+ int c = X(Z(y)); // OK: y.operator Z().operator X().operator int()
+ printf("c = %d\n", c);
+ float f = X(Z(y));
+ printf("f = %f\n", f);
+ int i = x;
+ printf("i = %d float = %f\n", i, float(x));
+ i = int(X(Z(y)));
+ f = float(X(Z(y)));
+ printf("i = %d float = %f\n", i,f);
+ f = (float)x;
+ i = (int)x;
+ printf("i = %d float = %f\n", i,f);
+
+ int d = (X)((Z)y);
+ printf("d = %d\n", d);
+
+ int e = (int)((X)((Z)y));
+ printf("e = %d\n", e);
+ O o1, o2;
+ g(o1, o2);
}
-// CHECK-LP64: .globl __ZN1ScviEv
+
+// CHECK-LP64: .globl __ZN1ScviEv
// CHECK-LP64-NEXT: __ZN1ScviEv:
-// CHECK-LP64: call __ZN1Ycv1ZEv
-// CHECK-LP64: call __ZN1Zcv1XEv
-// CHECK-LP64: call __ZN1XcviEv
-// CHECK-LP64: call __ZN1XcvfEv
+// CHECK-LP64: call __ZN1Ycv1ZEv
+// CHECK-LP64: call __ZN1Zcv1XEv
+// CHECK-LP64: call __ZN1XcviEv
+// CHECK-LP64: call __ZN1XcvfEv
// CHECK-LP32: .globl __ZN1ScviEv
// CHECK-LP32-NEXT: __ZN1ScviEv:
-// CHECK-LP32: call L__ZN1Ycv1ZEv
-// CHECK-LP32: call L__ZN1Zcv1XEv
-// CHECK-LP32: call L__ZN1XcviEv
-// CHECK-LP32: call L__ZN1XcvfEv
+// CHECK-LP32: call L__ZN1Ycv1ZEv
+// CHECK-LP32: call L__ZN1Zcv1XEv
+// CHECK-LP32: call L__ZN1XcviEv
+// CHECK-LP32: call L__ZN1XcvfEv
diff --git a/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
index c6214409d3..3c24b12752 100644
--- a/test/CodeGenCXX/copy-assign-synthesis-1.cpp
+++ b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
@@ -43,14 +43,16 @@ struct N : B {
printf("N1 = %d N2 = %d\n", N1, N2);
for (unsigned i = 0; i < 3; i++)
for (unsigned j = 0; j < 2; j++)
- printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1);
+ printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1);
B::pr();
}
- N& operator=(const N& arg) { N1 = arg.N1; N2 = arg.N2;
- for (unsigned i = 0; i < 3; i++)
- for (unsigned j = 0; j < 2; j++)
- arr_b[i][j] = arg.arr_b[i][j];
- return *this; }
+ N& operator=(const N& arg) {
+ N1 = arg.N1; N2 = arg.N2;
+ for (unsigned i = 0; i < 3; i++)
+ for (unsigned j = 0; j < 2; j++)
+ arr_b[i][j] = arg.arr_b[i][j];
+ return *this;
+ }
B arr_b[3][2];
};
diff --git a/test/CodeGenCXX/copy-constructor-elim.cpp b/test/CodeGenCXX/copy-constructor-elim.cpp
index 2a6be90bc6..daef92cdb7 100644
--- a/test/CodeGenCXX/copy-constructor-elim.cpp
+++ b/test/CodeGenCXX/copy-constructor-elim.cpp
@@ -7,9 +7,9 @@ extern "C" int printf(...);
struct C {
- C() : iC(6) {printf("C()\n"); }
- C(const C& c) { printf("C(const C& c)\n"); }
- int iC;
+ C() : iC(6) {printf("C()\n"); }
+ C(const C& c) { printf("C(const C& c)\n"); }
+ int iC;
};
C foo() {
@@ -18,10 +18,10 @@ C foo() {
class X { // ...
public:
- X(int) {}
- X(const X&, int i = 1, int j = 2, C c = foo()) {
- printf("X(const X&, %d, %d, %d)\n", i, j, c.iC);
- }
+ X(int) {}
+ X(const X&, int i = 1, int j = 2, C c = foo()) {
+ printf("X(const X&, %d, %d, %d)\n", i, j, c.iC);
+ }
};
@@ -33,12 +33,11 @@ S::S() { printf("S()\n"); }
void Call(S) {};
-int main()
-{
- X a(1);
- X b(a, 2);
- X c = b;
- X d(a, 5, 6);
- S s;
- Call(s);
+int main() {
+ X a(1);
+ X b(a, 2);
+ X c = b;
+ X d(a, 5, 6);
+ S s;
+ Call(s);
}
diff --git a/test/CodeGenCXX/copy-constructor-synthesis.cpp b/test/CodeGenCXX/copy-constructor-synthesis.cpp
index 2fe196d694..37550c4219 100644
--- a/test/CodeGenCXX/copy-constructor-synthesis.cpp
+++ b/test/CodeGenCXX/copy-constructor-synthesis.cpp
@@ -26,35 +26,36 @@ struct P {
struct X : M, N, P { // ...
- X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
- au_i1(1234), au1_4("MASKED") {}
- P p0;
- void pr() { printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM);
- printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP);
- printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name);
- printf("bf1 = %x bf2 = %x\n", bf1, bf2);
- printf("au_i2 = %d\n", au_i2);
- printf("au1_1 = %s\n", au1_1);
- }
- M m1;
- P p1;
- float f1;
- double d1;
- int i1;
- const char *name;
- unsigned bf1 : 8;
- unsigned bf2 : 16;
+ X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
+ au_i1(1234), au1_4("MASKED") {}
+ P p0;
+ void pr() {
+ printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM);
+ printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP);
+ printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name);
+ printf("bf1 = %x bf2 = %x\n", bf1, bf2);
+ printf("au_i2 = %d\n", au_i2);
+ printf("au1_1 = %s\n", au1_1);
+ }
+ M m1;
+ P p1;
+ float f1;
+ double d1;
+ int i1;
+ const char *name;
+ unsigned bf1 : 8;
+ unsigned bf2 : 16;
- union {
- int au_i1;
- int au_i2;
- };
- union {
- const char * au1_1;
- float au1_2;
- int au1_3;
- const char * au1_4;
- };
+ union {
+ int au_i1;
+ int au_i2;
+ };
+ union {
+ const char * au1_1;
+ float au1_2;
+ int au1_3;
+ const char * au1_4;
+ };
};
static int ix = 1;
@@ -87,19 +88,19 @@ struct XM {
I ARR_I[3][2];
};
-int main()
-{
- X a;
- X b(a);
- b.pr();
- X x;
- X c(x);
- c.pr();
+int main() {
+ X a;
+ X b(a);
+ b.pr();
+ X x;
+ X c(x);
+ c.pr();
- XM m0;
- XM m1 = m0;
- m1.pr();
+ XM m0;
+ XM m1 = m0;
+ m1.pr();
}
+
// CHECK-LP64: .globl __ZN1XC1ERK1X
// CHECK-LP64: .weak_definition __ZN1XC1ERK1X
// CHECK-LP64: __ZN1XC1ERK1X:
diff --git a/test/CodeGenCXX/default-constructor-for-members.cpp b/test/CodeGenCXX/default-constructor-for-members.cpp
index 28938fcebf..2d04bc9414 100644
--- a/test/CodeGenCXX/default-constructor-for-members.cpp
+++ b/test/CodeGenCXX/default-constructor-for-members.cpp
@@ -19,6 +19,6 @@ int main() {
M m1;
}
-// CHECK-LP64: call __ZN1SC1Ev
+// CHECK-LP64: call __ZN1SC1Ev
-// CHECK-LP32: call L__ZN1SC1Ev
+// CHECK-LP32: call L__ZN1SC1Ev
diff --git a/test/CodeGenCXX/default-destructor-synthesis.cpp b/test/CodeGenCXX/default-destructor-synthesis.cpp
index c9b48ed9c7..9cc802c85d 100644
--- a/test/CodeGenCXX/default-destructor-synthesis.cpp
+++ b/test/CodeGenCXX/default-destructor-synthesis.cpp
@@ -46,15 +46,15 @@ M gm;
int main() {M m1;}
-// CHECK-LP64: call __ZN1MC1Ev
-// CHECK-LP64: call __ZN1MD1Ev
-// CHECK-LP64: .globl __ZN1MD1Ev
-// CHECK-LP64-NEXT: .weak_definition __ZN1MD1Ev
-// CHECK-LP64-NEXT: __ZN1MD1Ev:
-
-
-// CHECK-LP32: call L__ZN1MC1Ev
-// CHECK-LP32: call L__ZN1MD1Ev
-// CHECK-LP32: .globl __ZN1MD1Ev
-// CHECK-LP32-NEXT: .weak_definition __ZN1MD1Ev
-// CHECK-LP32-NEXT: __ZN1MD1Ev:
+// CHECK-LP64: call __ZN1MC1Ev
+// CHECK-LP64: call __ZN1MD1Ev
+// CHECK-LP64: .globl __ZN1MD1Ev
+// CHECK-LP64-NEXT: .weak_definition __ZN1MD1Ev
+// CHECK-LP64-NEXT: __ZN1MD1Ev:
+
+
+// CHECK-LP32: call L__ZN1MC1Ev
+// CHECK-LP32: call L__ZN1MD1Ev
+// CHECK-LP32: .globl __ZN1MD1Ev
+// CHECK-LP32-NEXT: .weak_definition __ZN1MD1Ev
+// CHECK-LP32-NEXT:__ZN1MD1Ev:
diff --git a/test/CodeGenCXX/nested-base-member-access.cpp b/test/CodeGenCXX/nested-base-member-access.cpp
index aee7a12232..308f952c6d 100644
--- a/test/CodeGenCXX/nested-base-member-access.cpp
+++ b/test/CodeGenCXX/nested-base-member-access.cpp
@@ -35,14 +35,15 @@ struct P : Q, L {
struct N : M,P {
N() : M(100), P(200) {}
- void PR() { this->MPR(); this->PPR(); this->QPR();
- IQPR();
- printf("iM = %d\n", iM);
- printf("iP = %d\n", iP);
- printf("iQ = %d\n", iQ);
- printf("iL = %d\n", iL);
- printf("iIQ = %d\n", iIQ);
- }
+ void PR() {
+ this->MPR(); this->PPR(); this->QPR();
+ IQPR();
+ printf("iM = %d\n", iM);
+ printf("iP = %d\n", iP);
+ printf("iQ = %d\n", iQ);
+ printf("iL = %d\n", iL);
+ printf("iIQ = %d\n", iIQ);
+ }
};
int main() {
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index acc7853cd6..dfb705ae53 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -308,7 +308,7 @@ struct test5_D : virtual test5_B1, virtual test5_B21, virtual test5_B31 {
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32: .long 8
// CHECK-LP32 .space 4
-// CHECK-LP32 .space 4 FIXME
+// CHECK-LP32 .space 4 FIXME
// CHECK-LP32: .long 4
// CHECK-LP32-NEXT: .space 4
// CHECK-LP32-NEXT: .space 4
diff --git a/test/Lexer/comment-escape.c b/test/Lexer/comment-escape.c
index c568cd611f..c461457158 100644
--- a/test/Lexer/comment-escape.c
+++ b/test/Lexer/comment-escape.c
@@ -2,5 +2,5 @@
// rdar://6757323
// foo \
-#define blork 32
+#define blork 32
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c
index d794fcfe8b..572ac44d1f 100644
--- a/test/Parser/MicrosoftExtensions.c
+++ b/test/Parser/MicrosoftExtensions.c
@@ -9,22 +9,22 @@ __declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory );
typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
void * __ptr64 PtrToPtr64(const void *p)
{
- return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
+ return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
}
void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
{
- __asm {
- mov eax, Bit
- mov ecx, Base
- lock bts [ecx], eax
- setc al
- };
+ __asm {
+ mov eax, Bit
+ mov ecx, Base
+ lock bts [ecx], eax
+ setc al
+ };
}
void *_alloca(int);
void foo() {
- __declspec(align(16)) int *buffer = (int *)_alloca(9);
+ __declspec(align(16)) int *buffer = (int *)_alloca(9);
}
typedef bool (__stdcall __stdcall *blarg)(int);
diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp
index 62637bdc8d..397894727b 100644
--- a/test/Parser/cxx-friend.cpp
+++ b/test/Parser/cxx-friend.cpp
@@ -6,7 +6,7 @@ class C {
class A {
public:
- void f();
+ void f();
};
friend int x; // expected-error {{'friend' used outside of class}}
diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp
index 5f49fb15d7..94b7069afb 100644
--- a/test/Parser/cxx-template-decl.cpp
+++ b/test/Parser/cxx-template-decl.cpp
@@ -50,7 +50,7 @@ template <typename T, typename U> struct B { };
// Template parameter shadowing
template<typename T, // expected-note{{template parameter is declared here}}
- typename T> // expected-error{{declaration of 'T' shadows template parameter}}
+ typename T> // expected-error{{declaration of 'T' shadows template parameter}}
void shadow1();
template<typename T> // expected-note{{template parameter is declared here}}
diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c
index 2e84ed1a6b..f7706ca676 100644
--- a/test/Preprocessor/assembler-with-cpp.c
+++ b/test/Preprocessor/assembler-with-cpp.c
@@ -40,7 +40,7 @@
// rdar://6709206
// RUN: grep "5: expanded (" %t &&
#define M4 expanded
-#define M5() M4 ## (
+#define M5() M4 ## (
5: M5()
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index b7542b301b..c78fd29a89 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -144,12 +144,11 @@ int xx_sizecheck[(sizeof(xx) / sizeof(char)) == 5? 1 : -1];
static char const yy[5] = "test";
static char const zz[3] = "test"; // expected-warning{{initializer-string for char array is too long}}
-void charArrays()
-{
- static char const test[] = "test";
- int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1];
- static char const test2[] = { "weird stuff" };
- static char const test3[] = { "test", "excess stuff" }; // expected-warning{{excess elements in char array initializer}}
+void charArrays() {
+ static char const test[] = "test";
+ int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1];
+ static char const test2[] = { "weird stuff" };
+ static char const test3[] = { "test", "excess stuff" }; // expected-warning{{excess elements in char array initializer}}
char* cp[] = { "Hello" };
@@ -230,15 +229,15 @@ int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit)
// ptrs are constant
struct soft_segment_descriptor {
- long ssd_base;
+ long ssd_base;
};
static int dblfault_tss;
union uniao { int ola; } xpto[1];
struct soft_segment_descriptor gdt_segs[] = {
- {(long) &dblfault_tss},
- { (long)xpto},
+ {(long) &dblfault_tss},
+ { (long)xpto},
};
static void sppp_ipv6cp_up();
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index 6597bad4b5..e15381e4c6 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -21,7 +21,7 @@ int a() {
// test if attributes propagate to variables
extern int var;
int w() {
- return var; // expected-warning {{'var' is deprecated}}
+ return var; // expected-warning {{'var' is deprecated}}
}
int old_fn() __attribute__ ((deprecated));
diff --git a/test/Sema/block-call.c b/test/Sema/block-call.c
index c42b642337..893a8f61da 100644
--- a/test/Sema/block-call.c
+++ b/test/Sema/block-call.c
@@ -5,51 +5,47 @@ int (^IFP) ();
int (^II) (int);
int main() {
int (*FPL) (int) = FP; // C doesn't consider this an error.
-
+
// For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error.
int (^PFR) (int) = IFP; // OK
- PFR = II; // OK
-
- int (^IFP) () = PFR; // OK
-
+ PFR = II; // OK
- const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
+ int (^IFP) () = PFR; // OK
- const int (^CICC) () = CIC;
+ const int (^CIC) () = IFP; // expected-error {{incompatible block pointer types initializing 'int (^)()', expected 'int const (^)()'}}
- int * const (^IPCC) () = 0;
+ const int (^CICC) () = CIC;
- int * const (^IPCC1) () = IPCC;
+ int * const (^IPCC) () = 0;
- int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
+ int * const (^IPCC1) () = IPCC;
- int (^IPCC3) (const int) = PFR;
+ int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *const (^)()', expected 'int *(^)()'}}
+ int (^IPCC3) (const int) = PFR;
- int (^IPCC4) (int, char (^CArg) (double));
+ int (^IPCC4) (int, char (^CArg) (double));
+ int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
- int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
+ int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
- int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(double))', expected 'int (^)(int, char (^)(float))'}}
-
- IPCC2 = 0;
- IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}}
- int (^x)() = 0;
- int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
- int a = 1;
- int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
+ IPCC2 = 0;
+ IPCC2 = 1; // expected-error {{invalid conversion assigning integer 'int', expected block pointer 'int *(^)()'}}
+ int (^x)() = 0;
+ int (^y)() = 3; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
+ int a = 1;
+ int (^z)() = a+4; // expected-error {{invalid conversion initializing integer 'int', expected block pointer 'int (^)()'}}
}
int blah() {
- int (^IFP) (float);
- char (^PCP)(double, double, char);
+ int (^IFP) (float);
+ char (^PCP)(double, double, char);
- IFP(1.0);
- IFP (1.0, 2.0); // expected-error {{too many arguments to block call}}
+ IFP(1.0);
+ IFP (1.0, 2.0); // expected-error {{too many arguments to block call}}
- char ch = PCP(1.0, 2.0, 'a');
- return PCP(1.0, 2.0); // expected-error {{too few arguments to block}}
+ char ch = PCP(1.0, 2.0, 'a');
+ return PCP(1.0, 2.0); // expected-error {{too few arguments to block}}
}
-
diff --git a/test/Sema/block-explicit-return-type.c b/test/Sema/block-explicit-return-type.c
index c7b26b3d6b..f0a033dc0d 100644
--- a/test/Sema/block-explicit-return-type.c
+++ b/test/Sema/block-explicit-return-type.c
@@ -19,42 +19,39 @@ typedef void (^completion_block_t)(void);
typedef double (^myblock)(int);
double test(myblock I);
-int main()
-{
- __block int x = 1;
- __block int y = 2;
-
- (void)^void *{ return 0; };
-
- (void)^float(float y){ return y; };
-
- (void)^double (float y, double d)
- {
- if (y)
- return d;
- else
- return y;
- };
-
- const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) {
- if (flag)
- return 0;
- if (flag == 1)
- return arg;
- else if (flag == 2)
- return "";
- return arg1;
- };
-
- (void)^PF { return &gf; };
-
- some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; });
-
- double res = test(^(int z){x = y+z; return (double)z; });
+int main() {
+ __block int x = 1;
+ __block int y = 2;
+
+ (void)^void *{ return 0; };
+
+ (void)^float(float y){ return y; };
+
+ (void)^double (float y, double d) {
+ if (y)
+ return d;
+ else
+ return y;
+ };
+
+ const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) {
+ if (flag)
+ return 0;
+ if (flag == 1)
+ return arg;
+ else if (flag == 2)
+ return "";
+ return arg1;
+ };
+
+ (void)^PF { return &gf; };
+
+ some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; });
+
+ double res = test(^(int z){x = y+z; return (double)z; });
}
-void func()
-{
+void func() {
completion_block_t X;
completion_block_t (^blockx)(dispatch_item_t) = ^completion_block_t (dispatch_item_t item) {
@@ -66,7 +63,6 @@ void func()
};
blockx = blocky;
-
}
diff --git a/test/Sema/block-literal.c b/test/Sema/block-literal.c
index c4aadd5d48..9f5022dc63 100644
--- a/test/Sema/block-literal.c
+++ b/test/Sema/block-literal.c
@@ -12,34 +12,34 @@ void takeblock(T);
int takeintint(int (^C)(int)) { return C(4); }
T somefunction() {
- if (^{ })
- nothing();
+ if (^{ })
+ nothing();
- noop = ^{};
+ noop = ^{};
- noop = ^{printf("\nClosure\n"); };
+ noop = ^{printf("\nClosure\n"); };
- I(^{ });
+ I(^{ });
- return ^{printf("\nClosure\n"); };
+ return ^{printf("\nClosure\n"); };
}
void test2() {
- int x = 4;
+ int x = 4;
- takeblock(^{ printf("%d\n", x); });
+ takeblock(^{ printf("%d\n", x); });
while (1) {
- takeblock(^{
- break; // expected-error {{'break' statement not in loop or switch statement}}
- continue; // expected-error {{'continue' statement not in loop statement}}
- while(1) break; // ok
- goto foo; // expected-error {{goto not allowed}}
- });
+ takeblock(^{
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ while(1) break; // ok
+ goto foo; // expected-error {{goto not allowed}}
+ });
break;
- }
+ }
-foo:
- takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
+ foo:
+ takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
__block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
takeblock(^{ y = 8; });
}
@@ -59,11 +59,11 @@ void myfunc(int (^block)(int)) {}
void myfunc3(const int *x);
void test5() {
- int a;
+ int a;
- myfunc(^(int abcd) {
- myfunc3(&a);
- return 1;
+ myfunc(^(int abcd) {
+ myfunc3(&a);
+ return 1;
});
}
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index a9a7df61fe..8661fd8a52 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -4,37 +4,37 @@ void donotwarn();
int (^IFP) ();
int (^II) (int);
int test1() {
- int (^PFR) (int) = 0; // OK
- PFR = II; // OK
+ int (^PFR) (int) = 0; // OK
+ PFR = II; // OK
- if (PFR == II) // OK
+ if (PFR == II) // OK
donotwarn();
- if (PFR == IFP) // OK
+ if (PFR == IFP) // OK
donotwarn();
if (PFR == (int (^) (int))IFP) // OK
donotwarn();
- if (PFR == 0) // OK
+ if (PFR == 0) // OK
donotwarn();
- if (PFR) // OK
+ if (PFR) // OK
donotwarn();
- if (!PFR) // OK
+ if (!PFR) // OK
donotwarn();
- return PFR != IFP; // OK
+ return PFR != IFP; // OK
}
int test2(double (^S)()) {
double (^I)(int) = (void*) S;
- (void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
+ (void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
void *pv = I;
- pv = S;
+ pv = S;
I(1);
@@ -114,7 +114,7 @@ void test11(int i) {
void (^test12f)(void);
void test12() {
- test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
+ test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
}
// rdar://6808730
@@ -144,7 +144,7 @@ void foo(long (^comp)()) {
void (^test15f)(void);
void test15() {
- foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}}
+ foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)', expected 'long (^)()'}}
}
__block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}}
diff --git a/test/Sema/block-printf-attribute-1.c b/test/Sema/block-printf-attribute-1.c
index ce30b8e855..4941ae7bc6 100644
--- a/test/Sema/block-printf-attribute-1.c
+++ b/test/Sema/block-printf-attribute-1.c
@@ -1,15 +1,12 @@
// RUN: clang-cc %s -fsyntax-only -verify -fblocks
-int main()
-{
- void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
- ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
+int main() {
+ void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
+ ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
- void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};
-
- // FIXME: argument type poking not yet supportted.
- z(1, "%s", 1); /* { dg-warning "format \\'\%s\\' expects type \\'char \\*\\'\, but argument 3 has type \\'int\\'" } */
- z(1, "%s", "HELLO"); // OK
+ void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};
+ // FIXME: argument type poking not yet supportted.
+ z(1, "%s", 1); /* { dg-warning "format \\'\%s\\' expects type \\'char \\*\\'\, but argument 3 has type \\'int\\'" } */
+ z(1, "%s", "HELLO"); // OK
}
-
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 96dde363de..98a72731d6 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -31,7 +31,7 @@ CL foo() {
return (float)1.0;
else
if (2)
- return (double)2.0;
+ return (double)2.0;
return 1;
};
char *(^B)(void) = ^{
@@ -66,7 +66,7 @@ int foo3() {
Boolean (*value_equal)(uintptr_t, uintptr_t) = 0;
cb.isEqual = ^(const CFBasicHash *table, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key) {
- return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
+ return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
};
}
diff --git a/test/Sema/block-sentinel-attribute.c b/test/Sema/block-sentinel-attribute.c
index a7d4df108e..5628a2c780 100644
--- a/test/Sema/block-sentinel-attribute.c
+++ b/test/Sema/block-sentinel-attribute.c
@@ -2,24 +2,23 @@
void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
-int main()
-{
- void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}}
- void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
- ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {};
- void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
+int main() {
+ void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}}
+ void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
+ ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {};
+ void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
- void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
+ void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
- b(1, "%s", (void*)0); // OK
- b(1, "%s", 0); // expected-warning {{missing sentinel in block call}}
- z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}}
- z(1, "%s", (void*)0, 1, 0); // OK
+ b(1, "%s", (void*)0); // OK
+ b(1, "%s", 0); // expected-warning {{missing sentinel in block call}}
+ z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}}
+ z(1, "%s", (void*)0, 1, 0); // OK
- y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}}
+ y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}}
- y(1, "%s", (void*)0,3,4,5,6,7); // OK
+ y(1, "%s", (void*)0,3,4,5,6,7); // OK
}
diff --git a/test/Sema/c89-2.c b/test/Sema/c89-2.c
index 3b546404a9..50c5f4e5a8 100644
--- a/test/Sema/c89-2.c
+++ b/test/Sema/c89-2.c
@@ -1,5 +1,5 @@
/* RUN: clang-cc %s -std=c89 -pedantic-errors -verify
*/
-#if 1LL /* expected-error {{long long}} */
+#if 1LL /* expected-error {{long long}} */
#endif
diff --git a/test/Sema/c89.c b/test/Sema/c89.c
index 9bf720b6a3..fc50ebed66 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -25,7 +25,7 @@ void test3(int i) {
int A[i]; /* expected-warning {{variable length array}} */
}
-int test4 = 0LL; /* expected-warning {{long long}} */
+int test4 = 0LL; /* expected-warning {{long long}} */
/* PR1999 */
void test5(register);
diff --git a/test/Sema/complex-int.c b/test/Sema/complex-int.c
index 5977b4d1e0..6c660899e8 100644
--- a/test/Sema/complex-int.c
+++ b/test/Sema/complex-int.c
@@ -44,9 +44,8 @@ TestPairs(7); TestPairs(8);
// rdar://6097730
void test3(_Complex int *x) {
*x = ~*x;
-}
+}
void test4(_Complex float *x) {
*x = ~*x;
-}
-
+}
diff --git a/test/Sema/conditional.c b/test/Sema/conditional.c
index 1c7486a613..9f48c349c9 100644
--- a/test/Sema/conditional.c
+++ b/test/Sema/conditional.c
@@ -4,12 +4,10 @@ const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
void _efree(void *ptr);
-int _php_stream_free1()
-{
- return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
+int _php_stream_free1() {
+ return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
}
-int _php_stream_free2()
-{
- return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
+int _php_stream_free2() {
+ return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
}
diff --git a/test/Sema/darwin-align-cast.c b/test/Sema/darwin-align-cast.c
index 313a9e3410..fed8983191 100644
--- a/test/Sema/darwin-align-cast.c
+++ b/test/Sema/darwin-align-cast.c
@@ -8,10 +8,10 @@ struct cmsghdr {};
#if 0
This code below comes from the following system headers:
-sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
+sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
cmsghdr)) + __DARWIN_ALIGN(l))
-i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
+i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
+ __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
#endif
diff --git a/test/Sema/floating-point-compare.c b/test/Sema/floating-point-compare.c
index 763a8f4b86..9888105518 100644
--- a/test/Sema/floating-point-compare.c
+++ b/test/Sema/floating-point-compare.c
@@ -13,11 +13,11 @@ int f3(float x) {
}
int f4(float x) {
- return x == 0.0; // no-warning {{comparing}}
+ return x == 0.0; // no-warning {{comparing}}
}
int f5(float x) {
- return x == __builtin_inf(); // no-warning
+ return x == __builtin_inf(); // no-warning
}
int f7(float x) {
diff --git a/test/Sema/function-pointer-sentinel-attribute.c b/test/Sema/function-pointer-sentinel-attribute.c
index 0de02fa536..6d3fb17180 100644
--- a/test/Sema/function-pointer-sentinel-attribute.c
+++ b/test/Sema/function-pointer-sentinel-attribute.c
@@ -2,22 +2,19 @@
void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
-int main()
-{
- void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
- void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
+int main() {
+ void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
+ void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
- void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
+ void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
- b(1, "%s", (void*)0); // OK
- b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
- z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
- z(1, "%s", (void*)0, 1, 0); // OK
+ b(1, "%s", (void*)0); // OK
+ b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s", (void*)0, 1, 0); // OK
- y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
-
- y(1, "%s", (void*)0,3,4,5,6,7); // OK
+ y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
+ y(1, "%s", (void*)0,3,4,5,6,7); // OK
}
-
diff --git a/test/Sema/function-sentinel-attr.c b/test/Sema/function-sentinel-attr.c
index 6630479612..b33b4a063c 100644
--- a/test/Sema/function-sentinel-attr.c
+++ b/test/Sema/function-sentinel-attr.c
@@ -18,7 +18,7 @@ int main ()
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
foo5(1, NULL, 2); // OK
foo5(1,2,NULL, 1); // OK
- foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}}
+ foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}}
foo6(1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
foo6(1,NULL,3,4,5,6,7); // OK
diff --git a/test/Sema/implicit-int.c b/test/Sema/implicit-int.c
index 1a81cc55b5..5190bdbf93 100644
--- a/test/Sema/implicit-int.c
+++ b/test/Sema/implicit-int.c
@@ -12,15 +12,15 @@ void f((x)); // expected-warning {{type specifier missing, defaults to 'int'}}
// PR3702
#define PAD(ms10) { \
- register i; \
+ register i; \
}
-#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
+#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
void
h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}}
{
- ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}}
+ ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}}
}
struct foo {
diff --git a/test/Sema/predefined-function.c b/test/Sema/predefined-function.c
index e8ccb3636b..c8d17f0078 100644
--- a/test/Sema/predefined-function.c
+++ b/test/Sema/predefined-function.c
@@ -8,31 +8,30 @@ int eli(float b); // expected-note {{previous declaration is here}}
int b(int c) {return 1;}
int foo();
-int foo()
-{
- int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
- eli(b); // expected-error{{incompatible type passing}}
- return 0;
+int foo() {
+ int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
+ eli(b); // expected-error{{incompatible type passing}}
+ return 0;
}
int bar();
int bar(int i) // expected-note {{previous definition is here}}
{
- return 0;
+ return 0;
}
int bar() // expected-error {{redefinition of 'bar'}}
{
- return 0;
+ return 0;
}
int foobar(int); // note {{previous declaration is here}}
int foobar() // error {{conflicting types for 'foobar'}}
{
- return 0;
+ return 0;
}
int wibble(); // expected-note {{previous declaration is here}}
float wibble() // expected-error {{conflicting types for 'wibble'}}
{
- return 0.0f;
+ return 0.0f;
}
diff --git a/test/Sema/static-init.c b/test/Sema/static-init.c
index cd495568ca..510f3ab099 100644
--- a/test/Sema/static-init.c
+++ b/test/Sema/static-init.c
@@ -11,11 +11,11 @@ _Bool t = &t;
union bar {
- int i;
+ int i;
};
struct foo {
- unsigned ptr;
+ unsigned ptr;
};
union bar u[1];
diff --git a/test/Sema/struct-decl.c b/test/Sema/struct-decl.c
index 2c0945f9f8..a5a299bf09 100644
--- a/test/Sema/struct-decl.c
+++ b/test/Sema/struct-decl.c
@@ -1,26 +1,26 @@
// RUN: clang-cc -fsyntax-only -verify %s
// PR3459
struct bar {
- char n[1];
+ char n[1];
};
struct foo {
- char name[(int)&((struct bar *)0)->n];
- char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
+ char name[(int)&((struct bar *)0)->n];
+ char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
};
// PR3430
struct s {
- struct st {
- int v;
- } *ts;
+ struct st {
+ int v;
+ } *ts;
};
struct st;
int foo() {
- struct st *f;
- return f->v + f[0].v;
+ struct st *f;
+ return f->v + f[0].v;
}
// PR3642, PR3671
@@ -29,8 +29,8 @@ struct pppoe_tag {
char tag_data[];
};
struct datatag {
- struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
- char data;
+ struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
+ char data;
};
diff --git a/test/Sema/transparent-union-pointer.c b/test/Sema/transparent-union-pointer.c
index ea761f17e7..a58bd42f82 100644
--- a/test/Sema/transparent-union-pointer.c
+++ b/test/Sema/transparent-union-pointer.c
@@ -1,14 +1,14 @@
// RUN: clang-cc %s -fsyntax-only -verify
typedef union {
- union wait *__uptr;
- int *__iptr;
+ union wait *__uptr;
+ int *__iptr;
} __WAIT_STATUS __attribute__ ((__transparent_union__));
extern int wait (__WAIT_STATUS __stat_loc);
void fastcgi_cleanup() {
- int status = 0;
- wait(&status);
+ int status = 0;
+ wait(&status);
}
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index 2d466c203d..e14304a26f 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -9,7 +9,7 @@
#endif
class C {
- virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
+ virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
};
static_assert(__is_abstract(C), "C has a pure virtual function");
@@ -20,7 +20,7 @@ class D : C {
static_assert(__is_abstract(D), "D inherits from an abstract class");
class E : D {
- virtual void f();
+ virtual void f();
};
static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f");
@@ -38,8 +38,8 @@ struct S {
void t3(const C&);
void f() {
- C(); // expected-error {{allocation of an object of abstract type 'C'}}
- t3(C()); // expected-error {{allocation of an object of abstract type 'C'}}
+ C(); // expected-error {{allocation of an object of abstract type 'C'}}
+ t3(C()); // expected-error {{allocation of an object of abstract type 'C'}}
}
C e1[2]; // expected-error {{variable type 'C' is an abstract class}}
@@ -54,17 +54,17 @@ typedef void (*Func)(C); // expected-error {{parameter type 'C' is an abstract c
void t6(Func);
class F {
- F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}}
+ F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}}
- class D {
- void f(F c); // expected-error {{parameter type 'F' is an abstract class}}
- };
+ class D {
+ void f(F c); // expected-error {{parameter type 'F' is an abstract class}}
+ };
- union U {
- void u(F c); // expected-error {{parameter type 'F' is an abstract class}}
- };
+ union U {
+ void u(F c); // expected-error {{parameter type 'F' is an abstract class}}
+ };
- virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
+ virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
};
class Abstract;
@@ -72,50 +72,47 @@ class Abstract;
void t7(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}}
void t8() {
- void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}}
+ void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}}
}
namespace N {
- void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}}
+void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}}
}
class Abstract {
- virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
+ virtual void f() = 0; // expected-note {{pure virtual function 'f'}}
};
// <rdar://problem/6854087>
class foo {
public:
- virtual foo *getFoo() = 0;
+ virtual foo *getFoo() = 0;
};
class bar : public foo {
public:
- virtual bar *getFoo();
+ virtual bar *getFoo();
};
bar x;
// <rdar://problem/6902298>
-class A
-{
+class A {
public:
- virtual void release() = 0;
- virtual void release(int count) = 0;
- virtual void retain() = 0;
+ virtual void release() = 0;
+ virtual void release(int count) = 0;
+ virtual void retain() = 0;
};
-class B : public A
-{
+class B : public A {
public:
- virtual void release();
- virtual void release(int count);
- virtual void retain();
+ virtual void release();
+ virtual void release(int count);
+ virtual void retain();
};
-void foo(void)
-{
- B b;
+void foo(void) {
+ B b;
}
struct K {
diff --git a/test/SemaCXX/access-control-check.cpp b/test/SemaCXX/access-control-check.cpp
index d2acfe4167..fb124a932a 100644
--- a/test/SemaCXX/access-control-check.cpp
+++ b/test/SemaCXX/access-control-check.cpp
@@ -11,6 +11,6 @@ class P {
class N : M,P {
N() {}
- // FIXME. No access violation is reported in method call or member access.
+ // FIXME. No access violation is reported in method call or member access.
int PR() { return iP + PPR(); }
};
diff --git a/test/SemaCXX/attr-format.cpp b/test/SemaCXX/attr-format.cpp
index d1659c98de..369099a848 100644
--- a/test/SemaCXX/attr-format.cpp
+++ b/test/SemaCXX/attr-format.cpp
@@ -1,8 +1,8 @@
// RUN: clang-cc -fsyntax-only -verify %s
struct S {
- static void f(const char*, ...) __attribute__((format(printf, 1, 2)));
-
- // GCC has a hidden 'this' argument in member functions which is why
- // the format argument is argument 2 here.
- void g(const char*, ...) __attribute__((format(printf, 2, 3)));
-}; \ No newline at end of file
+ static void f(const char*, ...) __attribute__((format(printf, 1, 2)));
+
+ // GCC has a hidden 'this' argument in member functions which is why
+ // the format argument is argument 2 here.
+ void g(const char*, ...) __attribute__((format(printf, 2, 3)));
+};
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
index c38c3d3337..2092847bc0 100644
--- a/test/SemaCXX/class-base-member-init.cpp
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -7,9 +7,9 @@ public:
struct D : S {
D() : b1(0), b2(1), b1(0), S(), S() {} // expected-error {{multiple initializations given for non-static member 'b1'}} \
- // expected-note {{previous initialization is here}} \
- // expected-error {{multiple initializations given for base 'class S'}} \
- // expected-note {{previous initialization is here}}
+ // expected-note {{previous initialization is here}} \
+ // expected-error {{multiple initializations given for base 'class S'}} \
+ // expected-note {{previous initialization is here}}
int b1;
int b2;
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index 1a7787ee0e..b86a27d66d 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -94,18 +94,18 @@ struct Current : Derived {
Derived::V(), // expected-note {{base 'Derived::V'}}
::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
INT::NonExisting() {} // expected-error {{expected a class or namespace}} \
- // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+ // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
};
// FIXME. This is bad message!
-struct M { // expected-note {{candidate function}} \
- // expected-note {{candidate function}}
- M(int i, int j); // expected-note {{candidate function}} \
- // // expected-note {{candidate function}}
+struct M { // expected-note {{candidate function}} \
+ // expected-note {{candidate function}}
+ M(int i, int j); // expected-note {{candidate function}} \
+ // // expected-note {{candidate function}}
};
struct N : M {
- N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}}
+ N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}}
m1(100) { } // expected-error {{no matching constructor for initialization of 'm1'}}
M m1;
};
@@ -116,7 +116,7 @@ struct P : M { // expected-error {{default constructor for 'struct M' is missin
};
struct Q {
- Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}}
+ Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}}
pf(0.0) { } // expected-error {{incompatible type passing 'double', expected 'float *'}}
float f1;
diff --git a/test/SemaCXX/copy-constructor-error.cpp b/test/SemaCXX/copy-constructor-error.cpp
index afe741faa4..2e42fcc3b1 100644
--- a/test/SemaCXX/copy-constructor-error.cpp
+++ b/test/SemaCXX/copy-constructor-error.cpp
@@ -1,8 +1,8 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct S { // expected-note {{candidate function}}
- S (S); // expected-error {{copy constructor must pass its first argument by reference}} \\
- // expected-note {{candidate function}}
+struct S { // expected-note {{candidate function}}
+ S (S); // expected-error {{copy constructor must pass its first argument by reference}} \\
+ // expected-note {{candidate function}}
};
S f();
diff --git a/test/SemaCXX/default-assignment-operator.cpp b/test/SemaCXX/default-assignment-operator.cpp
index 64ea49837b..e627fefdef 100644
--- a/test/SemaCXX/default-assignment-operator.cpp
+++ b/test/SemaCXX/default-assignment-operator.cpp
@@ -26,7 +26,7 @@ Z z2;
// Test1
void f(X x, const X cx) {
- x = cx; // expected-note {{synthesized method is first required here}}
+ x = cx; // expected-note {{synthesized method is first required here}}
x = cx;
z1 = z2;
}
@@ -36,8 +36,7 @@ class T {};
T t1;
T t2;
-void g()
-{
+void g() {
t1 = t2;
}
@@ -51,8 +50,7 @@ public:
class W : V {};
W w1, w2;
-void h()
-{
+void h() {
w1 = w2;
}
@@ -67,9 +65,8 @@ public:
class D1 : B1 {};
D1 d1, d2;
-void i()
-{
- d1 = d2;
+void i() {
+ d1 = d2;
}
// Test5
@@ -83,8 +80,7 @@ public:
E1 e1, e2;
-void j()
-{
+void j() {
e1 = e2; // expected-note{{synthesized method is first required here}}
}
diff --git a/test/SemaCXX/default-constructor-initializers.cpp b/test/SemaCXX/default-constructor-initializers.cpp
index 12149e55a7..a6db6a7d9a 100644
--- a/test/SemaCXX/default-constructor-initializers.cpp
+++ b/test/SemaCXX/default-constructor-initializers.cpp
@@ -46,9 +46,9 @@ Y4 y4;
struct Z1 {
- int& z; // expected-note {{declared at}}
- const int c1; // expected-note {{declared at}}
- volatile int v1;
+ int& z; // expected-note {{declared at}}
+ const int c1; // expected-note {{declared at}}
+ volatile int v1;
};
Z1 z1; // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member 'z' cannot be default-initialized}} \
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index 9668c84693..431f457259 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -14,14 +14,13 @@ void f() {
// <rdar://problem/6502934>
typedef enum Foo {
- A = 0,
- B = 1
+ A = 0,
+ B = 1
} Foo;
-
-
+
void bar() {
- Foo myvar = A;
- myvar = B;
+ Foo myvar = A;
+ myvar = B;
}
/// PR3688
diff --git a/test/SemaCXX/illegal-member-initialization.cpp b/test/SemaCXX/illegal-member-initialization.cpp
index 8cedb6f73b..2d7c73d68a 100644
--- a/test/SemaCXX/illegal-member-initialization.cpp
+++ b/test/SemaCXX/illegal-member-initialization.cpp
@@ -3,7 +3,7 @@
struct A {
A() : value(), cvalue() { } // expected-error {{cannot initialize the member to null in default constructor because reference member 'value' cannot be null-initialized}} \
// expected-error {{constructor for 'struct A' must explicitly initialize the reference member 'value'}}
- int &value; // expected-note{{declared at}} {{expected-note{{declared at}}
+ int &value; // expected-note{{declared at}} {{expected-note{{declared at}}
const int cvalue;
};
@@ -11,10 +11,10 @@ struct B {
};
struct X {
- X() { } // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \
- // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \
- // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \
- // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}}
+ X() { } // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'value'}} \
+ // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cvalue'}} \
+ // expected-error {{constructor for 'struct X' must explicitly initialize the reference member 'b'}} \
+ // expected-error {{constructor for 'struct X' must explicitly initialize the const member 'cb'}}
int &value; // expected-note{{declared at}}
const int cvalue; // expected-note{{declared at}}
B& b; // expected-note{{declared at}}
diff --git a/test/SemaCXX/inherit.cpp b/test/SemaCXX/inherit.cpp
index eaad97cc82..069e30d0cd 100644
--- a/test/SemaCXX/inherit.cpp
+++ b/test/SemaCXX/inherit.cpp
@@ -10,7 +10,7 @@ class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base
class C : public B1, private B2 { };
-class D; // expected-note {{forward declaration of 'class D'}}
+class D; // expected-note {{forward declaration of 'class D'}}
class E : public D { }; // expected-error{{base class has incomplete type}}
diff --git a/test/SemaCXX/member-expr-static.cpp b/test/SemaCXX/member-expr-static.cpp
index b6495a8520..2fa7e0781c 100644
--- a/test/SemaCXX/member-expr-static.cpp
+++ b/test/SemaCXX/member-expr-static.cpp
@@ -2,20 +2,18 @@
typedef void (*thread_continue_t)();
extern "C" {
-extern void kernel_thread_start(thread_continue_t continuation);
-extern void pure_c(void);
+ extern void kernel_thread_start(thread_continue_t continuation);
+ extern void pure_c(void);
}
-class _IOConfigThread
-{
+class _IOConfigThread {
public:
- static void main( void );
+ static void main( void );
};
-void foo( void )
-{
- kernel_thread_start(&_IOConfigThread::main);
- kernel_thread_start((thread_continue_t)&_IOConfigThread::main);
- kernel_thread_start(&pure_c);
+void foo( void ) {
+ kernel_thread_start(&_IOConfigThread::main);
+ kernel_thread_start((thread_continue_t)&_IOConfigThread::main);
+ kernel_thread_start(&pure_c);
}
diff --git a/test/SemaCXX/static-initializers.cpp b/test/SemaCXX/static-initializers.cpp
index 3d92a532ae..a651243df7 100644
--- a/test/SemaCXX/static-initializers.cpp
+++ b/test/SemaCXX/static-initializers.cpp
@@ -1,12 +1,10 @@
// RUN: clang-cc -fsyntax-only -verify %s
-int f()
-{
- return 10;
+int f() {
+ return 10;
}
-void g()
-{
- static int a = f();
+void g() {
+ static int a = f();
}
static int b = f();
diff --git a/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index a1990329ac..bfce588b57 100644
--- a/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -64,13 +64,13 @@ struct B1 {
};
struct F : public A1, public B1, private virtual V {
- F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \
- // expected-note {{base 'struct V'}}
+ F() : A1(), V() { } // expected-warning {{base class 'struct A1' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
};
struct X : public virtual A, virtual V, public virtual B {
- X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \
- // expected-note {{base 'struct V'}}
+ X(): A(), V(), B() {} // expected-warning {{base class 'struct A' will be initialized after}} \
+ // expected-note {{base 'struct V'}}
};
class Anon {
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index ee6d9267c5..5c60b519ac 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -109,14 +109,14 @@ static bool HadErrors = false;
static llvm::cl::opt<bool>
Verbose("v", llvm::cl::desc("Enable verbose output"));
static llvm::cl::opt<bool>
-Stats("print-stats",
+Stats("print-stats",
llvm::cl::desc("Print performance metrics and statistics"));
static llvm::cl::opt<bool>
DisableFree("disable-free",
llvm::cl::desc("Disable freeing of memory on exit"),
llvm::cl::init(false));
static llvm::cl::opt<bool>
-EmptyInputOnly("empty-input-only",
+EmptyInputOnly("empty-input-only",
llvm::cl::desc("Force running on an empty input file"));
enum ProgActions {
@@ -129,7 +129,7 @@ enum ProgActions {
EmitAssembly, // Emit a .s file.
EmitLLVM, // Emit a .ll file.
EmitBC, // Emit a .bc file.
- EmitLLVMOnly, // Generate LLVM IR, but do not
+ EmitLLVMOnly, // Generate LLVM IR, but do not
EmitHTML, // Translate input source into HTML.
ASTPrint, // Parse ASTs and print them.
ASTPrintXML, // Parse ASTs and print them in XML.
@@ -143,13 +143,13 @@ enum ProgActions {
PrintPreprocessedInput, // -E mode.
DumpTokens, // Dump out preprocessed tokens.
DumpRawTokens, // Dump out raw tokens.
- RunAnalysis, // Run one or more source code analyses.
+ RunAnalysis, // Run one or more source code analyses.
GeneratePTH, // Generate pre-tokenized header.
GeneratePCH, // Generate pre-compiled header.
InheritanceView // View C++ inheritance for a specified class.
};
-static llvm::cl::opt<ProgActions>
+static llvm::cl::opt<ProgActions>
ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
llvm::cl::init(ParseSyntaxOnly),
llvm::cl::values(
@@ -262,13 +262,13 @@ PrintDiagnosticOption("fdiagnostics-show-option",
static llvm::cl::opt<unsigned>
MessageLength("fmessage-length",
- llvm::cl::desc("Format message diagnostics so that they fit "
- "within N columns or fewer, when possible."),
- llvm::cl::value_desc("N"));
+ llvm::cl::desc("Format message diagnostics so that they fit "
+ "within N columns or fewer, when possible."),
+ llvm::cl::value_desc("N"));
static llvm::cl::opt<bool>
NoColorDiagnostic("fno-color-diagnostics",
- llvm::cl::desc("Don't use colors when showing diagnostics "
+ llvm::cl::desc("Don't use colors when showing diagnostics "
"(automatically turned off if output is not a "
"terminal)."));
//===----------------------------------------------------------------------===//
@@ -402,8 +402,9 @@ PThread("pthread", llvm::cl::desc("Support POSIX threads in generated code"),
static llvm::cl::opt<bool>
ObjCSenderDispatch("fobjc-sender-dependent-dispatch",
- llvm::cl::desc("Enable sender-dependent dispatch for"
- "Objective-C messages"), llvm::cl::init(false));
+ llvm::cl::desc("Enable sender-dependent dispatch for"
+ "Objective-C messages"),
+ llvm::cl::init(false));
/// InitializeBaseLanguage - Handle the -x foo options.
static void InitializeBaseLanguage() {
@@ -416,14 +417,14 @@ static void InitializeBaseLanguage() {
static LangKind GetLanguage(const std::string &Filename) {
if (BaseLang != langkind_unspecified)
return BaseLang;
-
+
std::string::size_type DotPos = Filename.rfind('.');
if (DotPos == std::string::npos) {
BaseLang = langkind_c; // Default to C if no extension.
return langkind_c;
}
-
+
std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end());
// C header: .h
// C++ header: .hh or .H;
@@ -464,12 +465,12 @@ static void InitializeCOptions(LangOptions &Options) {
static void InitializeObjCOptions(LangOptions &Options) {
Options.ObjC1 = Options.ObjC2 = 1;
}
-
+
static void InitializeLangOptions(LangOptions &Options, LangKind LK){
// FIXME: implement -fpreprocessed mode.
bool NoPreprocess = false;
-
+
switch (LK) {
default: assert(0 && "Unknown language kind!");
case langkind_asm_cpp:
@@ -507,28 +508,28 @@ static void InitializeLangOptions(LangOptions &Options, LangKind LK){
Options.LaxVectorConversions = 1;
break;
}
-
+
if (ObjCExclusiveGC)
Options.setGCMode(LangOptions::GCOnly);
else if (ObjCEnableGC)
Options.setGCMode(LangOptions::HybridGC);
-
+
if (ObjCEnableGCBitmapPrint)
Options.ObjCGCBitmapPrint = 1;
-
+
if (AltiVec)
Options.AltiVec = 1;
if (PThread)
Options.POSIXThreads = 1;
-
+
Options.setVisibilityMode(SymbolVisibility);
Options.OverflowChecking = OverflowChecking;
}
/// LangStds - Language standards we support.
enum LangStds {
- lang_unspecified,
+ lang_unspecified,
lang_c89, lang_c94, lang_c99,
lang_gnu_START,
lang_gnu89 = lang_gnu_START, lang_gnu99,
@@ -575,7 +576,7 @@ static llvm::cl::opt<bool>
PascalStrings("fpascal-strings",
llvm::cl::desc("Recognize and construct Pascal-style "
"string literals"));
-
+
static llvm::cl::opt<bool>
MSExtensions("fms-extensions",
llvm::cl::desc("Accept some non-standard constructs used in "
@@ -647,7 +648,7 @@ static llvm::cl::opt<bool>
OptSize("Os", llvm::cl::desc("Optimize for size"));
static llvm::cl::opt<bool>
-DisableLLVMOptimizations("disable-llvm-optzns",
+DisableLLVMOptimizations("disable-llvm-optzns",
llvm::cl::desc("Don't run LLVM optimization passes"));
static llvm::cl::opt<bool>
@@ -661,7 +662,7 @@ MainFileName("main-file-name",
// FIXME: Also add an "-fno-access-control" option.
static llvm::cl::opt<bool>
-AccessControl("faccess-control",
+AccessControl("faccess-control",
llvm::cl::desc("Enable C++ access control"));
static llvm::cl::opt<bool>
@@ -705,7 +706,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
// Pass the map of target features to the target for validation and
// processing.
Target->HandleTargetFeatures(Features);
-
+
if (LangStd == lang_unspecified) {
// Based on the base language, pick one.
switch (LK) {
@@ -728,7 +729,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
break;
}
}
-
+
switch (LangStd) {
default: assert(0 && "Unknown language standard!");
@@ -760,17 +761,17 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
// GNUMode - Set if we're in gnu99, gnu89, gnucxx98, etc.
Options.GNUMode = LangStd >= lang_gnu_START;
-
+
if (Options.CPlusPlus) {
Options.C99 = 0;
Options.HexFloats = 0;
}
-
+
if (LangStd == lang_c89 || LangStd == lang_c94 || LangStd == lang_gnu89)
Options.ImplicitInt = 1;
else
Options.ImplicitInt = 0;
-
+
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
// is specified, or -std is set to a conforming mode.
Options.Trigraphs = !Options.GNUMode;
@@ -783,14 +784,14 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
// However, blocks are not turned off when compiling Obj-C or Obj-C++ code.
if (!Options.ObjC1 && !Options.GNUMode)
Options.Blocks = 0;
-
+
// Default to not accepting '$' in identifiers when preprocessing assembler,
// but do accept when preprocessing C. FIXME: these defaults are right for
// darwin, are they right everywhere?
Options.DollarIdents = LK != langkind_asm_cpp;
if (DollarsInIdents.getPosition()) // Explicit setting overrides default.
Options.DollarIdents = DollarsInIdents;
-
+
if (PascalStrings.getPosition())
Options.PascalStrings = PascalStrings;
if (MSExtensions.getPosition())
@@ -809,18 +810,18 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
Options.NoBuiltin = 1;
if (Freestanding)
Options.Freestanding = Options.NoBuiltin = 1;
-
+
if (EnableHeinousExtensions)
Options.HeinousExtensions = 1;
if (AccessControl)
Options.AccessControl = 1;
-
+
Options.ElideConstructors = !NoElideConstructors;
-
+
// OpenCL and C++ both have bool, true, false keywords.
Options.Bool = Options.OpenCL | Options.CPlusPlus;
-
+
Options.MathErrno = MathErrno;
Options.InstantiationDepth = TemplateDepth;
@@ -838,14 +839,14 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
Options.ObjCNonFragileABI = 1;
Options.ObjCSenderDispatch = ObjCSenderDispatch;
-
+
if (EmitAllDecls)
Options.EmitAllDecls = 1;
// The __OPTIMIZE_SIZE__ define is tied to -Oz, which we don't
// support.
Options.OptimizeSize = 0;
-
+
// -Os implies -O2
if (OptSize || OptLevel)
Options.Optimize = 1;
@@ -854,7 +855,7 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
Options.PICLevel = PICLevel;
Options.GNUInline = !Options.C99;
- // FIXME: This is affected by other options (-fno-inline).
+ // FIXME: This is affected by other options (-fno-inline).
Options.NoInline = !OptSize && !OptLevel;
Options.Static = StaticDefine;
@@ -881,7 +882,7 @@ TargetTriple("triple",
llvm::cl::desc("Specify target triple (e.g. i686-apple-darwin9)"));
static llvm::cl::opt<std::string>
-MacOSVersionMin("mmacosx-version-min",
+MacOSVersionMin("mmacosx-version-min",
llvm::cl::desc("Specify target Mac OS X version (e.g. 10.5)"));
// If -mmacosx-version-min=10.3.9 is specified, change the triple from being
@@ -891,12 +892,12 @@ MacOSVersionMin("mmacosx-version-min",
static void HandleMacOSVersionMin(std::string &Triple) {
std::string::size_type DarwinDashIdx = Triple.find("-darwin");
if (DarwinDashIdx == std::string::npos) {
- fprintf(stderr,
+ fprintf(stderr,
"-mmacosx-version-min only valid for darwin (Mac OS X) targets\n");
exit(1);
}
unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin");
-
+
// Remove the number.
Triple.resize(DarwinNumIdx);
@@ -914,10 +915,10 @@ static void HandleMacOSVersionMin(std::string &Triple) {
// The version number must be in the range 0-9.
MacOSVersionMinIsInvalid = (unsigned)VersionNum > 9;
-
+
// Turn MacOSVersionMin into a darwin number: e.g. 10.3.9 is 3 -> 7.
Triple += llvm::itostr(VersionNum+4);
-
+
if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 10.4.7 is ok.
// Add the period piece (.7) to the end of the triple. This gives us
// something like ...-darwin8.7
@@ -926,16 +927,16 @@ static void HandleMacOSVersionMin(std::string &Triple) {
MacOSVersionMinIsInvalid = true;
}
}
-
+
if (MacOSVersionMinIsInvalid) {
- fprintf(stderr,
+ fprintf(stderr,
"-mmacosx-version-min=%s is invalid, expected something like '10.4'.\n",
MacOSVersionMin.c_str());
exit(1);
}
- else if (VersionNum <= 4 &&
+ else if (VersionNum <= 4 &&
!strncmp(Triple.c_str(), "x86_64", strlen("x86_64"))) {
- fprintf(stderr,
+ fprintf(stderr,
"-mmacosx-version-min=%s is invalid with -arch x86_64.\n",
MacOSVersionMin.c_str());
exit(1);
@@ -944,7 +945,7 @@ static void HandleMacOSVersionMin(std::string &Triple) {
}
static llvm::cl::opt<std::string>
-IPhoneOSVersionMin("miphoneos-version-min",
+IPhoneOSVersionMin("miphoneos-version-min",
llvm::cl::desc("Specify target iPhone OS version (e.g. 2.0)"));
// If -miphoneos-version-min=2.2 is specified, change the triple from being
@@ -956,15 +957,15 @@ IPhoneOSVersionMin("miphoneos-version-min",
static void HandleIPhoneOSVersionMin(std::string &Triple) {
std::string::size_type DarwinDashIdx = Triple.find("-darwin");
if (DarwinDashIdx == std::string::npos) {
- fprintf(stderr,
+ fprintf(stderr,
"-miphoneos-version-min only valid for darwin (Mac OS X) targets\n");
exit(1);
}
unsigned DarwinNumIdx = DarwinDashIdx + strlen("-darwin");
-
+
// Remove the number.
Triple.resize(DarwinNumIdx);
-
+
// Validate that IPhoneOSVersionMin is a 'version number', starting with [2-9].[0-9]
bool IPhoneOSVersionMinIsInvalid = false;
int VersionNum = 0;
@@ -975,13 +976,13 @@ static void HandleIPhoneOSVersionMin(std::string &Triple) {
const char *Start = IPhoneOSVersionMin.c_str();
char *End = 0;
VersionNum = (int)strtol(Start, &End, 10);
-
+
// The version number must be in the range 0-9.
IPhoneOSVersionMinIsInvalid = (unsigned)VersionNum > 9;
-
+
// Turn IPhoneOSVersionMin into a darwin number: e.g. 2.0 is 2 -> 9.2.
Triple += "9." + llvm::itostr(VersionNum);
-
+
if (End[0] == '.' && isdigit(End[1]) && End[2] == '\0') { // 2.2 is ok.
// Add the period piece (.2) to the end of the triple. This gives us
// something like ...-darwin9.2.2
@@ -990,9 +991,9 @@ static void HandleIPhoneOSVersionMin(std::string &Triple) {
IPhoneOSVersionMinIsInvalid = true;
}
}
-
+
if (IPhoneOSVersionMinIsInvalid) {
- fprintf(stderr,
+ fprintf(stderr,
"-miphoneos-version-min=%s is invalid, expected something like '2.0'.\n",
IPhoneOSVersionMin.c_str());
exit(1);
@@ -1014,7 +1015,7 @@ static std::string CreateTargetTriple() {
HandleMacOSVersionMin(Triple);
else if (!IPhoneOSVersionMin.empty())
HandleIPhoneOSVersionMin(Triple);;
-
+
return Triple;
}
@@ -1030,14 +1031,14 @@ static bool InitializeSourceManager(Preprocessor &PP,
if (EmptyInputOnly) {
const char *EmptyStr = "";
- llvm::MemoryBuffer *SB =
+ llvm::MemoryBuffer *SB =
llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<empty input>");
SourceMgr.createMainFileIDForMemBuffer(SB);
} else if (InFile != "-") {
const FileEntry *File = FileMgr.getFile(InFile);
if (File) SourceMgr.createMainFileID(File, SourceLocation());
if (SourceMgr.getMainFileID().isInvalid()) {
- PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading)
+ PP.getDiagnostics().Report(FullSourceLoc(), diag::err_fe_error_reading)
<< InFile.c_str();
return true;
}
@@ -1053,7 +1054,7 @@ static bool InitializeSourceManager(Preprocessor &PP,
SourceMgr.createMainFileIDForMemBuffer(SB);
if (SourceMgr.getMainFileID().isInvalid()) {
- PP.getDiagnostics().Report(FullSourceLoc(),
+ PP.getDiagnostics().Report(FullSourceLoc(),
diag::err_fe_error_reading_stdin);
return true;
}
@@ -1094,7 +1095,7 @@ ImplicitIncludePTH("include-pth", llvm::cl::value_desc("file"),
llvm::cl::desc("Include file before parsing"));
static llvm::cl::opt<bool>
-RelocatablePCH("relocatable-pch",
+RelocatablePCH("relocatable-pch",
llvm::cl::desc("Whether to build a relocatable precompiled "
"header"));
@@ -1105,7 +1106,7 @@ RelocatablePCH("relocatable-pch",
// This tool exports a large number of command line options to control how the
// preprocessor searches for header files. At root, however, the Preprocessor
// object takes a very simple interface: a list of directories to search for
-//
+//
// FIXME: -nostdinc++
// FIXME: -imultilib
//
@@ -1165,22 +1166,22 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
++Fidx;
}
}
-
+
// Consume what's left from whatever list was longer.
for (; Iidx != I_dirs.size(); ++Iidx)
Init.AddPath(I_dirs[Iidx], InitHeaderSearch::Angled, false, true, false);
for (; Fidx != F_dirs.size(); ++Fidx)
Init.AddPath(F_dirs[Fidx], InitHeaderSearch::Angled, false, true, true);
-
+
// Handle -idirafter... options.
for (unsigned i = 0, e = idirafter_dirs.size(); i != e; ++i)
Init.AddPath(idirafter_dirs[i], InitHeaderSearch::After,
false, true, false);
-
+
// Handle -iquote... options.
for (unsigned i = 0, e = iquote_dirs.size(); i != e; ++i)
Init.AddPath(iquote_dirs[i], InitHeaderSearch::Quoted, false, true, false);
-
+
// Handle -isystem... options.
for (unsigned i = 0, e = isystem_dirs.size(); i != e; ++i)
Init.AddPath(isystem_dirs[i], InitHeaderSearch::System, false, true, false);
@@ -1198,28 +1199,28 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
bool iwithprefixbefore_done = iwithprefixbefore_vals.empty();
while (!iprefix_done || !iwithprefix_done || !iwithprefixbefore_done) {
if (!iprefix_done &&
- (iwithprefix_done ||
- iprefix_vals.getPosition(iprefix_idx) <
+ (iwithprefix_done ||
+ iprefix_vals.getPosition(iprefix_idx) <
iwithprefix_vals.getPosition(iwithprefix_idx)) &&
- (iwithprefixbefore_done ||
- iprefix_vals.getPosition(iprefix_idx) <
+ (iwithprefixbefore_done ||
+ iprefix_vals.getPosition(iprefix_idx) <
iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
Prefix = iprefix_vals[iprefix_idx];
++iprefix_idx;
iprefix_done = iprefix_idx == iprefix_vals.size();
} else if (!iwithprefix_done &&
- (iwithprefixbefore_done ||
- iwithprefix_vals.getPosition(iwithprefix_idx) <
+ (iwithprefixbefore_done ||
+ iwithprefix_vals.getPosition(iwithprefix_idx) <
iwithprefixbefore_vals.getPosition(iwithprefixbefore_idx))) {
- Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx],
+ Init.AddPath(Prefix+iwithprefix_vals[iwithprefix_idx],
InitHeaderSearch::System, false, false, false);
++iwithprefix_idx;
iwithprefix_done = iwithprefix_idx == iwithprefix_vals.size();
} else {
- Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx],
+ Init.AddPath(Prefix+iwithprefixbefore_vals[iwithprefixbefore_idx],
InitHeaderSearch::Angled, false, false, false);
++iwithprefixbefore_idx;
- iwithprefixbefore_done =
+ iwithprefixbefore_done =
iwithprefixbefore_idx == iwithprefixbefore_vals.size();
}
}
@@ -1228,36 +1229,35 @@ void InitializeIncludePaths(const char *Argv0, HeaderSearch &Headers,
Init.AddDefaultEnvVarPaths(Lang);
// Add the clang headers, which are relative to the clang binary.
- llvm::sys::Path MainExecutablePath =
+ llvm::sys::Path MainExecutablePath =
llvm::sys::Path::GetMainExecutable(Argv0,
(void*)(intptr_t)InitializeIncludePaths);
if (!MainExecutablePath.isEmpty()) {
MainExecutablePath.eraseComponent(); // Remove /clang from foo/bin/clang
MainExecutablePath.eraseComponent(); // Remove /bin from foo/bin
- // Get foo/lib/clang/<version>/include
+ // Get foo/lib/clang/<version>/include
MainExecutablePath.appendComponent("lib");
MainExecutablePath.appendComponent("clang");
MainExecutablePath.appendComponent(CLANG_VERSION_STRING);
MainExecutablePath.appendComponent("include");
-
+
// We pass true to ignore sysroot so that we *always* look for clang headers
// relative to our executable, never relative to -isysroot.
Init.AddPath(MainExecutablePath.c_str(), InitHeaderSearch::System,
false, false, false, true /*ignore sysroot*/);
}
-
- if (!nostdinc)
+
+ if (!nostdinc)
Init.AddDefaultSystemIncludePaths(Lang);
// Now that we have collected all of the include paths, merge them all
// together and tell the preprocessor about them.
-
+
Init.Realize();
}
-void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts)
-{
+void InitializePreprocessorInitOptions(PreprocessorInitOptions &InitOpts) {
// Add macros from the command line.
unsigned d = 0, D = D_macros.size();
unsigned u = 0, U = U_macros.size();
@@ -1326,17 +1326,17 @@ class VISIBILITY_HIDDEN DriverPreprocessorFactory : public PreprocessorFactory {
TargetInfo &Target;
SourceManager &SourceMgr;
HeaderSearch &HeaderInfo;
-
+
public:
DriverPreprocessorFactory(Diagnostic &diags, const LangOptions &opts,
TargetInfo &target, SourceManager &SM,
- HeaderSearch &Headers)
+ HeaderSearch &Headers)
: Diags(diags), LangInfo(opts), Target(target),
SourceMgr(SM), HeaderInfo(Headers) {}
-
-
+
+
virtual ~DriverPreprocessorFactory() {}
-
+
virtual Preprocessor* CreatePreprocessor() {
llvm::OwningPtr<PTHManager> PTHMgr;
@@ -1345,23 +1345,23 @@ public:
"options\n");
exit(1);
}
-
+
// Use PTH?
if (!TokenCache.empty() || !ImplicitIncludePTH.empty()) {
const std::string& x = TokenCache.empty() ? ImplicitIncludePTH:TokenCache;
- PTHMgr.reset(PTHManager::Create(x, &Diags,
+ PTHMgr.reset(PTHManager::Create(x, &Diags,
TokenCache.empty() ? Diagnostic::Error
: Diagnostic::Warning));
}
-
+
if (Diags.hasErrorOccurred())
exit(1);
-
+
// Create the Preprocessor.
llvm::OwningPtr<Preprocessor> PP(new Preprocessor(Diags, LangInfo, Target,
SourceMgr, HeaderInfo,
PTHMgr.get()));
-
+
// Note that this is different then passing PTHMgr to Preprocessor's ctor.
// That argument is used as the IdentifierInfoLookup argument to
// IdentifierTable's ctor.
@@ -1387,7 +1387,7 @@ public:
static void ParseFile(Preprocessor &PP, MinimalAction *PA) {
Parser P(PP, *PA);
PP.EnterMainSourceFile();
-
+
// Parsing the specified input file.
P.ParseTranslationUnit();
delete PA;
@@ -1424,24 +1424,24 @@ NoImplicitFloat("no-implicit-float",
/// and feature list.
static void ComputeFeatureMap(TargetInfo *Target,
llvm::StringMap<bool> &Features) {
- assert(Features.empty() && "invalid map");
+ assert(Features.empty() && "invalid map");
// Initialize the feature map based on the target.
Target->getDefaultFeatures(TargetCPU, Features);
// Apply the user specified deltas.
- for (llvm::cl::list<std::string>::iterator it = TargetFeatures.begin(),
+ for (llvm::cl::list<std::string>::iterator it = TargetFeatures.begin(),
ie = TargetFeatures.end(); it != ie; ++it) {
const char *Name = it->c_str();
-
+
// FIXME: Don't handle errors like this.
if (Name[0] != '-' && Name[0] != '+') {
- fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n",
+ fprintf(stderr, "error: clang-cc: invalid target feature string: %s\n",
Name);
exit(1);
}
if (!Target->setFeatureEnabled(Features, Name + 1, (Name[0] == '+'))) {
- fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n",
+ fprintf(stderr, "error: clang-cc: invalid target feature name: %s\n",
Name + 1);
exit(1);
}
@@ -1482,7 +1482,7 @@ static void InitializeCompileOptions(CompileOptions &Opts,
Opts.CPU = TargetCPU;
Opts.Features.clear();
- for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
+ for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
ie = Features.end(); it != ie; ++it) {
// FIXME: If we are completely confident that we have the right
// set, we only need to pass the minuses.
@@ -1490,9 +1490,9 @@ static void InitializeCompileOptions(CompileOptions &Opts,
Name += it->first();
Opts.Features.push_back(Name);
}
-
+
Opts.NoCommon = NoCommon | LangOpts.CPlusPlus;
-
+
// Handle -ftime-report.
Opts.TimePasses = TimeReport;
@@ -1579,7 +1579,7 @@ clEnumValN(NAME, CMDFLAG, DESC),
#include "clang/Frontend/Analyses.def"
clEnumValEnd));
-static llvm::cl::opt<AnalysisStores>
+static llvm::cl::opt<AnalysisStores>
AnalysisStoreOpt("analyzer-store",
llvm::cl::desc("Source Code Analysis - Abstract Memory Store Models"),
llvm::cl::init(BasicStoreModel),
@@ -1589,7 +1589,7 @@ clEnumValN(NAME##Model, CMDFLAG, DESC),
#include "clang/Frontend/Analyses.def"
clEnumValEnd));
-static llvm::cl::opt<AnalysisConstraints>
+static llvm::cl::opt<AnalysisConstraints>
AnalysisConstraintsOpt("analyzer-constraints",
llvm::cl::desc("Source Code Analysis - Symbolic Constraint Engines"),
llvm::cl::init(RangeConstraintsModel),
@@ -1681,7 +1681,7 @@ class LoggingDiagnosticClient : public DiagnosticClient {
llvm::OwningPtr<DiagnosticClient> Chain1;
llvm::OwningPtr<DiagnosticClient> Chain2;
public:
-
+
LoggingDiagnosticClient(DiagnosticClient *Normal) {
// Output diags both where requested...
Chain1.reset(Normal);
@@ -1695,12 +1695,12 @@ public:
!NoDiagnosticsFixIt,
MessageLength));
}
-
+
virtual void setLangOptions(const LangOptions *LO) {
Chain1->setLangOptions(LO);
Chain2->setLangOptions(LO);
}
-
+
virtual bool IncludeInDiagnosticCounts() const {
return Chain1->IncludeInDiagnosticCounts();
}
@@ -1715,11 +1715,11 @@ public:
static void SetUpBuildDumpLog(unsigned argc, char **argv,
llvm::OwningPtr<DiagnosticClient> &DiagClient) {
-
+
std::string ErrorInfo;
BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(),
ErrorInfo);
-
+
if (!ErrorInfo.empty()) {
llvm::errs() << "error opening -dump-build-information file '"
<< DumpBuildInformation << "', option ignored!\n";
@@ -1733,7 +1733,7 @@ static void SetUpBuildDumpLog(unsigned argc, char **argv,
for (unsigned i = 0; i != argc; ++i)
(*BuildLogFile) << argv[i] << ' ';
(*BuildLogFile) << '\n';
-
+
// LoggingDiagnosticClient - Insert a new logging diagnostic client in between
// the diagnostic producers and the normal receiver.
DiagClient.reset(new LoggingDiagnosticClient(DiagClient.take()));
@@ -1772,7 +1772,7 @@ static llvm::raw_ostream *ComputeOutFile(const std::string &InFile,
llvm::errs() << "ERROR: " << Error << "\n";
::exit(1);
}
-
+
if (OutFile != "-")
OutPath = OutFile;
@@ -1802,7 +1802,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
OS.reset(ComputeOutFile(InFile, 0, false, OutPath));
Consumer.reset(CreateASTPrinter(OS.get()));
break;
-
+
case ASTPrintXML:
OS.reset(ComputeOutFile(InFile, "xml", false, OutPath));
Consumer.reset(CreateASTPrinterXML(OS.get()));
@@ -1831,7 +1831,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
case EmitAssembly:
case EmitLLVM:
- case EmitBC:
+ case EmitBC:
case EmitLLVMOnly: {
BackendAction Act;
if (ProgAction == EmitAssembly) {
@@ -1860,7 +1860,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
PP.Diag(SourceLocation(), diag::err_relocatable_without_without_isysroot);
RelocatablePCH.setValue(false);
}
-
+
OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
if (RelocatablePCH.getValue())
Consumer.reset(CreatePCHGenerator(PP, OS.get(), isysroot.c_str()));
@@ -1920,7 +1920,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
}
case RunPreprocessorOnly:
break;
-
+
case GeneratePTH: {
llvm::TimeRegion Timer(ClangFrontendTimer);
if (OutputFile.empty() || OutputFile == "-") {
@@ -1933,15 +1933,15 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
CacheTokens(PP, static_cast<llvm::raw_fd_ostream*>(OS.get()));
ClearSourceMgr = true;
break;
- }
+ }
case PrintPreprocessedInput:
OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
break;
-
+
case ParseNoop:
break;
-
+
case ParsePrintCallbacks: {
llvm::TimeRegion Timer(ClangFrontendTimer);
OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
@@ -1955,13 +1955,13 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
Consumer.reset(new ASTConsumer());
break;
}
-
+
case RewriteMacros:
OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
RewriteMacrosInInput(PP, OS.get());
ClearSourceMgr = true;
break;
-
+
case RewriteTest:
OS.reset(ComputeOutFile(InFile, 0, true, OutPath));
DoRewriteTest(PP, OS.get());
@@ -1987,7 +1987,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
PP.getLangOptions());
bool AddedFixitLocation = false;
- for (unsigned Idx = 0, Last = FixItAtLocations.size();
+ for (unsigned Idx = 0, Last = FixItAtLocations.size();
Idx != Last; ++Idx) {
RequestedSourceLocation Requested;
if (ResolveParsedLocation(FixItAtLocations[Idx],
@@ -2017,19 +2017,19 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
PP.getBuiltinInfo(),
/* FreeMemory = */ !DisableFree,
/* size_reserve = */0));
-
+
llvm::OwningPtr<PCHReader> Reader;
llvm::OwningPtr<ExternalASTSource> Source;
-
+
if (!ImplicitIncludePCH.empty()) {
// If the user specified -isysroot, it will be used for relocatable PCH
// files.
const char *isysrootPCH = 0;
if (isysroot.getNumOccurrences() != 0)
isysrootPCH = isysroot.c_str();
-
+
Reader.reset(new PCHReader(PP, ContextOwner.get(), isysrootPCH));
-
+
// The user has asked us to include a precompiled header. Load
// the precompiled header into the AST context.
switch (Reader->ReadPCH(ImplicitIncludePCH)) {
@@ -2080,7 +2080,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
// If we have an ASTConsumer, run the parser with it.
if (Consumer)
- ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats,
+ ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats,
CompleteTranslationUnit);
if (PA == RunPreprocessorOnly) { // Just lex as fast as we can, no output.
@@ -2106,7 +2106,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
DisableLineMarkers, DumpDefines);
ClearSourceMgr = true;
}
-
+
if (FixItRewrite)
FixItRewrite->WriteFixedFile(InFile, OutputFile);
@@ -2116,7 +2116,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
Consumer.take();
else
Consumer.reset();
-
+
// If in -disable-free mode, don't deallocate ASTContext.
if (DisableFree)
ContextOwner.take();
@@ -2136,7 +2136,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
fprintf(stderr, "\n");
}
- // For a multi-file compilation, some things are ok with nuking the source
+ // For a multi-file compilation, some things are ok with nuking the source
// manager tables, other require stable fileid/macroid's across multiple
// files.
if (ClearSourceMgr)
@@ -2176,14 +2176,14 @@ int main(int argc, char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv,
"LLVM 'Clang' Compiler: http://clang.llvm.org\n");
-
+
if (TimeReport)
ClangFrontendTimer = new llvm::Timer("Clang front-end time");
-
+
if (Verbose)
llvm::errs() << "clang-cc version 1.0 based upon " << PACKAGE_STRING
<< " hosted on " << llvm::sys::getHostTriple() << "\n";
-
+
// If no input was specified, read from stdin.
if (InputFilenames.empty())
InputFilenames.push_back("-");
@@ -2227,17 +2227,17 @@ int main(int argc, char **argv) {
} else {
DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
}
-
+
if (!DumpBuildInformation.empty()) {
if (!HTMLDiag.empty()) {
fprintf(stderr,
"-dump-build-information and -html-diags don't work together\n");
return 1;
}
-
+
SetUpBuildDumpLog(argc, argv, DiagClient);
}
-
+
// Configure our handling of diagnostics.
Diagnostic Diags(DiagClient.get());
@@ -2253,7 +2253,7 @@ int main(int argc, char **argv) {
// -I- is a deprecated GCC feature, scan for it and reject it.
for (unsigned i = 0, e = I_dirs.size(); i != e; ++i) {
if (I_dirs[i] == "-") {
- Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported);
+ Diags.Report(FullSourceLoc(), diag::err_pp_I_dash_not_supported);
I_dirs.erase(I_dirs.begin()+i);
--i;
}
@@ -2262,18 +2262,18 @@ int main(int argc, char **argv) {
// Get information about the target being compiled for.
std::string Triple = CreateTargetTriple();
llvm::OwningPtr<TargetInfo> Target(TargetInfo::CreateTargetInfo(Triple));
-
+
if (Target == 0) {
- Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple)
+ Diags.Report(FullSourceLoc(), diag::err_fe_unknown_triple)
<< Triple.c_str();
return 1;
}
-
+
if (!InheritanceViewCls.empty()) // C++ visualization?
ProgAction = InheritanceView;
-
+
llvm::OwningPtr<SourceManager> SourceMgr;
-
+
// Create a file manager object to provide access to and cache the filesystem.
FileManager FileMgr;
@@ -2283,35 +2283,35 @@ int main(int argc, char **argv) {
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
-
+
/// Create a SourceManager object. This tracks and owns all the file
/// buffers allocated to a translation unit.
if (!SourceMgr)
SourceMgr.reset(new SourceManager());
else
SourceMgr->clearIDTables();
-
+
// Initialize language options, inferring file types from input filenames.
LangOptions LangInfo;
DiagClient->setLangOptions(&LangInfo);
-
+
InitializeBaseLanguage();
LangKind LK = GetLanguage(InFile);
InitializeLangOptions(LangInfo, LK);
InitializeLanguageStandard(LangInfo, LK, Target.get(), Features);
-
+
// Process the -I options and set them in the HeaderInfo.
HeaderSearch HeaderInfo(FileMgr);
-
-
+
+
InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo);
-
+
// Set up the preprocessor with these options.
DriverPreprocessorFactory PPFactory(Diags, LangInfo, *Target,
*SourceMgr.get(), HeaderInfo);
-
+
llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor());
-
+
if (!PP)
continue;
@@ -2342,7 +2342,7 @@ int main(int argc, char **argv) {
if (ImplicitIncludePCH.empty()) {
if (InitializeSourceManager(*PP.get(), InFile))
continue;
-
+
// Initialize builtin info.
PP->getBuiltinInfo().InitializeBuiltins(PP->getIdentifierTable(),
PP->getLangOptions().NoBuiltin);
@@ -2353,7 +2353,7 @@ int main(int argc, char **argv) {
// Process the source file.
ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features, Context);
-
+
HeaderInfo.ClearFileInfo();
DiagClient->setLangOptions(0);
}
@@ -2362,7 +2362,7 @@ int main(int argc, char **argv) {
if (unsigned NumDiagnostics = Diags.getNumDiagnostics())
fprintf(stderr, "%d diagnostic%s generated.\n", NumDiagnostics,
(NumDiagnostics == 1 ? "" : "s"));
-
+
if (Stats) {
FileMgr.PrintStats();
fprintf(stderr, "\n");
@@ -2370,11 +2370,11 @@ int main(int argc, char **argv) {
delete ClangFrontendTimer;
delete BuildLogFile;
-
+
// If verifying diagnostics and we reached here, all is well.
if (VerifyDiagnostics)
return 0;
-
+
// Managed static deconstruction. Useful for making things like
// -time-passes usable.
llvm::llvm_shutdown();
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index 88fd2417ac..2010434b7b 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -62,11 +62,11 @@ public:
: AST(ast), Filename(filename),
DeclRefMap(ast->getASTContext()),
SelMap(ast->getASTContext()) { }
-
+
virtual ASTContext &getASTContext() { return AST->getASTContext(); }
virtual DeclReferenceMap &getDeclReferenceMap() { return DeclRefMap; }
virtual SelectorMap &getSelectorMap() { return SelMap; }
-
+
llvm::OwningPtr<ASTUnit> AST;
std::string Filename;
DeclReferenceMap DeclRefMap;
@@ -85,7 +85,7 @@ enum ProgActions {
PrintDecls // Print declarations of the point-at node
};
-static llvm::cl::opt<ProgActions>
+static llvm::cl::opt<ProgActions>
ProgAction(
llvm::cl::desc("Choose action to perform on the pointed-at AST node:"),
llvm::cl::ZeroOrMore,
@@ -119,7 +119,7 @@ static void ProcessObjCMessage(ObjCMessageExpr *Msg, Indexer &Idxer) {
llvm::errs() << "Error: Cannot -print-refs on a ObjC message expression\n";
HadErrors = true;
return;
-
+
case PrintDecls: {
Analyz.FindObjCMethods(Msg, Results);
for (ResultsTy::iterator
@@ -144,7 +144,7 @@ static void ProcessObjCMessage(ObjCMessageExpr *Msg, Indexer &Idxer) {
static void ProcessASTLocation(ASTLocation ASTLoc, Indexer &Idxer) {
assert(ASTLoc.isValid());
-
+
if (ObjCMessageExpr *Msg =
dyn_cast_or_null<ObjCMessageExpr>(ASTLoc.getStmt()))
return ProcessObjCMessage(Msg, Idxer);
@@ -210,20 +210,20 @@ int main(int argc, char **argv) {
llvm::PrettyStackTraceProgram X(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv,
"LLVM 'Clang' Indexing Test Bed: http://clang.llvm.org\n");
-
+
FileManager FileMgr;
Program Prog;
Indexer Idxer(Prog, FileMgr);
llvm::SmallVector<TUnit*, 4> TUnits;
-
+
// If no input was specified, read from stdin.
if (InputFilenames.empty())
InputFilenames.push_back("-");
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
-
+
std::string ErrMsg;
llvm::OwningPtr<ASTUnit> AST;
@@ -235,7 +235,7 @@ int main(int argc, char **argv) {
TUnit *TU = new TUnit(AST.take(), InFile);
TUnits.push_back(TU);
-
+
Idxer.IndexAST(TU);
}
@@ -272,7 +272,7 @@ int main(int argc, char **argv) {
"Couldn't resolve source location (invalid location)\n";
return 1;
}
-
+
ASTLoc = ResolveLocationInAST(FirstAST->getASTContext(), Loc);
if (ASTLoc.isInvalid()) {
llvm::errs() << "[" << FirstFile << "] Error: " <<
@@ -280,7 +280,7 @@ int main(int argc, char **argv) {
return 1;
}
}
-
+
if (ASTLoc.isValid()) {
if (ProgAction == PrintPoint) {
llvm::raw_ostream &OS = llvm::outs();
@@ -292,7 +292,7 @@ int main(int argc, char **argv) {
ProcessASTLocation(ASTLoc, Idxer);
}
}
-
+
if (HadErrors)
return 1;
@@ -304,6 +304,6 @@ int main(int argc, char **argv) {
// Managed static deconstruction. Useful for making things like
// -time-passes usable.
llvm::llvm_shutdown();
-
+
return 0;
}