diff options
Diffstat (limited to 'lib/ARCMigrate')
22 files changed, 126 insertions, 134 deletions
diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 6da87903a4888..568e06f21fba6 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -1,9 +1,8 @@ //===--- ARCMT.cpp - Migration to ARC mode --------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -36,10 +35,10 @@ bool CapturedDiagList::clearDiagnostic(ArrayRef<unsigned> IDs, while (I != List.end()) { FullSourceLoc diagLoc = I->getLocation(); if ((IDs.empty() || // empty means clear all diagnostics in the range. - std::find(IDs.begin(), IDs.end(), I->getID()) != IDs.end()) && + llvm::is_contained(IDs, I->getID())) && !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && (diagLoc == range.getEnd() || - diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { + diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { cleared = true; ListTy::iterator eraseS = I++; if (eraseS->getLevel() != DiagnosticsEngine::Note) @@ -65,10 +64,10 @@ bool CapturedDiagList::hasDiagnostic(ArrayRef<unsigned> IDs, while (I != List.end()) { FullSourceLoc diagLoc = I->getLocation(); if ((IDs.empty() || // empty means any diagnostic in the range. - std::find(IDs.begin(), IDs.end(), I->getID()) != IDs.end()) && + llvm::find(IDs, I->getID()) != IDs.end()) && !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && (diagLoc == range.getEnd() || - diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { + diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { return true; } @@ -515,7 +514,7 @@ MigrationProcess::MigrationProcess( IntrusiveRefCntPtr<DiagnosticsEngine> Diags( new DiagnosticsEngine(DiagID, &CI.getDiagnosticOpts(), DiagClient, /*ShouldOwnClient=*/false)); - Remapper.initFromDisk(outputDir, *Diags, /*ignoreIfFilesChanges=*/true); + Remapper.initFromDisk(outputDir, *Diags, /*ignoreIfFilesChanged=*/true); } } diff --git a/lib/ARCMigrate/ARCMTActions.cpp b/lib/ARCMigrate/ARCMTActions.cpp index 0a5473ab19ecd..d72f53806e37b 100644 --- a/lib/ARCMigrate/ARCMTActions.cpp +++ b/lib/ARCMigrate/ARCMTActions.cpp @@ -1,9 +1,8 @@ //===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/lib/ARCMigrate/FileRemapper.cpp b/lib/ARCMigrate/FileRemapper.cpp index 225f47119b00a..1a4862d09aa6c 100644 --- a/lib/ARCMigrate/FileRemapper.cpp +++ b/lib/ARCMigrate/FileRemapper.cpp @@ -1,9 +1,8 @@ //===--- FileRemapper.cpp - File Remapping Helper -------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/lib/ARCMigrate/Internals.h b/lib/ARCMigrate/Internals.h index 1a261c1e31aa3..47fc093175008 100644 --- a/lib/ARCMigrate/Internals.h +++ b/lib/ARCMigrate/Internals.h @@ -1,9 +1,8 @@ //===-- Internals.h - Implementation Details---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 6950ce0e12f31..7126a0873ea0c 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -1,13 +1,13 @@ //===--- ObjCMT.cpp - ObjC Migrate Tool -----------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "Transforms.h" +#include "clang/Analysis/RetainSummaryManager.h" #include "clang/ARCMigrate/ARCMT.h" #include "clang/ARCMigrate/ARCMTActions.h" #include "clang/AST/ASTConsumer.h" @@ -27,7 +27,6 @@ #include "clang/Lex/PPConditionalDirectiveRecord.h" #include "clang/Lex/Preprocessor.h" #include "clang/Rewrite/Core/Rewriter.h" -#include "clang/StaticAnalyzer/Core/RetainSummaryManager.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/Path.h" @@ -65,9 +64,11 @@ class ObjCMigrateASTConsumer : public ASTConsumer { ObjCInstanceTypeFamily OIT_Family = OIT_None); void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl); - void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE, + void AddCFAnnotations(ASTContext &Ctx, + const RetainSummary *RS, const FunctionDecl *FuncDecl, bool ResultAnnotated); - void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE, + void AddCFAnnotations(ASTContext &Ctx, + const RetainSummary *RS, const ObjCMethodDecl *MethodDecl, bool ResultAnnotated); void AnnotateImplicitBridging(ASTContext &Ctx); @@ -85,6 +86,8 @@ class ObjCMigrateASTConsumer : public ASTConsumer { bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc); + std::unique_ptr<RetainSummaryManager> Summaries; + public: std::string MigrateDir; unsigned ASTMigrateActions; @@ -103,6 +106,14 @@ public: llvm::SmallVector<const Decl *, 8> CFFunctionIBCandidates; llvm::StringSet<> WhiteListFilenames; + RetainSummaryManager &getSummaryManager(ASTContext &Ctx) { + if (!Summaries) + Summaries.reset(new RetainSummaryManager(Ctx, + /*TrackNSCFObjects=*/true, + /*trackOSObjects=*/false)); + return *Summaries; + } + ObjCMigrateASTConsumer(StringRef migrateDir, unsigned astMigrateActions, FileRemapper &remapper, @@ -205,7 +216,7 @@ ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) { Remapper.initFromDisk(MigrateDir, CI.getDiagnostics(), - /*ignoreIfFilesChanges=*/true); + /*ignoreIfFilesChanged=*/true); CompInst = &CI; CI.getDiagnostics().setIgnoreAllWarnings(true); return true; @@ -1453,12 +1464,12 @@ void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *De } void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, - const CallEffects &CE, + const RetainSummary *RS, const FunctionDecl *FuncDecl, bool ResultAnnotated) { // Annotate function. if (!ResultAnnotated) { - RetEffect Ret = CE.getReturnValue(); + RetEffect Ret = RS->getRetEffect(); const char *AnnotationString = nullptr; if (Ret.getObjKind() == ObjKind::CF) { if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) @@ -1478,12 +1489,11 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, Editor->commit(commit); } } - ArrayRef<ArgEffect> AEArgs = CE.getArgs(); unsigned i = 0; for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; - ArgEffect AE = AEArgs[i]; + ArgEffect AE = RS->getArg(i); if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF && !pd->hasAttr<CFConsumedAttr>() && NSAPIObj->isMacroDefined("CF_CONSUMED")) { @@ -1507,7 +1517,8 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND if (FuncDecl->hasBody()) return CF_BRIDGING_NONE; - CallEffects CE = CallEffects::getEffect(FuncDecl); + const RetainSummary *RS = + getSummaryManager(Ctx).getSummary(AnyCall(FuncDecl)); bool FuncIsReturnAnnotated = (FuncDecl->hasAttr<CFReturnsRetainedAttr>() || FuncDecl->hasAttr<CFReturnsNotRetainedAttr>() || FuncDecl->hasAttr<NSReturnsRetainedAttr>() || @@ -1520,7 +1531,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND bool ReturnCFAudited = false; if (!FuncIsReturnAnnotated) { - RetEffect Ret = CE.getReturnValue(); + RetEffect Ret = RS->getRetEffect(); if (Ret.getObjKind() == ObjKind::CF && (Ret.isOwned() || Ret.notOwned())) ReturnCFAudited = true; @@ -1529,14 +1540,12 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND } // At this point result type is audited for potential inclusion. - // Now, how about argument types. - ArrayRef<ArgEffect> AEArgs = CE.getArgs(); unsigned i = 0; bool ArgCFAudited = false; for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; - ArgEffect AE = AEArgs[i]; + ArgEffect AE = RS->getArg(i); if ((AE.getKind() == DecRef /*CFConsumed annotated*/ || AE.getKind() == IncRef) && AE.getObjKind() == ObjKind::CF) { if (AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) @@ -1546,7 +1555,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND } else { QualType AT = pd->getType(); if (!AuditedType(AT)) { - AddCFAnnotations(Ctx, CE, FuncDecl, FuncIsReturnAnnotated); + AddCFAnnotations(Ctx, RS, FuncDecl, FuncIsReturnAnnotated); return CF_BRIDGING_NONE; } } @@ -1568,12 +1577,12 @@ void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx, } void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, - const CallEffects &CE, + const RetainSummary *RS, const ObjCMethodDecl *MethodDecl, bool ResultAnnotated) { // Annotate function. if (!ResultAnnotated) { - RetEffect Ret = CE.getReturnValue(); + RetEffect Ret = RS->getRetEffect(); const char *AnnotationString = nullptr; if (Ret.getObjKind() == ObjKind::CF) { if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) @@ -1605,12 +1614,11 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, Editor->commit(commit); } } - ArrayRef<ArgEffect> AEArgs = CE.getArgs(); unsigned i = 0; for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; - ArgEffect AE = AEArgs[i]; + ArgEffect AE = RS->getArg(i); if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF && !pd->hasAttr<CFConsumedAttr>() && @@ -1628,7 +1636,9 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( if (MethodDecl->hasBody() || MethodDecl->isImplicit()) return; - CallEffects CE = CallEffects::getEffect(MethodDecl); + const RetainSummary *RS = + getSummaryManager(Ctx).getSummary(AnyCall(MethodDecl)); + bool MethodIsReturnAnnotated = (MethodDecl->hasAttr<CFReturnsRetainedAttr>() || MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() || @@ -1636,7 +1646,7 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() || MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>()); - if (CE.getReceiver().getKind() == DecRef && + if (RS->getReceiverEffect().getKind() == DecRef && !MethodDecl->hasAttr<NSConsumesSelfAttr>() && MethodDecl->getMethodFamily() != OMF_init && MethodDecl->getMethodFamily() != OMF_release && @@ -1652,27 +1662,25 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( return; if (!MethodIsReturnAnnotated) { - RetEffect Ret = CE.getReturnValue(); + RetEffect Ret = RS->getRetEffect(); if ((Ret.getObjKind() == ObjKind::CF || Ret.getObjKind() == ObjKind::ObjC) && (Ret.isOwned() || Ret.notOwned())) { - AddCFAnnotations(Ctx, CE, MethodDecl, false); + AddCFAnnotations(Ctx, RS, MethodDecl, false); return; } 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(); unsigned i = 0; for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; - ArgEffect AE = AEArgs[i]; + ArgEffect AE = RS->getArg(i); if ((AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) || AE.getKind() == IncRef || !AuditedType(pd->getType())) { - AddCFAnnotations(Ctx, CE, MethodDecl, MethodIsReturnAnnotated); + AddCFAnnotations(Ctx, RS, MethodDecl, MethodIsReturnAnnotated); return; } } diff --git a/lib/ARCMigrate/PlistReporter.cpp b/lib/ARCMigrate/PlistReporter.cpp index 9e4cb3f4cd83b..6d7fcb053b482 100644 --- a/lib/ARCMigrate/PlistReporter.cpp +++ b/lib/ARCMigrate/PlistReporter.cpp @@ -1,9 +1,8 @@ //===--- PlistReporter.cpp - ARC Migrate Tool Plist Reporter ----*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -121,5 +120,5 @@ void arcmt::writeARCDiagsToPlist(const std::string &outPath, o << " </array>\n"; // Finish. - o << "</dict>\n</plist>"; + o << "</dict>\n</plist>\n"; } diff --git a/lib/ARCMigrate/TransAPIUses.cpp b/lib/ARCMigrate/TransAPIUses.cpp index 6146e07b1d2a1..638850dcf9ecc 100644 --- a/lib/ARCMigrate/TransAPIUses.cpp +++ b/lib/ARCMigrate/TransAPIUses.cpp @@ -1,9 +1,8 @@ //===--- TransAPIUses.cpp - Transformations to ARC mode -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransARCAssign.cpp b/lib/ARCMigrate/TransARCAssign.cpp index d2b4de4891c31..d1d5b9e014b17 100644 --- a/lib/ARCMigrate/TransARCAssign.cpp +++ b/lib/ARCMigrate/TransARCAssign.cpp @@ -1,9 +1,8 @@ //===--- TransARCAssign.cpp - Transformations to ARC mode -----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransAutoreleasePool.cpp b/lib/ARCMigrate/TransAutoreleasePool.cpp index 9d20774a89a6d..393adcd85a3f5 100644 --- a/lib/ARCMigrate/TransAutoreleasePool.cpp +++ b/lib/ARCMigrate/TransAutoreleasePool.cpp @@ -1,9 +1,8 @@ //===--- TransAutoreleasePool.cpp - Transformations to ARC mode -----------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransBlockObjCVariable.cpp b/lib/ARCMigrate/TransBlockObjCVariable.cpp index 85bdabb504614..1e4db33135b6a 100644 --- a/lib/ARCMigrate/TransBlockObjCVariable.cpp +++ b/lib/ARCMigrate/TransBlockObjCVariable.cpp @@ -1,9 +1,8 @@ //===--- TransBlockObjCVariable.cpp - Transformations to ARC mode ---------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp index 0327b0def1e6b..5d0cfb8a8b9c2 100644 --- a/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp +++ b/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp @@ -1,9 +1,8 @@ -//===--- TransEmptyStatements.cpp - Transformations to ARC mode -----------===// +//===-- TransEmptyStatementsAndDealloc.cpp - Transformations to ARC mode --===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -43,9 +42,8 @@ static bool isEmptyARCMTMacroStatement(NullStmt *S, return false; SourceManager &SM = Ctx.getSourceManager(); - std::vector<SourceLocation>::iterator - I = std::upper_bound(MacroLocs.begin(), MacroLocs.end(), SemiLoc, - BeforeThanCompare<SourceLocation>(SM)); + std::vector<SourceLocation>::iterator I = llvm::upper_bound( + MacroLocs, SemiLoc, BeforeThanCompare<SourceLocation>(SM)); --I; SourceLocation AfterMacroLoc = I->getLocWithOffset(getARCMTMacroName().size()); diff --git a/lib/ARCMigrate/TransGCAttrs.cpp b/lib/ARCMigrate/TransGCAttrs.cpp index 7697d3f048e6d..5e3162197ed1b 100644 --- a/lib/ARCMigrate/TransGCAttrs.cpp +++ b/lib/ARCMigrate/TransGCAttrs.cpp @@ -1,9 +1,8 @@ //===--- TransGCAttrs.cpp - Transformations to ARC mode --------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -69,6 +68,9 @@ public: if (handleAttr(Attr, D)) break; TL = Attr.getModifiedLoc(); + } else if (MacroQualifiedTypeLoc MDTL = + TL.getAs<MacroQualifiedTypeLoc>()) { + TL = MDTL.getInnerLoc(); } else if (ArrayTypeLoc Arr = TL.getAs<ArrayTypeLoc>()) { TL = Arr.getElementLoc(); } else if (PointerTypeLoc PT = TL.getAs<PointerTypeLoc>()) { @@ -267,7 +269,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx, StringRef toAttr = "strong"; if (hasWeak) { if (canApplyWeak(MigrateCtx.Pass.Ctx, IndProps.front()->getType(), - /*AllowOnUnkwownClass=*/true)) + /*AllowOnUnknownClass=*/true)) toAttr = "weak"; else toAttr = "unsafe_unretained"; diff --git a/lib/ARCMigrate/TransGCCalls.cpp b/lib/ARCMigrate/TransGCCalls.cpp index eff142ba3922b..43233e2d0b456 100644 --- a/lib/ARCMigrate/TransGCCalls.cpp +++ b/lib/ARCMigrate/TransGCCalls.cpp @@ -1,9 +1,8 @@ //===--- TransGCCalls.cpp - Transformations to ARC mode -------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp index 912f77aeb7893..0675fb0baeb80 100644 --- a/lib/ARCMigrate/TransProperties.cpp +++ b/lib/ARCMigrate/TransProperties.cpp @@ -1,9 +1,8 @@ //===--- TransProperties.cpp - Transformations to ARC mode ----------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransProtectedScope.cpp b/lib/ARCMigrate/TransProtectedScope.cpp index bfc542e7497cd..9e9e9cb7a96de 100644 --- a/lib/ARCMigrate/TransProtectedScope.cpp +++ b/lib/ARCMigrate/TransProtectedScope.cpp @@ -1,9 +1,8 @@ //===--- TransProtectedScope.cpp - Transformations to ARC mode ------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp index d199bb9365473..b76fc65574dd4 100644 --- a/lib/ARCMigrate/TransRetainReleaseDealloc.cpp +++ b/lib/ARCMigrate/TransRetainReleaseDealloc.cpp @@ -1,9 +1,8 @@ //===--- TransRetainReleaseDealloc.cpp - Transformations to ARC mode ------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -270,8 +269,8 @@ private: if (prevChildS != childE) { prevStmt = *prevChildS; - if (prevStmt) - prevStmt = prevStmt->IgnoreImplicit(); + if (auto *E = dyn_cast_or_null<Expr>(prevStmt)) + prevStmt = E->IgnoreImplicit(); } if (currChildS == childE) @@ -281,8 +280,8 @@ private: return std::make_pair(prevStmt, nextStmt); nextStmt = *currChildS; - if (nextStmt) - nextStmt = nextStmt->IgnoreImplicit(); + if (auto *E = dyn_cast_or_null<Expr>(nextStmt)) + nextStmt = E->IgnoreImplicit(); return std::make_pair(prevStmt, nextStmt); } diff --git a/lib/ARCMigrate/TransUnbridgedCasts.cpp b/lib/ARCMigrate/TransUnbridgedCasts.cpp index 9d46d8c5fcae0..e767ad5346c30 100644 --- a/lib/ARCMigrate/TransUnbridgedCasts.cpp +++ b/lib/ARCMigrate/TransUnbridgedCasts.cpp @@ -1,9 +1,8 @@ //===--- TransUnbridgedCasts.cpp - Transformations to ARC mode ------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransUnusedInitDelegate.cpp b/lib/ARCMigrate/TransUnusedInitDelegate.cpp index 70370ecc4e90b..bac8dfac9b415 100644 --- a/lib/ARCMigrate/TransUnusedInitDelegate.cpp +++ b/lib/ARCMigrate/TransUnusedInitDelegate.cpp @@ -1,9 +1,8 @@ //===--- TransUnusedInitDelegate.cpp - Transformations to ARC mode --------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Transformations: diff --git a/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp b/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp index 220102ec49ce1..d28bd378acc11 100644 --- a/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp +++ b/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp @@ -1,9 +1,8 @@ //===--- TransZeroOutPropsInDealloc.cpp - Transformations to ARC mode -----===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/ARCMigrate/TransformActions.cpp b/lib/ARCMigrate/TransformActions.cpp index d1768bc56cfcf..2c48e479dce8c 100644 --- a/lib/ARCMigrate/TransformActions.cpp +++ b/lib/ARCMigrate/TransformActions.cpp @@ -1,9 +1,8 @@ -//===--- ARCMT.cpp - Migration to ARC mode --------------------------------===// +//===-- TransformActions.cpp - Migration to ARC mode ----------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -314,7 +313,9 @@ void TransformActionsImpl::removeStmt(Stmt *S) { assert(IsInTransaction && "Actions only allowed during a transaction"); ActionData data; data.Kind = Act_RemoveStmt; - data.S = S->IgnoreImplicit(); // important for uniquing + if (auto *E = dyn_cast<Expr>(S)) + S = E->IgnoreImplicit(); // important for uniquing + data.S = S; CachedActions.push_back(data); } diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 8bd2b407aee94..59b80a917e560 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -1,9 +1,8 @@ //===--- Transforms.cpp - Transformations to ARC mode ---------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -287,10 +286,11 @@ private: void mark(Stmt *S) { if (!S) return; - while (LabelStmt *Label = dyn_cast<LabelStmt>(S)) + while (auto *Label = dyn_cast<LabelStmt>(S)) S = Label->getSubStmt(); - S = S->IgnoreImplicit(); - if (Expr *E = dyn_cast<Expr>(S)) + if (auto *E = dyn_cast<Expr>(S)) + S = E->IgnoreImplicit(); + if (auto *E = dyn_cast<Expr>(S)) Removables.insert(E); } }; diff --git a/lib/ARCMigrate/Transforms.h b/lib/ARCMigrate/Transforms.h index bafe9fc52a274..e087136f0e2c8 100644 --- a/lib/ARCMigrate/Transforms.h +++ b/lib/ARCMigrate/Transforms.h @@ -1,9 +1,8 @@ //===-- Transforms.h - Transformations to ARC mode --------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// |