aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-08-02 17:33:11 +0000
commitc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (patch)
tree27425930fc0c91650a7f3527fcac8e0f92907b90 /lib
parent486754660bb926339aefcf012a3f848592babb8b (diff)
downloadsrc-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.tar.gz
src-c7e70c433efc6953dc3888b9fbf9f3512d7da2b0.zip
Vendor import of clang trunk r338536:vendor/clang/clang-trunk-r338536
Notes
Notes: svn path=/vendor/clang/dist/; revision=337139 svn path=/vendor/clang/clang-trunk-r338536/; revision=337140; tag=vendor/clang/clang-trunk-r338536
Diffstat (limited to 'lib')
-rw-r--r--lib/ARCMigrate/ARCMT.cpp6
-rw-r--r--lib/ARCMigrate/FileRemapper.cpp6
-rw-r--r--lib/ARCMigrate/Internals.h2
-rw-r--r--lib/ARCMigrate/ObjCMT.cpp144
-rw-r--r--lib/ARCMigrate/PlistReporter.cpp2
-rw-r--r--lib/ARCMigrate/TransARCAssign.cpp2
-rw-r--r--lib/ARCMigrate/TransAutoreleasePool.cpp10
-rw-r--r--lib/ARCMigrate/TransBlockObjCVariable.cpp6
-rw-r--r--lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp2
-rw-r--r--lib/ARCMigrate/TransGCAttrs.cpp6
-rw-r--r--lib/ARCMigrate/TransProperties.cpp14
-rw-r--r--lib/ARCMigrate/TransProtectedScope.cpp2
-rw-r--r--lib/ARCMigrate/TransRetainReleaseDealloc.cpp4
-rw-r--r--lib/ARCMigrate/TransUnbridgedCasts.cpp4
-rw-r--r--lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp14
-rw-r--r--lib/ARCMigrate/TransformActions.cpp6
-rw-r--r--lib/ARCMigrate/Transforms.cpp38
-rw-r--r--lib/ARCMigrate/Transforms.h2
-rw-r--r--lib/AST/ASTContext.cpp396
-rw-r--r--lib/AST/ASTDiagnostic.cpp12
-rw-r--r--lib/AST/ASTDumper.cpp2
-rw-r--r--lib/AST/ASTImporter.cpp478
-rw-r--r--lib/AST/ASTStructuralEquivalence.cpp4
-rw-r--r--lib/AST/CXXInheritance.cpp64
-rw-r--r--lib/AST/Comment.cpp2
-rw-r--r--lib/AST/CommentLexer.cpp2
-rw-r--r--lib/AST/Decl.cpp129
-rw-r--r--lib/AST/DeclBase.cpp50
-rw-r--r--lib/AST/DeclCXX.cpp156
-rw-r--r--lib/AST/DeclObjC.cpp62
-rw-r--r--lib/AST/DeclPrinter.cpp28
-rw-r--r--lib/AST/DeclTemplate.cpp14
-rw-r--r--lib/AST/DeclarationName.cpp16
-rw-r--r--lib/AST/Expr.cpp193
-rw-r--r--lib/AST/ExprCXX.cpp94
-rw-r--r--lib/AST/ExprClassification.cpp12
-rw-r--r--lib/AST/ExprConstant.cpp310
-rw-r--r--lib/AST/ExternalASTSource.cpp2
-rw-r--r--lib/AST/ItaniumCXXABI.cpp2
-rw-r--r--lib/AST/ItaniumMangle.cpp136
-rw-r--r--lib/AST/Mangle.cpp2
-rw-r--r--lib/AST/MicrosoftMangle.cpp18
-rw-r--r--lib/AST/NSAPI.cpp6
-rw-r--r--lib/AST/NestedNameSpecifier.cpp104
-rw-r--r--lib/AST/ParentMap.cpp2
-rw-r--r--lib/AST/RecordLayout.cpp6
-rw-r--r--lib/AST/RecordLayoutBuilder.cpp242
-rw-r--r--lib/AST/StmtOpenMP.cpp12
-rw-r--r--lib/AST/StmtPrinter.cpp16
-rw-r--r--lib/AST/StmtProfile.cpp55
-rw-r--r--lib/AST/TemplateBase.cpp68
-rw-r--r--lib/AST/TemplateName.cpp14
-rw-r--r--lib/AST/Type.cpp158
-rw-r--r--lib/AST/TypeLoc.cpp20
-rw-r--r--lib/AST/TypePrinter.cpp216
-rw-r--r--lib/AST/VTTBuilder.cpp50
-rw-r--r--lib/AST/VTableBuilder.cpp566
-rw-r--r--lib/Analysis/AnalysisDeclContext.cpp18
-rw-r--r--lib/Analysis/BodyFarm.cpp52
-rw-r--r--lib/Analysis/CFG.cpp212
-rw-r--r--lib/Analysis/CFGReachabilityAnalysis.cpp14
-rw-r--r--lib/Analysis/CFGStmtMap.cpp12
-rw-r--r--lib/Analysis/CallGraph.cpp2
-rw-r--r--lib/Analysis/CocoaConventions.cpp32
-rw-r--r--lib/Analysis/ConstructionContext.cpp303
-rw-r--r--lib/Analysis/Consumed.cpp216
-rw-r--r--lib/Analysis/FormatString.cpp10
-rw-r--r--lib/Analysis/FormatStringParsing.h10
-rw-r--r--lib/Analysis/LiveVariables.cpp78
-rw-r--r--lib/Analysis/ObjCNoReturn.cpp8
-rw-r--r--lib/Analysis/PostOrderCFGView.cpp6
-rw-r--r--lib/Analysis/PrintfFormatString.cpp6
-rw-r--r--lib/Analysis/ProgramPoint.cpp2
-rw-r--r--lib/Analysis/ReachableCode.cpp22
-rw-r--r--lib/Analysis/ScanfFormatString.cpp26
-rw-r--r--lib/Analysis/UninitializedValues.cpp22
-rw-r--r--lib/Basic/Diagnostic.cpp12
-rw-r--r--lib/Basic/DiagnosticIDs.cpp2
-rw-r--r--lib/Basic/FileManager.cpp16
-rw-r--r--lib/Basic/FileSystemStatCache.cpp8
-rw-r--r--lib/Basic/IdentifierTable.cpp18
-rw-r--r--lib/Basic/Module.cpp28
-rw-r--r--lib/Basic/ObjCRuntime.cpp2
-rw-r--r--lib/Basic/SourceLocation.cpp2
-rw-r--r--lib/Basic/SourceManager.cpp64
-rw-r--r--lib/Basic/Targets/ARM.cpp4
-rw-r--r--lib/Basic/Targets/X86.cpp2
-rw-r--r--lib/Basic/Targets/X86.h8
-rw-r--r--lib/Basic/Warnings.cpp20
-rw-r--r--lib/CodeGen/CGBlocks.cpp38
-rw-r--r--lib/CodeGen/CGBlocks.h10
-rw-r--r--lib/CodeGen/CGBuilder.h2
-rw-r--r--lib/CodeGen/CGBuiltin.cpp6
-rw-r--r--lib/CodeGen/CGCXX.cpp4
-rw-r--r--lib/CodeGen/CGCXXABI.cpp4
-rw-r--r--lib/CodeGen/CGCall.cpp20
-rw-r--r--lib/CodeGen/CGCall.h4
-rw-r--r--lib/CodeGen/CGClass.cpp52
-rw-r--r--lib/CodeGen/CGCleanup.cpp18
-rw-r--r--lib/CodeGen/CGCleanup.h2
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp84
-rw-r--r--lib/CodeGen/CGDeclCXX.cpp14
-rw-r--r--lib/CodeGen/CGException.cpp8
-rw-r--r--lib/CodeGen/CGExpr.cpp10
-rw-r--r--lib/CodeGen/CGExprAgg.cpp54
-rw-r--r--lib/CodeGen/CGExprCXX.cpp84
-rw-r--r--lib/CodeGen/CGExprConstant.cpp37
-rw-r--r--lib/CodeGen/CGExprScalar.cpp107
-rw-r--r--lib/CodeGen/CGLoopInfo.cpp2
-rw-r--r--lib/CodeGen/CGObjC.cpp162
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp48
-rw-r--r--lib/CodeGen/CGObjCMac.cpp228
-rw-r--r--lib/CodeGen/CGObjCRuntime.cpp4
-rw-r--r--lib/CodeGen/CGObjCRuntime.h12
-rw-r--r--lib/CodeGen/CGOpenMPRuntime.cpp19
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.cpp23
-rw-r--r--lib/CodeGen/CGVTT.cpp30
-rw-r--r--lib/CodeGen/CGVTables.cpp2
-rw-r--r--lib/CodeGen/CGVTables.h14
-rw-r--r--lib/CodeGen/CGValue.h33
-rw-r--r--lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.h9
-rw-r--r--lib/CodeGen/CodeGenModule.cpp6
-rw-r--r--lib/CodeGen/CodeGenModule.h28
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp50
-rw-r--r--lib/CodeGen/CodeGenTypes.h14
-rw-r--r--lib/CodeGen/ConstantInitBuilder.cpp2
-rw-r--r--lib/CodeGen/ItaniumCXXABI.cpp18
-rw-r--r--lib/CodeGen/MicrosoftCXXABI.cpp14
-rw-r--r--lib/CodeGen/SwiftCallingConv.cpp4
-rw-r--r--lib/CodeGen/TargetInfo.cpp53
-rw-r--r--lib/Driver/CMakeLists.txt1
-rw-r--r--lib/Driver/Driver.cpp5
-rw-r--r--lib/Driver/SanitizerArgs.cpp12
-rw-r--r--lib/Driver/ToolChain.cpp6
-rw-r--r--lib/Driver/ToolChains/Arch/RISCV.cpp2
-rw-r--r--lib/Driver/ToolChains/Clang.cpp211
-rw-r--r--lib/Driver/ToolChains/Cuda.cpp12
-rw-r--r--lib/Driver/ToolChains/Cuda.h1
-rw-r--r--lib/Driver/ToolChains/Darwin.cpp73
-rw-r--r--lib/Driver/ToolChains/Darwin.h15
-rw-r--r--lib/Driver/ToolChains/Gnu.cpp6
-rw-r--r--lib/Driver/ToolChains/Linux.cpp9
-rw-r--r--lib/Driver/ToolChains/RISCV.cpp117
-rw-r--r--lib/Driver/ToolChains/RISCV.h57
-rw-r--r--lib/Edit/Commit.cpp4
-rw-r--r--lib/Edit/RewriteObjCFoundationAPI.cpp18
-rw-r--r--lib/Format/BreakableToken.cpp52
-rw-r--r--lib/Format/BreakableToken.h27
-rw-r--r--lib/Format/ContinuationIndenter.cpp25
-rw-r--r--lib/Format/ContinuationIndenter.h2
-rw-r--r--lib/Format/Format.cpp9
-rw-r--r--lib/Frontend/ASTConsumers.cpp2
-rw-r--r--lib/Frontend/ASTMerge.cpp10
-rw-r--r--lib/Frontend/ChainedIncludesSource.cpp6
-rw-r--r--lib/Frontend/CompilerInstance.cpp38
-rw-r--r--lib/Frontend/DependencyFile.cpp2
-rw-r--r--lib/Frontend/DependencyGraph.cpp20
-rw-r--r--lib/Frontend/DiagnosticRenderer.cpp6
-rw-r--r--lib/Frontend/FrontendAction.cpp8
-rw-r--r--lib/Frontend/FrontendActions.cpp10
-rw-r--r--lib/Frontend/LayoutOverrideSource.cpp58
-rw-r--r--lib/Frontend/MultiplexConsumer.cpp6
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp12
-rw-r--r--lib/Frontend/Rewrite/FixItRewriter.cpp2
-rw-r--r--lib/Frontend/Rewrite/FrontendActions.cpp4
-rw-r--r--lib/Frontend/Rewrite/RewriteModernObjC.cpp964
-rw-r--r--lib/Frontend/Rewrite/RewriteObjC.cpp388
-rw-r--r--lib/Frontend/SerializedDiagnosticPrinter.cpp46
-rw-r--r--lib/Frontend/TestModuleFileExtension.cpp2
-rw-r--r--lib/Frontend/TextDiagnostic.cpp28
-rw-r--r--lib/FrontendTool/ExecuteCompilerInvocation.cpp4
-rw-r--r--lib/Headers/avx512fintrin.h4
-rw-r--r--lib/Headers/avx512vlcdintrin.h2
-rw-r--r--lib/Headers/clzerointrin.h2
-rw-r--r--lib/Headers/lwpintrin.h4
-rw-r--r--lib/Headers/opencl-c.h8
-rw-r--r--lib/Index/IndexBody.cpp4
-rw-r--r--lib/Index/IndexTypeSourceInfo.cpp4
-rw-r--r--lib/Index/IndexingContext.cpp2
-rw-r--r--lib/Index/USRGeneration.cpp40
-rw-r--r--lib/Lex/HeaderSearch.cpp32
-rw-r--r--lib/Lex/LiteralSupport.cpp6
-rw-r--r--lib/Lex/MacroArgs.cpp14
-rw-r--r--lib/Lex/ModuleMap.cpp178
-rw-r--r--lib/Lex/PPDirectives.cpp6
-rw-r--r--lib/Lex/PPExpressions.cpp10
-rw-r--r--lib/Lex/PPLexerChange.cpp14
-rw-r--r--lib/Lex/PPMacroExpansion.cpp6
-rw-r--r--lib/Lex/Pragma.cpp26
-rw-r--r--lib/Lex/PreprocessingRecord.cpp46
-rw-r--r--lib/Lex/Preprocessor.cpp24
-rw-r--r--lib/Lex/TokenLexer.cpp20
-rw-r--r--lib/Parse/ParseAST.cpp4
-rw-r--r--lib/Parse/ParseCXXInlineMethods.cpp8
-rw-r--r--lib/Parse/ParseDecl.cpp32
-rw-r--r--lib/Parse/ParseDeclCXX.cpp64
-rw-r--r--lib/Parse/ParseExpr.cpp148
-rw-r--r--lib/Parse/ParseExprCXX.cpp190
-rw-r--r--lib/Parse/ParseInit.cpp50
-rw-r--r--lib/Parse/ParseObjc.cpp224
-rw-r--r--lib/Parse/ParsePragma.cpp30
-rw-r--r--lib/Parse/ParseStmtAsm.cpp2
-rw-r--r--lib/Parse/ParseTemplate.cpp74
-rw-r--r--lib/Parse/ParseTentative.cpp38
-rw-r--r--lib/Parse/Parser.cpp68
-rw-r--r--lib/Rewrite/DeltaTree.cpp4
-rw-r--r--lib/Rewrite/HTMLRewrite.cpp2
-rw-r--r--lib/Rewrite/Rewriter.cpp6
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp52
-rw-r--r--lib/Sema/CMakeLists.txt1
-rw-r--r--lib/Sema/CodeCompleteConsumer.cpp110
-rw-r--r--lib/Sema/DeclSpec.cpp50
-rw-r--r--lib/Sema/DelayedDiagnostic.cpp4
-rw-r--r--lib/Sema/IdentifierResolver.cpp54
-rw-r--r--lib/Sema/MultiplexExternalSemaSource.cpp14
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--lib/Sema/SemaAccess.cpp36
-rw-r--r--lib/Sema/SemaAttr.cpp4
-rw-r--r--lib/Sema/SemaCXXScopeSpec.cpp34
-rw-r--r--lib/Sema/SemaCast.cpp120
-rw-r--r--lib/Sema/SemaChecking.cpp174
-rw-r--r--lib/Sema/SemaCodeComplete.cpp30
-rw-r--r--lib/Sema/SemaDecl.cpp136
-rw-r--r--lib/Sema/SemaDeclAttr.cpp77
-rw-r--r--lib/Sema/SemaDeclObjC.cpp382
-rw-r--r--lib/Sema/SemaExceptionSpec.cpp2
-rw-r--r--lib/Sema/SemaExpr.cpp446
-rw-r--r--lib/Sema/SemaExprMember.cpp36
-rw-r--r--lib/Sema/SemaExprObjC.cpp380
-rw-r--r--lib/Sema/SemaInit.cpp296
-rw-r--r--lib/Sema/SemaLambda.cpp198
-rw-r--r--lib/Sema/SemaLookup.cpp26
-rw-r--r--lib/Sema/SemaObjCProperty.cpp138
-rw-r--r--lib/Sema/SemaPseudoObject.cpp134
-rw-r--r--lib/Sema/SemaStmt.cpp12
-rw-r--r--lib/Sema/SemaStmtAsm.cpp2
-rw-r--r--lib/Sema/SemaTemplate.cpp68
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp2
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp292
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp16
-rw-r--r--lib/Sema/SemaTemplateVariadic.cpp114
-rw-r--r--lib/Sema/SemaType.cpp65
-rw-r--r--lib/Sema/TreeTransform.h10
-rw-r--r--lib/Sema/TypeLocBuilder.h12
-rw-r--r--lib/Serialization/ASTReader.cpp13
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp68
-rw-r--r--lib/Serialization/ASTReaderInternals.h54
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp52
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp24
-rw-r--r--lib/Serialization/Module.cpp24
-rw-r--r--lib/Serialization/ModuleManager.cpp10
-rw-r--r--lib/StaticAnalyzer/Checkers/CStringChecker.cpp1
-rw-r--r--lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp188
-rw-r--r--lib/StaticAnalyzer/Checkers/IteratorChecker.cpp25
-rw-r--r--lib/StaticAnalyzer/Checkers/MallocChecker.cpp43
-rw-r--r--lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp2
-rw-r--r--lib/StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp18
-rw-r--r--lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp10
-rw-r--r--lib/StaticAnalyzer/Core/BugReporterVisitors.cpp37
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp63
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngine.cpp150
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineC.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineCXX.cpp43
-rw-r--r--lib/StaticAnalyzer/Core/IssueHash.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/ProgramState.cpp5
-rw-r--r--lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp46
-rw-r--r--lib/StaticAnalyzer/Core/Store.cpp4
268 files changed, 7893 insertions, 6757 deletions
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp
index 74c9974cc810..3c7b593be6d4 100644
--- a/lib/ARCMigrate/ARCMT.cpp
+++ b/lib/ARCMigrate/ARCMT.cpp
@@ -226,7 +226,7 @@ static void emitPremigrationErrors(const CapturedDiagList &arcDiags,
new DiagnosticsEngine(DiagID, diagOpts, &printer,
/*ShouldOwnClient=*/false));
Diags->setSourceManager(&PP.getSourceManager());
-
+
printer.BeginSourceFile(PP.getLangOpts(), &PP);
arcDiags.reportDiagnostics(*Diags);
printer.EndSourceFile();
@@ -305,7 +305,7 @@ bool arcmt::checkForManualIssues(
// After parsing of source files ended, we want to reuse the
// diagnostics objects to emit further diagnostics.
- // We call BeginSourceFile because DiagnosticConsumer requires that
+ // We call BeginSourceFile because DiagnosticConsumer requires that
// diagnostics with source range information are emitted only in between
// BeginSourceFile() and EndSourceFile().
DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
@@ -572,7 +572,7 @@ bool MigrationProcess::applyTransform(TransformFn trans,
// After parsing of source files ended, we want to reuse the
// diagnostics objects to emit further diagnostics.
- // We call BeginSourceFile because DiagnosticConsumer requires that
+ // We call BeginSourceFile because DiagnosticConsumer requires that
// diagnostics with source range information are emitted only in between
// BeginSourceFile() and EndSourceFile().
DiagClient->BeginSourceFile(Ctx.getLangOpts(), &Unit->getPreprocessor());
diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp
index 4dedac88f982..ccc8c9ee30ff 100644
--- a/lib/ARCMigrate/FileRemapper.cpp
+++ b/lib/ARCMigrate/FileRemapper.cpp
@@ -67,7 +67,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
llvm::MemoryBuffer::getFile(infoFile);
if (!fileBuf)
return report("Error opening file: " + infoFile, Diag);
-
+
SmallVector<StringRef, 64> lines;
fileBuf.get()->getBuffer().split(lines, "\n");
@@ -78,7 +78,7 @@ bool FileRemapper::initFromFile(StringRef filePath, DiagnosticsEngine &Diag,
return report("Invalid file data: '" + lines[idx+1] + "' not a number",
Diag);
StringRef toFilename = lines[idx+2];
-
+
const FileEntry *origFE = FileMgr->getFile(fromFilename);
if (!origFE) {
if (ignoreIfFilesChanged)
@@ -152,7 +152,7 @@ bool FileRemapper::flushToFile(StringRef outputPath, DiagnosticsEngine &Diag) {
llvm::MemoryBuffer *mem = I->second.get<llvm::MemoryBuffer *>();
newOut.write(mem->getBufferStart(), mem->getBufferSize());
newOut.close();
-
+
const FileEntry *newE = FileMgr->getFile(tempPath);
remap(origFE, newE);
infoOut << newE->getName() << '\n';
diff --git a/lib/ARCMigrate/Internals.h b/lib/ARCMigrate/Internals.h
index 4f153b1ad2f4..1a261c1e31aa 100644
--- a/lib/ARCMigrate/Internals.h
+++ b/lib/ARCMigrate/Internals.h
@@ -25,7 +25,7 @@ namespace arcmt {
class CapturedDiagList {
typedef std::list<StoredDiagnostic> ListTy;
ListTy List;
-
+
public:
void push_back(const StoredDiagnostic &diag) { List.push_back(diag); }
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index 433e6194a2c2..7e9bc6a5bdc6 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -46,7 +46,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
CF_BRIDGING_ENABLE,
CF_BRIDGING_MAY_INCLUDE
};
-
+
void migrateDecl(Decl *D);
void migrateObjCContainerDecl(ASTContext &Ctx, ObjCContainerDecl *D);
void migrateProtocolConformance(ASTContext &Ctx,
@@ -63,26 +63,26 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM,
ObjCInstanceTypeFamily OIT_Family = OIT_None);
-
+
void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl);
void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
const FunctionDecl *FuncDecl, bool ResultAnnotated);
void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
const ObjCMethodDecl *MethodDecl, bool ResultAnnotated);
-
+
void AnnotateImplicitBridging(ASTContext &Ctx);
-
+
CF_BRIDGING_KIND migrateAddFunctionAnnotation(ASTContext &Ctx,
const FunctionDecl *FuncDecl);
-
+
void migrateARCSafeAnnotation(ASTContext &Ctx, ObjCContainerDecl *CDecl);
-
+
void migrateAddMethodAnnotation(ASTContext &Ctx,
const ObjCMethodDecl *MethodDecl);
void inferDesignatedInitializers(ASTContext &Ctx,
const ObjCImplementationDecl *ImplD);
-
+
bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc);
public:
@@ -225,7 +225,7 @@ namespace {
isa<ObjCIvarRefExpr>(Expr) || isa<ParenExpr>(FullExpr) ||
isa<ParenListExpr>(Expr) || isa<SizeOfPackExpr>(Expr));
}
-
+
/// - Rewrite message expression for Objective-C setter and getters into
/// property-dot syntax.
bool rewriteToPropertyDotSyntax(const ObjCMessageExpr *Msg,
@@ -239,17 +239,17 @@ namespace {
if (const Expr *Receiver = Msg->getInstanceReceiver())
if (Receiver->getType()->isObjCBuiltinType())
return false;
-
+
const ObjCMethodDecl *Method = Msg->getMethodDecl();
if (!Method)
return false;
if (!Method->isPropertyAccessor())
return false;
-
+
const ObjCPropertyDecl *Prop = Method->findPropertyDecl();
if (!Prop)
return false;
-
+
SourceRange MsgRange = Msg->getSourceRange();
bool ReceiverIsSuper =
(Msg->getReceiverKind() == ObjCMessageExpr::SuperInstance);
@@ -276,7 +276,7 @@ namespace {
PropertyDotString = ".";
PropertyDotString += Prop->getName();
commit.replace(SpaceRange, PropertyDotString);
-
+
// remove '[' ']'
commit.replace(SourceRange(MsgRange.getBegin(), MsgRange.getBegin()), "");
commit.replace(SourceRange(MsgRange.getEnd(), MsgRange.getEnd()), "");
@@ -465,7 +465,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
PropertyString += "(nonatomic";
LParenAdded = true;
}
-
+
std::string PropertyNameString = Getter->getNameAsString();
StringRef PropertyName(PropertyNameString);
if (LengthOfPrefix > 0) {
@@ -480,8 +480,8 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
// Property with no setter may be suggested as a 'readonly' property.
if (!Setter)
append_attr(PropertyString, "readonly", LParenAdded);
-
-
+
+
// Short circuit 'delegate' properties that contain the name "delegate" or
// "dataSource", or have exact name "target" to have 'assign' attribute.
if (PropertyName.equals("target") ||
@@ -542,7 +542,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
}
SourceLocation StartGetterSelectorLoc = Getter->getSelectorStartLoc();
Selector GetterSelector = Getter->getSelector();
-
+
SourceLocation EndGetterSelectorLoc =
StartGetterSelectorLoc.getLocWithOffset(GetterSelector.getNameForSlot(0).size());
commit.replace(CharSourceRange::getCharRange(Getter->getLocStart(),
@@ -572,7 +572,7 @@ void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx,
ObjCContainerDecl *D) {
if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D))
return;
-
+
for (auto *Method : D->methods()) {
if (Method->isDeprecated())
continue;
@@ -587,7 +587,7 @@ void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx,
}
if (!(ASTMigrateActions & FrontendOptions::ObjCMT_ReturnsInnerPointerProperty))
return;
-
+
for (auto *Prop : D->instance_properties()) {
if ((ASTMigrateActions & FrontendOptions::ObjCMT_Annotation) &&
!Prop->isDeprecated())
@@ -628,7 +628,7 @@ ClassImplementsAllMethodsAndProperties(ASTContext &Ctx,
else
return false;
}
-
+
// At this point, all required properties in this protocol conform to those
// declared in the class.
// Check that class implements the required methods of the protocol too.
@@ -666,7 +666,7 @@ static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
std::string ClassString;
SourceLocation EndLoc =
IDecl->getSuperClass() ? IDecl->getSuperClassLoc() : IDecl->getLocation();
-
+
if (Protocols.empty()) {
ClassString = '<';
for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
@@ -686,7 +686,7 @@ static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
ObjCInterfaceDecl::protocol_loc_iterator PL = IDecl->protocol_loc_end() - 1;
EndLoc = *PL;
}
-
+
commit.insertAfterToken(EndLoc, ClassString);
return true;
}
@@ -717,7 +717,7 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
ClassString += NSIntegerName;
}
ClassString += ", ";
-
+
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
@@ -731,7 +731,7 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
}
else
return false;
-
+
SourceLocation EndTypedefDclLoc = TypedefDcl->getLocEnd();
EndTypedefDclLoc = trans::findSemiAfterLocation(EndTypedefDclLoc,
NS.getASTContext(), /*IsDecl*/true);
@@ -763,13 +763,13 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx,
QualType DesignatedEnumType = EnumDcl->getIntegerType();
assert(!DesignatedEnumType.isNull()
&& "rewriteToNSMacroDecl - underlying enum type is null");
-
+
PrintingPolicy Policy(Ctx.getPrintingPolicy());
std::string TypeString = DesignatedEnumType.getAsString(Policy);
std::string ClassString = IsNSIntegerType ? "NS_ENUM(" : "NS_OPTIONS(";
ClassString += TypeString;
ClassString += ", ";
-
+
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ") ";
SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
@@ -781,7 +781,7 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx,
SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1);
SourceLocation EndTypedefLoc = TypedefDcl->getLocEnd();
-
+
commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc));
}
@@ -801,7 +801,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(InitExpr))
if (BO->isShiftOp() || BO->isBitwiseOp())
return true;
-
+
uint64_t EnumVal = Enumerator->getInitVal().getZExtValue();
if (PowerOfTwo && EnumVal) {
if (!llvm::isPowerOf2_64(EnumVal))
@@ -826,7 +826,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
return AllHexdecimalEnumerator || (PowerOfTwo && (MaxPowerOfTwoVal > 2));
}
-void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
+void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl) {
const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface();
if (!IDecl || ObjCProtocolDecls.empty() || IDecl->isDeprecated())
@@ -836,11 +836,11 @@ void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
llvm::SmallPtrSet<ObjCProtocolDecl *, 8> ExplicitProtocols;
Ctx.CollectInheritedProtocols(IDecl, ExplicitProtocols);
llvm::SmallVector<ObjCProtocolDecl *, 8> PotentialImplicitProtocols;
-
+
for (ObjCProtocolDecl *ProtDecl : ObjCProtocolDecls)
if (!ExplicitProtocols.count(ProtDecl))
PotentialImplicitProtocols.push_back(ProtDecl);
-
+
if (PotentialImplicitProtocols.empty())
return;
@@ -852,10 +852,10 @@ void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
if (ClassImplementsAllMethodsAndProperties(Ctx, ImpDecl, IDecl,
PotentialImplicitProtocols[i]))
ConformingProtocols.push_back(PotentialImplicitProtocols[i]);
-
+
if (ConformingProtocols.empty())
return;
-
+
// Further reduce number of conforming protocols. If protocol P1 is in the list
// protocol P2 (P2<P1>), No need to include P1.
llvm::SmallVector<ObjCProtocolDecl*, 8> MinimalConformingProtocols;
@@ -885,7 +885,7 @@ void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
void ObjCMigrateASTConsumer::CacheObjCNSIntegerTypedefed(
const TypedefDecl *TypedefDcl) {
-
+
QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
if (NSAPIObj->isObjCNSIntegerType(qt))
NSIntegerTypedefed = TypedefDcl;
@@ -919,10 +919,10 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
}
if (TypedefDcl->isDeprecated())
return false;
-
+
QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
StringRef NSIntegerName = NSAPIObj->GetNSIntegralKind(qt);
-
+
if (NSIntegerName.empty()) {
// Also check for typedef enum {...} TD;
if (const EnumType *EnumTy = qt->getAs<EnumType>()) {
@@ -938,7 +938,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
}
return false;
}
-
+
// We may still use NS_OPTIONS based on what we find in the enumertor list.
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
if (!InsertFoundation(Ctx, TypedefDcl->getLocStart()))
@@ -1000,7 +1000,7 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
ObjCMethodDecl *OM) {
ObjCInstanceTypeFamily OIT_Family =
Selector::getInstTypeMethodFamily(OM->getSelector());
-
+
std::string ClassName;
switch (OIT_Family) {
case OIT_None:
@@ -1025,7 +1025,7 @@ void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
}
if (!OM->getReturnType()->isObjCIdType())
return;
-
+
ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl);
if (!IDecl) {
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl))
@@ -1080,7 +1080,7 @@ static bool AvailabilityAttrsMatch(Attr *At1, Attr *At2) {
if (!AA1)
return true;
const AvailabilityAttr *AA2 = dyn_cast<AvailabilityAttr>(At2);
-
+
VersionTuple Introduced1 = AA1->getIntroduced();
VersionTuple Deprecated1 = AA1->getDeprecated();
VersionTuple Obsoleted1 = AA1->getObsoleted();
@@ -1159,14 +1159,14 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
QualType GRT = Method->getReturnType();
if (GRT->isVoidType())
return false;
-
+
Selector GetterSelector = Method->getSelector();
ObjCInstanceTypeFamily OIT_Family =
Selector::getInstTypeMethodFamily(GetterSelector);
-
+
if (OIT_Family != OIT_None)
return false;
-
+
IdentifierInfo *getterName = GetterSelector.getIdentifierInfoForSlot(0);
Selector SetterSelector =
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
@@ -1199,7 +1199,7 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
}
}
}
-
+
if (SetterMethod) {
if ((ASTMigrateActions & FrontendOptions::ObjCMT_ReadwriteProperty) == 0)
return false;
@@ -1207,7 +1207,7 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
if (SetterMethod->isDeprecated() ||
!AttributesMatch(Method, SetterMethod, AvailabilityArgsMatch))
return false;
-
+
// Is this a valid setter, matching the target getter?
QualType SRT = SetterMethod->getReturnType();
if (!SRT->isVoidType())
@@ -1255,7 +1255,7 @@ void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx,
if (!TypeIsInnerPointer(RT) ||
!NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))
return;
-
+
edit::Commit commit(*Editor);
commit.insertBefore(OM->getLocEnd(), " NS_RETURNS_INNER_POINTER");
Editor->commit(commit);
@@ -1277,7 +1277,7 @@ void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx,
ObjCContainerDecl *CDecl) {
if (CDecl->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(CDecl))
return;
-
+
// migrate methods which can have instancetype as their result type.
for (auto *Method : CDecl->methods()) {
if (Method->isDeprecated())
@@ -1294,7 +1294,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
OM->getReturnType() == Ctx.getObjCInstanceType() ||
!OM->getReturnType()->isObjCIdType())
return;
-
+
// Candidate factory methods are + (id) NaMeXXX : ... which belong to a class
// NSYYYNamE with matching names be at least 3 characters long.
ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl);
@@ -1306,17 +1306,17 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
}
if (!IDecl)
return;
-
+
std::string StringClassName = IDecl->getName();
StringRef LoweredClassName(StringClassName);
std::string StringLoweredClassName = LoweredClassName.lower();
LoweredClassName = StringLoweredClassName;
-
+
IdentifierInfo *MethodIdName = OM->getSelector().getIdentifierInfoForSlot(0);
// Handle method with no name at its first selector slot; e.g. + (id):(int)x.
if (!MethodIdName)
return;
-
+
std::string MethodName = MethodIdName->getName();
if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) {
StringRef STRefMethodName(MethodName);
@@ -1353,10 +1353,10 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
static bool IsVoidStarType(QualType Ty) {
if (!Ty->isPointerType())
return false;
-
+
while (const TypedefType *TD = dyn_cast<TypedefType>(Ty.getTypePtr()))
Ty = TD->getDecl()->getUnderlyingType();
-
+
// Is the type void*?
const PointerType* PT = Ty->getAs<PointerType>();
if (PT->getPointeeType().getUnqualifiedType()->isVoidType())
@@ -1418,14 +1418,14 @@ void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {
void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl) {
if (Decl->isDeprecated())
return;
-
+
if (Decl->hasAttr<CFAuditedTransferAttr>()) {
assert(CFFunctionIBCandidates.empty() &&
"Cannot have audited functions/methods inside user "
"provided CF_IMPLICIT_BRIDGING_ENABLE");
return;
}
-
+
// Finction must be annotated first.
if (const FunctionDecl *FuncDecl = dyn_cast<FunctionDecl>(Decl)) {
CF_BRIDGING_KIND AuditKind = migrateAddFunctionAnnotation(Ctx, FuncDecl);
@@ -1469,7 +1469,7 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))
AnnotationString = " NS_RETURNS_RETAINED";
}
-
+
if (AnnotationString) {
edit::Commit commit(*Editor);
commit.insertAfterToken(FuncDecl->getLocEnd(), AnnotationString);
@@ -1503,18 +1503,18 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
const FunctionDecl *FuncDecl) {
if (FuncDecl->hasBody())
return CF_BRIDGING_NONE;
-
+
CallEffects CE = CallEffects::getEffect(FuncDecl);
bool FuncIsReturnAnnotated = (FuncDecl->hasAttr<CFReturnsRetainedAttr>() ||
FuncDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
FuncDecl->hasAttr<NSReturnsRetainedAttr>() ||
FuncDecl->hasAttr<NSReturnsNotRetainedAttr>() ||
FuncDecl->hasAttr<NSReturnsAutoreleasedAttr>());
-
+
// Trivial case of when function is annotated and has no argument.
if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0)
return CF_BRIDGING_NONE;
-
+
bool ReturnCFAudited = false;
if (!FuncIsReturnAnnotated) {
RetEffect Ret = CE.getReturnValue();
@@ -1524,7 +1524,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
else if (!AuditedType(FuncDecl->getReturnType()))
return CF_BRIDGING_NONE;
}
-
+
// At this point result type is audited for potential inclusion.
// Now, how about argument types.
ArrayRef<ArgEffect> AEArgs = CE.getArgs();
@@ -1550,7 +1550,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
}
if (ReturnCFAudited || ArgCFAudited)
return CF_BRIDGING_ENABLE;
-
+
return CF_BRIDGING_MAY_INCLUDE;
}
@@ -1558,7 +1558,7 @@ void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx,
ObjCContainerDecl *CDecl) {
if (!isa<ObjCInterfaceDecl>(CDecl) || CDecl->isDeprecated())
return;
-
+
// migrate methods which can have instancetype as their result type.
for (const auto *Method : CDecl->methods())
migrateCFAnnotation(Ctx, Method);
@@ -1588,14 +1588,14 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
case clang::OMF_init:
case clang::OMF_mutableCopy:
break;
-
+
default:
if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))
AnnotationString = " NS_RETURNS_RETAINED";
break;
}
}
-
+
if (AnnotationString) {
edit::Commit commit(*Editor);
commit.insertBefore(MethodDecl->getLocEnd(), AnnotationString);
@@ -1622,7 +1622,7 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
const ObjCMethodDecl *MethodDecl) {
if (MethodDecl->hasBody() || MethodDecl->isImplicit())
return;
-
+
CallEffects CE = CallEffects::getEffect(MethodDecl);
bool MethodIsReturnAnnotated = (MethodDecl->hasAttr<CFReturnsRetainedAttr>() ||
MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
@@ -1639,12 +1639,12 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
commit.insertBefore(MethodDecl->getLocEnd(), " NS_CONSUMES_SELF");
Editor->commit(commit);
}
-
+
// Trivial case of when function is annotated and has no argument.
if (MethodIsReturnAnnotated &&
(MethodDecl->param_begin() == MethodDecl->param_end()))
return;
-
+
if (!MethodIsReturnAnnotated) {
RetEffect Ret = CE.getReturnValue();
if ((Ret.getObjKind() == RetEffect::CF ||
@@ -1655,7 +1655,7 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
} else if (!AuditedType(MethodDecl->getReturnType()))
return;
}
-
+
// At this point result type is either annotated or audited.
// Now, how about argument types.
ArrayRef<ArgEffect> AEArgs = CE.getArgs();
@@ -1811,7 +1811,7 @@ private:
OS.write_escaped(Text) << "\",\n";
}
};
-
+
void insert(SourceLocation Loc, StringRef Text) override {
EntryWriter Writer(SourceMgr, OS);
Writer.writeLoc(Loc);
@@ -1835,7 +1835,7 @@ private:
} // end anonymous namespace
void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
-
+
TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
if (ASTMigrateActions & FrontendOptions::ObjCMT_MigrateDecls) {
for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end();
@@ -1846,7 +1846,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
AnnotateImplicitBridging(Ctx);
}
-
+
if (ObjCInterfaceDecl *CDecl = dyn_cast<ObjCInterfaceDecl>(*D))
if (canModify(CDecl))
migrateObjCContainerDecl(Ctx, CDecl);
@@ -1911,7 +1911,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
canModify(FD))
migrateCFAnnotation(Ctx, FD);
}
-
+
if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(*D)) {
bool CanModify = canModify(CDecl);
// migrate methods which can have instancetype as their result type.
@@ -1934,7 +1934,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
AnnotateImplicitBridging(Ctx);
}
-
+
if (IsOutputFile) {
std::error_code EC;
llvm::raw_fd_ostream OS(MigrateDir, EC, llvm::sys::fs::F_None);
diff --git a/lib/ARCMigrate/PlistReporter.cpp b/lib/ARCMigrate/PlistReporter.cpp
index 2ad1c8591a9e..9e4cb3f4cd83 100644
--- a/lib/ARCMigrate/PlistReporter.cpp
+++ b/lib/ARCMigrate/PlistReporter.cpp
@@ -81,7 +81,7 @@ void arcmt::writeARCDiagsToPlist(const std::string &outPath,
for (ArrayRef<StoredDiagnostic>::iterator
DI = diags.begin(), DE = diags.end(); DI != DE; ++DI) {
-
+
const StoredDiagnostic &D = *DI;
if (D.getLevel() == DiagnosticsEngine::Ignored)
diff --git a/lib/ARCMigrate/TransARCAssign.cpp b/lib/ARCMigrate/TransARCAssign.cpp
index 80bfd22d6258..d2b4de4891c3 100644
--- a/lib/ARCMigrate/TransARCAssign.cpp
+++ b/lib/ARCMigrate/TransARCAssign.cpp
@@ -65,7 +65,7 @@ public:
}
}
}
-
+
return true;
}
};
diff --git a/lib/ARCMigrate/TransAutoreleasePool.cpp b/lib/ARCMigrate/TransAutoreleasePool.cpp
index a8a99fa712a3..2d35655d186f 100644
--- a/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ b/lib/ARCMigrate/TransAutoreleasePool.cpp
@@ -80,7 +80,7 @@ public:
Body = body;
TraverseStmt(body);
}
-
+
~AutoreleasePoolRewriter() {
SmallVector<VarDecl *, 8> VarsToHandle;
@@ -174,7 +174,7 @@ public:
PoolVarInfo &info = PoolVars[VD];
info.Dcl = DclS;
collectRefs(VD, S, info.Refs);
- // Does this statement follow the pattern:
+ // Does this statement follow the pattern:
// NSAutoreleasePool * pool = [NSAutoreleasePool new];
if (isPoolCreation(VD->getInit())) {
Scopes.push_back(PoolScope());
@@ -188,7 +188,7 @@ public:
} else if (BinaryOperator *bop = dyn_cast<BinaryOperator>(child)) {
if (DeclRefExpr *dref = dyn_cast<DeclRefExpr>(bop->getLHS())) {
if (VarDecl *VD = dyn_cast<VarDecl>(dref->getDecl())) {
- // Does this statement follow the pattern:
+ // Does this statement follow the pattern:
// pool = [NSAutoreleasePool new];
if (isNSAutoreleasePool(VD->getType()) &&
isPoolCreation(bop->getRHS())) {
@@ -311,7 +311,7 @@ private:
scope.IsFollowedBySimpleReturnStmt = true;
++SI; // the return will be included in scope, don't check it.
}
-
+
for (; SI != SE; ++SI) {
nameUsedOutsideScope = !NameReferenceChecker(Pass.Ctx, scope,
referenceLoc,
@@ -415,7 +415,7 @@ private:
IdentifierInfo *PoolII;
Selector DrainSel;
-
+
struct PoolVarInfo {
DeclStmt *Dcl;
ExprSet Refs;
diff --git a/lib/ARCMigrate/TransBlockObjCVariable.cpp b/lib/ARCMigrate/TransBlockObjCVariable.cpp
index fac6a84c45e5..85bdabb50461 100644
--- a/lib/ARCMigrate/TransBlockObjCVariable.cpp
+++ b/lib/ARCMigrate/TransBlockObjCVariable.cpp
@@ -43,11 +43,11 @@ class RootBlockObjCVarRewriter :
class BlockVarChecker : public RecursiveASTVisitor<BlockVarChecker> {
VarDecl *Var;
-
+
typedef RecursiveASTVisitor<BlockVarChecker> base;
public:
BlockVarChecker(VarDecl *var) : Var(var) { }
-
+
bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) {
if (DeclRefExpr *
ref = dyn_cast<DeclRefExpr>(castE->getSubExpr())) {
@@ -77,7 +77,7 @@ public:
bool VisitBlockDecl(BlockDecl *block) {
SmallVector<VarDecl *, 4> BlockVars;
-
+
for (const auto &I : block->captures()) {
VarDecl *var = I.getVariable();
if (I.isByRef() &&
diff --git a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
index cbc22ed60172..0327b0def1e6 100644
--- a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
+++ b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
@@ -208,7 +208,7 @@ static void cleanupDeallocOrFinalize(MigrationPass &pass) {
for (auto *MD : I->instance_methods()) {
if (!MD->hasBody())
continue;
-
+
if (MD->getMethodFamily() == OMF_dealloc) {
DeallocM = MD;
} else if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp
index 4fd21aa6c269..fb45cd92c1f6 100644
--- a/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/lib/ARCMigrate/TransGCAttrs.cpp
@@ -48,7 +48,7 @@ public:
return true;
SaveAndRestore<bool> Save(FullyMigratable, isMigratable(D));
-
+
if (ObjCPropertyDecl *PropD = dyn_cast<ObjCPropertyDecl>(D)) {
lookForAttribute(PropD, PropD->getTypeSourceInfo());
AllProps.push_back(PropD);
@@ -107,7 +107,7 @@ public:
Kind = MigrationContext::GCAttrOccurrence::Weak;
else
return false;
-
+
MigrateCtx.AttrSet.insert(RawLoc);
MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence());
MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back();
@@ -164,7 +164,7 @@ public:
for (auto I : D->redecls())
if (!isInMainFile(I->getLocation()))
return false;
-
+
return true;
}
diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp
index 1468c21a0093..912f77aeb789 100644
--- a/lib/ARCMigrate/TransProperties.cpp
+++ b/lib/ARCMigrate/TransProperties.cpp
@@ -47,7 +47,7 @@ class PropertiesRewriter {
MigrationContext &MigrateCtx;
MigrationPass &Pass;
ObjCImplementationDecl *CurImplD;
-
+
enum PropActionKind {
PropAction_None,
PropAction_RetainReplacedWithStrong,
@@ -118,7 +118,7 @@ public:
AtPropDeclsTy::iterator findAtLoc = AtProps.find(rawAtLoc);
if (findAtLoc == AtProps.end())
continue;
-
+
PropsTy &props = findAtLoc->second;
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I) {
if (I->PropD == propD) {
@@ -137,7 +137,7 @@ public:
continue;
if (hasIvarWithExplicitARCOwnership(props))
continue;
-
+
Transaction Trans(Pass.TA);
rewriteProperty(props, atLoc);
}
@@ -170,7 +170,7 @@ private:
void rewriteProperty(PropsTy &props, SourceLocation atLoc) {
ObjCPropertyDecl::PropertyAttributeKind propAttrs = getPropertyAttrs(props);
-
+
if (propAttrs & (ObjCPropertyDecl::OBJC_PR_copy |
ObjCPropertyDecl::OBJC_PR_unsafe_unretained |
ObjCPropertyDecl::OBJC_PR_strong |
@@ -215,7 +215,7 @@ private:
void rewriteAssign(PropsTy &props, SourceLocation atLoc) const {
bool canUseWeak = canApplyWeak(Pass.Ctx, getPropertyType(props),
/*AllowOnUnknownClass=*/Pass.isGCMigration());
- const char *toWhich =
+ const char *toWhich =
(Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "strong" :
(canUseWeak ? "weak" : "unsafe_unretained");
@@ -227,7 +227,7 @@ private:
if (isUserDeclared(I->IvarD)) {
if (I->IvarD &&
I->IvarD->getType().getObjCLifetime() != Qualifiers::OCL_Weak) {
- const char *toWhich =
+ const char *toWhich =
(Pass.isGCMigration() && !hasGCWeak(props, atLoc)) ? "__strong " :
(canUseWeak ? "__weak " : "__unsafe_unretained ");
Pass.TA.insert(I->IvarD->getLocation(), toWhich);
@@ -327,7 +327,7 @@ private:
}
}
- return false;
+ return false;
}
// Returns true if all declarations in the @property have GC __weak.
diff --git a/lib/ARCMigrate/TransProtectedScope.cpp b/lib/ARCMigrate/TransProtectedScope.cpp
index 0fcbcbedfe04..1bb4c1f4e449 100644
--- a/lib/ARCMigrate/TransProtectedScope.cpp
+++ b/lib/ARCMigrate/TransProtectedScope.cpp
@@ -46,7 +46,7 @@ struct CaseInfo {
St_CannotFix,
St_Fixed
} State;
-
+
CaseInfo() : SC(nullptr), State(St_Unchecked) {}
CaseInfo(SwitchCase *S, SourceRange Range)
: SC(S), Range(Range), State(St_Unchecked) {}
diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
index ebe289b34df8..c411044ecde3 100644
--- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -251,7 +251,7 @@ private:
while (OuterS && (isa<ParenExpr>(OuterS) ||
isa<CastExpr>(OuterS) ||
isa<ExprWithCleanups>(OuterS)));
-
+
if (!OuterS)
return std::make_pair(prevStmt, nextStmt);
@@ -419,7 +419,7 @@ private:
bool isRemovable(Expr *E) const {
return Removables.count(E);
}
-
+
bool tryRemoving(Expr *E) const {
if (isRemovable(E)) {
Pass.TA.removeStmt(E);
diff --git a/lib/ARCMigrate/TransUnbridgedCasts.cpp b/lib/ARCMigrate/TransUnbridgedCasts.cpp
index de52bef4d206..66167d37ac95 100644
--- a/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ b/lib/ARCMigrate/TransUnbridgedCasts.cpp
@@ -97,7 +97,7 @@ public:
if (castType->isObjCRetainableType() == castExprType->isObjCRetainableType())
return true;
-
+
bool exprRetainable = castExprType->isObjCIndirectLifetimeType();
bool castRetainable = castType->isObjCIndirectLifetimeType();
if (exprRetainable == castRetainable) return true;
@@ -153,7 +153,7 @@ private:
// Do not migrate to couple of bridge transfer casts which
// cancel each other out. Leave it unchanged so error gets user
// attention instead.
- if (FD->getName() == "CFRetain" &&
+ if (FD->getName() == "CFRetain" &&
FD->getNumParams() == 1 &&
FD->getParent()->isTranslationUnit() &&
FD->isExternallyVisible()) {
diff --git a/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp b/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
index 76ce0ec90db3..220102ec49ce 100644
--- a/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
+++ b/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
@@ -56,7 +56,7 @@ public:
bool BackedBySynthesizeSetter = false;
for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator
- P = SynthesizedProperties.begin(),
+ P = SynthesizedProperties.begin(),
E = SynthesizedProperties.end(); P != E; ++P) {
ObjCPropertyDecl *PropDecl = P->first;
if (PropDecl->getSetterName() == ME->getSelector()) {
@@ -66,11 +66,11 @@ public:
}
if (!BackedBySynthesizeSetter)
return true;
-
+
// Remove the setter message if RHS is null
Transaction Trans(TA);
Expr *RHS = ME->getArg(0);
- bool RHSIsNull =
+ bool RHSIsNull =
RHS->isNullPointerConstant(Ctx,
Expr::NPC_ValueDependentIsNull);
if (RHSIsNull && isRemovable(ME))
@@ -119,10 +119,10 @@ public:
ObjCPropertyDecl *PD = PID->getPropertyDecl();
ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
if (!(setterM && setterM->isDefined())) {
- ObjCPropertyDecl::PropertyAttributeKind AttrKind =
+ ObjCPropertyDecl::PropertyAttributeKind AttrKind =
PD->getPropertyAttributes();
- if (AttrKind &
- (ObjCPropertyDecl::OBJC_PR_retain |
+ if (AttrKind &
+ (ObjCPropertyDecl::OBJC_PR_retain |
ObjCPropertyDecl::OBJC_PR_copy |
ObjCPropertyDecl::OBJC_PR_strong))
SynthesizedProperties[PD] = PID;
@@ -173,7 +173,7 @@ private:
return false;
bool IvarBacksPropertySynthesis = false;
for (llvm::DenseMap<ObjCPropertyDecl*, ObjCPropertyImplDecl*>::iterator
- P = SynthesizedProperties.begin(),
+ P = SynthesizedProperties.begin(),
E = SynthesizedProperties.end(); P != E; ++P) {
ObjCPropertyImplDecl *PropImpDecl = P->second;
if (PropImpDecl && PropImpDecl->getPropertyIvarDecl() == IVDecl) {
diff --git a/lib/ARCMigrate/TransformActions.cpp b/lib/ARCMigrate/TransformActions.cpp
index 704be4374d3d..3f79cc441e85 100644
--- a/lib/ARCMigrate/TransformActions.cpp
+++ b/lib/ARCMigrate/TransformActions.cpp
@@ -76,7 +76,7 @@ class TransformActionsImpl {
End = FullSourceLoc(srcMgr.getExpansionLoc(endLoc), srcMgr);
}
assert(Begin.isValid() && End.isValid());
- }
+ }
RangeComparison compareWith(const CharRange &RHS) const {
if (End.isBeforeInTranslationUnitThan(RHS.Begin))
@@ -94,7 +94,7 @@ class TransformActionsImpl {
else
return Range_ExtendsEnd;
}
-
+
static RangeComparison compare(SourceRange LHS, SourceRange RHS,
SourceManager &SrcMgr, Preprocessor &PP) {
return CharRange(CharSourceRange::getTokenRange(LHS), SrcMgr, PP)
@@ -485,7 +485,7 @@ void TransformActionsImpl::commitReplaceText(SourceLocation loc,
SourceLocation afterText = loc.getLocWithOffset(text.size());
addRemoval(CharSourceRange::getCharRange(loc, afterText));
- commitInsert(loc, replacementText);
+ commitInsert(loc, replacementText);
}
void TransformActionsImpl::commitIncreaseIndentation(SourceRange range,
diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp
index 1f4e6a297fc3..4a7af2858879 100644
--- a/lib/ARCMigrate/Transforms.cpp
+++ b/lib/ARCMigrate/Transforms.cpp
@@ -203,7 +203,7 @@ bool trans::isGlobalVar(Expr *E) {
return isGlobalVar(condOp->getTrueExpr()) &&
isGlobalVar(condOp->getFalseExpr());
- return false;
+ return false;
}
StringRef trans::getNilString(MigrationPass &Pass) {
@@ -240,9 +240,9 @@ class RemovablesCollector : public RecursiveASTVisitor<RemovablesCollector> {
public:
RemovablesCollector(ExprSet &removables)
: Removables(removables) { }
-
+
bool shouldWalkTypesOfTypeLocs() const { return false; }
-
+
bool TraverseStmtExpr(StmtExpr *E) {
CompoundStmt *S = E->getSubStmt();
for (CompoundStmt::body_iterator
@@ -253,40 +253,40 @@ public:
}
return true;
}
-
+
bool VisitCompoundStmt(CompoundStmt *S) {
for (auto *I : S->body())
mark(I);
return true;
}
-
+
bool VisitIfStmt(IfStmt *S) {
mark(S->getThen());
mark(S->getElse());
return true;
}
-
+
bool VisitWhileStmt(WhileStmt *S) {
mark(S->getBody());
return true;
}
-
+
bool VisitDoStmt(DoStmt *S) {
mark(S->getBody());
return true;
}
-
+
bool VisitForStmt(ForStmt *S) {
mark(S->getInit());
mark(S->getInc());
mark(S->getBody());
return true;
}
-
+
private:
void mark(Stmt *S) {
if (!S) return;
-
+
while (LabelStmt *Label = dyn_cast<LabelStmt>(S))
S = Label->getSubStmt();
S = S->IgnoreImplicit();
@@ -408,12 +408,12 @@ bool MigrationContext::rewritePropertyAttribute(StringRef fromAttr,
return false;
lexer.LexFromRawLexer(tok);
if (tok.isNot(tok::l_paren)) return false;
-
+
Token BeforeTok = tok;
Token AfterTok;
AfterTok.startToken();
SourceLocation AttrLoc;
-
+
lexer.LexFromRawLexer(tok);
if (tok.is(tok::r_paren))
return false;
@@ -454,7 +454,7 @@ bool MigrationContext::rewritePropertyAttribute(StringRef fromAttr,
return true;
}
-
+
return false;
}
@@ -493,7 +493,7 @@ bool MigrationContext::addPropertyAttribute(StringRef attr,
Pass.TA.insert(tok.getLocation(), std::string("(") + attr.str() + ") ");
return true;
}
-
+
lexer.LexFromRawLexer(tok);
if (tok.is(tok::r_paren)) {
Pass.TA.insert(tok.getLocation(), attr);
@@ -520,7 +520,7 @@ static void GCRewriteFinalize(MigrationPass &pass) {
DeclContext *DC = Ctx.getTranslationUnitDecl();
Selector FinalizeSel =
Ctx.Selectors.getNullarySelector(&pass.Ctx.Idents.get("finalize"));
-
+
typedef DeclContext::specific_decl_iterator<ObjCImplementationDecl>
impl_iterator;
for (impl_iterator I = impl_iterator(DC->decls_begin()),
@@ -528,11 +528,11 @@ static void GCRewriteFinalize(MigrationPass &pass) {
for (const auto *MD : I->instance_methods()) {
if (!MD->hasBody())
continue;
-
+
if (MD->isInstanceMethod() && MD->getSelector() == FinalizeSel) {
const ObjCMethodDecl *FinalizeM = MD;
Transaction Trans(TA);
- TA.insert(FinalizeM->getSourceRange().getBegin(),
+ TA.insert(FinalizeM->getSourceRange().getBegin(),
"#if !__has_feature(objc_arc)\n");
CharSourceRange::getTokenRange(FinalizeM->getSourceRange());
const SourceManager &SM = pass.Ctx.getSourceManager();
@@ -540,10 +540,10 @@ static void GCRewriteFinalize(MigrationPass &pass) {
bool Invalid;
std::string str = "\n#endif\n";
str += Lexer::getSourceText(
- CharSourceRange::getTokenRange(FinalizeM->getSourceRange()),
+ CharSourceRange::getTokenRange(FinalizeM->getSourceRange()),
SM, LangOpts, &Invalid);
TA.insertAfterToken(FinalizeM->getSourceRange().getEnd(), str);
-
+
break;
}
}
diff --git a/lib/ARCMigrate/Transforms.h b/lib/ARCMigrate/Transforms.h
index 8ea4f79456a8..bafe9fc52a27 100644
--- a/lib/ARCMigrate/Transforms.h
+++ b/lib/ARCMigrate/Transforms.h
@@ -103,7 +103,7 @@ public:
explicit MigrationContext(MigrationPass &pass) : Pass(pass) {}
~MigrationContext();
-
+
typedef std::vector<ASTTraverser *>::iterator traverser_iterator;
traverser_iterator traversers_begin() { return Traversers.begin(); }
traverser_iterator traversers_end() { return Traversers.end(); }
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 25dc4441aafd..d50f4493788a 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -492,11 +492,11 @@ comments::FullComment *ASTContext::getCommentForDecl(
if (D->isInvalidDecl())
return nullptr;
D = adjustDeclToTemplate(D);
-
+
const Decl *Canonical = D->getCanonicalDecl();
llvm::DenseMap<const Decl *, comments::FullComment *>::iterator Pos =
ParsedComments.find(Canonical);
-
+
if (Pos != ParsedComments.end()) {
if (Canonical != D) {
comments::FullComment *FC = Pos->second;
@@ -505,9 +505,9 @@ comments::FullComment *ASTContext::getCommentForDecl(
}
return Pos->second;
}
-
+
const Decl *OriginalDecl;
-
+
const RawComment *RC = getRawCommentForAnyRedecl(D, &OriginalDecl);
if (!RC) {
if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
@@ -558,7 +558,7 @@ comments::FullComment *ASTContext::getCommentForDecl(
if (const CXXRecordDecl *NonVirtualBase = Ty->getAsCXXRecordDecl()) {
if (!(NonVirtualBase= NonVirtualBase->getDefinition()))
continue;
-
+
if (comments::FullComment *FC = getCommentForDecl((NonVirtualBase), PP))
return cloneFullComment(FC, D);
}
@@ -580,7 +580,7 @@ comments::FullComment *ASTContext::getCommentForDecl(
}
return nullptr;
}
-
+
// If the RawComment was attached to other redeclaration of this Decl, we
// should parse the comment in context of that other Decl. This is important
// because comments can contain references to parameter names which can be
@@ -593,8 +593,8 @@ comments::FullComment *ASTContext::getCommentForDecl(
return FC;
}
-void
-ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
+void
+ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
TemplateTemplateParmDecl *Parm) {
ID.AddInteger(Parm->getDepth());
ID.AddInteger(Parm->getPosition());
@@ -602,7 +602,7 @@ ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
TemplateParameterList *Params = Parm->getTemplateParameters();
ID.AddInteger(Params->size());
- for (TemplateParameterList::const_iterator P = Params->begin(),
+ for (TemplateParameterList::const_iterator P = Params->begin(),
PEnd = Params->end();
P != PEnd; ++P) {
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
@@ -610,7 +610,7 @@ ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
ID.AddBoolean(TTP->isParameterPack());
continue;
}
-
+
if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
ID.AddInteger(1);
ID.AddBoolean(NTTP->isParameterPack());
@@ -622,11 +622,11 @@ ASTContext::CanonicalTemplateTemplateParm::Profile(llvm::FoldingSetNodeID &ID,
QualType T = NTTP->getExpansionType(I);
ID.AddPointer(T.getCanonicalType().getAsOpaquePtr());
}
- } else
+ } else
ID.AddBoolean(false);
continue;
}
-
+
auto *TTP = cast<TemplateTemplateParmDecl>(*P);
ID.AddInteger(2);
Profile(ID, TTP);
@@ -644,17 +644,17 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
= CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
if (Canonical)
return Canonical->getParam();
-
+
// Build a canonical template parameter list.
TemplateParameterList *Params = TTP->getTemplateParameters();
SmallVector<NamedDecl *, 4> CanonParams;
CanonParams.reserve(Params->size());
- for (TemplateParameterList::const_iterator P = Params->begin(),
+ for (TemplateParameterList::const_iterator P = Params->begin(),
PEnd = Params->end();
P != PEnd; ++P) {
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P))
CanonParams.push_back(
- TemplateTypeParmDecl::Create(*this, getTranslationUnitDecl(),
+ TemplateTypeParmDecl::Create(*this, getTranslationUnitDecl(),
SourceLocation(),
SourceLocation(),
TTP->getDepth(),
@@ -672,7 +672,7 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
ExpandedTInfos.push_back(
getTrivialTypeSourceInfo(ExpandedTypes.back()));
}
-
+
Param = NonTypeTemplateParmDecl::Create(*this, getTranslationUnitDecl(),
SourceLocation(),
SourceLocation(),
@@ -704,9 +704,9 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
Expr *const CanonRequiresClause = nullptr;
TemplateTemplateParmDecl *CanonTTP
- = TemplateTemplateParmDecl::Create(*this, getTranslationUnitDecl(),
+ = TemplateTemplateParmDecl::Create(*this, getTranslationUnitDecl(),
SourceLocation(), TTP->getDepth(),
- TTP->getPosition(),
+ TTP->getPosition(),
TTP->isParameterPack(),
nullptr,
TemplateParameterList::Create(*this, SourceLocation(),
@@ -823,7 +823,7 @@ ASTContext::~ASTContext() {
if (auto *R = const_cast<ASTRecordLayout *>((I++)->second))
R->Destroy(*this);
}
-
+
for (llvm::DenseMap<const Decl*, AttrVec*>::iterator A = DeclAttrs.begin(),
AEnd = DeclAttrs.end();
A != AEnd; ++A)
@@ -1001,7 +1001,7 @@ void ASTContext::addLazyModuleInitializers(Module *M, ArrayRef<uint32_t> IDs) {
ArrayRef<Decl *> ASTContext::getModuleInitializers(Module *M) {
auto It = ModuleInitializers.find(M);
- if (It == ModuleInitializers.end())
+ if (It == ModuleInitializers.end())
return None;
auto *Inits = It->second;
@@ -1098,7 +1098,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
ABI.reset(createCXXABI(Target));
AddrSpaceMap = getAddressSpaceMap(Target, LangOpts);
AddrSpaceMapMangling = isAddrSpaceMapManglingEnabled(Target, LangOpts);
-
+
// C99 6.2.5p19.
InitBuiltinType(VoidTy, BuiltinType::Void);
@@ -1242,13 +1242,13 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
InitBuiltinType(OCLQueueTy, BuiltinType::OCLQueue);
InitBuiltinType(OCLReserveIDTy, BuiltinType::OCLReserveID);
}
-
+
// Builtin type for __objc_yes and __objc_no
ObjCBuiltinBoolTy = (Target.useSignedCharForObjCBool() ?
SignedCharTy : BoolTy);
-
+
ObjCConstantStringType = QualType();
-
+
ObjCSuperType = QualType();
// void * type
@@ -1281,7 +1281,7 @@ AttrVec& ASTContext::getDeclAttrs(const Decl *D) {
void *Mem = Allocate(sizeof(AttrVec));
Result = new (Mem) AttrVec;
}
-
+
return *Result;
}
@@ -1361,11 +1361,11 @@ void
ASTContext::setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern) {
assert((isa<UsingDecl>(Pattern) ||
isa<UnresolvedUsingValueDecl>(Pattern) ||
- isa<UnresolvedUsingTypenameDecl>(Pattern)) &&
+ isa<UnresolvedUsingTypenameDecl>(Pattern)) &&
"pattern decl is not a using decl");
assert((isa<UsingDecl>(Inst) ||
isa<UnresolvedUsingValueDecl>(Inst) ||
- isa<UnresolvedUsingTypenameDecl>(Inst)) &&
+ isa<UnresolvedUsingTypenameDecl>(Inst)) &&
"instantiation did not produce a using decl");
assert(!InstantiatedFromUsingDecl[Inst] && "pattern already exists");
InstantiatedFromUsingDecl[Inst] = Pattern;
@@ -1432,7 +1432,7 @@ ASTContext::overridden_methods(const CXXMethodDecl *Method) const {
return overridden_method_range(Pos->second.begin(), Pos->second.end());
}
-void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method,
+void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method,
const CXXMethodDecl *Overridden) {
assert(Method->isCanonicalDecl() && Overridden->isCanonicalDecl());
OverriddenMethods[Method].push_back(Overridden);
@@ -1466,7 +1466,7 @@ void ASTContext::addedLocalImportDecl(ImportDecl *Import) {
LastLocalImport = Import;
return;
}
-
+
LastLocalImport->NextLocalImport = Import;
LastLocalImport = Import;
}
@@ -1513,7 +1513,7 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const {
}
}
else if (isa<FieldDecl>(D))
- UseAlignAttrOnly =
+ UseAlignAttrOnly =
D->hasAttr<PackedAttr>() ||
cast<FieldDecl>(D)->getParent()->hasAttr<PackedAttr>();
@@ -1881,7 +1881,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
case BuiltinType::ObjCId:
case BuiltinType::ObjCClass:
case BuiltinType::ObjCSel:
- Width = Target->getPointerWidth(0);
+ Width = Target->getPointerWidth(0);
Align = Target->getPointerAlign(0);
break;
case BuiltinType::OCLSampler:
@@ -2056,6 +2056,27 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
return TypeInfo(Width, Align, AlignIsRequired);
}
+unsigned ASTContext::getTypeUnadjustedAlign(const Type *T) const {
+ UnadjustedAlignMap::iterator I = MemoizedUnadjustedAlign.find(T);
+ if (I != MemoizedUnadjustedAlign.end())
+ return I->second;
+
+ unsigned UnadjustedAlign;
+ if (const auto *RT = T->getAs<RecordType>()) {
+ const RecordDecl *RD = RT->getDecl();
+ const ASTRecordLayout &Layout = getASTRecordLayout(RD);
+ UnadjustedAlign = toBits(Layout.getUnadjustedAlignment());
+ } else if (const auto *ObjCI = T->getAs<ObjCInterfaceType>()) {
+ const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
+ UnadjustedAlign = toBits(Layout.getUnadjustedAlignment());
+ } else {
+ UnadjustedAlign = getTypeAlign(T);
+ }
+
+ MemoizedUnadjustedAlign[T] = UnadjustedAlign;
+ return UnadjustedAlign;
+}
+
unsigned ASTContext::getOpenMPDefaultSimdAlign(QualType T) const {
unsigned SimdAlign = getTargetInfo().getSimdDefaultAlign();
// Target ppc64 with QPX: simd default alignment for pointer to double is 32.
@@ -2086,7 +2107,7 @@ CharUnits ASTContext::getTypeSizeInChars(const Type *T) const {
return getTypeInfoInChars(T).first;
}
-/// getTypeAlignInChars - Return the ABI-specified alignment of a type, in
+/// getTypeAlignInChars - Return the ABI-specified alignment of a type, in
/// characters. This method does not work on incomplete types.
CharUnits ASTContext::getTypeAlignInChars(QualType T) const {
return toCharUnitsFromBits(getTypeAlign(T));
@@ -2095,6 +2116,16 @@ CharUnits ASTContext::getTypeAlignInChars(const Type *T) const {
return toCharUnitsFromBits(getTypeAlign(T));
}
+/// getTypeUnadjustedAlignInChars - Return the ABI-specified alignment of a
+/// type, in characters, before alignment adustments. This method does
+/// not work on incomplete types.
+CharUnits ASTContext::getTypeUnadjustedAlignInChars(QualType T) const {
+ return toCharUnitsFromBits(getTypeUnadjustedAlign(T));
+}
+CharUnits ASTContext::getTypeUnadjustedAlignInChars(const Type *T) const {
+ return toCharUnitsFromBits(getTypeUnadjustedAlign(T));
+}
+
/// 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
@@ -2172,7 +2203,7 @@ void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI,
Ivars.push_back(I);
} else {
auto *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
- for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
+ for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv;
Iv= Iv->getNextIvar())
Ivars.push_back(Iv);
}
@@ -2184,11 +2215,11 @@ void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols) {
if (const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
// We can use protocol_iterator here instead of
- // all_referenced_protocol_iterator since we are walking all categories.
+ // all_referenced_protocol_iterator since we are walking all categories.
for (auto *Proto : OI->all_referenced_protocols()) {
CollectInheritedProtocols(Proto, Protocols);
}
-
+
// Categories of this Interface.
for (const auto *Cat : OI->visible_categories())
CollectInheritedProtocols(Cat, Protocols);
@@ -2379,11 +2410,11 @@ bool ASTContext::hasUniqueObjectRepresentations(QualType Ty) const {
}
unsigned ASTContext::CountNonClassIvars(const ObjCInterfaceDecl *OI) const {
- unsigned count = 0;
+ unsigned count = 0;
// Count ivars declared in class extension.
for (const auto *Ext : OI->known_extensions())
count += Ext->ivar_size();
-
+
// Count ivar defined in this class's implementation. This
// includes synthesized ivars.
if (ObjCImplementationDecl *ImplDecl = OI->getImplementation())
@@ -2471,7 +2502,7 @@ const ObjCInterfaceDecl *ASTContext::getObjContainingInterface(
/// none exists.
Expr *ASTContext::getBlockVarCopyInits(const VarDecl*VD) {
assert(VD && "Passed null params");
- assert(VD->hasAttr<BlocksAttr>() &&
+ assert(VD->hasAttr<BlocksAttr>() &&
"getBlockVarCopyInits - not __block var");
llvm::DenseMap<const VarDecl*, Expr*>::iterator
I = BlockVarCopyInits.find(VD);
@@ -2481,7 +2512,7 @@ Expr *ASTContext::getBlockVarCopyInits(const VarDecl*VD) {
/// Set the copy inialization expression of a block var decl.
void ASTContext::setBlockVarCopyInits(VarDecl*VD, Expr* Init) {
assert(VD && Init && "Passed null params");
- assert(VD->hasAttr<BlocksAttr>() &&
+ assert(VD->hasAttr<BlocksAttr>() &&
"setBlockVarCopyInits - not __block var");
BlockVarCopyInits[VD] = Init;
}
@@ -2868,9 +2899,9 @@ QualType ASTContext::getBlockPointerType(QualType T) const {
/// lvalue reference to the specified type.
QualType
ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const {
- assert(getCanonicalType(T) != OverloadTy &&
+ assert(getCanonicalType(T) != OverloadTy &&
"Unresolved overloaded function type");
-
+
// Unique pointers, to guarantee there is only one pointer of a particular
// structure.
llvm::FoldingSetNodeID ID;
@@ -3159,7 +3190,7 @@ QualType ASTContext::getVariableArrayType(QualType EltTy,
// Since we don't unique expressions, it isn't possible to unique VLA's
// that have an expression provided for their size.
QualType Canon;
-
+
// Be sure to pull qualifiers off the element type.
if (!EltTy.isCanonical() || EltTy.hasLocalQualifiers()) {
SplitQualType canonSplit = getCanonicalType(EltTy).split();
@@ -3167,7 +3198,7 @@ QualType ASTContext::getVariableArrayType(QualType EltTy,
IndexTypeQuals, Brackets);
Canon = getQualifiedType(Canon, canonSplit.Quals);
}
-
+
auto *New = new (*this, TypeAlignment)
VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals, Brackets);
@@ -3184,7 +3215,7 @@ QualType ASTContext::getDependentSizedArrayType(QualType elementType,
ArrayType::ArraySizeModifier ASM,
unsigned elementTypeQuals,
SourceRange brackets) const {
- assert((!numElements || numElements->isTypeDependent() ||
+ assert((!numElements || numElements->isTypeDependent() ||
numElements->isValueDependent()) &&
"Size must be type- or value-dependent!");
@@ -3417,7 +3448,7 @@ ASTContext::getDependentSizedExtVectorType(QualType vecType,
} else {
QualType Canon = getDependentSizedExtVectorType(CanonVecTy, SizeExpr,
SourceLocation());
- New = new (*this, TypeAlignment)
+ New = new (*this, TypeAlignment)
DependentSizedExtVectorType(*this, vecType, Canon, SizeExpr, AttrLoc);
}
}
@@ -3426,10 +3457,10 @@ ASTContext::getDependentSizedExtVectorType(QualType vecType,
return QualType(New, 0);
}
-QualType ASTContext::getDependentAddressSpaceType(QualType PointeeType,
- Expr *AddrSpaceExpr,
+QualType ASTContext::getDependentAddressSpaceType(QualType PointeeType,
+ Expr *AddrSpaceExpr,
SourceLocation AttrLoc) const {
- assert(AddrSpaceExpr->isInstantiationDependent());
+ assert(AddrSpaceExpr->isInstantiationDependent());
QualType canonPointeeType = getCanonicalType(PointeeType);
@@ -3443,22 +3474,22 @@ QualType ASTContext::getDependentAddressSpaceType(QualType PointeeType,
if (!canonTy) {
canonTy = new (*this, TypeAlignment)
- DependentAddressSpaceType(*this, canonPointeeType,
+ DependentAddressSpaceType(*this, canonPointeeType,
QualType(), AddrSpaceExpr, AttrLoc);
DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
Types.push_back(canonTy);
}
-
+
if (canonPointeeType == PointeeType &&
canonTy->getAddrSpaceExpr() == AddrSpaceExpr)
- return QualType(canonTy, 0);
+ return QualType(canonTy, 0);
auto *sugaredType
= new (*this, TypeAlignment)
- DependentAddressSpaceType(*this, PointeeType, QualType(canonTy, 0),
+ DependentAddressSpaceType(*this, PointeeType, QualType(canonTy, 0),
AddrSpaceExpr, AttrLoc);
Types.push_back(sugaredType);
- return QualType(sugaredType, 0);
+ return QualType(sugaredType, 0);
}
/// Determine whether \p T is canonical as the result type of a function.
@@ -3818,7 +3849,7 @@ QualType ASTContext::getRecordType(const RecordDecl *Decl) const {
if (const RecordDecl *PrevDecl = Decl->getPreviousDecl())
if (PrevDecl->TypeForDecl)
- return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
+ return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
auto *newType = new (*this, TypeAlignment) RecordType(Decl);
Decl->TypeForDecl = newType;
@@ -3831,7 +3862,7 @@ QualType ASTContext::getEnumType(const EnumDecl *Decl) const {
if (const EnumDecl *PrevDecl = Decl->getPreviousDecl())
if (PrevDecl->TypeForDecl)
- return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
+ return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
auto *newType = new (*this, TypeAlignment) EnumType(Decl);
Decl->TypeForDecl = newType;
@@ -3882,7 +3913,7 @@ ASTContext::getSubstTemplateTypeParmType(const TemplateTypeParmType *Parm,
return QualType(SubstParm, 0);
}
-/// Retrieve a
+/// Retrieve a
QualType ASTContext::getSubstTemplateTypeParmPackType(
const TemplateTypeParmType *Parm,
const TemplateArgument &ArgPack) {
@@ -3892,14 +3923,14 @@ QualType ASTContext::getSubstTemplateTypeParmPackType(
assert(P.getAsType().isCanonical() && "Pack contains non-canonical type");
}
#endif
-
+
llvm::FoldingSetNodeID ID;
SubstTemplateTypeParmPackType::Profile(ID, Parm, ArgPack);
void *InsertPos = nullptr;
if (SubstTemplateTypeParmPackType *SubstParm
= SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(SubstParm, 0);
-
+
QualType Canon;
if (!Parm->isCanonicalUnqualified()) {
Canon = getCanonicalType(QualType(Parm, 0));
@@ -3913,7 +3944,7 @@ QualType ASTContext::getSubstTemplateTypeParmPackType(
ArgPack);
Types.push_back(SubstParm);
SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
- return QualType(SubstParm, 0);
+ return QualType(SubstParm, 0);
}
/// Retrieve the template type parameter type for a template
@@ -3935,7 +3966,7 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
QualType Canon = getTemplateTypeParmType(Depth, Index, ParameterPack);
TypeParm = new (*this, TypeAlignment) TemplateTypeParmType(TTPDecl, Canon);
- TemplateTypeParmType *TypeCheck
+ TemplateTypeParmType *TypeCheck
= TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(!TypeCheck && "Template type parameter canonical type broken");
(void)TypeCheck;
@@ -3954,7 +3985,7 @@ ASTContext::getTemplateSpecializationTypeInfo(TemplateName Name,
SourceLocation NameLoc,
const TemplateArgumentListInfo &Args,
QualType Underlying) const {
- assert(!Name.getAsDependentTemplateName() &&
+ assert(!Name.getAsDependentTemplateName() &&
"No dependent template names here!");
QualType TST = getTemplateSpecializationType(Name, Args, Underlying);
@@ -3974,7 +4005,7 @@ QualType
ASTContext::getTemplateSpecializationType(TemplateName Template,
const TemplateArgumentListInfo &Args,
QualType Underlying) const {
- assert(!Template.getAsDependentTemplateName() &&
+ assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
SmallVector<TemplateArgument, 4> ArgVec;
@@ -3990,7 +4021,7 @@ static bool hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
for (const TemplateArgument &Arg : Args)
if (Arg.isPackExpansion())
return true;
-
+
return true;
}
#endif
@@ -3999,13 +4030,13 @@ QualType
ASTContext::getTemplateSpecializationType(TemplateName Template,
ArrayRef<TemplateArgument> Args,
QualType Underlying) const {
- assert(!Template.getAsDependentTemplateName() &&
+ assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
// Look through qualified template names.
if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
Template = TemplateName(QTN->getTemplateDecl());
-
- bool IsTypeAlias =
+
+ bool IsTypeAlias =
Template.getAsTemplateDecl() &&
isa<TypeAliasTemplateDecl>(Template.getAsTemplateDecl());
QualType CanonType;
@@ -4037,13 +4068,13 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
QualType ASTContext::getCanonicalTemplateSpecializationType(
TemplateName Template, ArrayRef<TemplateArgument> Args) const {
- assert(!Template.getAsDependentTemplateName() &&
+ assert(!Template.getAsDependentTemplateName() &&
"No dependent template names here!");
// Look through qualified template names.
if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
Template = TemplateName(QTN->getTemplateDecl());
-
+
// Build the canonical template specialization type.
TemplateName CanonTemplate = getCanonicalTemplateName(Template);
SmallVector<TemplateArgument, 4> CanonArgs;
@@ -4174,7 +4205,7 @@ ASTContext::getDependentTemplateSpecializationType(
NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
ArrayRef<TemplateArgument> Args) const {
- assert((!NNS || NNS->isDependent()) &&
+ assert((!NNS || NNS->isDependent()) &&
"nested-name-specifier must be dependent");
llvm::FoldingSetNodeID ID;
@@ -4309,7 +4340,7 @@ static bool areSortedAndUniqued(ArrayRef<ObjCProtocolDecl *> Protocols) {
if (Protocols[0]->getCanonicalDecl() != Protocols[0])
return false;
-
+
for (unsigned i = 1; i != Protocols.size(); ++i)
if (CmpProtocolNames(&Protocols[i - 1], &Protocols[i]) >= 0 ||
Protocols[i]->getCanonicalDecl() != Protocols[i])
@@ -4534,7 +4565,7 @@ bool ASTContext::ObjCObjectAdoptsQTypeProtocols(QualType QT,
ObjCInterfaceDecl *IC) {
if (!QT->isObjCQualifiedIdType())
return false;
-
+
if (const auto *OPT = QT->getAs<ObjCObjectPointerType>()) {
// If both the right and left sides have qualifiers.
for (auto *Proto : OPT->quals()) {
@@ -4578,7 +4609,7 @@ bool ASTContext::QIdProtocolsAdoptObjCObjectProtocols(QualType QT,
}
if (Conforms)
return true;
-
+
for (auto *PI : InheritedProtocols) {
// If both the right and left sides have qualifiers.
bool Adopts = false;
@@ -4639,7 +4670,7 @@ QualType ASTContext::getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
// Prefer the definition, if there is one.
if (const ObjCInterfaceDecl *Def = Decl->getDefinition())
Decl = Def;
-
+
void *Mem = Allocate(sizeof(ObjCInterfaceType), TypeAlignment);
auto *T = new (Mem) ObjCInterfaceType(Decl);
Decl->TypeForDecl = T;
@@ -4870,7 +4901,7 @@ CanQualType ASTContext::getSizeType() const {
return getFromTargetType(Target->getSizeType());
}
-/// Return the unique signed counterpart of the integer type
+/// Return the unique signed counterpart of the integer type
/// corresponding to size_t.
CanQualType ASTContext::getSignedSizeType() const {
return getFromTargetType(Target->getSignedSizeType());
@@ -5059,14 +5090,14 @@ bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2) {
const auto *T1MPType = T1->getAs<MemberPointerType>();
const auto *T2MPType = T2->getAs<MemberPointerType>();
- if (T1MPType && T2MPType &&
- hasSameUnqualifiedType(QualType(T1MPType->getClass(), 0),
+ if (T1MPType && T2MPType &&
+ hasSameUnqualifiedType(QualType(T1MPType->getClass(), 0),
QualType(T2MPType->getClass(), 0))) {
T1 = T1MPType->getPointeeType();
T2 = T2MPType->getPointeeType();
return true;
}
-
+
if (getLangOpts().ObjC1) {
const auto *T1OPType = T1->getAs<ObjCObjectPointerType>();
const auto *T2OPType = T2->getAs<ObjCObjectPointerType>();
@@ -5076,9 +5107,9 @@ bool ASTContext::UnwrapSimilarTypes(QualType &T1, QualType &T2) {
return true;
}
}
-
+
// FIXME: Block pointers, too?
-
+
return false;
}
@@ -5170,7 +5201,7 @@ TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name) const {
TemplateDecl *Template = Name.getAsTemplateDecl();
if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Template))
Template = getCanonicalTemplateTemplateParmDecl(TTP);
-
+
// The canonical template name is the canonical template declaration.
return TemplateName(cast<TemplateDecl>(Template->getCanonicalDecl()));
}
@@ -5245,7 +5276,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const {
case TemplateArgument::Pack: {
if (Arg.pack_size() == 0)
return Arg;
-
+
auto *CanonArgs = new (*this) TemplateArgument[Arg.pack_size()];
unsigned Idx = 0;
for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
@@ -5289,7 +5320,7 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const {
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
QualType T = getCanonicalType(QualType(NNS->getAsType(), 0));
-
+
// If we have some kind of dependent-named type (e.g., "typename T::type"),
// break it apart into its prefix and identifier, then reconsititute those
// as the canonical nested-name-specifier. This is required to canonicalize
@@ -5298,7 +5329,7 @@ ASTContext::getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const {
// typedef typename T::type T1;
// typedef typename T1::type T2;
if (const auto *DNT = T->getAs<DependentNameType>())
- return NestedNameSpecifier::Create(*this, DNT->getQualifier(),
+ return NestedNameSpecifier::Create(*this, DNT->getQualifier(),
const_cast<IdentifierInfo *>(DNT->getIdentifier()));
// Otherwise, just canonicalize the type, and force it to be a TypeSpec.
@@ -5930,24 +5961,24 @@ bool ASTContext::BlockRequiresCopying(QualType Ty,
if (const CXXRecordDecl *record = Ty->getAsCXXRecordDecl()) {
const Expr *copyExpr = getBlockVarCopyInits(D);
if (!copyExpr && record->hasTrivialDestructor()) return false;
-
+
return true;
}
-
+
// The block needs copy/destroy helpers if Ty is non-trivial to destructively
// move or destroy.
if (Ty.isNonTrivialToPrimitiveDestructiveMove() || Ty.isDestructedType())
return true;
if (!Ty->isObjCRetainableType()) return false;
-
+
Qualifiers qs = Ty.getQualifiers();
-
+
// If we have lifetime, that dominates.
if (Qualifiers::ObjCLifetime lifetime = qs.getObjCLifetime()) {
switch (lifetime) {
case Qualifiers::OCL_None: llvm_unreachable("impossible");
-
+
// These are just bits as far as the runtime is concerned.
case Qualifiers::OCL_ExplicitNone:
case Qualifiers::OCL_Autoreleasing:
@@ -5971,7 +6002,7 @@ bool ASTContext::getByrefLifetime(QualType Ty,
if (!getLangOpts().ObjC1 ||
getLangOpts().getGC() != LangOptions::NonGC)
return false;
-
+
HasByrefExtendedLayout = false;
if (Ty->isRecordType()) {
HasByrefExtendedLayout = true;
@@ -6009,7 +6040,7 @@ static bool isTypeTypedefedAsBOOL(QualType T) {
CharUnits ASTContext::getObjCEncodingTypeSize(QualType type) const {
if (!type->isIncompleteArrayType() && type->isIncompleteType())
return CharUnits::Zero();
-
+
CharUnits sz = getTypeSizeInChars(type);
// Make all integer and enum types at least as large as an int
@@ -6085,11 +6116,11 @@ std::string ASTContext::getObjCEncodingForBlock(const BlockExpr *Expr) const {
S += charUnitsToString(ParmOffset);
// Block pointer and offset.
S += "@?0";
-
+
// Argument types.
ParmOffset = PtrSize;
for (auto PVDecl : Decl->parameters()) {
- QualType PType = PVDecl->getOriginalType();
+ QualType PType = PVDecl->getOriginalType();
if (const auto *AT =
dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
// Use array's original type only if it has known number of
@@ -6122,8 +6153,8 @@ ASTContext::getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const {
CharUnits sz = getObjCEncodingTypeSize(PType);
if (sz.isZero())
continue;
-
- assert(sz.isPositive() &&
+
+ assert(sz.isPositive() &&
"getObjCEncodingForFunctionDecl - Incomplete param type");
ParmOffset += sz;
}
@@ -6145,12 +6176,12 @@ ASTContext::getObjCEncodingForFunctionDecl(const FunctionDecl *Decl) const {
S += charUnitsToString(ParmOffset);
ParmOffset += getObjCEncodingTypeSize(PType);
}
-
+
return S;
}
/// getObjCEncodingForMethodParameter - Return the encoded type for a single
-/// method parameter or return type. If Extended, include class names and
+/// method parameter or return type. If Extended, include class names and
/// block object types.
void ASTContext::getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT,
QualType T, std::string& S,
@@ -6160,9 +6191,9 @@ void ASTContext::getObjCEncodingForMethodParameter(Decl::ObjCDeclQualifier QT,
// Encode parameter type.
getObjCEncodingForTypeImpl(T, S, true, true, nullptr,
true /*OutermostType*/,
- false /*EncodingProperty*/,
- false /*StructField*/,
- Extended /*EncodeBlockParameters*/,
+ false /*EncodingProperty*/,
+ false /*StructField*/,
+ Extended /*EncodeBlockParameters*/,
Extended /*EncodeClassNames*/);
}
@@ -6188,8 +6219,8 @@ std::string ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
CharUnits sz = getObjCEncodingTypeSize(PType);
if (sz.isZero())
continue;
-
- assert(sz.isPositive() &&
+
+ assert(sz.isPositive() &&
"getObjCEncodingForMethodDecl - Incomplete param type");
ParmOffset += sz;
}
@@ -6211,12 +6242,12 @@ std::string ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
PType = PVDecl->getType();
} else if (PType->isFunctionType())
PType = PVDecl->getType();
- getObjCEncodingForMethodParameter(PVDecl->getObjCDeclQualifier(),
+ getObjCEncodingForMethodParameter(PVDecl->getObjCDeclQualifier(),
PType, S, Extended);
S += charUnitsToString(ParmOffset);
ParmOffset += getObjCEncodingTypeSize(PType);
}
-
+
return S;
}
@@ -6457,11 +6488,11 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
static char ObjCEncodingForEnumType(const ASTContext *C, const EnumType *ET) {
EnumDecl *Enum = ET->getDecl();
-
+
// The encoding of an non-fixed enum type is always 'i', regardless of size.
if (!Enum->isFixed())
return 'i';
-
+
// The encoding of a fixed enum type matches its fixed underlying type.
const auto *BT = Enum->getIntegerType()->castAs<BuiltinType>();
return getObjCEncodingForPrimitiveKind(C, BT->getKind());
@@ -6709,7 +6740,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
S += "@?"; // Unlike a pointer-to-function, which is "^?".
if (EncodeBlockParameters) {
const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
-
+
S += '<';
// Block return type
getObjCEncodingForTypeImpl(
@@ -6747,7 +6778,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
// TODO: Double check to make sure this intentionally falls through.
LLVM_FALLTHROUGH;
}
-
+
case Type::ObjCInterface: {
// Ignore protocol qualifiers when mangling at this level.
// @encode(class_name)
@@ -6837,7 +6868,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
}
S += '@';
- if (OPT->getInterfaceDecl() &&
+ if (OPT->getInterfaceDecl() &&
(FD || EncodingProperty || EncodeClassNames)) {
S += '"';
S += OPT->getInterfaceDecl()->getObjCRuntimeNameAsString();
@@ -6862,7 +6893,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
if (NotEncodedT)
*NotEncodedT = T;
return;
-
+
// We could see an undeduced auto type here during error recovery.
// Just ignore it.
case Type::Auto:
@@ -6910,7 +6941,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
}
}
}
-
+
unsigned i = 0;
for (auto *Field : RDecl->fields()) {
uint64_t offs = layout.getFieldOffset(i);
@@ -6971,7 +7002,7 @@ void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
#ifndef NDEBUG
assert(CurOffs <= CurLayObj->first);
if (CurOffs < CurLayObj->first) {
- uint64_t padding = CurLayObj->first - CurOffs;
+ uint64_t padding = CurLayObj->first - CurOffs;
// FIXME: There doesn't seem to be a way to indicate in the encoding that
// packing/alignment of members is different that normal, in which case
// the encoding will be out-of-sync with the real layout.
@@ -7071,15 +7102,15 @@ TypedefDecl *ASTContext::getObjCClassDecl() const {
ObjCInterfaceDecl *ASTContext::getObjCProtocolDecl() const {
if (!ObjCProtocolClassDecl) {
- ObjCProtocolClassDecl
- = ObjCInterfaceDecl::Create(*this, getTranslationUnitDecl(),
+ ObjCProtocolClassDecl
+ = ObjCInterfaceDecl::Create(*this, getTranslationUnitDecl(),
SourceLocation(),
&Idents.get("Protocol"),
/*typeParamList=*/nullptr,
/*PrevDecl=*/nullptr,
- SourceLocation(), true);
+ SourceLocation(), true);
}
-
+
return ObjCProtocolClassDecl;
}
@@ -7485,7 +7516,7 @@ ASTContext::getQualifiedTemplateName(NestedNameSpecifier *NNS,
bool TemplateKeyword,
TemplateDecl *Template) const {
assert(NNS && "Missing nested-name-specifier in qualified template name");
-
+
// FIXME: Canonicalization?
llvm::FoldingSetNodeID ID;
QualifiedTemplateName::Profile(ID, NNS, TemplateKeyword, Template);
@@ -7540,22 +7571,22 @@ ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
/// Retrieve the template name that represents a dependent
/// template name such as \c MetaFun::template operator+.
-TemplateName
+TemplateName
ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
OverloadedOperatorKind Operator) const {
assert((!NNS || NNS->isDependent()) &&
"Nested name specifier must be dependent");
-
+
llvm::FoldingSetNodeID ID;
DependentTemplateName::Profile(ID, NNS, Operator);
void *InsertPos = nullptr;
DependentTemplateName *QTN
= DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
-
+
if (QTN)
return TemplateName(QTN);
-
+
NestedNameSpecifier *CanonNNS = getCanonicalNestedNameSpecifier(NNS);
if (CanonNNS == NNS) {
QTN = new (*this, alignof(DependentTemplateName))
@@ -7570,12 +7601,12 @@ ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
assert(!CheckQTN && "Dependent template name canonicalization broken");
(void)CheckQTN;
}
-
+
DependentTemplateNames.InsertNode(QTN, InsertPos);
return TemplateName(QTN);
}
-TemplateName
+TemplateName
ASTContext::getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
TemplateName replacement) const {
llvm::FoldingSetNodeID ID;
@@ -7584,7 +7615,7 @@ ASTContext::getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
void *insertPos = nullptr;
SubstTemplateTemplateParmStorage *subst
= SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
-
+
if (!subst) {
subst = new (*this) SubstTemplateTemplateParmStorage(param, replacement);
SubstTemplateTemplateParms.InsertNode(subst, insertPos);
@@ -7593,7 +7624,7 @@ ASTContext::getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param,
return TemplateName(subst);
}
-TemplateName
+TemplateName
ASTContext::getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
const TemplateArgument &ArgPack) const {
auto &Self = const_cast<ASTContext &>(*this);
@@ -7603,9 +7634,9 @@ ASTContext::getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
void *InsertPos = nullptr;
SubstTemplateTemplateParmPackStorage *Subst
= SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
-
+
if (!Subst) {
- Subst = new (*this) SubstTemplateTemplateParmPackStorage(Param,
+ Subst = new (*this) SubstTemplateTemplateParmPackStorage(Param,
ArgPack.pack_size(),
ArgPack.pack_begin());
SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
@@ -7725,12 +7756,12 @@ ASTContext::ProtocolCompatibleWithProtocol(ObjCProtocolDecl *lProto,
/// ObjCQualifiedClassTypesAreCompatible - compare Class<pr,...> and
/// Class<pr1, ...>.
-bool ASTContext::ObjCQualifiedClassTypesAreCompatible(QualType lhs,
+bool ASTContext::ObjCQualifiedClassTypesAreCompatible(QualType lhs,
QualType rhs) {
const auto *lhsQID = lhs->getAs<ObjCObjectPointerType>();
const auto *rhsOPT = rhs->getAs<ObjCObjectPointerType>();
assert((lhsQID && rhsOPT) && "ObjCQualifiedClassTypesAreCompatible");
-
+
for (auto *lhsProto : lhsQID->quals()) {
bool match = false;
for (auto *rhsProto : rhsOPT->quals()) {
@@ -7835,7 +7866,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
if (!match)
return false;
}
-
+
// Static class's protocols, or its super class or category protocols
// must be found, direct or indirect in rhs's qualifier list or it is a mismatch.
if (ObjCInterfaceDecl *lhsID = lhsOPT->getInterfaceDecl()) {
@@ -7897,12 +7928,12 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
QualType(RHSOPT,0),
false));
}
-
+
if (LHS->isObjCQualifiedClass() && RHS->isObjCQualifiedClass()) {
return finish(ObjCQualifiedClassTypesAreCompatible(QualType(LHSOPT,0),
QualType(RHSOPT,0)));
}
-
+
// If we have 2 user-defined types, fall into that path.
if (LHS->getInterface() && RHS->getInterface()) {
return finish(canAssignObjCInterfaces(LHS, RHS));
@@ -7912,7 +7943,7 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT,
}
/// canAssignObjCInterfacesInBlockPointer - This routine is specifically written
-/// for providing type-safety for objective-c pointers used to pass/return
+/// for providing type-safety for objective-c pointers used to pass/return
/// arguments in block literals. When passed as arguments, passing 'A*' where
/// 'id' is expected is not OK. Passing 'Sub *" where 'Super *" is expected is
/// not OK. For the return type, the opposite is not OK.
@@ -7941,17 +7972,17 @@ bool ASTContext::canAssignObjCInterfacesInBlockPointer(
if (RHSOPT->isObjCBuiltinType() || LHSOPT->isObjCIdType())
return true;
-
+
if (LHSOPT->isObjCBuiltinType()) {
return finish(RHSOPT->isObjCBuiltinType() ||
RHSOPT->isObjCQualifiedIdType());
}
-
+
if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType())
return finish(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.
@@ -7979,13 +8010,13 @@ static int compareObjCProtocolsByName(ObjCProtocolDecl * const *lhs,
/// the given common base.
/// It is used to build composite qualifier list of the composite type of
/// the conditional expression involving two objective-c pointer objects.
-static
+static
void getIntersectionOfProtocols(ASTContext &Context,
const ObjCInterfaceDecl *CommonBase,
const ObjCObjectPointerType *LHSOPT,
const ObjCObjectPointerType *RHSOPT,
SmallVectorImpl<ObjCProtocolDecl *> &IntersectionSet) {
-
+
const ObjCObjectType* LHS = LHSOPT->getObjectType();
const ObjCObjectType* RHS = RHSOPT->getObjectType();
assert(LHS->getInterface() && "LHS must have an interface base");
@@ -8254,7 +8285,7 @@ bool ASTContext::canAssignObjCInterfaces(const ObjCObjectType *LHS,
// If there is no protocols associated with RHS, it is not a match.
if (SuperClassInheritedProtocols.empty())
return false;
-
+
for (const auto *LHSProto : LHS->quals()) {
bool SuperImplementsProtocol = false;
for (auto *SuperClassProto : SuperClassInheritedProtocols)
@@ -8367,7 +8398,7 @@ QualType ASTContext::mergeFunctionParameterTypes(QualType lhs, QualType rhs,
return mergeTypes(lhs, rhs, OfBlockPointer, Unqualified);
}
-QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
+QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
bool OfBlockPointer,
bool Unqualified) {
const auto *lbase = lhs->getAs<FunctionType>();
@@ -8392,7 +8423,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
Unqualified);
if (retType.isNull())
return {};
-
+
if (Unqualified)
retType = retType.getUnqualifiedType();
@@ -8402,7 +8433,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
LRetType = LRetType.getUnqualifiedType();
RRetType = RRetType.getUnqualifiedType();
}
-
+
if (getCanonicalType(retType) != LRetType)
allLTypes = false;
if (getCanonicalType(retType) != RRetType)
@@ -8491,7 +8522,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs,
if (getCanonicalType(paramType) != getCanonicalType(rParamType))
allRTypes = false;
}
-
+
if (allLTypes) return lhs;
if (allRTypes) return rhs;
@@ -8566,7 +8597,7 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET,
return {};
}
-QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
+QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
bool OfBlockPointer,
bool Unqualified, bool BlockReturnType) {
// C++ [expr]: If an expression initially has the type "reference to T", the
@@ -8581,7 +8612,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
LHS = LHS.getUnqualifiedType();
RHS = RHS.getUnqualifiedType();
}
-
+
QualType LHSCan = getCanonicalType(LHS),
RHSCan = getCanonicalType(RHS);
@@ -8663,7 +8694,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
if (RHS->isObjCIdType() && LHS->isBlockPointerType())
return RHS;
}
-
+
return {};
}
@@ -8700,7 +8731,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
LHSPointee = LHSPointee.getUnqualifiedType();
RHSPointee = RHSPointee.getUnqualifiedType();
}
- QualType ResultType = mergeTypes(LHSPointee, RHSPointee, false,
+ QualType ResultType = mergeTypes(LHSPointee, RHSPointee, false,
Unqualified);
if (ResultType.isNull())
return {};
@@ -8752,7 +8783,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
LHSValue = LHSValue.getUnqualifiedType();
RHSValue = RHSValue.getUnqualifiedType();
}
- QualType ResultType = mergeTypes(LHSValue, RHSValue, false,
+ QualType ResultType = mergeTypes(LHSValue, RHSValue, false,
Unqualified);
if (ResultType.isNull())
return {};
@@ -8775,7 +8806,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
LHSElem = LHSElem.getUnqualifiedType();
RHSElem = RHSElem.getUnqualifiedType();
}
-
+
QualType ResultType = mergeTypes(LHSElem, RHSElem, false, Unqualified);
if (ResultType.isNull())
return {};
@@ -8958,7 +8989,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
cast<FunctionType>(RHSCan.getTypePtr())->getReturnType();
QualType NewReturnType =
cast<FunctionType>(LHSCan.getTypePtr())->getReturnType();
- QualType ResReturnType =
+ QualType ResReturnType =
mergeObjCGCQualifiers(NewReturnType, OldReturnType);
if (ResReturnType.isNull())
return {};
@@ -8976,7 +9007,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
}
return {};
}
-
+
// If the qualifiers are different, the types can still be merged.
Qualifiers LQuals = LHSCan.getLocalQualifiers();
Qualifiers RQuals = RHSCan.getLocalQualifiers();
@@ -8985,7 +9016,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
LQuals.getAddressSpace() != RQuals.getAddressSpace())
return {};
-
+
// Exactly one GC qualifier difference is allowed: __strong is
// okay if the other type has no GC qualifier but is an Objective
// C object pointer (i.e. implicitly strong by default). We fix
@@ -8994,17 +9025,17 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
Qualifiers::GC GC_L = LQuals.getObjCGCAttr();
Qualifiers::GC GC_R = RQuals.getObjCGCAttr();
assert((GC_L != GC_R) && "unequal qualifier sets had only equal elements");
-
+
if (GC_L == Qualifiers::Weak || GC_R == Qualifiers::Weak)
return {};
-
+
if (GC_L == Qualifiers::Strong)
return LHS;
if (GC_R == Qualifiers::Strong)
return RHS;
return {};
}
-
+
if (LHSCan->isObjCObjectPointerType() && RHSCan->isObjCObjectPointerType()) {
QualType LHSBaseQT = LHS->getAs<ObjCObjectPointerType>()->getPointeeType();
QualType RHSBaseQT = RHS->getAs<ObjCObjectPointerType>()->getPointeeType();
@@ -9033,7 +9064,7 @@ unsigned ASTContext::getIntWidth(QualType T) const {
QualType ASTContext::getCorrespondingUnsignedType(QualType T) const {
assert((T->hasSignedIntegerRepresentation() || T->isSignedFixedPointType()) &&
"Unexpected type");
-
+
// Turn <4 x signed int> -> <4 x unsigned int>
if (const auto *VTy = T->getAs<VectorType>())
return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
@@ -9042,7 +9073,7 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) const {
// For enums, we return the unsigned version of the base type.
if (const auto *ETy = T->getAs<EnumType>())
T = ETy->getDecl()->getIntegerType();
-
+
const auto *BTy = T->getAs<BuiltinType>();
assert(BTy && "Unexpected signed integer or fixed point type");
switch (BTy->getKind()) {
@@ -9114,7 +9145,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
int HowLong = 0;
bool Signed = false, Unsigned = false;
RequiresICE = false;
-
+
// Read the prefixed modifiers first.
bool Done = false;
#ifndef NDEBUG
@@ -9278,10 +9309,10 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
assert(End != Str && "Missing vector size");
Str = End;
- QualType ElementType = DecodeTypeFromStr(Str, Context, Error,
+ QualType ElementType = DecodeTypeFromStr(Str, Context, Error,
RequiresICE, false);
assert(!RequiresICE && "Can't require vector ICE");
-
+
// TODO: No way to make AltiVec vectors in builtins yet.
Type = Context.getVectorType(ElementType, NumElements,
VectorType::GenericVector);
@@ -9289,16 +9320,16 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
}
case 'E': {
char *End;
-
+
unsigned NumElements = strtoul(Str, &End, 10);
assert(End != Str && "Missing vector size");
-
+
Str = End;
-
+
QualType ElementType = DecodeTypeFromStr(Str, Context, Error, RequiresICE,
false);
Type = Context.getExtVectorType(ElementType, NumElements);
- break;
+ break;
}
case 'X': {
QualType ElementType = DecodeTypeFromStr(Str, Context, Error, RequiresICE,
@@ -9306,7 +9337,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
assert(!RequiresICE && "Can't require complex ICE");
Type = Context.getComplexType(ElementType);
break;
- }
+ }
case 'Y':
Type = Context.getPointerDiffType();
break;
@@ -9376,9 +9407,9 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
break;
}
}
-
+
assert((!RequiresICE || Type->isIntegralOrEnumerationType()) &&
- "Integer constant 'I' type must be an integer");
+ "Integer constant 'I' type must be an integer");
return Type;
}
@@ -9397,9 +9428,9 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
RequiresICE, true);
if (Error != GE_None)
return {};
-
+
assert(!RequiresICE && "Result of intrinsic cannot be required to be an ICE");
-
+
while (TypeStr[0] && TypeStr[0] != '.') {
QualType Ty = DecodeTypeFromStr(TypeStr, *this, Error, RequiresICE, true);
if (Error != GE_None)
@@ -9409,7 +9440,7 @@ QualType ASTContext::GetBuiltinType(unsigned Id,
// caller cares, fill in the bitmask we return.
if (RequiresICE && IntegerConstantArgs)
*IntegerConstantArgs |= 1 << ArgTypes.size();
-
+
// Do array -> pointer decay. The builtin should use the decayed type.
if (Ty->isArrayType())
Ty = getArrayDecayedType(Ty);
@@ -9504,21 +9535,6 @@ static GVALinkage basicGVALinkageForFunction(const ASTContext &Context,
return GVA_DiscardableODR;
}
-static bool isDeclareTargetToDeclaration(const Decl *VD) {
- for (const Decl *D : VD->redecls()) {
- if (!D->hasAttrs())
- continue;
- if (const auto *Attr = D->getAttr<OMPDeclareTargetDeclAttr>())
- return Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_To;
- }
- if (const auto *V = dyn_cast<VarDecl>(VD)) {
- if (const VarDecl *TD = V->getTemplateInstantiationPattern())
- return isDeclareTargetToDeclaration(TD);
- }
-
- return false;
-}
-
static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
const Decl *D, GVALinkage L) {
// See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
@@ -9535,12 +9551,6 @@ static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context,
// visible externally so they can be launched from host.
if (L == GVA_DiscardableODR || L == GVA_Internal)
return GVA_StrongODR;
- } else if (Context.getLangOpts().OpenMP && Context.getLangOpts().OpenMPIsDevice &&
- isDeclareTargetToDeclaration(D)) {
- // Static variables must be visible externally so they can be mapped from
- // host.
- if (L == GVA_Internal)
- return GVA_StrongODR;
}
return L;
}
@@ -10006,7 +10016,7 @@ void ASTContext::setParameterIndex(const ParmVarDecl *D, unsigned int index) {
unsigned ASTContext::getParameterIndex(const ParmVarDecl *D) const {
ParameterIndexTable::const_iterator I = ParamIndices.find(D);
- assert(I != ParamIndices.end() &&
+ assert(I != ParamIndices.end() &&
"ParmIndices lacks entry set by ParmVarDecl");
return I->second;
}
@@ -10240,10 +10250,10 @@ ASTContext::ObjCMethodsAreEqual(const ObjCMethodDecl *MethodDecl,
return false;
if (!hasSameType(MethodDecl->getReturnType(), MethodImpl->getReturnType()))
return false;
-
+
if (MethodDecl->param_size() != MethodImpl->param_size())
return false;
-
+
for (ObjCMethodDecl::param_const_iterator IM = MethodImpl->param_begin(),
IF = MethodDecl->param_begin(), EM = MethodImpl->param_end(),
EF = MethodDecl->param_end();
diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp
index c4c0f6e5ebe3..50d2d2999e51 100644
--- a/lib/AST/ASTDiagnostic.cpp
+++ b/lib/AST/ASTDiagnostic.cpp
@@ -200,7 +200,7 @@ break; \
return QC.apply(Context, QT);
}
-/// Convert the given type to a string suitable for printing as part of
+/// Convert the given type to a string suitable for printing as part of
/// a diagnostic.
///
/// There are four main criteria when determining whether we should have an
@@ -254,7 +254,7 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
// and the desugared comparison string.
std::string CompareCanS =
CompareCanTy.getAsString(Context.getPrintingPolicy());
-
+
if (CompareCanS == CanS)
continue; // No new info from canonical type
@@ -327,11 +327,11 @@ void clang::FormatASTNodeDiagnosticArgument(
void *Cookie,
ArrayRef<intptr_t> QualTypeVals) {
ASTContext &Context = *static_cast<ASTContext*>(Cookie);
-
+
size_t OldEnd = Output.size();
llvm::raw_svector_ostream OS(Output);
bool NeedQuotes = true;
-
+
switch (Kind) {
default: llvm_unreachable("unknown ArgumentKind");
case DiagnosticsEngine::ak_qualtype_pair: {
@@ -365,7 +365,7 @@ void clang::FormatASTNodeDiagnosticArgument(
case DiagnosticsEngine::ak_qualtype: {
assert(Modifier.empty() && Argument.empty() &&
"Invalid modifier for QualType argument");
-
+
QualType Ty(QualType::getFromOpaquePtr(reinterpret_cast<void*>(Val)));
OS << ConvertTypeToDiagnosticString(Context, Ty, PrevArgs, QualTypeVals);
NeedQuotes = false;
@@ -2040,7 +2040,7 @@ public:
/// is successful.
static bool FormatTemplateTypeDiff(ASTContext &Context, QualType FromType,
QualType ToType, bool PrintTree,
- bool PrintFromType, bool ElideType,
+ bool PrintFromType, bool ElideType,
bool ShowColors, raw_ostream &OS) {
if (PrintTree)
PrintFromType = true;
diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp
index f46ae58d192d..8a653ecebae3 100644
--- a/lib/AST/ASTDumper.cpp
+++ b/lib/AST/ASTDumper.cpp
@@ -1966,7 +1966,7 @@ void ASTDumper::dumpStmt(const Stmt *S) {
}
void ASTDumper::VisitStmt(const Stmt *Node) {
- {
+ {
ColorScope Color(*this, StmtColor);
OS << Node->getStmtClassName();
}
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 6668067233e4..b360b3910636 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -221,8 +221,8 @@ namespace clang {
QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
// Importing declarations
- bool ImportDeclParts(NamedDecl *D, DeclContext *&DC,
- DeclContext *&LexicalDC, DeclarationName &Name,
+ bool ImportDeclParts(NamedDecl *D, DeclContext *&DC,
+ DeclContext *&LexicalDC, DeclarationName &Name,
NamedDecl *&ToD, SourceLocation &Loc);
void ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD = nullptr);
void ImportDeclarationNameLoc(const DeclarationNameInfo &From,
@@ -237,9 +237,9 @@ namespace clang {
Designator ImportDesignator(const Designator &D);
Optional<LambdaCapture> ImportLambdaCapture(const LambdaCapture &From);
-
+
/// What we should import from the definition.
- enum ImportDefinitionKind {
+ enum ImportDefinitionKind {
/// Import the default subset of the definition, which might be
/// nothing (if minimal import is set) or might be everything (if minimal
/// import is not set).
@@ -258,7 +258,7 @@ namespace clang {
(IDK == IDK_Default && !Importer.isMinimalImport());
}
- bool ImportDefinition(RecordDecl *From, RecordDecl *To,
+ bool ImportDefinition(RecordDecl *From, RecordDecl *To,
ImportDefinitionKind Kind = IDK_Default);
bool ImportDefinition(VarDecl *From, VarDecl *To,
ImportDefinitionKind Kind = IDK_Default);
@@ -600,21 +600,21 @@ QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
// context supports ObjC.
case BuiltinType::Char_U:
- // The context we're importing from has an unsigned 'char'. If we're
- // importing into a context with a signed 'char', translate to
+ // The context we're importing from has an unsigned 'char'. If we're
+ // importing into a context with a signed 'char', translate to
// 'unsigned char' instead.
if (Importer.getToContext().getLangOpts().CharIsSigned)
return Importer.getToContext().UnsignedCharTy;
-
+
return Importer.getToContext().CharTy;
case BuiltinType::Char_S:
- // The context we're importing from has an unsigned 'char'. If we're
- // importing into a context with a signed 'char', translate to
+ // The context we're importing from has an unsigned 'char'. If we're
+ // importing into a context with a signed 'char', translate to
// 'unsigned char' instead.
if (!Importer.getToContext().getLangOpts().CharIsSigned)
return Importer.getToContext().SignedCharTy;
-
+
return Importer.getToContext().CharTy;
case BuiltinType::WChar_S:
@@ -639,7 +639,7 @@ QualType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return {};
-
+
return Importer.getToContext().getComplexType(ToElementType);
}
@@ -647,7 +647,7 @@ QualType ASTNodeImporter::VisitPointerType(const PointerType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
return {};
-
+
return Importer.getToContext().getPointerType(ToPointeeType);
}
@@ -656,7 +656,7 @@ QualType ASTNodeImporter::VisitBlockPointerType(const BlockPointerType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
return {};
-
+
return Importer.getToContext().getBlockPointerType(ToPointeeType);
}
@@ -666,7 +666,7 @@ ASTNodeImporter::VisitLValueReferenceType(const LValueReferenceType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
if (ToPointeeType.isNull())
return {};
-
+
return Importer.getToContext().getLValueReferenceType(ToPointeeType);
}
@@ -676,8 +676,8 @@ ASTNodeImporter::VisitRValueReferenceType(const RValueReferenceType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
if (ToPointeeType.isNull())
return {};
-
- return Importer.getToContext().getRValueReferenceType(ToPointeeType);
+
+ return Importer.getToContext().getRValueReferenceType(ToPointeeType);
}
QualType ASTNodeImporter::VisitMemberPointerType(const MemberPointerType *T) {
@@ -685,9 +685,9 @@ QualType ASTNodeImporter::VisitMemberPointerType(const MemberPointerType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
return {};
-
+
QualType ClassType = Importer.Import(QualType(T->getClass(), 0));
- return Importer.getToContext().getMemberPointerType(ToPointeeType,
+ return Importer.getToContext().getMemberPointerType(ToPointeeType,
ClassType.getTypePtr());
}
@@ -695,8 +695,8 @@ QualType ASTNodeImporter::VisitConstantArrayType(const ConstantArrayType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return {};
-
- return Importer.getToContext().getConstantArrayType(ToElementType,
+
+ return Importer.getToContext().getConstantArrayType(ToElementType,
T->getSize(),
T->getSizeModifier(),
T->getIndexTypeCVRQualifiers());
@@ -707,8 +707,8 @@ ASTNodeImporter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return {};
-
- return Importer.getToContext().getIncompleteArrayType(ToElementType,
+
+ return Importer.getToContext().getIncompleteArrayType(ToElementType,
T->getSizeModifier(),
T->getIndexTypeCVRQualifiers());
}
@@ -721,7 +721,7 @@ QualType ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
Expr *Size = Importer.Import(T->getSizeExpr());
if (!Size)
return {};
-
+
SourceRange Brackets = Importer.Import(T->getBracketsRange());
return Importer.getToContext().getVariableArrayType(ToElementType, Size,
T->getSizeModifier(),
@@ -751,8 +751,8 @@ QualType ASTNodeImporter::VisitVectorType(const VectorType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return {};
-
- return Importer.getToContext().getVectorType(ToElementType,
+
+ return Importer.getToContext().getVectorType(ToElementType,
T->getNumElements(),
T->getVectorKind());
}
@@ -761,14 +761,14 @@ QualType ASTNodeImporter::VisitExtVectorType(const ExtVectorType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return {};
-
- return Importer.getToContext().getExtVectorType(ToElementType,
+
+ return Importer.getToContext().getExtVectorType(ToElementType,
T->getNumElements());
}
QualType
ASTNodeImporter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
- // FIXME: What happens if we're importing a function without a prototype
+ // FIXME: What happens if we're importing a function without a prototype
// into C++? Should we make it variadic?
QualType ToResultType = Importer.Import(T->getReturnType());
if (ToResultType.isNull())
@@ -782,7 +782,7 @@ QualType ASTNodeImporter::VisitFunctionProtoType(const FunctionProtoType *T) {
QualType ToResultType = Importer.Import(T->getReturnType());
if (ToResultType.isNull())
return {};
-
+
// Import argument types
SmallVector<QualType, 4> ArgTypes;
for (const auto &A : T->param_types()) {
@@ -791,7 +791,7 @@ QualType ASTNodeImporter::VisitFunctionProtoType(const FunctionProtoType *T) {
return {};
ArgTypes.push_back(ArgType);
}
-
+
// Import exception types
SmallVector<QualType, 4> ExceptionTypes;
for (const auto &E : T->exceptions()) {
@@ -841,7 +841,7 @@ QualType ASTNodeImporter::VisitParenType(const ParenType *T) {
QualType ToInnerType = Importer.Import(T->getInnerType());
if (ToInnerType.isNull())
return {};
-
+
return Importer.getToContext().getParenType(ToInnerType);
}
@@ -850,7 +850,7 @@ QualType ASTNodeImporter::VisitTypedefType(const TypedefType *T) {
dyn_cast_or_null<TypedefNameDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)
return {};
-
+
return Importer.getToContext().getTypeDeclType(ToDecl);
}
@@ -858,7 +858,7 @@ QualType ASTNodeImporter::VisitTypeOfExprType(const TypeOfExprType *T) {
Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
if (!ToExpr)
return {};
-
+
return Importer.getToContext().getTypeOfExprType(ToExpr);
}
@@ -866,7 +866,7 @@ QualType ASTNodeImporter::VisitTypeOfType(const TypeOfType *T) {
QualType ToUnderlyingType = Importer.Import(T->getUnderlyingType());
if (ToUnderlyingType.isNull())
return {};
-
+
return Importer.getToContext().getTypeOfType(ToUnderlyingType);
}
@@ -875,7 +875,7 @@ QualType ASTNodeImporter::VisitDecltypeType(const DecltypeType *T) {
Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
if (!ToExpr)
return {};
-
+
QualType UnderlyingType = Importer.Import(T->getUnderlyingType());
if (UnderlyingType.isNull())
return {};
@@ -903,7 +903,7 @@ QualType ASTNodeImporter::VisitAutoType(const AutoType *T) {
if (ToDeduced.isNull())
return {};
}
-
+
return Importer.getToContext().getAutoType(ToDeduced, T->getKeyword(),
/*IsDependent*/false);
}
@@ -1000,20 +1000,20 @@ QualType ASTNodeImporter::VisitTemplateSpecializationType(
TemplateName ToTemplate = Importer.Import(T->getTemplateName());
if (ToTemplate.isNull())
return {};
-
+
SmallVector<TemplateArgument, 2> ToTemplateArgs;
if (ImportTemplateArguments(T->getArgs(), T->getNumArgs(), ToTemplateArgs))
return {};
-
+
QualType ToCanonType;
if (!QualType(T, 0).isCanonical()) {
- QualType FromCanonType
+ QualType FromCanonType
= Importer.getFromContext().getCanonicalType(QualType(T, 0));
ToCanonType =Importer.Import(FromCanonType);
if (ToCanonType.isNull())
return {};
}
- return Importer.getToContext().getTemplateSpecializationType(ToTemplate,
+ return Importer.getToContext().getTemplateSpecializationType(ToTemplate,
ToTemplateArgs,
ToCanonType);
}
@@ -1136,9 +1136,9 @@ ASTNodeImporter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
//----------------------------------------------------------------------------
// Import Declarations
//----------------------------------------------------------------------------
-bool ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclContext *&DC,
- DeclContext *&LexicalDC,
- DeclarationName &Name,
+bool ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclContext *&DC,
+ DeclContext *&LexicalDC,
+ DeclarationName &Name,
NamedDecl *&ToD,
SourceLocation &Loc) {
// Check if RecordDecl is in FunctionDecl parameters to avoid infinite loop.
@@ -1163,19 +1163,19 @@ bool ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclContext *&DC,
DC = Importer.ImportContext(OrigDC);
if (!DC)
return true;
-
+
LexicalDC = DC;
if (D->getDeclContext() != D->getLexicalDeclContext()) {
LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
if (!LexicalDC)
return true;
}
-
+
// Import the name of this declaration.
Name = Importer.Import(D->getDeclName());
if (D->getDeclName() && !Name)
return true;
-
+
// Import the location of this declaration.
Loc = Importer.Import(D->getLocation());
ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
@@ -1185,13 +1185,13 @@ bool ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclContext *&DC,
void ASTNodeImporter::ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD) {
if (!FromD)
return;
-
+
if (!ToD) {
ToD = Importer.Import(FromD);
if (!ToD)
return;
}
-
+
if (auto *FromRecord = dyn_cast<RecordDecl>(FromD)) {
if (auto *ToRecord = cast_or_null<RecordDecl>(ToD)) {
if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() && !ToRecord->getDefinition()) {
@@ -1246,12 +1246,12 @@ ASTNodeImporter::ImportDeclarationNameLoc(const DeclarationNameInfo &From,
llvm_unreachable("Unknown name kind.");
}
-void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
+void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
if (Importer.isMinimalImport() && !ForceImport) {
Importer.ImportContext(FromDC);
return;
}
-
+
for (auto *From : FromDC->decls())
Importer.Import(From);
}
@@ -1260,7 +1260,7 @@ void ASTNodeImporter::ImportImplicitMethods(
const CXXRecordDecl *From, CXXRecordDecl *To) {
assert(From->isCompleteDefinition() && To->getDefinition() == To &&
"Import implicit methods to or from non-definition");
-
+
for (CXXMethodDecl *FromM : From->methods())
if (FromM->isImplicit())
Importer.Import(FromM);
@@ -1277,19 +1277,19 @@ static void setTypedefNameForAnonDecl(TagDecl *From, TagDecl *To,
}
}
-bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To,
+bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To,
ImportDefinitionKind Kind) {
if (To->getDefinition() || To->isBeingDefined()) {
if (Kind == IDK_Everything)
ImportDeclContext(From, /*ForceImport=*/true);
-
+
return false;
}
-
+
To->startDefinition();
setTypedefNameForAnonDecl(From, To, Importer);
-
+
// Add base classes.
if (auto *ToCXX = dyn_cast<CXXRecordDecl>(To)) {
auto *FromCXX = cast<CXXRecordDecl>(From);
@@ -1374,9 +1374,9 @@ bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To,
// Ensure that we have a definition for the base.
ImportDefinitionIfNeeded(Base1.getType()->getAsCXXRecordDecl());
-
+
Bases.push_back(
- new (Importer.getToContext())
+ new (Importer.getToContext())
CXXBaseSpecifier(Importer.Import(Base1.getSourceRange()),
Base1.isVirtual(),
Base1.isBaseOfClass(),
@@ -1387,10 +1387,10 @@ bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To,
if (!Bases.empty())
ToCXX->setBases(Bases.data(), Bases.size());
}
-
+
if (shouldForceImportDeclContext(Kind))
ImportDeclContext(From, /*ForceImport=*/true);
-
+
To->completeDefinition();
return false;
}
@@ -1410,14 +1410,14 @@ bool ASTNodeImporter::ImportDefinition(VarDecl *From, VarDecl *To,
return false;
}
-bool ASTNodeImporter::ImportDefinition(EnumDecl *From, EnumDecl *To,
+bool ASTNodeImporter::ImportDefinition(EnumDecl *From, EnumDecl *To,
ImportDefinitionKind Kind) {
if (To->getDefinition() || To->isBeingDefined()) {
if (Kind == IDK_Everything)
ImportDeclContext(From, /*ForceImport=*/true);
return false;
}
-
+
To->startDefinition();
setTypedefNameForAnonDecl(From, To, Importer);
@@ -1425,14 +1425,14 @@ bool ASTNodeImporter::ImportDefinition(EnumDecl *From, EnumDecl *To,
QualType T = Importer.Import(Importer.getFromContext().getTypeDeclType(From));
if (T.isNull())
return true;
-
+
QualType ToPromotionType = Importer.Import(From->getPromotionType());
if (ToPromotionType.isNull())
return true;
if (shouldForceImportDeclContext(Kind))
ImportDeclContext(From, /*ForceImport=*/true);
-
+
// FIXME: we might need to merge the number of positive or negative bits
// if the enumerator lists don't match.
To->completeDefinition(T, ToPromotionType,
@@ -1446,7 +1446,7 @@ TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList(
SmallVector<NamedDecl *, 4> ToParams(Params->size());
if (ImportContainerChecked(*Params, ToParams))
return nullptr;
-
+
Expr *ToRequiresClause;
if (Expr *const R = Params->getRequiresClause()) {
ToRequiresClause = Importer.Import(R);
@@ -1464,19 +1464,19 @@ TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList(
ToRequiresClause);
}
-TemplateArgument
+TemplateArgument
ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) {
switch (From.getKind()) {
case TemplateArgument::Null:
return TemplateArgument();
-
+
case TemplateArgument::Type: {
QualType ToType = Importer.Import(From.getAsType());
if (ToType.isNull())
return {};
return TemplateArgument(ToType);
}
-
+
case TemplateArgument::Integral: {
QualType ToType = Importer.Import(From.getIntegralType());
if (ToType.isNull())
@@ -1503,16 +1503,16 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) {
TemplateName ToTemplate = Importer.Import(From.getAsTemplate());
if (ToTemplate.isNull())
return {};
-
+
return TemplateArgument(ToTemplate);
}
case TemplateArgument::TemplateExpansion: {
- TemplateName ToTemplate
+ TemplateName ToTemplate
= Importer.Import(From.getAsTemplateOrTemplatePattern());
if (ToTemplate.isNull())
return {};
-
+
return TemplateArgument(ToTemplate, From.getNumTemplateExpansions());
}
@@ -1520,7 +1520,7 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) {
if (Expr *ToExpr = Importer.Import(From.getAsExpr()))
return TemplateArgument(ToExpr);
return TemplateArgument();
-
+
case TemplateArgument::Pack: {
SmallVector<TemplateArgument, 2> ToPack;
ToPack.reserve(From.pack_size());
@@ -1531,7 +1531,7 @@ ASTNodeImporter::ImportTemplateArgument(const TemplateArgument &From) {
llvm::makeArrayRef(ToPack).copy(Importer.getToContext()));
}
}
-
+
llvm_unreachable("Invalid template argument kind");
}
@@ -1566,10 +1566,10 @@ bool ASTNodeImporter::ImportTemplateArguments(const TemplateArgument *FromArgs,
TemplateArgument To = ImportTemplateArgument(FromArgs[I]);
if (To.isNull() && !FromArgs[I].isNull())
return true;
-
+
ToArgs.push_back(To);
}
-
+
return false;
}
@@ -1714,11 +1714,11 @@ Decl *ASTNodeImporter::VisitEmptyDecl(EmptyDecl *D) {
}
Decl *ASTNodeImporter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
- TranslationUnitDecl *ToD =
+ TranslationUnitDecl *ToD =
Importer.getToContext().getTranslationUnitDecl();
-
+
Importer.MapImported(D, ToD);
-
+
return ToD;
}
@@ -1801,23 +1801,23 @@ Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
for (auto *FoundDecl : FoundDecls) {
if (!FoundDecl->isInIdentifierNamespace(Decl::IDNS_Namespace))
continue;
-
+
if (auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
MergeWithNamespace = FoundNS;
ConflictingDecls.clear();
break;
}
-
+
ConflictingDecls.push_back(FoundDecl);
}
-
+
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, Decl::IDNS_Namespace,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
}
}
-
+
// Create the "to" namespace, if needed.
NamespaceDecl *ToNamespace = MergeWithNamespace;
if (!ToNamespace) {
@@ -1828,7 +1828,7 @@ Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
return ToNamespace;
ToNamespace->setLexicalDeclContext(LexicalDC);
LexicalDC->addDeclInternal(ToNamespace);
-
+
// If this is an anonymous namespace, register it as the anonymous
// namespace within its context.
if (!Name) {
@@ -1839,9 +1839,9 @@ Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
}
}
Importer.MapImported(D, ToNamespace);
-
+
ImportDeclContext(D);
-
+
return ToNamespace;
}
@@ -1918,7 +1918,7 @@ Decl *ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) {
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
if (!Name)
return nullptr;
@@ -2076,7 +2076,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
IDNS = Decl::IDNS_Ordinary;
} else if (Importer.getToContext().getLangOpts().CPlusPlus)
IDNS |= Decl::IDNS_Ordinary;
-
+
// We may already have an enum of the same name; try to find and match it.
if (!DC->isFunctionOrMethod() && SearchName) {
SmallVector<NamedDecl *, 4> ConflictingDecls;
@@ -2085,24 +2085,24 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
for (auto *FoundDecl : FoundDecls) {
if (!FoundDecl->isInIdentifierNamespace(IDNS))
continue;
-
+
Decl *Found = FoundDecl;
if (auto *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
if (const auto *Tag = Typedef->getUnderlyingType()->getAs<TagType>())
Found = Tag->getDecl();
}
-
+
if (auto *FoundEnum = dyn_cast<EnumDecl>(Found)) {
if (IsStructuralMatch(D, FoundEnum))
return Importer.MapImported(D, FoundEnum);
}
-
+
ConflictingDecls.push_back(FoundDecl);
}
-
+
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
}
}
@@ -2126,7 +2126,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
if (ToIntegerType.isNull())
return nullptr;
D2->setIntegerType(ToIntegerType);
-
+
// Import the definition
if (D->isCompleteDefinition() && ImportDefinition(D, D2))
return nullptr;
@@ -2189,7 +2189,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
for (auto *FoundDecl : FoundDecls) {
if (!FoundDecl->isInIdentifierNamespace(IDNS))
continue;
-
+
Decl *Found = FoundDecl;
if (auto *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
if (const auto *Tag = Typedef->getUnderlyingType()->getAs<TagType>())
@@ -2237,38 +2237,38 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
} else if (!D->isCompleteDefinition()) {
// We have a forward declaration of this type, so adopt that forward
// declaration rather than building a new one.
-
+
// If one or both can be completed from external storage then try one
// last time to complete and compare them before doing this.
-
+
if (FoundRecord->hasExternalLexicalStorage() &&
!FoundRecord->isCompleteDefinition())
FoundRecord->getASTContext().getExternalSource()->CompleteType(FoundRecord);
if (D->hasExternalLexicalStorage())
D->getASTContext().getExternalSource()->CompleteType(D);
-
+
if (FoundRecord->isCompleteDefinition() &&
D->isCompleteDefinition() &&
!IsStructuralMatch(D, FoundRecord))
continue;
-
+
AdoptDecl = FoundRecord;
continue;
} else if (!SearchName) {
continue;
}
}
-
+
ConflictingDecls.push_back(FoundDecl);
}
-
+
if (!ConflictingDecls.empty() && SearchName) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
}
}
-
+
// Create the record declaration.
RecordDecl *D2 = AdoptDecl;
SourceLocation StartLoc = Importer.Import(D->getLocStart());
@@ -2392,7 +2392,7 @@ Decl *ASTNodeImporter::VisitEnumConstantDecl(EnumConstantDecl *D) {
if (T.isNull())
return nullptr;
- // Determine whether there are any other declarations with the same name and
+ // Determine whether there are any other declarations with the same name and
// in the same context.
if (!LexicalDC->isFunctionOrMethod()) {
SmallVector<NamedDecl *, 4> ConflictingDecls;
@@ -2410,16 +2410,16 @@ Decl *ASTNodeImporter::VisitEnumConstantDecl(EnumConstantDecl *D) {
ConflictingDecls.push_back(FoundDecl);
}
-
+
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
if (!Name)
return nullptr;
}
}
-
+
Expr *Init = Importer.Import(D->getInitExpr());
if (D->getInitExpr() && !Init)
return nullptr;
@@ -2608,7 +2608,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
// Complain about inconsistent function types.
Importer.ToDiag(Loc, diag::err_odr_function_type_inconsistent)
<< Name << D->getType() << FoundFunction->getType();
- Importer.ToDiag(FoundFunction->getLocation(),
+ Importer.ToDiag(FoundFunction->getLocation(),
diag::note_odr_value_here)
<< FoundFunction->getType();
}
@@ -2619,11 +2619,11 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
if (!Name)
return nullptr;
- }
+ }
}
DeclarationNameInfo NameInfo(Name, Loc);
@@ -2663,7 +2663,7 @@ Decl *ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
Parameters.push_back(ToP);
}
-
+
TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
if (D->getTypeSourceInfo() && !TInfo)
return nullptr;
@@ -2851,7 +2851,7 @@ Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) {
if (ToD)
return ToD;
- // Determine whether we've already imported this field.
+ // Determine whether we've already imported this field.
SmallVector<NamedDecl *, 2> FoundDecls;
DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
for (auto *FoundDecl : FoundDecls) {
@@ -2916,7 +2916,7 @@ Decl *ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) {
if (ToD)
return ToD;
- // Determine whether we've already imported this field.
+ // Determine whether we've already imported this field.
SmallVector<NamedDecl *, 2> FoundDecls;
DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
@@ -3153,7 +3153,7 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) {
<< FoundVar->getType();
}
}
-
+
ConflictingDecls.push_back(FoundDecl);
}
@@ -3165,7 +3165,7 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) {
if (VarDecl *DDef = D->getDefinition()) {
if (VarDecl *ExistingDef = MergeWithVar->getDefinition()) {
- Importer.ToDiag(ExistingDef->getLocation(),
+ Importer.ToDiag(ExistingDef->getLocation(),
diag::err_odr_variable_multiple_def)
<< Name;
Importer.FromDiag(DDef->getLocation(), diag::note_odr_defined_here);
@@ -3179,19 +3179,19 @@ Decl *ASTNodeImporter::VisitVarDecl(VarDecl *D) {
}
}
}
-
+
return MergeWithVar;
}
-
+
if (!ConflictingDecls.empty()) {
Name = Importer.HandleNameConflict(Name, DC, IDNS,
- ConflictingDecls.data(),
+ ConflictingDecls.data(),
ConflictingDecls.size());
if (!Name)
return nullptr;
}
}
-
+
// Import the type.
QualType T = Importer.Import(D->getType());
if (T.isNull())
@@ -3228,7 +3228,7 @@ Decl *ASTNodeImporter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
// Parameters are created in the translation unit's context, then moved
// into the function declaration's context afterward.
DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
-
+
// Import the name of this declaration.
DeclarationName Name = Importer.Import(D->getDeclName());
if (D->getDeclName() && !Name)
@@ -3236,7 +3236,7 @@ Decl *ASTNodeImporter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
// Import the location of this declaration.
SourceLocation Loc = Importer.Import(D->getLocation());
-
+
// Import the parameter's type.
QualType T = Importer.Import(D->getType());
if (T.isNull())
@@ -3255,7 +3255,7 @@ Decl *ASTNodeImporter::VisitParmVarDecl(ParmVarDecl *D) {
// Parameters are created in the translation unit's context, then moved
// into the function declaration's context afterward.
DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
-
+
// Import the name of this declaration.
DeclarationName Name = Importer.Import(D->getDeclName());
if (D->getDeclName() && !Name)
@@ -3263,7 +3263,7 @@ Decl *ASTNodeImporter::VisitParmVarDecl(ParmVarDecl *D) {
// Import the location of this declaration.
SourceLocation Loc = Importer.Import(D->getLocation());
-
+
// Import the parameter's type.
QualType T = Importer.Import(D->getType());
if (T.isNull())
@@ -3334,7 +3334,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Importer.ToDiag(Loc, diag::err_odr_objc_method_result_type_inconsistent)
<< D->isInstanceMethod() << Name << D->getReturnType()
<< FoundMethod->getReturnType();
- Importer.ToDiag(FoundMethod->getLocation(),
+ Importer.ToDiag(FoundMethod->getLocation(),
diag::note_odr_objc_method_here)
<< D->isInstanceMethod() << Name;
return nullptr;
@@ -3345,7 +3345,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Importer.ToDiag(Loc, diag::err_odr_objc_method_num_params_inconsistent)
<< D->isInstanceMethod() << Name
<< D->param_size() << FoundMethod->param_size();
- Importer.ToDiag(FoundMethod->getLocation(),
+ Importer.ToDiag(FoundMethod->getLocation(),
diag::note_odr_objc_method_here)
<< D->isInstanceMethod() << Name;
return nullptr;
@@ -3372,7 +3372,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
if (D->isVariadic() != FoundMethod->isVariadic()) {
Importer.ToDiag(Loc, diag::err_odr_objc_method_variadic_inconsistent)
<< D->isInstanceMethod() << Name;
- Importer.ToDiag(FoundMethod->getLocation(),
+ Importer.ToDiag(FoundMethod->getLocation(),
diag::note_odr_objc_method_here)
<< D->isInstanceMethod() << Name;
return nullptr;
@@ -3411,7 +3411,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
ToParams.push_back(ToP);
}
-
+
// Set the parameters.
for (auto *ToParam : ToParams) {
ToParam->setOwningFunction(ToMethod);
@@ -3494,7 +3494,7 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
// loops when bringing in their DeclContext.
ToCategory->setTypeParamList(ImportObjCTypeParamList(
D->getTypeParamList()));
-
+
// Import protocols
SmallVector<ObjCProtocolDecl *, 4> Protocols;
SmallVector<SourceLocation, 4> ProtocolLocs;
@@ -3511,17 +3511,17 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
Protocols.push_back(ToProto);
ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
}
-
+
// FIXME: If we're merging, make sure that the protocol list is the same.
ToCategory->setProtocolList(Protocols.data(), Protocols.size(),
ProtocolLocs.data(), Importer.getToContext());
} else {
Importer.MapImported(D, ToCategory);
}
-
+
// Import all of the members of this category.
ImportDeclContext(D);
-
+
// If we have an implementation, import it as well.
if (D->getImplementation()) {
auto *Impl =
@@ -3532,11 +3532,11 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
ToCategory->setImplementation(Impl);
}
-
+
return ToCategory;
}
-bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
+bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
ObjCProtocolDecl *To,
ImportDefinitionKind Kind) {
if (To->getDefinition()) {
@@ -3547,11 +3547,11 @@ bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
// Start the protocol definition
To->startDefinition();
-
+
// Import protocols
SmallVector<ObjCProtocolDecl *, 4> Protocols;
SmallVector<SourceLocation, 4> ProtocolLocs;
- ObjCProtocolDecl::protocol_loc_iterator
+ ObjCProtocolDecl::protocol_loc_iterator
FromProtoLoc = From->protocol_loc_begin();
for (ObjCProtocolDecl::protocol_iterator FromProto = From->protocol_begin(),
FromProtoEnd = From->protocol_end();
@@ -3563,7 +3563,7 @@ bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
Protocols.push_back(ToProto);
ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
}
-
+
// FIXME: If we're merging, make sure that the protocol list is the same.
To->setProtocolList(Protocols.data(), Protocols.size(),
ProtocolLocs.data(), Importer.getToContext());
@@ -3576,7 +3576,7 @@ bool ASTNodeImporter::ImportDefinition(ObjCProtocolDecl *From,
}
Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
- // If this protocol has a definition in the translation unit we're coming
+ // If this protocol has a definition in the translation unit we're coming
// from, but this particular declaration is not that definition, import the
// definition and map to that.
ObjCProtocolDecl *Definition = D->getDefinition();
@@ -3604,11 +3604,11 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
for (auto *FoundDecl : FoundDecls) {
if (!FoundDecl->isInIdentifierNamespace(Decl::IDNS_ObjCProtocol))
continue;
-
+
if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
break;
}
-
+
ObjCProtocolDecl *ToProto = MergeWithProtocol;
if (!ToProto) {
if (GetImportedOrCreateDecl(ToProto, D, Importer.getToContext(), DC,
@@ -3831,7 +3831,7 @@ Decl *ASTNodeImporter::VisitUnresolvedUsingTypenameDecl(
return ToUsing;
}
-bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
+bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
ObjCInterfaceDecl *To,
ImportDefinitionKind Kind) {
if (To->getDefinition()) {
@@ -3842,36 +3842,36 @@ bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
if (!FromSuper)
return true;
}
-
- ObjCInterfaceDecl *ToSuper = To->getSuperClass();
+
+ ObjCInterfaceDecl *ToSuper = To->getSuperClass();
if ((bool)FromSuper != (bool)ToSuper ||
(FromSuper && !declaresSameEntity(FromSuper, ToSuper))) {
- Importer.ToDiag(To->getLocation(),
+ Importer.ToDiag(To->getLocation(),
diag::err_odr_objc_superclass_inconsistent)
<< To->getDeclName();
if (ToSuper)
Importer.ToDiag(To->getSuperClassLoc(), diag::note_odr_objc_superclass)
<< To->getSuperClass()->getDeclName();
else
- Importer.ToDiag(To->getLocation(),
+ Importer.ToDiag(To->getLocation(),
diag::note_odr_objc_missing_superclass);
if (From->getSuperClass())
- Importer.FromDiag(From->getSuperClassLoc(),
+ Importer.FromDiag(From->getSuperClassLoc(),
diag::note_odr_objc_superclass)
<< From->getSuperClass()->getDeclName();
else
- Importer.FromDiag(From->getLocation(),
- diag::note_odr_objc_missing_superclass);
+ Importer.FromDiag(From->getLocation(),
+ diag::note_odr_objc_missing_superclass);
}
-
+
if (shouldForceImportDeclContext(Kind))
ImportDeclContext(From);
return false;
}
-
+
// Start the definition.
To->startDefinition();
-
+
// If this class has a superclass, import it.
if (From->getSuperClass()) {
TypeSourceInfo *SuperTInfo = Importer.Import(From->getSuperClassTInfo());
@@ -3880,13 +3880,13 @@ bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
To->setSuperClass(SuperTInfo);
}
-
+
// Import protocols
SmallVector<ObjCProtocolDecl *, 4> Protocols;
SmallVector<SourceLocation, 4> ProtocolLocs;
- ObjCInterfaceDecl::protocol_loc_iterator
+ ObjCInterfaceDecl::protocol_loc_iterator
FromProtoLoc = From->protocol_loc_begin();
-
+
for (ObjCInterfaceDecl::protocol_iterator FromProto = From->protocol_begin(),
FromProtoEnd = From->protocol_end();
FromProto != FromProtoEnd;
@@ -3897,23 +3897,23 @@ bool ASTNodeImporter::ImportDefinition(ObjCInterfaceDecl *From,
Protocols.push_back(ToProto);
ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
}
-
+
// FIXME: If we're merging, make sure that the protocol list is the same.
To->setProtocolList(Protocols.data(), Protocols.size(),
ProtocolLocs.data(), Importer.getToContext());
-
+
// Import categories. When the categories themselves are imported, they'll
// hook themselves into this interface.
for (auto *Cat : From->known_categories())
Importer.Import(Cat);
-
+
// If we have an @implementation, import it as well.
if (From->getImplementation()) {
auto *Impl = cast_or_null<ObjCImplementationDecl>(
Importer.Import(From->getImplementation()));
if (!Impl)
return true;
-
+
To->setImplementation(Impl);
}
@@ -3975,11 +3975,11 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
for (auto *FoundDecl : FoundDecls) {
if (!FoundDecl->isInIdentifierNamespace(Decl::IDNS_Ordinary))
continue;
-
+
if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
break;
}
-
+
// Create an interface declaration, if one does not already exist.
ObjCInterfaceDecl *ToIface = MergeWithIface;
if (!ToIface) {
@@ -3997,7 +3997,7 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
// loops when bringing in their DeclContext.
ToIface->setTypeParamList(ImportObjCTypeParamList(
D->getTypeParamListAsWritten()));
-
+
if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToIface))
return nullptr;
@@ -4032,11 +4032,11 @@ Decl *ASTNodeImporter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
ToImpl->setLexicalDeclContext(LexicalDC);
}
-
+
LexicalDC->addDeclInternal(ToImpl);
Category->setImplementation(ToImpl);
}
-
+
Importer.MapImported(D, ToImpl);
ImportDeclContext(D);
return ToImpl;
@@ -4113,7 +4113,7 @@ Decl *ASTNodeImporter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
return nullptr;
}
}
-
+
// Import all of the members of this @implementation.
ImportDeclContext(D);
@@ -4235,10 +4235,10 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
// Check that we have the same kind of property implementation (@synthesize
// vs. @dynamic).
if (D->getPropertyImplementation() != ToImpl->getPropertyImplementation()) {
- Importer.ToDiag(ToImpl->getLocation(),
+ Importer.ToDiag(ToImpl->getLocation(),
diag::err_odr_objc_property_impl_kind_inconsistent)
- << Property->getDeclName()
- << (ToImpl->getPropertyImplementation()
+ << Property->getDeclName()
+ << (ToImpl->getPropertyImplementation()
== ObjCPropertyImplDecl::Dynamic);
Importer.FromDiag(D->getLocation(),
diag::note_odr_objc_property_impl_kind)
@@ -4246,25 +4246,25 @@ Decl *ASTNodeImporter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
<< (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic);
return nullptr;
}
-
- // For @synthesize, check that we have the same
+
+ // For @synthesize, check that we have the same
if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize &&
Ivar != ToImpl->getPropertyIvarDecl()) {
- Importer.ToDiag(ToImpl->getPropertyIvarDeclLoc(),
+ Importer.ToDiag(ToImpl->getPropertyIvarDeclLoc(),
diag::err_odr_objc_synthesize_ivar_inconsistent)
<< Property->getDeclName()
<< ToImpl->getPropertyIvarDecl()->getDeclName()
<< Ivar->getDeclName();
- Importer.FromDiag(D->getPropertyIvarDeclLoc(),
+ Importer.FromDiag(D->getPropertyIvarDeclLoc(),
diag::note_odr_objc_synthesize_ivar_here)
<< D->getPropertyIvarDecl()->getDeclName();
return nullptr;
}
-
+
// Merge the existing implementation with the new implementation.
Importer.MapImported(D, ToImpl);
}
-
+
return ToImpl;
}
@@ -4272,7 +4272,7 @@ Decl *ASTNodeImporter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
// For template arguments, we adopt the translation unit as our declaration
// context. This context will be fixed when the actual template declaration
// is created.
-
+
// FIXME: Import default argument.
TemplateTypeParmDecl *ToD = nullptr;
(void)GetImportedOrCreateDecl(
@@ -4444,16 +4444,16 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
return D2;
ToTemplated->setDescribedClassTemplate(D2);
-
+
D2->setAccess(D->getAccess());
D2->setLexicalDeclContext(LexicalDC);
LexicalDC->addDeclInternal(D2);
-
+
if (FromTemplated->isCompleteDefinition() &&
!ToTemplated->isCompleteDefinition()) {
// FIXME: Import definition!
}
-
+
return D2;
}
@@ -4488,14 +4488,14 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl(
if (!LexicalDC)
return nullptr;
}
-
+
// Import the location of this declaration.
SourceLocation StartLoc = Importer.Import(D->getLocStart());
SourceLocation IdLoc = Importer.Import(D->getLocation());
// Import template arguments.
SmallVector<TemplateArgument, 2> TemplateArgs;
- if (ImportTemplateArguments(D->getTemplateArgs().data(),
+ if (ImportTemplateArguments(D->getTemplateArgs().data(),
D->getTemplateArgs().size(),
TemplateArgs))
return nullptr;
@@ -4507,9 +4507,9 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl(
if (D2) {
// We already have a class template specialization with these template
// arguments.
-
+
// FIXME: Check for specialization vs. instantiation errors.
-
+
if (RecordDecl *FoundDef = D2->getDefinition()) {
if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
// The record types structurally match, or the "from" translation
@@ -4557,7 +4557,7 @@ Decl *ASTNodeImporter::VisitClassTemplateSpecializationDecl(
// Add this specialization to the class template.
ClassTemplate->AddSpecialization(D2, InsertPos);
-
+
// Import the qualifier, if any.
D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
@@ -5484,7 +5484,7 @@ Expr *ASTNodeImporter::VisitDeclRefExpr(DeclRefExpr *E) {
if (!FoundD)
return nullptr;
}
-
+
QualType T = Importer.Import(E->getType());
if (T.isNull())
return nullptr;
@@ -5497,7 +5497,7 @@ Expr *ASTNodeImporter::VisitDeclRefExpr(DeclRefExpr *E) {
ResInfo = &ToTAInfo;
}
- DeclRefExpr *DRE = DeclRefExpr::Create(Importer.getToContext(),
+ DeclRefExpr *DRE = DeclRefExpr::Create(Importer.getToContext(),
Importer.Import(E->getQualifierLoc()),
Importer.Import(E->getTemplateKeywordLoc()),
ToD,
@@ -5583,7 +5583,7 @@ Expr *ASTNodeImporter::VisitIntegerLiteral(IntegerLiteral *E) {
if (T.isNull())
return nullptr;
- return IntegerLiteral::Create(Importer.getToContext(),
+ return IntegerLiteral::Create(Importer.getToContext(),
E->getValue(), T,
Importer.Import(E->getLocation()));
}
@@ -5674,7 +5674,7 @@ Expr *ASTNodeImporter::VisitParenExpr(ParenExpr *E) {
if (!SubExpr)
return nullptr;
- return new (Importer.getToContext())
+ return new (Importer.getToContext())
ParenExpr(Importer.Import(E->getLParen()),
Importer.Import(E->getRParen()),
SubExpr);
@@ -5721,7 +5721,7 @@ Expr *ASTNodeImporter::VisitUnaryOperator(UnaryOperator *E) {
Expr *
ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
QualType ResultType = Importer.Import(E->getType());
-
+
if (E->isArgumentType()) {
TypeSourceInfo *TInfo = Importer.Import(E->getArgumentTypeInfo());
if (!TInfo)
@@ -5732,7 +5732,7 @@ ASTNodeImporter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
Importer.Import(E->getOperatorLoc()),
Importer.Import(E->getRParenLoc()));
}
-
+
Expr *SubExpr = Importer.Import(E->getArgumentExpr());
if (!SubExpr)
return nullptr;
@@ -5904,7 +5904,7 @@ Expr *ASTNodeImporter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
if (!RHS)
return nullptr;
- return new (Importer.getToContext())
+ return new (Importer.getToContext())
CompoundAssignOperator(LHS, RHS, E->getOpcode(),
T, E->getValueKind(),
E->getObjectKind(),
@@ -6354,11 +6354,11 @@ Expr *ASTNodeImporter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
QualType T = Importer.Import(E->getType());
if (T.isNull())
return nullptr;
-
+
Expr *ToFn = Importer.Import(E->getCallee());
if (!ToFn)
return nullptr;
-
+
SmallVector<Expr *, 4> ToArgs(E->getNumArgs());
if (ImportContainerChecked(E->arguments(), ToArgs))
return nullptr;
@@ -6372,7 +6372,7 @@ Expr *ASTNodeImporter::VisitCXXThisExpr(CXXThisExpr *E) {
QualType T = Importer.Import(E->getType());
if (T.isNull())
return nullptr;
-
+
return new (Importer.getToContext())
CXXThisExpr(Importer.Import(E->getLocation()), T, E->isImplicit());
}
@@ -6381,7 +6381,7 @@ Expr *ASTNodeImporter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
QualType T = Importer.Import(E->getType());
if (T.isNull())
return nullptr;
-
+
return new (Importer.getToContext())
CXXBoolLiteralExpr(E->getValue(), T, Importer.Import(E->getLocation()));
}
@@ -6646,7 +6646,7 @@ Expr *ASTNodeImporter::VisitCallExpr(CallExpr *E) {
}
return new (Importer.getToContext())
- CallExpr(Importer.getToContext(), ToCallee,
+ CallExpr(Importer.getToContext(), ToCallee,
llvm::makeArrayRef(ToArgs_Copied, NumArgs), T, E->getValueKind(),
Importer.Import(E->getRParenLoc()));
}
@@ -6838,18 +6838,18 @@ Expr *ASTNodeImporter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
SourceLocation ToOperatorLoc = Importer.Import(E->getOperatorLoc());
SourceLocation ToRParenLoc = Importer.Import(E->getRParenLoc());
SourceRange ToAngleBrackets = Importer.Import(E->getAngleBrackets());
-
+
if (isa<CXXStaticCastExpr>(E)) {
return CXXStaticCastExpr::Create(
- Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
+ Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
} else if (isa<CXXDynamicCastExpr>(E)) {
return CXXDynamicCastExpr::Create(
- Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
+ Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
} else if (isa<CXXReinterpretCastExpr>(E)) {
return CXXReinterpretCastExpr::Create(
- Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
+ Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
} else {
return nullptr;
@@ -6943,22 +6943,22 @@ QualType ASTImporter::Import(QualType FromT) {
return {};
const Type *fromTy = FromT.getTypePtr();
-
- // Check whether we've already imported this type.
+
+ // Check whether we've already imported this type.
llvm::DenseMap<const Type *, const Type *>::iterator Pos
= ImportedTypes.find(fromTy);
if (Pos != ImportedTypes.end())
return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
-
+
// Import the type
ASTNodeImporter Importer(*this);
QualType ToT = Importer.Visit(fromTy);
if (ToT.isNull())
return ToT;
-
+
// Record the imported type.
ImportedTypes[fromTy] = ToT.getTypePtr();
-
+
return ToContext.getQualifiedType(ToT, FromT.getLocalQualifiers());
}
@@ -6972,7 +6972,7 @@ TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
if (T.isNull())
return nullptr;
- return ToContext.getTrivialTypeSourceInfo(T,
+ return ToContext.getTrivialTypeSourceInfo(T,
Import(FromTSI->getTypeLoc().getLocStart()));
}
@@ -7027,7 +7027,7 @@ DeclContext *ASTImporter::ImportContext(DeclContext *FromDC) {
if (!ToDC)
return nullptr;
- // When we're using a record/enum/Objective-C class/protocol as a context, we
+ // When we're using a record/enum/Objective-C class/protocol as a context, we
// need it to have a definition.
if (auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
auto *FromRecord = cast<RecordDecl>(FromDC);
@@ -7048,7 +7048,7 @@ DeclContext *ASTImporter::ImportContext(DeclContext *FromDC) {
ASTNodeImporter::IDK_Basic);
} else {
CompleteDecl(ToEnum);
- }
+ }
} else if (auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
if (ToClass->getDefinition()) {
@@ -7068,9 +7068,9 @@ DeclContext *ASTImporter::ImportContext(DeclContext *FromDC) {
ASTNodeImporter::IDK_Basic);
} else {
CompleteDecl(ToProto);
- }
+ }
}
-
+
return ToDC;
}
@@ -7085,11 +7085,11 @@ Stmt *ASTImporter::Import(Stmt *FromS) {
if (!FromS)
return nullptr;
- // Check whether we've already imported this declaration.
+ // Check whether we've already imported this declaration.
llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
if (Pos != ImportedStmts.end())
return Pos->second;
-
+
// Import the type
ASTNodeImporter Importer(*this);
Stmt *ToS = Importer.Visit(FromS);
@@ -7115,14 +7115,14 @@ NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) {
return nullptr;
case NestedNameSpecifier::Namespace:
- if (auto *NS =
+ if (auto *NS =
cast_or_null<NamespaceDecl>(Import(FromNNS->getAsNamespace()))) {
return NestedNameSpecifier::Create(ToContext, prefix, NS);
}
return nullptr;
case NestedNameSpecifier::NamespaceAlias:
- if (auto *NSAD =
+ if (auto *NSAD =
cast_or_null<NamespaceAliasDecl>(Import(FromNNS->getAsNamespaceAlias()))) {
return NestedNameSpecifier::Create(ToContext, prefix, NSAD);
}
@@ -7142,9 +7142,9 @@ NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) {
case NestedNameSpecifier::TypeSpecWithTemplate: {
QualType T = Import(QualType(FromNNS->getAsType(), 0u));
if (!T.isNull()) {
- bool bTemplate = FromNNS->getKind() ==
+ bool bTemplate = FromNNS->getKind() ==
NestedNameSpecifier::TypeSpecWithTemplate;
- return NestedNameSpecifier::Create(ToContext, prefix,
+ return NestedNameSpecifier::Create(ToContext, prefix,
bTemplate, T.getTypePtr());
}
}
@@ -7231,48 +7231,48 @@ TemplateName ASTImporter::Import(TemplateName From) {
if (auto *ToTemplate =
cast_or_null<TemplateDecl>(Import(From.getAsTemplateDecl())))
return TemplateName(ToTemplate);
-
+
return {};
-
+
case TemplateName::OverloadedTemplate: {
OverloadedTemplateStorage *FromStorage = From.getAsOverloadedTemplate();
UnresolvedSet<2> ToTemplates;
for (auto *I : *FromStorage) {
- if (auto *To = cast_or_null<NamedDecl>(Import(I)))
+ if (auto *To = cast_or_null<NamedDecl>(Import(I)))
ToTemplates.addDecl(To);
else
return {};
}
- return ToContext.getOverloadedTemplateName(ToTemplates.begin(),
+ return ToContext.getOverloadedTemplateName(ToTemplates.begin(),
ToTemplates.end());
}
-
+
case TemplateName::QualifiedTemplate: {
QualifiedTemplateName *QTN = From.getAsQualifiedTemplateName();
NestedNameSpecifier *Qualifier = Import(QTN->getQualifier());
if (!Qualifier)
return {};
-
+
if (auto *ToTemplate =
cast_or_null<TemplateDecl>(Import(From.getAsTemplateDecl())))
- return ToContext.getQualifiedTemplateName(Qualifier,
- QTN->hasTemplateKeyword(),
+ return ToContext.getQualifiedTemplateName(Qualifier,
+ QTN->hasTemplateKeyword(),
ToTemplate);
return {};
}
-
+
case TemplateName::DependentTemplate: {
DependentTemplateName *DTN = From.getAsDependentTemplateName();
NestedNameSpecifier *Qualifier = Import(DTN->getQualifier());
if (!Qualifier)
return {};
-
+
if (DTN->isIdentifier()) {
- return ToContext.getDependentTemplateName(Qualifier,
+ return ToContext.getDependentTemplateName(Qualifier,
Import(DTN->getIdentifier()));
}
-
+
return ToContext.getDependentTemplateName(Qualifier, DTN->getOperator());
}
@@ -7287,10 +7287,10 @@ TemplateName ASTImporter::Import(TemplateName From) {
TemplateName replacement = Import(subst->getReplacement());
if (replacement.isNull())
return {};
-
+
return ToContext.getSubstTemplateTemplateParm(param, replacement);
}
-
+
case TemplateName::SubstTemplateTemplateParmPack: {
SubstTemplateTemplateParmPackStorage *SubstPack
= From.getAsSubstTemplateTemplateParmPack();
@@ -7299,17 +7299,17 @@ TemplateName ASTImporter::Import(TemplateName From) {
Import(SubstPack->getParameterPack()));
if (!Param)
return {};
-
+
ASTNodeImporter Importer(*this);
- TemplateArgument ArgPack
+ TemplateArgument ArgPack
= Importer.ImportTemplateArgument(SubstPack->getArgumentPack());
if (ArgPack.isNull())
return {};
-
+
return ToContext.getSubstTemplateTemplateParmPack(Param, ArgPack);
}
}
-
+
llvm_unreachable("Invalid template name kind");
}
@@ -7452,26 +7452,26 @@ void ASTImporter::ImportDefinition(Decl *From) {
Decl *To = Import(From);
if (!To)
return;
-
+
if (auto *FromDC = cast<DeclContext>(From)) {
ASTNodeImporter Importer(*this);
-
+
if (auto *ToRecord = dyn_cast<RecordDecl>(To)) {
if (!ToRecord->getDefinition()) {
- Importer.ImportDefinition(cast<RecordDecl>(FromDC), ToRecord,
+ Importer.ImportDefinition(cast<RecordDecl>(FromDC), ToRecord,
ASTNodeImporter::IDK_Everything);
return;
- }
+ }
}
if (auto *ToEnum = dyn_cast<EnumDecl>(To)) {
if (!ToEnum->getDefinition()) {
- Importer.ImportDefinition(cast<EnumDecl>(FromDC), ToEnum,
+ Importer.ImportDefinition(cast<EnumDecl>(FromDC), ToEnum,
ASTNodeImporter::IDK_Everything);
return;
- }
+ }
}
-
+
if (auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
if (!ToIFace->getDefinition()) {
Importer.ImportDefinition(cast<ObjCInterfaceDecl>(FromDC), ToIFace,
@@ -7487,7 +7487,7 @@ void ASTImporter::ImportDefinition(Decl *From) {
return;
}
}
-
+
Importer.ImportDeclContext(FromDC, true);
}
}
diff --git a/lib/AST/ASTStructuralEquivalence.cpp b/lib/AST/ASTStructuralEquivalence.cpp
index 7853ab28810b..df3c2be9a2e2 100644
--- a/lib/AST/ASTStructuralEquivalence.cpp
+++ b/lib/AST/ASTStructuralEquivalence.cpp
@@ -505,7 +505,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
if (Proto1->getTypeQuals() != Proto2->getTypeQuals())
return false;
-
+
// Check exceptions, this information is lost in canonical type.
const auto *OrigProto1 =
cast<FunctionProtoType>(OrigT1.getDesugaredType(Context.FromCtx));
@@ -513,7 +513,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
cast<FunctionProtoType>(OrigT2.getDesugaredType(Context.ToCtx));
auto Spec1 = OrigProto1->getExceptionSpecType();
auto Spec2 = OrigProto2->getExceptionSpecType();
-
+
if (Spec1 != Spec2)
return false;
if (Spec1 == EST_Dynamic) {
diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp
index 2825329775ed..a0b22b6a85e0 100644
--- a/lib/AST/CXXInheritance.cpp
+++ b/lib/AST/CXXInheritance.cpp
@@ -99,7 +99,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
CXXBasePaths &Paths) const {
if (getCanonicalDecl() == Base->getCanonicalDecl())
return false;
-
+
Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
@@ -120,7 +120,7 @@ bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {
if (getCanonicalDecl() == Base->getCanonicalDecl())
return false;
-
+
Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
@@ -165,7 +165,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
continue;
}
- CXXRecordDecl *Base =
+ CXXRecordDecl *Base =
cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition());
if (!Base ||
(Base->isDependentContext() &&
@@ -174,7 +174,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches,
AllMatches = false;
continue;
}
-
+
Queue.push_back(Base);
if (!BaseMatches(Base)) {
if (AllowShortCircuit) return false;
@@ -209,12 +209,12 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
// C++ [temp.dep]p3:
// In the definition of a class template or a member of a class template,
// if a base class of the class template depends on a template-parameter,
- // the base class scope is not examined during unqualified name lookup
- // either at the point of definition of the class template or member or
+ // the base class scope is not examined during unqualified name lookup
+ // either at the point of definition of the class template or member or
// during an instantiation of the class tem- plate or member.
if (!LookupInDependent && BaseType->isDependentType())
continue;
-
+
// Determine whether we need to visit this base class at all,
// updating the count of subobjects appropriately.
IsVirtBaseAndNumberNonVirtBases &Subobjects = ClassSubobjects[BaseType];
@@ -261,13 +261,13 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
if (IsFirstStep)
ScratchPath.Access = BaseSpec.getAccessSpecifier();
else
- ScratchPath.Access = CXXRecordDecl::MergeAccess(AccessToHere,
+ ScratchPath.Access = CXXRecordDecl::MergeAccess(AccessToHere,
BaseSpec.getAccessSpecifier());
}
-
+
// Track whether there's a path involving this specific base.
bool FoundPathThroughBase = false;
-
+
if (BaseMatches(&BaseSpec, ScratchPath)) {
// We've found a path that terminates at this base.
FoundPath = FoundPathThroughBase = true;
@@ -313,15 +313,15 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
// a sub-object A if A is a base class sub-object of B. Any
// declarations that are so hidden are eliminated from
// consideration.
-
- // There is a path to a base class that meets the criteria. If we're
+
+ // There is a path to a base class that meets the criteria. If we're
// not collecting paths or finding ambiguities, we're done.
FoundPath = FoundPathThroughBase = true;
if (!isFindingAmbiguities())
return FoundPath;
}
}
-
+
// Pop this base specifier off the current path (if we're
// collecting paths).
if (isRecordingPaths()) {
@@ -336,7 +336,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
// Reset the scratch path access.
ScratchPath.Access = AccessToHere;
-
+
return FoundPath;
}
@@ -352,7 +352,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches,
// we're done.
if (!Paths.isRecordingPaths() || !Paths.isFindingAmbiguities())
return true;
-
+
// C++ [class.member.lookup]p6:
// When virtual base classes are used, a hidden declaration can be
// reached along a path through the sub-object lattice that does
@@ -396,7 +396,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches,
return true;
}
-bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier,
+bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path,
const CXXRecordDecl *BaseRecord) {
assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
@@ -405,7 +405,7 @@ bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier,
->getCanonicalDecl() == BaseRecord;
}
-bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
+bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path,
const CXXRecordDecl *BaseRecord) {
assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
@@ -415,7 +415,7 @@ bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier,
->getCanonicalDecl() == BaseRecord;
}
-bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier,
+bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path,
DeclarationName Name) {
RecordDecl *BaseRecord =
@@ -490,12 +490,12 @@ bool CXXRecordDecl::FindOMPReductionMember(const CXXBaseSpecifier *Specifier,
}
bool CXXRecordDecl::
-FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier,
+FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier,
CXXBasePath &Path,
DeclarationName Name) {
RecordDecl *BaseRecord =
Specifier->getType()->castAs<RecordType>()->getDecl();
-
+
for (Path.Decls = BaseRecord->lookup(Name);
!Path.Decls.empty();
Path.Decls = Path.Decls.slice(1)) {
@@ -504,7 +504,7 @@ FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier,
Path.Decls.front()->isInIdentifierNamespace(IDNS_Tag))
return true;
}
-
+
return false;
}
@@ -538,20 +538,20 @@ std::vector<const NamedDecl *> CXXRecordDecl::lookupDependentName(
return Results;
}
-void OverridingMethods::add(unsigned OverriddenSubobject,
+void OverridingMethods::add(unsigned OverriddenSubobject,
UniqueVirtualMethod Overriding) {
SmallVectorImpl<UniqueVirtualMethod> &SubobjectOverrides
= Overrides[OverriddenSubobject];
- if (std::find(SubobjectOverrides.begin(), SubobjectOverrides.end(),
+ if (std::find(SubobjectOverrides.begin(), SubobjectOverrides.end(),
Overriding) == SubobjectOverrides.end())
SubobjectOverrides.push_back(Overriding);
}
void OverridingMethods::add(const OverridingMethods &Other) {
for (const_iterator I = Other.begin(), IE = Other.end(); I != IE; ++I) {
- for (overriding_const_iterator M = I->second.begin(),
+ for (overriding_const_iterator M = I->second.begin(),
MEnd = I->second.end();
- M != MEnd;
+ M != MEnd;
++M)
add(I->first, *M);
}
@@ -586,7 +586,7 @@ public:
} // namespace
-void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
+void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
bool VirtualBase,
const CXXRecordDecl *InVirtualSubobject,
CXXFinalOverriderMap &Overriders) {
@@ -633,7 +633,7 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
// Merge the overriders from this base class into our own set of
// overriders.
- for (CXXFinalOverriderMap::iterator OM = BaseOverriders->begin(),
+ for (CXXFinalOverriderMap::iterator OM = BaseOverriders->begin(),
OMEnd = BaseOverriders->end();
OM != OMEnd;
++OM) {
@@ -656,7 +656,7 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
if (OverriddenMethods.begin() == OverriddenMethods.end()) {
// This is a new virtual function that does not override any
// other virtual function. Add it to the map of virtual
- // functions for which we are tracking overridders.
+ // functions for which we are tracking overridders.
// C++ [class.virtual]p2:
// For convenience we say that any virtual function overrides itself.
@@ -711,12 +711,12 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD,
FinalOverriderCollector::~FinalOverriderCollector() {
for (llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *>::iterator
VO = VirtualOverriders.begin(), VOEnd = VirtualOverriders.end();
- VO != VOEnd;
+ VO != VOEnd;
++VO)
delete VO->second;
}
-void
+void
CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const {
FinalOverriderCollector Collector;
Collector.Collect(this, false, nullptr, FinalOverriders);
@@ -754,7 +754,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const {
}
}
-static void
+static void
AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context,
CXXIndirectPrimaryBaseSet& Bases) {
// If the record has a virtual primary base class, add it to our set.
@@ -777,7 +777,7 @@ AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context,
}
-void
+void
CXXRecordDecl::getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const {
ASTContext &Context = getASTContext();
diff --git a/lib/AST/Comment.cpp b/lib/AST/Comment.cpp
index dfa2a1665d40..0d759e226c42 100644
--- a/lib/AST/Comment.cpp
+++ b/lib/AST/Comment.cpp
@@ -205,7 +205,7 @@ void DeclInfo::fill() {
return;
}
CurrentDecl = CommentDecl;
-
+
Decl::Kind K = CommentDecl->getKind();
switch (K) {
default:
diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp
index 6ff4d45a9572..8d401ff5c7ea 100644
--- a/lib/AST/CommentLexer.cpp
+++ b/lib/AST/CommentLexer.cpp
@@ -274,7 +274,7 @@ const char *findCCommentEnd(const char *BufferPtr, const char *BufferEnd) {
}
llvm_unreachable("buffer end hit before '*/' was seen");
}
-
+
} // end anonymous namespace
void Lexer::formTokenWithChars(Token &Result, const char *TokEnd,
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 3b9b85a20af6..8030dd0c2f41 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -633,7 +633,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,
// equivalent in C99)
// The C++ modules TS adds "non-exported" to this list.
if (Context.getLangOpts().CPlusPlus &&
- Var->getType().isConstQualified() &&
+ Var->getType().isConstQualified() &&
!Var->getType().isVolatileQualified() &&
!Var->isInline() &&
!isExportedFromModuleIntefaceUnit(Var)) {
@@ -1049,7 +1049,7 @@ bool NamedDecl::isLinkageValid() const {
ObjCStringFormatFamily NamedDecl::getObjCFStringFormattingFamily() const {
StringRef name = getName();
if (name.empty()) return SFF_None;
-
+
if (name.front() == 'C')
if (name == "CFStringCreateWithFormat" ||
name == "CFStringCreateWithFormatAndArguments" ||
@@ -1338,7 +1338,7 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
case Decl::ObjCPropertyImpl:
case Decl::ObjCProtocol:
return getExternalLinkageFor(D);
-
+
case Decl::CXXRecord: {
const auto *Record = cast<CXXRecordDecl>(D);
if (Record->isLambda()) {
@@ -1348,25 +1348,25 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
}
// This lambda has its linkage/visibility determined:
- // - either by the outermost lambda if that lambda has no mangling
- // number.
+ // - either by the outermost lambda if that lambda has no mangling
+ // number.
// - or by the parent of the outer most lambda
- // This prevents infinite recursion in settings such as nested lambdas
- // used in NSDMI's, for e.g.
+ // This prevents infinite recursion in settings such as nested lambdas
+ // used in NSDMI's, for e.g.
// struct L {
// int t{};
- // int t2 = ([](int a) { return [](int b) { return b; };})(t)(t);
+ // int t2 = ([](int a) { return [](int b) { return b; };})(t)(t);
// };
- const CXXRecordDecl *OuterMostLambda =
+ const CXXRecordDecl *OuterMostLambda =
getOutermostEnclosingLambda(Record);
if (!OuterMostLambda->getLambdaManglingNumber())
return getInternalLinkageFor(D);
-
+
return getLVForClosure(
OuterMostLambda->getDeclContext()->getRedeclContext(),
OuterMostLambda->getLambdaContextDecl(), computation);
}
-
+
break;
}
}
@@ -1374,7 +1374,7 @@ LinkageInfo LinkageComputer::computeLVForDecl(const NamedDecl *D,
// Handle linkage for namespace-scope names.
if (D->getDeclContext()->getRedeclContext()->isFileContext())
return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);
-
+
// C++ [basic.link]p5:
// In addition, a member function, static data member, a named
// class or enumeration of class scope, or an unnamed class or
@@ -1718,7 +1718,7 @@ NamedDecl *NamedDecl::getUnderlyingDeclImpl() {
bool NamedDecl::isCXXInstanceMember() const {
if (!isCXXClassMember())
return false;
-
+
const NamedDecl *D = this;
if (isa<UsingShadowDecl>(D))
D = cast<UsingShadowDecl>(D)->getTargetDecl();
@@ -1938,7 +1938,7 @@ VarDecl::TLSKind VarDecl::getTLSKind() const {
SourceRange VarDecl::getSourceRange() const {
if (const Expr *Init = getInit()) {
SourceLocation InitEnd = Init->getLocEnd();
- // If Init is implicit, ignore its source range and fallback on
+ // If Init is implicit, ignore its source range and fallback on
// DeclaratorDecl::getSourceRange() to handle postfix elements.
if (InitEnd.isValid() && InitEnd != getLocation())
return SourceRange(getOuterLocStart(), InitEnd);
@@ -2174,11 +2174,11 @@ bool VarDecl::isOutOfLine() const {
return false;
// If this static data member was instantiated from a static data member of
- // a class template, check whether that static data member was defined
+ // a class template, check whether that static data member was defined
// out-of-line.
if (VarDecl *VD = getInstantiatedFromStaticDataMember())
return VD->isOutOfLine();
-
+
return false;
}
@@ -2891,7 +2891,7 @@ FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch");
FunTmpl->setPreviousDecl(PrevFunTmpl);
}
-
+
if (PrevDecl && PrevDecl->IsInline)
IsInline = true;
}
@@ -3043,7 +3043,7 @@ static bool RedeclForcesDefC99(const FunctionDecl *Redecl) {
if (Redecl->isImplicit())
return false;
- if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern)
+ if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern)
return true; // Not an inline definition
return false;
@@ -3088,7 +3088,7 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
if (!Prev->isInlineSpecified() ||
Prev->getStorageClass() != SC_Extern)
return false;
- } else if (Prev->isInlineSpecified() &&
+ } else if (Prev->isInlineSpecified() &&
Prev->getStorageClass() != SC_Extern) {
return false;
}
@@ -3100,8 +3100,8 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
return false;
// C99 6.7.4p6:
- // [...] If all of the file scope declarations for a function in a
- // translation unit include the inline function specifier without extern,
+ // [...] If all of the file scope declarations for a function in a
+ // translation unit include the inline function specifier without extern,
// then the definition in that translation unit is an inline definition.
if (isInlineSpecified() && getStorageClass() != SC_Extern)
return false;
@@ -3149,12 +3149,9 @@ SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
const Attr *FunctionDecl::getUnusedResultAttr() const {
QualType RetType = getReturnType();
- if (RetType->isRecordType()) {
- if (const auto *Ret =
- dyn_cast_or_null<RecordDecl>(RetType->getAsTagDecl())) {
- if (const auto *R = Ret->getAttr<WarnUnusedResultAttr>())
- return R;
- }
+ if (const auto *Ret = RetType->getAsRecordDecl()) {
+ if (const auto *R = Ret->getAttr<WarnUnusedResultAttr>())
+ return R;
} else if (const auto *ET = RetType->getAs<EnumType>()) {
if (const EnumDecl *ED = ET->getDecl()) {
if (const auto *R = ED->getAttr<WarnUnusedResultAttr>())
@@ -3177,16 +3174,16 @@ const Attr *FunctionDecl::getUnusedResultAttr() const {
/// inline definition becomes externally visible (C99 6.7.4p6).
///
/// In GNU89 mode, or if the gnu_inline attribute is attached to the function
-/// definition, we use the GNU semantics for inline, which are nearly the
-/// opposite of C99 semantics. In particular, "inline" by itself will create
-/// an externally visible symbol, but "extern inline" will not create an
+/// definition, we use the GNU semantics for inline, which are nearly the
+/// opposite of C99 semantics. In particular, "inline" by itself will create
+/// an externally visible symbol, but "extern inline" will not create an
/// externally visible symbol.
bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
"Must be a function definition");
assert(isInlined() && "Function must be inline");
ASTContext &Context = getASTContext();
-
+
if (Context.getLangOpts().GNUInline || hasAttr<GNUInlineAttr>()) {
// Note: If you change the logic here, please change
// doesDeclarationForceExternallyVisibleDefinition as well.
@@ -3196,15 +3193,15 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
// externally visible.
if (!(isInlineSpecified() && getStorageClass() == SC_Extern))
return true;
-
+
// If any declaration is 'inline' but not 'extern', then this definition
// is externally visible.
for (auto Redecl : redecls()) {
- if (Redecl->isInlineSpecified() &&
+ if (Redecl->isInlineSpecified() &&
Redecl->getStorageClass() != SC_Extern)
return true;
- }
-
+ }
+
return false;
}
@@ -3213,17 +3210,17 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
"should not use C inline rules in C++");
// C99 6.7.4p6:
- // [...] If all of the file scope declarations for a function in a
- // translation unit include the inline function specifier without extern,
+ // [...] If all of the file scope declarations for a function in a
+ // translation unit include the inline function specifier without extern,
// then the definition in that translation unit is an inline definition.
for (auto Redecl : redecls()) {
if (RedeclForcesDefC99(Redecl))
return true;
}
-
+
// C99 6.7.4p6:
- // An inline definition does not provide an external definition for the
- // function, and does not forbid an external definition in another
+ // An inline definition does not provide an external definition for the
+ // function, and does not forbid an external definition in another
// translation unit.
return false;
}
@@ -3273,13 +3270,13 @@ MemberSpecializationInfo *FunctionDecl::getMemberSpecializationInfo() const {
return TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo *>();
}
-void
+void
FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,
FunctionDecl *FD,
TemplateSpecializationKind TSK) {
- assert(TemplateOrSpecialization.isNull() &&
+ assert(TemplateOrSpecialization.isNull() &&
"Member function is already a specialization");
- MemberSpecializationInfo *Info
+ MemberSpecializationInfo *Info
= new (C) MemberSpecializationInfo(FD, TSK);
TemplateOrSpecialization = Info;
}
@@ -3296,12 +3293,12 @@ bool FunctionDecl::isImplicitlyInstantiable() const {
// If the function is invalid, it can't be implicitly instantiated.
if (isInvalidDecl())
return false;
-
+
switch (getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ExplicitInstantiationDefinition:
return false;
-
+
case TSK_ImplicitInstantiation:
return true;
@@ -3320,12 +3317,12 @@ bool FunctionDecl::isImplicitlyInstantiable() const {
bool HasPattern = false;
if (PatternDecl)
HasPattern = PatternDecl->hasBody(PatternDecl);
-
+
// C++0x [temp.explicit]p9:
// Except for inline functions, other explicit instantiation declarations
// have the effect of suppressing the implicit instantiation of the entity
- // to which they refer.
- if (!HasPattern || !PatternDecl)
+ // to which they refer.
+ if (!HasPattern || !PatternDecl)
return true;
return PatternDecl->isInlined();
@@ -3335,7 +3332,7 @@ bool FunctionDecl::isTemplateInstantiation() const {
switch (getTemplateSpecializationKind()) {
case TSK_Undeclared:
case TSK_ExplicitSpecialization:
- return false;
+ return false;
case TSK_ImplicitInstantiation:
case TSK_ExplicitInstantiationDeclaration:
case TSK_ExplicitInstantiationDefinition:
@@ -3343,7 +3340,7 @@ bool FunctionDecl::isTemplateInstantiation() const {
}
llvm_unreachable("All TSK values handled.");
}
-
+
FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
// Handle class scope explicit specialization special case.
if (getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
@@ -3352,13 +3349,13 @@ FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
return nullptr;
}
- // If this is a generic lambda call operator specialization, its
+ // If this is a generic lambda call operator specialization, its
// instantiation pattern is always its primary template's pattern
- // even if its primary template was instantiated from another
+ // even if its primary template was instantiated from another
// member template (which happens with nested generic lambdas).
- // Since a lambda's call operator's body is transformed eagerly,
- // we don't have to go hunting for a prototype definition template
- // (i.e. instantiated-from-member-template) to use as an instantiation
+ // Since a lambda's call operator's body is transformed eagerly,
+ // we don't have to go hunting for a prototype definition template
+ // (i.e. instantiated-from-member-template) to use as an instantiation
// pattern.
if (isGenericLambdaCallOperatorSpecialization(
@@ -3377,7 +3374,7 @@ FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const {
}
return getDefinitionOrSelf(Primary->getTemplatedDecl());
- }
+ }
if (auto *MFD = getInstantiatedFromMemberFunction())
return getDefinitionOrSelf(MFD);
@@ -3432,7 +3429,7 @@ FunctionDecl::setFunctionTemplateSpecialization(ASTContext &C,
TemplateSpecializationKind TSK,
const TemplateArgumentListInfo *TemplateArgsAsWritten,
SourceLocation PointOfInstantiation) {
- assert(TSK != TSK_Undeclared &&
+ assert(TSK != TSK_Undeclared &&
"Must specify the type of function template specialization");
FunctionTemplateSpecializationInfo *Info
= TemplateOrSpecialization.dyn_cast<FunctionTemplateSpecializationInfo*>();
@@ -3500,7 +3497,7 @@ TemplateSpecializationKind FunctionDecl::getTemplateSpecializationKind() const {
= TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>();
if (MSInfo)
return MSInfo->getTemplateSpecializationKind();
-
+
return TSK_Undeclared;
}
@@ -3540,22 +3537,22 @@ SourceLocation FunctionDecl::getPointOfInstantiation() const {
else if (MemberSpecializationInfo *MSInfo
= TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>())
return MSInfo->getPointOfInstantiation();
-
+
return SourceLocation();
}
bool FunctionDecl::isOutOfLine() const {
if (Decl::isOutOfLine())
return true;
-
- // If this function was instantiated from a member function of a
+
+ // If this function was instantiated from a member function of a
// class template, check whether that member function was defined out-of-line.
if (FunctionDecl *FD = getInstantiatedFromMemberFunction()) {
const FunctionDecl *Definition;
if (FD->hasBody(Definition))
return Definition->isOutOfLine();
}
-
+
// If this function was instantiated from a function template,
// check whether that function template was defined out-of-line.
if (FunctionTemplateDecl *FunTmpl = getPrimaryTemplate()) {
@@ -3563,7 +3560,7 @@ bool FunctionDecl::isOutOfLine() const {
if (FunTmpl->getTemplatedDecl()->hasBody(Definition))
return Definition->isOutOfLine();
}
-
+
return false;
}
@@ -3576,7 +3573,7 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
if (!FnInfo)
return 0;
-
+
// Builtin handling.
switch (getBuiltinID()) {
case Builtin::BI__builtin_memset:
@@ -4525,7 +4522,7 @@ static unsigned getNumModuleIdentifiers(Module *Mod) {
return Result;
}
-ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
+ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
Module *Imported,
ArrayRef<SourceLocation> IdentifierLocs)
: Decl(Import, DC, StartLoc), ImportedAndComplete(Imported, true) {
@@ -4535,7 +4532,7 @@ ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
StoredLocs);
}
-ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
+ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
Module *Imported, SourceLocation EndLoc)
: Decl(Import, DC, StartLoc), ImportedAndComplete(Imported, false) {
*getTrailingObjects<SourceLocation>() = EndLoc;
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index e3817c0abc38..700ddd389ddd 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -139,7 +139,7 @@ void Decl::setInvalidDecl(bool Invalid) {
if (!isa<ParmVarDecl>(this)) {
// Defensive maneuver for ill-formed code: we're likely not to make it to
// a point where we set the access specifier, so default it to "public"
- // to avoid triggering asserts elsewhere in the front end.
+ // to avoid triggering asserts elsewhere in the front end.
setAccess(AS_public);
}
@@ -211,7 +211,7 @@ bool Decl::isTemplateParameterPack() const {
bool Decl::isParameterPack() const {
if (const auto *Parm = dyn_cast<ParmVarDecl>(this))
return Parm->isParameterPack();
-
+
return isTemplateParameterPack();
}
@@ -253,7 +253,7 @@ bool Decl::isTemplated() const {
const DeclContext *Decl::getParentFunctionOrMethod() const {
for (const DeclContext *DC = getDeclContext();
- DC && !DC->isTranslationUnit() && !DC->isNamespace();
+ DC && !DC->isTranslationUnit() && !DC->isNamespace();
DC = DC->getParent())
if (DC->isFunctionOrMethod())
return DC;
@@ -419,7 +419,7 @@ void Decl::markUsed(ASTContext &C) {
setIsUsed();
}
-bool Decl::isReferenced() const {
+bool Decl::isReferenced() const {
if (Referenced)
return true;
@@ -428,7 +428,7 @@ bool Decl::isReferenced() const {
if (I->Referenced)
return true;
- return false;
+ return false;
}
bool Decl::isExported() const {
@@ -530,13 +530,13 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
HintMessage = " - ";
HintMessage += A->getMessage();
}
-
+
// Make sure that this declaration has not been marked 'unavailable'.
if (A->getUnavailable()) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
- Out << "not available on " << PrettyPlatformName
+ Out << "not available on " << PrettyPlatformName
<< HintMessage;
}
@@ -544,13 +544,13 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
}
// Make sure that this declaration has already been introduced.
- if (!A->getIntroduced().empty() &&
+ if (!A->getIntroduced().empty() &&
EnclosingVersion < A->getIntroduced()) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
VersionTuple VTI(A->getIntroduced());
- Out << "introduced in " << PrettyPlatformName << ' '
+ Out << "introduced in " << PrettyPlatformName << ' '
<< VTI << HintMessage;
}
@@ -563,10 +563,10 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
Message->clear();
llvm::raw_string_ostream Out(*Message);
VersionTuple VTO(A->getObsoleted());
- Out << "obsoleted in " << PrettyPlatformName << ' '
+ Out << "obsoleted in " << PrettyPlatformName << ' '
<< VTO << HintMessage;
}
-
+
return AR_Unavailable;
}
@@ -579,7 +579,7 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
Out << "first deprecated in " << PrettyPlatformName << ' '
<< VTD << HintMessage;
}
-
+
return AR_Deprecated;
}
@@ -1012,7 +1012,7 @@ DeclContext *DeclContext::getLookupParent() {
if (getParent()->getRedeclContext()->isFileContext() &&
getLexicalParent()->getRedeclContext()->isRecord())
return getLexicalParent();
-
+
return getParent();
}
@@ -1047,11 +1047,11 @@ bool DeclContext::isDependentContext() const {
if (const auto *Record = dyn_cast<CXXRecordDecl>(this)) {
if (Record->getDescribedClassTemplate())
return true;
-
+
if (Record->isDependentLambda())
return true;
}
-
+
if (const auto *Function = dyn_cast<FunctionDecl>(this)) {
if (Function->getDescribedFunctionTemplate())
return true;
@@ -1140,12 +1140,12 @@ DeclContext *DeclContext::getPrimaryContext() {
if (auto *Def = cast<ObjCInterfaceDecl>(this)->getDefinition())
return Def;
return this;
-
+
case Decl::ObjCProtocol:
if (auto *Def = cast<ObjCProtocolDecl>(this)->getDefinition())
return Def;
return this;
-
+
case Decl::ObjCCategory:
return this;
@@ -1180,20 +1180,20 @@ DeclContext *DeclContext::getPrimaryContext() {
}
}
-void
+void
DeclContext::collectAllContexts(SmallVectorImpl<DeclContext *> &Contexts){
Contexts.clear();
-
+
if (DeclKind != Decl::Namespace) {
Contexts.push_back(this);
return;
}
-
+
auto *Self = static_cast<NamespaceDecl *>(this);
for (NamespaceDecl *N = Self->getMostRecentDecl(); N;
N = N->getPreviousDecl())
Contexts.push_back(N);
-
+
std::reverse(Contexts.begin(), Contexts.end());
}
@@ -1253,7 +1253,7 @@ DeclContext::LoadLexicalDeclsFromExternalStorage() const {
bool FieldsAlreadyLoaded = false;
if (const auto *RD = dyn_cast<RecordDecl>(this))
FieldsAlreadyLoaded = RD->LoadedFieldsFromExternalStorage;
-
+
// Splice the newly-read declarations into the beginning of the list
// of declarations.
Decl *ExternalFirst, *ExternalLast;
@@ -1638,7 +1638,7 @@ void DeclContext::loadLazyLocalLexicalLookups() {
void DeclContext::localUncachedLookup(DeclarationName Name,
SmallVectorImpl<NamedDecl *> &Results) {
Results.clear();
-
+
// If there's no external storage, just perform a normal lookup and copy
// the results.
if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) {
@@ -1661,7 +1661,7 @@ void DeclContext::localUncachedLookup(DeclarationName Name,
}
}
- // Slow case: grovel through the declarations in our chain looking for
+ // Slow case: grovel through the declarations in our chain looking for
// matches.
// FIXME: If we have lazy external declarations, this will not find them!
// FIXME: Should we CollectAllContexts and walk them all here?
@@ -1892,7 +1892,7 @@ DependentDiagnostic *DependentDiagnostic::Create(ASTContext &C,
PartialDiagnostic::Storage *DiagStorage = nullptr;
if (PDiag.hasStorage())
DiagStorage = new (C) PartialDiagnostic::Storage;
-
+
auto *DD = new (C) DependentDiagnostic(PDiag, DiagStorage);
// TODO: Maybe we shouldn't reverse the order during insertion.
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 076e6376d157..51e8e14f804a 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -203,7 +203,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// The set of seen virtual base types.
llvm::SmallPtrSet<CanQualType, 8> SeenVBaseTypes;
-
+
// The virtual bases of this class.
SmallVector<const CXXBaseSpecifier *, 8> VBases;
@@ -257,7 +257,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
data().Aggregate = false;
// C++ [class.virtual]p1:
- // A class that declares or inherits a virtual function is called a
+ // A class that declares or inherits a virtual function is called a
// polymorphic class.
if (BaseClassDecl->isPolymorphic()) {
data().Polymorphic = true;
@@ -277,7 +277,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// Record if this base is the first non-literal field or base.
if (!hasNonLiteralTypeFieldsOrBases() && !BaseType->isLiteralType(C))
data().HasNonLiteralTypeFieldsOrBases = true;
-
+
// Now go through all virtual bases of this base and add them.
for (const auto &VBase : BaseClassDecl->vbases()) {
// Add this base if it's not already in the list.
@@ -421,7 +421,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// has an Objective-C object member.
if (BaseClassDecl->hasObjectMember())
setHasObjectMember(true);
-
+
if (BaseClassDecl->hasVolatileMember())
setHasVolatileMember(true);
@@ -453,7 +453,7 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
// we know there are no repeated base classes.
if (data().IsStandardLayout && NumBases > 1 && hasRepeatedBaseClass(this))
data().IsStandardLayout = false;
-
+
if (VBases.empty()) {
data().IsParsingBaseSpecifiers = false;
return;
@@ -548,7 +548,7 @@ bool CXXRecordDecl::isTriviallyCopyable() const {
}
void CXXRecordDecl::markedVirtualFunctionPure() {
- // C++ [class.abstract]p2:
+ // C++ [class.abstract]p2:
// A class is abstract if it has at least one pure virtual function.
data().Abstract = true;
}
@@ -639,7 +639,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
// Ignore friends and invalid declarations.
if (D->getFriendObjectKind() || D->isInvalidDecl())
return;
-
+
auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(D);
if (FunTmpl)
D = FunTmpl->getTemplatedDecl();
@@ -651,23 +651,23 @@ void CXXRecordDecl::addedMember(Decl *D) {
if (auto *UnderlyingFunTmpl = dyn_cast<FunctionTemplateDecl>(DUnderlying))
DUnderlying = UnderlyingFunTmpl->getTemplatedDecl();
}
-
+
if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) {
if (Method->isVirtual()) {
// C++ [dcl.init.aggr]p1:
// An aggregate is an array or a class with [...] no virtual functions.
data().Aggregate = false;
-
+
// C++ [class]p4:
// A POD-struct is an aggregate class...
data().PlainOldData = false;
-
+
// C++14 [meta.unary.prop]p4:
// T is a class type [...] with [...] no virtual member functions...
data().Empty = false;
// C++ [class.virtual]p1:
- // A class that declares or inherits a virtual function is called a
+ // A class that declares or inherits a virtual function is called a
// polymorphic class.
data().Polymorphic = true;
@@ -873,8 +873,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().IsStandardLayout = false;
// C++ [class.bit]p2:
- // A declaration for a bit-field that omits the identifier declares an
- // unnamed bit-field. Unnamed bit-fields are not members and cannot be
+ // A declaration for a bit-field that omits the identifier declares an
+ // unnamed bit-field. Unnamed bit-fields are not members and cannot be
// initialized.
if (Field->isUnnamedBitfield()) {
// C++ [meta.unary.prop]p4: [LWG2358]
@@ -886,7 +886,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().Empty = false;
return;
}
-
+
// C++11 [class]p7:
// A standard-layout class is a class that:
// -- either has no non-static data members in the most derived class
@@ -898,7 +898,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
// An aggregate is an array or a class (clause 9) with [...] no
// private or protected non-static data members (clause 11).
//
- // A POD must be an aggregate.
+ // A POD must be an aggregate.
if (D->getAccess() == AS_private || D->getAccess() == AS_protected) {
data().Aggregate = false;
data().PlainOldData = false;
@@ -938,8 +938,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
data().HasVariantMembers = true;
// C++0x [class]p9:
- // A POD struct is a class that is both a trivial class and a
- // standard-layout class, and has no non-static data members of type
+ // A POD struct is a class that is both a trivial class and a
+ // standard-layout class, and has no non-static data members of type
// non-POD struct, non-POD union (or array of such types).
//
// Automatic Reference Counting: the presence of a member of Objective-C pointer type
@@ -974,7 +974,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
}
} else if (!T.isCXX98PODType(Context))
data().PlainOldData = false;
-
+
if (T->isReferenceType()) {
if (!Field->hasInClassInitializer())
data().HasUninitializedReferenceMember = true;
@@ -1235,7 +1235,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
// T is a class type [...] with [...] no non-static data members
data().Empty = false;
}
-
+
// Handle using declarations of conversion functions.
if (auto *Shadow = dyn_cast<UsingShadowDecl>(D)) {
if (Shadow->getDeclName().getNameKind()
@@ -1321,40 +1321,40 @@ bool CXXRecordDecl::isCLike() const {
return isPOD() && data().HasOnlyCMembers;
}
-
-bool CXXRecordDecl::isGenericLambda() const {
+
+bool CXXRecordDecl::isGenericLambda() const {
if (!isLambda()) return false;
return getLambdaData().IsGenericLambda;
}
CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const {
if (!isLambda()) return nullptr;
- DeclarationName Name =
+ DeclarationName Name =
getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
DeclContext::lookup_result Calls = lookup(Name);
assert(!Calls.empty() && "Missing lambda call operator!");
- assert(Calls.size() == 1 && "More than one lambda call operator!");
-
+ assert(Calls.size() == 1 && "More than one lambda call operator!");
+
NamedDecl *CallOp = Calls.front();
if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp))
return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
-
+
return cast<CXXMethodDecl>(CallOp);
}
CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const {
if (!isLambda()) return nullptr;
- DeclarationName Name =
+ DeclarationName Name =
&getASTContext().Idents.get(getLambdaStaticInvokerName());
DeclContext::lookup_result Invoker = lookup(Name);
if (Invoker.empty()) return nullptr;
- assert(Invoker.size() == 1 && "More than one static invoker operator!");
+ assert(Invoker.size() == 1 && "More than one static invoker operator!");
NamedDecl *InvokerFun = Invoker.front();
if (const auto *InvokerTemplate = dyn_cast<FunctionTemplateDecl>(InvokerFun))
return cast<CXXMethodDecl>(InvokerTemplate->getTemplatedDecl());
-
- return cast<CXXMethodDecl>(InvokerFun);
+
+ return cast<CXXMethodDecl>(InvokerFun);
}
void CXXRecordDecl::getCaptureFields(
@@ -1375,10 +1375,10 @@ void CXXRecordDecl::getCaptureFields(
assert(Field == field_end());
}
-TemplateParameterList *
+TemplateParameterList *
CXXRecordDecl::getGenericLambdaTemplateParameterList() const {
if (!isLambda()) return nullptr;
- CXXMethodDecl *CallOp = getLambdaCallOperator();
+ CXXMethodDecl *CallOp = getLambdaCallOperator();
if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate())
return Tmpl->getTemplateParameters();
return nullptr;
@@ -1481,7 +1481,7 @@ static void CollectVisibleConversions(ASTContext &Context,
// found. These will be added to the output as long as they don't
// appear in the hidden-conversions set.
UnresolvedSet<8> VBaseCs;
-
+
// The set of conversions in virtual bases that we've determined to
// be hidden.
llvm::SmallPtrSet<NamedDecl*, 8> HiddenVBaseCs;
@@ -1572,13 +1572,13 @@ MemberSpecializationInfo *CXXRecordDecl::getMemberSpecializationInfo() const {
return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
}
-void
+void
CXXRecordDecl::setInstantiationOfMemberClass(CXXRecordDecl *RD,
TemplateSpecializationKind TSK) {
- assert(TemplateOrInstantiation.isNull() &&
+ assert(TemplateOrInstantiation.isNull() &&
"Previous template or instantiation?");
assert(!isa<ClassTemplatePartialSpecializationDecl>(this));
- TemplateOrInstantiation
+ TemplateOrInstantiation
= new (getASTContext()) MemberSpecializationInfo(RD, TSK);
}
@@ -1593,25 +1593,25 @@ void CXXRecordDecl::setDescribedClassTemplate(ClassTemplateDecl *Template) {
TemplateSpecializationKind CXXRecordDecl::getTemplateSpecializationKind() const{
if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this))
return Spec->getSpecializationKind();
-
+
if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo())
return MSInfo->getTemplateSpecializationKind();
-
+
return TSK_Undeclared;
}
-void
+void
CXXRecordDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
if (auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
Spec->setSpecializationKind(TSK);
return;
}
-
+
if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
MSInfo->setTemplateSpecializationKind(TSK);
return;
}
-
+
llvm_unreachable("Not a class template or member class specialization");
}
@@ -1771,17 +1771,17 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
getFinalOverriders(MyFinalOverriders);
FinalOverriders = &MyFinalOverriders;
}
-
+
bool Done = false;
- for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
+ for (CXXFinalOverriderMap::iterator M = FinalOverriders->begin(),
MEnd = FinalOverriders->end();
M != MEnd && !Done; ++M) {
- for (OverridingMethods::iterator SO = M->second.begin(),
+ for (OverridingMethods::iterator SO = M->second.begin(),
SOEnd = M->second.end();
SO != SOEnd && !Done; ++SO) {
- assert(SO->second.size() > 0 &&
+ assert(SO->second.size() > 0 &&
"All virtual functions have overriding virtual functions");
-
+
// C++ [class.abstract]p4:
// A class is abstract if it contains or inherits at least one
// pure virtual function for which the final overrider is pure
@@ -1794,7 +1794,7 @@ void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
}
}
}
-
+
// Set access bits correctly on the directly-declared conversions.
for (conversion_iterator I = conversion_begin(), E = conversion_end();
I != E; ++I)
@@ -1805,14 +1805,14 @@ bool CXXRecordDecl::mayBeAbstract() const {
if (data().Abstract || isInvalidDecl() || !data().Polymorphic ||
isDependentContext())
return false;
-
+
for (const auto &B : bases()) {
const auto *BaseDecl =
cast<CXXRecordDecl>(B.getType()->getAs<RecordType>()->getDecl());
if (BaseDecl->isAbstract())
return true;
}
-
+
return false;
}
@@ -2006,7 +2006,7 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const {
return false;
// C++ [basic.stc.dynamic.deallocation]p2:
- // If a class T has a member deallocation function named operator delete
+ // If a class T has a member deallocation function named operator delete
// with exactly one parameter, then that function is a usual (non-placement)
// deallocation function. [...]
if (getNumParams() == 1)
@@ -2022,8 +2022,8 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const {
++UsualParams;
// C++ <=14 [basic.stc.dynamic.deallocation]p2:
- // [...] If class T does not declare such an operator delete but does
- // declare a member deallocation function named operator delete with
+ // [...] If class T does not declare such an operator delete but does
+ // declare a member deallocation function named operator delete with
// exactly two parameters, the second of which has type std::size_t (18.1),
// then this function is a usual deallocation function.
//
@@ -2048,8 +2048,8 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const {
// usual deallocation functions.
if (Context.getLangOpts().AlignedAllocation)
return true;
-
- // This function is a usual deallocation function if there are no
+
+ // This function is a usual deallocation function if there are no
// single-parameter deallocation functions of the same kind.
DeclContext::lookup_result R = getDeclContext()->lookup(getDeclName());
for (DeclContext::lookup_result::iterator I = R.begin(), E = R.end();
@@ -2058,25 +2058,25 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const {
if (FD->getNumParams() == 1)
return false;
}
-
+
return true;
}
bool CXXMethodDecl::isCopyAssignmentOperator() const {
// C++0x [class.copy]p17:
- // A user-declared copy assignment operator X::operator= is a non-static
- // non-template member function of class X with exactly one parameter of
+ // A user-declared copy assignment operator X::operator= is a non-static
+ // non-template member function of class X with exactly one parameter of
// type X, X&, const X&, volatile X& or const volatile X&.
if (/*operator=*/getOverloadedOperator() != OO_Equal ||
- /*non-static*/ isStatic() ||
+ /*non-static*/ isStatic() ||
/*non-template*/getPrimaryTemplate() || getDescribedFunctionTemplate() ||
getNumParams() != 1)
return false;
-
+
QualType ParamType = getParamDecl(0)->getType();
if (const auto *Ref = ParamType->getAs<LValueReferenceType>())
ParamType = Ref->getPointeeType();
-
+
ASTContext &Context = getASTContext();
QualType ClassType
= Context.getCanonicalType(Context.getTypeDeclType(getParent()));
@@ -2151,7 +2151,7 @@ QualType CXXMethodDecl::getThisType(ASTContext &C) const {
}
bool CXXMethodDecl::hasInlineBody() const {
- // If this function is a template instantiation, look at the template from
+ // If this function is a template instantiation, look at the template from
// which it was instantiated.
const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
if (!CheckFn)
@@ -2203,7 +2203,7 @@ CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
CXXCtorInitializer::CXXCtorInitializer(ASTContext &Context,
TypeSourceInfo *TInfo,
- SourceLocation L, Expr *Init,
+ SourceLocation L, Expr *Init,
SourceLocation R)
: Initializee(TInfo), Init(Init), LParenLoc(L), RParenLoc(R),
IsDelegating(true), IsVirtual(false), IsWritten(false), SourceOrder(0) {}
@@ -2225,13 +2225,13 @@ const Type *CXXCtorInitializer::getBaseClass() const {
SourceLocation CXXCtorInitializer::getSourceLocation() const {
if (isInClassMemberInitializer())
return getAnyMember()->getLocation();
-
+
if (isAnyMemberInitializer())
return getMemberLocation();
if (const auto *TSInfo = Initializee.get<TypeSourceInfo *>())
return TSInfo->getTypeLoc().getLocalSourceRange().getBegin();
-
+
return {};
}
@@ -2318,37 +2318,37 @@ bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const {
// or else all other parameters have default arguments (8.3.6).
// C++0x [class.copy]p3:
// A non-template constructor for class X is a move constructor if its
- // first parameter is of type X&&, const X&&, volatile X&&, or
- // const volatile X&&, and either there are no other parameters or else
+ // first parameter is of type X&&, const X&&, volatile X&&, or
+ // const volatile X&&, and either there are no other parameters or else
// all other parameters have default arguments.
if ((getNumParams() < 1) ||
(getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
(getPrimaryTemplate() != nullptr) ||
(getDescribedFunctionTemplate() != nullptr))
return false;
-
+
const ParmVarDecl *Param = getParamDecl(0);
-
- // Do we have a reference type?
+
+ // Do we have a reference type?
const auto *ParamRefType = Param->getType()->getAs<ReferenceType>();
if (!ParamRefType)
return false;
-
+
// Is it a reference to our class type?
ASTContext &Context = getASTContext();
-
+
CanQualType PointeeType
= Context.getCanonicalType(ParamRefType->getPointeeType());
- CanQualType ClassTy
+ CanQualType ClassTy
= Context.getCanonicalType(Context.getTagDeclType(getParent()));
if (PointeeType.getUnqualifiedType() != ClassTy)
return false;
-
+
// FIXME: other qualifiers?
-
+
// We have a copy or move constructor.
TypeQuals = PointeeType.getCVRQualifiers();
- return true;
+ return true;
}
bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
@@ -2379,14 +2379,14 @@ bool CXXConstructorDecl::isSpecializationCopyingObject() const {
ASTContext &Context = getASTContext();
CanQualType ParamType = Context.getCanonicalType(Param->getType());
-
+
// Is it the same as our class type?
- CanQualType ClassTy
+ CanQualType ClassTy
= Context.getCanonicalType(Context.getTagDeclType(getParent()));
if (ParamType.getUnqualifiedType() != ClassTy)
return false;
-
- return true;
+
+ return true;
}
void CXXDestructorDecl::anchor() {}
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 5db045099997..01fd10429fc1 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -51,7 +51,7 @@ void ObjCListBase::set(void *const* InList, unsigned Elts, ASTContext &Ctx) {
memcpy(List, InList, sizeof(void*)*Elts);
}
-void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts,
+void ObjCProtocolList::set(ObjCProtocolDecl* const* InList, unsigned Elts,
const SourceLocation *Locs, ASTContext &Ctx) {
if (Elts == 0)
return;
@@ -145,7 +145,7 @@ bool ObjCContainerDecl::HasUserDeclaredSetterMethod(
break;
}
}
-
+
// Also look into protocols, for a user declared instance method.
for (const auto *Proto : ID->all_referenced_protocols())
if (Proto->HasUserDeclaredSetterMethod(Property))
@@ -235,7 +235,7 @@ ObjCPropertyDecl *ObjCContainerDecl::FindPropertyDeclaration(
if (Def->isHidden())
return nullptr;
}
-
+
// Search the extensions of a class first; they override what's in
// the class itself.
if (const auto *ClassDecl = dyn_cast<ObjCInterfaceDecl>(this)) {
@@ -332,7 +332,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const {
// FIXME: Should make sure no callers ever do this.
if (!hasDefinition())
return nullptr;
-
+
if (data().ExternallyCompleted)
LoadExternalDefinition();
@@ -351,7 +351,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::getSuperClass() const {
SourceLocation ObjCInterfaceDecl::getSuperClassLoc() const {
if (TypeSourceInfo *superTInfo = getSuperClassTInfo())
return superTInfo->getTypeLoc().getLocStart();
-
+
return SourceLocation();
}
@@ -429,12 +429,12 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
if (data().ExternallyCompleted)
LoadExternalDefinition();
- if (data().AllReferencedProtocols.empty() &&
+ if (data().AllReferencedProtocols.empty() &&
data().ReferencedProtocols.empty()) {
data().AllReferencedProtocols.set(ExtList, ExtNum, C);
return;
}
-
+
// Check for duplicate protocol in class's protocol list.
// This is O(n*m). But it is extremely rare and number of protocols in
// class or its extension are very few.
@@ -446,7 +446,7 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList(
if (C.ProtocolCompatibleWithProtocol(ProtoInExtension, Proto)) {
protocolExists = true;
break;
- }
+ }
}
// Do we want to warn on a protocol in extension class which
// already exist in the class? Probably not.
@@ -633,7 +633,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID,
return I;
}
}
-
+
ClassDecl = ClassDecl->getSuperClass();
}
return nullptr;
@@ -673,7 +673,7 @@ ObjCInterfaceDecl::lookupNestedProtocol(IdentifierInfo *Name) {
/// the class, its categories, and its super classes (using a linear search).
/// When argument category "C" is specified, any implicit method found
/// in this category is ignored.
-ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
+ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
bool isInstance,
bool shallowCategoryLookup,
bool followSuper,
@@ -693,7 +693,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
// 1. Look through primary class.
if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
return MethodDecl;
-
+
// 2. Didn't find one yet - now look through categories.
for (const auto *Cat : ClassDecl->visible_categories())
if ((MethodDecl = Cat->getMethod(Sel, isInstance)))
@@ -704,7 +704,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
for (const auto *I : ClassDecl->protocols())
if ((MethodDecl = I->lookupMethod(Sel, isInstance)))
return MethodDecl;
-
+
// 4. Didn't find one yet - now look through categories' protocols
if (!shallowCategoryLookup)
for (const auto *Cat : ClassDecl->visible_categories()) {
@@ -716,8 +716,8 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
if (C != Cat || !MethodDecl->isImplicit())
return MethodDecl;
}
-
-
+
+
if (!followSuper)
return nullptr;
@@ -742,7 +742,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod(
ObjCMethodDecl *Method = nullptr;
if (ObjCImplementationDecl *ImpDecl = getImplementation())
- Method = Instance ? ImpDecl->getInstanceMethod(Sel)
+ Method = Instance ? ImpDecl->getInstanceMethod(Sel)
: ImpDecl->getClassMethod(Sel);
// Look through local category implementations associated with the class.
@@ -990,12 +990,12 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
if (!isInstanceMethod())
family = OMF_None;
break;
-
+
case OMF_initialize:
if (isInstanceMethod() || !getReturnType()->isVoidType())
family = OMF_None;
break;
-
+
case OMF_performSelector:
if (!isInstanceMethod() || !getReturnType()->isObjCIdType())
family = OMF_None;
@@ -1021,7 +1021,7 @@ ObjCMethodFamily ObjCMethodDecl::getMethodFamily() const {
}
}
break;
-
+
}
// Cache the result.
@@ -1441,11 +1441,11 @@ ObjCInterfaceDecl::ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC,
: ObjCContainerDecl(ObjCInterface, DC, Id, CLoc, AtLoc),
redeclarable_base(C) {
setPreviousDecl(PrevDecl);
-
+
// Copy the 'data' pointer over.
if (PrevDecl)
Data = PrevDecl->Data;
-
+
setImplicit(IsInternal);
setTypeParamList(typeParamList);
@@ -1459,9 +1459,9 @@ void ObjCInterfaceDecl::LoadExternalDefinition() const {
}
void ObjCInterfaceDecl::setExternallyCompleted() {
- assert(getASTContext().getExternalSource() &&
+ assert(getASTContext().getExternalSource() &&
"Class can't be externally completed without an external source");
- assert(hasDefinition() &&
+ assert(hasDefinition() &&
"Forward declarations can't be externally completed");
data().ExternallyCompleted = true;
}
@@ -1496,7 +1496,7 @@ ObjCImplementationDecl::getObjCRuntimeNameAsString() const {
if (ObjCInterfaceDecl *ID =
const_cast<ObjCImplementationDecl*>(this)->getClassInterface())
return ID->getObjCRuntimeNameAsString();
-
+
return getName();
}
@@ -1504,11 +1504,11 @@ ObjCImplementationDecl *ObjCInterfaceDecl::getImplementation() const {
if (const ObjCInterfaceDecl *Def = getDefinition()) {
if (data().ExternallyCompleted)
LoadExternalDefinition();
-
+
return getASTContext().getObjCImplementation(
const_cast<ObjCInterfaceDecl*>(Def));
}
-
+
// FIXME: Should make sure no callers ever do this.
return nullptr;
}
@@ -1576,7 +1576,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
// cached and complete!
if (!data().IvarListMissingImplementation)
return data().IvarList;
-
+
if (ObjCImplementationDecl *ImplDecl = getImplementation()) {
data().IvarListMissingImplementation = false;
if (!ImplDecl->ivar_empty()) {
@@ -1593,7 +1593,7 @@ ObjCIvarDecl *ObjCInterfaceDecl::all_declared_ivar_begin() {
curIvar->setNextIvar(IV);
curIvar = IV;
}
-
+
if (!layout.empty()) {
// Order synthesized ivars by their size.
std::stable_sort(layout.begin(), layout.end());
@@ -1659,7 +1659,7 @@ bool ObjCInterfaceDecl::ClassImplementsProtocol(ObjCProtocolDecl *lProto,
bool RHSIsQualifiedID) {
if (!hasDefinition())
return false;
-
+
ObjCInterfaceDecl *IDecl = this;
// 1st, look up the class.
for (auto *PI : IDecl->protocols()){
@@ -1869,7 +1869,7 @@ void ObjCProtocolDecl::allocateDefinitionData() {
void ObjCProtocolDecl::startDefinition() {
allocateDefinitionData();
-
+
// Update all of the declarations with a pointer to the definition.
for (auto *RD : redecls())
RD->Data = this->Data;
@@ -1926,7 +1926,7 @@ ObjCProtocolDecl::getObjCRuntimeNameAsString() const {
void ObjCCategoryDecl::anchor() {}
ObjCCategoryDecl::ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc,
- SourceLocation ClassNameLoc,
+ SourceLocation ClassNameLoc,
SourceLocation CategoryNameLoc,
IdentifierInfo *Id, ObjCInterfaceDecl *IDecl,
ObjCTypeParamList *typeParamList,
@@ -2008,7 +2008,7 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
atStartLoc, CategoryNameLoc);
}
-ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C,
+ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
return new (C, ID) ObjCCategoryImplDecl(nullptr, nullptr, nullptr,
SourceLocation(), SourceLocation(),
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index d3d9c23cca6e..09e22f19f87a 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -44,7 +44,7 @@ namespace {
///
/// \param Quals The Objective-C declaration qualifiers.
/// \param T The type to print.
- void PrintObjCMethodType(ASTContext &Ctx, Decl::ObjCDeclQualifier Quals,
+ void PrintObjCMethodType(ASTContext &Ctx, Decl::ObjCDeclQualifier Quals,
QualType T);
void PrintObjCTypeParams(ObjCTypeParamList *Params);
@@ -196,7 +196,7 @@ LLVM_DUMP_METHOD void DeclContext::dumpDeclContext() const {
const DeclContext *DC = this;
while (!DC->isTranslationUnit())
DC = DC->getParent();
-
+
ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
DeclPrinter Printer(llvm::errs(), Ctx.getPrintingPolicy(), Ctx, 0);
Printer.VisitDeclContext(const_cast<DeclContext *>(this), /*Indent=*/false);
@@ -482,7 +482,7 @@ void DeclPrinter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
void DeclPrinter::VisitTypedefDecl(TypedefDecl *D) {
if (!Policy.SuppressSpecifiers) {
Out << "typedef ";
-
+
if (D->isModulePrivate())
Out << "__module_private__ ";
}
@@ -641,7 +641,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
}
Proto += ")";
-
+
if (FT) {
if (FT->isConst())
Proto += " const";
@@ -666,7 +666,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
Proto += " throw(";
if (FT->getExceptionSpecType() == EST_MSAny)
Proto += "...";
- else
+ else
for (unsigned I = 0, N = FT->getNumExceptions(); I != N; ++I) {
if (I)
Proto += ", ";
@@ -1141,8 +1141,8 @@ void DeclPrinter::VisitClassTemplatePartialSpecializationDecl(
// Objective-C declarations
//----------------------------------------------------------------------------
-void DeclPrinter::PrintObjCMethodType(ASTContext &Ctx,
- Decl::ObjCDeclQualifier Quals,
+void DeclPrinter::PrintObjCMethodType(ASTContext &Ctx,
+ Decl::ObjCDeclQualifier Quals,
QualType T) {
Out << '(';
if (Quals & Decl::ObjCDeclQualifier::OBJC_TQ_In)
@@ -1161,7 +1161,7 @@ void DeclPrinter::PrintObjCMethodType(ASTContext &Ctx,
if (auto nullability = AttributedType::stripOuterNullability(T))
Out << getNullabilitySpelling(*nullability, true) << ' ';
}
-
+
Out << Ctx.getUnqualifiedObjCPointerType(T).getAsString(Policy);
Out << ')';
}
@@ -1216,7 +1216,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
if (lastPos != 0)
Out << " ";
Out << name.substr(lastPos, pos - lastPos) << ':';
- PrintObjCMethodType(OMD->getASTContext(),
+ PrintObjCMethodType(OMD->getASTContext(),
PI->getObjCDeclQualifier(),
PI->getType());
Out << *PI;
@@ -1228,7 +1228,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
if (OMD->isVariadic())
Out << ", ...";
-
+
prettyPrintAttributes(OMD);
if (OMD->getBody() && !Policy.TerseOutput) {
@@ -1248,7 +1248,7 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) {
Out << "@implementation " << I << " : " << *SID;
else
Out << "@implementation " << I;
-
+
if (OID->ivar_size() > 0) {
Out << "{\n";
eolnOut = true;
@@ -1290,7 +1290,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
if (auto TypeParams = OID->getTypeParamListAsWritten()) {
PrintObjCTypeParams(TypeParams);
}
-
+
if (SID)
Out << " : " << QualType(OID->getSuperClassType(), 0).getAsString(Policy);
@@ -1369,7 +1369,7 @@ void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) {
Indentation -= Policy.Indentation;
Out << "}\n";
}
-
+
VisitDeclContext(PID, false);
Out << "@end";
@@ -1448,7 +1448,7 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
Out << (first ? ' ' : ',') << "atomic";
first = false;
}
-
+
if (PDecl->getPropertyAttributes() &
ObjCPropertyDecl::OBJC_PR_nullability) {
if (auto nullability = AttributedType::stripOuterNullability(T)) {
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 8854f7879ac6..848427e7f9d9 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -117,7 +117,7 @@ unsigned TemplateParameterList::getMinRequiredArguments() const {
unsigned TemplateParameterList::getDepth() const {
if (size() == 0)
return 0;
-
+
const NamedDecl *FirstParm = getParam(0);
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
return TTP->getDepth();
@@ -338,13 +338,13 @@ llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
ClassTemplateDecl::getSpecializations() const {
LoadLazySpecializations();
return getCommonPtr()->Specializations;
-}
+}
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
ClassTemplateDecl::getPartialSpecializations() {
LoadLazySpecializations();
return getCommonPtr()->PartialSpecializations;
-}
+}
RedeclarableTemplateDecl::CommonBase *
ClassTemplateDecl::newCommon(ASTContext &C) const {
@@ -427,11 +427,11 @@ ClassTemplateDecl::getInjectedClassNameSpecialization() {
return CommonPtr->InjectedClassNameType;
// C++0x [temp.dep.type]p2:
- // The template argument list of a primary template is a template argument
+ // The template argument list of a primary template is a template argument
// list in which the nth template argument has the value of the nth template
- // parameter of the class template. If the nth template parameter is a
- // template parameter pack (14.5.3), the nth template argument is a pack
- // expansion (14.5.3) whose pattern is the name of the template parameter
+ // parameter of the class template. If the nth template parameter is a
+ // template parameter pack (14.5.3), the nth template argument is a pack
+ // expansion (14.5.3) whose pattern is the name of the template parameter
// pack.
ASTContext &Context = getASTContext();
TemplateParameterList *Params = getTemplateParameters();
diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp
index 31bae93c3cb5..9866d92f61eb 100644
--- a/lib/AST/DeclarationName.cpp
+++ b/lib/AST/DeclarationName.cpp
@@ -114,14 +114,14 @@ static int compareInt(unsigned A, unsigned B) {
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
if (LHS.getNameKind() != RHS.getNameKind())
return (LHS.getNameKind() < RHS.getNameKind() ? -1 : 1);
-
+
switch (LHS.getNameKind()) {
case DeclarationName::Identifier: {
IdentifierInfo *LII = LHS.getAsIdentifierInfo();
IdentifierInfo *RII = RHS.getAsIdentifierInfo();
if (!LII) return RII ? -1 : 0;
if (!RII) return 1;
-
+
return LII->getName().compare(RII->getName());
}
@@ -148,7 +148,7 @@ int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
return compareInt(LN, RN);
}
-
+
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
@@ -171,7 +171,7 @@ int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
case DeclarationName::CXXLiteralOperatorName:
return LHS.getCXXLiteralIdentifier()->getName().compare(
RHS.getCXXLiteralIdentifier()->getName());
-
+
case DeclarationName::CXXUsingDirective:
return 0;
}
@@ -565,7 +565,7 @@ DeclarationNameTable::getCXXLiteralOperatorName(IdentifierInfo *II) {
if (CXXLiteralOperatorIdName *Name =
LiteralNames->FindNodeOrInsertPos(ID, InsertPos))
return DeclarationName (Name);
-
+
CXXLiteralOperatorIdName *LiteralName = new (Ctx) CXXLiteralOperatorIdName;
LiteralName->ExtraKindOrNumArgs = DeclarationNameExtra::CXXLiteralOperator;
LiteralName->ID = II;
@@ -636,13 +636,13 @@ bool DeclarationNameInfo::isInstantiationDependent() const {
case DeclarationName::CXXUsingDirective:
case DeclarationName::CXXDeductionGuideName:
return false;
-
+
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
if (TypeSourceInfo *TInfo = LocInfo.NamedType.TInfo)
return TInfo->getType()->isInstantiationDependentType();
-
+
return Name.getCXXNameType()->isInstantiationDependentType();
}
llvm_unreachable("All name kinds handled.");
@@ -689,7 +689,7 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const {
llvm_unreachable("Unexpected declaration name kind");
}
-SourceLocation DeclarationNameInfo::getEndLoc() const {
+SourceLocation DeclarationNameInfo::getEndLocPrivate() const {
switch (Name.getNameKind()) {
case DeclarationName::Identifier:
case DeclarationName::CXXDeductionGuideName:
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 193efa4e097d..7556c76c38bd 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -137,9 +137,9 @@ bool Expr::isKnownToHaveBooleanValue() const {
// If this value has _Bool type, it is obvious 0/1.
if (E->getType()->isBooleanType()) return true;
- // If this is a non-scalar-integer type, we don't care enough to try.
+ // If this is a non-scalar-integer type, we don't care enough to try.
if (!E->getType()->isIntegralOrEnumerationType()) return false;
-
+
if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) {
switch (UO->getOpcode()) {
case UO_Plus:
@@ -150,12 +150,12 @@ bool Expr::isKnownToHaveBooleanValue() const {
return false;
}
}
-
+
// Only look through implicit casts. If the user writes
// '(int) (a && b)' treat it as an arbitrary int.
if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
return CE->getSubExpr()->isKnownToHaveBooleanValue();
-
+
if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
switch (BO->getOpcode()) {
default: return false;
@@ -168,24 +168,24 @@ bool Expr::isKnownToHaveBooleanValue() const {
case BO_LAnd: // AND operator.
case BO_LOr: // Logical OR operator.
return true;
-
+
case BO_And: // Bitwise AND operator.
case BO_Xor: // Bitwise XOR operator.
case BO_Or: // Bitwise OR operator.
// Handle things like (x==2)|(y==12).
return BO->getLHS()->isKnownToHaveBooleanValue() &&
BO->getRHS()->isKnownToHaveBooleanValue();
-
+
case BO_Comma:
case BO_Assign:
return BO->getRHS()->isKnownToHaveBooleanValue();
}
}
-
+
if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E))
return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
CO->getFalseExpr()->isKnownToHaveBooleanValue();
-
+
return false;
}
@@ -230,7 +230,7 @@ SourceLocation Expr::getExprLoc() const {
// Primary Expressions.
//===----------------------------------------------------------------------===//
-/// Compute the type-, value-, and instantiation-dependence of a
+/// Compute the type-, value-, and instantiation-dependence of a
/// declaration reference
/// based on the declaration being referenced.
static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
@@ -259,9 +259,9 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
} else if (T->isInstantiationDependentType()) {
InstantiationDependent = true;
}
-
+
// (TD) - a conversion-function-id that specifies a dependent type
- if (D->getDeclName().getNameKind()
+ if (D->getDeclName().getNameKind()
== DeclarationName::CXXConversionFunctionName) {
QualType T = D->getDeclName().getCXXNameType();
if (T->isDependentType()) {
@@ -270,18 +270,18 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
InstantiationDependent = true;
return;
}
-
+
if (T->isInstantiationDependentType())
InstantiationDependent = true;
}
-
+
// (VD) - the name of a non-type template parameter,
if (isa<NonTypeTemplateParmDecl>(D)) {
ValueDependent = true;
InstantiationDependent = true;
return;
}
-
+
// (VD) - a constant with integral or enumeration type and is
// initialized with an expression that is value-dependent.
// (VD) - a constant with literal type and is initialized with an
@@ -302,10 +302,10 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
}
}
- // (VD) - FIXME: Missing from the standard:
- // - a member function or a static data member of the current
+ // (VD) - FIXME: Missing from the standard:
+ // - a member function or a static data member of the current
// instantiation
- if (Var->isStaticDataMember() &&
+ if (Var->isStaticDataMember() &&
Var->getDeclContext()->isDependentContext()) {
ValueDependent = true;
InstantiationDependent = true;
@@ -313,12 +313,12 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
if (TInfo->getType()->isIncompleteArrayType())
TypeDependent = true;
}
-
+
return;
}
-
- // (VD) - FIXME: Missing from the standard:
- // - a member function or a static data member of the current
+
+ // (VD) - FIXME: Missing from the standard:
+ // - a member function or a static data member of the current
// instantiation
if (isa<CXXMethodDecl>(D) && D->getDeclContext()->isDependentContext()) {
ValueDependent = true;
@@ -625,7 +625,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
llvm::raw_string_ostream TOut(TemplateParams);
for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
I != E; ++I) {
- const TemplateParameterList *Params
+ const TemplateParameterList *Params
= (*I)->getSpecializedTemplate()->getTemplateParameters();
const TemplateArgumentList &Args = (*I)->getTemplateArgs();
assert(Params->size() == Args.size());
@@ -638,10 +638,10 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
}
}
- FunctionTemplateSpecializationInfo *FSI
+ FunctionTemplateSpecializationInfo *FSI
= FD->getTemplateSpecializationInfo();
if (FSI && !FSI->isExplicitSpecialization()) {
- const TemplateParameterList* Params
+ const TemplateParameterList* Params
= FSI->getTemplate()->getTemplateParameters();
const TemplateArgumentList* Args = FSI->TemplateArguments;
assert(Params->size() == Args->size());
@@ -942,7 +942,7 @@ void StringLiteral::outputString(raw_ostream &OS) const {
// Convert UTF-16 surrogate pairs back to codepoints before rendering.
// Leave invalid surrogates alone; we'll use \x for those.
- if (getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
+ if (getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
Char <= 0xdbff) {
uint32_t Trail = getCodeUnit(I + 1);
if (Trail >= 0xdc00 && Trail <= 0xdfff) {
@@ -1025,7 +1025,7 @@ void StringLiteral::setString(const ASTContext &C, StringRef Str,
// code unit size and endianness for the type of string.
this->Kind = Kind;
this->IsPascal = IsPascal;
-
+
CharByteWidth = mapCharByteWidth(C.getTargetInfo(),Kind);
assert((Str.size()%CharByteWidth == 0)
&& "size of data must be multiple of CharByteWidth");
@@ -1092,7 +1092,7 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
while (1) {
assert(TokNo < getNumConcatenated() && "Invalid byte number!");
SourceLocation StrTokLoc = 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.
@@ -1112,17 +1112,17 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
}
const char *StrData = Buffer.data()+LocInfo.second;
-
+
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), Features,
Buffer.begin(), StrData, Buffer.end());
Token TheTok;
TheLexer.LexFromRawLexer(TheTok);
-
+
// Use the StringLiteralParser to compute the length of the string in bytes.
StringLiteralParser SLP(TheTok, SM, Features, Target);
unsigned TokNumBytes = SLP.GetStringLength();
-
+
// If the byte is in this token, return the location of the byte.
if (ByteNo < TokNumBytes ||
(ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
@@ -1258,12 +1258,12 @@ Decl *CallExpr::getCalleeDecl() {
Decl *Expr::getReferencedDeclOfCallee() {
Expr *CEE = IgnoreParenImpCasts();
-
+
while (SubstNonTypeTemplateParmExpr *NTTP
= dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
CEE = NTTP->getReplacement()->IgnoreParenCasts();
}
-
+
// If we're calling a dereference, look at the pointer instead.
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CEE)) {
if (BO->isPtrMemOp())
@@ -1379,7 +1379,7 @@ SourceLocation CallExpr::getLocEnd() const {
OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type,
SourceLocation OperatorLoc,
- TypeSourceInfo *tsi,
+ TypeSourceInfo *tsi,
ArrayRef<OffsetOfNode> comps,
ArrayRef<Expr*> exprs,
SourceLocation RParenLoc) {
@@ -1402,17 +1402,17 @@ OffsetOfExpr::OffsetOfExpr(const ASTContext &C, QualType type,
ArrayRef<OffsetOfNode> comps, ArrayRef<Expr*> exprs,
SourceLocation RParenLoc)
: Expr(OffsetOfExprClass, type, VK_RValue, OK_Ordinary,
- /*TypeDependent=*/false,
+ /*TypeDependent=*/false,
/*ValueDependent=*/tsi->getType()->isDependentType(),
tsi->getType()->isInstantiationDependentType(),
tsi->getType()->containsUnexpandedParameterPack()),
- OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
+ OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
NumComps(comps.size()), NumExprs(exprs.size())
{
for (unsigned i = 0; i != comps.size(); ++i) {
setComponent(i, comps[i]);
}
-
+
for (unsigned i = 0; i != exprs.size(); ++i) {
if (exprs[i]->isTypeDependent() || exprs[i]->isValueDependent())
ExprBits.ValueDependent = true;
@@ -1427,7 +1427,7 @@ IdentifierInfo *OffsetOfNode::getFieldName() const {
assert(getKind() == Field || getKind() == Identifier);
if (getKind() == Field)
return getField()->getIdentifier();
-
+
return reinterpret_cast<IdentifierInfo *> (Data & ~(uintptr_t)Mask);
}
@@ -1497,11 +1497,11 @@ MemberExpr *MemberExpr::Create(
E->setValueDependent(true);
E->setTypeDependent(true);
E->setInstantiationDependent(true);
- }
- else if (QualifierLoc &&
- QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
+ }
+ else if (QualifierLoc &&
+ QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())
E->setInstantiationDependent(true);
-
+
E->HasQualifierOrFoundDecl = true;
MemberExprNameQualifier *NQ =
@@ -1582,9 +1582,9 @@ bool CastExpr::CastConsistency() const {
// Otherwise, we should only have block and ObjC pointer casts
// here if they stay within the type kind.
if (!getType()->isPointerType()) {
- assert(getType()->isObjCObjectPointerType() ==
+ assert(getType()->isObjCObjectPointerType() ==
getSubExpr()->getType()->isObjCObjectPointerType());
- assert(getType()->isBlockPointerType() ==
+ assert(getType()->isBlockPointerType() ==
getSubExpr()->getType()->isBlockPointerType());
}
goto CheckNoBasePath;
@@ -1708,11 +1708,11 @@ Expr *CastExpr::getSubExprAsWritten() {
if (auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
SubExpr = MCE->getImplicitObjectArgument();
}
-
+
// If the subexpression we're left with is an implicit cast, look
// through that, too.
- } while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
-
+ } while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
+
return const_cast<Expr*>(SubExpr);
}
@@ -1734,6 +1734,21 @@ NamedDecl *CastExpr::getConversionFunction() const {
return nullptr;
}
+CastExpr::BasePathSizeTy *CastExpr::BasePathSize() {
+ assert(!path_empty());
+ switch (getStmtClass()) {
+#define ABSTRACT_STMT(x)
+#define CASTEXPR(Type, Base) \
+ case Stmt::Type##Class: \
+ return static_cast<Type *>(this) \
+ ->getTrailingObjects<CastExpr::BasePathSizeTy>();
+#define STMT(Type, Base)
+#include "clang/AST/StmtNodes.inc"
+ default:
+ llvm_unreachable("non-cast expressions not possible here");
+ }
+}
+
CXXBaseSpecifier **CastExpr::path_buffer() {
switch (getStmtClass()) {
#define ABSTRACT_STMT(x)
@@ -1772,7 +1787,9 @@ ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T,
const CXXCastPath *BasePath,
ExprValueKind VK) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
ImplicitCastExpr *E =
new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, VK);
if (PathSize)
@@ -1783,7 +1800,9 @@ ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T,
ImplicitCastExpr *ImplicitCastExpr::CreateEmpty(const ASTContext &C,
unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) ImplicitCastExpr(EmptyShell(), PathSize);
}
@@ -1794,7 +1813,9 @@ CStyleCastExpr *CStyleCastExpr::Create(const ASTContext &C, QualType T,
TypeSourceInfo *WrittenTy,
SourceLocation L, SourceLocation R) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
CStyleCastExpr *E =
new (Buffer) CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
if (PathSize)
@@ -1805,7 +1826,9 @@ CStyleCastExpr *CStyleCastExpr::Create(const ASTContext &C, QualType T,
CStyleCastExpr *CStyleCastExpr::CreateEmpty(const ASTContext &C,
unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) CStyleCastExpr(EmptyShell(), PathSize);
}
@@ -1933,7 +1956,7 @@ InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc,
if (initExprs[I]->containsUnexpandedParameterPack())
ExprBits.ContainsUnexpandedParameterPack = true;
}
-
+
InitExprs.insert(C, InitExprs.end(), initExprs.begin(), initExprs.end());
}
@@ -2023,12 +2046,12 @@ SourceLocation InitListExpr::getLocStart() const {
if (Beg.isInvalid()) {
// Find the first non-null initializer.
for (InitExprsTy::const_iterator I = InitExprs.begin(),
- E = InitExprs.end();
+ E = InitExprs.end();
I != E; ++I) {
if (Stmt *S = *I) {
Beg = S->getLocStart();
break;
- }
+ }
}
}
return Beg;
@@ -2079,7 +2102,7 @@ Stmt *BlockExpr::getBody() {
/// 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 Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
+bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
SourceRange &R1, SourceRange &R2,
ASTContext &Ctx) const {
// Don't warn if the expr is type dependent. The type could end up
@@ -2436,7 +2459,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
case DeclRefExprClass: {
const Decl *D = cast<DeclRefExpr>(E)->getDecl();
-
+
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
if (VD->hasGlobalStorage())
return true;
@@ -2526,7 +2549,7 @@ Expr *Expr::IgnoreParenCasts() {
E = P->getSubExpr();
continue;
}
- if (MaterializeTemporaryExpr *Materialize
+ if (MaterializeTemporaryExpr *Materialize
= dyn_cast<MaterializeTemporaryExpr>(E)) {
E = Materialize->GetTemporaryExpr();
continue;
@@ -2535,7 +2558,7 @@ Expr *Expr::IgnoreParenCasts() {
= dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
E = NTTP->getReplacement();
continue;
- }
+ }
return E;
}
}
@@ -2574,7 +2597,7 @@ Expr *Expr::IgnoreParenLValueCasts() {
E = P->getSubExpr();
continue;
}
- } else if (MaterializeTemporaryExpr *Materialize
+ } else if (MaterializeTemporaryExpr *Materialize
= dyn_cast<MaterializeTemporaryExpr>(E)) {
E = Materialize->GetTemporaryExpr();
continue;
@@ -2613,7 +2636,7 @@ Expr *Expr::IgnoreParenImpCasts() {
E = P->getSubExpr();
continue;
}
- if (MaterializeTemporaryExpr *Materialize
+ if (MaterializeTemporaryExpr *Materialize
= dyn_cast<MaterializeTemporaryExpr>(E)) {
E = Materialize->GetTemporaryExpr();
continue;
@@ -2668,7 +2691,7 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) {
E = NTTP->getReplacement();
continue;
}
-
+
return E;
}
}
@@ -2680,7 +2703,7 @@ bool Expr::isDefaultArgument() const {
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
E = ICE->getSubExprAsWritten();
-
+
return isa<CXXDefaultArgExpr>(E);
}
@@ -2756,43 +2779,43 @@ bool Expr::isTemporaryObject(ASTContext &C, const CXXRecordDecl *TempTy) const {
bool Expr::isImplicitCXXThis() const {
const Expr *E = this;
-
+
// Strip away parentheses and casts we don't care about.
while (true) {
if (const ParenExpr *Paren = dyn_cast<ParenExpr>(E)) {
E = Paren->getSubExpr();
continue;
}
-
+
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
if (ICE->getCastKind() == CK_NoOp ||
ICE->getCastKind() == CK_LValueToRValue ||
- ICE->getCastKind() == CK_DerivedToBase ||
+ ICE->getCastKind() == CK_DerivedToBase ||
ICE->getCastKind() == CK_UncheckedDerivedToBase) {
E = ICE->getSubExpr();
continue;
}
}
-
+
if (const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
if (UnOp->getOpcode() == UO_Extension) {
E = UnOp->getSubExpr();
continue;
}
}
-
+
if (const MaterializeTemporaryExpr *M
= dyn_cast<MaterializeTemporaryExpr>(E)) {
E = M->GetTemporaryExpr();
continue;
}
-
+
break;
}
-
+
if (const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
return This->isImplicit();
-
+
return false;
}
@@ -2978,7 +3001,7 @@ bool CallExpr::isBuiltinAssumeFalse(const ASTContext &Ctx) const {
if (!FD || (FD->getBuiltinID() != Builtin::BI__assume &&
FD->getBuiltinID() != Builtin::BI__builtin_assume))
return false;
-
+
const Expr* Arg = getArg(0);
bool ArgVal;
return !Arg->isValueDependent() &&
@@ -3289,11 +3312,11 @@ namespace {
typedef ConstEvaluatedExprVisitor<NonTrivialCallFinder> Inherited;
bool NonTrivial;
-
+
public:
explicit NonTrivialCallFinder(const ASTContext &Context)
: Inherited(Context), NonTrivial(false) { }
-
+
bool hasNonTrivialCall() const { return NonTrivial; }
void VisitCallExpr(const CallExpr *E) {
@@ -3305,7 +3328,7 @@ namespace {
return;
}
}
-
+
NonTrivial = true;
}
@@ -3315,7 +3338,7 @@ namespace {
Inherited::VisitStmt(E);
return;
}
-
+
NonTrivial = true;
}
@@ -3324,7 +3347,7 @@ namespace {
Inherited::VisitStmt(E);
return;
}
-
+
NonTrivial = true;
}
};
@@ -3333,10 +3356,10 @@ namespace {
bool Expr::hasNonTrivialCall(const ASTContext &Ctx) const {
NonTrivialCallFinder Finder(Ctx);
Finder.Visit(this);
- return Finder.hasNonTrivialCall();
+ return Finder.hasNonTrivialCall();
}
-/// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null
+/// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null
/// pointer constant or not, as well as the specific kind of constant detected.
/// Null pointer constants can be integer constant expressions with the
/// value zero, casts of zero to void*, nullptr (C++0X), or __null
@@ -3354,7 +3377,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
return NPCK_ZeroExpression;
else
return NPCK_NotNull;
-
+
case NPC_ValueDependentIsNotNull:
return NPCK_NotNull;
}
@@ -3410,7 +3433,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
} else if (isa<GNUNullExpr>(this)) {
// The GNU __null extension is always a null pointer constant.
return NPCK_GNUNull;
- } else if (const MaterializeTemporaryExpr *M
+ } else if (const MaterializeTemporaryExpr *M
= dyn_cast<MaterializeTemporaryExpr>(this)) {
return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
} else if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(this)) {
@@ -3431,7 +3454,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
return ILE->getInit(0)->isNullPointerConstant(Ctx, NPC);
}
// This expression must be an integer type.
- if (!getType()->isIntegerType() ||
+ if (!getType()->isIntegerType() ||
(Ctx.getLangOpts().CPlusPlus && getType()->isEnumeralType()))
return NPCK_NotNull;
@@ -3549,7 +3572,7 @@ FieldDecl *Expr::getSourceBitField() {
bool Expr::refersToVectorElement() const {
// FIXME: Why do we not just look at the ObjectKind here?
const Expr *E = this->IgnoreParens();
-
+
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
if (ICE->getValueKind() != VK_RValue &&
ICE->getCastKind() == CK_NoOp)
@@ -3557,7 +3580,7 @@ bool Expr::refersToVectorElement() const {
else
break;
}
-
+
if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E))
return ASE->getBase()->getType()->isVectorType();
@@ -3652,7 +3675,7 @@ void ExtVectorElementExpr::getEncodedElementAccess(
ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef<Expr*> args,
QualType Type, SourceLocation BLoc,
- SourceLocation RP)
+ SourceLocation RP)
: Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary,
Type->isDependentType(), Type->isDependentType(),
Type->isInstantiationDependentType(),
@@ -3791,11 +3814,11 @@ DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty,
End->isTypeDependent() || End->isValueDependent()) {
ExprBits.TypeDependent = ExprBits.ValueDependent = true;
ExprBits.InstantiationDependent = true;
- } else if (Start->isInstantiationDependent() ||
+ } else if (Start->isInstantiationDependent() ||
End->isInstantiationDependent()) {
ExprBits.InstantiationDependent = true;
}
-
+
// Propagate unexpanded parameter packs.
if (Start->containsUnexpandedParameterPack() ||
End->containsUnexpandedParameterPack())
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 3a204c244f68..93d68ec8e0b2 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -120,7 +120,7 @@ CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew,
if (Array) {
if (arraySize->isInstantiationDependent())
ExprBits.InstantiationDependent = true;
-
+
if (arraySize->containsUnexpandedParameterPack())
ExprBits.ContainsUnexpandedParameterPack = true;
@@ -210,8 +210,8 @@ PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info)
CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context,
Expr *Base, bool isArrow, SourceLocation OperatorLoc,
- NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType,
- SourceLocation ColonColonLoc, SourceLocation TildeLoc,
+ NestedNameSpecifierLoc QualifierLoc, TypeSourceInfo *ScopeType,
+ SourceLocation ColonColonLoc, SourceLocation TildeLoc,
PseudoDestructorTypeStorage DestroyedType)
: Expr(CXXPseudoDestructorExprClass,
Context.BoundMemberTy,
@@ -230,10 +230,10 @@ CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context,
->isInstantiationDependentType())),
// ContainsUnexpandedParameterPack
(Base->containsUnexpandedParameterPack() ||
- (QualifierLoc &&
+ (QualifierLoc &&
QualifierLoc.getNestedNameSpecifier()
->containsUnexpandedParameterPack()) ||
- (ScopeType &&
+ (ScopeType &&
ScopeType->getType()->containsUnexpandedParameterPack()) ||
(DestroyedType.getTypeSourceInfo() &&
DestroyedType.getTypeSourceInfo()->getType()
@@ -246,7 +246,7 @@ CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context,
QualType CXXPseudoDestructorExpr::getDestroyedType() const {
if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
return TInfo->getType();
-
+
return QualType();
}
@@ -300,7 +300,7 @@ OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C,
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs,
- UnresolvedSetIterator Begin,
+ UnresolvedSetIterator Begin,
UnresolvedSetIterator End,
bool KnownDependent,
bool KnownInstantiationDependent,
@@ -393,13 +393,13 @@ DependentScopeDeclRefExpr::DependentScopeDeclRefExpr(QualType T,
: Expr(DependentScopeDeclRefExprClass, T, VK_LValue, OK_Ordinary,
true, true,
(NameInfo.isInstantiationDependent() ||
- (QualifierLoc &&
+ (QualifierLoc &&
QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
(NameInfo.containsUnexpandedParameterPack() ||
- (QualifierLoc &&
+ (QualifierLoc &&
QualifierLoc.getNestedNameSpecifier()
->containsUnexpandedParameterPack()))),
- QualifierLoc(QualifierLoc), NameInfo(NameInfo),
+ QualifierLoc(QualifierLoc), NameInfo(NameInfo),
HasTemplateKWAndArgsInfo(Args != nullptr || TemplateKWLoc.isValid())
{
if (Args) {
@@ -555,11 +555,13 @@ CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T,
CastKind K, Expr *Op,
const CXXCastPath *BasePath,
TypeSourceInfo *WrittenTy,
- SourceLocation L,
+ SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
auto *E =
new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
RParenLoc, AngleBrackets);
@@ -571,7 +573,9 @@ CXXStaticCastExpr *CXXStaticCastExpr::Create(const ASTContext &C, QualType T,
CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext &C,
unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize);
}
@@ -580,11 +584,13 @@ CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T,
CastKind K, Expr *Op,
const CXXCastPath *BasePath,
TypeSourceInfo *WrittenTy,
- SourceLocation L,
+ SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
auto *E =
new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
RParenLoc, AngleBrackets);
@@ -596,7 +602,9 @@ CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T,
CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext &C,
unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
}
@@ -637,11 +645,13 @@ CXXReinterpretCastExpr *
CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T,
ExprValueKind VK, CastKind K, Expr *Op,
const CXXCastPath *BasePath,
- TypeSourceInfo *WrittenTy, SourceLocation L,
+ TypeSourceInfo *WrittenTy, SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
auto *E =
new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
RParenLoc, AngleBrackets);
@@ -653,14 +663,16 @@ CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T,
CXXReinterpretCastExpr *
CXXReinterpretCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
}
CXXConstCastExpr *CXXConstCastExpr::Create(const ASTContext &C, QualType T,
ExprValueKind VK, Expr *Op,
TypeSourceInfo *WrittenTy,
- SourceLocation L,
+ SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
return new (C) CXXConstCastExpr(T, VK, Op, WrittenTy, L, RParenLoc, AngleBrackets);
@@ -676,7 +688,9 @@ CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK,
const CXXCastPath *BasePath,
SourceLocation L, SourceLocation R) {
unsigned PathSize = (BasePath ? BasePath->size() : 0);
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
auto *E =
new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R);
if (PathSize)
@@ -687,7 +701,9 @@ CXXFunctionalCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK,
CXXFunctionalCastExpr *
CXXFunctionalCastExpr::CreateEmpty(const ASTContext &C, unsigned PathSize) {
- void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
+ void *Buffer =
+ C.Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
+ PathSize ? 1 : 0, PathSize));
return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
}
@@ -829,7 +845,7 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC,
ZeroInitialization(ZeroInitialization), ConstructKind(ConstructKind) {
if (NumArgs) {
this->Args = new (C) Stmt*[Args.size()];
-
+
for (unsigned i = 0; i != Args.size(); ++i) {
assert(Args[i] && "NULL argument in CXXConstructExpr");
@@ -839,7 +855,7 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC,
ExprBits.InstantiationDependent = true;
if (Args[i]->containsUnexpandedParameterPack())
ExprBits.ContainsUnexpandedParameterPack = true;
-
+
this->Args[i] = Args[i];
}
}
@@ -852,7 +868,7 @@ LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit,
unsigned Bits = 0;
if (Implicit)
Bits |= Capture_Implicit;
-
+
switch (Kind) {
case LCK_StarThis:
Bits |= Capture_ByCopy;
@@ -901,9 +917,9 @@ LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
assert(CaptureInits.size() == Captures.size() && "Wrong number of arguments");
CXXRecordDecl *Class = getLambdaClass();
CXXRecordDecl::LambdaDefinitionData &Data = Class->getLambdaData();
-
+
// FIXME: Propagate "has unexpanded parameter pack" bit.
-
+
// Copy captures.
const ASTContext &Context = Class->getASTContext();
Data.NumCaptures = NumCaptures;
@@ -914,15 +930,15 @@ LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange,
for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
if (Captures[I].isExplicit())
++Data.NumExplicitCaptures;
-
+
*ToCapture++ = Captures[I];
}
-
+
// Copy initialization expressions for the non-static data members.
Stmt **Stored = getStoredStmts();
for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
*Stored++ = CaptureInits[I];
-
+
// Copy the body of the lambda.
*Stored++ = getCallOperator()->getBody();
}
@@ -1001,7 +1017,7 @@ CXXRecordDecl *LambdaExpr::getLambdaClass() const {
CXXMethodDecl *LambdaExpr::getCallOperator() const {
CXXRecordDecl *Record = getLambdaClass();
- return Record->getLambdaCallOperator();
+ return Record->getLambdaCallOperator();
}
TemplateParameterList *LambdaExpr::getTemplateParameterList() const {
@@ -1188,7 +1204,7 @@ CXXDependentScopeMemberExpr::CreateEmpty(const ASTContext &C,
bool CXXDependentScopeMemberExpr::isImplicitAccess() const {
if (!Base)
return true;
-
+
return cast<Expr>(Base)->isImplicitCXXThis();
}
@@ -1218,7 +1234,7 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C,
SourceLocation TemplateKWLoc,
const DeclarationNameInfo &MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs,
- UnresolvedSetIterator Begin,
+ UnresolvedSetIterator Begin,
UnresolvedSetIterator End)
: OverloadExpr(
UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc,
@@ -1241,7 +1257,7 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C,
bool UnresolvedMemberExpr::isImplicitAccess() const {
if (!Base)
return true;
-
+
return cast<Expr>(Base)->isImplicitCXXThis();
}
@@ -1300,11 +1316,11 @@ CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const {
assert(PT && "base of arrow member access is not pointer");
BaseType = PT->getPointeeType();
}
-
+
Record = BaseType->getAsCXXRecordDecl();
assert(Record && "base of member expression does not name record");
}
-
+
return Record;
}
@@ -1328,7 +1344,7 @@ SizeOfPackExpr *SizeOfPackExpr::CreateDeserialized(ASTContext &Context,
}
SubstNonTypeTemplateParmPackExpr::
-SubstNonTypeTemplateParmPackExpr(QualType T,
+SubstNonTypeTemplateParmPackExpr(QualType T,
ExprValueKind ValueKind,
NonTypeTemplateParmDecl *Param,
SourceLocation NameLoc,
@@ -1411,13 +1427,13 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
setInstantiationDependent(true);
if (Args[I]->getType()->containsUnexpandedParameterPack())
setContainsUnexpandedParameterPack(true);
-
+
ToArgs[I] = Args[I];
}
}
TypeTraitExpr *TypeTraitExpr::Create(const ASTContext &C, QualType T,
- SourceLocation Loc,
+ SourceLocation Loc,
TypeTrait Kind,
ArrayRef<TypeSourceInfo *> Args,
SourceLocation RParenLoc,
diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp
index c5b3b361a0a5..e50dd9c79d11 100644
--- a/lib/AST/ExprClassification.cpp
+++ b/lib/AST/ExprClassification.cpp
@@ -345,9 +345,9 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
return ClassifyUnnamed(Ctx, cast<ExplicitCastExpr>(E)->getTypeAsWritten());
case Expr::CXXUnresolvedConstructExprClass:
- return ClassifyUnnamed(Ctx,
+ return ClassifyUnnamed(Ctx,
cast<CXXUnresolvedConstructExpr>(E)->getTypeAsWritten());
-
+
case Expr::BinaryConditionalOperatorClass: {
if (!Lang.CPlusPlus) return Cl::CL_PRValue;
const auto *co = cast<BinaryConditionalOperator>(E);
@@ -370,7 +370,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
return (kind == Cl::CL_PRValue) ? Cl::CL_ObjCMessageRValue : kind;
}
return Cl::CL_PRValue;
-
+
// Some C++ expressions are always class temporaries.
case Expr::CXXConstructExprClass:
case Expr::CXXInheritedCtorInitExprClass:
@@ -400,7 +400,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
case Expr::MaterializeTemporaryExprClass:
return cast<MaterializeTemporaryExpr>(E)->isBoundToLvalueReference()
- ? Cl::CL_LValue
+ ? Cl::CL_LValue
: Cl::CL_XValue;
case Expr::InitListExprClass:
@@ -546,7 +546,7 @@ static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) {
if (E->getOpcode() == BO_PtrMemD)
return (E->getType()->isFunctionType() ||
E->hasPlaceholderType(BuiltinType::BoundMember))
- ? Cl::CL_MemberFunction
+ ? Cl::CL_MemberFunction
: ClassifyInternal(Ctx, E->getLHS());
// C++ [expr.mptr.oper]p6: The result of an ->* expression is an lvalue if its
@@ -554,7 +554,7 @@ static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) {
if (E->getOpcode() == BO_PtrMemI)
return (E->getType()->isFunctionType() ||
E->hasPlaceholderType(BuiltinType::BoundMember))
- ? Cl::CL_MemberFunction
+ ? Cl::CL_MemberFunction
: Cl::CL_LValue;
// All other binary operations are prvalues.
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index e69914f25da2..44cf75dbd25b 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -319,6 +319,25 @@ namespace {
return false;
}
+ /// Get the range of valid index adjustments in the form
+ /// {maximum value that can be subtracted from this pointer,
+ /// maximum value that can be added to this pointer}
+ std::pair<uint64_t, uint64_t> validIndexAdjustments() {
+ if (Invalid || isMostDerivedAnUnsizedArray())
+ return {0, 0};
+
+ // [expr.add]p4: For the purposes of these operators, a pointer to a
+ // nonarray object behaves the same as a pointer to the first element of
+ // an array of length one with the type of the object as its element type.
+ bool IsArray = MostDerivedPathLength == Entries.size() &&
+ MostDerivedIsArrayElement;
+ uint64_t ArrayIndex =
+ IsArray ? Entries.back().ArrayIndex : (uint64_t)IsOnePastTheEnd;
+ uint64_t ArraySize =
+ IsArray ? getMostDerivedArraySize() : (uint64_t)1;
+ return {ArrayIndex, ArraySize - ArrayIndex};
+ }
+
/// Check that this refers to a valid subobject.
bool isValidSubobject() const {
if (Invalid)
@@ -329,6 +348,13 @@ namespace {
/// relevant diagnostic and set the designator as invalid.
bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
+ /// Get the type of the designated object.
+ QualType getType(ASTContext &Ctx) const {
+ return MostDerivedPathLength == Entries.size()
+ ? MostDerivedType
+ : Ctx.getRecordType(getAsBaseClass(Entries.back()));
+ }
+
/// Update this designator to refer to the first element within this array.
void addArrayUnchecked(const ConstantArrayType *CAT) {
PathEntry Entry;
@@ -572,7 +598,7 @@ namespace {
// FIXME: Force the precision of the source value down so we don't
// print digits which are usually useless (we don't really care here if
// we truncate a digit by accident in edge cases). Ideally,
- // APFloat::toString would automatically print the shortest
+ // APFloat::toString would automatically print the shortest
// representation which rounds to the correct value, but it's a bit
// tricky to implement.
unsigned precision =
@@ -826,7 +852,7 @@ namespace {
private:
OptionalDiagnostic Diag(SourceLocation Loc, diag::kind DiagId,
unsigned ExtraNotes, bool IsCCEDiag) {
-
+
if (EvalStatus.Diag) {
// If we have a prior diagnostic, it will be noting that the expression
// isn't a constant expression. This diagnostic is more important,
@@ -880,7 +906,7 @@ namespace {
unsigned ExtraNotes = 0) {
return Diag(Loc, DiagId, ExtraNotes, false);
}
-
+
OptionalDiagnostic FFDiag(const Expr *E, diag::kind DiagId
= diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0) {
@@ -1706,6 +1732,54 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
}
}
+static const ValueDecl *GetLValueBaseDecl(const LValue &LVal) {
+ return LVal.Base.dyn_cast<const ValueDecl*>();
+}
+
+static bool IsLiteralLValue(const LValue &Value) {
+ if (Value.getLValueCallIndex())
+ return false;
+ const Expr *E = Value.Base.dyn_cast<const Expr*>();
+ return E && !isa<MaterializeTemporaryExpr>(E);
+}
+
+static bool IsWeakLValue(const LValue &Value) {
+ const ValueDecl *Decl = GetLValueBaseDecl(Value);
+ return Decl && Decl->isWeak();
+}
+
+static bool isZeroSized(const LValue &Value) {
+ const ValueDecl *Decl = GetLValueBaseDecl(Value);
+ if (Decl && isa<VarDecl>(Decl)) {
+ QualType Ty = Decl->getType();
+ if (Ty->isArrayType())
+ return Ty->isIncompleteType() ||
+ Decl->getASTContext().getTypeSize(Ty) == 0;
+ }
+ return false;
+}
+
+static bool HasSameBase(const LValue &A, const LValue &B) {
+ if (!A.getLValueBase())
+ return !B.getLValueBase();
+ if (!B.getLValueBase())
+ return false;
+
+ if (A.getLValueBase().getOpaqueValue() !=
+ B.getLValueBase().getOpaqueValue()) {
+ const Decl *ADecl = GetLValueBaseDecl(A);
+ if (!ADecl)
+ return false;
+ const Decl *BDecl = GetLValueBaseDecl(B);
+ if (!BDecl || ADecl->getCanonicalDecl() != BDecl->getCanonicalDecl())
+ return false;
+ }
+
+ return IsGlobalLValue(A.getLValueBase()) ||
+ (A.getLValueCallIndex() == B.getLValueCallIndex() &&
+ A.getLValueVersion() == B.getLValueVersion());
+}
+
static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
assert(Base && "no location for a null lvalue");
const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>();
@@ -1917,33 +1991,6 @@ CheckConstantExpression(EvalInfo &Info, SourceLocation DiagLoc, QualType Type,
return true;
}
-static const ValueDecl *GetLValueBaseDecl(const LValue &LVal) {
- return LVal.Base.dyn_cast<const ValueDecl*>();
-}
-
-static bool IsLiteralLValue(const LValue &Value) {
- if (Value.getLValueCallIndex())
- return false;
- const Expr *E = Value.Base.dyn_cast<const Expr*>();
- return E && !isa<MaterializeTemporaryExpr>(E);
-}
-
-static bool IsWeakLValue(const LValue &Value) {
- const ValueDecl *Decl = GetLValueBaseDecl(Value);
- return Decl && Decl->isWeak();
-}
-
-static bool isZeroSized(const LValue &Value) {
- const ValueDecl *Decl = GetLValueBaseDecl(Value);
- if (Decl && isa<VarDecl>(Decl)) {
- QualType Ty = Decl->getType();
- if (Ty->isArrayType())
- return Ty->isIncompleteType() ||
- Decl->getASTContext().getTypeSize(Ty) == 0;
- }
- return false;
-}
-
static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {
// A null base expression indicates a null pointer. These are always
// evaluatable, and they are false unless the offset is zero.
@@ -4286,13 +4333,13 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
if (Info.getLangOpts().CPlusPlus11) {
const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
-
+
// If this function is not constexpr because it is an inherited
// non-constexpr constructor, diagnose that directly.
auto *CD = dyn_cast<CXXConstructorDecl>(DiagDecl);
if (CD && CD->isInheritingConstructor()) {
auto *Inherited = CD->getInheritedConstructor().getConstructor();
- if (!Inherited->isConstexpr())
+ if (!Inherited->isConstexpr())
DiagDecl = CD = Inherited;
}
@@ -4853,7 +4900,7 @@ public:
return false;
This = &ThisVal;
Args = Args.slice(1);
- } else if (MD && MD->isLambdaStaticInvoker()) {
+ } else if (MD && MD->isLambdaStaticInvoker()) {
// Map the static invoker for the lambda back to the call operator.
// Conveniently, we don't have to slice out the 'this' argument (as is
// being done for the non-static case), since a static member function
@@ -4888,7 +4935,7 @@ public:
FD = LambdaCallOp;
}
-
+
} else
return Error(E);
@@ -5732,7 +5779,7 @@ public:
// Update 'Result' to refer to the data member/field of the closure object
// that represents the '*this' capture.
if (!HandleLValueMember(Info, E, Result,
- Info.CurrentCall->LambdaThisCaptureField))
+ Info.CurrentCall->LambdaThisCaptureField))
return false;
// If we captured '*this' by reference, replace the field with its referent.
if (Info.CurrentCall->LambdaThisCaptureField->getType()
@@ -6117,6 +6164,130 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
return ZeroInitialization(E);
}
+ case Builtin::BImemcpy:
+ case Builtin::BImemmove:
+ case Builtin::BIwmemcpy:
+ case Builtin::BIwmemmove:
+ if (Info.getLangOpts().CPlusPlus11)
+ Info.CCEDiag(E, diag::note_constexpr_invalid_function)
+ << /*isConstexpr*/0 << /*isConstructor*/0
+ << (std::string("'") + Info.Ctx.BuiltinInfo.getName(BuiltinOp) + "'");
+ else
+ Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr);
+ LLVM_FALLTHROUGH;
+ case Builtin::BI__builtin_memcpy:
+ case Builtin::BI__builtin_memmove:
+ case Builtin::BI__builtin_wmemcpy:
+ case Builtin::BI__builtin_wmemmove: {
+ bool WChar = BuiltinOp == Builtin::BIwmemcpy ||
+ BuiltinOp == Builtin::BIwmemmove ||
+ BuiltinOp == Builtin::BI__builtin_wmemcpy ||
+ BuiltinOp == Builtin::BI__builtin_wmemmove;
+ bool Move = BuiltinOp == Builtin::BImemmove ||
+ BuiltinOp == Builtin::BIwmemmove ||
+ BuiltinOp == Builtin::BI__builtin_memmove ||
+ BuiltinOp == Builtin::BI__builtin_wmemmove;
+
+ // The result of mem* is the first argument.
+ if (!Visit(E->getArg(0)))
+ return false;
+ LValue Dest = Result;
+
+ LValue Src;
+ if (!EvaluatePointer(E->getArg(1), Src, Info))
+ return false;
+
+ APSInt N;
+ if (!EvaluateInteger(E->getArg(2), N, Info))
+ return false;
+ assert(!N.isSigned() && "memcpy and friends take an unsigned size");
+
+ // If the size is zero, we treat this as always being a valid no-op.
+ // (Even if one of the src and dest pointers is null.)
+ if (!N)
+ return true;
+
+ // We require that Src and Dest are both pointers to arrays of
+ // trivially-copyable type. (For the wide version, the designator will be
+ // invalid if the designated object is not a wchar_t.)
+ QualType T = Dest.Designator.getType(Info.Ctx);
+ QualType SrcT = Src.Designator.getType(Info.Ctx);
+ if (!Info.Ctx.hasSameUnqualifiedType(T, SrcT)) {
+ Info.FFDiag(E, diag::note_constexpr_memcpy_type_pun) << Move << SrcT << T;
+ return false;
+ }
+ if (!T.isTriviallyCopyableType(Info.Ctx)) {
+ Info.FFDiag(E, diag::note_constexpr_memcpy_nontrivial) << Move << T;
+ return false;
+ }
+
+ // Figure out how many T's we're copying.
+ uint64_t TSize = Info.Ctx.getTypeSizeInChars(T).getQuantity();
+ if (!WChar) {
+ uint64_t Remainder;
+ llvm::APInt OrigN = N;
+ llvm::APInt::udivrem(OrigN, TSize, N, Remainder);
+ if (Remainder) {
+ Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
+ << Move << WChar << 0 << T << OrigN.toString(10, /*Signed*/false)
+ << (unsigned)TSize;
+ return false;
+ }
+ }
+
+ // Check that the copying will remain within the arrays, just so that we
+ // can give a more meaningful diagnostic. This implicitly also checks that
+ // N fits into 64 bits.
+ uint64_t RemainingSrcSize = Src.Designator.validIndexAdjustments().second;
+ uint64_t RemainingDestSize = Dest.Designator.validIndexAdjustments().second;
+ if (N.ugt(RemainingSrcSize) || N.ugt(RemainingDestSize)) {
+ Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
+ << Move << WChar << (N.ugt(RemainingSrcSize) ? 1 : 2) << T
+ << N.toString(10, /*Signed*/false);
+ return false;
+ }
+ uint64_t NElems = N.getZExtValue();
+ uint64_t NBytes = NElems * TSize;
+
+ // Check for overlap.
+ int Direction = 1;
+ if (HasSameBase(Src, Dest)) {
+ uint64_t SrcOffset = Src.getLValueOffset().getQuantity();
+ uint64_t DestOffset = Dest.getLValueOffset().getQuantity();
+ if (DestOffset >= SrcOffset && DestOffset - SrcOffset < NBytes) {
+ // Dest is inside the source region.
+ if (!Move) {
+ Info.FFDiag(E, diag::note_constexpr_memcpy_overlap) << WChar;
+ return false;
+ }
+ // For memmove and friends, copy backwards.
+ if (!HandleLValueArrayAdjustment(Info, E, Src, T, NElems - 1) ||
+ !HandleLValueArrayAdjustment(Info, E, Dest, T, NElems - 1))
+ return false;
+ Direction = -1;
+ } else if (!Move && SrcOffset >= DestOffset &&
+ SrcOffset - DestOffset < NBytes) {
+ // Src is inside the destination region for memcpy: invalid.
+ Info.FFDiag(E, diag::note_constexpr_memcpy_overlap) << WChar;
+ return false;
+ }
+ }
+
+ while (true) {
+ APValue Val;
+ if (!handleLValueToRValueConversion(Info, E, T, Src, Val) ||
+ !handleAssignment(Info, E, Dest, T, Val))
+ return false;
+ // Do not iterate past the last element; if we're copying backwards, that
+ // might take us off the start of the array.
+ if (--NElems == 0)
+ return true;
+ if (!HandleLValueArrayAdjustment(Info, E, Src, T, Direction) ||
+ !HandleLValueArrayAdjustment(Info, E, Dest, T, Direction))
+ return false;
+ }
+ }
+
default:
return visitNonBuiltinCallExpr(E);
}
@@ -6583,7 +6754,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
if (ClosureClass->isInvalidDecl()) return false;
if (Info.checkingPotentialConstantExpression()) return true;
-
+
const size_t NumFields =
std::distance(ClosureClass->field_begin(), ClosureClass->field_end());
@@ -6602,7 +6773,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
assert(CaptureInitIt != E->capture_init_end());
// Get the initializer for this field
Expr *const CurFieldInit = *CaptureInitIt++;
-
+
// If there is no initializer, either this is a VLA or an error has
// occurred.
if (!CurFieldInit)
@@ -6802,18 +6973,18 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
// The number of initializers can be less than the number of
// vector elements. For OpenCL, this can be due to nested vector
- // initialization. For GCC compatibility, missing trailing elements
+ // initialization. For GCC compatibility, missing trailing elements
// should be initialized with zeroes.
unsigned CountInits = 0, CountElts = 0;
while (CountElts < NumElements) {
// Handle nested vector initialization.
- if (CountInits < NumInits
+ if (CountInits < NumInits
&& E->getInit(CountInits)->getType()->isVectorType()) {
APValue v;
if (!EvaluateVector(E->getInit(CountInits), v, Info))
return Error(E);
unsigned vlen = v.getVectorLength();
- for (unsigned j = 0; j < vlen; j++)
+ for (unsigned j = 0; j < vlen; j++)
Elements.push_back(v.getVectorElt(j));
CountElts += vlen;
} else if (EltTy->isIntegerType()) {
@@ -7108,7 +7279,7 @@ public:
}
bool Success(const llvm::APInt &I, const Expr *E, APValue &Result) {
- assert(E->getType()->isIntegralOrEnumerationType() &&
+ assert(E->getType()->isIntegralOrEnumerationType() &&
"Invalid evaluation result.");
assert(I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) &&
"Invalid evaluation result.");
@@ -7198,7 +7369,7 @@ public:
}
return Success(Info.ArrayInitIndex, E);
}
-
+
// Note, GNU defines __null as an integer, not a pointer.
bool VisitGNUNullExpr(const GNUNullExpr *E) {
return ZeroInitialization(E);
@@ -8357,27 +8528,6 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
}
}
-static bool HasSameBase(const LValue &A, const LValue &B) {
- if (!A.getLValueBase())
- return !B.getLValueBase();
- if (!B.getLValueBase())
- return false;
-
- if (A.getLValueBase().getOpaqueValue() !=
- B.getLValueBase().getOpaqueValue()) {
- const Decl *ADecl = GetLValueBaseDecl(A);
- if (!ADecl)
- return false;
- const Decl *BDecl = GetLValueBaseDecl(B);
- if (!BDecl || ADecl->getCanonicalDecl() != BDecl->getCanonicalDecl())
- return false;
- }
-
- return IsGlobalLValue(A.getLValueBase()) ||
- (A.getLValueCallIndex() == B.getLValueCallIndex() &&
- A.getLValueVersion() == B.getLValueVersion());
-}
-
/// Determine whether this is a pointer past the end of the complete
/// object referred to by the lvalue.
static bool isOnePastTheEndOfCompleteObject(const ASTContext &Ctx,
@@ -8585,12 +8735,12 @@ bool DataRecursiveIntBinOpEvaluator::
Result = RHSResult.Val;
return true;
}
-
+
if (E->isLogicalOp()) {
bool lhsResult, rhsResult;
bool LHSIsOK = HandleConversionToBool(LHSResult.Val, lhsResult);
bool RHSIsOK = HandleConversionToBool(RHSResult.Val, rhsResult);
-
+
if (LHSIsOK) {
if (RHSIsOK) {
if (E->getOpcode() == BO_LOr)
@@ -8606,26 +8756,26 @@ bool DataRecursiveIntBinOpEvaluator::
return Success(rhsResult, E, Result);
}
}
-
+
return false;
}
-
+
assert(E->getLHS()->getType()->isIntegralOrEnumerationType() &&
E->getRHS()->getType()->isIntegralOrEnumerationType());
-
+
if (LHSResult.Failed || RHSResult.Failed)
return false;
-
+
const APValue &LHSVal = LHSResult.Val;
const APValue &RHSVal = RHSResult.Val;
-
+
// Handle cases like (unsigned long)&a + 4.
if (E->isAdditiveOp() && LHSVal.isLValue() && RHSVal.isInt()) {
Result = LHSVal;
addOrSubLValueAsInteger(Result, RHSVal.getInt(), E->getOpcode() == BO_Sub);
return true;
}
-
+
// Handle cases like 4 + (unsigned long)&a
if (E->getOpcode() == BO_Add &&
RHSVal.isLValue() && LHSVal.isInt()) {
@@ -8633,7 +8783,7 @@ bool DataRecursiveIntBinOpEvaluator::
addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/false);
return true;
}
-
+
if (E->getOpcode() == BO_Sub && LHSVal.isLValue() && RHSVal.isLValue()) {
// Handle (intptr_t)&&A - (intptr_t)&&B.
if (!LHSVal.getLValueOffset().isZero() ||
@@ -8672,7 +8822,7 @@ bool DataRecursiveIntBinOpEvaluator::
void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
Job &job = Queue.back();
-
+
switch (job.Kind) {
case Job::AnyExprKind: {
if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(job.E)) {
@@ -8682,12 +8832,12 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
return;
}
}
-
+
EvaluateExpr(job.E, Result);
Queue.pop_back();
return;
}
-
+
case Job::BinOpKind: {
const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
bool SuppressRHSDiags = false;
@@ -8702,7 +8852,7 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
enqueue(Bop->getRHS());
return;
}
-
+
case Job::BinOpVisitedLHSKind: {
const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
EvalResult RHS;
@@ -8712,7 +8862,7 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
return;
}
}
-
+
llvm_unreachable("Invalid Job::Kind!");
}
@@ -9299,7 +9449,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
const RecordType *BaseRT = CurrentType->getAs<RecordType>();
if (!BaseRT)
return Error(OOE);
-
+
// Add the offset to the base.
Result += RL.getBaseClassOffset(cast<CXXRecordDecl>(BaseRT->getDecl()));
break;
@@ -10531,7 +10681,7 @@ static bool FastEvaluateAsRValue(const Expr *Exp, Expr::EvalResult &Result,
IsConst = false;
return true;
}
-
+
// FIXME: Evaluating values of large array and record types can cause
// performance problems. Only do so in C++11 for now.
if (Exp->isRValue() && (Exp->getType()->isArrayType() ||
@@ -10553,7 +10703,7 @@ bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const {
bool IsConst;
if (FastEvaluateAsRValue(this, Result, Ctx, IsConst))
return IsConst;
-
+
EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
return ::EvaluateAsRValue(Info, this, Result.Val);
}
diff --git a/lib/AST/ExternalASTSource.cpp b/lib/AST/ExternalASTSource.cpp
index 198ba9d4fbdb..40829c2e249d 100644
--- a/lib/AST/ExternalASTSource.cpp
+++ b/lib/AST/ExternalASTSource.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file provides the default implementation of the ExternalASTSource
+// This file provides the default implementation of the ExternalASTSource
// interface, which enables construction of AST nodes from some external
// source.
//
diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp
index a75ae14f9015..64580edf004b 100644
--- a/lib/AST/ItaniumCXXABI.cpp
+++ b/lib/AST/ItaniumCXXABI.cpp
@@ -190,7 +190,7 @@ public:
return false;
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
- CharUnits PointerSize =
+ CharUnits PointerSize =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
return Layout.getNonVirtualSize() == PointerSize;
}
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 3b99a3d9afda..2dc04f2f3d86 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -46,10 +46,10 @@ namespace {
/// Retrieve the declaration context that should be used when mangling the given
/// declaration.
static const DeclContext *getEffectiveDeclContext(const Decl *D) {
- // The ABI assumes that lambda closure types that occur within
+ // The ABI assumes that lambda closure types that occur within
// default arguments live in the context of the function. However, due to
// the way in which Clang parses and creates function declarations, this is
- // not the case: the lambda closure type ends up living in the context
+ // not the case: the lambda closure type ends up living in the context
// where the function itself resides, because the function declaration itself
// had not yet been created. Fix the context here.
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
@@ -65,7 +65,7 @@ static const DeclContext *getEffectiveDeclContext(const Decl *D) {
= dyn_cast_or_null<ParmVarDecl>(BD->getBlockManglingContextDecl()))
return ContextParam->getDeclContext();
}
-
+
const DeclContext *DC = D->getDeclContext();
if (isa<CapturedDecl>(DC) || isa<OMPDeclareReductionDecl>(DC)) {
return getEffectiveDeclContext(cast<Decl>(DC));
@@ -441,7 +441,7 @@ public:
void mangleName(const NamedDecl *ND);
void mangleType(QualType T);
void mangleNameOrStandardSubstitution(const NamedDecl *ND);
-
+
private:
bool mangleSubstitution(const NamedDecl *ND);
@@ -786,7 +786,7 @@ static bool isStd(const NamespaceDecl *NS) {
if (!IgnoreLinkageSpecDecls(getEffectiveParentContext(NS))
->isTranslationUnit())
return false;
-
+
const IdentifierInfo *II = NS->getOriginalNamespace()->getIdentifier();
return II && II->isStr("std");
}
@@ -998,7 +998,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(
// ::= <substitution>
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
-
+
if (mangleSubstitution(Template))
return;
@@ -1100,7 +1100,7 @@ void CXXNameMangler::manglePrefix(QualType type) {
if (const auto *TST = type->getAs<TemplateSpecializationType>()) {
if (!mangleSubstitution(QualType(TST, 0))) {
mangleTemplatePrefix(TST->getTemplateName());
-
+
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
@@ -1372,7 +1372,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
// safety, just handle all ObjC containers here.
if (isa<ObjCContainerDecl>(ND))
break;
-
+
// We must have an anonymous struct.
const TagDecl *TD = cast<TagDecl>(ND);
if (const TypedefNameDecl *D = TD->getTypedefNameForAnonDecl()) {
@@ -1389,7 +1389,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
}
// <unnamed-type-name> ::= <closure-type-name>
- //
+ //
// <closure-type-name> ::= Ul <lambda-sig> E [ <nonnegative number> ] _
// <lambda-sig> ::= <parameter-type>+ # Parameter types or 'v' for 'void'.
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
@@ -1515,9 +1515,9 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
const DeclContext *DC,
const AbiTagList *AdditionalAbiTags,
bool NoFunction) {
- // <nested-name>
+ // <nested-name>
// ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E
- // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix>
+ // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix>
// <template-args> E
Out << 'N';
@@ -1530,7 +1530,7 @@ void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
mangleQualifiers(MethodQuals);
mangleRefQualifier(Method->getRefQualifier());
}
-
+
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
@@ -1561,7 +1561,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
const AbiTagList *AdditionalAbiTags) {
// <local-name> := Z <function encoding> E <entity name> [<discriminator>]
// := Z <function encoding> E s [<discriminator>]
- // <local-name> := Z <function encoding> E d [ <parameter number> ]
+ // <local-name> := Z <function encoding> E d [ <parameter number> ]
// _ <entity name>
// <discriminator> := _ <non-negative number>
assert(isa<NamedDecl>(D) || isa<BlockDecl>(D));
@@ -1591,9 +1591,9 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
// be a bug that is fixed in trunk.
if (RD) {
- // The parameter number is omitted for the last parameter, 0 for the
- // second-to-last parameter, 1 for the third-to-last parameter, etc. The
- // <entity name> will of course contain a <closure-type-name>: Its
+ // The parameter number is omitted for the last parameter, 0 for the
+ // second-to-last parameter, 1 for the third-to-last parameter, etc. The
+ // <entity name> will of course contain a <closure-type-name>: Its
// numbering will be local to the particular argument in which it appears
// -- other default arguments do not affect its encoding.
const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD);
@@ -1610,7 +1610,7 @@ void CXXNameMangler::mangleLocalName(const Decl *D,
}
}
}
-
+
// Mangle the name relative to the closest enclosing function.
// equality ok because RD derived from ND above
if (D == RD) {
@@ -1699,8 +1699,8 @@ void CXXNameMangler::mangleUnqualifiedBlock(const BlockDecl *Block) {
}
void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
- // If the context of a closure type is an initializer for a class member
- // (static or nonstatic), it is encoded in a qualified name with a final
+ // If the context of a closure type is an initializer for a class member
+ // (static or nonstatic), it is encoded in a qualified name with a final
// <prefix> of the form:
//
// <data-member-prefix> := <member source-name> M
@@ -1730,9 +1730,9 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
mangleBareFunctionType(Proto, /*MangleReturnType=*/false,
Lambda->getLambdaStaticInvoker());
Out << "E";
-
- // The number is omitted for the first closure type with a given
- // <lambda-sig> in a given context; it is n-2 for the nth closure type
+
+ // The number is omitted for the first closure type with a given
+ // <lambda-sig> in a given context; it is n-2 for the nth closure type
// (in lexical order) with that same <lambda-sig> and context.
//
// The AST keeps track of the number for us.
@@ -1740,7 +1740,7 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
assert(Number > 0 && "Lambda should be mangled as an unnamed class");
if (Number > 1)
mangleNumber(Number - 2);
- Out << '_';
+ Out << '_';
}
void CXXNameMangler::manglePrefix(NestedNameSpecifier *qualifier) {
@@ -1795,10 +1795,10 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
assert(!isLocalContainerContext(DC));
- const NamedDecl *ND = cast<NamedDecl>(DC);
+ const NamedDecl *ND = cast<NamedDecl>(DC);
if (mangleSubstitution(ND))
return;
-
+
// Check if we have a template.
const TemplateArgumentList *TemplateArgs = nullptr;
if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
@@ -2286,19 +2286,19 @@ void CXXNameMangler::mangleQualifiers(Qualifiers Quals, const DependentAddressSp
switch (Quals.getObjCLifetime()) {
case Qualifiers::OCL_None:
break;
-
+
case Qualifiers::OCL_Weak:
// Do nothing as we already handled this case above.
break;
-
+
case Qualifiers::OCL_Strong:
mangleVendorQualifier("__strong");
break;
-
+
case Qualifiers::OCL_Autoreleasing:
mangleVendorQualifier("__autoreleasing");
break;
-
+
case Qualifiers::OCL_ExplicitNone:
// The __unsafe_unretained qualifier is *not* mangled, so that
// __unsafe_unretained types in ARC produce the same manglings as the
@@ -2329,11 +2329,11 @@ void CXXNameMangler::mangleRefQualifier(RefQualifierKind RefQualifier) {
switch (RefQualifier) {
case RQ_None:
break;
-
+
case RQ_LValue:
Out << 'R';
break;
-
+
case RQ_RValue:
Out << 'O';
break;
@@ -2364,15 +2364,15 @@ static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty,
void CXXNameMangler::mangleType(QualType T) {
// If our type is instantiation-dependent but not dependent, we mangle
- // it as it was written in the source, removing any top-level sugar.
+ // it as it was written in the source, removing any top-level sugar.
// Otherwise, use the canonical type.
//
- // FIXME: This is an approximation of the instantiation-dependent name
+ // FIXME: This is an approximation of the instantiation-dependent name
// mangling rules, since we should really be using the type as written and
// augmented via semantic analysis (i.e., with implicit conversions and
- // default template arguments) for any instantiation-dependent type.
+ // default template arguments) for any instantiation-dependent type.
// Unfortunately, that requires several changes to our AST:
- // - Instantiation-dependent TemplateSpecializationTypes will need to be
+ // - Instantiation-dependent TemplateSpecializationTypes will need to be
// uniqued, so that we can handle substitutions properly
// - Default template arguments will need to be represented in the
// TemplateSpecializationType, since they need to be mangled even though
@@ -2402,16 +2402,16 @@ void CXXNameMangler::mangleType(QualType T) {
do {
// Don't desugar through template specialization types that aren't
// type aliases. We need to mangle the template arguments as written.
- if (const TemplateSpecializationType *TST
+ if (const TemplateSpecializationType *TST
= dyn_cast<TemplateSpecializationType>(T))
if (!TST->isTypeAlias())
break;
- QualType Desugared
+ QualType Desugared
= T.getSingleStepDesugaredType(Context.getASTContext());
if (Desugared == T)
break;
-
+
T = Desugared;
} while (true);
}
@@ -2435,7 +2435,7 @@ void CXXNameMangler::mangleType(QualType T) {
}
if (quals || ty->isDependentAddressSpaceType()) {
- if (const DependentAddressSpaceType *DAST =
+ if (const DependentAddressSpaceType *DAST =
dyn_cast<DependentAddressSpaceType>(ty)) {
SplitQualType splitDAST = DAST->getPointeeType().split();
mangleQualifiers(splitDAST.Quals, DAST);
@@ -2899,7 +2899,7 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {
QualType PointeeType = T->getPointeeType();
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(PointeeType)) {
mangleType(FPT);
-
+
// Itanium C++ ABI 5.1.8:
//
// The type of a non-static member function is considered to be different,
@@ -2907,8 +2907,8 @@ void CXXNameMangler::mangleType(const MemberPointerType *T) {
// static member function whose type appears similar. The types of two
// non-static member functions are considered to be different, for the
// purposes of substitution, if the functions are members of different
- // classes. In other words, for the purposes of substitution, the class of
- // which the function is a member is considered part of the type of
+ // classes. In other words, for the purposes of substitution, the class of
+ // which the function is a member is considered part of the type of
// function.
// Given that we already substitute member function pointers as a
@@ -3225,9 +3225,9 @@ void CXXNameMangler::mangleType(const TemplateSpecializationType *T) {
} else {
if (mangleSubstitution(QualType(T, 0)))
return;
-
+
mangleTemplatePrefix(T->getTemplateName());
-
+
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
@@ -3283,7 +3283,7 @@ void CXXNameMangler::mangleType(const DependentTemplateSpecializationType *T) {
// FIXME: GCC does not appear to mangle the template arguments when
// the template in question is a dependent template name. Should we
// emulate that badness?
- mangleTemplateArgs(T->getArgs(), T->getNumArgs());
+ mangleTemplateArgs(T->getArgs(), T->getNumArgs());
Out << 'E';
}
@@ -3328,7 +3328,7 @@ void CXXNameMangler::mangleType(const UnaryTransformType *T) {
// mangle it as the underlying type since they are equivalent.
if (T->isDependentType()) {
Out << 'U';
-
+
switch (T->getUTTKind()) {
case UnaryTransformType::EnumUnderlyingType:
Out << "3eut";
@@ -3498,7 +3498,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
// ::= L <mangled-name> E # external name
// ::= fpT # 'this' expression
QualType ImplicitlyConvertedToType;
-
+
recurse:
switch (E->getStmtClass()) {
case Expr::NoStmtClass:
@@ -3861,24 +3861,24 @@ recurse:
case Expr::UnaryExprOrTypeTraitExprClass: {
const UnaryExprOrTypeTraitExpr *SAE = cast<UnaryExprOrTypeTraitExpr>(E);
-
+
if (!SAE->isInstantiationDependent()) {
// Itanium C++ ABI:
- // If the operand of a sizeof or alignof operator is not
- // instantiation-dependent it is encoded as an integer literal
+ // If the operand of a sizeof or alignof operator is not
+ // instantiation-dependent it is encoded as an integer literal
// reflecting the result of the operator.
//
- // If the result of the operator is implicitly converted to a known
- // integer type, that type is used for the literal; otherwise, the type
+ // If the result of the operator is implicitly converted to a known
+ // integer type, that type is used for the literal; otherwise, the type
// of std::size_t or std::ptrdiff_t is used.
- QualType T = (ImplicitlyConvertedToType.isNull() ||
+ QualType T = (ImplicitlyConvertedToType.isNull() ||
!ImplicitlyConvertedToType->isIntegerType())? SAE->getType()
: ImplicitlyConvertedToType;
llvm::APSInt V = SAE->EvaluateKnownConstInt(Context.getASTContext());
mangleIntegerLiteral(T, V);
break;
}
-
+
switch(SAE->getKind()) {
case UETT_SizeOf:
Out << 's';
@@ -3994,16 +3994,16 @@ recurse:
E = cast<ImplicitCastExpr>(E)->getSubExpr();
goto recurse;
}
-
+
case Expr::ObjCBridgedCastExprClass: {
- // Mangle ownership casts as a vendor extended operator __bridge,
+ // Mangle ownership casts as a vendor extended operator __bridge,
// __bridge_transfer, or __bridge_retain.
StringRef Kind = cast<ObjCBridgedCastExpr>(E)->getBridgeKindName();
Out << "v1U" << Kind.size() << Kind;
}
// Fall through to mangle the cast itself.
LLVM_FALLTHROUGH;
-
+
case Expr::CStyleCastExprClass:
mangleCastExpression(E, "cv");
break;
@@ -4143,7 +4143,7 @@ recurse:
Out << (cast<ObjCBoolLiteralExpr>(E)->getValue() ? '1' : '0');
Out << 'E';
break;
-
+
case Expr::CXXBoolLiteralExprClass:
Out << "Lb";
Out << (cast<CXXBoolLiteralExpr>(E)->getValue() ? '1' : '0');
@@ -4198,12 +4198,12 @@ recurse:
Out << "LDnE";
break;
}
-
+
case Expr::PackExpansionExprClass:
Out << "sp";
mangleExpression(cast<PackExpansionExpr>(E)->getPattern());
break;
-
+
case Expr::SizeOfPackExprClass: {
auto *SPE = cast<SizeOfPackExpr>(E);
if (SPE->isPartiallySubstituted()) {
@@ -4430,11 +4430,11 @@ void CXXNameMangler::mangleTemplateArg(TemplateArgument A) {
// ::= J <template-arg>* E # argument pack
if (!A.isInstantiationDependent() || A.isDependent())
A = Context.getASTContext().getCanonicalTemplateArgument(A);
-
+
switch (A.getKind()) {
case TemplateArgument::Null:
llvm_unreachable("Cannot mangle NULL template argument");
-
+
case TemplateArgument::Type:
mangleType(A.getAsType());
break;
@@ -4461,7 +4461,7 @@ void CXXNameMangler::mangleTemplateArg(TemplateArgument A) {
break;
}
}
-
+
Out << 'X';
mangleExpression(E);
Out << 'E';
@@ -4578,7 +4578,7 @@ bool CXXNameMangler::mangleSubstitution(QualType T) {
bool CXXNameMangler::mangleSubstitution(TemplateName Template) {
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return mangleSubstitution(TD);
-
+
Template = Context.getASTContext().getCanonicalTemplateName(Template);
return mangleSubstitution(
reinterpret_cast<uintptr_t>(Template.getAsVoidPointer()));
@@ -4743,7 +4743,7 @@ void CXXNameMangler::addSubstitution(QualType T) {
void CXXNameMangler::addSubstitution(TemplateName Template) {
if (TemplateDecl *TD = Template.getAsTemplateDecl())
return addSubstitution(TD);
-
+
Template = Context.getASTContext().getCanonicalTemplateName(Template);
addSubstitution(reinterpret_cast<uintptr_t>(Template.getAsVoidPointer()));
}
@@ -4865,14 +4865,14 @@ void ItaniumMangleContextImpl::mangleThunk(const CXXMethodDecl *MD,
// # base is the nominal target function of thunk
// # first call-offset is 'this' adjustment
// # second call-offset is result adjustment
-
+
assert(!isa<CXXDestructorDecl>(MD) &&
"Use mangleCXXDtor for destructor decls!");
CXXNameMangler Mangler(*this, Out);
Mangler.getStream() << "_ZT";
if (!Thunk.Return.isEmpty())
Mangler.getStream() << 'c';
-
+
// Mangle the 'this' pointer adjustment.
Mangler.mangleCallOffset(Thunk.This.NonVirtual,
Thunk.This.Virtual.Itanium.VCallOffsetOffset);
@@ -4894,7 +4894,7 @@ void ItaniumMangleContextImpl::mangleCXXDtorThunk(
Mangler.getStream() << "_ZT";
// Mangle the 'this' pointer adjustment.
- Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
+ Mangler.mangleCallOffset(ThisAdjustment.NonVirtual,
ThisAdjustment.Virtual.Itanium.VCallOffsetOffset);
Mangler.mangleFunctionEncoding(DD);
diff --git a/lib/AST/Mangle.cpp b/lib/AST/Mangle.cpp
index 56a2500274a7..b0e5146e8194 100644
--- a/lib/AST/Mangle.cpp
+++ b/lib/AST/Mangle.cpp
@@ -44,7 +44,7 @@ static void mangleFunctionBlock(MangleContext &Context,
if (discriminator == 0)
Out << "__" << Outer << "_block_invoke";
else
- Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+ Out << "__" << Outer << "_block_invoke_" << discriminator+1;
}
void MangleContext::anchor() { }
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp
index e45f9f7902e2..5db51b5cb384 100644
--- a/lib/AST/MicrosoftMangle.cpp
+++ b/lib/AST/MicrosoftMangle.cpp
@@ -760,7 +760,7 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
// type [ -> template-parameters]
// \-> namespace[s]
// What we do is we create a new mangler, mangle the same type (without
- // a namespace suffix) to a string using the extra mangler and then use
+ // a namespace suffix) to a string using the extra mangler and then use
// the mangled type name as a key to check the mangling of different types
// for aliasing.
@@ -1373,13 +1373,14 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD,
case TemplateArgument::Declaration: {
const NamedDecl *ND = TA.getAsDecl();
if (isa<FieldDecl>(ND) || isa<IndirectFieldDecl>(ND)) {
- mangleMemberDataPointer(
- cast<CXXRecordDecl>(ND->getDeclContext())->getMostRecentNonInjectedDecl(),
- cast<ValueDecl>(ND));
+ mangleMemberDataPointer(cast<CXXRecordDecl>(ND->getDeclContext())
+ ->getMostRecentNonInjectedDecl(),
+ cast<ValueDecl>(ND));
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD);
if (MD && MD->isInstance()) {
- mangleMemberFunctionPointer(MD->getParent()->getMostRecentNonInjectedDecl(), MD);
+ mangleMemberFunctionPointer(
+ MD->getParent()->getMostRecentNonInjectedDecl(), MD);
} else {
Out << "$1?";
mangleName(FD);
@@ -2285,7 +2286,8 @@ void MicrosoftCXXNameMangler::mangleType(const TagDecl *TD) {
// If you add a call to this, consider updating isArtificialTagType() too.
void MicrosoftCXXNameMangler::mangleArtificalTagType(
- TagTypeKind TK, StringRef UnqualifiedName, ArrayRef<StringRef> NestedNames) {
+ TagTypeKind TK, StringRef UnqualifiedName,
+ ArrayRef<StringRef> NestedNames) {
// <name> ::= <unscoped-name> {[<named-scope>]+ | [<nested-name>]}? @
mangleTagTypeKind(TK);
@@ -2372,8 +2374,8 @@ void MicrosoftCXXNameMangler::mangleArrayType(const ArrayType *T) {
// <type> ::= <pointer-to-member-type>
// <pointer-to-member-type> ::= <pointer-cvr-qualifiers> <cvr-qualifiers>
// <class name> <type>
-void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T, Qualifiers Quals,
- SourceRange Range) {
+void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T,
+ Qualifiers Quals, SourceRange Range) {
QualType PointeeType = T->getPointeeType();
manglePointerCVQualifiers(Quals);
manglePointerExtQualifiers(Quals, PointeeType);
diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp
index 536bf2c378fa..94ad87b6e337 100644
--- a/lib/AST/NSAPI.cpp
+++ b/lib/AST/NSAPI.cpp
@@ -432,7 +432,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
return NSAPI::NSNumberWithDouble;
case BuiltinType::Bool:
return NSAPI::NSNumberWithBool;
-
+
case BuiltinType::Void:
case BuiltinType::WChar_U:
case BuiltinType::WChar_S:
@@ -491,7 +491,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
case BuiltinType::OMPArraySection:
break;
}
-
+
return None;
}
@@ -511,7 +511,7 @@ bool NSAPI::isObjCNSUIntegerType(QualType T) const {
StringRef NSAPI::GetNSIntegralKind(QualType T) const {
if (!Ctx.getLangOpts().ObjC1 || T.isNull())
return StringRef();
-
+
while (const TypedefType *TDT = T->getAs<TypedefType>()) {
StringRef NSIntegralResust =
llvm::StringSwitch<StringRef>(
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index 503d0eb65e1e..a514d57b6b6b 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -85,7 +85,7 @@ NestedNameSpecifier::Create(const ASTContext &Context,
NestedNameSpecifier *
NestedNameSpecifier::Create(const ASTContext &Context,
- NestedNameSpecifier *Prefix,
+ NestedNameSpecifier *Prefix,
NamespaceAliasDecl *Alias) {
assert(Alias && "Namespace alias cannot be NULL");
assert((!Prefix ||
@@ -234,7 +234,7 @@ bool NestedNameSpecifier::isInstantiationDependent() const {
case Identifier:
// Identifier specifiers always represent dependent types
return true;
-
+
case Namespace:
case NamespaceAlias:
case Global:
@@ -284,7 +284,7 @@ NestedNameSpecifier::print(raw_ostream &OS,
case Namespace:
if (getAsNamespace()->isAnonymousNamespace())
return;
-
+
OS << getAsNamespace()->getName();
break;
@@ -348,7 +348,7 @@ LLVM_DUMP_METHOD void NestedNameSpecifier::dump() const {
print(llvm::errs(), PrintingPolicy(LO));
}
-unsigned
+unsigned
NestedNameSpecifierLoc::getLocalDataLength(NestedNameSpecifier *Qualifier) {
assert(Qualifier && "Expected a non-NULL qualifier");
@@ -379,7 +379,7 @@ NestedNameSpecifierLoc::getLocalDataLength(NestedNameSpecifier *Qualifier) {
return Length;
}
-unsigned
+unsigned
NestedNameSpecifierLoc::getDataLength(NestedNameSpecifier *Qualifier) {
unsigned Length = 0;
for (; Qualifier; Qualifier = Qualifier->getPrefix())
@@ -394,7 +394,7 @@ static SourceLocation LoadSourceLocation(void *Data, unsigned Offset) {
memcpy(&Raw, static_cast<char *>(Data) + Offset, sizeof(unsigned));
return SourceLocation::getFromRawEncoding(Raw);
}
-
+
/// Load a (possibly unaligned) pointer from a given address and
/// offset.
static void *LoadPointer(void *Data, unsigned Offset) {
@@ -406,19 +406,19 @@ static void *LoadPointer(void *Data, unsigned Offset) {
SourceRange NestedNameSpecifierLoc::getSourceRange() const {
if (!Qualifier)
return SourceRange();
-
+
NestedNameSpecifierLoc First = *this;
while (NestedNameSpecifierLoc Prefix = First.getPrefix())
First = Prefix;
-
- return SourceRange(First.getLocalSourceRange().getBegin(),
+
+ return SourceRange(First.getLocalSourceRange().getBegin(),
getLocalSourceRange().getEnd());
}
SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
if (!Qualifier)
return SourceRange();
-
+
unsigned Offset = getDataLength(Qualifier->getPrefix());
switch (Qualifier->getKind()) {
case NestedNameSpecifier::Global:
@@ -478,7 +478,7 @@ static void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize,
memcpy(Buffer + BufferSize, Start, End - Start);
BufferSize += End-Start;
}
-
+
/// Save a source location to the given buffer.
static void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
unsigned &BufferSize, unsigned &BufferCapacity) {
@@ -487,7 +487,7 @@ static void SaveSourceLocation(SourceLocation Loc, char *&Buffer,
reinterpret_cast<char *>(&Raw) + sizeof(unsigned),
Buffer, BufferSize, BufferCapacity);
}
-
+
/// Save a pointer to the given buffer.
static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
unsigned &BufferCapacity) {
@@ -497,18 +497,18 @@ static void SavePointer(void *Ptr, char *&Buffer, unsigned &BufferSize,
}
NestedNameSpecifierLocBuilder::
-NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
+NestedNameSpecifierLocBuilder(const NestedNameSpecifierLocBuilder &Other)
: Representation(Other.Representation) {
if (!Other.Buffer)
return;
-
+
if (Other.BufferCapacity == 0) {
// Shallow copy is okay.
Buffer = Other.Buffer;
BufferSize = Other.BufferSize;
return;
}
-
+
// Deep copy
Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
BufferCapacity);
@@ -518,72 +518,72 @@ NestedNameSpecifierLocBuilder &
NestedNameSpecifierLocBuilder::
operator=(const NestedNameSpecifierLocBuilder &Other) {
Representation = Other.Representation;
-
+
if (Buffer && Other.Buffer && BufferCapacity >= Other.BufferSize) {
// Re-use our storage.
BufferSize = Other.BufferSize;
memcpy(Buffer, Other.Buffer, BufferSize);
return *this;
}
-
+
// Free our storage, if we have any.
if (BufferCapacity) {
free(Buffer);
BufferCapacity = 0;
}
-
+
if (!Other.Buffer) {
// Empty.
Buffer = nullptr;
BufferSize = 0;
return *this;
}
-
+
if (Other.BufferCapacity == 0) {
// Shallow copy is okay.
Buffer = Other.Buffer;
BufferSize = Other.BufferSize;
return *this;
}
-
+
// Deep copy.
Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize,
BufferCapacity);
return *this;
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
- SourceLocation TemplateKWLoc,
- TypeLoc TL,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+ SourceLocation TemplateKWLoc,
+ TypeLoc TL,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
- TemplateKWLoc.isValid(),
+ Representation = NestedNameSpecifier::Create(Context, Representation,
+ TemplateKWLoc.isValid(),
TL.getTypePtr());
-
+
// Push source-location info into the buffer.
SavePointer(TL.getOpaqueData(), Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
IdentifierInfo *Identifier,
- SourceLocation IdentifierLoc,
+ SourceLocation IdentifierLoc,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
+ Representation = NestedNameSpecifier::Create(Context, Representation,
Identifier);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(IdentifierLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
NamespaceDecl *Namespace,
- SourceLocation NamespaceLoc,
+ SourceLocation NamespaceLoc,
SourceLocation ColonColonLoc) {
- Representation = NestedNameSpecifier::Create(Context, Representation,
+ Representation = NestedNameSpecifier::Create(Context, Representation,
Namespace);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(NamespaceLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
@@ -591,20 +591,20 @@ void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
void NestedNameSpecifierLocBuilder::Extend(ASTContext &Context,
NamespaceAliasDecl *Alias,
- SourceLocation AliasLoc,
+ SourceLocation AliasLoc,
SourceLocation ColonColonLoc) {
Representation = NestedNameSpecifier::Create(Context, Representation, Alias);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(AliasLoc, Buffer, BufferSize, BufferCapacity);
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::MakeGlobal(ASTContext &Context,
+void NestedNameSpecifierLocBuilder::MakeGlobal(ASTContext &Context,
SourceLocation ColonColonLoc) {
assert(!Representation && "Already have a nested-name-specifier!?");
Representation = NestedNameSpecifier::GlobalSpecifier(Context);
-
+
// Push source-location info into the buffer.
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
@@ -620,12 +620,12 @@ void NestedNameSpecifierLocBuilder::MakeSuper(ASTContext &Context,
SaveSourceLocation(ColonColonLoc, Buffer, BufferSize, BufferCapacity);
}
-void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
- NestedNameSpecifier *Qualifier,
+void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
+ NestedNameSpecifier *Qualifier,
SourceRange R) {
Representation = Qualifier;
-
- // Construct bogus (but well-formed) source information for the
+
+ // Construct bogus (but well-formed) source information for the
// nested-name-specifier.
BufferSize = 0;
SmallVector<NestedNameSpecifier *, 4> Stack;
@@ -639,24 +639,24 @@ void NestedNameSpecifierLocBuilder::MakeTrivial(ASTContext &Context,
case NestedNameSpecifier::NamespaceAlias:
SaveSourceLocation(R.getBegin(), Buffer, BufferSize, BufferCapacity);
break;
-
+
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
TypeSourceInfo *TSInfo
= Context.getTrivialTypeSourceInfo(QualType(NNS->getAsType(), 0),
R.getBegin());
- SavePointer(TSInfo->getTypeLoc().getOpaqueData(), Buffer, BufferSize,
+ SavePointer(TSInfo->getTypeLoc().getOpaqueData(), Buffer, BufferSize,
BufferCapacity);
break;
}
-
+
case NestedNameSpecifier::Global:
case NestedNameSpecifier::Super:
break;
}
-
+
// Save the location of the '::'.
- SaveSourceLocation(Stack.empty()? R.getEnd() : R.getBegin(),
+ SaveSourceLocation(Stack.empty()? R.getEnd() : R.getBegin(),
Buffer, BufferSize, BufferCapacity);
}
}
@@ -670,8 +670,8 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
BufferSize = 0;
return;
}
-
- // Rather than copying the data (which is wasteful), "adopt" the
+
+ // Rather than copying the data (which is wasteful), "adopt" the
// pointer (which points into the ASTContext) but set the capacity to zero to
// indicate that we don't own it.
Representation = Other.getNestedNameSpecifier();
@@ -680,16 +680,16 @@ void NestedNameSpecifierLocBuilder::Adopt(NestedNameSpecifierLoc Other) {
BufferCapacity = 0;
}
-NestedNameSpecifierLoc
+NestedNameSpecifierLoc
NestedNameSpecifierLocBuilder::getWithLocInContext(ASTContext &Context) const {
if (!Representation)
return NestedNameSpecifierLoc();
-
+
// If we adopted our data pointer from elsewhere in the AST context, there's
// no need to copy the memory.
if (BufferCapacity == 0)
return NestedNameSpecifierLoc(Representation, Buffer);
-
+
// FIXME: After copying the source-location information, should we free
// our (temporary) buffer and adopt the ASTContext-allocated memory?
// Doing so would optimize repeated calls to getWithLocInContext().
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp
index bc57b20790d9..af2a480dc23f 100644
--- a/lib/AST/ParentMap.cpp
+++ b/lib/AST/ParentMap.cpp
@@ -137,7 +137,7 @@ Stmt *ParentMap::getParentIgnoreParenCasts(Stmt *S) const {
}
while (S && (isa<ParenExpr>(S) || isa<CastExpr>(S)));
- return S;
+ return S;
}
Stmt *ParentMap::getParentIgnoreParenImpCasts(Stmt *S) const {
diff --git a/lib/AST/RecordLayout.cpp b/lib/AST/RecordLayout.cpp
index 37fe029f53bd..9db23d50d0af 100644
--- a/lib/AST/RecordLayout.cpp
+++ b/lib/AST/RecordLayout.cpp
@@ -30,10 +30,12 @@ void ASTRecordLayout::Destroy(ASTContext &Ctx) {
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
CharUnits alignment,
+ CharUnits unadjustedAlignment,
CharUnits requiredAlignment,
CharUnits datasize,
ArrayRef<uint64_t> fieldoffsets)
: Size(size), DataSize(datasize), Alignment(alignment),
+ UnadjustedAlignment(unadjustedAlignment),
RequiredAlignment(requiredAlignment) {
FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
}
@@ -41,6 +43,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
// Constructor for C++ records.
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
CharUnits size, CharUnits alignment,
+ CharUnits unadjustedAlignment,
CharUnits requiredAlignment,
bool hasOwnVFPtr, bool hasExtendableVFPtr,
CharUnits vbptroffset,
@@ -57,6 +60,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
const BaseOffsetsMapTy& BaseOffsets,
const VBaseOffsetsMapTy& VBaseOffsets)
: Size(size), DataSize(datasize), Alignment(alignment),
+ UnadjustedAlignment(unadjustedAlignment),
RequiredAlignment(requiredAlignment), CXXInfo(new (Ctx) CXXRecordLayoutInfo)
{
FieldOffsets.append(Ctx, fieldoffsets.begin(), fieldoffsets.end());
@@ -87,5 +91,5 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
"Primary base must be at offset 0!");
}
}
-#endif
+#endif
}
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index b4b09c7cecd7..6f71d5b83e62 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -105,7 +105,7 @@ struct ExternalLayout {
class EmptySubobjectMap {
const ASTContext &Context;
uint64_t CharWidth;
-
+
/// Class - The class whose empty entries we're keeping track of.
const CXXRecordDecl *Class;
@@ -113,35 +113,35 @@ class EmptySubobjectMap {
typedef llvm::TinyPtrVector<const CXXRecordDecl *> ClassVectorTy;
typedef llvm::DenseMap<CharUnits, ClassVectorTy> EmptyClassOffsetsMapTy;
EmptyClassOffsetsMapTy EmptyClassOffsets;
-
+
/// MaxEmptyClassOffset - The highest offset known to contain an empty
/// base subobject.
CharUnits MaxEmptyClassOffset;
-
+
/// ComputeEmptySubobjectSizes - Compute the size of the largest base or
/// member subobject that is empty.
void ComputeEmptySubobjectSizes();
-
+
void AddSubobjectAtOffset(const CXXRecordDecl *RD, CharUnits Offset);
-
+
void UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
CharUnits Offset, bool PlacingEmptyBase);
-
- void UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
+
+ void UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
CharUnits Offset);
void UpdateEmptyFieldSubobjects(const FieldDecl *FD, CharUnits Offset);
-
+
/// AnyEmptySubobjectsBeyondOffset - Returns whether there are any empty
/// subobjects beyond the given offset.
bool AnyEmptySubobjectsBeyondOffset(CharUnits Offset) const {
return Offset <= MaxEmptyClassOffset;
}
- CharUnits
+ CharUnits
getFieldOffset(const ASTRecordLayout &Layout, unsigned FieldNo) const {
uint64_t FieldOffset = Layout.getFieldOffset(FieldNo);
- assert(FieldOffset % CharWidth == 0 &&
+ assert(FieldOffset % CharWidth == 0 &&
"Field offset not at char boundary!");
return Context.toCharUnitsFromBits(FieldOffset);
@@ -154,7 +154,7 @@ protected:
bool CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
CharUnits Offset);
- bool CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
+ bool CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
CharUnits Offset) const;
bool CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
@@ -228,7 +228,7 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() {
}
bool
-EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
+EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
CharUnits Offset) const {
// We only need to check empty bases.
if (!RD->isEmpty())
@@ -245,8 +245,8 @@ EmptySubobjectMap::CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
// There is already an empty class of the same type at this offset.
return false;
}
-
-void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD,
+
+void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD,
CharUnits Offset) {
// We only care about empty bases.
if (!RD->isEmpty())
@@ -257,9 +257,9 @@ void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD,
ClassVectorTy &Classes = EmptyClassOffsets[Offset];
if (std::find(Classes.begin(), Classes.end(), RD) != Classes.end())
return;
-
+
Classes.push_back(RD);
-
+
// Update the empty class offset.
if (Offset > MaxEmptyClassOffset)
MaxEmptyClassOffset = Offset;
@@ -296,10 +296,10 @@ EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
return false;
}
}
-
+
// Traverse all member variables.
unsigned FieldNo = 0;
- for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
+ for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
E = Info->Class->field_end(); I != E; ++I, ++FieldNo) {
if (I->isBitField())
continue;
@@ -312,15 +312,15 @@ EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
return true;
}
-void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
+void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
CharUnits Offset,
bool PlacingEmptyBase) {
if (!PlacingEmptyBase && Offset >= SizeOfLargestEmptySubobject) {
// We know that the only empty subobjects that can conflict with empty
// subobject of non-empty bases, are empty bases that can be placed at
- // offset zero. Because of this, we only need to keep track of empty base
+ // offset zero. Because of this, we only need to keep track of empty base
// subobjects with offsets less than the size of the largest empty
- // subobject for our class.
+ // subobject for our class.
return;
}
@@ -338,7 +338,7 @@ void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
if (Info->PrimaryVirtualBaseInfo) {
BaseSubobjectInfo *PrimaryVirtualBaseInfo = Info->PrimaryVirtualBaseInfo;
-
+
if (Info == PrimaryVirtualBaseInfo->Derived)
UpdateEmptyBaseSubobjects(PrimaryVirtualBaseInfo, Offset,
PlacingEmptyBase);
@@ -346,7 +346,7 @@ void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
// Traverse all member variables.
unsigned FieldNo = 0;
- for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
+ for (CXXRecordDecl::field_iterator I = Info->Class->field_begin(),
E = Info->Class->field_end(); I != E; ++I, ++FieldNo) {
if (I->isBitField())
continue;
@@ -373,7 +373,7 @@ bool EmptySubobjectMap::CanPlaceBaseAtOffset(const BaseSubobjectInfo *Info,
}
bool
-EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
+EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
CharUnits Offset) const {
// We don't have to keep looking past the maximum offset that's known to
@@ -383,7 +383,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
if (!CanPlaceSubobjectAtOffset(RD, Offset))
return false;
-
+
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
// Traverse all non-virtual bases.
@@ -408,7 +408,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
return false;
}
}
-
+
// Traverse all member variables.
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
@@ -417,7 +417,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
continue;
CharUnits FieldOffset = Offset + getFieldOffset(Layout, FieldNo);
-
+
if (!CanPlaceFieldSubobjectAtOffset(*I, FieldOffset))
return false;
}
@@ -432,7 +432,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
// contain an empty class.
if (!AnyEmptySubobjectsBeyondOffset(Offset))
return true;
-
+
QualType T = FD->getType();
if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
return CanPlaceFieldSubobjectAtOffset(RD, RD, Offset);
@@ -454,7 +454,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
// contain an empty class.
if (!AnyEmptySubobjectsBeyondOffset(ElementOffset))
return true;
-
+
if (!CanPlaceFieldSubobjectAtOffset(RD, RD, ElementOffset))
return false;
@@ -466,23 +466,23 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const FieldDecl *FD,
}
bool
-EmptySubobjectMap::CanPlaceFieldAtOffset(const FieldDecl *FD,
+EmptySubobjectMap::CanPlaceFieldAtOffset(const FieldDecl *FD,
CharUnits Offset) {
if (!CanPlaceFieldSubobjectAtOffset(FD, Offset))
return false;
-
+
// We are able to place the member variable at this offset.
// Make sure to update the empty base subobject map.
UpdateEmptyFieldSubobjects(FD, Offset);
return true;
}
-void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
+void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
CharUnits Offset) {
// We know that the only empty subobjects that can conflict with empty
// field subobjects are subobjects of empty bases that can be placed at offset
- // zero. Because of this, we only need to keep track of empty field
+ // zero. Because of this, we only need to keep track of empty field
// subobjects with offsets less than the size of the largest empty
// subobject for our class.
if (Offset >= SizeOfLargestEmptySubobject)
@@ -512,7 +512,7 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
UpdateEmptyFieldSubobjects(VBaseDecl, Class, VBaseOffset);
}
}
-
+
// Traverse all member variables.
unsigned FieldNo = 0;
for (CXXRecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end();
@@ -525,7 +525,7 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
UpdateEmptyFieldSubobjects(*I, FieldOffset);
}
}
-
+
void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const FieldDecl *FD,
CharUnits Offset) {
QualType T = FD->getType();
@@ -543,13 +543,13 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const FieldDecl *FD,
const CXXRecordDecl *RD = RT->getAsCXXRecordDecl();
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
-
+
uint64_t NumElements = Context.getConstantArrayElementCount(AT);
CharUnits ElementOffset = Offset;
-
+
for (uint64_t I = 0; I != NumElements; ++I) {
// We know that the only empty subobjects that can conflict with empty
- // field subobjects are subobjects of empty bases that can be placed at
+ // field subobjects are subobjects of empty bases that can be placed at
// offset zero. Because of this, we only need to keep track of empty field
// subobjects with offsets less than the size of the largest empty
// subobject for our class.
@@ -582,23 +582,26 @@ protected:
/// The alignment if attribute packed is not used.
CharUnits UnpackedAlignment;
+ /// \brief The maximum of the alignments of top-level members.
+ CharUnits UnadjustedAlignment;
+
SmallVector<uint64_t, 16> FieldOffsets;
/// Whether the external AST source has provided a layout for this
/// record.
unsigned UseExternalLayout : 1;
- /// Whether we need to infer alignment, even when we have an
+ /// Whether we need to infer alignment, even when we have an
/// externally-provided layout.
unsigned InferAlignment : 1;
-
+
/// Packed - Whether the record is packed or not.
unsigned Packed : 1;
unsigned IsUnion : 1;
unsigned IsMac68kAlign : 1;
-
+
unsigned IsMsStruct : 1;
/// UnfilledBitsInLastUnit - If the last field laid out was a bitfield,
@@ -662,6 +665,7 @@ protected:
EmptySubobjectMap *EmptySubobjects)
: Context(Context), EmptySubobjects(EmptySubobjects), Size(0),
Alignment(CharUnits::One()), UnpackedAlignment(CharUnits::One()),
+ UnadjustedAlignment(CharUnits::One()),
UseExternalLayout(false), InferAlignment(false), Packed(false),
IsUnion(false), IsMac68kAlign(false), IsMsStruct(false),
UnfilledBitsInLastUnit(0), LastBitfieldTypeSize(0),
@@ -687,14 +691,14 @@ protected:
/// BaseSubobjectInfoAllocator - Allocator for BaseSubobjectInfo objects.
llvm::SpecificBumpPtrAllocator<BaseSubobjectInfo> BaseSubobjectInfoAllocator;
-
+
typedef llvm::DenseMap<const CXXRecordDecl *, BaseSubobjectInfo *>
BaseSubobjectInfoMapTy;
/// VirtualBaseInfo - Map from all the (direct or indirect) virtual bases
/// of the class we're laying out to their base subobject info.
BaseSubobjectInfoMapTy VirtualBaseInfo;
-
+
/// NonVirtualBaseInfo - Map from all the direct non-virtual bases of the
/// class we're laying out to their base subobject info.
BaseSubobjectInfoMapTy NonVirtualBaseInfo;
@@ -705,7 +709,7 @@ protected:
/// ComputeBaseSubobjectInfo - Compute the base subobject information for a
/// single class and all of its base classes.
- BaseSubobjectInfo *ComputeBaseSubobjectInfo(const CXXRecordDecl *RD,
+ BaseSubobjectInfo *ComputeBaseSubobjectInfo(const CXXRecordDecl *RD,
bool IsVirtual,
BaseSubobjectInfo *Derived);
@@ -754,18 +758,18 @@ protected:
///
/// \param Field The field whose offset is being queried.
/// \param ComputedOffset The offset that we've computed for this field.
- uint64_t updateExternalFieldOffset(const FieldDecl *Field,
+ uint64_t updateExternalFieldOffset(const FieldDecl *Field,
uint64_t ComputedOffset);
-
+
void CheckFieldPadding(uint64_t Offset, uint64_t UnpaddedOffset,
uint64_t UnpackedOffset, unsigned UnpackedAlign,
bool isPacked, const FieldDecl *D);
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
- CharUnits getSize() const {
+ CharUnits getSize() const {
assert(Size % Context.getCharWidth() == 0);
- return Context.toCharUnitsFromBits(Size);
+ return Context.toCharUnitsFromBits(Size);
}
uint64_t getSizeInBits() const { return Size; }
@@ -774,9 +778,9 @@ protected:
CharUnits getAligment() const { return Alignment; }
- CharUnits getDataSize() const {
+ CharUnits getDataSize() const {
assert(DataSize % Context.getCharWidth() == 0);
- return Context.toCharUnitsFromBits(DataSize);
+ return Context.toCharUnitsFromBits(DataSize);
}
uint64_t getDataSizeInBits() const { return DataSize; }
@@ -867,7 +871,7 @@ void ItaniumRecordLayoutBuilder::DeterminePrimaryBase(const CXXRecordDecl *RD) {
BaseSubobjectInfo *ItaniumRecordLayoutBuilder::ComputeBaseSubobjectInfo(
const CXXRecordDecl *RD, bool IsVirtual, BaseSubobjectInfo *Derived) {
BaseSubobjectInfo *Info;
-
+
if (IsVirtual) {
// Check if we already have info about this virtual base.
BaseSubobjectInfo *&InfoSlot = VirtualBaseInfo[RD];
@@ -882,7 +886,7 @@ BaseSubobjectInfo *ItaniumRecordLayoutBuilder::ComputeBaseSubobjectInfo(
} else {
Info = new (BaseSubobjectInfoAllocator.Allocate()) BaseSubobjectInfo;
}
-
+
Info->Class = RD;
Info->IsVirtual = IsVirtual;
Info->Derived = nullptr;
@@ -898,10 +902,10 @@ BaseSubobjectInfo *ItaniumRecordLayoutBuilder::ComputeBaseSubobjectInfo(
// This base does have a primary virtual base.
PrimaryVirtualBase = Layout.getPrimaryBase();
assert(PrimaryVirtualBase && "Didn't have a primary virtual base!");
-
+
// Now check if we have base subobject info about this primary base.
PrimaryVirtualBaseInfo = VirtualBaseInfo.lookup(PrimaryVirtualBase);
-
+
if (PrimaryVirtualBaseInfo) {
if (PrimaryVirtualBaseInfo->Derived) {
// We did have info about this primary base, and it turns out that it
@@ -925,19 +929,19 @@ BaseSubobjectInfo *ItaniumRecordLayoutBuilder::ComputeBaseSubobjectInfo(
Info->Bases.push_back(ComputeBaseSubobjectInfo(BaseDecl, IsVirtual, Info));
}
-
+
if (PrimaryVirtualBase && !PrimaryVirtualBaseInfo) {
// Traversing the bases must have created the base info for our primary
// virtual base.
PrimaryVirtualBaseInfo = VirtualBaseInfo.lookup(PrimaryVirtualBase);
assert(PrimaryVirtualBaseInfo &&
"Did not create a primary virtual base!");
-
+
// Claim the primary virtual base as our primary virtual base.
Info->PrimaryVirtualBaseInfo = PrimaryVirtualBaseInfo;
PrimaryVirtualBaseInfo->Derived = Info;
}
-
+
return Info;
}
@@ -990,7 +994,7 @@ void ItaniumRecordLayoutBuilder::LayoutNonVirtualBases(
// Compute base subobject info.
ComputeBaseSubobjectInfo(RD);
-
+
// If we have a primary base class, lay it out.
if (PrimaryBase) {
if (PrimaryBaseIsVirtual) {
@@ -1008,9 +1012,9 @@ void ItaniumRecordLayoutBuilder::LayoutNonVirtualBases(
LayoutVirtualBase(PrimaryBaseInfo);
} else {
- BaseSubobjectInfo *PrimaryBaseInfo =
+ BaseSubobjectInfo *PrimaryBaseInfo =
NonVirtualBaseInfo.lookup(PrimaryBase);
- assert(PrimaryBaseInfo &&
+ assert(PrimaryBaseInfo &&
"Did not find base info for non-virtual primary base!");
LayoutNonVirtualBase(PrimaryBaseInfo);
@@ -1020,9 +1024,9 @@ void ItaniumRecordLayoutBuilder::LayoutNonVirtualBases(
// primary base, add it in now.
} else if (RD->isDynamicClass()) {
assert(DataSize == 0 && "Vtable pointer must be at offset zero!");
- CharUnits PtrWidth =
+ CharUnits PtrWidth =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
- CharUnits PtrAlign =
+ CharUnits PtrAlign =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
EnsureVTablePointerAlignment(PtrAlign);
HasOwnVFPtr = true;
@@ -1070,14 +1074,14 @@ void ItaniumRecordLayoutBuilder::AddPrimaryVirtualBaseOffsets(
// This base isn't interesting, it has no virtual bases.
if (!Info->Class->getNumVBases())
return;
-
+
// First, check if we have a virtual primary base to add offsets for.
if (Info->PrimaryVirtualBaseInfo) {
- assert(Info->PrimaryVirtualBaseInfo->IsVirtual &&
+ assert(Info->PrimaryVirtualBaseInfo->IsVirtual &&
"Primary virtual base is not virtual!");
if (Info->PrimaryVirtualBaseInfo->Derived == Info) {
// Add the offset.
- assert(!VBases.count(Info->PrimaryVirtualBaseInfo->Class) &&
+ assert(!VBases.count(Info->PrimaryVirtualBaseInfo->Class) &&
"primary vbase offset already exists!");
VBases.insert(std::make_pair(Info->PrimaryVirtualBaseInfo->Class,
ASTRecordLayout::VBaseInfo(Offset, false)));
@@ -1147,13 +1151,13 @@ void ItaniumRecordLayoutBuilder::LayoutVirtualBases(
void ItaniumRecordLayoutBuilder::LayoutVirtualBase(
const BaseSubobjectInfo *Base) {
assert(!Base->Derived && "Trying to lay out a primary virtual base!");
-
+
// Layout the base.
CharUnits Offset = LayoutBase(Base);
// Add its base class offset.
assert(!VBases.count(Base->Class) && "vbase offset already exists!");
- VBases.insert(std::make_pair(Base->Class,
+ VBases.insert(std::make_pair(Base->Class,
ASTRecordLayout::VBaseInfo(Offset, false)));
AddPrimaryVirtualBaseOffsets(Base, Offset);
@@ -1163,9 +1167,9 @@ CharUnits
ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(Base->Class);
-
+
CharUnits Offset;
-
+
// Query the external layout to see if it provides an offset.
bool HasExternalLayout = false;
if (UseExternalLayout) {
@@ -1174,7 +1178,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
else
HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
}
-
+
// Clang <= 6 incorrectly applied the 'packed' attribute to base classes.
// Per GCC's documentation, it only applies to non-static data members.
CharUnits UnpackedBaseAlign = Layout.getNonVirtualAlignment();
@@ -1220,7 +1224,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
InferAlignment = false;
}
}
-
+
if (!Base->Class->isEmpty()) {
// Update the data size.
setDataSize(Offset + Layout.getNonVirtualSize());
@@ -1241,7 +1245,7 @@ void ItaniumRecordLayoutBuilder::InitializeLayout(const Decl *D) {
IsMsStruct = RD->isMsStruct(Context);
}
- Packed = D->hasAttr<PackedAttr>();
+ Packed = D->hasAttr<PackedAttr>();
// Honor the default struct packing maximum alignment flag.
if (unsigned DefaultMaxFieldAlignment = Context.getLangOpts().PackStruct) {
@@ -1263,7 +1267,7 @@ void ItaniumRecordLayoutBuilder::InitializeLayout(const Decl *D) {
if (unsigned MaxAlign = D->getMaxAlignment())
UpdateAlignment(Context.toCharUnitsFromBits(MaxAlign));
}
-
+
// If there is an external AST source, ask it for the various offsets.
if (const RecordDecl *RD = dyn_cast<RecordDecl>(D))
if (ExternalASTSource *Source = Context.getExternalSource()) {
@@ -1417,7 +1421,7 @@ void ItaniumRecordLayoutBuilder::LayoutWideBitField(uint64_t FieldSize,
setDataSize(std::max(getDataSizeInBits(), RoundedFieldSize));
FieldOffset = 0;
} else {
- // The bitfield is allocated starting at the next offset aligned
+ // The bitfield is allocated starting at the next offset aligned
// appropriately for T', with length n bits.
FieldOffset = llvm::alignTo(getDataSizeInBits(), Context.toBits(TypeAlign));
@@ -1609,7 +1613,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
bool AllowPadding = MaxFieldAlignment.isZero();
// Compute the real offset.
- if (FieldSize == 0 ||
+ if (FieldSize == 0 ||
(AllowPadding &&
(FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
FieldOffset = llvm::alignTo(FieldOffset, FieldAlign);
@@ -1707,7 +1711,9 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
setSize(std::max(getSizeInBits(), getDataSizeInBits()));
// Remember max struct/class alignment.
- UpdateAlignment(Context.toCharUnitsFromBits(FieldAlign),
+ UnadjustedAlignment =
+ std::max(UnadjustedAlignment, Context.toCharUnitsFromBits(FieldAlign));
+ UpdateAlignment(Context.toCharUnitsFromBits(FieldAlign),
Context.toCharUnitsFromBits(UnpackedFieldAlign));
}
@@ -1725,7 +1731,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
LastBitfieldTypeSize = 0;
bool FieldPacked = Packed || D->hasAttr<PackedAttr>();
- CharUnits FieldOffset =
+ CharUnits FieldOffset =
IsUnion ? CharUnits::Zero() : getDataSize();
CharUnits FieldSize;
CharUnits FieldAlign;
@@ -1740,12 +1746,12 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
FieldAlign = Context.getTypeAlignInChars(ATy->getElementType());
} else if (const ReferenceType *RT = D->getType()->getAs<ReferenceType>()) {
unsigned AS = Context.getTargetAddressSpace(RT->getPointeeType());
- FieldSize =
+ FieldSize =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(AS));
- FieldAlign =
+ FieldAlign =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(AS));
} else {
- std::pair<CharUnits, CharUnits> FieldInfo =
+ std::pair<CharUnits, CharUnits> FieldInfo =
Context.getTypeInfoInChars(D->getType());
FieldSize = FieldInfo.first;
FieldAlign = FieldInfo.second;
@@ -1753,7 +1759,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
if (IsMsStruct) {
// If MS bitfield layout is required, figure out what type is being
// laid out and align the field to the width of that type.
-
+
// Resolve all typedefs down to their base type and round up the field
// alignment if necessary.
QualType T = Context.getBaseElementType(D->getType());
@@ -1799,7 +1805,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
if (FieldPacked)
FieldAlign = CharUnits::One();
- CharUnits MaxAlignmentInChars =
+ CharUnits MaxAlignmentInChars =
Context.toCharUnitsFromBits(D->getMaxAlignment());
FieldAlign = std::max(FieldAlign, MaxAlignmentInChars);
UnpackedFieldAlign = std::max(UnpackedFieldAlign, MaxAlignmentInChars);
@@ -1817,12 +1823,12 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
if (UseExternalLayout) {
FieldOffset = Context.toCharUnitsFromBits(
updateExternalFieldOffset(D, Context.toBits(FieldOffset)));
-
+
if (!IsUnion && EmptySubobjects) {
// Record the fact that we're placing a field at this offset.
bool Allowed = EmptySubobjects->CanPlaceFieldAtOffset(D, FieldOffset);
(void)Allowed;
- assert(Allowed && "Externally-placed field cannot be placed here");
+ assert(Allowed && "Externally-placed field cannot be placed here");
}
} else {
if (!IsUnion && EmptySubobjects) {
@@ -1833,12 +1839,12 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
}
}
}
-
+
// Place this field at the current location.
FieldOffsets.push_back(Context.toBits(FieldOffset));
if (!UseExternalLayout)
- CheckFieldPadding(Context.toBits(FieldOffset), UnpaddedFieldOffset,
+ CheckFieldPadding(Context.toBits(FieldOffset), UnpaddedFieldOffset,
Context.toBits(UnpackedFieldOffset),
Context.toBits(UnpackedFieldAlign), FieldPacked, D);
@@ -1862,6 +1868,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
setSize(std::max(getSizeInBits(), getDataSizeInBits()));
// Remember max struct/class alignment.
+ UnadjustedAlignment = std::max(UnadjustedAlignment, FieldAlign);
UpdateAlignment(FieldAlign, UnpackedFieldAlign);
}
@@ -1959,7 +1966,7 @@ ItaniumRecordLayoutBuilder::updateExternalFieldOffset(const FieldDecl *Field,
Alignment = CharUnits::One();
InferAlignment = false;
}
-
+
// Use the externally-supplied field offset.
return ExternalFieldOffset;
}
@@ -1990,7 +1997,7 @@ void ItaniumRecordLayoutBuilder::CheckFieldPadding(
// be done by clients of the AST, such as codegen.
if (D->getLocation().isInvalid())
return;
-
+
unsigned CharBitNum = Context.getTargetInfo().getCharWidth();
// Warn if padding was introduced to the struct/class.
@@ -2445,7 +2452,9 @@ void MicrosoftRecordLayoutBuilder::cxxLayout(const CXXRecordDecl *RD) {
auto RoundingAlignment = Alignment;
if (!MaxFieldAlignment.isZero())
RoundingAlignment = std::min(RoundingAlignment, MaxFieldAlignment);
- NonVirtualSize = Size = Size.alignTo(RoundingAlignment);
+ if (!UseExternalLayout)
+ Size = Size.alignTo(RoundingAlignment);
+ NonVirtualSize = Size;
RequiredAlignment = std::max(
RequiredAlignment, Context.toCharUnitsFromBits(RD->getMaxAlignment()));
layoutVirtualBases(RD);
@@ -2646,21 +2655,16 @@ void MicrosoftRecordLayoutBuilder::layoutField(const FieldDecl *FD) {
LastFieldIsNonZeroWidthBitfield = false;
ElementInfo Info = getAdjustedElementInfo(FD);
Alignment = std::max(Alignment, Info.Alignment);
- if (IsUnion) {
- placeFieldAtOffset(CharUnits::Zero());
- Size = std::max(Size, Info.Size);
- } else {
- CharUnits FieldOffset;
- if (UseExternalLayout) {
- FieldOffset =
- Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
- assert(FieldOffset >= Size && "field offset already allocated");
- } else {
- FieldOffset = Size.alignTo(Info.Alignment);
- }
- placeFieldAtOffset(FieldOffset);
- Size = FieldOffset + Info.Size;
- }
+ CharUnits FieldOffset;
+ if (UseExternalLayout)
+ FieldOffset =
+ Context.toCharUnitsFromBits(External.getExternalFieldOffset(FD));
+ else if (IsUnion)
+ FieldOffset = CharUnits::Zero();
+ else
+ FieldOffset = Size.alignTo(Info.Alignment);
+ placeFieldAtOffset(FieldOffset);
+ Size = std::max(Size, FieldOffset + Info.Size);
}
void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
@@ -2685,18 +2689,17 @@ void MicrosoftRecordLayoutBuilder::layoutBitField(const FieldDecl *FD) {
}
LastFieldIsNonZeroWidthBitfield = true;
CurrentBitfieldSize = Info.Size;
- if (IsUnion) {
- placeFieldAtOffset(CharUnits::Zero());
- Size = std::max(Size, Info.Size);
- // TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
- } else if (UseExternalLayout) {
+ if (UseExternalLayout) {
auto FieldBitOffset = External.getExternalFieldOffset(FD);
placeFieldAtBitOffset(FieldBitOffset);
auto NewSize = Context.toCharUnitsFromBits(
llvm::alignTo(FieldBitOffset + Width, Context.getCharWidth()));
- assert(NewSize >= Size && "bit field offset already allocated");
- Size = NewSize;
+ Size = std::max(Size, NewSize);
Alignment = std::max(Alignment, Info.Alignment);
+ } else if (IsUnion) {
+ placeFieldAtOffset(CharUnits::Zero());
+ Size = std::max(Size, Info.Size);
+ // TODO: Add a Sema warning that MS ignores bitfield alignment in unions.
} else {
// Allocate a new block of memory and place the bitfield in it.
CharUnits FieldOffset = Size.alignTo(Info.Alignment);
@@ -2969,7 +2972,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
if (D->hasExternalLexicalStorage() && !D->getDefinition())
getExternalSource()->CompleteType(const_cast<RecordDecl*>(D));
-
+
D = D->getDefinition();
assert(D && "Cannot get layout of forward declarations!");
assert(!D->isInvalidDecl() && "Cannot get layout of invalid decl!");
@@ -2988,7 +2991,8 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
Builder.cxxLayout(RD);
NewEntry = new (*this) ASTRecordLayout(
- *this, Builder.Size, Builder.Alignment, Builder.RequiredAlignment,
+ *this, Builder.Size, Builder.Alignment, Builder.Alignment,
+ Builder.RequiredAlignment,
Builder.HasOwnVFPtr, Builder.HasOwnVFPtr || Builder.PrimaryBase,
Builder.VBPtrOffset, Builder.DataSize, Builder.FieldOffsets,
Builder.NonVirtualSize, Builder.Alignment, CharUnits::Zero(),
@@ -2998,7 +3002,8 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
} else {
Builder.layout(D);
NewEntry = new (*this) ASTRecordLayout(
- *this, Builder.Size, Builder.Alignment, Builder.RequiredAlignment,
+ *this, Builder.Size, Builder.Alignment, Builder.Alignment,
+ Builder.RequiredAlignment,
Builder.Size, Builder.FieldOffsets);
}
} else {
@@ -3019,7 +3024,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
CharUnits NonVirtualSize =
skipTailPadding ? DataSize : Builder.NonVirtualSize;
NewEntry = new (*this) ASTRecordLayout(
- *this, Builder.getSize(), Builder.Alignment,
+ *this, Builder.getSize(), Builder.Alignment, Builder.UnadjustedAlignment,
/*RequiredAlignment : used by MS-ABI)*/
Builder.Alignment, Builder.HasOwnVFPtr, RD->isDynamicClass(),
CharUnits::fromQuantity(-1), DataSize, Builder.FieldOffsets,
@@ -3032,7 +3037,7 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
Builder.Layout(D);
NewEntry = new (*this) ASTRecordLayout(
- *this, Builder.getSize(), Builder.Alignment,
+ *this, Builder.getSize(), Builder.Alignment, Builder.UnadjustedAlignment,
/*RequiredAlignment : used by MS-ABI)*/
Builder.Alignment, Builder.getSize(), Builder.FieldOffsets);
}
@@ -3186,6 +3191,7 @@ ASTContext::getObjCLayout(const ObjCInterfaceDecl *D,
const ASTRecordLayout *NewEntry =
new (*this) ASTRecordLayout(*this, Builder.getSize(),
Builder.Alignment,
+ Builder.UnadjustedAlignment,
/*RequiredAlignment : used by MS-ABI)*/
Builder.Alignment,
Builder.getDataSize(),
@@ -3215,7 +3221,7 @@ static void PrintBitFieldOffset(raw_ostream &OS, CharUnits Offset,
BufferOS << Begin << '-' << (Begin + Width - 1);
}
}
-
+
OS << llvm::right_justify(Buffer, 10) << " | ";
OS.indent(IndentLevel * 2);
}
@@ -3323,7 +3329,7 @@ static void DumpRecordLayout(raw_ostream &OS, const RecordDecl *RD,
// Dump virtual bases.
if (CXXRD && IncludeVirtualBases) {
- const ASTRecordLayout::VBaseOffsetsMapTy &VtorDisps =
+ const ASTRecordLayout::VBaseOffsetsMapTy &VtorDisps =
Layout.getVBaseOffsetsMap();
for (const CXXBaseSpecifier &Base : CXXRD->vbases()) {
diff --git a/lib/AST/StmtOpenMP.cpp b/lib/AST/StmtOpenMP.cpp
index 87bf5aaaa585..1258af7a2d37 100644
--- a/lib/AST/StmtOpenMP.cpp
+++ b/lib/AST/StmtOpenMP.cpp
@@ -1222,9 +1222,9 @@ OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
alignof(OMPClause *));
void *Mem = C.Allocate(
Size + sizeof(OMPClause *) * Clauses.size() +
- sizeof(Stmt *) *
+ sizeof(Stmt *) *
numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
- OMPTargetParallelForSimdDirective *Dir =
+ OMPTargetParallelForSimdDirective *Dir =
new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
CollapsedNum, Clauses.size());
Dir->setClauses(Clauses);
@@ -1262,20 +1262,20 @@ OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
alignof(OMPClause *));
void *Mem = C.Allocate(
Size + sizeof(OMPClause *) * NumClauses +
- sizeof(Stmt *) *
+ sizeof(Stmt *) *
numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
}
OMPTargetSimdDirective *
-OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
+OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
SourceLocation EndLoc, unsigned CollapsedNum,
ArrayRef<OMPClause *> Clauses,
Stmt *AssociatedStmt, const HelperExprs &Exprs) {
unsigned Size =
llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
- sizeof(Stmt *) *
+ sizeof(Stmt *) *
numLoopChildren(CollapsedNum, OMPD_target_simd));
OMPTargetSimdDirective *Dir = new (Mem)
OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
@@ -1303,7 +1303,7 @@ OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
unsigned Size =
llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
- sizeof(Stmt *) *
+ sizeof(Stmt *) *
numLoopChildren(CollapsedNum, OMPD_target_simd));
return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
}
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index dad57de8940b..cbf26c036058 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -366,13 +366,13 @@ void StmtPrinter::VisitMSDependentExistsStmt(MSDependentExistsStmt *Node) {
OS << "__if_exists (";
else
OS << "__if_not_exists (";
-
+
if (NestedNameSpecifier *Qualifier
= Node->getQualifierLoc().getNestedNameSpecifier())
Qualifier->print(OS, Policy);
-
+
OS << Node->getNameInfo() << ") ";
-
+
PrintRawCompoundStmt(Node->getSubStmt());
}
@@ -990,7 +990,7 @@ void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
OS << "map(";
if (Node->getMapType() != OMPC_MAP_unknown) {
if (Node->getMapTypeModifier() != OMPC_MAP_unknown) {
- OS << getOpenMPSimpleClauseTypeName(OMPC_map,
+ OS << getOpenMPSimpleClauseTypeName(OMPC_map,
Node->getMapTypeModifier());
OS << ',';
}
@@ -1645,12 +1645,12 @@ void StmtPrinter::VisitOffsetOfExpr(OffsetOfExpr *Node) {
IdentifierInfo *Id = ON.getFieldName();
if (!Id)
continue;
-
+
if (PrintedSomething)
OS << ".";
else
PrintedSomething = true;
- OS << Id->getName();
+ OS << Id->getName();
}
OS << ")";
}
@@ -2672,7 +2672,7 @@ void StmtPrinter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
if (I > 0)
OS << ", ";
-
+
ObjCDictionaryElement Element = E->getKeyValueElement(I);
Visit(Element.Key);
OS << " : ";
@@ -2781,7 +2781,7 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
OS << "{ }";
}
-void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
+void StmtPrinter::VisitOpaqueValueExpr(OpaqueValueExpr *Node) {
PrintExpr(Node->getSourceExpr());
}
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 791ec569cc41..15653c4fd838 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -1277,25 +1277,24 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Arrow:
case OO_Call:
case OO_Conditional:
- case OO_Coawait:
case NUM_OVERLOADED_OPERATORS:
llvm_unreachable("Invalid operator call kind");
-
+
case OO_Plus:
if (S->getNumArgs() == 1) {
UnaryOp = UO_Plus;
return Stmt::UnaryOperatorClass;
}
-
+
BinaryOp = BO_Add;
return Stmt::BinaryOperatorClass;
-
+
case OO_Minus:
if (S->getNumArgs() == 1) {
UnaryOp = UO_Minus;
return Stmt::UnaryOperatorClass;
}
-
+
BinaryOp = BO_Sub;
return Stmt::BinaryOperatorClass;
@@ -1304,14 +1303,14 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
UnaryOp = UO_Deref;
return Stmt::UnaryOperatorClass;
}
-
+
BinaryOp = BO_Mul;
return Stmt::BinaryOperatorClass;
case OO_Slash:
BinaryOp = BO_Div;
return Stmt::BinaryOperatorClass;
-
+
case OO_Percent:
BinaryOp = BO_Rem;
return Stmt::BinaryOperatorClass;
@@ -1325,10 +1324,10 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
UnaryOp = UO_AddrOf;
return Stmt::UnaryOperatorClass;
}
-
+
BinaryOp = BO_And;
return Stmt::BinaryOperatorClass;
-
+
case OO_Pipe:
BinaryOp = BO_Or;
return Stmt::BinaryOperatorClass;
@@ -1352,7 +1351,7 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Greater:
BinaryOp = BO_GT;
return Stmt::BinaryOperatorClass;
-
+
case OO_PlusEqual:
BinaryOp = BO_AddAssign;
return Stmt::CompoundAssignOperatorClass;
@@ -1376,19 +1375,19 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_CaretEqual:
BinaryOp = BO_XorAssign;
return Stmt::CompoundAssignOperatorClass;
-
+
case OO_AmpEqual:
BinaryOp = BO_AndAssign;
return Stmt::CompoundAssignOperatorClass;
-
+
case OO_PipeEqual:
BinaryOp = BO_OrAssign;
return Stmt::CompoundAssignOperatorClass;
-
+
case OO_LessLess:
BinaryOp = BO_Shl;
return Stmt::BinaryOperatorClass;
-
+
case OO_GreaterGreater:
BinaryOp = BO_Shr;
return Stmt::BinaryOperatorClass;
@@ -1396,7 +1395,7 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_LessLessEqual:
BinaryOp = BO_ShlAssign;
return Stmt::CompoundAssignOperatorClass;
-
+
case OO_GreaterGreaterEqual:
BinaryOp = BO_ShrAssign;
return Stmt::CompoundAssignOperatorClass;
@@ -1404,15 +1403,15 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_EqualEqual:
BinaryOp = BO_EQ;
return Stmt::BinaryOperatorClass;
-
+
case OO_ExclaimEqual:
BinaryOp = BO_NE;
return Stmt::BinaryOperatorClass;
-
+
case OO_LessEqual:
BinaryOp = BO_LE;
return Stmt::BinaryOperatorClass;
-
+
case OO_GreaterEqual:
BinaryOp = BO_GE;
return Stmt::BinaryOperatorClass;
@@ -1420,17 +1419,17 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_Spaceship:
// FIXME: Update this once we support <=> expressions.
llvm_unreachable("<=> expressions not supported yet");
-
+
case OO_AmpAmp:
BinaryOp = BO_LAnd;
return Stmt::BinaryOperatorClass;
-
+
case OO_PipePipe:
BinaryOp = BO_LOr;
return Stmt::BinaryOperatorClass;
case OO_PlusPlus:
- UnaryOp = S->getNumArgs() == 1? UO_PreInc
+ UnaryOp = S->getNumArgs() == 1? UO_PreInc
: UO_PostInc;
return Stmt::UnaryOperatorClass;
@@ -1446,11 +1445,15 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
case OO_ArrowStar:
BinaryOp = BO_PtrMemI;
return Stmt::BinaryOperatorClass;
-
+
case OO_Subscript:
return Stmt::ArraySubscriptExprClass;
+
+ case OO_Coawait:
+ UnaryOp = UO_Coawait;
+ return Stmt::UnaryOperatorClass;
}
-
+
llvm_unreachable("Invalid overloaded operator expression");
}
@@ -1482,7 +1485,7 @@ void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Visit(S->getArg(I));
if (SC == Stmt::UnaryOperatorClass)
ID.AddInteger(UnaryOp);
- else if (SC == Stmt::BinaryOperatorClass ||
+ else if (SC == Stmt::BinaryOperatorClass ||
SC == Stmt::CompoundAssignOperatorClass)
ID.AddInteger(BinaryOp);
else
@@ -1843,7 +1846,7 @@ void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
}
void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
- VisitExpr(E);
+ VisitExpr(E);
}
void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
@@ -1962,7 +1965,7 @@ void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
case TemplateArgument::TemplateExpansion:
VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
-
+
case TemplateArgument::Declaration:
VisitDecl(Arg.getAsDecl());
break;
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index 394e9f38bcfd..a78927d229b9 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -157,16 +157,16 @@ bool TemplateArgument::isInstantiationDependent() const {
switch (getKind()) {
case Null:
llvm_unreachable("Should not have a NULL template argument");
-
+
case Type:
return getAsType()->isInstantiationDependentType();
-
+
case Template:
return getAsTemplate().isInstantiationDependent();
-
+
case TemplateExpansion:
return true;
-
+
case Declaration:
if (DeclContext *DC = dyn_cast<DeclContext>(getAsDecl()))
return DC->isDependentContext();
@@ -174,14 +174,14 @@ bool TemplateArgument::isInstantiationDependent() const {
case NullPtr:
return false;
-
+
case Integral:
// Never dependent
return false;
-
+
case Expression:
return getAsExpr()->isInstantiationDependent();
-
+
case Pack:
for (const auto &P : pack_elements())
if (P.isInstantiationDependent())
@@ -197,17 +197,17 @@ bool TemplateArgument::isPackExpansion() const {
case Null:
case Declaration:
case Integral:
- case Pack:
+ case Pack:
case Template:
case NullPtr:
return false;
-
+
case TemplateExpansion:
return true;
-
+
case Type:
return isa<PackExpansionType>(getAsType());
-
+
case Expression:
return isa<PackExpansionExpr>(getAsExpr());
}
@@ -233,7 +233,7 @@ bool TemplateArgument::containsUnexpandedParameterPack() const {
if (getAsTemplate().containsUnexpandedParameterPack())
return true;
break;
-
+
case Expression:
if (getAsExpr()->containsUnexpandedParameterPack())
return true;
@@ -254,8 +254,8 @@ Optional<unsigned> TemplateArgument::getNumTemplateExpansions() const {
assert(getKind() == TemplateExpansion);
if (TemplateArg.NumExpansions)
return TemplateArg.NumExpansions - 1;
-
- return None;
+
+ return None;
}
QualType TemplateArgument::getNonTypeTemplateArgumentType() const {
@@ -319,7 +319,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
}
break;
}
-
+
case Integral:
getAsIntegral().Profile(ID);
getIntegralType().Profile(ID);
@@ -342,7 +342,7 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
switch (getKind()) {
case Null:
case Type:
- case Expression:
+ case Expression:
case Template:
case TemplateExpansion:
case NullPtr:
@@ -368,14 +368,14 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
TemplateArgument TemplateArgument::getPackExpansionPattern() const {
assert(isPackExpansion());
-
+
switch (getKind()) {
case Type:
return getAsType()->getAs<PackExpansionType>()->getPattern();
-
+
case Expression:
return cast<PackExpansionExpr>(getAsExpr())->getPattern();
-
+
case TemplateExpansion:
return TemplateArgument(getAsTemplateOrTemplatePattern());
@@ -391,20 +391,20 @@ TemplateArgument TemplateArgument::getPackExpansionPattern() const {
llvm_unreachable("Invalid TemplateArgument Kind!");
}
-void TemplateArgument::print(const PrintingPolicy &Policy,
+void TemplateArgument::print(const PrintingPolicy &Policy,
raw_ostream &Out) const {
switch (getKind()) {
case Null:
Out << "(no value)";
break;
-
+
case Type: {
PrintingPolicy SubPolicy(Policy);
SubPolicy.SuppressStrongLifetime = true;
getAsType().print(Out, SubPolicy);
break;
}
-
+
case Declaration: {
NamedDecl *ND = getAsDecl();
Out << '&';
@@ -429,15 +429,15 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
getAsTemplateOrTemplatePattern().print(Out, Policy);
Out << "...";
break;
-
+
case Integral:
printIntegral(*this, Out, Policy);
break;
-
+
case Expression:
getAsExpr()->printPretty(Out, nullptr, Policy);
break;
-
+
case Pack:
Out << "<";
bool First = true;
@@ -446,11 +446,11 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
First = false;
else
Out << ", ";
-
+
P.print(Policy, Out);
}
Out << ">";
- break;
+ break;
}
}
@@ -486,13 +486,13 @@ SourceRange TemplateArgumentLoc::getSourceRange() const {
case TemplateArgument::Template:
if (getTemplateQualifierLoc())
- return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
+ return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
getTemplateNameLoc());
return SourceRange(getTemplateNameLoc());
case TemplateArgument::TemplateExpansion:
if (getTemplateQualifierLoc())
- return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
+ return SourceRange(getTemplateQualifierLoc().getBeginLoc(),
getTemplateEllipsisLoc());
return SourceRange(getTemplateNameLoc(), getTemplateEllipsisLoc());
@@ -514,19 +514,19 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
// This is bad, but not as bad as crashing because of argument
// count mismatches.
return DB << "(null template argument)";
-
+
case TemplateArgument::Type:
return DB << Arg.getAsType();
-
+
case TemplateArgument::Declaration:
return DB << Arg.getAsDecl();
case TemplateArgument::NullPtr:
return DB << "nullptr";
-
+
case TemplateArgument::Integral:
return DB << Arg.getAsIntegral().toString(10);
-
+
case TemplateArgument::Template:
return DB << Arg.getAsTemplate();
@@ -545,7 +545,7 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
Arg.getAsExpr()->printPretty(OS, nullptr, Policy);
return DB << OS.str();
}
-
+
case TemplateArgument::Pack: {
// FIXME: We're guessing at LangOptions!
SmallString<32> Str;
diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp
index 548468ed17cd..0a7a6bc3c6a7 100644
--- a/lib/AST/TemplateName.cpp
+++ b/lib/AST/TemplateName.cpp
@@ -31,7 +31,7 @@
using namespace clang;
-TemplateArgument
+TemplateArgument
SubstTemplateTemplateParmPackStorage::getArgumentPack() const {
return TemplateArgument(llvm::makeArrayRef(Arguments, size()));
}
@@ -40,7 +40,7 @@ void SubstTemplateTemplateParmStorage::Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, Parameter, Replacement);
}
-void SubstTemplateTemplateParmStorage::Profile(llvm::FoldingSetNodeID &ID,
+void SubstTemplateTemplateParmStorage::Profile(llvm::FoldingSetNodeID &ID,
TemplateTemplateParmDecl *parameter,
TemplateName replacement) {
ID.AddPointer(parameter);
@@ -52,7 +52,7 @@ void SubstTemplateTemplateParmPackStorage::Profile(llvm::FoldingSetNodeID &ID,
Profile(ID, Context, Parameter, getArgumentPack());
}
-void SubstTemplateTemplateParmPackStorage::Profile(llvm::FoldingSetNodeID &ID,
+void SubstTemplateTemplateParmPackStorage::Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
TemplateTemplateParmDecl *Parameter,
const TemplateArgument &ArgPack) {
@@ -180,7 +180,7 @@ bool TemplateName::isInstantiationDependent() const {
if (QTN->getQualifier()->isInstantiationDependent())
return true;
}
-
+
return isDependent();
}
@@ -191,7 +191,7 @@ bool TemplateName::containsUnexpandedParameterPack() const {
}
if (TemplateDecl *Template = getAsTemplateDecl()) {
- if (TemplateTemplateParmDecl *TTP
+ if (TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(Template))
return TTP->isParameterPack();
@@ -199,7 +199,7 @@ bool TemplateName::containsUnexpandedParameterPack() const {
}
if (DependentTemplateName *DTN = getAsDependentTemplateName())
- return DTN->getQualifier() &&
+ return DTN->getQualifier() &&
DTN->getQualifier()->containsUnexpandedParameterPack();
return getAsSubstTemplateTemplateParmPack() != nullptr;
@@ -220,7 +220,7 @@ TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy,
if (!SuppressNNS && DTN->getQualifier())
DTN->getQualifier()->print(OS, Policy);
OS << "template ";
-
+
if (DTN->isIdentifier())
OS << DTN->getIdentifier()->getName();
else
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index fad8c0d1c6b2..f79a59712a41 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -138,14 +138,14 @@ unsigned ConstantArrayType::getNumAddressingBits(const ASTContext &Context,
SizeExtended.getBitWidth()) * 2);
llvm::APSInt TotalSize(llvm::APInt(SizeExtended.getBitWidth(), ElementSize));
- TotalSize *= SizeExtended;
+ TotalSize *= SizeExtended;
return TotalSize.getActiveBits();
}
unsigned ConstantArrayType::getMaxSizeBits(const ASTContext &Context) {
unsigned Bits = Context.getTypeSize(Context.getSizeType());
-
+
// Limit the number of bits in size_t so that maximal bit size fits 64 bit
// integer (see PR8256). We can do this as currently there is no hardware
// that supports full 64-bit virtual space.
@@ -155,7 +155,7 @@ unsigned ConstantArrayType::getMaxSizeBits(const ASTContext &Context) {
return Bits;
}
-DependentSizedArrayType::DependentSizedArrayType(const ASTContext &Context,
+DependentSizedArrayType::DependentSizedArrayType(const ASTContext &Context,
QualType et, QualType can,
Expr *e, ArraySizeModifier sm,
unsigned tq,
@@ -201,8 +201,8 @@ void DependentVectorType::Profile(llvm::FoldingSetNodeID &ID,
DependentSizedExtVectorType::DependentSizedExtVectorType(const
ASTContext &Context,
QualType ElementType,
- QualType can,
- Expr *SizeExpr,
+ QualType can,
+ Expr *SizeExpr,
SourceLocation loc)
: Type(DependentSizedExtVector, can, /*Dependent=*/true,
/*InstantiationDependent=*/true,
@@ -249,7 +249,7 @@ VectorType::VectorType(TypeClass tc, QualType vecType, unsigned nElements,
: Type(tc, canonType, vecType->isDependentType(),
vecType->isInstantiationDependentType(),
vecType->isVariablyModifiedType(),
- vecType->containsUnexpandedParameterPack()),
+ vecType->containsUnexpandedParameterPack()),
ElementType(vecType) {
VectorTypeBits.VecKind = vecKind;
VectorTypeBits.NumElements = nElements;
@@ -629,9 +629,9 @@ ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
ArrayRef<QualType> typeArgs,
ArrayRef<ObjCProtocolDecl *> protocols,
bool isKindOf)
- : Type(ObjCObject, Canonical, Base->isDependentType(),
- Base->isInstantiationDependentType(),
- Base->isVariablyModifiedType(),
+ : Type(ObjCObject, Canonical, Base->isDependentType(),
+ Base->isInstantiationDependentType(),
+ Base->isVariablyModifiedType(),
Base->containsUnexpandedParameterPack()),
BaseType(Base) {
ObjCObjectTypeBits.IsKindOf = isKindOf;
@@ -657,7 +657,7 @@ ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
initialize(protocols);
}
-bool ObjCObjectType::isSpecialized() const {
+bool ObjCObjectType::isSpecialized() const {
// If we have type arguments written here, the type is specialized.
if (ObjCObjectTypeBits.NumTypeArgs > 0)
return true;
@@ -744,7 +744,7 @@ namespace {
/// Visitor used by simpleTransform() to perform the transformation.
template<typename F>
-struct SimpleTransformVisitor
+struct SimpleTransformVisitor
: public TypeVisitor<SimpleTransformVisitor<F>, QualType> {
ASTContext &Ctx;
F &&TheFunc;
@@ -769,7 +769,7 @@ public:
TRIVIAL_TYPE_CLASS(Builtin)
- QualType VisitComplexType(const ComplexType *T) {
+ QualType VisitComplexType(const ComplexType *T) {
QualType elementType = recurse(T->getElementType());
if (elementType.isNull())
return {};
@@ -807,7 +807,7 @@ public:
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
+ if (pointeeType.getAsOpaquePtr()
== T->getPointeeTypeAsWritten().getAsOpaquePtr())
return QualType(T, 0);
@@ -819,7 +819,7 @@ public:
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
+ if (pointeeType.getAsOpaquePtr()
== T->getPointeeTypeAsWritten().getAsOpaquePtr())
return QualType(T, 0);
@@ -834,7 +834,7 @@ public:
if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
return QualType(T, 0);
- return Ctx.getMemberPointerType(pointeeType, T->getClass());
+ return Ctx.getMemberPointerType(pointeeType, T->getClass());
}
QualType VisitConstantArrayType(const ConstantArrayType *T) {
@@ -876,7 +876,7 @@ public:
T->getIndexTypeCVRQualifiers());
}
- QualType VisitVectorType(const VectorType *T) {
+ QualType VisitVectorType(const VectorType *T) {
QualType elementType = recurse(T->getElementType());
if (elementType.isNull())
return {};
@@ -884,11 +884,11 @@ public:
if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
return QualType(T, 0);
- return Ctx.getVectorType(elementType, T->getNumElements(),
+ return Ctx.getVectorType(elementType, T->getNumElements(),
T->getVectorKind());
}
- QualType VisitExtVectorType(const ExtVectorType *T) {
+ QualType VisitExtVectorType(const ExtVectorType *T) {
QualType elementType = recurse(T->getElementType());
if (elementType.isNull())
return {};
@@ -899,7 +899,7 @@ public:
return Ctx.getExtVectorType(elementType, T->getNumElements());
}
- QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
+ QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
QualType returnType = recurse(T->getReturnType());
if (returnType.isNull())
return {};
@@ -910,7 +910,7 @@ public:
return Ctx.getFunctionNoProtoType(returnType, T->getExtInfo());
}
- QualType VisitFunctionProtoType(const FunctionProtoType *T) {
+ QualType VisitFunctionProtoType(const FunctionProtoType *T) {
QualType returnType = recurse(T->getReturnType());
if (returnType.isNull())
return {};
@@ -938,7 +938,7 @@ public:
QualType newExceptionType = recurse(exceptionType);
if (newExceptionType.isNull())
return {};
-
+
if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
exceptionChanged = true;
@@ -958,7 +958,7 @@ public:
return Ctx.getFunctionType(returnType, paramTypes, info);
}
- QualType VisitParenType(const ParenType *T) {
+ QualType VisitParenType(const ParenType *T) {
QualType innerType = recurse(T->getInnerType());
if (innerType.isNull())
return {};
@@ -972,7 +972,7 @@ public:
TRIVIAL_TYPE_CLASS(Typedef)
TRIVIAL_TYPE_CLASS(ObjCTypeParam)
- QualType VisitAdjustedType(const AdjustedType *T) {
+ QualType VisitAdjustedType(const AdjustedType *T) {
QualType originalType = recurse(T->getOriginalType());
if (originalType.isNull())
return {};
@@ -981,20 +981,20 @@ public:
if (adjustedType.isNull())
return {};
- if (originalType.getAsOpaquePtr()
+ if (originalType.getAsOpaquePtr()
== T->getOriginalType().getAsOpaquePtr() &&
adjustedType.getAsOpaquePtr() == T->getAdjustedType().getAsOpaquePtr())
return QualType(T, 0);
return Ctx.getAdjustedType(originalType, adjustedType);
}
-
- QualType VisitDecayedType(const DecayedType *T) {
+
+ QualType VisitDecayedType(const DecayedType *T) {
QualType originalType = recurse(T->getOriginalType());
if (originalType.isNull())
return {};
- if (originalType.getAsOpaquePtr()
+ if (originalType.getAsOpaquePtr()
== T->getOriginalType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1011,7 +1011,7 @@ public:
// FIXME: Non-trivial to implement, but important for C++
TRIVIAL_TYPE_CLASS(Elaborated)
- QualType VisitAttributedType(const AttributedType *T) {
+ QualType VisitAttributedType(const AttributedType *T) {
QualType modifiedType = recurse(T->getModifiedType());
if (modifiedType.isNull())
return {};
@@ -1020,13 +1020,13 @@ public:
if (equivalentType.isNull())
return {};
- if (modifiedType.getAsOpaquePtr()
+ if (modifiedType.getAsOpaquePtr()
== T->getModifiedType().getAsOpaquePtr() &&
- equivalentType.getAsOpaquePtr()
+ equivalentType.getAsOpaquePtr()
== T->getEquivalentType().getAsOpaquePtr())
return QualType(T, 0);
- return Ctx.getAttributedType(T->getAttrKind(), modifiedType,
+ return Ctx.getAttributedType(T->getAttrKind(), modifiedType,
equivalentType);
}
@@ -1035,7 +1035,7 @@ public:
if (replacementType.isNull())
return {};
- if (replacementType.getAsOpaquePtr()
+ if (replacementType.getAsOpaquePtr()
== T->getReplacementType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1054,7 +1054,7 @@ public:
if (deducedType.isNull())
return {};
- if (deducedType.getAsOpaquePtr()
+ if (deducedType.getAsOpaquePtr()
== T->getDeducedType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1088,7 +1088,7 @@ public:
!typeArgChanged)
return QualType(T, 0);
- return Ctx.getObjCObjectType(baseType, typeArgs,
+ return Ctx.getObjCObjectType(baseType, typeArgs,
llvm::makeArrayRef(T->qual_begin(),
T->getNumProtocols()),
T->isKindOfTypeAsWritten());
@@ -1101,7 +1101,7 @@ public:
if (pointeeType.isNull())
return {};
- if (pointeeType.getAsOpaquePtr()
+ if (pointeeType.getAsOpaquePtr()
== T->getPointeeType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1113,7 +1113,7 @@ public:
if (valueType.isNull())
return {};
- if (valueType.getAsOpaquePtr()
+ if (valueType.getAsOpaquePtr()
== T->getValueType().getAsOpaquePtr())
return QualType(T, 0);
@@ -1628,6 +1628,10 @@ CXXRecordDecl *Type::getAsCXXRecordDecl() const {
return dyn_cast_or_null<CXXRecordDecl>(getAsTagDecl());
}
+RecordDecl *Type::getAsRecordDecl() const {
+ return dyn_cast_or_null<RecordDecl>(getAsTagDecl());
+}
+
TagDecl *Type::getAsTagDecl() const {
if (const auto *TT = getAs<TagType>())
return TT->getDecl();
@@ -1739,10 +1743,10 @@ bool Type::hasIntegerRepresentation() const {
/// Determine whether this type is an integral type.
///
-/// This routine determines whether the given type is an integral type per
+/// This routine determines whether the given type is an integral type per
/// C++ [basic.fundamental]p7. Although the C standard does not define the
/// term "integral type", it has a similar term "integer type", and in C++
-/// the two terms are equivalent. However, C's "integer type" includes
+/// the two terms are equivalent. However, C's "integer type" includes
/// enumeration types, while C++'s "integer type" does not. The \c ASTContext
/// parameter is used to determine whether we should be following the C or
/// C++ rules when determining whether this type is an integral/integer type.
@@ -1751,7 +1755,7 @@ bool Type::hasIntegerRepresentation() const {
/// type", use this routine.
///
/// For cases where C permits "an integer type" and C++ permits "an integral
-/// or enumeration type", use \c isIntegralOrEnumerationType() instead.
+/// or enumeration type", use \c isIntegralOrEnumerationType() instead.
///
/// \param Ctx The context in which this type occurs.
///
@@ -1862,12 +1866,12 @@ bool Type::isSignedIntegerOrEnumerationType() const {
return BT->getKind() >= BuiltinType::Char_S &&
BT->getKind() <= BuiltinType::Int128;
}
-
+
if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
if (ET->getDecl()->isComplete())
return ET->getDecl()->getIntegerType()->isSignedIntegerType();
}
-
+
return false;
}
@@ -1902,12 +1906,12 @@ bool Type::isUnsignedIntegerOrEnumerationType() const {
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::UInt128;
}
-
+
if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
if (ET->getDecl()->isComplete())
return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
}
-
+
return false;
}
@@ -2111,16 +2115,16 @@ bool QualType::isCXX98PODType(const ASTContext &Context) const {
// are PODs according to the standard.
if (isNull())
return false;
-
+
if ((*this)->isIncompleteArrayType())
return Context.getBaseElementType(*this).isCXX98PODType(Context);
-
+
if ((*this)->isIncompleteType())
return false;
if (hasNonTrivialObjCLifetime())
return false;
-
+
QualType CanonicalType = getTypePtr()->CanonicalType;
switch (CanonicalType->getTypeClass()) {
// Everything not explicitly mentioned is not POD.
@@ -2129,7 +2133,7 @@ bool QualType::isCXX98PODType(const ASTContext &Context) const {
case Type::ConstantArray:
// IncompleteArray is handled above.
return Context.getBaseElementType(*this).isCXX98PODType(Context);
-
+
case Type::ObjCObjectPointer:
case Type::BlockPointer:
case Type::Builtin:
@@ -2159,27 +2163,27 @@ bool QualType::isTrivialType(const ASTContext &Context) const {
// are PODs according to the standard.
if (isNull())
return false;
-
+
if ((*this)->isArrayType())
return Context.getBaseElementType(*this).isTrivialType(Context);
-
+
// Return false for incomplete types after skipping any incomplete array
// types which are expressly allowed by the standard and thus our API.
if ((*this)->isIncompleteType())
return false;
-
+
if (hasNonTrivialObjCLifetime())
return false;
-
+
QualType CanonicalType = getTypePtr()->CanonicalType;
if (CanonicalType->isDependentType())
return false;
-
+
// C++0x [basic.types]p9:
// Scalar types, trivial class types, arrays of such types, and
// cv-qualified versions of these types are collectively called trivial
// types.
-
+
// As an extension, Clang treats vector types as Scalar types.
if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
return true;
@@ -2193,10 +2197,10 @@ bool QualType::isTrivialType(const ASTContext &Context) const {
!ClassDecl->hasNonTrivialDefaultConstructor() &&
ClassDecl->isTriviallyCopyable();
}
-
+
return true;
}
-
+
// No other types can match.
return false;
}
@@ -2221,7 +2225,7 @@ bool QualType::isTriviallyCopyableType(const ASTContext &Context) const {
// which are expressly allowed by the standard and thus our API.
if (CanonicalType->isIncompleteType())
return false;
-
+
// As an extension, Clang treats vector types as Scalar types.
if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
return true;
@@ -2477,10 +2481,10 @@ bool Type::isPromotableIntegerType() const {
if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull()
|| ET->getDecl()->isScoped())
return false;
-
+
return true;
}
-
+
return false;
}
@@ -2531,7 +2535,7 @@ TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) {
case TST_union: return TTK_Union;
case TST_enum: return TTK_Enum;
}
-
+
llvm_unreachable("Type specifier is not a tag type kind.");
}
@@ -2647,7 +2651,7 @@ const char *Type::getTypeClassName() const {
#define TYPE(Derived, Base) case Derived: return #Derived;
#include "clang/AST/TypeNodes.def"
}
-
+
llvm_unreachable("Invalid type class.");
}
@@ -2800,16 +2804,16 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
QualType QualType::getNonLValueExprType(const ASTContext &Context) const {
if (const auto *RefType = getTypePtr()->getAs<ReferenceType>())
return RefType->getPointeeType();
-
+
// C++0x [basic.lval]:
- // Class prvalues can have cv-qualified types; non-class prvalues always
+ // Class prvalues can have cv-qualified types; non-class prvalues always
// have cv-unqualified types.
//
// See also C99 6.3.2.1p2.
if (!Context.getLangOpts().CPlusPlus ||
(!getTypePtr()->isDependentType() && !getTypePtr()->isRecordType()))
return getUnqualifiedType();
-
+
return *this;
}
@@ -2993,7 +2997,7 @@ bool FunctionProtoType::isTemplateVariadic() const {
for (unsigned ArgIdx = getNumParams(); ArgIdx; --ArgIdx)
if (isa<PackExpansionType>(getParamType(ArgIdx - 1)))
return true;
-
+
return false;
}
@@ -3005,7 +3009,7 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
// Note that valid type pointers are never ambiguous with anything else.
//
// The encoding grammar begins:
- // type type* bool int bool
+ // type type* bool int bool
// If that final bool is true, then there is a section for the EH spec:
// bool type*
// This is followed by an optional "consumed argument" section of the
@@ -3013,7 +3017,7 @@ void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
// bool*
// Finally, we have the ext info and trailing return type flag:
// int bool
- //
+ //
// There is no ambiguity between the consumed arguments and an empty EH
// spec because of the leading 'bool' which unambiguously indicates
// whether the following bool is the EH spec or part of the arguments.
@@ -3074,7 +3078,7 @@ bool TypeOfExprType::isSugared() const {
QualType TypeOfExprType::desugar() const {
if (isSugared())
return getUnderlyingExpr()->getType();
-
+
return QualType(this, 0);
}
@@ -3098,7 +3102,7 @@ bool DecltypeType::isSugared() const { return !E->isInstantiationDependent(); }
QualType DecltypeType::desugar() const {
if (isSugared())
return getUnderlyingType();
-
+
return QualType(this, 0);
}
@@ -3174,6 +3178,7 @@ bool AttributedType::isQualifier() const {
case AttributedType::attr_nonnull:
case AttributedType::attr_nullable:
case AttributedType::attr_null_unspecified:
+ case AttributedType::attr_lifetimebound:
return true;
// These aren't qualifiers; they rewrite the modified type to be a
@@ -3243,6 +3248,7 @@ bool AttributedType::isCallingConv() const {
case attr_null_unspecified:
case attr_objc_kindof:
case attr_nocf_check:
+ case attr_lifetimebound:
return false;
case attr_pcs:
@@ -3274,7 +3280,7 @@ IdentifierInfo *TemplateTypeParmType::getIdentifier() const {
}
SubstTemplateTypeParmPackType::
-SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param,
+SubstTemplateTypeParmPackType(const TemplateTypeParmType *Param,
QualType Canon,
const TemplateArgument &ArgPack)
: Type(SubstTemplateTypeParmPack, Canon, true, true, false, true),
@@ -3331,7 +3337,7 @@ TemplateSpecializationType(TemplateName T,
false,
T.containsUnexpandedParameterPack()),
Template(T), NumArgs(Args.size()), TypeAlias(!AliasedType.isNull()) {
- assert(!T.getAsDependentTemplateName() &&
+ assert(!T.getAsDependentTemplateName() &&
"Use DependentTemplateSpecializationType for dependent template-name");
assert((T.getKind() == TemplateName::Template ||
T.getKind() == TemplateName::SubstTemplateTemplateParm ||
@@ -3546,7 +3552,7 @@ static CachedProperties computeCachedProperties(const Type *T) {
}
// C++ [basic.link]p8:
- // - it is a compound type (3.9.2) other than a class or enumeration,
+ // - it is a compound type (3.9.2) other than a class or enumeration,
// compounded exclusively from types that have linkage; or
case Type::Complex:
return Cache::get(cast<ComplexType>(T)->getElementType());
@@ -3716,14 +3722,14 @@ Optional<NullabilityKind> Type::getNullability(const ASTContext &context) const
QualType desugared = type.getSingleStepDesugaredType(context);
if (desugared.getTypePtr() == type.getTypePtr())
return None;
-
+
type = desugared;
} while (true);
}
bool Type::canHaveNullability(bool ResultIfUnknown) const {
QualType type = getCanonicalTypeInternal();
-
+
switch (type->getTypeClass()) {
// We'll only see canonical types here.
#define NON_CANONICAL_TYPE(Class, Parent) \
@@ -3957,7 +3963,7 @@ bool Type::isObjCLifetimeType() const {
}
/// Determine whether the given type T is a "bridgable" Objective-C type,
-/// which is either an Objective-C object pointer type or an
+/// which is either an Objective-C object pointer type or an
bool Type::isObjCARCBridgableType() const {
return isObjCObjectPointerType() || isBlockPointerType();
}
@@ -3967,7 +3973,7 @@ bool Type::isCARCBridgableType() const {
const auto *Pointer = getAs<PointerType>();
if (!Pointer)
return false;
-
+
QualType Pointee = Pointer->getPointeeType();
return Pointee->isVoidType() || Pointee->isRecordType();
}
@@ -3980,7 +3986,7 @@ bool Type::hasSizedVLAType() const {
if (const auto *ref = getAs<ReferenceType>())
return ref->getPointeeType()->hasSizedVLAType();
if (const ArrayType *arr = getAsArrayTypeUnsafe()) {
- if (isa<VariableArrayType>(arr) &&
+ if (isa<VariableArrayType>(arr) &&
cast<VariableArrayType>(arr)->getSizeExpr())
return true;
diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp
index 6fa76e14a590..e4fd6f106e33 100644
--- a/lib/AST/TypeLoc.cpp
+++ b/lib/AST/TypeLoc.cpp
@@ -127,7 +127,7 @@ TypeLoc TypeLoc::getNextTypeLocImpl(TypeLoc TL) {
/// Initializes a type location, and all of its children
/// recursively, as if the entire tree had been written in the
/// given location.
-void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
+void TypeLoc::initializeImpl(ASTContext &Context, TypeLoc TL,
SourceLocation Loc) {
while (true) {
switch (TL.getTypeLocClass()) {
@@ -370,7 +370,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
case BuiltinType::SatULongFract:
llvm_unreachable("Builtin type needs extra local data!");
// Fall through, if the impossible happens.
-
+
case BuiltinType::NullPtr:
case BuiltinType::Overload:
case BuiltinType::Dependent:
@@ -446,13 +446,13 @@ void ObjCTypeParamTypeLoc::initializeLocal(ASTContext &Context,
setProtocolLoc(i, Loc);
}
-void ObjCObjectTypeLoc::initializeLocal(ASTContext &Context,
+void ObjCObjectTypeLoc::initializeLocal(ASTContext &Context,
SourceLocation Loc) {
setHasBaseTypeAsWritten(true);
setTypeArgsLAngleLoc(Loc);
setTypeArgsRAngleLoc(Loc);
for (unsigned i = 0, e = getNumTypeArgs(); i != e; ++i) {
- setTypeArgTInfo(i,
+ setTypeArgTInfo(i,
Context.getTrivialTypeSourceInfo(
getTypePtr()->getTypeArgsAsWritten()[i], Loc));
}
@@ -479,7 +479,7 @@ void UnaryTransformTypeLoc::initializeLocal(ASTContext &Context,
Context.getTrivialTypeSourceInfo(getTypePtr()->getBaseType(), Loc));
}
-void ElaboratedTypeLoc::initializeLocal(ASTContext &Context,
+void ElaboratedTypeLoc::initializeLocal(ASTContext &Context,
SourceLocation Loc) {
setElaboratedKeywordLoc(Loc);
NestedNameSpecifierLocBuilder Builder;
@@ -487,7 +487,7 @@ void ElaboratedTypeLoc::initializeLocal(ASTContext &Context,
setQualifierLoc(Builder.getWithLocInContext(Context));
}
-void DependentNameTypeLoc::initializeLocal(ASTContext &Context,
+void DependentNameTypeLoc::initializeLocal(ASTContext &Context,
SourceLocation Loc) {
setElaboratedKeywordLoc(Loc);
NestedNameSpecifierLocBuilder Builder;
@@ -516,14 +516,14 @@ DependentTemplateSpecializationTypeLoc::initializeLocal(ASTContext &Context,
getArgInfos(), Loc);
}
-void TemplateSpecializationTypeLoc::initializeArgLocs(ASTContext &Context,
+void TemplateSpecializationTypeLoc::initializeArgLocs(ASTContext &Context,
unsigned NumArgs,
const TemplateArgument *Args,
TemplateArgumentLocInfo *ArgInfos,
SourceLocation Loc) {
for (unsigned i = 0, e = NumArgs; i != e; ++i) {
switch (Args[i].getKind()) {
- case TemplateArgument::Null:
+ case TemplateArgument::Null:
llvm_unreachable("Impossible TemplateArgument");
case TemplateArgument::Integral:
@@ -535,10 +535,10 @@ void TemplateSpecializationTypeLoc::initializeArgLocs(ASTContext &Context,
case TemplateArgument::Expression:
ArgInfos[i] = TemplateArgumentLocInfo(Args[i].getAsExpr());
break;
-
+
case TemplateArgument::Type:
ArgInfos[i] = TemplateArgumentLocInfo(
- Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
+ Context.getTrivialTypeSourceInfo(Args[i].getAsType(),
Loc));
break;
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index c5e2244e26c5..e032c312aa12 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -52,14 +52,14 @@ namespace {
class IncludeStrongLifetimeRAII {
PrintingPolicy &Policy;
bool Old;
-
+
public:
- explicit IncludeStrongLifetimeRAII(PrintingPolicy &Policy)
+ explicit IncludeStrongLifetimeRAII(PrintingPolicy &Policy)
: Policy(Policy), Old(Policy.SuppressStrongLifetime) {
if (!Policy.SuppressLifetimeQualifiers)
Policy.SuppressStrongLifetime = false;
}
-
+
~IncludeStrongLifetimeRAII() {
Policy.SuppressStrongLifetime = Old;
}
@@ -68,13 +68,13 @@ namespace {
class ParamPolicyRAII {
PrintingPolicy &Policy;
bool Old;
-
+
public:
- explicit ParamPolicyRAII(PrintingPolicy &Policy)
+ explicit ParamPolicyRAII(PrintingPolicy &Policy)
: Policy(Policy), Old(Policy.SuppressSpecifiers) {
Policy.SuppressSpecifiers = false;
}
-
+
~ParamPolicyRAII() {
Policy.SuppressSpecifiers = Old;
}
@@ -84,7 +84,7 @@ namespace {
PrintingPolicy &Policy;
bool SuppressTagKeyword;
bool SuppressScope;
-
+
public:
explicit ElaboratedTypePolicyRAII(PrintingPolicy &Policy) : Policy(Policy) {
SuppressTagKeyword = Policy.SuppressTagKeyword;
@@ -92,13 +92,13 @@ namespace {
Policy.SuppressTagKeyword = true;
Policy.SuppressScope = true;
}
-
+
~ElaboratedTypePolicyRAII() {
Policy.SuppressTagKeyword = SuppressTagKeyword;
Policy.SuppressScope = SuppressScope;
}
};
-
+
class TypePrinter {
PrintingPolicy Policy;
unsigned Indentation;
@@ -193,7 +193,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
TC = AT->desugar()->getTypeClass();
if (const auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T))
TC = Subst->getReplacementType()->getTypeClass();
-
+
switch (TC) {
case Type::Auto:
case Type::Builtin:
@@ -221,19 +221,19 @@ bool TypePrinter::canPrefixQualifiers(const Type *T,
case Type::Pipe:
CanPrefixQualifiers = true;
break;
-
+
case Type::ObjCObjectPointer:
CanPrefixQualifiers = T->isObjCIdType() || T->isObjCClassType() ||
T->isObjCQualifiedIdType() || T->isObjCQualifiedClassType();
break;
-
+
case Type::ConstantArray:
case Type::IncompleteArray:
case Type::VariableArray:
case Type::DependentSizedArray:
NeedARCStrongQualifier = true;
LLVM_FALLTHROUGH;
-
+
case Type::Adjusted:
case Type::Decayed:
case Type::Pointer:
@@ -444,8 +444,8 @@ void TypePrinter::printRValueReferenceAfter(const RValueReferenceType *T,
printAfter(Inner, OS);
}
-void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
- raw_ostream &OS) {
+void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
printBefore(T->getPointeeType(), OS);
@@ -461,8 +461,8 @@ void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
OS << "::*";
}
-void TypePrinter::printMemberPointerAfter(const MemberPointerType *T,
- raw_ostream &OS) {
+void TypePrinter::printMemberPointerAfter(const MemberPointerType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
// Handle things like 'int (Cls::*A)[4];' correctly.
@@ -472,14 +472,14 @@ void TypePrinter::printMemberPointerAfter(const MemberPointerType *T,
printAfter(T->getPointeeType(), OS);
}
-void TypePrinter::printConstantArrayBefore(const ConstantArrayType *T,
+void TypePrinter::printConstantArrayBefore(const ConstantArrayType *T,
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
printBefore(T->getElementType(), OS);
}
-void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T,
+void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T,
raw_ostream &OS) {
OS << '[';
if (T->getIndexTypeQualifiers().hasQualifiers()) {
@@ -495,27 +495,27 @@ void TypePrinter::printConstantArrayAfter(const ConstantArrayType *T,
printAfter(T->getElementType(), OS);
}
-void TypePrinter::printIncompleteArrayBefore(const IncompleteArrayType *T,
+void TypePrinter::printIncompleteArrayBefore(const IncompleteArrayType *T,
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
printBefore(T->getElementType(), OS);
}
-void TypePrinter::printIncompleteArrayAfter(const IncompleteArrayType *T,
+void TypePrinter::printIncompleteArrayAfter(const IncompleteArrayType *T,
raw_ostream &OS) {
OS << "[]";
printAfter(T->getElementType(), OS);
}
-void TypePrinter::printVariableArrayBefore(const VariableArrayType *T,
+void TypePrinter::printVariableArrayBefore(const VariableArrayType *T,
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
printBefore(T->getElementType(), OS);
}
-void TypePrinter::printVariableArrayAfter(const VariableArrayType *T,
+void TypePrinter::printVariableArrayAfter(const VariableArrayType *T,
raw_ostream &OS) {
OS << '[';
if (T->getIndexTypeQualifiers().hasQualifiers()) {
@@ -555,7 +555,7 @@ void TypePrinter::printDecayedAfter(const DecayedType *T, raw_ostream &OS) {
}
void TypePrinter::printDependentSizedArrayBefore(
- const DependentSizedArrayType *T,
+ const DependentSizedArrayType *T,
raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
@@ -563,7 +563,7 @@ void TypePrinter::printDependentSizedArrayBefore(
}
void TypePrinter::printDependentSizedArrayAfter(
- const DependentSizedArrayType *T,
+ const DependentSizedArrayType *T,
raw_ostream &OS) {
OS << '[';
if (T->getSizeExpr())
@@ -587,22 +587,22 @@ void TypePrinter::printDependentAddressSpaceAfter(
}
void TypePrinter::printDependentSizedExtVectorBefore(
- const DependentSizedExtVectorType *T,
- raw_ostream &OS) {
+ const DependentSizedExtVectorType *T,
+ raw_ostream &OS) {
printBefore(T->getElementType(), OS);
}
void TypePrinter::printDependentSizedExtVectorAfter(
- const DependentSizedExtVectorType *T,
- raw_ostream &OS) {
+ const DependentSizedExtVectorType *T,
+ raw_ostream &OS) {
OS << " __attribute__((ext_vector_type(";
if (T->getSizeExpr())
T->getSizeExpr()->printPretty(OS, nullptr, Policy);
- OS << ")))";
+ OS << ")))";
printAfter(T->getElementType(), OS);
}
-void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
+void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
switch (T->getVectorKind()) {
case VectorType::AltiVecPixel:
OS << "__vector __pixel ";
@@ -632,7 +632,7 @@ void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
<< T->getNumElements()
<< " * sizeof(";
print(T->getElementType(), OS, StringRef());
- OS << ")))) ";
+ OS << ")))) ";
printBefore(T->getElementType(), OS);
break;
}
@@ -692,19 +692,19 @@ void TypePrinter::printDependentVectorAfter(
}
void TypePrinter::printExtVectorBefore(const ExtVectorType *T,
- raw_ostream &OS) {
+ raw_ostream &OS) {
printBefore(T->getElementType(), OS);
}
-void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) {
+void TypePrinter::printExtVectorAfter(const ExtVectorType *T, raw_ostream &OS) {
printAfter(T->getElementType(), OS);
OS << " __attribute__((ext_vector_type(";
OS << T->getNumElements();
OS << ")))";
}
-void
-FunctionProtoType::printExceptionSpecification(raw_ostream &OS,
+void
+FunctionProtoType::printExceptionSpecification(raw_ostream &OS,
const PrintingPolicy &Policy)
const {
if (hasDynamicExceptionSpec()) {
@@ -715,7 +715,7 @@ FunctionProtoType::printExceptionSpecification(raw_ostream &OS,
for (unsigned I = 0, N = getNumExceptions(); I != N; ++I) {
if (I)
OS << ", ";
-
+
OS << getExceptionType(I).stream(Policy);
}
OS << ')';
@@ -732,7 +732,7 @@ FunctionProtoType::printExceptionSpecification(raw_ostream &OS,
}
}
-void TypePrinter::printFunctionProtoBefore(const FunctionProtoType *T,
+void TypePrinter::printFunctionProtoBefore(const FunctionProtoType *T,
raw_ostream &OS) {
if (T->hasTrailingReturn()) {
OS << "auto ";
@@ -761,8 +761,8 @@ StringRef clang::getParameterABISpelling(ParameterABI ABI) {
llvm_unreachable("bad parameter ABI kind");
}
-void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
- raw_ostream &OS) {
+void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
+ raw_ostream &OS) {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!HasEmptyPlaceHolder)
OS << ')';
@@ -785,7 +785,7 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
print(T->getParamType(i), OS, StringRef());
}
}
-
+
if (T->isVariadic()) {
if (T->getNumParams())
OS << ", ";
@@ -794,7 +794,7 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
// Do not emit int() if we have a proto, emit 'int(void)'.
OS << "void";
}
-
+
OS << ')';
FunctionType::ExtInfo Info = T->getExtInfo();
@@ -902,8 +902,8 @@ void TypePrinter::printFunctionAfter(const FunctionType::ExtInfo &Info,
OS << " __attribute__((nocf_check))";
}
-void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T,
- raw_ostream &OS) {
+void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T,
+ raw_ostream &OS) {
// If needed for precedence reasons, wrap the inner part in grouping parens.
SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder, false);
printBefore(T->getReturnType(), OS);
@@ -911,13 +911,13 @@ void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T,
OS << '(';
}
-void TypePrinter::printFunctionNoProtoAfter(const FunctionNoProtoType *T,
+void TypePrinter::printFunctionNoProtoAfter(const FunctionNoProtoType *T,
raw_ostream &OS) {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!HasEmptyPlaceHolder)
OS << ')';
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
-
+
OS << "()";
printFunctionAfter(T->getExtInfo(), OS);
printAfter(T->getReturnType(), OS);
@@ -944,7 +944,7 @@ void TypePrinter::printUnresolvedUsingBefore(const UnresolvedUsingType *T,
void TypePrinter::printUnresolvedUsingAfter(const UnresolvedUsingType *T,
raw_ostream &OS) {}
-void TypePrinter::printTypedefBefore(const TypedefType *T, raw_ostream &OS) {
+void TypePrinter::printTypedefBefore(const TypedefType *T, raw_ostream &OS) {
printTypeSpec(T->getDecl(), OS);
}
@@ -961,7 +961,7 @@ void TypePrinter::printTypeOfExprBefore(const TypeOfExprType *T,
void TypePrinter::printTypeOfExprAfter(const TypeOfExprType *T,
raw_ostream &OS) {}
-void TypePrinter::printTypeOfBefore(const TypeOfType *T, raw_ostream &OS) {
+void TypePrinter::printTypeOfBefore(const TypeOfType *T, raw_ostream &OS) {
OS << "typeof(";
print(T->getUnderlyingType(), OS, StringRef());
OS << ')';
@@ -970,7 +970,7 @@ void TypePrinter::printTypeOfBefore(const TypeOfType *T, raw_ostream &OS) {
void TypePrinter::printTypeOfAfter(const TypeOfType *T, raw_ostream &OS) {}
-void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) {
+void TypePrinter::printDecltypeBefore(const DecltypeType *T, raw_ostream &OS) {
OS << "decltype(";
if (T->getUnderlyingExpr())
T->getUnderlyingExpr()->printPretty(OS, nullptr, Policy);
@@ -1008,7 +1008,7 @@ void TypePrinter::printUnaryTransformAfter(const UnaryTransformType *T,
printAfter(T->getBaseType(), OS);
}
-void TypePrinter::printAutoBefore(const AutoType *T, raw_ostream &OS) {
+void TypePrinter::printAutoBefore(const AutoType *T, raw_ostream &OS) {
// If the type has been deduced, do not print 'auto'.
if (!T->getDeducedType().isNull()) {
printBefore(T->getDeducedType(), OS);
@@ -1022,7 +1022,7 @@ void TypePrinter::printAutoBefore(const AutoType *T, raw_ostream &OS) {
}
}
-void TypePrinter::printAutoAfter(const AutoType *T, raw_ostream &OS) {
+void TypePrinter::printAutoAfter(const AutoType *T, raw_ostream &OS) {
// If the type has been deduced, do not print 'auto'.
if (!T->getDeducedType().isNull())
printAfter(T->getDeducedType(), OS);
@@ -1079,7 +1079,7 @@ void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS) {
AppendScope(DC->getParent(), OS);
if (const auto *NS = dyn_cast<NamespaceDecl>(DC)) {
- if (Policy.SuppressUnwrittenScope &&
+ if (Policy.SuppressUnwrittenScope &&
(NS->isAnonymousNamespace() || NS->isInline()))
return;
if (NS->getIdentifier())
@@ -1143,7 +1143,7 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
} else {
OS << "anonymous";
}
-
+
if (Policy.AnonymousTagLocations) {
// Suppress the redundant tag keyword if we just printed one.
// We don't have to worry about ElaboratedTypes here because you can't
@@ -1188,14 +1188,14 @@ void TypePrinter::printRecordBefore(const RecordType *T, raw_ostream &OS) {
void TypePrinter::printRecordAfter(const RecordType *T, raw_ostream &OS) {}
-void TypePrinter::printEnumBefore(const EnumType *T, raw_ostream &OS) {
+void TypePrinter::printEnumBefore(const EnumType *T, raw_ostream &OS) {
printTag(T->getDecl(), OS);
}
void TypePrinter::printEnumAfter(const EnumType *T, raw_ostream &OS) {}
-void TypePrinter::printTemplateTypeParmBefore(const TemplateTypeParmType *T,
- raw_ostream &OS) {
+void TypePrinter::printTemplateTypeParmBefore(const TemplateTypeParmType *T,
+ raw_ostream &OS) {
if (IdentifierInfo *Id = T->getIdentifier())
OS << Id->getName();
else
@@ -1203,40 +1203,40 @@ void TypePrinter::printTemplateTypeParmBefore(const TemplateTypeParmType *T,
spaceBeforePlaceHolder(OS);
}
-void TypePrinter::printTemplateTypeParmAfter(const TemplateTypeParmType *T,
+void TypePrinter::printTemplateTypeParmAfter(const TemplateTypeParmType *T,
raw_ostream &OS) {}
void TypePrinter::printSubstTemplateTypeParmBefore(
- const SubstTemplateTypeParmType *T,
- raw_ostream &OS) {
+ const SubstTemplateTypeParmType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
printBefore(T->getReplacementType(), OS);
}
void TypePrinter::printSubstTemplateTypeParmAfter(
- const SubstTemplateTypeParmType *T,
- raw_ostream &OS) {
+ const SubstTemplateTypeParmType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
printAfter(T->getReplacementType(), OS);
}
void TypePrinter::printSubstTemplateTypeParmPackBefore(
- const SubstTemplateTypeParmPackType *T,
- raw_ostream &OS) {
+ const SubstTemplateTypeParmPackType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
printTemplateTypeParmBefore(T->getReplacedParameter(), OS);
}
void TypePrinter::printSubstTemplateTypeParmPackAfter(
- const SubstTemplateTypeParmPackType *T,
- raw_ostream &OS) {
+ const SubstTemplateTypeParmPackType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
printTemplateTypeParmAfter(T->getReplacedParameter(), OS);
}
void TypePrinter::printTemplateSpecializationBefore(
- const TemplateSpecializationType *T,
- raw_ostream &OS) {
+ const TemplateSpecializationType *T,
+ raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
T->getTemplateName().print(OS, Policy);
@@ -1245,7 +1245,7 @@ void TypePrinter::printTemplateSpecializationBefore(
}
void TypePrinter::printTemplateSpecializationAfter(
- const TemplateSpecializationType *T,
+ const TemplateSpecializationType *T,
raw_ostream &OS) {}
void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
@@ -1279,7 +1279,7 @@ void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
if (Qualifier)
Qualifier->print(OS, Policy);
}
-
+
ElaboratedTypePolicyRAII PolicyRAII(Policy);
printBefore(T->getNamedType(), OS);
}
@@ -1309,13 +1309,13 @@ void TypePrinter::printParenAfter(const ParenType *T, raw_ostream &OS) {
}
void TypePrinter::printDependentNameBefore(const DependentNameType *T,
- raw_ostream &OS) {
+ raw_ostream &OS) {
OS << TypeWithKeyword::getKeywordName(T->getKeyword());
if (T->getKeyword() != ETK_None)
OS << " ";
-
+
T->getQualifier()->print(OS, Policy);
-
+
OS << T->getIdentifier()->getName();
spaceBeforePlaceHolder(OS);
}
@@ -1324,7 +1324,7 @@ void TypePrinter::printDependentNameAfter(const DependentNameType *T,
raw_ostream &OS) {}
void TypePrinter::printDependentTemplateSpecializationBefore(
- const DependentTemplateSpecializationType *T, raw_ostream &OS) {
+ const DependentTemplateSpecializationType *T, raw_ostream &OS) {
IncludeStrongLifetimeRAII Strong(Policy);
OS << TypeWithKeyword::getKeywordName(T->getKeyword());
@@ -1341,12 +1341,12 @@ void TypePrinter::printDependentTemplateSpecializationBefore(
void TypePrinter::printDependentTemplateSpecializationAfter(
const DependentTemplateSpecializationType *T, raw_ostream &OS) {}
-void TypePrinter::printPackExpansionBefore(const PackExpansionType *T,
+void TypePrinter::printPackExpansionBefore(const PackExpansionType *T,
raw_ostream &OS) {
printBefore(T->getPattern(), OS);
}
-void TypePrinter::printPackExpansionAfter(const PackExpansionType *T,
+void TypePrinter::printPackExpansionAfter(const PackExpansionType *T,
raw_ostream &OS) {
printAfter(T->getPattern(), OS);
OS << "...";
@@ -1443,9 +1443,27 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
return;
}
+ if (T->getAttrKind() == AttributedType::attr_lifetimebound) {
+ OS << " [[clang::lifetimebound]]";
+ return;
+ }
+
OS << " __attribute__((";
switch (T->getAttrKind()) {
- default: llvm_unreachable("This attribute should have been handled already");
+ case AttributedType::attr_lifetimebound:
+ case AttributedType::attr_nonnull:
+ case AttributedType::attr_nullable:
+ case AttributedType::attr_null_unspecified:
+ case AttributedType::attr_objc_gc:
+ case AttributedType::attr_objc_inert_unsafe_unretained:
+ case AttributedType::attr_objc_kindof:
+ case AttributedType::attr_objc_ownership:
+ case AttributedType::attr_ptr32:
+ case AttributedType::attr_ptr64:
+ case AttributedType::attr_sptr:
+ case AttributedType::attr_uptr:
+ llvm_unreachable("This attribute should have been handled already");
+
case AttributedType::attr_address_space:
OS << "address_space(";
// FIXME: printing the raw LangAS value is wrong. This should probably
@@ -1489,36 +1507,6 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
break;
}
- case AttributedType::attr_objc_gc: {
- OS << "objc_gc(";
-
- QualType tmp = T->getEquivalentType();
- while (tmp.getObjCGCAttr() == Qualifiers::GCNone) {
- QualType next = tmp->getPointeeType();
- if (next == tmp) break;
- tmp = next;
- }
-
- if (tmp.isObjCGCWeak())
- OS << "weak";
- else
- OS << "strong";
- OS << ')';
- break;
- }
-
- case AttributedType::attr_objc_ownership:
- OS << "objc_ownership(";
- switch (T->getEquivalentType().getObjCLifetime()) {
- case Qualifiers::OCL_None: llvm_unreachable("no ownership!");
- case Qualifiers::OCL_ExplicitNone: OS << "none"; break;
- case Qualifiers::OCL_Strong: OS << "strong"; break;
- case Qualifiers::OCL_Weak: OS << "weak"; break;
- case Qualifiers::OCL_Autoreleasing: OS << "autoreleasing"; break;
- }
- OS << ')';
- break;
-
case AttributedType::attr_ns_returns_retained:
OS << "ns_returns_retained";
break;
@@ -1561,13 +1549,13 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
OS << "))";
}
-void TypePrinter::printObjCInterfaceBefore(const ObjCInterfaceType *T,
- raw_ostream &OS) {
+void TypePrinter::printObjCInterfaceBefore(const ObjCInterfaceType *T,
+ raw_ostream &OS) {
OS << T->getDecl()->getName();
spaceBeforePlaceHolder(OS);
}
-void TypePrinter::printObjCInterfaceAfter(const ObjCInterfaceType *T,
+void TypePrinter::printObjCInterfaceAfter(const ObjCInterfaceType *T,
raw_ostream &OS) {}
void TypePrinter::printObjCTypeParamBefore(const ObjCTypeParamType *T,
@@ -1640,7 +1628,7 @@ void TypePrinter::printObjCObjectAfter(const ObjCObjectType *T,
return printAfter(T->getBaseType(), OS);
}
-void TypePrinter::printObjCObjectPointerBefore(const ObjCObjectPointerType *T,
+void TypePrinter::printObjCObjectPointerBefore(const ObjCObjectPointerType *T,
raw_ostream &OS) {
printBefore(T->getPointeeType(), OS);
@@ -1653,7 +1641,7 @@ void TypePrinter::printObjCObjectPointerBefore(const ObjCObjectPointerType *T,
}
}
-void TypePrinter::printObjCObjectPointerAfter(const ObjCObjectPointerType *T,
+void TypePrinter::printObjCObjectPointerAfter(const ObjCObjectPointerType *T,
raw_ostream &OS) {}
static
@@ -1832,11 +1820,11 @@ void Qualifiers::print(raw_ostream &OS, const PrintingPolicy& Policy,
switch (lifetime) {
case Qualifiers::OCL_None: llvm_unreachable("none but true");
case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break;
- case Qualifiers::OCL_Strong:
+ case Qualifiers::OCL_Strong:
if (!Policy.SuppressStrongLifetime)
- OS << "__strong";
+ OS << "__strong";
break;
-
+
case Qualifiers::OCL_Weak: OS << "__weak"; break;
case Qualifiers::OCL_Autoreleasing: OS << "__autoreleasing"; break;
}
diff --git a/lib/AST/VTTBuilder.cpp b/lib/AST/VTTBuilder.cpp
index b946f10105f4..a3f3dbdfb4f9 100644
--- a/lib/AST/VTTBuilder.cpp
+++ b/lib/AST/VTTBuilder.cpp
@@ -32,11 +32,11 @@ using namespace clang;
VTTBuilder::VTTBuilder(ASTContext &Ctx,
const CXXRecordDecl *MostDerivedClass,
bool GenerateDefinition)
- : Ctx(Ctx), MostDerivedClass(MostDerivedClass),
+ : Ctx(Ctx), MostDerivedClass(MostDerivedClass),
MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
GenerateDefinition(GenerateDefinition) {
// Lay out this VTT.
- LayoutVTT(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
+ LayoutVTT(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
/*BaseIsVirtual=*/false);
}
@@ -69,22 +69,22 @@ void VTTBuilder::LayoutSecondaryVTTs(BaseSubobject Base) {
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(RD);
- CharUnits BaseOffset = Base.getBaseOffset() +
+ CharUnits BaseOffset = Base.getBaseOffset() +
Layout.getBaseClassOffset(BaseDecl);
-
+
// Layout the VTT for this base.
LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/false);
}
}
void
-VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
+VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
bool BaseIsMorallyVirtual,
uint64_t VTableIndex,
const CXXRecordDecl *VTableClass,
VisitedVirtualBasesSetTy &VBases) {
const CXXRecordDecl *RD = Base.getBase();
-
+
// We're not interested in bases that don't have virtual bases, and not
// morally virtual bases.
if (!RD->getNumVBases() && !BaseIsMorallyVirtual)
@@ -96,14 +96,14 @@ VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
// Itanium C++ ABI 2.6.2:
// Secondary virtual pointers are present for all bases with either
- // virtual bases or virtual function declarations overridden along a
+ // virtual bases or virtual function declarations overridden along a
// virtual path.
//
// If the base class is not dynamic, we don't want to add it, nor any
// of its base classes.
if (!BaseDecl->isDynamicClass())
continue;
-
+
bool BaseDeclIsMorallyVirtual = BaseIsMorallyVirtual;
bool BaseDeclIsNonVirtualPrimaryBase = false;
CharUnits BaseOffset;
@@ -111,15 +111,15 @@ VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
// Ignore virtual bases that we've already visited.
if (!VBases.insert(BaseDecl).second)
continue;
-
+
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
BaseDeclIsMorallyVirtual = true;
} else {
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(RD);
-
- BaseOffset = Base.getBaseOffset() +
+
+ BaseOffset = Base.getBaseOffset() +
Layout.getBaseClassOffset(BaseDecl);
-
+
if (!Layout.isPrimaryBaseVirtual() &&
Layout.getPrimaryBase() == BaseDecl)
BaseDeclIsNonVirtualPrimaryBase = true;
@@ -133,19 +133,19 @@ VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
if (!BaseDeclIsNonVirtualPrimaryBase &&
(BaseDecl->getNumVBases() || BaseDeclIsMorallyVirtual)) {
// Add the vtable pointer.
- AddVTablePointer(BaseSubobject(BaseDecl, BaseOffset), VTableIndex,
+ AddVTablePointer(BaseSubobject(BaseDecl, BaseOffset), VTableIndex,
VTableClass);
}
// And lay out the secondary virtual pointers for the base class.
LayoutSecondaryVirtualPointers(BaseSubobject(BaseDecl, BaseOffset),
- BaseDeclIsMorallyVirtual, VTableIndex,
+ BaseDeclIsMorallyVirtual, VTableIndex,
VTableClass, VBases);
}
}
-void
-VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
+void
+VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
uint64_t VTableIndex) {
VisitedVirtualBasesSetTy VBases;
LayoutSecondaryVirtualPointers(Base, /*BaseIsMorallyVirtual=*/false,
@@ -155,21 +155,21 @@ VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
void VTTBuilder::LayoutVirtualVTTs(const CXXRecordDecl *RD,
VisitedVirtualBasesSetTy &VBases) {
for (const auto &I : RD->bases()) {
- const CXXRecordDecl *BaseDecl =
+ const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(I.getType()->getAs<RecordType>()->getDecl());
-
+
// Check if this is a virtual base.
if (I.isVirtual()) {
// Check if we've seen this base before.
if (!VBases.insert(BaseDecl).second)
continue;
-
- CharUnits BaseOffset =
+
+ CharUnits BaseOffset =
MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
-
+
LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/true);
}
-
+
// We only need to layout virtual VTTs for this base if it actually has
// virtual bases.
if (BaseDecl->getNumVBases())
@@ -181,7 +181,7 @@ void VTTBuilder::LayoutVTT(BaseSubobject Base, bool BaseIsVirtual) {
const CXXRecordDecl *RD = Base.getBase();
// Itanium C++ ABI 2.6.2:
- // An array of virtual table addresses, called the VTT, is declared for
+ // An array of virtual table addresses, called the VTT, is declared for
// each class type that has indirect or direct virtual base classes.
if (RD->getNumVBases() == 0)
return;
@@ -201,10 +201,10 @@ void VTTBuilder::LayoutVTT(BaseSubobject Base, bool BaseIsVirtual) {
// Add the secondary VTTs.
LayoutSecondaryVTTs(Base);
-
+
// Add the secondary virtual pointers.
LayoutSecondaryVirtualPointers(Base, VTableIndex);
-
+
// If this is the primary VTT, we want to lay out virtual VTTs as well.
if (IsPrimaryVTT) {
VisitedVirtualBasesSetTy VBases;
diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp
index 0a3da024f147..dfc5774ab498 100644
--- a/lib/AST/VTableBuilder.cpp
+++ b/lib/AST/VTableBuilder.cpp
@@ -35,14 +35,14 @@ namespace {
struct BaseOffset {
/// DerivedClass - The derived class.
const CXXRecordDecl *DerivedClass;
-
+
/// VirtualBase - If the path from the derived class to the base class
/// involves virtual base classes, this holds the declaration of the last
/// virtual base in this path (i.e. closest to the base class).
const CXXRecordDecl *VirtualBase;
/// NonVirtualOffset - The offset from the derived class to the base class.
- /// (Or the offset from the virtual base class to the base class, if the
+ /// (Or the offset from the virtual base class to the base class, if the
/// path from the derived class to the base class involves a virtual base
/// class.
CharUnits NonVirtualOffset;
@@ -51,7 +51,7 @@ struct BaseOffset {
NonVirtualOffset(CharUnits::Zero()) { }
BaseOffset(const CXXRecordDecl *DerivedClass,
const CXXRecordDecl *VirtualBase, CharUnits NonVirtualOffset)
- : DerivedClass(DerivedClass), VirtualBase(VirtualBase),
+ : DerivedClass(DerivedClass), VirtualBase(VirtualBase),
NonVirtualOffset(NonVirtualOffset) { }
bool isEmpty() const { return NonVirtualOffset.isZero() && !VirtualBase; }
@@ -81,19 +81,19 @@ private:
/// MostDerivedClass - The most derived class for which the final overriders
/// are stored.
const CXXRecordDecl *MostDerivedClass;
-
- /// MostDerivedClassOffset - If we're building final overriders for a
+
+ /// MostDerivedClassOffset - If we're building final overriders for a
/// construction vtable, this holds the offset from the layout class to the
/// most derived class.
const CharUnits MostDerivedClassOffset;
- /// LayoutClass - The class we're using for layout information. Will be
+ /// LayoutClass - The class we're using for layout information. Will be
/// different than the most derived class if the final overriders are for a
- /// construction vtable.
- const CXXRecordDecl *LayoutClass;
+ /// construction vtable.
+ const CXXRecordDecl *LayoutClass;
ASTContext &Context;
-
+
/// MostDerivedClassLayout - the AST record layout of the most derived class.
const ASTRecordLayout &MostDerivedClassLayout;
@@ -103,19 +103,19 @@ private:
typedef llvm::DenseMap<MethodBaseOffsetPairTy,
OverriderInfo> OverridersMapTy;
-
- /// OverridersMap - The final overriders for all virtual member functions of
+
+ /// OverridersMap - The final overriders for all virtual member functions of
/// all the base subobjects of the most derived class.
OverridersMapTy OverridersMap;
-
+
/// SubobjectsToOffsetsMapTy - A mapping from a base subobject (represented
/// as a record decl and a subobject number) and its offsets in the most
/// derived class as well as the layout class.
- typedef llvm::DenseMap<std::pair<const CXXRecordDecl *, unsigned>,
+ typedef llvm::DenseMap<std::pair<const CXXRecordDecl *, unsigned>,
CharUnits> SubobjectOffsetMapTy;
typedef llvm::DenseMap<const CXXRecordDecl *, unsigned> SubobjectCountMapTy;
-
+
/// ComputeBaseOffsets - Compute the offsets for all base subobjects of the
/// given base.
void ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual,
@@ -125,40 +125,40 @@ private:
SubobjectCountMapTy &SubobjectCounts);
typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
-
+
/// dump - dump the final overriders for a base subobject, and all its direct
/// and indirect base subobjects.
void dump(raw_ostream &Out, BaseSubobject Base,
VisitedVirtualBasesSetTy& VisitedVirtualBases);
-
+
public:
FinalOverriders(const CXXRecordDecl *MostDerivedClass,
CharUnits MostDerivedClassOffset,
const CXXRecordDecl *LayoutClass);
/// getOverrider - Get the final overrider for the given method declaration in
- /// the subobject with the given base offset.
- OverriderInfo getOverrider(const CXXMethodDecl *MD,
+ /// the subobject with the given base offset.
+ OverriderInfo getOverrider(const CXXMethodDecl *MD,
CharUnits BaseOffset) const {
- assert(OverridersMap.count(std::make_pair(MD, BaseOffset)) &&
+ assert(OverridersMap.count(std::make_pair(MD, BaseOffset)) &&
"Did not find overrider!");
-
+
return OverridersMap.lookup(std::make_pair(MD, BaseOffset));
}
-
+
/// dump - dump the final overriders.
void dump() {
VisitedVirtualBasesSetTy VisitedVirtualBases;
- dump(llvm::errs(), BaseSubobject(MostDerivedClass, CharUnits::Zero()),
+ dump(llvm::errs(), BaseSubobject(MostDerivedClass, CharUnits::Zero()),
VisitedVirtualBases);
}
-
+
};
FinalOverriders::FinalOverriders(const CXXRecordDecl *MostDerivedClass,
CharUnits MostDerivedClassOffset,
const CXXRecordDecl *LayoutClass)
- : MostDerivedClass(MostDerivedClass),
+ : MostDerivedClass(MostDerivedClass),
MostDerivedClassOffset(MostDerivedClassOffset), LayoutClass(LayoutClass),
Context(MostDerivedClass->getASTContext()),
MostDerivedClassLayout(Context.getASTRecordLayout(MostDerivedClass)) {
@@ -167,10 +167,10 @@ FinalOverriders::FinalOverriders(const CXXRecordDecl *MostDerivedClass,
SubobjectOffsetMapTy SubobjectOffsets;
SubobjectOffsetMapTy SubobjectLayoutClassOffsets;
SubobjectCountMapTy SubobjectCounts;
- ComputeBaseOffsets(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
+ ComputeBaseOffsets(BaseSubobject(MostDerivedClass, CharUnits::Zero()),
/*IsVirtual=*/false,
- MostDerivedClassOffset,
- SubobjectOffsets, SubobjectLayoutClassOffsets,
+ MostDerivedClassOffset,
+ SubobjectOffsets, SubobjectLayoutClassOffsets,
SubobjectCounts);
// Get the final overriders.
@@ -183,10 +183,10 @@ FinalOverriders::FinalOverriders(const CXXRecordDecl *MostDerivedClass,
for (const auto &M : Methods) {
unsigned SubobjectNumber = M.first;
- assert(SubobjectOffsets.count(std::make_pair(MD->getParent(),
+ assert(SubobjectOffsets.count(std::make_pair(MD->getParent(),
SubobjectNumber)) &&
"Did not find subobject offset!");
-
+
CharUnits BaseOffset = SubobjectOffsets[std::make_pair(MD->getParent(),
SubobjectNumber)];
@@ -198,12 +198,12 @@ FinalOverriders::FinalOverriders(const CXXRecordDecl *MostDerivedClass,
std::make_pair(OverriderRD, Method.Subobject))
&& "Did not find subobject offset!");
CharUnits OverriderOffset =
- SubobjectLayoutClassOffsets[std::make_pair(OverriderRD,
+ SubobjectLayoutClassOffsets[std::make_pair(OverriderRD,
Method.Subobject)];
OverriderInfo& Overrider = OverridersMap[std::make_pair(MD, BaseOffset)];
assert(!Overrider.Method && "Overrider should not exist yet!");
-
+
Overrider.Offset = OverriderOffset;
Overrider.Method = Method.Method;
Overrider.VirtualBase = Method.InVirtualSubobject;
@@ -235,11 +235,11 @@ static BaseOffset ComputeBaseOffset(const ASTContext &Context,
break;
}
}
-
+
// Now compute the non-virtual offset.
for (unsigned I = NonVirtualStart, E = Path.size(); I != E; ++I) {
const CXXBasePathElement &Element = Path[I];
-
+
// Check the base class offset.
const ASTRecordLayout &Layout = Context.getASTRecordLayout(Element.Class);
@@ -247,12 +247,12 @@ static BaseOffset ComputeBaseOffset(const ASTContext &Context,
NonVirtualOffset += Layout.getBaseClassOffset(Base);
}
-
+
// FIXME: This should probably use CharUnits or something. Maybe we should
- // even change the base offsets in ASTRecordLayout to be specified in
+ // even change the base offsets in ASTRecordLayout to be specified in
// CharUnits.
return BaseOffset(DerivedRD, VirtualBase, NonVirtualOffset);
-
+
}
static BaseOffset ComputeBaseOffset(const ASTContext &Context,
@@ -268,67 +268,67 @@ static BaseOffset ComputeBaseOffset(const ASTContext &Context,
}
static BaseOffset
-ComputeReturnAdjustmentBaseOffset(ASTContext &Context,
+ComputeReturnAdjustmentBaseOffset(ASTContext &Context,
const CXXMethodDecl *DerivedMD,
const CXXMethodDecl *BaseMD) {
const FunctionType *BaseFT = BaseMD->getType()->getAs<FunctionType>();
const FunctionType *DerivedFT = DerivedMD->getType()->getAs<FunctionType>();
-
+
// Canonicalize the return types.
CanQualType CanDerivedReturnType =
Context.getCanonicalType(DerivedFT->getReturnType());
CanQualType CanBaseReturnType =
Context.getCanonicalType(BaseFT->getReturnType());
- assert(CanDerivedReturnType->getTypeClass() ==
- CanBaseReturnType->getTypeClass() &&
+ assert(CanDerivedReturnType->getTypeClass() ==
+ CanBaseReturnType->getTypeClass() &&
"Types must have same type class!");
-
+
if (CanDerivedReturnType == CanBaseReturnType) {
// No adjustment needed.
return BaseOffset();
}
-
+
if (isa<ReferenceType>(CanDerivedReturnType)) {
- CanDerivedReturnType =
+ CanDerivedReturnType =
CanDerivedReturnType->getAs<ReferenceType>()->getPointeeType();
- CanBaseReturnType =
+ CanBaseReturnType =
CanBaseReturnType->getAs<ReferenceType>()->getPointeeType();
} else if (isa<PointerType>(CanDerivedReturnType)) {
- CanDerivedReturnType =
+ CanDerivedReturnType =
CanDerivedReturnType->getAs<PointerType>()->getPointeeType();
- CanBaseReturnType =
+ CanBaseReturnType =
CanBaseReturnType->getAs<PointerType>()->getPointeeType();
} else {
llvm_unreachable("Unexpected return type!");
}
-
+
// We need to compare unqualified types here; consider
// const T *Base::foo();
// T *Derived::foo();
- if (CanDerivedReturnType.getUnqualifiedType() ==
+ if (CanDerivedReturnType.getUnqualifiedType() ==
CanBaseReturnType.getUnqualifiedType()) {
// No adjustment needed.
return BaseOffset();
}
-
- const CXXRecordDecl *DerivedRD =
+
+ const CXXRecordDecl *DerivedRD =
cast<CXXRecordDecl>(cast<RecordType>(CanDerivedReturnType)->getDecl());
-
- const CXXRecordDecl *BaseRD =
+
+ const CXXRecordDecl *BaseRD =
cast<CXXRecordDecl>(cast<RecordType>(CanBaseReturnType)->getDecl());
return ComputeBaseOffset(Context, BaseRD, DerivedRD);
}
-void
+void
FinalOverriders::ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual,
CharUnits OffsetInLayoutClass,
SubobjectOffsetMapTy &SubobjectOffsets,
SubobjectOffsetMapTy &SubobjectLayoutClassOffsets,
SubobjectCountMapTy &SubobjectCounts) {
const CXXRecordDecl *RD = Base.getBase();
-
+
unsigned SubobjectNumber = 0;
if (!IsVirtual)
SubobjectNumber = ++SubobjectCounts[RD];
@@ -336,13 +336,13 @@ FinalOverriders::ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual,
// Set up the subobject to offset mapping.
assert(!SubobjectOffsets.count(std::make_pair(RD, SubobjectNumber))
&& "Subobject offset already exists!");
- assert(!SubobjectLayoutClassOffsets.count(std::make_pair(RD, SubobjectNumber))
+ assert(!SubobjectLayoutClassOffsets.count(std::make_pair(RD, SubobjectNumber))
&& "Subobject offset already exists!");
SubobjectOffsets[std::make_pair(RD, SubobjectNumber)] = Base.getBaseOffset();
SubobjectLayoutClassOffsets[std::make_pair(RD, SubobjectNumber)] =
OffsetInLayoutClass;
-
+
// Traverse our bases.
for (const auto &B : RD->bases()) {
const CXXRecordDecl *BaseDecl = B.getType()->getAsCXXRecordDecl();
@@ -358,19 +358,19 @@ FinalOverriders::ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual,
Context.getASTRecordLayout(LayoutClass);
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
- BaseOffsetInLayoutClass =
+ BaseOffsetInLayoutClass =
LayoutClassLayout.getVBaseClassOffset(BaseDecl);
} else {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
CharUnits Offset = Layout.getBaseClassOffset(BaseDecl);
-
+
BaseOffset = Base.getBaseOffset() + Offset;
BaseOffsetInLayoutClass = OffsetInLayoutClass + Offset;
}
- ComputeBaseOffsets(BaseSubobject(BaseDecl, BaseOffset),
- B.isVirtual(), BaseOffsetInLayoutClass,
- SubobjectOffsets, SubobjectLayoutClassOffsets,
+ ComputeBaseOffsets(BaseSubobject(BaseDecl, BaseOffset),
+ B.isVirtual(), BaseOffsetInLayoutClass,
+ SubobjectOffsets, SubobjectLayoutClassOffsets,
SubobjectCounts);
}
}
@@ -382,7 +382,7 @@ void FinalOverriders::dump(raw_ostream &Out, BaseSubobject Base,
for (const auto &B : RD->bases()) {
const CXXRecordDecl *BaseDecl = B.getType()->getAsCXXRecordDecl();
-
+
// Ignore bases that don't have any virtual member functions.
if (!BaseDecl->isPolymorphic())
continue;
@@ -393,7 +393,7 @@ void FinalOverriders::dump(raw_ostream &Out, BaseSubobject Base,
// We've visited this base before.
continue;
}
-
+
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
} else {
BaseOffset = Layout.getBaseClassOffset(BaseDecl) + Base.getBaseOffset();
@@ -431,19 +431,19 @@ void FinalOverriders::dump(raw_ostream &Out, BaseSubobject Base,
Offset.VirtualBase->printQualifiedName(Out);
Out << " vbase, ";
}
-
+
Out << Offset.NonVirtualOffset.getQuantity() << " nv]";
}
-
+
Out << "\n";
- }
+ }
}
/// VCallOffsetMap - Keeps track of vcall offsets when building a vtable.
struct VCallOffsetMap {
-
+
typedef std::pair<const CXXMethodDecl *, CharUnits> MethodAndOffsetPairTy;
-
+
/// Offsets - Keeps track of methods and their offsets.
// FIXME: This should be a real map and not a vector.
SmallVector<MethodAndOffsetPairTy, 16> Offsets;
@@ -458,11 +458,11 @@ public:
/// add was successful, or false if there was already a member function with
/// the same signature in the map.
bool AddVCallOffset(const CXXMethodDecl *MD, CharUnits OffsetOffset);
-
+
/// getVCallOffsetOffset - Returns the vcall offset offset (relative to the
/// vtable address point) for the given virtual member function.
CharUnits getVCallOffsetOffset(const CXXMethodDecl *MD);
-
+
// empty - Return whether the offset map is empty or not.
bool empty() const { return Offsets.empty(); }
};
@@ -489,13 +489,13 @@ bool VCallOffsetMap::MethodsCanShareVCallOffset(const CXXMethodDecl *LHS,
const CXXMethodDecl *RHS) {
assert(LHS->isVirtual() && "LHS must be virtual!");
assert(RHS->isVirtual() && "LHS must be virtual!");
-
+
// A destructor can share a vcall offset with another destructor.
if (isa<CXXDestructorDecl>(LHS))
return isa<CXXDestructorDecl>(RHS);
// FIXME: We need to check more things here.
-
+
// The methods must have the same name.
DeclarationName LHSName = LHS->getDeclName();
DeclarationName RHSName = RHS->getDeclName();
@@ -506,14 +506,14 @@ bool VCallOffsetMap::MethodsCanShareVCallOffset(const CXXMethodDecl *LHS,
return HasSameVirtualSignature(LHS, RHS);
}
-bool VCallOffsetMap::AddVCallOffset(const CXXMethodDecl *MD,
+bool VCallOffsetMap::AddVCallOffset(const CXXMethodDecl *MD,
CharUnits OffsetOffset) {
// Check if we can reuse an offset.
for (const auto &OffsetPair : Offsets) {
if (MethodsCanShareVCallOffset(OffsetPair.first, MD))
return false;
}
-
+
// Add the offset.
Offsets.push_back(MethodAndOffsetPairTy(MD, OffsetOffset));
return true;
@@ -525,36 +525,36 @@ CharUnits VCallOffsetMap::getVCallOffsetOffset(const CXXMethodDecl *MD) {
if (MethodsCanShareVCallOffset(OffsetPair.first, MD))
return OffsetPair.second;
}
-
+
llvm_unreachable("Should always find a vcall offset offset!");
}
/// VCallAndVBaseOffsetBuilder - Class for building vcall and vbase offsets.
class VCallAndVBaseOffsetBuilder {
public:
- typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits>
+ typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits>
VBaseOffsetOffsetsMapTy;
private:
/// MostDerivedClass - The most derived class for which we're building vcall
/// and vbase offsets.
const CXXRecordDecl *MostDerivedClass;
-
- /// LayoutClass - The class we're using for layout information. Will be
+
+ /// LayoutClass - The class we're using for layout information. Will be
/// different than the most derived class if we're building a construction
/// vtable.
const CXXRecordDecl *LayoutClass;
-
+
/// Context - The ASTContext which we will use for layout information.
ASTContext &Context;
/// Components - vcall and vbase offset components
typedef SmallVector<VTableComponent, 64> VTableComponentVectorTy;
VTableComponentVectorTy Components;
-
+
/// VisitedVirtualBases - Visited virtual bases.
llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBases;
-
+
/// VCallOffsets - Keeps track of vcall offsets.
VCallOffsetMap VCallOffsets;
@@ -562,7 +562,7 @@ private:
/// VBaseOffsetOffsets - Contains the offsets of the virtual base offsets,
/// relative to the address point.
VBaseOffsetOffsetsMapTy VBaseOffsetOffsets;
-
+
/// FinalOverriders - The final overriders of the most derived class.
/// (Can be null when we're not building a vtable of the most derived class).
const FinalOverriders *Overriders;
@@ -571,48 +571,48 @@ private:
/// given base subobject.
void AddVCallAndVBaseOffsets(BaseSubobject Base, bool BaseIsVirtual,
CharUnits RealBaseOffset);
-
+
/// AddVCallOffsets - Add vcall offsets for the given base subobject.
void AddVCallOffsets(BaseSubobject Base, CharUnits VBaseOffset);
-
+
/// AddVBaseOffsets - Add vbase offsets for the given class.
- void AddVBaseOffsets(const CXXRecordDecl *Base,
+ void AddVBaseOffsets(const CXXRecordDecl *Base,
CharUnits OffsetInLayoutClass);
-
+
/// getCurrentOffsetOffset - Get the current vcall or vbase offset offset in
/// chars, relative to the vtable address point.
CharUnits getCurrentOffsetOffset() const;
-
+
public:
VCallAndVBaseOffsetBuilder(const CXXRecordDecl *MostDerivedClass,
const CXXRecordDecl *LayoutClass,
const FinalOverriders *Overriders,
BaseSubobject Base, bool BaseIsVirtual,
CharUnits OffsetInLayoutClass)
- : MostDerivedClass(MostDerivedClass), LayoutClass(LayoutClass),
+ : MostDerivedClass(MostDerivedClass), LayoutClass(LayoutClass),
Context(MostDerivedClass->getASTContext()), Overriders(Overriders) {
-
+
// Add vcall and vbase offsets.
AddVCallAndVBaseOffsets(Base, BaseIsVirtual, OffsetInLayoutClass);
}
-
+
/// Methods for iterating over the components.
typedef VTableComponentVectorTy::const_reverse_iterator const_iterator;
const_iterator components_begin() const { return Components.rbegin(); }
const_iterator components_end() const { return Components.rend(); }
-
+
const VCallOffsetMap &getVCallOffsets() const { return VCallOffsets; }
const VBaseOffsetOffsetsMapTy &getVBaseOffsetOffsets() const {
return VBaseOffsetOffsets;
}
};
-
-void
+
+void
VCallAndVBaseOffsetBuilder::AddVCallAndVBaseOffsets(BaseSubobject Base,
bool BaseIsVirtual,
CharUnits RealBaseOffset) {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(Base.getBase());
-
+
// Itanium C++ ABI 2.5.2:
// ..in classes sharing a virtual table with a primary base class, the vcall
// and vbase offsets added by the derived class all come before the vcall
@@ -626,16 +626,16 @@ VCallAndVBaseOffsetBuilder::AddVCallAndVBaseOffsets(BaseSubobject Base,
bool PrimaryBaseIsVirtual = Layout.isPrimaryBaseVirtual();
CharUnits PrimaryBaseOffset;
-
+
// Get the base offset of the primary base.
if (PrimaryBaseIsVirtual) {
assert(Layout.getVBaseClassOffset(PrimaryBase).isZero() &&
"Primary vbase should have a zero offset!");
-
+
const ASTRecordLayout &MostDerivedClassLayout =
Context.getASTRecordLayout(MostDerivedClass);
-
- PrimaryBaseOffset =
+
+ PrimaryBaseOffset =
MostDerivedClassLayout.getVBaseClassOffset(PrimaryBase);
} else {
assert(Layout.getBaseClassOffset(PrimaryBase).isZero() &&
@@ -657,19 +657,19 @@ VCallAndVBaseOffsetBuilder::AddVCallAndVBaseOffsets(BaseSubobject Base,
}
CharUnits VCallAndVBaseOffsetBuilder::getCurrentOffsetOffset() const {
- // OffsetIndex is the index of this vcall or vbase offset, relative to the
+ // OffsetIndex is the index of this vcall or vbase offset, relative to the
// vtable address point. (We subtract 3 to account for the information just
// above the address point, the RTTI info, the offset to top, and the
// vcall offset itself).
int64_t OffsetIndex = -(int64_t)(3 + Components.size());
-
- CharUnits PointerWidth =
+
+ CharUnits PointerWidth =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
CharUnits OffsetOffset = PointerWidth * OffsetIndex;
return OffsetOffset;
}
-void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
+void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
CharUnits VBaseOffset) {
const CXXRecordDecl *RD = Base.getBase();
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
@@ -687,7 +687,7 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
AddVCallOffsets(BaseSubobject(PrimaryBase, Base.getBaseOffset()),
VBaseOffset);
}
-
+
// Add the vcall offsets.
for (const auto *MD : RD->methods()) {
if (!MD->isVirtual())
@@ -695,7 +695,7 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
MD = MD->getCanonicalDecl();
CharUnits OffsetOffset = getCurrentOffsetOffset();
-
+
// Don't add a vcall offset if we already have one for this member function
// signature.
if (!VCallOffsets.AddVCallOffset(MD, OffsetOffset))
@@ -705,20 +705,20 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
if (Overriders) {
// Get the final overrider.
- FinalOverriders::OverriderInfo Overrider =
+ FinalOverriders::OverriderInfo Overrider =
Overriders->getOverrider(MD, Base.getBaseOffset());
-
- /// The vcall offset is the offset from the virtual base to the object
+
+ /// The vcall offset is the offset from the virtual base to the object
/// where the function was overridden.
Offset = Overrider.Offset - VBaseOffset;
}
-
+
Components.push_back(
VTableComponent::MakeVCallOffset(Offset));
}
// And iterate over all non-virtual bases (ignoring the primary base).
- for (const auto &B : RD->bases()) {
+ for (const auto &B : RD->bases()) {
if (B.isVirtual())
continue;
@@ -727,18 +727,18 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
continue;
// Get the base offset of this base.
- CharUnits BaseOffset = Base.getBaseOffset() +
+ CharUnits BaseOffset = Base.getBaseOffset() +
Layout.getBaseClassOffset(BaseDecl);
-
- AddVCallOffsets(BaseSubobject(BaseDecl, BaseOffset),
+
+ AddVCallOffsets(BaseSubobject(BaseDecl, BaseOffset),
VBaseOffset);
}
}
-void
+void
VCallAndVBaseOffsetBuilder::AddVBaseOffsets(const CXXRecordDecl *RD,
CharUnits OffsetInLayoutClass) {
- const ASTRecordLayout &LayoutClassLayout =
+ const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass);
// Add vbase offsets.
@@ -747,7 +747,7 @@ VCallAndVBaseOffsetBuilder::AddVBaseOffsets(const CXXRecordDecl *RD,
// Check if this is a virtual base that we haven't visited before.
if (B.isVirtual() && VisitedVirtualBases.insert(BaseDecl).second) {
- CharUnits Offset =
+ CharUnits Offset =
LayoutClassLayout.getVBaseClassOffset(BaseDecl) - OffsetInLayoutClass;
// Add the vbase offset offset.
@@ -770,12 +770,12 @@ VCallAndVBaseOffsetBuilder::AddVBaseOffsets(const CXXRecordDecl *RD,
/// ItaniumVTableBuilder - Class for building vtable layout information.
class ItaniumVTableBuilder {
public:
- /// PrimaryBasesSetVectorTy - A set vector of direct and indirect
+ /// PrimaryBasesSetVectorTy - A set vector of direct and indirect
/// primary bases.
- typedef llvm::SmallSetVector<const CXXRecordDecl *, 8>
+ typedef llvm::SmallSetVector<const CXXRecordDecl *, 8>
PrimaryBasesSetVectorTy;
-
- typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits>
+
+ typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits>
VBaseOffsetOffsetsMapTy;
typedef VTableLayout::AddressPointsMapTy AddressPointsMapTy;
@@ -785,7 +785,7 @@ public:
private:
/// VTables - Global vtable information.
ItaniumVTableContext &VTables;
-
+
/// MostDerivedClass - The most derived class for which we're building this
/// vtable.
const CXXRecordDecl *MostDerivedClass;
@@ -793,19 +793,19 @@ private:
/// MostDerivedClassOffset - If we're building a construction vtable, this
/// holds the offset from the layout class to the most derived class.
const CharUnits MostDerivedClassOffset;
-
- /// MostDerivedClassIsVirtual - Whether the most derived class is a virtual
+
+ /// MostDerivedClassIsVirtual - Whether the most derived class is a virtual
/// base. (This only makes sense when building a construction vtable).
bool MostDerivedClassIsVirtual;
-
- /// LayoutClass - The class we're using for layout information. Will be
+
+ /// LayoutClass - The class we're using for layout information. Will be
/// different than the most derived class if we're building a construction
/// vtable.
const CXXRecordDecl *LayoutClass;
-
+
/// Context - The ASTContext which we will use for layout information.
ASTContext &Context;
-
+
/// FinalOverriders - The final overriders of the most derived class.
const FinalOverriders Overriders;
@@ -828,29 +828,29 @@ private:
struct MethodInfo {
/// BaseOffset - The base offset of this method.
const CharUnits BaseOffset;
-
+
/// BaseOffsetInLayoutClass - The base offset in the layout class of this
/// method.
const CharUnits BaseOffsetInLayoutClass;
-
+
/// VTableIndex - The index in the vtable that this method has.
/// (For destructors, this is the index of the complete destructor).
const uint64_t VTableIndex;
-
- MethodInfo(CharUnits BaseOffset, CharUnits BaseOffsetInLayoutClass,
+
+ MethodInfo(CharUnits BaseOffset, CharUnits BaseOffsetInLayoutClass,
uint64_t VTableIndex)
- : BaseOffset(BaseOffset),
+ : BaseOffset(BaseOffset),
BaseOffsetInLayoutClass(BaseOffsetInLayoutClass),
VTableIndex(VTableIndex) { }
-
- MethodInfo()
- : BaseOffset(CharUnits::Zero()),
- BaseOffsetInLayoutClass(CharUnits::Zero()),
+
+ MethodInfo()
+ : BaseOffset(CharUnits::Zero()),
+ BaseOffsetInLayoutClass(CharUnits::Zero()),
VTableIndex(0) { }
};
-
+
typedef llvm::DenseMap<const CXXMethodDecl *, MethodInfo> MethodInfoMapTy;
-
+
/// MethodInfoMap - The information for all methods in the vtable we're
/// currently building.
MethodInfoMapTy MethodInfoMap;
@@ -860,25 +860,25 @@ private:
MethodVTableIndicesTy MethodVTableIndices;
typedef llvm::DenseMap<uint64_t, ThunkInfo> VTableThunksMapTy;
-
- /// VTableThunks - The thunks by vtable index in the vtable currently being
+
+ /// VTableThunks - The thunks by vtable index in the vtable currently being
/// built.
VTableThunksMapTy VTableThunks;
typedef SmallVector<ThunkInfo, 1> ThunkInfoVectorTy;
typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy;
-
+
/// Thunks - A map that contains all the thunks needed for all methods in the
/// most derived class for which the vtable is currently being built.
ThunksMapTy Thunks;
-
+
/// AddThunk - Add a thunk for the given method.
void AddThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk);
-
+
/// ComputeThisAdjustments - Compute the 'this' pointer adjustments for the
/// part of the vtable we're currently building.
void ComputeThisAdjustments();
-
+
typedef llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBasesSetTy;
/// PrimaryVirtualBases - All known virtual bases who are a primary base of
@@ -888,7 +888,7 @@ private:
/// ComputeReturnAdjustment - Compute the return adjustment given a return
/// adjustment base offset.
ReturnAdjustment ComputeReturnAdjustment(BaseOffset Offset);
-
+
/// ComputeThisAdjustmentBaseOffset - Compute the base offset for adjusting
/// the 'this' pointer from the base subobject to the derived subobject.
BaseOffset ComputeThisAdjustmentBaseOffset(BaseSubobject Base,
@@ -897,8 +897,8 @@ private:
/// ComputeThisAdjustment - Compute the 'this' pointer adjustment for the
/// given virtual member function, its offset in the layout class and its
/// final overrider.
- ThisAdjustment
- ComputeThisAdjustment(const CXXMethodDecl *MD,
+ ThisAdjustment
+ ComputeThisAdjustment(const CXXMethodDecl *MD,
CharUnits BaseOffsetInLayoutClass,
FinalOverriders::OverriderInfo Overrider);
@@ -907,7 +907,7 @@ private:
void AddMethod(const CXXMethodDecl *MD, ReturnAdjustment ReturnAdjustment);
/// IsOverriderUsed - Returns whether the overrider will ever be used in this
- /// part of the vtable.
+ /// part of the vtable.
///
/// Itanium C++ ABI 2.5.2:
///
@@ -921,16 +921,16 @@ private:
/// adjustment is required and no thunk is generated. However, inside D
/// objects, A is no longer a primary base of C, so if we allowed calls to
/// C::f() to use the copy of A's vtable in the C subobject, we would need
- /// to adjust this from C* to B::A*, which would require a third-party
- /// thunk. Since we require that a call to C::f() first convert to A*,
- /// C-in-D's copy of A's vtable is never referenced, so this is not
+ /// to adjust this from C* to B::A*, which would require a third-party
+ /// thunk. Since we require that a call to C::f() first convert to A*,
+ /// C-in-D's copy of A's vtable is never referenced, so this is not
/// necessary.
bool IsOverriderUsed(const CXXMethodDecl *Overrider,
CharUnits BaseOffsetInLayoutClass,
const CXXRecordDecl *FirstBaseInPrimaryBaseChain,
CharUnits FirstBaseOffsetInLayoutClass) const;
-
+
/// AddMethods - Add the methods of this base subobject and all its
/// primary bases to the vtable components vector.
void AddMethods(BaseSubobject Base, CharUnits BaseOffsetInLayoutClass,
@@ -949,12 +949,12 @@ private:
/// or a direct or indirect base of a virtual base.
///
/// \param BaseIsVirtualInLayoutClass - Whether the base subobject is virtual
- /// in the layout class.
+ /// in the layout class.
void LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
bool BaseIsMorallyVirtual,
bool BaseIsVirtualInLayoutClass,
CharUnits OffsetInLayoutClass);
-
+
/// LayoutSecondaryVTables - Layout the secondary vtables for the given base
/// subobject.
///
@@ -965,18 +965,18 @@ private:
/// DeterminePrimaryVirtualBases - Determine the primary virtual bases in this
/// class hierarchy.
- void DeterminePrimaryVirtualBases(const CXXRecordDecl *RD,
+ void DeterminePrimaryVirtualBases(const CXXRecordDecl *RD,
CharUnits OffsetInLayoutClass,
VisitedVirtualBasesSetTy &VBases);
/// LayoutVTablesForVirtualBases - Layout vtables for all virtual bases of the
/// given base (excluding any primary bases).
- void LayoutVTablesForVirtualBases(const CXXRecordDecl *RD,
+ void LayoutVTablesForVirtualBases(const CXXRecordDecl *RD,
VisitedVirtualBasesSetTy &VBases);
/// isBuildingConstructionVTable - Return whether this vtable builder is
/// building a construction vtable.
- bool isBuildingConstructorVTable() const {
+ bool isBuildingConstructorVTable() const {
return MostDerivedClass != LayoutClass;
}
@@ -1055,16 +1055,16 @@ public:
void ItaniumVTableBuilder::AddThunk(const CXXMethodDecl *MD,
const ThunkInfo &Thunk) {
- assert(!isBuildingConstructorVTable() &&
+ assert(!isBuildingConstructorVTable() &&
"Can't add thunks for construction vtable");
SmallVectorImpl<ThunkInfo> &ThunksVector = Thunks[MD];
// Check if we have this thunk already.
- if (std::find(ThunksVector.begin(), ThunksVector.end(), Thunk) !=
+ if (std::find(ThunksVector.begin(), ThunksVector.end(), Thunk) !=
ThunksVector.end())
return;
-
+
ThunksVector.push_back(Thunk);
}
@@ -1107,18 +1107,18 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
// Ignore adjustments for unused function pointers.
uint64_t VTableIndex = MethodInfo.VTableIndex;
- if (Components[VTableIndex].getKind() ==
+ if (Components[VTableIndex].getKind() ==
VTableComponent::CK_UnusedFunctionPointer)
continue;
-
+
// Get the final overrider for this method.
FinalOverriders::OverriderInfo Overrider =
Overriders.getOverrider(MD, MethodInfo.BaseOffset);
-
+
// Check if we need an adjustment at all.
if (MethodInfo.BaseOffsetInLayoutClass == Overrider.Offset) {
// When a return thunk is needed by a derived class that overrides a
- // virtual base, gcc uses a virtual 'this' adjustment as well.
+ // virtual base, gcc uses a virtual 'this' adjustment as well.
// While the thunk itself might be needed by vtables in subclasses or
// in construction vtables, there doesn't seem to be a reason for using
// the thunk in this vtable. Still, we do so to match gcc.
@@ -1143,7 +1143,7 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
/// Clear the method info map.
MethodInfoMap.clear();
-
+
if (isBuildingConstructorVTable()) {
// We don't need to store thunk information for construction vtables.
return;
@@ -1153,7 +1153,7 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
const VTableComponent &Component = Components[TI.first];
const ThunkInfo &Thunk = TI.second;
const CXXMethodDecl *MD;
-
+
switch (Component.getKind()) {
default:
llvm_unreachable("Unexpected vtable component kind!");
@@ -1176,7 +1176,7 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
ReturnAdjustment
ItaniumVTableBuilder::ComputeReturnAdjustment(BaseOffset Offset) {
ReturnAdjustment Adjustment;
-
+
if (!Offset.isEmpty()) {
if (Offset.VirtualBase) {
// Get the virtual base offset offset.
@@ -1193,7 +1193,7 @@ ItaniumVTableBuilder::ComputeReturnAdjustment(BaseOffset Offset) {
Adjustment.NonVirtual = Offset.NonVirtualOffset.getQuantity();
}
-
+
return Adjustment;
}
@@ -1201,7 +1201,7 @@ BaseOffset ItaniumVTableBuilder::ComputeThisAdjustmentBaseOffset(
BaseSubobject Base, BaseSubobject Derived) const {
const CXXRecordDecl *BaseRD = Base.getBase();
const CXXRecordDecl *DerivedRD = Derived.getBase();
-
+
CXXBasePaths Paths(/*FindAmbiguities=*/true,
/*RecordPaths=*/true, /*DetectVirtual=*/true);
@@ -1214,32 +1214,32 @@ BaseOffset ItaniumVTableBuilder::ComputeThisAdjustmentBaseOffset(
BaseOffset Offset = ComputeBaseOffset(Context, DerivedRD, Path);
CharUnits OffsetToBaseSubobject = Offset.NonVirtualOffset;
-
+
if (Offset.VirtualBase) {
// If we have a virtual base class, the non-virtual offset is relative
// to the virtual base class offset.
const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass);
-
- /// Get the virtual base offset, relative to the most derived class
+
+ /// Get the virtual base offset, relative to the most derived class
/// layout.
- OffsetToBaseSubobject +=
+ OffsetToBaseSubobject +=
LayoutClassLayout.getVBaseClassOffset(Offset.VirtualBase);
} else {
- // Otherwise, the non-virtual offset is relative to the derived class
+ // Otherwise, the non-virtual offset is relative to the derived class
// offset.
OffsetToBaseSubobject += Derived.getBaseOffset();
}
-
+
// Check if this path gives us the right base subobject.
if (OffsetToBaseSubobject == Base.getBaseOffset()) {
// Since we're going from the base class _to_ the derived class, we'll
// invert the non-virtual offset here.
Offset.NonVirtualOffset = -Offset.NonVirtualOffset;
return Offset;
- }
+ }
}
-
+
return BaseOffset();
}
@@ -1249,13 +1249,13 @@ ThisAdjustment ItaniumVTableBuilder::ComputeThisAdjustment(
// Ignore adjustments for pure virtual member functions.
if (Overrider.Method->isPure())
return ThisAdjustment();
-
- BaseSubobject OverriddenBaseSubobject(MD->getParent(),
+
+ BaseSubobject OverriddenBaseSubobject(MD->getParent(),
BaseOffsetInLayoutClass);
-
+
BaseSubobject OverriderBaseSubobject(Overrider.Method->getParent(),
Overrider.Offset);
-
+
// Compute the adjustment offset.
BaseOffset Offset = ComputeThisAdjustmentBaseOffset(OverriddenBaseSubobject,
OverriderBaseSubobject);
@@ -1263,7 +1263,7 @@ ThisAdjustment ItaniumVTableBuilder::ComputeThisAdjustment(
return ThisAdjustment();
ThisAdjustment Adjustment;
-
+
if (Offset.VirtualBase) {
// Get the vcall offset map for this virtual base.
VCallOffsetMap &VCallOffsets = VCallOffsetsForVBases[Offset.VirtualBase];
@@ -1278,24 +1278,24 @@ ThisAdjustment ItaniumVTableBuilder::ComputeThisAdjustment(
/*BaseIsVirtual=*/true,
/*OffsetInLayoutClass=*/
CharUnits::Zero());
-
+
VCallOffsets = Builder.getVCallOffsets();
}
-
+
Adjustment.Virtual.Itanium.VCallOffsetOffset =
VCallOffsets.getVCallOffsetOffset(MD).getQuantity();
}
// Set the non-virtual part of the adjustment.
Adjustment.NonVirtual = Offset.NonVirtualOffset.getQuantity();
-
+
return Adjustment;
}
void ItaniumVTableBuilder::AddMethod(const CXXMethodDecl *MD,
ReturnAdjustment ReturnAdjustment) {
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(MD)) {
- assert(ReturnAdjustment.isEmpty() &&
+ assert(ReturnAdjustment.isEmpty() &&
"Destructor can't have return adjustment!");
// Add both the complete destructor and the deleting destructor.
@@ -1312,7 +1312,7 @@ void ItaniumVTableBuilder::AddMethod(const CXXMethodDecl *MD,
}
/// OverridesIndirectMethodInBase - Return whether the given member function
-/// overrides any methods in the set of given bases.
+/// overrides any methods in the set of given bases.
/// Unlike OverridesMethodInBase, this checks "overriders of overriders".
/// For example, if we have:
///
@@ -1320,7 +1320,7 @@ void ItaniumVTableBuilder::AddMethod(const CXXMethodDecl *MD,
/// struct B : A { virtual void f(); }
/// struct C : B { virtual void f(); }
///
-/// OverridesIndirectMethodInBase will return true if given C::f as the method
+/// OverridesIndirectMethodInBase will return true if given C::f as the method
/// and { A } as the set of bases.
static bool OverridesIndirectMethodInBases(
const CXXMethodDecl *MD,
@@ -1333,7 +1333,7 @@ static bool OverridesIndirectMethodInBases(
if (OverridesIndirectMethodInBases(OverriddenMD, Bases))
return true;
}
-
+
return false;
}
@@ -1347,9 +1347,9 @@ bool ItaniumVTableBuilder::IsOverriderUsed(
return true;
// We know now that Base (or a direct or indirect base of it) is a primary
- // base in part of the class hierarchy, but not a primary base in the most
+ // base in part of the class hierarchy, but not a primary base in the most
// derived class.
-
+
// If the overrider is the first base in the primary base chain, we know
// that the overrider will be used.
if (Overrider->getParent() == FirstBaseInPrimaryBaseChain)
@@ -1365,10 +1365,10 @@ bool ItaniumVTableBuilder::IsOverriderUsed(
while (true) {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
-
+
if (!PrimaryBase)
break;
-
+
if (Layout.isPrimaryBaseVirtual()) {
assert(Layout.getVBaseClassOffset(PrimaryBase).isZero() &&
"Primary base should always be at offset 0!");
@@ -1387,13 +1387,13 @@ bool ItaniumVTableBuilder::IsOverriderUsed(
assert(Layout.getBaseClassOffset(PrimaryBase).isZero() &&
"Primary base should always be at offset 0!");
}
-
+
if (!PrimaryBases.insert(PrimaryBase))
llvm_unreachable("Found a duplicate primary base!");
RD = PrimaryBase;
}
-
+
// If the final overrider is an override of one of the primary bases,
// then we know that it will be used.
return OverridesIndirectMethodInBases(Overrider, PrimaryBases);
@@ -1446,13 +1446,13 @@ void ItaniumVTableBuilder::AddMethods(
if (Layout.isPrimaryBaseVirtual()) {
assert(Layout.getVBaseClassOffset(PrimaryBase).isZero() &&
"Primary vbase should have a zero offset!");
-
+
const ASTRecordLayout &MostDerivedClassLayout =
Context.getASTRecordLayout(MostDerivedClass);
-
- PrimaryBaseOffset =
+
+ PrimaryBaseOffset =
MostDerivedClassLayout.getVBaseClassOffset(PrimaryBase);
-
+
const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass);
@@ -1467,9 +1467,9 @@ void ItaniumVTableBuilder::AddMethods(
}
AddMethods(BaseSubobject(PrimaryBase, PrimaryBaseOffset),
- PrimaryBaseOffsetInLayoutClass, FirstBaseInPrimaryBaseChain,
+ PrimaryBaseOffsetInLayoutClass, FirstBaseInPrimaryBaseChain,
FirstBaseOffsetInLayoutClass, PrimaryBases);
-
+
if (!PrimaryBases.insert(PrimaryBase))
llvm_unreachable("Found a duplicate primary base!");
}
@@ -1486,31 +1486,31 @@ void ItaniumVTableBuilder::AddMethods(
MD = MD->getCanonicalDecl();
// Get the final overrider.
- FinalOverriders::OverriderInfo Overrider =
+ FinalOverriders::OverriderInfo Overrider =
Overriders.getOverrider(MD, Base.getBaseOffset());
// Check if this virtual member function overrides a method in a primary
// base. If this is the case, and the return type doesn't require adjustment
// then we can just use the member function from the primary base.
- if (const CXXMethodDecl *OverriddenMD =
+ if (const CXXMethodDecl *OverriddenMD =
FindNearestOverriddenMethod(MD, PrimaryBases)) {
- if (ComputeReturnAdjustmentBaseOffset(Context, MD,
+ if (ComputeReturnAdjustmentBaseOffset(Context, MD,
OverriddenMD).isEmpty()) {
// Replace the method info of the overridden method with our own
// method.
- assert(MethodInfoMap.count(OverriddenMD) &&
+ assert(MethodInfoMap.count(OverriddenMD) &&
"Did not find the overridden method!");
MethodInfo &OverriddenMethodInfo = MethodInfoMap[OverriddenMD];
-
+
MethodInfo MethodInfo(Base.getBaseOffset(), BaseOffsetInLayoutClass,
OverriddenMethodInfo.VTableIndex);
assert(!MethodInfoMap.count(MD) &&
"Should not have method info for this method yet!");
-
+
MethodInfoMap.insert(std::make_pair(MD, MethodInfo));
MethodInfoMap.erase(OverriddenMD);
-
+
// If the overridden method exists in a virtual base class or a direct
// or indirect base class of a virtual base class, we need to emit a
// thunk if we ever have a class hierarchy where the base class is not
@@ -1529,11 +1529,11 @@ void ItaniumVTableBuilder::AddMethods(
// the final overrider.
BaseOffset ReturnAdjustmentOffset =
ComputeReturnAdjustmentBaseOffset(Context, Overrider.Method, MD);
- ReturnAdjustment ReturnAdjustment =
+ ReturnAdjustment ReturnAdjustment =
ComputeReturnAdjustment(ReturnAdjustmentOffset);
// This is a virtual thunk for the most derived class, add it.
- AddThunk(Overrider.Method,
+ AddThunk(Overrider.Method,
ThunkInfo(ThisAdjustment, ReturnAdjustment));
}
}
@@ -1577,7 +1577,7 @@ void ItaniumVTableBuilder::AddMethods(
// Check if this overrider is going to be used.
const CXXMethodDecl *OverriderMD = Overrider.Method;
if (!IsOverriderUsed(OverriderMD, BaseOffsetInLayoutClass,
- FirstBaseInPrimaryBaseChain,
+ FirstBaseInPrimaryBaseChain,
FirstBaseOffsetInLayoutClass)) {
Components.push_back(VTableComponent::MakeUnusedFunction(OverriderMD));
continue;
@@ -1587,13 +1587,13 @@ void ItaniumVTableBuilder::AddMethods(
// We don't want to do this for pure virtual member functions.
BaseOffset ReturnAdjustmentOffset;
if (!OverriderMD->isPure()) {
- ReturnAdjustmentOffset =
+ ReturnAdjustmentOffset =
ComputeReturnAdjustmentBaseOffset(Context, OverriderMD, MD);
}
- ReturnAdjustment ReturnAdjustment =
+ ReturnAdjustment ReturnAdjustment =
ComputeReturnAdjustment(ReturnAdjustmentOffset);
-
+
AddMethod(Overrider.Method, ReturnAdjustment);
}
}
@@ -1604,14 +1604,14 @@ void ItaniumVTableBuilder::LayoutVTable() {
/*BaseIsMorallyVirtual=*/false,
MostDerivedClassIsVirtual,
MostDerivedClassOffset);
-
+
VisitedVirtualBasesSetTy VBases;
-
+
// Determine the primary virtual bases.
- DeterminePrimaryVirtualBases(MostDerivedClass, MostDerivedClassOffset,
+ DeterminePrimaryVirtualBases(MostDerivedClass, MostDerivedClassOffset,
VBases);
VBases.clear();
-
+
LayoutVTablesForVirtualBases(MostDerivedClass, VBases);
// -fapple-kext adds an extra entry at end of vtbl.
@@ -1630,14 +1630,14 @@ void ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
// Add vcall and vbase offsets for this vtable.
VCallAndVBaseOffsetBuilder Builder(MostDerivedClass, LayoutClass, &Overriders,
- Base, BaseIsVirtualInLayoutClass,
+ Base, BaseIsVirtualInLayoutClass,
OffsetInLayoutClass);
Components.append(Builder.components_begin(), Builder.components_end());
-
+
// Check if we need to add these vcall offsets.
if (BaseIsVirtualInLayoutClass && !Builder.getVCallOffsets().empty()) {
VCallOffsetMap &VCallOffsets = VCallOffsetsForVBases[Base.getBase()];
-
+
if (VCallOffsets.empty())
VCallOffsets = Builder.getVCallOffsets();
}
@@ -1659,7 +1659,7 @@ void ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
// Now go through all virtual member functions and add them.
PrimaryBasesSetVectorTy PrimaryBases;
AddMethods(Base, OffsetInLayoutClass,
- Base.getBase(), OffsetInLayoutClass,
+ Base.getBase(), OffsetInLayoutClass,
PrimaryBases);
const CXXRecordDecl *RD = Base.getBase();
@@ -1692,10 +1692,10 @@ void ItaniumVTableBuilder::LayoutPrimaryAndSecondaryVTables(
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
-
+
if (!PrimaryBase)
break;
-
+
if (Layout.isPrimaryBaseVirtual()) {
// Check if this virtual primary base is a primary base in the layout
// class. If it's not, we don't want to add it.
@@ -1721,19 +1721,19 @@ ItaniumVTableBuilder::LayoutSecondaryVTables(BaseSubobject Base,
bool BaseIsMorallyVirtual,
CharUnits OffsetInLayoutClass) {
// Itanium C++ ABI 2.5.2:
- // Following the primary virtual table of a derived class are secondary
+ // Following the primary virtual table of a derived class are secondary
// virtual tables for each of its proper base classes, except any primary
// base(s) with which it shares its primary virtual table.
const CXXRecordDecl *RD = Base.getBase();
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
-
+
for (const auto &B : RD->bases()) {
// Ignore virtual bases, we'll emit them later.
if (B.isVirtual())
continue;
-
+
const CXXRecordDecl *BaseDecl = B.getType()->getAsCXXRecordDecl();
// Ignore bases that don't have a vtable.
@@ -1753,11 +1753,11 @@ ItaniumVTableBuilder::LayoutSecondaryVTables(BaseSubobject Base,
// Get the base offset of this base.
CharUnits RelativeBaseOffset = Layout.getBaseClassOffset(BaseDecl);
CharUnits BaseOffset = Base.getBaseOffset() + RelativeBaseOffset;
-
- CharUnits BaseOffsetInLayoutClass =
+
+ CharUnits BaseOffsetInLayoutClass =
OffsetInLayoutClass + RelativeBaseOffset;
-
- // Don't emit a secondary vtable for a primary base. We might however want
+
+ // Don't emit a secondary vtable for a primary base. We might however want
// to emit secondary vtables for other bases of this base.
if (BaseDecl == PrimaryBase) {
LayoutSecondaryVTables(BaseSubobject(BaseDecl, BaseOffset),
@@ -1778,7 +1778,7 @@ void ItaniumVTableBuilder::DeterminePrimaryVirtualBases(
const CXXRecordDecl *RD, CharUnits OffsetInLayoutClass,
VisitedVirtualBasesSetTy &VBases) {
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
-
+
// Check if this base has a primary base.
if (const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase()) {
@@ -1794,13 +1794,13 @@ void ItaniumVTableBuilder::DeterminePrimaryVirtualBases(
CharUnits PrimaryBaseOffsetInLayoutClass =
LayoutClassLayout.getVBaseClassOffset(PrimaryBase);
-
- // We know that the base is not a primary base in the layout class if
+
+ // We know that the base is not a primary base in the layout class if
// the base offsets are different.
if (PrimaryBaseOffsetInLayoutClass != OffsetInLayoutClass)
IsPrimaryVirtualBase = false;
}
-
+
if (IsPrimaryVirtualBase)
PrimaryVirtualBases.insert(PrimaryBase);
}
@@ -1811,18 +1811,18 @@ void ItaniumVTableBuilder::DeterminePrimaryVirtualBases(
const CXXRecordDecl *BaseDecl = B.getType()->getAsCXXRecordDecl();
CharUnits BaseOffsetInLayoutClass;
-
+
if (B.isVirtual()) {
if (!VBases.insert(BaseDecl).second)
continue;
-
+
const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass);
- BaseOffsetInLayoutClass =
+ BaseOffsetInLayoutClass =
LayoutClassLayout.getVBaseClassOffset(BaseDecl);
} else {
- BaseOffsetInLayoutClass =
+ BaseOffsetInLayoutClass =
OffsetInLayoutClass + Layout.getBaseClassOffset(BaseDecl);
}
@@ -1846,12 +1846,12 @@ void ItaniumVTableBuilder::LayoutVTablesForVirtualBases(
VBases.insert(BaseDecl).second) {
const ASTRecordLayout &MostDerivedClassLayout =
Context.getASTRecordLayout(MostDerivedClass);
- CharUnits BaseOffset =
+ CharUnits BaseOffset =
MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
-
+
const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass);
- CharUnits BaseOffsetInLayoutClass =
+ CharUnits BaseOffsetInLayoutClass =
LayoutClassLayout.getVBaseClassOffset(BaseDecl);
LayoutPrimaryAndSecondaryVTables(
@@ -1860,7 +1860,7 @@ void ItaniumVTableBuilder::LayoutVTablesForVirtualBases(
/*BaseIsVirtualInLayoutClass=*/true,
BaseOffsetInLayoutClass);
}
-
+
// We only need to check the base for virtual base vtables if it actually
// has virtual bases.
if (BaseDecl->getNumVBases())
@@ -1897,7 +1897,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
AddressPointsByIndex.insert(std::make_pair(Index, Base));
}
-
+
for (unsigned I = 0, E = Components.size(); I != E; ++I) {
uint64_t Index = I;
@@ -1910,7 +1910,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
case VTableComponent::CK_VCallOffset:
Out << "vcall_offset ("
- << Component.getVCallOffset().getQuantity()
+ << Component.getVCallOffset().getQuantity()
<< ")";
break;
@@ -1925,17 +1925,17 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
<< Component.getOffsetToTop().getQuantity()
<< ")";
break;
-
+
case VTableComponent::CK_RTTI:
Component.getRTTIDecl()->printQualifiedName(Out);
Out << " RTTI";
break;
-
+
case VTableComponent::CK_FunctionPointer: {
const CXXMethodDecl *MD = Component.getFunctionDecl();
- std::string Str =
- PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
+ std::string Str =
+ PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
MD);
Out << Str;
if (MD->isPure())
@@ -1950,7 +1950,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
if (!Thunk.Return.isEmpty()) {
Out << "\n [return adjustment: ";
Out << Thunk.Return.NonVirtual << " non-virtual";
-
+
if (Thunk.Return.Virtual.Itanium.VBaseOffsetOffset) {
Out << ", " << Thunk.Return.Virtual.Itanium.VBaseOffsetOffset;
Out << " vbase offset offset";
@@ -1963,26 +1963,26 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
if (!Thunk.This.isEmpty()) {
Out << "\n [this adjustment: ";
Out << Thunk.This.NonVirtual << " non-virtual";
-
+
if (Thunk.This.Virtual.Itanium.VCallOffsetOffset) {
Out << ", " << Thunk.This.Virtual.Itanium.VCallOffsetOffset;
Out << " vcall offset offset";
}
Out << ']';
- }
+ }
}
break;
}
- case VTableComponent::CK_CompleteDtorPointer:
+ case VTableComponent::CK_CompleteDtorPointer:
case VTableComponent::CK_DeletingDtorPointer: {
- bool IsComplete =
+ bool IsComplete =
Component.getKind() == VTableComponent::CK_CompleteDtorPointer;
-
+
const CXXDestructorDecl *DD = Component.getDestructorDecl();
-
+
DD->printQualifiedName(Out);
if (IsComplete)
Out << "() [complete]";
@@ -1998,15 +1998,15 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
if (!Thunk.This.isEmpty()) {
Out << "\n [this adjustment: ";
Out << Thunk.This.NonVirtual << " non-virtual";
-
+
if (Thunk.This.Virtual.Itanium.VCallOffsetOffset) {
Out << ", " << Thunk.This.Virtual.Itanium.VCallOffsetOffset;
Out << " vcall offset offset";
}
-
+
Out << ']';
- }
- }
+ }
+ }
break;
}
@@ -2014,8 +2014,8 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
case VTableComponent::CK_UnusedFunctionPointer: {
const CXXMethodDecl *MD = Component.getUnusedFunctionDecl();
- std::string Str =
- PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
+ std::string Str =
+ PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
MD);
Out << "[unused] " << Str;
if (MD->isPure())
@@ -2025,14 +2025,14 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
}
Out << '\n';
-
+
// Dump the next address point.
uint64_t NextIndex = Index + 1;
if (AddressPointsByIndex.count(NextIndex)) {
if (AddressPointsByIndex.count(NextIndex) == 1) {
- const BaseSubobject &Base =
+ const BaseSubobject &Base =
AddressPointsByIndex.find(NextIndex)->second;
-
+
Out << " -- (";
Base.getBase()->printQualifiedName(Out);
Out << ", " << Base.getBaseOffset().getQuantity();
@@ -2040,7 +2040,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
} else {
CharUnits BaseOffset =
AddressPointsByIndex.lower_bound(NextIndex)->second.getBaseOffset();
-
+
// We store the class names in a set to get a stable order.
std::set<std::string> ClassNames;
for (const auto &I :
@@ -2060,10 +2060,10 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
}
Out << '\n';
-
+
if (isBuildingConstructorVTable())
return;
-
+
if (MostDerivedClass->getNumVBases()) {
// We store the virtual base class names and their offsets in a map to get
// a stable order.
@@ -2074,7 +2074,7 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
CharUnits OffsetOffset = I.second;
ClassNamesAndOffsets.insert(std::make_pair(ClassName, OffsetOffset));
}
-
+
Out << "Virtual base offset offsets for '";
MostDerivedClass->printQualifiedName(Out);
Out << "' (";
@@ -2086,17 +2086,17 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
Out << "\n";
}
-
+
if (!Thunks.empty()) {
// We store the method names in a map to get a stable order.
std::map<std::string, const CXXMethodDecl *> MethodNamesAndDecls;
for (const auto &I : Thunks) {
const CXXMethodDecl *MD = I.first;
- std::string MethodName =
+ std::string MethodName =
PredefinedExpr::ComputeName(PredefinedExpr::PrettyFunctionNoVirtual,
MD);
-
+
MethodNamesAndDecls.insert(std::make_pair(MethodName, MD));
}
@@ -2113,12 +2113,12 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
Out << "Thunks for '" << MethodName << "' (" << ThunksVector.size();
Out << (ThunksVector.size() == 1 ? " entry" : " entries") << ").\n";
-
+
for (unsigned I = 0, E = ThunksVector.size(); I != E; ++I) {
const ThunkInfo &Thunk = ThunksVector[I];
Out << llvm::format("%4d | ", I);
-
+
// If this function pointer has a return pointer adjustment, dump it.
if (!Thunk.Return.isEmpty()) {
Out << "return adjustment: " << Thunk.Return.NonVirtual;
@@ -2136,16 +2136,16 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
if (!Thunk.This.isEmpty()) {
Out << "this adjustment: ";
Out << Thunk.This.NonVirtual << " non-virtual";
-
+
if (Thunk.This.Virtual.Itanium.VCallOffsetOffset) {
Out << ", " << Thunk.This.Virtual.Itanium.VCallOffsetOffset;
Out << " vcall offset offset";
}
}
-
+
Out << '\n';
}
-
+
Out << '\n';
}
}
@@ -2227,7 +2227,7 @@ uint64_t ItaniumVTableContext::getMethodVTableIndex(GlobalDecl GD) {
MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
if (I != MethodVTableIndices.end())
return I->second;
-
+
const CXXRecordDecl *RD = cast<CXXMethodDecl>(GD.getDecl())->getParent();
computeVTableRelatedInformation(RD);
@@ -2241,8 +2241,8 @@ CharUnits
ItaniumVTableContext::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD,
const CXXRecordDecl *VBase) {
ClassPairTy ClassPair(RD, VBase);
-
- VirtualBaseClassOffsetOffsetsMapTy::iterator I =
+
+ VirtualBaseClassOffsetOffsetsMapTy::iterator I =
VirtualBaseClassOffsetOffsets.find(ClassPair);
if (I != VirtualBaseClassOffsetOffsets.end())
return I->second;
@@ -2258,10 +2258,10 @@ ItaniumVTableContext::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD,
VirtualBaseClassOffsetOffsets.insert(std::make_pair(ClassPair, I.second));
}
-
+
I = VirtualBaseClassOffsetOffsets.find(ClassPair);
assert(I != VirtualBaseClassOffsetOffsets.end() && "Did not find index!");
-
+
return I->second;
}
@@ -2298,10 +2298,10 @@ ItaniumVTableContext::computeVTableRelatedInformation(const CXXRecordDecl *RD) {
// the rest of the vtable related information.
if (!RD->getNumVBases())
return;
-
+
const CXXRecordDecl *VBase =
RD->vbases_begin()->getType()->getAsCXXRecordDecl();
-
+
if (VirtualBaseClassOffsetOffsets.count(std::make_pair(RD, VBase)))
return;
diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp
index 486fffbe1299..9557f68452ff 100644
--- a/lib/Analysis/AnalysisDeclContext.cpp
+++ b/lib/Analysis/AnalysisDeclContext.cpp
@@ -56,13 +56,13 @@ using ManagedAnalysisMap = llvm::DenseMap<const void *, ManagedAnalysis *>;
AnalysisDeclContext::AnalysisDeclContext(AnalysisDeclContextManager *Mgr,
const Decl *d,
const CFG::BuildOptions &buildOptions)
- : Manager(Mgr), D(d), cfgBuildOptions(buildOptions) {
+ : Manager(Mgr), D(d), cfgBuildOptions(buildOptions) {
cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
}
AnalysisDeclContext::AnalysisDeclContext(AnalysisDeclContextManager *Mgr,
const Decl *d)
- : Manager(Mgr), D(d) {
+ : Manager(Mgr), D(d) {
cfgBuildOptions.forcedBlkExprs = &forcedBlkExprs;
}
@@ -154,7 +154,7 @@ const ImplicitParamDecl *AnalysisDeclContext::getSelfDecl() const {
const VarDecl *VD = I.getVariable();
if (isSelfDecl(VD))
return dyn_cast<ImplicitParamDecl>(VD);
- }
+ }
}
auto *CXXMethod = dyn_cast<CXXMethodDecl>(D);
@@ -191,7 +191,7 @@ AnalysisDeclContext::getBlockForRegisteredExpression(const Stmt *stmt) {
assert(forcedBlkExprs);
if (const auto *e = dyn_cast<Expr>(stmt))
stmt = e->IgnoreParens();
- CFG::BuildOptions::ForcedBlkExprs::const_iterator itr =
+ CFG::BuildOptions::ForcedBlkExprs::const_iterator itr =
forcedBlkExprs->find(stmt);
assert(itr != forcedBlkExprs->end());
return itr->second;
@@ -251,7 +251,7 @@ CFG *AnalysisDeclContext::getUnoptimizedCFG() {
CFGStmtMap *AnalysisDeclContext::getCFGStmtMap() {
if (cfgStmtMap)
return cfgStmtMap.get();
-
+
if (CFG *c = getCFG()) {
cfgStmtMap.reset(CFGStmtMap::Build(c, &getParentMap()));
return cfgStmtMap.get();
@@ -263,7 +263,7 @@ CFGStmtMap *AnalysisDeclContext::getCFGStmtMap() {
CFGReverseBlockReachabilityAnalysis *AnalysisDeclContext::getCFGReachablityAnalysis() {
if (CFA)
return CFA.get();
-
+
if (CFG *c = getCFG()) {
CFA.reset(new CFGReverseBlockReachabilityAnalysis(*c));
return CFA.get();
@@ -346,7 +346,7 @@ bool AnalysisDeclContext::isInStdNamespace(const Decl *D) {
LocationContextManager &AnalysisDeclContext::getLocationContextManager() {
assert(Manager &&
"Cannot create LocationContexts without an AnalysisDeclContextManager!");
- return Manager->getLocationContextManager();
+ return Manager->getLocationContextManager();
}
//===----------------------------------------------------------------------===//
@@ -562,9 +562,9 @@ public:
IgnoredContexts.insert(BR->getBlockDecl());
Visit(BR->getBlockDecl()->getBody());
}
-
+
void VisitPseudoObjectExpr(PseudoObjectExpr *PE) {
- for (PseudoObjectExpr::semantics_iterator it = PE->semantics_begin(),
+ for (PseudoObjectExpr::semantics_iterator it = PE->semantics_begin(),
et = PE->semantics_end(); it != et; ++it) {
Expr *Semantic = *it;
if (auto *OVE = dyn_cast<OpaqueValueExpr>(Semantic))
diff --git a/lib/Analysis/BodyFarm.cpp b/lib/Analysis/BodyFarm.cpp
index b9fb15b2db25..ac8fcdc912a0 100644
--- a/lib/Analysis/BodyFarm.cpp
+++ b/lib/Analysis/BodyFarm.cpp
@@ -50,33 +50,33 @@ namespace {
class ASTMaker {
public:
ASTMaker(ASTContext &C) : C(C) {}
-
+
/// Create a new BinaryOperator representing a simple assignment.
BinaryOperator *makeAssignment(const Expr *LHS, const Expr *RHS, QualType Ty);
-
+
/// Create a new BinaryOperator representing a comparison.
BinaryOperator *makeComparison(const Expr *LHS, const Expr *RHS,
BinaryOperator::Opcode Op);
-
+
/// Create a new compound stmt using the provided statements.
CompoundStmt *makeCompound(ArrayRef<Stmt*>);
-
+
/// Create a new DeclRefExpr for the referenced variable.
DeclRefExpr *makeDeclRefExpr(const VarDecl *D,
bool RefersToEnclosingVariableOrCapture = false);
-
+
/// Create a new UnaryOperator representing a dereference.
UnaryOperator *makeDereference(const Expr *Arg, QualType Ty);
-
+
/// Create an implicit cast for an integer conversion.
Expr *makeIntegralCast(const Expr *Arg, QualType Ty);
-
+
/// Create an implicit cast to a builtin boolean type.
ImplicitCastExpr *makeIntegralCastToBoolean(const Expr *Arg);
-
+
/// Create an implicit cast for lvalue-to-rvaluate conversions.
ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty);
-
+
/// Make RValue out of variable declaration, creating a temporary
/// DeclRefExpr in the process.
ImplicitCastExpr *
@@ -92,10 +92,10 @@ public:
/// Create an Objective-C ivar reference.
ObjCIvarRefExpr *makeObjCIvarRef(const Expr *Base, const ObjCIvarDecl *IVar);
-
+
/// Create a Return statement.
ReturnStmt *makeReturn(const Expr *RetVal);
-
+
/// Create an integer literal expression of the given type.
IntegerLiteral *makeIntegerLiteral(uint64_t Value, QualType Ty);
@@ -342,7 +342,7 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) {
// Nullable pointer, non-null iff function is a CXXRecordDecl.
CXXRecordDecl *CallbackRecordDecl = CallbackType->getAsCXXRecordDecl();
QualType FlagType = Flag->getType().getNonReferenceType();
- auto *FlagRecordDecl = dyn_cast_or_null<RecordDecl>(FlagType->getAsTagDecl());
+ auto *FlagRecordDecl = FlagType->getAsRecordDecl();
if (!FlagRecordDecl) {
LLVM_DEBUG(llvm::dbgs() << "Flag field is not a record: "
@@ -506,9 +506,9 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
// block();
// }
// }
-
+
ASTMaker M(C);
-
+
// (1) Create the call.
CallExpr *CE = new (C) CallExpr(
/*ASTContext=*/C,
@@ -532,11 +532,11 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) {
PredicateTy),
M.makeIntegralCast(DoneValue, PredicateTy),
PredicateTy);
-
+
// (3) Create the compound statement.
Stmt *Stmts[] = { B, CE };
CompoundStmt *CS = M.makeCompound(Stmts);
-
+
// (4) Create the 'if' condition.
ImplicitCastExpr *LValToRval =
M.makeLvalueToRvalue(
@@ -576,7 +576,7 @@ static Stmt *create_dispatch_sync(ASTContext &C, const FunctionDecl *D) {
// void dispatch_sync(dispatch_queue_t queue, void (^block)(void)) {
// block();
// }
- //
+ //
ASTMaker M(C);
DeclRefExpr *DR = M.makeDeclRefExpr(PV);
ImplicitCastExpr *ICE = M.makeLvalueToRvalue(DR, Ty);
@@ -612,16 +612,16 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)
const ParmVarDecl *NewValue = D->getParamDecl(1);
QualType NewValueTy = NewValue->getType();
-
+
assert(OldValueTy == NewValueTy);
-
+
const ParmVarDecl *TheValue = D->getParamDecl(2);
QualType TheValueTy = TheValue->getType();
const PointerType *PT = TheValueTy->getAs<PointerType>();
if (!PT)
return nullptr;
QualType PointeeTy = PT->getPointeeType();
-
+
ASTMaker M(C);
// Construct the comparison.
Expr *Comparison =
@@ -643,29 +643,29 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)
PointeeTy),
M.makeLvalueToRvalue(M.makeDeclRefExpr(NewValue), NewValueTy),
NewValueTy);
-
+
Expr *BoolVal = M.makeObjCBool(true);
Expr *RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)
: M.makeIntegralCast(BoolVal, ResultTy);
Stmts[1] = M.makeReturn(RetVal);
CompoundStmt *Body = M.makeCompound(Stmts);
-
+
// Construct the else clause.
BoolVal = M.makeObjCBool(false);
RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)
: M.makeIntegralCast(BoolVal, ResultTy);
Stmt *Else = M.makeReturn(RetVal);
-
+
/// Construct the If.
Stmt *If = new (C) IfStmt(C, SourceLocation(), false, nullptr, nullptr,
Comparison, Body, SourceLocation(), Else);
- return If;
+ return If;
}
Stmt *BodyFarm::getBody(const FunctionDecl *D) {
D = D->getCanonicalDecl();
-
+
Optional<Stmt *> &Val = Bodies[D];
if (Val.hasValue())
return Val.getValue();
@@ -692,7 +692,7 @@ Stmt *BodyFarm::getBody(const FunctionDecl *D) {
.Case("dispatch_once", create_dispatch_once)
.Default(nullptr);
}
-
+
if (FF) { Val = FF(C, D); }
else if (Injector) { Val = Injector->getBody(D); }
return Val.getValue();
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 8a3ab15458dd..97829de7ace3 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -145,7 +145,7 @@ static bool areExprTypesCompatible(const Expr *E1, const Expr *E2) {
namespace {
class CFGBuilder;
-
+
/// The CFG builder uses a recursive algorithm to build the CFG. When
/// we process an expression, sometimes we know that we must add the
/// subexpressions as block-level expressions. For example:
@@ -279,7 +279,7 @@ public:
private:
BumpVectorContext ctx;
-
+
/// Automatic variables in order of declaration.
AutomaticVarsTy Vars;
@@ -366,7 +366,7 @@ class TryResult {
public:
TryResult() = default;
TryResult(bool b) : X(b ? 1 : 0) {}
-
+
bool isTrue() const { return X == 1; }
bool isFalse() const { return X == 0; }
bool isKnown() const { return X >= 0; }
@@ -492,11 +492,11 @@ class CFGBuilder {
bool badCFG = false;
const CFG::BuildOptions &BuildOpts;
-
+
// State to track for building switch statements.
bool switchExclusivelyCovered = false;
Expr::EvalResult *switchCond = nullptr;
-
+
CFG::BuildOptions::ForcedBlkExprs::value_type *cachedEntry = nullptr;
const Stmt *lastLookup = nullptr;
@@ -516,7 +516,7 @@ public:
std::unique_ptr<CFG> buildCFG(const Decl *D, Stmt *Statement);
bool alwaysAdd(const Stmt *stmt);
-
+
private:
// Visitors to walk an AST and construct the CFG.
CFGBlock *VisitAddrLabelExpr(AddrLabelExpr *A, AddStmtChoice asc);
@@ -569,6 +569,7 @@ private:
CFGBlock *VisitObjCAtTryStmt(ObjCAtTryStmt *S);
CFGBlock *VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S);
CFGBlock *VisitObjCForCollectionStmt(ObjCForCollectionStmt *S);
+ CFGBlock *VisitObjCMessageExpr(ObjCMessageExpr *E, AddStmtChoice asc);
CFGBlock *VisitPseudoObjectExpr(PseudoObjectExpr *E);
CFGBlock *VisitReturnStmt(ReturnStmt *R);
CFGBlock *VisitSEHExceptStmt(SEHExceptStmt *S);
@@ -683,6 +684,25 @@ private:
void findConstructionContexts(const ConstructionContextLayer *Layer,
Stmt *Child);
+ // Scan all arguments of a call expression for a construction context.
+ // These sorts of call expressions don't have a common superclass,
+ // hence strict duck-typing.
+ template <typename CallLikeExpr,
+ typename = typename std::enable_if<
+ std::is_same<CallLikeExpr, CallExpr>::value ||
+ std::is_same<CallLikeExpr, CXXConstructExpr>::value ||
+ std::is_same<CallLikeExpr, ObjCMessageExpr>::value>>
+ void findConstructionContextsForArguments(CallLikeExpr *E) {
+ for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
+ Expr *Arg = E->getArg(i);
+ if (Arg->getType()->getAsCXXRecordDecl() && !Arg->isGLValue())
+ findConstructionContexts(
+ ConstructionContextLayer::create(cfg->getBumpVectorContext(),
+ ConstructionContextItem(E, i)),
+ Arg);
+ }
+ }
+
// Unset the construction context after consuming it. This is done immediately
// after adding the CFGConstructor or CFGCXXRecordTypedCall element, so
// there's no need to do this manually in every Visit... function.
@@ -721,6 +741,19 @@ private:
void addLocalScopeAndDtors(Stmt *S);
+ const ConstructionContext *retrieveAndCleanupConstructionContext(Expr *E) {
+ if (!BuildOpts.AddRichCXXConstructors)
+ return nullptr;
+
+ const ConstructionContextLayer *Layer = ConstructionContextMap.lookup(E);
+ if (!Layer)
+ return nullptr;
+
+ cleanupConstructionContext(E);
+ return ConstructionContext::createFromLayers(cfg->getBumpVectorContext(),
+ Layer);
+ }
+
// Interface to CFGBlock - adding CFGElements.
void appendStmt(CFGBlock *B, const Stmt *S) {
@@ -733,16 +766,10 @@ private:
}
void appendConstructor(CFGBlock *B, CXXConstructExpr *CE) {
- if (BuildOpts.AddRichCXXConstructors) {
- if (const ConstructionContextLayer *Layer =
- ConstructionContextMap.lookup(CE)) {
- cleanupConstructionContext(CE);
- if (const auto *CC = ConstructionContext::createFromLayers(
- cfg->getBumpVectorContext(), Layer)) {
- B->appendConstructor(CE, CC, cfg->getBumpVectorContext());
- return;
- }
- }
+ if (const ConstructionContext *CC =
+ retrieveAndCleanupConstructionContext(CE)) {
+ B->appendConstructor(CE, CC, cfg->getBumpVectorContext());
+ return;
}
// No valid construction context found. Fall back to statement.
@@ -753,18 +780,10 @@ private:
if (alwaysAdd(CE) && cachedEntry)
cachedEntry->second = B;
- if (BuildOpts.AddRichCXXConstructors) {
- if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE, *Context)) {
- if (const ConstructionContextLayer *Layer =
- ConstructionContextMap.lookup(CE)) {
- cleanupConstructionContext(CE);
- if (const auto *CC = ConstructionContext::createFromLayers(
- cfg->getBumpVectorContext(), Layer)) {
- B->appendCXXRecordTypedCall(CE, CC, cfg->getBumpVectorContext());
- return;
- }
- }
- }
+ if (const ConstructionContext *CC =
+ retrieveAndCleanupConstructionContext(CE)) {
+ B->appendCXXRecordTypedCall(CE, CC, cfg->getBumpVectorContext());
+ return;
}
// No valid construction context found. Fall back to statement.
@@ -787,6 +806,20 @@ private:
B->appendMemberDtor(FD, cfg->getBumpVectorContext());
}
+ void appendObjCMessage(CFGBlock *B, ObjCMessageExpr *ME) {
+ if (alwaysAdd(ME) && cachedEntry)
+ cachedEntry->second = B;
+
+ if (const ConstructionContext *CC =
+ retrieveAndCleanupConstructionContext(ME)) {
+ B->appendCXXRecordTypedCall(ME, CC, cfg->getBumpVectorContext());
+ return;
+ }
+
+ B->appendStmt(const_cast<ObjCMessageExpr *>(ME),
+ cfg->getBumpVectorContext());
+ }
+
void appendTemporaryDtor(CFGBlock *B, CXXBindTemporaryExpr *E) {
B->appendTemporaryDtor(E, cfg->getBumpVectorContext());
}
@@ -1067,7 +1100,7 @@ private:
bool tryEvaluate(Expr *S, Expr::EvalResult &outResult) {
if (!BuildOpts.PruneTriviallyFalseEdges)
return false;
- return !S->isTypeDependent() &&
+ return !S->isTypeDependent() &&
!S->isValueDependent() &&
S->EvaluateAsRValue(outResult, *Context);
}
@@ -1183,18 +1216,18 @@ inline bool AddStmtChoice::alwaysAdd(CFGBuilder &builder,
bool CFGBuilder::alwaysAdd(const Stmt *stmt) {
bool shouldAdd = BuildOpts.alwaysAdd(stmt);
-
+
if (!BuildOpts.forcedBlkExprs)
return shouldAdd;
- if (lastLookup == stmt) {
+ if (lastLookup == stmt) {
if (cachedEntry) {
assert(cachedEntry->first == stmt);
return true;
}
return shouldAdd;
}
-
+
lastLookup = stmt;
// Perform the lookup!
@@ -1215,7 +1248,7 @@ bool CFGBuilder::alwaysAdd(const Stmt *stmt) {
cachedEntry = &*itr;
return true;
}
-
+
// FIXME: Add support for dependent-sized array types in C++?
// Does it even make sense to build a CFG for an uninstantiated template?
static const VariableArrayType *FindVA(const Type *t) {
@@ -1232,6 +1265,8 @@ static const VariableArrayType *FindVA(const Type *t) {
void CFGBuilder::consumeConstructionContext(
const ConstructionContextLayer *Layer, Expr *E) {
+ assert((isa<CXXConstructExpr>(E) || isa<CallExpr>(E) ||
+ isa<ObjCMessageExpr>(E)) && "Expression cannot construct an object!");
if (const ConstructionContextLayer *PreviouslyStoredLayer =
ConstructionContextMap.lookup(E)) {
(void)PreviouslyStoredLayer;
@@ -1252,8 +1287,8 @@ void CFGBuilder::findConstructionContexts(
if (!Child)
return;
- auto withExtraLayer = [this, Layer](Stmt *S) {
- return ConstructionContextLayer::create(cfg->getBumpVectorContext(), S,
+ auto withExtraLayer = [this, Layer](const ConstructionContextItem &Item) {
+ return ConstructionContextLayer::create(cfg->getBumpVectorContext(), Item,
Layer);
};
@@ -1275,10 +1310,11 @@ void CFGBuilder::findConstructionContexts(
case Stmt::CallExprClass:
case Stmt::CXXMemberCallExprClass:
case Stmt::CXXOperatorCallExprClass:
- case Stmt::UserDefinedLiteralClass: {
- auto *CE = cast<CallExpr>(Child);
- if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(CE, *Context))
- consumeConstructionContext(Layer, CE);
+ case Stmt::UserDefinedLiteralClass:
+ case Stmt::ObjCMessageExprClass: {
+ auto *E = cast<Expr>(Child);
+ if (CFGCXXRecordTypedCall::isCXXRecordTypedCall(E))
+ consumeConstructionContext(Layer, E);
break;
}
case Stmt::ExprWithCleanupsClass: {
@@ -1313,18 +1349,17 @@ void CFGBuilder::findConstructionContexts(
// it indicates the beginning of a temporary object construction context,
// so it shouldn't be found in the middle. However, if it is the beginning
// of an elidable copy or move construction context, we need to include it.
- if (const auto *CE =
- dyn_cast_or_null<CXXConstructExpr>(Layer->getTriggerStmt())) {
- if (CE->isElidable()) {
- auto *MTE = cast<MaterializeTemporaryExpr>(Child);
- findConstructionContexts(withExtraLayer(MTE), MTE->GetTemporaryExpr());
- }
+ if (Layer->getItem().getKind() ==
+ ConstructionContextItem::ElidableConstructorKind) {
+ auto *MTE = cast<MaterializeTemporaryExpr>(Child);
+ findConstructionContexts(withExtraLayer(MTE), MTE->GetTemporaryExpr());
}
break;
}
case Stmt::ConditionalOperatorClass: {
auto *CO = cast<ConditionalOperator>(Child);
- if (!dyn_cast_or_null<MaterializeTemporaryExpr>(Layer->getTriggerStmt())) {
+ if (Layer->getItem().getKind() !=
+ ConstructionContextItem::MaterializationKind) {
// If the object returned by the conditional operator is not going to be a
// temporary object that needs to be immediately materialized, then
// it must be C++17 with its mandatory copy elision. Do not yet promise
@@ -1427,7 +1462,7 @@ std::unique_ptr<CFG> CFGBuilder::buildCFG(const Decl *D, Stmt *Statement) {
// If there is no target block that contains label, then we are looking
// at an incomplete AST. Handle this by not registering a successor.
if (LI == LabelMap.end()) continue;
-
+
addSuccessor(B, LI->second.block);
}
@@ -1513,7 +1548,7 @@ CFGBlock *CFGBuilder::addInitializer(CXXCtorInitializer *I) {
return Block;
}
-/// Retrieve the type of the temporary object whose lifetime was
+/// Retrieve the type of the temporary object whose lifetime was
/// extended by a local reference with the given initializer.
static QualType getReferenceInitTemporaryType(const Expr *Init,
bool *FoundMTE = nullptr) {
@@ -1766,7 +1801,7 @@ LocalScope* CFGBuilder::createOrReuseLocalScope(LocalScope* Scope) {
}
/// addLocalScopeForStmt - Add LocalScope to local scopes tree for statement
-/// that should create implicit scope (e.g. if/else substatements).
+/// that should create implicit scope (e.g. if/else substatements).
void CFGBuilder::addLocalScopeForStmt(Stmt *S) {
if (!BuildOpts.AddImplicitDtors && !BuildOpts.AddLifetime &&
!BuildOpts.AddScopes)
@@ -2101,6 +2136,9 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc) {
case Stmt::ObjCForCollectionStmtClass:
return VisitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(S));
+ case Stmt::ObjCMessageExprClass:
+ return VisitObjCMessageExpr(cast<ObjCMessageExpr>(S), asc);
+
case Stmt::OpaqueValueExprClass:
return Block;
@@ -2383,12 +2421,7 @@ CFGBlock *CFGBuilder::VisitCallExpr(CallExpr *C, AddStmtChoice asc) {
if (!boundType.isNull()) calleeType = boundType;
}
- // FIXME: Once actually implemented, this construction context layer should
- // include the number of the argument as well.
- for (auto Arg: C->arguments()) {
- findConstructionContexts(
- ConstructionContextLayer::create(cfg->getBumpVectorContext(), C), Arg);
- }
+ findConstructionContextsForArguments(C);
// If this is a call to a no-return function, this stops the block here.
bool NoReturn = getFunctionExtInfo(*calleeType).getNoReturn();
@@ -2574,7 +2607,7 @@ CFGBlock *CFGBuilder::VisitConditionalOperator(AbstractConditionalOperator *C,
// At least one of this or the above will be run.
return addStmt(BCO->getCommon());
}
-
+
return addStmt(condExpr);
}
@@ -2583,7 +2616,7 @@ CFGBlock *CFGBuilder::VisitDeclStmt(DeclStmt *DS) {
// CFG entirely.
if (isa<LabelDecl>(*DS->decl_begin()))
return Block;
-
+
// This case also handles static_asserts.
if (DS->isSingleDecl())
return VisitDeclSubExpr(DS);
@@ -3032,7 +3065,7 @@ CFGBlock *CFGBuilder::VisitLambdaExpr(LambdaExpr *E, AddStmtChoice asc) {
}
return LastBlock;
}
-
+
CFGBlock *CFGBuilder::VisitGotoStmt(GotoStmt *G) {
// Goto is a control-flow statement. Thus we stop processing the current
// block and create a new one.
@@ -3146,7 +3179,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
else if (badCFG)
return nullptr;
}
-
+
// Because of short-circuit evaluation, the condition of the loop can span
// multiple basic blocks. Thus we need the "Entry" and "Exit" blocks that
// evaluate the condition.
@@ -3188,8 +3221,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
const DeclStmt *DS = F->getConditionVariableDeclStmt();
assert(DS->isSingleDecl());
findConstructionContexts(
- ConstructionContextLayer::create(cfg->getBumpVectorContext(),
- const_cast<DeclStmt *>(DS)),
+ ConstructionContextLayer::create(cfg->getBumpVectorContext(), DS),
Init);
appendStmt(Block, DS);
EntryConditionBlock = addStmt(Init);
@@ -3214,7 +3246,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
// Link up the loop-back block to the entry condition block.
addSuccessor(TransitionBlock, EntryConditionBlock);
-
+
// The condition block is the implicit successor for any code above the loop.
Succ = EntryConditionBlock;
@@ -3334,7 +3366,7 @@ CFGBlock *CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
CFGBlock *LoopBackBlock = nullptr;
Succ = LoopBackBlock = createBlock();
LoopBackBlock->setLoopTarget(S);
-
+
BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos);
ContinueJumpTarget = JumpTarget(Succ, ScopePos);
@@ -3401,7 +3433,7 @@ CFGBlock *CFGBuilder::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
// Add the PseudoObject as the last thing.
appendStmt(Block, E);
- CFGBlock *lastBlock = Block;
+ CFGBlock *lastBlock = Block;
// Before that, evaluate all of the semantics in order. In
// CFG-land, that means appending them in reverse order.
@@ -3580,6 +3612,16 @@ CFGBlock *CFGBuilder::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
return VisitStmt(S, AddStmtChoice::AlwaysAdd);
}
+CFGBlock *CFGBuilder::VisitObjCMessageExpr(ObjCMessageExpr *ME,
+ AddStmtChoice asc) {
+ findConstructionContextsForArguments(ME);
+
+ autoCreateBlock();
+ appendObjCMessage(Block, ME);
+
+ return VisitChildren(ME);
+}
+
CFGBlock *CFGBuilder::VisitCXXThrowExpr(CXXThrowExpr *T) {
// If we were in the middle of a block we stop processing that block.
if (badCFG)
@@ -3734,7 +3776,7 @@ CFGBlock *CFGBuilder::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E,
// VLA types have expressions that must be evaluated.
CFGBlock *lastBlock = Block;
-
+
if (E->isArgumentType()) {
for (const VariableArrayType *VA =FindVA(E->getArgumentType().getTypePtr());
VA != nullptr; VA = FindVA(VA->getElementType().getTypePtr()))
@@ -3863,7 +3905,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
return LastBlock;
}
-
+
static bool shouldAddCase(bool &switchExclusivelyCovered,
const Expr::EvalResult *switchCond,
const CaseStmt *CS,
@@ -3878,7 +3920,7 @@ static bool shouldAddCase(bool &switchExclusivelyCovered,
// Evaluate the LHS of the case value.
const llvm::APSInt &lhsInt = CS->getLHS()->EvaluateKnownConstInt(Ctx);
const llvm::APSInt &condInt = switchCond->Val.getInt();
-
+
if (condInt == lhsInt) {
addCase = true;
switchExclusivelyCovered = true;
@@ -3897,7 +3939,7 @@ static bool shouldAddCase(bool &switchExclusivelyCovered,
else
addCase = true;
}
- return addCase;
+ return addCase;
}
CFGBlock *CFGBuilder::VisitCaseStmt(CaseStmt *CS) {
@@ -4069,7 +4111,7 @@ CFGBlock *CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt *CS) {
CFGBlock *CatchBlock = Block;
if (!CatchBlock)
CatchBlock = createBlock();
-
+
// CXXCatchStmt is more than just a label. They have semantic meaning
// as well, as they implicitly "initialize" the catch variable. Add
// it to the CFG as a CFGElement so that the control-flow of these
@@ -4244,6 +4286,11 @@ CFGBlock *CFGBuilder::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E,
CFGBlock *CFGBuilder::VisitCXXConstructExpr(CXXConstructExpr *C,
AddStmtChoice asc) {
+ // If the constructor takes objects as arguments by value, we need to properly
+ // construct these objects. Construction contexts we find here aren't for the
+ // constructor C, they're for its arguments only.
+ findConstructionContextsForArguments(C);
+
autoCreateBlock();
appendConstructor(Block, C);
@@ -4624,7 +4671,7 @@ CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
const RecordType *recordType = ty->getAs<RecordType>();
const CXXRecordDecl *classDecl =
cast<CXXRecordDecl>(recordType->getDecl());
- return classDecl->getDestructor();
+ return classDecl->getDestructor();
}
case CFGElement::DeleteDtor: {
const CXXDeleteExpr *DE = castAs<CFGDeleteDtor>().getDeleteExpr();
@@ -4722,7 +4769,7 @@ public:
for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I ) {
unsigned j = 1;
for (CFGBlock::const_iterator BI = (*I)->begin(), BEnd = (*I)->end() ;
- BI != BEnd; ++BI, ++j ) {
+ BI != BEnd; ++BI, ++j ) {
if (Optional<CFGStmt> SE = BI->getAs<CFGStmt>()) {
const Stmt *stmt= SE->getStmt();
std::pair<unsigned, unsigned> P((*I)->getBlockID(), j);
@@ -4961,7 +5008,7 @@ static void print_construction_context(raw_ostream &OS,
OS << ", ";
const auto *SICC = cast<SimpleConstructorInitializerConstructionContext>(CC);
print_initializer(OS, Helper, SICC->getCXXCtorInitializer());
- break;
+ return;
}
case ConstructionContext::CXX17ElidedCopyConstructorInitializerKind: {
OS << ", ";
@@ -5012,6 +5059,17 @@ static void print_construction_context(raw_ostream &OS,
Stmts.push_back(TOCC->getConstructorAfterElision());
break;
}
+ case ConstructionContext::ArgumentKind: {
+ const auto *ACC = cast<ArgumentConstructionContext>(CC);
+ if (const Stmt *BTE = ACC->getCXXBindTemporaryExpr()) {
+ OS << ", ";
+ Helper.handledStmt(const_cast<Stmt *>(BTE), OS);
+ }
+ OS << ", ";
+ Helper.handledStmt(const_cast<Expr *>(ACC->getCallLikeExpr()), OS);
+ OS << "+" << ACC->getIndex();
+ return;
+ }
}
for (auto I: Stmts)
if (I) {
@@ -5151,7 +5209,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
// Print the header.
if (ShowColors)
OS.changeColor(raw_ostream::YELLOW, true);
-
+
OS << "\n [B" << B.getBlockID();
if (&B == &cfg->getEntry())
@@ -5164,7 +5222,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
OS << " (NORETURN)]\n";
else
OS << "]\n";
-
+
if (ShowColors)
OS.resetColor();
@@ -5235,7 +5293,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
CFGBlockTerminatorPrint TPrinter(OS, &Helper, PP);
TPrinter.print(B.getTerminator());
OS << '\n';
-
+
if (ShowColors)
OS.resetColor();
}
@@ -5254,7 +5312,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
if (ShowColors)
OS.changeColor(Color);
-
+
for (CFGBlock::const_pred_iterator I = B.pred_begin(), E = B.pred_end();
I != E; ++I, ++i) {
if (i % 10 == 8)
@@ -5271,7 +5329,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
if (!Reachable)
OS << "(Unreachable)";
}
-
+
if (ShowColors)
OS.resetColor();
diff --git a/lib/Analysis/CFGReachabilityAnalysis.cpp b/lib/Analysis/CFGReachabilityAnalysis.cpp
index 6f557e092fd7..cdad5b57aee8 100644
--- a/lib/Analysis/CFGReachabilityAnalysis.cpp
+++ b/lib/Analysis/CFGReachabilityAnalysis.cpp
@@ -27,13 +27,13 @@ CFGReverseBlockReachabilityAnalysis::CFGReverseBlockReachabilityAnalysis(
bool CFGReverseBlockReachabilityAnalysis::isReachable(const CFGBlock *Src,
const CFGBlock *Dst) {
const unsigned DstBlockID = Dst->getBlockID();
-
+
// If we haven't analyzed the destination node, run the analysis now
if (!analyzed[DstBlockID]) {
mapReachability(Dst);
analyzed[DstBlockID] = true;
}
-
+
// Return the cached result
return reachable[DstBlockID][Src->getBlockID()];
}
@@ -43,10 +43,10 @@ bool CFGReverseBlockReachabilityAnalysis::isReachable(const CFGBlock *Src,
void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {
SmallVector<const CFGBlock *, 11> worklist;
llvm::BitVector visited(analyzed.size());
-
+
ReachableSet &DstReachability = reachable[Dst->getBlockID()];
DstReachability.resize(analyzed.size(), false);
-
+
// Start searching from the destination node, since we commonly will perform
// multiple queries relating to a destination node.
worklist.push_back(Dst);
@@ -58,7 +58,7 @@ void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {
if (visited[block->getBlockID()])
continue;
visited[block->getBlockID()] = true;
-
+
// Update reachability information for this node -> Dst
if (!firstRun) {
// Don't insert Dst -> Dst unless it was a predecessor of itself
@@ -66,9 +66,9 @@ void CFGReverseBlockReachabilityAnalysis::mapReachability(const CFGBlock *Dst) {
}
else
firstRun = false;
-
+
// Add the predecessors to the worklist.
- for (CFGBlock::const_pred_iterator i = block->pred_begin(),
+ for (CFGBlock::const_pred_iterator i = block->pred_begin(),
e = block->pred_end(); i != e; ++i) {
if (*i)
worklist.push_back(*i);
diff --git a/lib/Analysis/CFGStmtMap.cpp b/lib/Analysis/CFGStmtMap.cpp
index 19b80191f7a7..3eed0d52f848 100644
--- a/lib/Analysis/CFGStmtMap.cpp
+++ b/lib/Analysis/CFGStmtMap.cpp
@@ -24,7 +24,7 @@ static SMap *AsMap(void *m) { return (SMap*) m; }
CFGStmtMap::~CFGStmtMap() { delete AsMap(M); }
-CFGBlock *CFGStmtMap::getBlock(Stmt *S) {
+CFGBlock *CFGStmtMap::getBlock(Stmt *S) {
SMap *SM = AsMap(M);
Stmt *X = S;
@@ -53,17 +53,17 @@ static void Accumulate(SMap &SM, CFGBlock *B) {
Optional<CFGStmt> CS = CE.getAs<CFGStmt>();
if (!CS)
continue;
-
+
CFGBlock *&Entry = SM[CS->getStmt()];
// If 'Entry' is already initialized (e.g., a terminator was already),
// skip.
if (Entry)
continue;
-
+
Entry = B;
-
+
}
-
+
// Look at the label of the block.
if (Stmt *Label = B->getLabel())
SM[Label] = B;
@@ -82,7 +82,7 @@ CFGStmtMap *CFGStmtMap::Build(CFG *C, ParentMap *PM) {
SMap *SM = new SMap();
// Walk all blocks, accumulating the block-level expressions, labels,
- // and terminators.
+ // and terminators.
for (CFG::iterator I = C->begin(), E = C->end(); I != E; ++I)
Accumulate(*SM, *I);
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index fb6d7e87a9a3..bac00680ffda 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -84,7 +84,7 @@ public:
void VisitObjCMessageExpr(ObjCMessageExpr *ME) {
if (ObjCInterfaceDecl *IDecl = ME->getReceiverInterface()) {
Selector Sel = ME->getSelector();
-
+
// Find the callee definition within the same translation unit.
Decl *D = nullptr;
if (ME->isInstanceMessage())
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp
index 4d57623e2161..b2d416c171a1 100644
--- a/lib/Analysis/CocoaConventions.cpp
+++ b/lib/Analysis/CocoaConventions.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements cocoa naming convention analysis.
+// This file implements cocoa naming convention analysis.
//
//===----------------------------------------------------------------------===//
@@ -34,15 +34,15 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
return false;
RetTy = TD->getDecl()->getUnderlyingType();
}
-
+
if (Name.empty())
return false;
-
+
// Is the type void*?
const PointerType* PT = RetTy->getAs<PointerType>();
if (!(PT->getPointeeType().getUnqualifiedType()->isVoidType()))
return false;
-
+
// Does the name start with the prefix?
return Name.startswith(Prefix);
}
@@ -66,32 +66,32 @@ bool coreFoundation::isCFObjectRef(QualType T) {
bool cocoa::isCocoaObjectRef(QualType Ty) {
if (!Ty->isObjCObjectPointerType())
return false;
-
+
const ObjCObjectPointerType *PT = Ty->getAs<ObjCObjectPointerType>();
-
+
// Can be true for objects with the 'NSObject' attribute.
if (!PT)
return true;
-
+
// We assume that id<..>, id, Class, and Class<..> all represent tracked
// objects.
if (PT->isObjCIdType() || PT->isObjCQualifiedIdType() ||
PT->isObjCClassType() || PT->isObjCQualifiedClassType())
return true;
-
+
// 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->hasDefinition())
return true;
-
+
for ( ; ID ; ID = ID->getSuperClass())
if (ID->getIdentifier()->getName() == "NSObject")
return true;
-
+
return false;
}
@@ -101,11 +101,11 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
const IdentifierInfo *ident = fn->getIdentifier();
if (!ident) return false;
StringRef functionName = ident->getName();
-
+
StringRef::iterator it = functionName.begin();
StringRef::iterator start = it;
StringRef::iterator endI = functionName.end();
-
+
while (true) {
// Scan for the start of 'create' or 'copy'.
for ( ; it != endI ; ++it) {
@@ -124,7 +124,7 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// Did we hit the end of the string? If so, we didn't find a match.
if (it == endI)
return false;
-
+
// Scan for *lowercase* 'reate' or 'opy', followed by no lowercase
// character.
StringRef suffix = functionName.substr(it - start);
@@ -137,10 +137,10 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// Keep scanning.
continue;
}
-
+
if (it == endI || !isLowercase(*it))
return true;
-
+
// If we matched a lowercase character, it isn't the end of the
// word. Keep scanning.
}
diff --git a/lib/Analysis/ConstructionContext.cpp b/lib/Analysis/ConstructionContext.cpp
index ed1e63243217..8169d4a93a6d 100644
--- a/lib/Analysis/ConstructionContext.cpp
+++ b/lib/Analysis/ConstructionContext.cpp
@@ -15,15 +15,17 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/ConstructionContext.h"
+#include "clang/AST/ExprObjC.h"
using namespace clang;
const ConstructionContextLayer *
-ConstructionContextLayer::create(BumpVectorContext &C, TriggerTy Trigger,
+ConstructionContextLayer::create(BumpVectorContext &C,
+ const ConstructionContextItem &Item,
const ConstructionContextLayer *Parent) {
ConstructionContextLayer *CC =
C.getAllocator().Allocate<ConstructionContextLayer>();
- return new (CC) ConstructionContextLayer(Trigger, Parent);
+ return new (CC) ConstructionContextLayer(Item, Parent);
}
bool ConstructionContextLayer::isStrictlyMoreSpecificThan(
@@ -32,7 +34,7 @@ bool ConstructionContextLayer::isStrictlyMoreSpecificThan(
while (true) {
if (!Other)
return Self;
- if (!Self || !Self->isSameLayer(Other))
+ if (!Self || !(Self->Item == Other->Item))
return false;
Self = Self->getParent();
Other = Other->getParent();
@@ -40,145 +42,176 @@ bool ConstructionContextLayer::isStrictlyMoreSpecificThan(
llvm_unreachable("The above loop can only be terminated via return!");
}
+const ConstructionContext *
+ConstructionContext::createMaterializedTemporaryFromLayers(
+ BumpVectorContext &C, const MaterializeTemporaryExpr *MTE,
+ const CXXBindTemporaryExpr *BTE,
+ const ConstructionContextLayer *ParentLayer) {
+ assert(MTE);
+
+ // If the object requires destruction and is not lifetime-extended,
+ // then it must have a BTE within its MTE, otherwise it shouldn't.
+ // FIXME: This should be an assertion.
+ if (!BTE && !(MTE->getType().getCanonicalType()->getAsCXXRecordDecl()
+ ->hasTrivialDestructor() ||
+ MTE->getStorageDuration() != SD_FullExpression)) {
+ return nullptr;
+ }
+
+ // If the temporary is lifetime-extended, don't save the BTE,
+ // because we don't need a temporary destructor, but an automatic
+ // destructor.
+ if (MTE->getStorageDuration() != SD_FullExpression) {
+ BTE = nullptr;
+ }
+
+ // Handle pre-C++17 copy and move elision.
+ const CXXConstructExpr *ElidedCE = nullptr;
+ const ConstructionContext *ElidedCC = nullptr;
+ if (ParentLayer) {
+ const ConstructionContextItem &ElidedItem = ParentLayer->getItem();
+ assert(ElidedItem.getKind() ==
+ ConstructionContextItem::ElidableConstructorKind);
+ ElidedCE = cast<CXXConstructExpr>(ElidedItem.getStmt());
+ assert(ElidedCE->isElidable());
+ // We're creating a construction context that might have already
+ // been created elsewhere. Maybe we should unique our construction
+ // contexts. That's what we often do, but in this case it's unlikely
+ // to bring any benefits.
+ ElidedCC = createFromLayers(C, ParentLayer->getParent());
+ if (!ElidedCC) {
+ // We may fail to create the elided construction context.
+ // In this case, skip copy elision entirely.
+ return create<SimpleTemporaryObjectConstructionContext>(C, BTE, MTE);
+ }
+ return create<ElidedTemporaryObjectConstructionContext>(
+ C, BTE, MTE, ElidedCE, ElidedCC);
+ }
+
+ // This is a normal temporary.
+ assert(!ParentLayer);
+ return create<SimpleTemporaryObjectConstructionContext>(C, BTE, MTE);
+}
+
+const ConstructionContext *ConstructionContext::createBoundTemporaryFromLayers(
+ BumpVectorContext &C, const CXXBindTemporaryExpr *BTE,
+ const ConstructionContextLayer *ParentLayer) {
+ if (!ParentLayer) {
+ // A temporary object that doesn't require materialization.
+ // In particular, it shouldn't require copy elision, because
+ // copy/move constructors take a reference, which requires
+ // materialization to obtain the glvalue.
+ return create<SimpleTemporaryObjectConstructionContext>(C, BTE,
+ /*MTE=*/nullptr);
+ }
+
+ const ConstructionContextItem &ParentItem = ParentLayer->getItem();
+ switch (ParentItem.getKind()) {
+ case ConstructionContextItem::VariableKind: {
+ const auto *DS = cast<DeclStmt>(ParentItem.getStmt());
+ assert(!cast<VarDecl>(DS->getSingleDecl())->getType().getCanonicalType()
+ ->getAsCXXRecordDecl()->hasTrivialDestructor());
+ return create<CXX17ElidedCopyVariableConstructionContext>(C, DS, BTE);
+ }
+ case ConstructionContextItem::NewAllocatorKind: {
+ llvm_unreachable("This context does not accept a bound temporary!");
+ }
+ case ConstructionContextItem::ReturnKind: {
+ assert(ParentLayer->isLast());
+ const auto *RS = cast<ReturnStmt>(ParentItem.getStmt());
+ assert(!RS->getRetValue()->getType().getCanonicalType()
+ ->getAsCXXRecordDecl()->hasTrivialDestructor());
+ return create<CXX17ElidedCopyReturnedValueConstructionContext>(C, RS,
+ BTE);
+ }
+
+ case ConstructionContextItem::MaterializationKind: {
+ // No assert. We may have an elidable copy on the grandparent layer.
+ const auto *MTE = cast<MaterializeTemporaryExpr>(ParentItem.getStmt());
+ return createMaterializedTemporaryFromLayers(C, MTE, BTE,
+ ParentLayer->getParent());
+ }
+ case ConstructionContextItem::TemporaryDestructorKind: {
+ llvm_unreachable("Duplicate CXXBindTemporaryExpr in the AST!");
+ }
+ case ConstructionContextItem::ElidedDestructorKind: {
+ llvm_unreachable("Elided destructor items are not produced by the CFG!");
+ }
+ case ConstructionContextItem::ElidableConstructorKind: {
+ llvm_unreachable("Materialization is necessary to put temporary into a "
+ "copy or move constructor!");
+ }
+ case ConstructionContextItem::ArgumentKind: {
+ assert(ParentLayer->isLast());
+ const auto *E = cast<Expr>(ParentItem.getStmt());
+ assert(isa<CallExpr>(E) || isa<CXXConstructExpr>(E) ||
+ isa<ObjCMessageExpr>(E));
+ return create<ArgumentConstructionContext>(C, E, ParentItem.getIndex(),
+ BTE);
+ }
+ case ConstructionContextItem::InitializerKind: {
+ assert(ParentLayer->isLast());
+ const auto *I = ParentItem.getCXXCtorInitializer();
+ assert(!I->getAnyMember()->getType().getCanonicalType()
+ ->getAsCXXRecordDecl()->hasTrivialDestructor());
+ return create<CXX17ElidedCopyConstructorInitializerConstructionContext>(
+ C, I, BTE);
+ }
+ } // switch (ParentItem.getKind())
+
+ llvm_unreachable("Unexpected construction context with destructor!");
+}
+
const ConstructionContext *ConstructionContext::createFromLayers(
BumpVectorContext &C, const ConstructionContextLayer *TopLayer) {
// Before this point all we've had was a stockpile of arbitrary layers.
// Now validate that it is shaped as one of the finite amount of expected
// patterns.
- if (const Stmt *S = TopLayer->getTriggerStmt()) {
- if (const auto *DS = dyn_cast<DeclStmt>(S)) {
- assert(TopLayer->isLast());
- return create<SimpleVariableConstructionContext>(C, DS);
- }
- if (const auto *NE = dyn_cast<CXXNewExpr>(S)) {
- assert(TopLayer->isLast());
- return create<NewAllocatedObjectConstructionContext>(C, NE);
- }
- if (const auto *BTE = dyn_cast<CXXBindTemporaryExpr>(S)) {
- const MaterializeTemporaryExpr *MTE = nullptr;
- assert(BTE->getType().getCanonicalType()
- ->getAsCXXRecordDecl()->hasNonTrivialDestructor());
- // For temporaries with destructors, there may or may not be
- // lifetime extension on the parent layer.
- if (const ConstructionContextLayer *ParentLayer = TopLayer->getParent()) {
- // C++17 *requires* elision of the constructor at the return site
- // and at variable/member initialization site, while previous standards
- // were allowing an optional elidable constructor.
- // This is the C++17 copy-elided construction into a ctor initializer.
- if (const CXXCtorInitializer *I = ParentLayer->getTriggerInit()) {
- return create<
- CXX17ElidedCopyConstructorInitializerConstructionContext>(C,
- I, BTE);
- }
- assert(ParentLayer->getTriggerStmt() &&
- "Non-statement-based layers have been handled above!");
- // This is the normal, non-C++17 case: a temporary object which has
- // both destruction and materialization info attached to it in the AST.
- if ((MTE = dyn_cast<MaterializeTemporaryExpr>(
- ParentLayer->getTriggerStmt()))) {
- if (MTE->getStorageDuration() != SD_FullExpression) {
- // If the temporary is lifetime-extended, don't save the BTE,
- // because we don't need a temporary destructor, but an automatic
- // destructor.
- BTE = nullptr;
- }
-
- // Handle pre-C++17 copy and move elision.
- const CXXConstructExpr *ElidedCE = nullptr;
- const ConstructionContext *ElidedCC = nullptr;
- if (const ConstructionContextLayer *ElidedLayer =
- ParentLayer->getParent()) {
- ElidedCE = cast<CXXConstructExpr>(ElidedLayer->getTriggerStmt());
- assert(ElidedCE->isElidable());
- // We're creating a construction context that might have already
- // been created elsewhere. Maybe we should unique our construction
- // contexts. That's what we often do, but in this case it's unlikely
- // to bring any benefits.
- ElidedCC = createFromLayers(C, ElidedLayer->getParent());
- if (!ElidedCC) {
- // We may fail to create the elided construction context.
- // In this case, skip copy elision entirely.
- return create<SimpleTemporaryObjectConstructionContext>(C, BTE,
- MTE);
- } else {
- return create<ElidedTemporaryObjectConstructionContext>(
- C, BTE, MTE, ElidedCE, ElidedCC);
- }
- }
- assert(ParentLayer->isLast());
- return create<SimpleTemporaryObjectConstructionContext>(C, BTE, MTE);
- }
- assert(ParentLayer->isLast());
-
- // This is a constructor into a function argument. Not implemented yet.
- if (isa<CallExpr>(ParentLayer->getTriggerStmt()))
- return nullptr;
- // This is C++17 copy-elided construction into return statement.
- if (auto *RS = dyn_cast<ReturnStmt>(ParentLayer->getTriggerStmt())) {
- assert(!RS->getRetValue()->getType().getCanonicalType()
- ->getAsCXXRecordDecl()->hasTrivialDestructor());
- return create<CXX17ElidedCopyReturnedValueConstructionContext>(C,
- RS, BTE);
- }
- // This is C++17 copy-elided construction into a simple variable.
- if (auto *DS = dyn_cast<DeclStmt>(ParentLayer->getTriggerStmt())) {
- assert(!cast<VarDecl>(DS->getSingleDecl())->getType()
- .getCanonicalType()->getAsCXXRecordDecl()
- ->hasTrivialDestructor());
- return create<CXX17ElidedCopyVariableConstructionContext>(C, DS, BTE);
- }
- llvm_unreachable("Unexpected construction context with destructor!");
- }
- // A temporary object that doesn't require materialization.
- // In particular, it shouldn't require copy elision, because
- // copy/move constructors take a reference, which requires
- // materialization to obtain the glvalue.
- return create<SimpleTemporaryObjectConstructionContext>(C, BTE,
- /*MTE=*/nullptr);
- }
- if (const auto *MTE = dyn_cast<MaterializeTemporaryExpr>(S)) {
- // If the object requires destruction and is not lifetime-extended,
- // then it must have a BTE within its MTE.
- // FIXME: This should be an assertion.
- if (!(MTE->getType().getCanonicalType()
- ->getAsCXXRecordDecl()->hasTrivialDestructor() ||
- MTE->getStorageDuration() != SD_FullExpression))
- return nullptr;
-
- // Handle pre-C++17 copy and move elision.
- const CXXConstructExpr *ElidedCE = nullptr;
- const ConstructionContext *ElidedCC = nullptr;
- if (const ConstructionContextLayer *ElidedLayer = TopLayer->getParent()) {
- ElidedCE = cast<CXXConstructExpr>(ElidedLayer->getTriggerStmt());
- assert(ElidedCE->isElidable());
- // We're creating a construction context that might have already
- // been created elsewhere. Maybe we should unique our construction
- // contexts. That's what we often do, but in this case it's unlikely
- // to bring any benefits.
- ElidedCC = createFromLayers(C, ElidedLayer->getParent());
- if (!ElidedCC) {
- // We may fail to create the elided construction context.
- // In this case, skip copy elision entirely.
- return create<SimpleTemporaryObjectConstructionContext>(C, nullptr,
- MTE);
- }
- return create<ElidedTemporaryObjectConstructionContext>(
- C, nullptr, MTE, ElidedCE, ElidedCC);
- }
- assert(TopLayer->isLast());
- return create<SimpleTemporaryObjectConstructionContext>(C, nullptr, MTE);
- }
- if (const auto *RS = dyn_cast<ReturnStmt>(S)) {
- assert(TopLayer->isLast());
- return create<SimpleReturnedValueConstructionContext>(C, RS);
- }
- // This is a constructor into a function argument. Not implemented yet.
- if (isa<CallExpr>(TopLayer->getTriggerStmt()))
- return nullptr;
- llvm_unreachable("Unexpected construction context with statement!");
- } else if (const CXXCtorInitializer *I = TopLayer->getTriggerInit()) {
+ const ConstructionContextItem &TopItem = TopLayer->getItem();
+ switch (TopItem.getKind()) {
+ case ConstructionContextItem::VariableKind: {
+ assert(TopLayer->isLast());
+ const auto *DS = cast<DeclStmt>(TopItem.getStmt());
+ return create<SimpleVariableConstructionContext>(C, DS);
+ }
+ case ConstructionContextItem::NewAllocatorKind: {
+ assert(TopLayer->isLast());
+ const auto *NE = cast<CXXNewExpr>(TopItem.getStmt());
+ return create<NewAllocatedObjectConstructionContext>(C, NE);
+ }
+ case ConstructionContextItem::ReturnKind: {
assert(TopLayer->isLast());
+ const auto *RS = cast<ReturnStmt>(TopItem.getStmt());
+ return create<SimpleReturnedValueConstructionContext>(C, RS);
+ }
+ case ConstructionContextItem::MaterializationKind: {
+ const auto *MTE = cast<MaterializeTemporaryExpr>(TopItem.getStmt());
+ return createMaterializedTemporaryFromLayers(C, MTE, /*BTE=*/nullptr,
+ TopLayer->getParent());
+ }
+ case ConstructionContextItem::TemporaryDestructorKind: {
+ const auto *BTE = cast<CXXBindTemporaryExpr>(TopItem.getStmt());
+ assert(BTE->getType().getCanonicalType()->getAsCXXRecordDecl()
+ ->hasNonTrivialDestructor());
+ return createBoundTemporaryFromLayers(C, BTE, TopLayer->getParent());
+ }
+ case ConstructionContextItem::ElidedDestructorKind: {
+ llvm_unreachable("Elided destructor items are not produced by the CFG!");
+ }
+ case ConstructionContextItem::ElidableConstructorKind: {
+ llvm_unreachable("The argument needs to be materialized first!");
+ }
+ case ConstructionContextItem::InitializerKind: {
+ assert(TopLayer->isLast());
+ const CXXCtorInitializer *I = TopItem.getCXXCtorInitializer();
return create<SimpleConstructorInitializerConstructionContext>(C, I);
}
+ case ConstructionContextItem::ArgumentKind: {
+ assert(TopLayer->isLast());
+ const auto *E = cast<Expr>(TopItem.getStmt());
+ return create<ArgumentConstructionContext>(C, E, TopItem.getIndex(),
+ /*BTE=*/nullptr);
+ }
+ } // switch (TopItem.getKind())
llvm_unreachable("Unexpected construction context!");
}
diff --git a/lib/Analysis/Consumed.cpp b/lib/Analysis/Consumed.cpp
index a46386e2d13d..bc81a71b3d91 100644
--- a/lib/Analysis/Consumed.cpp
+++ b/lib/Analysis/Consumed.cpp
@@ -40,7 +40,7 @@
// TODO: Adjust states of args to constructors in the same way that arguments to
// function calls are handled.
// TODO: Use information from tests in for- and while-loop conditional.
-// TODO: Add notes about the actual and expected state for
+// TODO: Add notes about the actual and expected state for
// TODO: Correctly identify unreachable blocks when chaining boolean operators.
// TODO: Adjust the parser and AttributesList class to support lists of
// identifiers.
@@ -124,30 +124,30 @@ static bool isCallableInState(const CallableWhenAttr *CWAttr,
case CallableWhenAttr::Unknown:
MappedAttrState = CS_Unknown;
break;
-
+
case CallableWhenAttr::Unconsumed:
MappedAttrState = CS_Unconsumed;
break;
-
+
case CallableWhenAttr::Consumed:
MappedAttrState = CS_Consumed;
break;
}
-
+
if (MappedAttrState == State)
return true;
}
-
+
return false;
}
static bool isConsumableType(const QualType &QT) {
if (QT->isPointerType() || QT->isReferenceType())
return false;
-
+
if (const CXXRecordDecl *RD = QT->getAsCXXRecordDecl())
return RD->hasAttr<ConsumableAttr>();
-
+
return false;
}
@@ -250,13 +250,13 @@ static StringRef stateToString(ConsumedState State) {
switch (State) {
case consumed::CS_None:
return "none";
-
+
case consumed::CS_Unknown:
return "unknown";
-
+
case consumed::CS_Unconsumed:
return "unconsumed";
-
+
case consumed::CS_Consumed:
return "consumed";
}
@@ -307,7 +307,7 @@ class PropagationInfo {
VarTestResult LTest;
VarTestResult RTest;
};
-
+
union {
ConsumedState State;
VarTestResult VarTest;
@@ -315,7 +315,7 @@ class PropagationInfo {
const CXXBindTemporaryExpr *Tmp;
BinTestTy BinTest;
};
-
+
public:
PropagationInfo() = default;
PropagationInfo(const VarTestResult &VarTest)
@@ -326,7 +326,7 @@ public:
VarTest.Var = Var;
VarTest.TestsFor = TestsFor;
}
-
+
PropagationInfo(const BinaryOperator *Source, EffectiveOp EOp,
const VarTestResult &LTest, const VarTestResult &RTest)
: InfoType(IT_BinTest) {
@@ -335,7 +335,7 @@ public:
BinTest.LTest = LTest;
BinTest.RTest = RTest;
}
-
+
PropagationInfo(const BinaryOperator *Source, EffectiveOp EOp,
const VarDecl *LVar, ConsumedState LTestsFor,
const VarDecl *RVar, ConsumedState RTestsFor)
@@ -347,46 +347,46 @@ public:
BinTest.RTest.Var = RVar;
BinTest.RTest.TestsFor = RTestsFor;
}
-
+
PropagationInfo(ConsumedState State)
: InfoType(IT_State), State(State) {}
PropagationInfo(const VarDecl *Var) : InfoType(IT_Var), Var(Var) {}
PropagationInfo(const CXXBindTemporaryExpr *Tmp)
: InfoType(IT_Tmp), Tmp(Tmp) {}
-
+
const ConsumedState &getState() const {
assert(InfoType == IT_State);
return State;
}
-
+
const VarTestResult &getVarTest() const {
asser