aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools/clang/lib/ARCMigrate
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-20 14:02:54 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-20 14:02:54 +0000
commitd5ea6fa648f8835a44adfb322b788e615d77cb71 (patch)
tree570aa90958a58b9d6a71fa8594ee0ad8d2a18f2c /contrib/llvm/tools/clang/lib/ARCMigrate
parentd9484dd61cc151c4f34c31e07f693fefa66316b5 (diff)
parent676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (diff)
downloadsrc-d5ea6fa648f8835a44adfb322b788e615d77cb71.tar.gz
src-d5ea6fa648f8835a44adfb322b788e615d77cb71.zip
Merge clang trunk r351319, resolve conflicts, and update FREEBSD-Xlist.
Notes
Notes: svn path=/projects/clang800-import/; revision=343214
Diffstat (limited to 'contrib/llvm/tools/clang/lib/ARCMigrate')
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/ARCMT.cpp6
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/FileRemapper.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/ObjCMT.cpp124
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransAPIUses.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransAutoreleasePool.cpp28
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransGCAttrs.cpp17
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransGCCalls.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransProtectedScope.cpp7
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp22
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp19
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransformActions.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/Transforms.cpp6
12 files changed, 120 insertions, 117 deletions
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/ARCMT.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/ARCMT.cpp
index 3c7b593be6d4..6da87903a488 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/ARCMT.cpp
@@ -190,8 +190,6 @@ createInvocationForMigration(CompilerInvocation &origCI,
PPOpts.Includes.insert(PPOpts.Includes.begin(), OriginalFile);
PPOpts.ImplicitPCHInclude.clear();
}
- // FIXME: Get the original header of a PTH as well.
- CInvok->getPreprocessorOpts().ImplicitPTHInclude.clear();
std::string define = getARCMTMacroName();
define += '=';
CInvok->getPreprocessorOpts().addMacroDef(define);
@@ -241,7 +239,7 @@ bool arcmt::checkForManualIssues(
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors,
StringRef plistOut) {
- if (!origCI.getLangOpts()->ObjC1)
+ if (!origCI.getLangOpts()->ObjC)
return false;
LangOptions::GCMode OrigGCMode = origCI.getLangOpts()->getGC();
@@ -342,7 +340,7 @@ applyTransforms(CompilerInvocation &origCI, const FrontendInputFile &Input,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
DiagnosticConsumer *DiagClient, StringRef outputDir,
bool emitPremigrationARCErrors, StringRef plistOut) {
- if (!origCI.getLangOpts()->ObjC1)
+ if (!origCI.getLangOpts()->ObjC)
return false;
LangOptions::GCMode OrigGCMode = origCI.getLangOpts()->getGC();
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/FileRemapper.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/FileRemapper.cpp
index ccc8c9ee30ff..225f47119b00 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -226,7 +226,7 @@ void FileRemapper::remap(const FileEntry *file, const FileEntry *newfile) {
const FileEntry *FileRemapper::getOriginalFile(StringRef filePath) {
const FileEntry *file = FileMgr->getFile(filePath);
- // If we are updating a file that overriden an original file,
+ // If we are updating a file that overridden an original file,
// actually update the original file.
llvm::DenseMap<const FileEntry *, const FileEntry *>::iterator
I = ToFromMappings.find(file);
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/ObjCMT.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/ObjCMT.cpp
index 7e9bc6a5bdc6..6950ce0e12f3 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -27,7 +27,7 @@
#include "clang/Lex/PPConditionalDirectiveRecord.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/StaticAnalyzer/Checkers/ObjCRetainCount.h"
+#include "clang/StaticAnalyzer/Core/RetainSummaryManager.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Path.h"
@@ -36,7 +36,7 @@
using namespace clang;
using namespace arcmt;
-using namespace ento::objc_retain;
+using namespace ento;
namespace {
@@ -261,7 +261,7 @@ namespace {
if (IsGetter) {
// Find space location range between receiver expression and getter method.
SourceLocation BegLoc =
- ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
+ ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
BegLoc = PP.getLocForEndOfToken(BegLoc);
SourceLocation EndLoc = Msg->getSelectorLoc(0);
SourceRange SpaceRange(BegLoc, EndLoc);
@@ -269,7 +269,7 @@ namespace {
// rewrite getter method expression into: receiver.property or
// (receiver).property
if (NeedsParen) {
- commit.insertBefore(receiver->getLocStart(), "(");
+ commit.insertBefore(receiver->getBeginLoc(), "(");
PropertyDotString = ").";
}
else
@@ -291,9 +291,9 @@ namespace {
if (!RHS)
return false;
SourceLocation BegLoc =
- ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getLocEnd();
+ ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc();
BegLoc = PP.getLocForEndOfToken(BegLoc);
- SourceLocation EndLoc = RHS->getLocStart();
+ SourceLocation EndLoc = RHS->getBeginLoc();
EndLoc = EndLoc.getLocWithOffset(-1);
const char *colon = PP.getSourceManager().getCharacterData(EndLoc);
// Add a space after '=' if there is no space between RHS and '='
@@ -545,14 +545,14 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
SourceLocation EndGetterSelectorLoc =
StartGetterSelectorLoc.getLocWithOffset(GetterSelector.getNameForSlot(0).size());
- commit.replace(CharSourceRange::getCharRange(Getter->getLocStart(),
+ commit.replace(CharSourceRange::getCharRange(Getter->getBeginLoc(),
EndGetterSelectorLoc),
PropertyString);
if (Setter && AvailabilityArgsMatch) {
SourceLocation EndLoc = Setter->getDeclaratorEndLoc();
// Get location past ';'
EndLoc = EndLoc.getLocWithOffset(1);
- SourceLocation BeginOfSetterDclLoc = Setter->getLocStart();
+ SourceLocation BeginOfSetterDclLoc = Setter->getBeginLoc();
// FIXME. This assumes that setter decl; is immediately preceded by eoln.
// It is trying to remove the setter method decl. line entirely.
BeginOfSetterDclLoc = BeginOfSetterDclLoc.getLocWithOffset(-1);
@@ -720,32 +720,33 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
- SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
+ SourceRange R(EnumDcl->getBeginLoc(), EnumDcl->getBeginLoc());
commit.replace(R, ClassString);
- SourceLocation EndOfEnumDclLoc = EnumDcl->getLocEnd();
+ SourceLocation EndOfEnumDclLoc = EnumDcl->getEndLoc();
EndOfEnumDclLoc = trans::findSemiAfterLocation(EndOfEnumDclLoc,
NS.getASTContext(), /*IsDecl*/true);
if (EndOfEnumDclLoc.isValid()) {
- SourceRange EnumDclRange(EnumDcl->getLocStart(), EndOfEnumDclLoc);
- commit.insertFromRange(TypedefDcl->getLocStart(), EnumDclRange);
+ SourceRange EnumDclRange(EnumDcl->getBeginLoc(), EndOfEnumDclLoc);
+ commit.insertFromRange(TypedefDcl->getBeginLoc(), EnumDclRange);
}
else
return false;
- SourceLocation EndTypedefDclLoc = TypedefDcl->getLocEnd();
+ SourceLocation EndTypedefDclLoc = TypedefDcl->getEndLoc();
EndTypedefDclLoc = trans::findSemiAfterLocation(EndTypedefDclLoc,
NS.getASTContext(), /*IsDecl*/true);
if (EndTypedefDclLoc.isValid()) {
- SourceRange TDRange(TypedefDcl->getLocStart(), EndTypedefDclLoc);
+ SourceRange TDRange(TypedefDcl->getBeginLoc(), EndTypedefDclLoc);
commit.remove(TDRange);
}
else
return false;
- EndOfEnumDclLoc = trans::findLocationAfterSemi(EnumDcl->getLocEnd(), NS.getASTContext(),
- /*IsDecl*/true);
+ EndOfEnumDclLoc =
+ trans::findLocationAfterSemi(EnumDcl->getEndLoc(), NS.getASTContext(),
+ /*IsDecl*/ true);
if (EndOfEnumDclLoc.isValid()) {
- SourceLocation BeginOfEnumDclLoc = EnumDcl->getLocStart();
+ SourceLocation BeginOfEnumDclLoc = EnumDcl->getBeginLoc();
// FIXME. This assumes that enum decl; is immediately preceded by eoln.
// It is trying to remove the enum decl. lines entirely.
BeginOfEnumDclLoc = BeginOfEnumDclLoc.getLocWithOffset(-1);
@@ -775,12 +776,13 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx,
SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin();
if (EndLoc.isInvalid())
return;
- CharSourceRange R = CharSourceRange::getCharRange(EnumDcl->getLocStart(), EndLoc);
+ CharSourceRange R =
+ CharSourceRange::getCharRange(EnumDcl->getBeginLoc(), EndLoc);
commit.replace(R, ClassString);
// This is to remove spaces between '}' and typedef name.
- SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
+ SourceLocation StartTypedefLoc = EnumDcl->getEndLoc();
StartTypedefLoc = StartTypedefLoc.getLocWithOffset(+1);
- SourceLocation EndTypedefLoc = TypedefDcl->getLocEnd();
+ SourceLocation EndTypedefLoc = TypedefDcl->getEndLoc();
commit.remove(SourceRange(StartTypedefLoc, EndTypedefLoc));
}
@@ -811,7 +813,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
}
if (AllHexdecimalEnumerator && EnumVal) {
bool FoundHexdecimalEnumerator = false;
- SourceLocation EndLoc = Enumerator->getLocEnd();
+ SourceLocation EndLoc = Enumerator->getEndLoc();
Token Tok;
if (!PP.getRawToken(EndLoc, Tok, /*IgnoreWhiteSpace=*/true))
if (Tok.isLiteral() && Tok.getLength() > 2) {
@@ -928,7 +930,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
if (const EnumType *EnumTy = qt->getAs<EnumType>()) {
if (EnumTy->getDecl() == EnumDcl) {
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
- if (!InsertFoundation(Ctx, TypedefDcl->getLocStart()))
+ if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc()))
return false;
edit::Commit commit(*Editor);
rewriteToNSMacroDecl(Ctx, EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
@@ -941,7 +943,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
// 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()))
+ if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc()))
return false;
edit::Commit commit(*Editor);
bool Res = rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj,
@@ -964,7 +966,7 @@ static void ReplaceWithInstancetype(ASTContext &Ctx,
ClassString = "instancetype";
}
else {
- R = SourceRange(OM->getLocStart(), OM->getLocStart());
+ R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc());
ClassString = OM->isInstanceMethod() ? '-' : '+';
ClassString += " (instancetype)";
}
@@ -986,7 +988,7 @@ static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC,
}
}
else {
- R = SourceRange(OM->getLocStart(), OM->getLocStart());
+ R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc());
ClassString = "+ (";
ClassString += IDecl->getName(); ClassString += "*)";
}
@@ -1257,7 +1259,7 @@ void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx,
return;
edit::Commit commit(*Editor);
- commit.insertBefore(OM->getLocEnd(), " NS_RETURNS_INNER_POINTER");
+ commit.insertBefore(OM->getEndLoc(), " NS_RETURNS_INNER_POINTER");
Editor->commit(commit);
}
@@ -1269,7 +1271,7 @@ void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ct
!NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER"))
return;
edit::Commit commit(*Editor);
- commit.insertBefore(P->getLocEnd(), " NS_RETURNS_INNER_POINTER ");
+ commit.insertBefore(P->getEndLoc(), " NS_RETURNS_INNER_POINTER ");
Editor->commit(commit);
}
@@ -1395,9 +1397,9 @@ void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) {
CFFunctionIBCandidates[CFFunctionIBCandidates.size()-1];
const char *PragmaString = "\nCF_IMPLICIT_BRIDGING_ENABLED\n\n";
edit::Commit commit(*Editor);
- commit.insertBefore(FirstFD->getLocStart(), PragmaString);
+ commit.insertBefore(FirstFD->getBeginLoc(), PragmaString);
PragmaString = "\n\nCF_IMPLICIT_BRIDGING_DISABLED\n";
- SourceLocation EndLoc = LastFD->getLocEnd();
+ SourceLocation EndLoc = LastFD->getEndLoc();
// get location just past end of function location.
EndLoc = PP.getLocForEndOfToken(EndLoc);
if (isa<FunctionDecl>(LastFD)) {
@@ -1458,21 +1460,21 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (!ResultAnnotated) {
RetEffect Ret = CE.getReturnValue();
const char *AnnotationString = nullptr;
- if (Ret.getObjKind() == RetEffect::CF) {
+ if (Ret.getObjKind() == ObjKind::CF) {
if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
AnnotationString = " CF_RETURNS_RETAINED";
else if (Ret.notOwned() &&
NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))
AnnotationString = " CF_RETURNS_NOT_RETAINED";
}
- else if (Ret.getObjKind() == RetEffect::ObjC) {
+ else if (Ret.getObjKind() == ObjKind::ObjC) {
if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED"))
AnnotationString = " NS_RETURNS_RETAINED";
}
if (AnnotationString) {
edit::Commit commit(*Editor);
- commit.insertAfterToken(FuncDecl->getLocEnd(), AnnotationString);
+ commit.insertAfterToken(FuncDecl->getEndLoc(), AnnotationString);
Editor->commit(commit);
}
}
@@ -1482,14 +1484,15 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
const ParmVarDecl *pd = *pi;
ArgEffect AE = AEArgs[i];
- if (AE == DecRef && !pd->hasAttr<CFConsumedAttr>() &&
+ if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::CF &&
+ !pd->hasAttr<CFConsumedAttr>() &&
NSAPIObj->isMacroDefined("CF_CONSUMED")) {
edit::Commit commit(*Editor);
commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
Editor->commit(commit);
- }
- else if (AE == DecRefMsg && !pd->hasAttr<NSConsumedAttr>() &&
- NSAPIObj->isMacroDefined("NS_CONSUMED")) {
+ } else if (AE.getKind() == DecRef && AE.getObjKind() == ObjKind::ObjC &&
+ !pd->hasAttr<NSConsumedAttr>() &&
+ NSAPIObj->isMacroDefined("NS_CONSUMED")) {
edit::Commit commit(*Editor);
commit.insertBefore(pd->getLocation(), "NS_CONSUMED ");
Editor->commit(commit);
@@ -1518,7 +1521,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
bool ReturnCFAudited = false;
if (!FuncIsReturnAnnotated) {
RetEffect Ret = CE.getReturnValue();
- if (Ret.getObjKind() == RetEffect::CF &&
+ if (Ret.getObjKind() == ObjKind::CF &&
(Ret.isOwned() || Ret.notOwned()))
ReturnCFAudited = true;
else if (!AuditedType(FuncDecl->getReturnType()))
@@ -1534,13 +1537,13 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND
pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {
const ParmVarDecl *pd = *pi;
ArgEffect AE = AEArgs[i];
- if (AE == DecRef /*CFConsumed annotated*/ || AE == IncRef) {
- if (AE == DecRef && !pd->hasAttr<CFConsumedAttr>())
+ if ((AE.getKind() == DecRef /*CFConsumed annotated*/ ||
+ AE.getKind() == IncRef) && AE.getObjKind() == ObjKind::CF) {
+ if (AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>())
ArgCFAudited = true;
- else if (AE == IncRef)
+ else if (AE.getKind() == IncRef)
ArgCFAudited = true;
- }
- else {
+ } else {
QualType AT = pd->getType();
if (!AuditedType(AT)) {
AddCFAnnotations(Ctx, CE, FuncDecl, FuncIsReturnAnnotated);
@@ -1572,14 +1575,14 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (!ResultAnnotated) {
RetEffect Ret = CE.getReturnValue();
const char *AnnotationString = nullptr;
- if (Ret.getObjKind() == RetEffect::CF) {
+ if (Ret.getObjKind() == ObjKind::CF) {
if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
AnnotationString = " CF_RETURNS_RETAINED";
else if (Ret.notOwned() &&
NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED"))
AnnotationString = " CF_RETURNS_NOT_RETAINED";
}
- else if (Ret.getObjKind() == RetEffect::ObjC) {
+ else if (Ret.getObjKind() == ObjKind::ObjC) {
ObjCMethodFamily OMF = MethodDecl->getMethodFamily();
switch (OMF) {
case clang::OMF_alloc:
@@ -1598,7 +1601,7 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
if (AnnotationString) {
edit::Commit commit(*Editor);
- commit.insertBefore(MethodDecl->getLocEnd(), AnnotationString);
+ commit.insertBefore(MethodDecl->getEndLoc(), AnnotationString);
Editor->commit(commit);
}
}
@@ -1608,7 +1611,9 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) {
const ParmVarDecl *pd = *pi;
ArgEffect AE = AEArgs[i];
- if (AE == DecRef && !pd->hasAttr<CFConsumedAttr>() &&
+ if (AE.getKind() == DecRef
+ && AE.getObjKind() == ObjKind::CF
+ && !pd->hasAttr<CFConsumedAttr>() &&
NSAPIObj->isMacroDefined("CF_CONSUMED")) {
edit::Commit commit(*Editor);
commit.insertBefore(pd->getLocation(), "CF_CONSUMED ");
@@ -1624,19 +1629,20 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
return;
CallEffects CE = CallEffects::getEffect(MethodDecl);
- bool MethodIsReturnAnnotated = (MethodDecl->hasAttr<CFReturnsRetainedAttr>() ||
- MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() ||
- MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>());
-
- if (CE.getReceiver() == DecRefMsg &&
+ bool MethodIsReturnAnnotated =
+ (MethodDecl->hasAttr<CFReturnsRetainedAttr>() ||
+ MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() ||
+ MethodDecl->hasAttr<NSReturnsRetainedAttr>() ||
+ MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() ||
+ MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>());
+
+ if (CE.getReceiver().getKind() == DecRef &&
!MethodDecl->hasAttr<NSConsumesSelfAttr>() &&
MethodDecl->getMethodFamily() != OMF_init &&
MethodDecl->getMethodFamily() != OMF_release &&
NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) {
edit::Commit commit(*Editor);
- commit.insertBefore(MethodDecl->getLocEnd(), " NS_CONSUMES_SELF");
+ commit.insertBefore(MethodDecl->getEndLoc(), " NS_CONSUMES_SELF");
Editor->commit(commit);
}
@@ -1647,8 +1653,8 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
if (!MethodIsReturnAnnotated) {
RetEffect Ret = CE.getReturnValue();
- if ((Ret.getObjKind() == RetEffect::CF ||
- Ret.getObjKind() == RetEffect::ObjC) &&
+ if ((Ret.getObjKind() == ObjKind::CF ||
+ Ret.getObjKind() == ObjKind::ObjC) &&
(Ret.isOwned() || Ret.notOwned())) {
AddCFAnnotations(Ctx, CE, MethodDecl, false);
return;
@@ -1664,8 +1670,8 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) {
const ParmVarDecl *pd = *pi;
ArgEffect AE = AEArgs[i];
- if ((AE == DecRef && !pd->hasAttr<CFConsumedAttr>()) || AE == IncRef ||
- !AuditedType(pd->getType())) {
+ if ((AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) ||
+ AE.getKind() == IncRef || !AuditedType(pd->getType())) {
AddCFAnnotations(Ctx, CE, MethodDecl, MethodIsReturnAnnotated);
return;
}
@@ -1713,7 +1719,7 @@ void ObjCMigrateASTConsumer::inferDesignatedInitializers(
continue;
if (hasSuperInitCall(MD)) {
edit::Commit commit(*Editor);
- commit.insert(IFaceM->getLocEnd(), " NS_DESIGNATED_INITIALIZER");
+ commit.insert(IFaceM->getEndLoc(), " NS_DESIGNATED_INITIALIZER");
Editor->commit(commit);
}
}
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransAPIUses.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransAPIUses.cpp
index 40c8a070f813..6146e07b1d2a 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransAPIUses.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransAPIUses.cpp
@@ -75,7 +75,7 @@ public:
return true;
if (pointee.getObjCLifetime() > Qualifiers::OCL_ExplicitNone)
- Pass.TA.report(parm->getLocStart(),
+ Pass.TA.report(parm->getBeginLoc(),
diag::err_arcmt_nsinvocation_ownership,
parm->getSourceRange())
<< selName;
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransAutoreleasePool.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
index 2d35655d186f..9d20774a89a6 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
@@ -128,21 +128,21 @@ public:
Pass.TA.removeStmt(*scope.End);
Stmt::child_iterator retI = scope.End;
++retI;
- SourceLocation afterSemi = findLocationAfterSemi((*retI)->getLocEnd(),
- Pass.Ctx);
+ SourceLocation afterSemi =
+ findLocationAfterSemi((*retI)->getEndLoc(), Pass.Ctx);
assert(afterSemi.isValid() &&
"Didn't we check before setting IsFollowedBySimpleReturnStmt "
"to true?");
Pass.TA.insertAfterToken(afterSemi, "\n}");
Pass.TA.increaseIndentation(
- SourceRange(scope.getIndentedRange().getBegin(),
- (*retI)->getLocEnd()),
- scope.CompoundParent->getLocStart());
+ SourceRange(scope.getIndentedRange().getBegin(),
+ (*retI)->getEndLoc()),
+ scope.CompoundParent->getBeginLoc());
} else {
Pass.TA.replaceStmt(*scope.Begin, "@autoreleasepool {");
Pass.TA.replaceStmt(*scope.End, "}");
Pass.TA.increaseIndentation(scope.getIndentedRange(),
- scope.CompoundParent->getLocStart());
+ scope.CompoundParent->getBeginLoc());
}
}
@@ -241,7 +241,7 @@ private:
Stmt::child_iterator rangeE = Begin;
for (Stmt::child_iterator I = rangeS; I != End; ++I)
++rangeE;
- return SourceRange((*rangeS)->getLocStart(), (*rangeE)->getLocEnd());
+ return SourceRange((*rangeS)->getBeginLoc(), (*rangeE)->getEndLoc());
}
};
@@ -256,8 +256,8 @@ private:
SourceLocation &declarationLoc)
: Ctx(ctx), referenceLoc(referenceLoc),
declarationLoc(declarationLoc) {
- ScopeRange = SourceRange((*scope.Begin)->getLocStart(),
- (*scope.End)->getLocStart());
+ ScopeRange = SourceRange((*scope.Begin)->getBeginLoc(),
+ (*scope.End)->getBeginLoc());
}
bool VisitDeclRefExpr(DeclRefExpr *E) {
@@ -307,7 +307,7 @@ private:
if (ReturnStmt *retS = dyn_cast<ReturnStmt>(*SI))
if ((retS->getRetValue() == nullptr ||
isa<DeclRefExpr>(retS->getRetValue()->IgnoreParenCasts())) &&
- findLocationAfterSemi(retS->getLocEnd(), Pass.Ctx).isValid()) {
+ findLocationAfterSemi(retS->getEndLoc(), Pass.Ctx).isValid()) {
scope.IsFollowedBySimpleReturnStmt = true;
++SI; // the return will be included in scope, don't check it.
}
@@ -328,9 +328,9 @@ private:
"NSAutoreleasePool scope that it was declared in", referenceLoc);
Pass.TA.reportNote("name declared here", declarationLoc);
Pass.TA.reportNote("intended @autoreleasepool scope begins here",
- (*scope.Begin)->getLocStart());
+ (*scope.Begin)->getBeginLoc());
Pass.TA.reportNote("intended @autoreleasepool scope ends here",
- (*scope.End)->getLocStart());
+ (*scope.End)->getBeginLoc());
return;
}
}
@@ -403,8 +403,8 @@ private:
return cast<Expr>(getEssential((Stmt*)E));
}
static Stmt *getEssential(Stmt *S) {
- if (ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(S))
- S = EWC->getSubExpr();
+ if (FullExpr *FE = dyn_cast<FullExpr>(S))
+ S = FE->getSubExpr();
if (Expr *E = dyn_cast<Expr>(S))
S = E->IgnoreParenCasts();
return S;
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCAttrs.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCAttrs.cpp
index fb45cd92c1f6..7697d3f048e6 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCAttrs.cpp
@@ -81,10 +81,11 @@ public:
}
bool handleAttr(AttributedTypeLoc TL, Decl *D = nullptr) {
- if (TL.getAttrKind() != AttributedType::attr_objc_ownership)
+ auto *OwnershipAttr = TL.getAttrAs<ObjCOwnershipAttr>();
+ if (!OwnershipAttr)
return false;
- SourceLocation Loc = TL.getAttrNameLoc();
+ SourceLocation Loc = OwnershipAttr->getLocation();
unsigned RawLoc = Loc.getRawEncoding();
if (MigrateCtx.AttrSet.count(RawLoc))
return true;
@@ -93,13 +94,7 @@ public:
SourceManager &SM = Ctx.getSourceManager();
if (Loc.isMacroID())
Loc = SM.getImmediateExpansionRange(Loc).getBegin();
- SmallString<32> Buf;
- bool Invalid = false;
- StringRef Spell = Lexer::getSpelling(
- SM.getSpellingLoc(TL.getAttrEnumOperandLoc()),
- Buf, SM, Ctx.getLangOpts(), &Invalid);
- if (Invalid)
- return false;
+ StringRef Spell = OwnershipAttr->getKind()->getName();
MigrationContext::GCAttrOccurrence::AttrKind Kind;
if (Spell == "strong")
Kind = MigrationContext::GCAttrOccurrence::Strong;
@@ -284,7 +279,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx,
}
for (unsigned i = 0, e = ATLs.size(); i != e; ++i) {
- SourceLocation Loc = ATLs[i].first.getAttrNameLoc();
+ SourceLocation Loc = ATLs[i].first.getAttr()->getLocation();
if (Loc.isMacroID())
Loc = MigrateCtx.Pass.Ctx.getSourceManager()
.getImmediateExpansionRange(Loc)
@@ -340,7 +335,7 @@ void MigrationContext::dumpGCAttrs() {
llvm::errs() << "KIND: "
<< (Attr.Kind == GCAttrOccurrence::Strong ? "strong" : "weak");
llvm::errs() << "\nLOC: ";
- Attr.Loc.dump(Pass.Ctx.getSourceManager());
+ Attr.Loc.print(llvm::errs(), Pass.Ctx.getSourceManager());
llvm::errs() << "\nTYPE: ";
Attr.ModifiedType.dump();
if (Attr.Dcl) {
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCCalls.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCCalls.cpp
index 3a236d34cd4b..eff142ba3922 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCCalls.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransGCCalls.cpp
@@ -38,7 +38,7 @@ public:
TransformActions &TA = MigrateCtx.Pass.TA;
if (MigrateCtx.isGCOwnedNonObjC(E->getType())) {
- TA.report(E->getLocStart(), diag::warn_arcmt_nsalloc_realloc,
+ TA.report(E->getBeginLoc(), diag::warn_arcmt_nsalloc_realloc,
E->getSourceRange());
return true;
}
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransProtectedScope.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransProtectedScope.cpp
index 1bb4c1f4e449..bfc542e7497c 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransProtectedScope.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransProtectedScope.cpp
@@ -73,12 +73,13 @@ public:
Curr = Curr->getNextSwitchCase();
}
- SourceLocation NextLoc = S->getLocEnd();
+ SourceLocation NextLoc = S->getEndLoc();
Curr = S->getSwitchCaseList();
// We iterate over case statements in reverse source-order.
while (Curr) {
- Cases.push_back(CaseInfo(Curr,SourceRange(Curr->getLocStart(), NextLoc)));
- NextLoc = Curr->getLocStart();
+ Cases.push_back(
+ CaseInfo(Curr, SourceRange(Curr->getBeginLoc(), NextLoc)));
+ NextLoc = Curr->getBeginLoc();
Curr = Curr->getNextSwitchCase();
}
return true;
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
index c411044ecde3..d199bb936547 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -71,9 +71,10 @@ public:
// will likely die immediately while previously it was kept alive
// by the autorelease pool. This is bad practice in general, leave it
// and emit an error to force the user to restructure their code.
- Pass.TA.reportError("it is not safe to remove an unused 'autorelease' "
+ Pass.TA.reportError(
+ "it is not safe to remove an unused 'autorelease' "
"message; its receiver may be destroyed immediately",
- E->getLocStart(), E->getSourceRange());
+ E->getBeginLoc(), E->getSourceRange());
return true;
}
}
@@ -89,7 +90,7 @@ public:
std::string err = "it is not safe to remove '";
err += E->getSelector().getAsString() + "' message on "
"an __unsafe_unretained type";
- Pass.TA.reportError(err, rec->getLocStart());
+ Pass.TA.reportError(err, rec->getBeginLoc());
return true;
}
@@ -98,18 +99,21 @@ public:
std::string err = "it is not safe to remove '";
err += E->getSelector().getAsString() + "' message on "
"a global variable";
- Pass.TA.reportError(err, rec->getLocStart());
+ Pass.TA.reportError(err, rec->getBeginLoc());
return true;
}
if (E->getMethodFamily() == OMF_release && isDelegateMessage(rec)) {
- Pass.TA.reportError("it is not safe to remove 'retain' "
+ Pass.TA.reportError(
+ "it is not safe to remove 'retain' "
"message on the result of a 'delegate' message; "
"the object that was passed to 'setDelegate:' may not be "
- "properly retained", rec->getLocStart());
+ "properly retained",
+ rec->getBeginLoc());
return true;
}
}
+ break;
case OMF_dealloc:
break;
}
@@ -250,7 +254,7 @@ private:
}
while (OuterS && (isa<ParenExpr>(OuterS) ||
isa<CastExpr>(OuterS) ||
- isa<ExprWithCleanups>(OuterS)));
+ isa<FullExpr>(OuterS)));
if (!OuterS)
return std::make_pair(prevStmt, nextStmt);
@@ -373,8 +377,8 @@ private:
RecContainer = StmtE;
Rec = Init->IgnoreParenImpCasts();
- if (ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(Rec))
- Rec = EWC->getSubExpr()->IgnoreParenImpCasts();
+ if (FullExpr *FE = dyn_cast<FullExpr>(Rec))
+ Rec = FE->getSubExpr()->IgnoreParenImpCasts();
RecRange = Rec->getSourceRange();
if (SM.isMacroArgExpansion(RecRange.getBegin()))
RecRange.setBegin(SM.getImmediateSpellingLoc(RecRange.getBegin()));
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
index 66167d37ac95..9d46d8c5fcae 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
@@ -209,7 +209,7 @@ private:
// We will remove the compiler diagnostic.
if (!TA.hasDiagnostic(diag::err_arc_mismatched_cast,
diag::err_arc_cast_requires_bridge,
- E->getLocStart())) {
+ E->getBeginLoc())) {
Trans.abort();
return;
}
@@ -225,13 +225,12 @@ private:
}
TA.clearDiagnostic(diag::err_arc_mismatched_cast,
- diag::err_arc_cast_requires_bridge,
- E->getLocStart());
+ diag::err_arc_cast_requires_bridge, E->getBeginLoc());
if (Kind == OBC_Bridge || !Pass.CFBridgingFunctionsDefined()) {
if (CStyleCastExpr *CCE = dyn_cast<CStyleCastExpr>(E)) {
TA.insertAfterToken(CCE->getLParenLoc(), bridge);
} else {
- SourceLocation insertLoc = E->getSubExpr()->getLocStart();
+ SourceLocation insertLoc = E->getSubExpr()->getBeginLoc();
SmallString<128> newCast;
newCast += '(';
newCast += bridge;
@@ -243,7 +242,7 @@ private:
} else {
newCast += '(';
TA.insert(insertLoc, newCast.str());
- TA.insertAfterToken(E->getLocEnd(), ")");
+ TA.insertAfterToken(E->getEndLoc(), ")");
}
}
} else {
@@ -251,7 +250,7 @@ private:
SmallString<32> BridgeCall;
Expr *WrapE = E->getSubExpr();
- SourceLocation InsertLoc = WrapE->getLocStart();
+ SourceLocation InsertLoc = WrapE->getBeginLoc();
SourceManager &SM = Pass.Ctx.getSourceManager();
char PrevChar = *SM.getCharacterData(InsertLoc.getLocWithOffset(-1));
@@ -268,7 +267,7 @@ private:
} else {
BridgeCall += '(';
TA.insert(InsertLoc, BridgeCall);
- TA.insertAfterToken(WrapE->getLocEnd(), ")");
+ TA.insertAfterToken(WrapE->getEndLoc(), ")");
}
}
}
@@ -368,19 +367,19 @@ private:
err += family == OMF_autorelease ? "autorelease" : "release";
err += "' message; a __bridge cast may result in a pointer to a "
"destroyed object and a __bridge_retained may leak the object";
- Pass.TA.reportError(err, E->getLocStart(),
+ Pass.TA.reportError(err, E->getBeginLoc(),
E->getSubExpr()->getSourceRange());
Stmt *parent = E;
do {
parent = StmtMap->getParentIgnoreParenImpCasts(parent);
- } while (parent && isa<ExprWithCleanups>(parent));
+ } while (parent && isa<FullExpr>(parent));
if (ReturnStmt *retS = dyn_cast_or_null<ReturnStmt>(parent)) {
std::string note = "remove the cast and change return type of function "
"to '";
note += E->getSubExpr()->getType().getAsString(Pass.Ctx.getPrintingPolicy());
note += "' to have the object automatically autoreleased";
- Pass.TA.reportNote(note, retS->getLocStart());
+ Pass.TA.reportNote(note, retS->getBeginLoc());
}
}
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransformActions.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransformActions.cpp
index 3f79cc441e85..d1768bc56cfc 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransformActions.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransformActions.cpp
@@ -350,7 +350,7 @@ void TransformActionsImpl::replaceText(SourceLocation loc, StringRef text,
void TransformActionsImpl::replaceStmt(Stmt *S, StringRef text) {
assert(IsInTransaction && "Actions only allowed during a transaction");
text = getUniqueText(text);
- insert(S->getLocStart(), text);
+ insert(S->getBeginLoc(), text);
removeStmt(S);
}
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/Transforms.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/Transforms.cpp
index 4a7af2858879..8bd2b407aee9 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/Transforms.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/Transforms.cpp
@@ -74,8 +74,8 @@ bool trans::isPlusOneAssign(const BinaryOperator *E) {
bool trans::isPlusOne(const Expr *E) {
if (!E)
return false;
- if (const ExprWithCleanups *EWC = dyn_cast<ExprWithCleanups>(E))
- E = EWC->getSubExpr();
+ if (const FullExpr *FE = dyn_cast<FullExpr>(E))
+ E = FE->getSubExpr();
if (const ObjCMessageExpr *
ME = dyn_cast<ObjCMessageExpr>(E->IgnoreParenCasts()))
@@ -359,7 +359,7 @@ MigrationContext::~MigrationContext() {
bool MigrationContext::isGCOwnedNonObjC(QualType T) {
while (!T.isNull()) {
if (const AttributedType *AttrT = T->getAs<AttributedType>()) {
- if (AttrT->getAttrKind() == AttributedType::attr_objc_ownership)
+ if (AttrT->getAttrKind() == attr::ObjCOwnership)
return !AttrT->getModifiedType()->isObjCRetainableType();
}