From: Gabor Horvath Date: Fri, 9 Aug 2019 18:58:09 +0000 (+0000) Subject: Revert Fix a build bot failure and multiple warnings instances for range base for... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da2bd2d3f8027c530fe9cabb7ac484bb788942b0;p=clang Revert Fix a build bot failure and multiple warnings instances for range base for loops This reverts r368459 (git commit 2bf522aea62e4fb653cacb68072167d25149099e) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368462 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 3ac45e25bb..dfc12e91a6 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -6616,7 +6616,7 @@ static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call, return; } else if (auto *OCE = dyn_cast(Call)) { FunctionDecl *Callee = OCE->getDirectCallee(); - if (Callee && Callee->isCXXInstanceMember() && + if (Callee->isCXXInstanceMember() && shouldTrackImplicitObjectArg(cast(Callee))) VisitPointerArg(Callee, OCE->getArg(0)); return; @@ -7070,11 +7070,8 @@ static SourceRange nextPathEntryRange(const IndirectLocalPath &Path, unsigned I, // supporting lifetime extension. break; - case IndirectLocalPathEntry::VarInit: - if (cast(Path[I].D)->isImplicit()) - return SourceRange(); - LLVM_FALLTHROUGH; case IndirectLocalPathEntry::DefaultInit: + case IndirectLocalPathEntry::VarInit: return Path[I].E->getSourceRange(); } } @@ -7136,7 +7133,7 @@ void Sema::checkInitializerLifetime(const InitializedEntity &Entity, return false; } - if (IsGslPtrInitWithGslTempOwner && DiagLoc.isValid()) { + if (IsGslPtrInitWithGslTempOwner) { Diag(DiagLoc, diag::warn_dangling_lifetime_pointer) << DiagRange; return false; } diff --git a/test/Sema/warn-lifetime-analysis-nocfg.cpp b/test/Sema/warn-lifetime-analysis-nocfg.cpp index eaddb74e5a..efa54fe662 100644 --- a/test/Sema/warn-lifetime-analysis-nocfg.cpp +++ b/test/Sema/warn-lifetime-analysis-nocfg.cpp @@ -201,13 +201,6 @@ void danglingReferenceFromTempOwner() { std::vector getTempVec(); std::optional> getTempOptVec(); -void testLoops() { - for (auto i : getTempVec()) // ok - ; - for (auto i : *getTempOptVec()) // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} - ; -} - int &usedToBeFalsePositive(std::vector &v) { std::vector::iterator it = v.begin(); int& value = *it;