r332804 - [Driver] Loosen test for LLVM findNearest
Author: modocache Date: Sat May 19 04:46:58 2018 New Revision: 332804 URL: http://llvm.org/viewvc/llvm-project?rev=332804&view=rev Log: [Driver] Loosen test for LLVM findNearest Summary: When https://reviews.llvm.org/D46776 landed to improve the behavior of `llvm::OptTable::findNearest`, a PS4 buildbot began failing due to an assertion that a suggestion "-debug-info-macro" should be provided for the unrecognized option `clang -cc1as -debug-info-macros`. All other buildbots succeeded in this check, and the PS4 buildbot succeeded in the other `findNearest` tests. Temporarily loosen this check in order to reland the `findNearest` change. Test Plan: check-clang Modified: cfe/trunk/test/Driver/unknown-arg.c Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=332804&r1=332803&r2=332804&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Sat May 19 04:46:58 2018 @@ -51,7 +51,7 @@ // SILENT-NOT: warning: // CC1AS-DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? // CC1AS-DID-YOU-MEAN: error: unknown argument '--version', did you mean '-version'? -// CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros', did you mean '-debug-info-macro'? +// CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros' // UNKNOWN-INTEGRATED: error: unknown integrated tool 'asphalt'. Valid tools include '-cc1' and '-cc1as'. // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332806 - [Driver] Temporarily remove test for LLVM findNearest
Author: modocache Date: Sat May 19 05:44:02 2018 New Revision: 332806 URL: http://llvm.org/viewvc/llvm-project?rev=332806&view=rev Log: [Driver] Temporarily remove test for LLVM findNearest Summary: This fixes a failure caused by the revert of https://reviews.llvm.org/rL332805. Modified: cfe/trunk/test/Driver/unknown-arg.c Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=332806&r1=332805&r2=332806&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Sat May 19 05:44:02 2018 @@ -51,7 +51,6 @@ // SILENT-NOT: warning: // CC1AS-DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? // CC1AS-DID-YOU-MEAN: error: unknown argument '--version', did you mean '-version'? -// CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros' // UNKNOWN-INTEGRATED: error: unknown integrated tool 'asphalt'. Valid tools include '-cc1' and '-cc1as'. // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341327 - Removing -debug-info-macros from option suggestions test
Author: modocache Date: Mon Sep 3 09:55:02 2018 New Revision: 341327 URL: http://llvm.org/viewvc/llvm-project?rev=341327&view=rev Log: Removing -debug-info-macros from option suggestions test Summary: https://reviews.llvm.org/D46776 added better support for prefixes for the "did you mean ...?" command line option suggestions. One of the tests was checking against the `-debug-info-macro` option, which was failing on the PS4 build bot. Tests would succeed against the `--help` and `--version` options. From https://llvm.org/devmtg/2013-11/slides/Robinson-PS4Toolchain.pdf, it looks like the PS4 SDK forces optimizations and *could be* disabling the `-debug-info-macro` altogether. This diff removes `-debug-info-macro` altogether. Patch by Arnaud Coomans! Test Plan: untested since we do not have access to a PS4 with the SDK. Reviewers: cfe-commits, modocache Reviewed By: modocache Differential Revision: https://reviews.llvm.org/D50410 Modified: cfe/trunk/test/Driver/unknown-arg.c Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=341327&r1=341326&r2=341327&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Mon Sep 3 09:55:02 2018 @@ -14,7 +14,7 @@ // RUN: FileCheck %s --check-prefix=CL-ERROR-DID-YOU-MEAN // RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -Wno-unknown-argument -### -- %s 2>&1 | \ // RUN: FileCheck %s --check-prefix=SILENT -// RUN: not %clang -cc1as -hell --version -debug-info-macros 2>&1 | \ +// RUN: not %clang -cc1as -hell --version 2>&1 | \ // RUN: FileCheck %s --check-prefix=CC1AS-DID-YOU-MEAN // RUN: not %clang -cc1asphalt -help 2>&1 | \ // RUN: FileCheck %s --check-prefix=UNKNOWN-INTEGRATED ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r325288 - [Sema] Toggle diags when finding allocators (NFCI)
Author: modocache Date: Thu Feb 15 12:09:25 2018 New Revision: 325288 URL: http://llvm.org/viewvc/llvm-project?rev=325288&view=rev Log: [Sema] Toggle diags when finding allocators (NFCI) Summary: Many methods in Sema take a `bool Diagnose` parameter. Examples of such methods include `Sema::FindDeallocationFunction` and `Sema::SpecialMemberIsTrivial`. Calling these methods with `Diagnose = false` allows callers to, for instance, check for the existence of a deallocation function, without that check resulting in error diagnostics being emitted if no matching deallocation function exists. Add a similar `bool Diagnose` to the `Sema::FindAllocationFunctions` method, so that checks for the existence of allocation functions can be made without triggering error diagnostics. This allows `SemaCoroutine.cpp`, in its implementation of the Coroutines TS, to check for the existence of a particular `operator new` overload, but then without error fall back to a default `operator new` if no matching overload exists. Test Plan: `check-clang` Reviewers: rsmith, GorNishanov, eric_niebler Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42605 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaExprCXX.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=325288&r1=325287&r2=325288&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 15 12:09:25 2018 @@ -5151,7 +5151,8 @@ public: bool UseGlobal, QualType AllocType, bool IsArray, bool &PassAlignment, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, - FunctionDecl *&OperatorDelete); + FunctionDecl *&OperatorDelete, + bool Diagnose = true); void DeclareGlobalNewDelete(); void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, ArrayRef Params); Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=325288&r1=325287&r2=325288&view=diff == --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Feb 15 12:09:25 2018 @@ -2151,12 +2151,10 @@ bool Sema::CheckAllocatedType(QualType A return false; } -static bool -resolveAllocationOverload(Sema &S, LookupResult &R, SourceRange Range, - SmallVectorImpl &Args, bool &PassAlignment, - FunctionDecl *&Operator, - OverloadCandidateSet *AlignedCandidates = nullptr, - Expr *AlignArg = nullptr) { +static bool resolveAllocationOverload( +Sema &S, LookupResult &R, SourceRange Range, SmallVectorImpl &Args, +bool &PassAlignment, FunctionDecl *&Operator, +OverloadCandidateSet *AlignedCandidates, Expr *AlignArg, bool Diagnose) { OverloadCandidateSet Candidates(R.getNameLoc(), OverloadCandidateSet::CSK_Normal); for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); @@ -2202,7 +2200,8 @@ resolveAllocationOverload(Sema &S, Looku AlignArg = Args[1]; Args.erase(Args.begin() + 1); return resolveAllocationOverload(S, R, Range, Args, PassAlignment, - Operator, &Candidates, AlignArg); + Operator, &Candidates, AlignArg, + Diagnose); } // MSVC will fall back on trying to find a matching global operator new @@ -2218,48 +2217,53 @@ resolveAllocationOverload(Sema &S, Looku S.LookupQualifiedName(R, S.Context.getTranslationUnitDecl()); // FIXME: This will give bad diagnostics pointing at the wrong functions. return resolveAllocationOverload(S, R, Range, Args, PassAlignment, - Operator, nullptr); + Operator, /*Candidates=*/nullptr, + /*AlignArg=*/nullptr, Diagnose); } -S.Diag(R.getNameLoc(), diag::err_ovl_no_viable_function_in_call) - << R.getLookupName() << Range; - -// If we have aligned candidates, only note the align_val_t candidates -// from AlignedCandidates and the non-align_val_t candidates from -// Candidates. -if (AlignedCandidates) { - auto IsAligned = [](OverloadCandidate &C) { -return C.Function->getNumParams() > 1 && - C.Function->getParamDecl(1)->getType()->isAlignValT(); - }; - auto IsUnaligned = [&](OverloadCandidate
r325291 - [Coroutines] Use allocator overload when available
Author: modocache Date: Thu Feb 15 12:37:22 2018 New Revision: 325291 URL: http://llvm.org/viewvc/llvm-project?rev=325291&view=rev Log: [Coroutines] Use allocator overload when available Summary: Depends on https://reviews.llvm.org/D42605. An implementation of the behavior described in `[dcl.fct.def.coroutine]/7`: when a promise type overloads `operator new` using a "placement new" that takes the same argument types as the coroutine function, that overload is used when allocating the coroutine frame. Simply passing references to the coroutine function parameters directly to `operator new` results in invariant violations in LLVM's coroutine splitting pass, so this implementation modifies Clang codegen to produce allocator-specific alloc/store/loads for each parameter being forwarded to the allocator. Test Plan: `check-clang` Reviewers: rsmith, GorNishanov, eric_niebler Reviewed By: GorNishanov Subscribers: lewissbaker, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D42606 Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp cfe/trunk/test/CodeGenCoroutines/coro-gro-nrvo.cpp cfe/trunk/test/CodeGenCoroutines/coro-params.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=325291&r1=325290&r2=325291&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Thu Feb 15 12:37:22 2018 @@ -12,6 +12,7 @@ //===--===// #include "CoroutineStmtBuilder.h" +#include "clang/AST/ASTLambda.h" #include "clang/AST/Decl.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" @@ -506,24 +507,15 @@ VarDecl *Sema::buildCoroutinePromise(Sou auto RefExpr = ExprEmpty(); auto Move = Moves.find(PD); -if (Move != Moves.end()) { - // If a reference to the function parameter exists in the coroutine - // frame, use that reference. - auto *MoveDecl = - cast(cast(Move->second)->getSingleDecl()); - RefExpr = BuildDeclRefExpr(MoveDecl, MoveDecl->getType(), - ExprValueKind::VK_LValue, FD->getLocation()); -} else { - // If the function parameter doesn't exist in the coroutine frame, it - // must be a scalar value. Use it directly. - assert(!PD->getType()->getAsCXXRecordDecl() && - "Non-scalar types should have been moved and inserted into the " - "parameter moves map"); - RefExpr = - BuildDeclRefExpr(PD, PD->getOriginalType().getNonReferenceType(), - ExprValueKind::VK_LValue, FD->getLocation()); -} - +assert(Move != Moves.end() && + "Coroutine function parameter not inserted into move map"); +// If a reference to the function parameter exists in the coroutine +// frame, use that reference. +auto *MoveDecl = +cast(cast(Move->second)->getSingleDecl()); +RefExpr = +BuildDeclRefExpr(MoveDecl, MoveDecl->getType().getNonReferenceType(), + ExprValueKind::VK_LValue, FD->getLocation()); if (RefExpr.isInvalid()) return nullptr; CtorArgExprs.push_back(RefExpr.get()); @@ -1050,7 +1042,12 @@ bool CoroutineStmtBuilder::makeNewAndDel const bool RequiresNoThrowAlloc = ReturnStmtOnAllocFailure != nullptr; - // FIXME: Add support for stateful allocators. + // [dcl.fct.def.coroutine]/7 + // Lookup allocation functions using a parameter list composed of the + // requested size of the coroutine state being allocated, followed by + // the coroutine function's arguments. If a matching allocation function + // exists, use it. Otherwise, use an allocation function that just takes + // the requested size. FunctionDecl *OperatorNew = nullptr; FunctionDecl *OperatorDelete = nullptr; @@ -1058,10 +1055,62 @@ bool CoroutineStmtBuilder::makeNewAndDel bool PassAlignment = false; SmallVector PlacementArgs; + // [dcl.fct.def.coroutine]/7 + // "The allocation functionâs name is looked up in the scope of P. + // [...] If the lookup finds an allocation function in the scope of P, + // overload resolution is performed on a function call created by assembling + // an argument list. The first argument is the amount of space requested, + // and has type std::size_t. The lvalues p1 ... pn are the succeeding + // arguments." + // + // ...where "p1 ... pn" are defined earlier as: + // + // [dcl.fct.def.coroutine]/3 + // "For a coroutine f that is a non-static member function, let P1 denote the + // type of the implicit object parameter (13.3.1) and P2 ... Pn be the types + // of the function parameters; otherwise let P1 ... Pn be the types of the + // function parameters. Let p1 ...
Re: r325291 - [Coroutines] Use allocator overload when available
Hi Douglas, thanks for letting me know. I'm looking into this now. At first these error messages made me think https://reviews.llvm.org/rL325291 was merged in, but not https://reviews.llvm.org/rL325288. But I guess that's not possible. Is there a way to find out the host triple used on this buildbot? Off the top of my head I can't think of any reasons why frontend diagnostics would be output for this platform but not others. Thanks for your patience! On Fri, Feb 16, 2018 at 5:31 AM, wrote: > Hi Brian, > > Your change is causing a test failure on the clang-cmake-armv7-a15 bot in > the test Clang::SemaCXX/coroutines.cpp. > > http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15742 > > error: 'error' diagnostics seen but not expected: > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 790: 'operator new' takes > type size_t ('unsigned int') as first parameter > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 806: 'operator new' takes > type size_t ('unsigned int') as first parameter > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 816: 'operator new' takes > type size_t ('unsigned int') as first parameter > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 839: 'operator new' takes > type size_t ('unsigned int') as first parameter > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 856: 'operator new' takes > type size_t ('unsigned int') as first parameter > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 872: 'operator new' takes > type size_t ('unsigned int') as first parameter > error: 'note' diagnostics expected but not seen: > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 816 (directive at > /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp:815): candidate function not > viable: requires 2 arguments, but 1 was provided > File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp Line 839 (directive at > /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/ > tools/clang/test/SemaCXX/coroutines.cpp:838): candidate function not > viable: requires 4 arguments, but 1 was provided > 8 errors generated. > > Can you take a look? > > Douglas Yung > > > -Original Message- > > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf > Of > > Brian Gesiak via cfe-commits > > Sent: Thursday, February 15, 2018 12:37 > > To: cfe-commits@lists.llvm.org > > Subject: r325291 - [Coroutines] Use allocator overload when available > > > > Author: modocache > > Date: Thu Feb 15 12:37:22 2018 > > New Revision: 325291 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=325291&view=rev > > Log: > > [Coroutines] Use allocator overload when available > > > > Summary: > > Depends on https://reviews.llvm.org/D42605. > > > > An implementation of the behavior described in > `[dcl.fct.def.coroutine]/7`: > > when a promise type overloads `operator new` using a "placement new" > > that takes the same argument types as the coroutine function, that > overload is > > used when allocating the coroutine frame. > > > > Simply passing references to the coroutine function parameters directly > to > > `operator new` results in invariant violations in LLVM's coroutine > splitting > > pass, so this implementation modifies Clang codegen to produce allocator- > > specific alloc/store/loads for each parameter being forwarded to the > > allocator. > > > > Test Plan: `check-clang` > > > > Reviewers: rsmith, GorNishanov, eric_niebler > > > > Reviewed By: GorNishanov > > > > Subscribers: lewissbaker, EricWF, cfe-commits > > > > Differential Revision: https://reviews.llvm.org/D42606 > > > > Modified: > > cfe/trunk/lib/Sema/SemaCoroutine.cpp > > cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp > > cfe/trunk/test/CodeGenCoroutines/coro-gro-nrvo.cpp > > cfe/trunk/test/CodeGenCoroutines/coro-params.cpp > > cfe/trunk/test/SemaCXX/coroutines.cpp > > > > Modified: cfe/trunk/lib/Sema/SemaCorou
Re: r325291 - [Coroutines] Use allocator overload when available
Ah I'm sorry, I've reproduced this with a `-triple armeb-none-eabi` argument. Douglas, do you mind if I fix forward? - Brian On Fri, Feb 16, 2018 at 8:55 AM, Brian Gesiak wrote: > Hi Douglas, thanks for letting me know. I'm looking into this now. > > At first these error messages made me think https://reviews.llvm.org/ > rL325291 was merged in, but not https://reviews.llvm.org/rL325288. But I > guess that's not possible. > > Is there a way to find out the host triple used on this buildbot? Off the > top of my head I can't think of any reasons why frontend diagnostics would > be output for this platform but not others. > > Thanks for your patience! > > > On Fri, Feb 16, 2018 at 5:31 AM, wrote: > >> Hi Brian, >> >> Your change is causing a test failure on the clang-cmake-armv7-a15 bot in >> the test Clang::SemaCXX/coroutines.cpp. >> >> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15742 >> >> error: 'error' diagnostics seen but not expected: >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 790: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 806: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 816: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 839: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 856: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 872: 'operator new' takes type >> size_t ('unsigned int') as first parameter >> error: 'note' diagnostics expected but not seen: >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 816 (directive at >> /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp:815): candidate function not viable: >> requires 2 arguments, but 1 was provided >> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp Line 839 (directive at >> /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >> /clang/test/SemaCXX/coroutines.cpp:838): candidate function not viable: >> requires 4 arguments, but 1 was provided >> 8 errors generated. >> >> Can you take a look? >> >> Douglas Yung >> >> > -Original Message- >> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On >> Behalf Of >> > Brian Gesiak via cfe-commits >> > Sent: Thursday, February 15, 2018 12:37 >> > To: cfe-commits@lists.llvm.org >> > Subject: r325291 - [Coroutines] Use allocator overload when available >> > >> > Author: modocache >> > Date: Thu Feb 15 12:37:22 2018 >> > New Revision: 325291 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=325291&view=rev >> > Log: >> > [Coroutines] Use allocator overload when available >> > >> > Summary: >> > Depends on https://reviews.llvm.org/D42605. >> > >> > An implementation of the behavior described in >> `[dcl.fct.def.coroutine]/7`: >> > when a promise type overloads `operator new` using a "placement new" >> > that takes the same argument types as the coroutine function, that >> overload is >> > used when allocating the coroutine frame. >> > >> > Simply passing references to the coroutine function parameters directly >> to >> > `operator new` results in invariant violations in LLVM's coroutine >> splitting >> > pass, so this implementation modifies Clang codegen to produce >> allocator- >> > specific alloc/store/loads for each parameter being forwarded to the >> > allocator. >> > >> > Test Plan: `check-clang` >> > >> > Reviewers: rsmith,
r325342 - [Coroutines] Use target-agnostic size_t in test
Author: modocache Date: Fri Feb 16 06:11:27 2018 New Revision: 325342 URL: http://llvm.org/viewvc/llvm-project?rev=325342&view=rev Log: [Coroutines] Use target-agnostic size_t in test Summary: Fix a test failure on ARM hosts that was caused by a difference in the type of size_t, by using a target-agnostic definiton. Test Plan: ``` clang -cc1 -internal-isystem build/lib/clang/7.0.0/include -nostdsysteminc \ -std=c++14 -fcoroutines-ts -verify clang/test/SemaCXX/coroutines.cpp \ -fcxx-exceptions -fexceptions \ -triple armeb-none-eabi ``` Modified: cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=325342&r1=325341&r2=325342&view=diff == --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Fri Feb 16 06:11:27 2018 @@ -787,7 +787,7 @@ struct good_promise_custom_new_operator suspend_always final_suspend(); void return_void(); void unhandled_exception(); - void *operator new(unsigned long, double, float, int); + void *operator new(SizeT, double, float, int); }; coro @@ -803,7 +803,7 @@ struct good_promise_nonstatic_member_cus suspend_always final_suspend(); void return_void(); void unhandled_exception(); - void *operator new(unsigned long, coroutine_nonstatic_member_struct &, double); + void *operator new(SizeT, coroutine_nonstatic_member_struct &, double); }; struct bad_promise_nonstatic_member_mismatched_custom_new_operator { @@ -813,7 +813,7 @@ struct bad_promise_nonstatic_member_mism void return_void(); void unhandled_exception(); // expected-note@+1 {{candidate function not viable: requires 2 arguments, but 1 was provided}} - void *operator new(unsigned long, double); + void *operator new(SizeT, double); }; struct coroutine_nonstatic_member_struct { @@ -836,7 +836,7 @@ struct bad_promise_mismatched_custom_new void return_void(); void unhandled_exception(); // expected-note@+1 {{candidate function not viable: requires 4 arguments, but 1 was provided}} - void *operator new(unsigned long, double, float, int); + void *operator new(SizeT, double, float, int); }; coro @@ -853,7 +853,7 @@ struct bad_promise_throwing_custom_new_o void return_void(); void unhandled_exception(); // expected-error@+1 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}} - void *operator new(unsigned long, double, float, int); + void *operator new(SizeT, double, float, int); }; coro @@ -869,7 +869,7 @@ struct good_promise_noexcept_custom_new_ suspend_always final_suspend(); void return_void(); void unhandled_exception(); - void *operator new(unsigned long, double, float, int) noexcept; + void *operator new(SizeT, double, float, int) noexcept; }; coro ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r325291 - [Coroutines] Use allocator overload when available
This should be fixed in https://reviews.llvm.org/rL325342. Thanks for your help! - Brian On Fri, Feb 16, 2018 at 9:07 AM, Brian Gesiak wrote: > Ah I'm sorry, I've reproduced this with a `-triple armeb-none-eabi` > argument. Douglas, do you mind if I fix forward? > > - Brian > > On Fri, Feb 16, 2018 at 8:55 AM, Brian Gesiak wrote: > >> Hi Douglas, thanks for letting me know. I'm looking into this now. >> >> At first these error messages made me think >> https://reviews.llvm.org/rL325291 was merged in, but not >> https://reviews.llvm.org/rL325288. But I guess that's not possible. >> >> Is there a way to find out the host triple used on this buildbot? Off the >> top of my head I can't think of any reasons why frontend diagnostics would >> be output for this platform but not others. >> >> Thanks for your patience! >> >> >> On Fri, Feb 16, 2018 at 5:31 AM, wrote: >> >>> Hi Brian, >>> >>> Your change is causing a test failure on the clang-cmake-armv7-a15 bot >>> in the test Clang::SemaCXX/coroutines.cpp. >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15742 >>> >>> error: 'error' diagnostics seen but not expected: >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 790: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 806: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 816: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 839: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 856: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 872: 'operator new' takes type >>> size_t ('unsigned int') as first parameter >>> error: 'note' diagnostics expected but not seen: >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 816 (directive at >>> /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp:815): candidate function not viable: >>> requires 2 arguments, but 1 was provided >>> File /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp Line 839 (directive at >>> /home/buildslave/buildslave/clang-cmake-armv7-a15/llvm/tools >>> /clang/test/SemaCXX/coroutines.cpp:838): candidate function not viable: >>> requires 4 arguments, but 1 was provided >>> 8 errors generated. >>> >>> Can you take a look? >>> >>> Douglas Yung >>> >>> > -Original Message- >>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On >>> Behalf Of >>> > Brian Gesiak via cfe-commits >>> > Sent: Thursday, February 15, 2018 12:37 >>> > To: cfe-commits@lists.llvm.org >>> > Subject: r325291 - [Coroutines] Use allocator overload when available >>> > >>> > Author: modocache >>> > Date: Thu Feb 15 12:37:22 2018 >>> > New Revision: 325291 >>> > >>> > URL: http://llvm.org/viewvc/llvm-project?rev=325291&view=rev >>> > Log: >>> > [Coroutines] Use allocator overload when available >>> > >>> > Summary: >>> > Depends on https://reviews.llvm.org/D42605. >>> > >>> > An implementation of the behavior described in >>> `[dcl.fct.def.coroutine]/7`: >>> > when a promise type overloads `operator new` using a "placement new" >>> > that takes the same argument types as the coroutine function, that >>> overload is >>> > used when allocating the coroutine frame. >>>
r306079 - [Frontend] 'Show hotness' can be used with a sampling profile
Author: modocache Date: Thu Jun 22 21:38:45 2017 New Revision: 306079 URL: http://llvm.org/viewvc/llvm-project?rev=306079&view=rev Log: [Frontend] 'Show hotness' can be used with a sampling profile Summary: Prior to this change, using `-fdiagnostics-show-hotness` with a sampling profile specified via `-fprofile-sample-use=` would result in the Clang frontend emitting a warning: "argument '-fdiagnostics-show-hotness' requires profile-guided optimization information". Of course, a sampling profile *is* profile-guided optimization information, so the warning is misleading. Furthermore, despite the warning, hotness was displayed based on the data in the sampling profile. Prevent the warning from being emitted when a sampling profile is used, and add a test that verifies this. Reviewers: anemet, davidxl Reviewed By: davidxl Subscribers: danielcdh, cfe-commits Differential Revision: https://reviews.llvm.org/D34082 Added: cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=306079&r1=306078&r2=306079&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 22 21:38:45 2017 @@ -892,14 +892,18 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.DiagnosticsWithHotness = Args.hasArg(options::OPT_fdiagnostics_show_hotness); + bool UsingSampleProfile = !Opts.SampleProfileFile.empty(); + if (Opts.DiagnosticsWithHotness && - Opts.getProfileUse() == CodeGenOptions::ProfileNone) + Opts.getProfileUse() == CodeGenOptions::ProfileNone && + !UsingSampleProfile) { Diags.Report(diag::warn_drv_fdiagnostics_show_hotness_requires_pgo); + } // If the user requested to use a sample profile for PGO, then the // backend will need to track source location information so the profile // can be incorporated into the IR. - if (!Opts.SampleProfileFile.empty()) + if (UsingSampleProfile) NeedLocTracking = true; // If the user requested a flag that requires source locations available in Added: cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext?rev=306079&view=auto == --- cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext (added) +++ cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext Thu Jun 22 21:38:45 2017 @@ -0,0 +1,7 @@ +foo:0:0 + 0: 0 +bar:29:29 + 6: foo:0 +main:0:0 + 0: 0 bar:0 + Modified: cfe/trunk/test/Frontend/optimization-remark-with-hotness.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-with-hotness.c?rev=306079&r1=306078&r2=306079&view=diff == --- cfe/trunk/test/Frontend/optimization-remark-with-hotness.c (original) +++ cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Thu Jun 22 21:38:45 2017 @@ -1,11 +1,21 @@ +// Generate instrumentation and sampling profile data. // RUN: llvm-profdata merge \ -// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \ +// RUN: %S/Inputs/optimization-remark-with-hotness.proftext \ // RUN: -o %t.profdata +// RUN: llvm-profdata merge -sample \ +// RUN: %S/Inputs/optimization-remark-with-hotness-sample.proftext \ +// RUN: -o %t-sample.profdata +// // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ // RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ // RUN: -fprofile-instrument-use-path=%t.profdata -Rpass=inline \ // RUN: -Rpass-analysis=inline -Rpass-missed=inline \ // RUN: -fdiagnostics-show-hotness -verify +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name \ +// RUN: optimization-remark-with-hotness.c %s -emit-llvm-only \ +// RUN: -fprofile-sample-use=%t-sample.profdata -Rpass=inline \ +// RUN: -Rpass-analysis=inline -Rpass-missed=inline \ +// RUN: -fdiagnostics-show-hotness -verify // The clang version of the previous test. // RUN: %clang -target x86_64-apple-macosx10.9 %s -c -emit-llvm -o /dev/null \ // RUN: -fprofile-instr-use=%t.profdata -Rpass=inline \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321917 - [Driver] Suggest correctly spelled driver options
Author: modocache Date: Fri Jan 5 16:25:40 2018 New Revision: 321917 URL: http://llvm.org/viewvc/llvm-project?rev=321917&view=rev Log: [Driver] Suggest correctly spelled driver options Summary: Depends on https://reviews.llvm.org/D41732. Utilities such as `opt`, when invoked with arguments that are very nearly spelled correctly, suggest the correctly spelled options: ``` bin/opt -hel opt: Unknown command line argument '-hel'. Try: 'bin/opt -help' opt: Did you mean '-help'? ``` Clang, on the other hand, prior to this commit, does not: ``` bin/clang -hel clang-6.0: error: unknown argument: '-hel' ``` This commit makes use of the new libLLVMOption API from https://reviews.llvm.org/D41732 in order to provide correct suggestions: ``` bin/clang -hel clang-6.0: error: unknown argument: '-hel', did you mean '-help'? ``` Test Plan: `check-clang` Reviewers: yamaguchi, v.g.vassilev, teemperor, ruiu, bruno Reviewed By: bruno Subscribers: bruno, jroelofs, cfe-commits Differential Revision: https://reviews.llvm.org/D41733 Added: cfe/trunk/test/Driver/unsupported-option.c cfe/trunk/test/Frontend/unknown-arg.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Driver/unknown-arg.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=321917&r1=321916&r2=321917&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jan 5 16:25:40 2018 @@ -11,6 +11,8 @@ let Component = "Driver" in { def err_drv_no_such_file : Error<"no such file or directory: '%0'">; def err_drv_unsupported_opt : Error<"unsupported option '%0'">; +def err_drv_unsupported_opt_with_suggestion + : Error<"unsupported option '%0', did you mean '%1'?">; def err_drv_unsupported_opt_for_target : Error< "unsupported option '%0' for target '%1'">; def err_drv_unsupported_option_argument : Error< @@ -135,9 +137,14 @@ def err_arch_unsupported_isa def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; def err_drv_unknown_argument : Error<"unknown argument: '%0'">; +def err_drv_unknown_argument_with_suggestion + : Error<"unknown argument '%0', did you mean '%1'?">; def warn_drv_unknown_argument_clang_cl : Warning< "unknown argument ignored in clang-cl: '%0'">, InGroup; +def warn_drv_unknown_argument_clang_cl_with_suggestion : Warning< + "unknown argument ignored in clang-cl '%0' (did you mean '%1'?)">, + InGroup; def warn_drv_ycyu_no_arg_clang_cl : Warning< "support for '%0' without a filename not implemented yet; flag ignored">, Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=321917&r1=321916&r2=321917&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 5 16:25:40 2018 @@ -188,9 +188,19 @@ InputArgList Driver::ParseArgStrings(Arr // Check for unsupported options. for (const Arg *A : Args) { if (A->getOption().hasFlag(options::Unsupported)) { - Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args); - ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt, -SourceLocation()) > + unsigned DiagID; + auto ArgString = A->getAsString(Args); + std::string Nearest; + if (getOpts().findNearest( +ArgString, Nearest, IncludedFlagsBitmask, +ExcludedFlagsBitmask | options::Unsupported) > 1) { +DiagID = diag::err_drv_unsupported_opt; +Diag(DiagID) << ArgString; + } else { +DiagID = diag::err_drv_unsupported_opt_with_suggestion; +Diag(DiagID) << ArgString << Nearest; + } + ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) > DiagnosticsEngine::Warning; continue; } @@ -205,11 +215,20 @@ InputArgList Driver::ParseArgStrings(Arr } for (const Arg *A : Args.filtered(options::OPT_UNKNOWN)) { -auto ID = IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl - : diag::err_drv_unknown_argument; - -Diags.Report(ID) << A->getAsString(Args); -ContainsError |= Diags.getDiagnosticLevel(ID, SourceLocation()) > +unsigned DiagID; +auto ArgString = A->getAsString(Args); +std::string Nearest; +if (getOpts().findNearest( + ArgString, Nearest, IncludedFlagsBitmask, ExcludedFlagsBitmask) > 1) { + DiagID = IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl + : diag::err_drv_unknown_argument
r322118 - [Frontend] Remove unused FileMgr in pp arg parse
Author: modocache Date: Tue Jan 9 13:26:47 2018 New Revision: 322118 URL: http://llvm.org/viewvc/llvm-project?rev=322118&view=rev Log: [Frontend] Remove unused FileMgr in pp arg parse Summary: A FIXME added 8 years ago (2010) in https://reviews.llvm.org/rL118203 mentioned that a FileManager should not need to be used when parsing preprocessor arguments. In fact, its only use was removed 6 years ago (2012), in https://reviews.llvm.org/rL166452. Remove the unused variable and the obsolete FIXME. Test Plan: `check-clang` Reviewers: v.g.vassilev Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41867 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=322118&r1=322117&r2=322118&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jan 9 13:26:47 2018 @@ -2618,7 +2618,6 @@ static bool isStrictlyPreprocessorAction } static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, - FileManager &FileMgr, DiagnosticsEngine &Diags, frontend::ActionKind Action) { using namespace options; @@ -2840,12 +2839,7 @@ bool CompilerInvocation::CreateFromArgs( !LangOpts.Sanitize.has(SanitizerKind::Address) && !LangOpts.Sanitize.has(SanitizerKind::Memory); - // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of - // PCH file and find the original header name. Remove the need to do that in - // ParsePreprocessorArgs and remove the FileManager - // parameters from the function and the "FileManager.h" #include. - FileManager FileMgr(Res.getFileSystemOpts()); - ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, FileMgr, Diags, + ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, Diags, Res.getFrontendOpts().ProgramAction); ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), Args, Res.getFrontendOpts().ProgramAction); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322220 - [Driver] Test for correct '--version' suggestion
Author: modocache Date: Wed Jan 10 12:23:45 2018 New Revision: 30 URL: http://llvm.org/viewvc/llvm-project?rev=30&view=rev Log: [Driver] Test for correct '--version' suggestion Summary: The `llvm::OptTable::findNearest` bug fixed in https://reviews.llvm.org/D41873 manifested itself as the following erroneous message when invoking Clang: ``` clang -version clang-6.0: error: unknown argument '-version', did you mean 'version'? ``` Add a test to catch any future regressions to the now correct behavior, which asks "did you mean '--version'?". Test Plan: `check-clang` Reviewers: v.g.vassilev, teemperor, ruiu, jroelofs, yamaguchi Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41912 Modified: cfe/trunk/test/Driver/unknown-arg.c Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=30&r1=322219&r2=30&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Wed Jan 10 12:23:45 2018 @@ -1,6 +1,6 @@ // RUN: not %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -### 2>&1 | \ // RUN: FileCheck %s -// RUN: not %clang %s -stdlibs=foo -hell -### 2>&1 | \ +// RUN: not %clang %s -stdlibs=foo -hell -version -### 2>&1 | \ // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN // RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -### -c -- %s 2>&1 | \ // RUN: FileCheck %s --check-prefix=CL @@ -22,6 +22,7 @@ // CHECK: error: unknown argument: '-funknown-to-clang-option' // DID-YOU-MEAN: error: unknown argument '-stdlibs=foo', did you mean '-stdlib=foo'? // DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? +// DID-YOU-MEAN: error: unknown argument '-version', did you mean '--version'? // CL: warning: unknown argument ignored in clang-cl: '-cake-is-lie' // CL: warning: unknown argument ignored in clang-cl: '-%0' // CL: warning: unknown argument ignored in clang-cl: '-%d' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r335420 - [Sema] isValidCoroutineContext FIXME and citations
Author: modocache Date: Sat Jun 23 11:01:02 2018 New Revision: 335420 URL: http://llvm.org/viewvc/llvm-project?rev=335420&view=rev Log: [Sema] isValidCoroutineContext FIXME and citations Summary: Add citations to the Coroutines TS to the `isValidCoroutineContext` function, as well as a FIXME and test for [expr.await]p2, which states a co_await expression cannot be used in a default argument. Test Plan: check-clang Reviewers: GorNishanov, EricWF Reviewed By: GorNishanov Subscribers: rsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D48519 Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=335420&r1=335419&r2=335420&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sat Jun 23 11:01:02 2018 @@ -9,6 +9,9 @@ // // This file implements semantic analysis for C++ Coroutines. // +// This file contains references to sections of the Coroutines TS, which +// can be found at http://wg21.link/coroutines. +// //===--===// #include "CoroutineStmtBuilder.h" @@ -196,13 +199,25 @@ static QualType lookupCoroutineHandleTyp static bool isValidCoroutineContext(Sema &S, SourceLocation Loc, StringRef Keyword) { - // 'co_await' and 'co_yield' are not permitted in unevaluated operands. + // 'co_await' and 'co_yield' are not permitted in unevaluated operands, + // such as subexpressions of \c sizeof. + // + // [expr.await]p2, emphasis added: "An await-expression shall appear only in + // a *potentially evaluated* expression within the compound-statement of a + // function-body outside of a handler [...] A context within a function where + // an await-expression can appear is called a suspension context of the + // function." And per [expr.yield]p1: "A yield-expression shall appear only + // within a suspension context of a function." if (S.isUnevaluatedContext()) { S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword; return false; } - // Any other usage must be within a function. + // Per [expr.await]p2, any other usage must be within a function. + // FIXME: This also covers [expr.await]p2: "An await-expression shall not + // appear in a default argument." But the diagnostic QoI here could be + // improved to inform the user that default arguments specifically are not + // allowed. auto *FD = dyn_cast(S.CurContext); if (!FD) { S.Diag(Loc, isa(S.CurContext) @@ -233,22 +248,37 @@ static bool isValidCoroutineContext(Sema // Diagnose when a constructor, destructor, copy/move assignment operator, // or the function 'main' are declared as a coroutine. auto *MD = dyn_cast(FD); + // [class.ctor]p6: "A constructor shall not be a coroutine." if (MD && isa(MD)) return DiagInvalid(DiagCtor); + // [class.dtor]p17: "A destructor shall not be a coroutine." else if (MD && isa(MD)) return DiagInvalid(DiagDtor); + // N4499 [special]p6: "A special member function shall not be a coroutine." + // Per C++ [special]p1, special member functions are the "default constructor, + // copy constructor and copy assignment operator, move constructor and move + // assignment operator, and destructor." else if (MD && MD->isCopyAssignmentOperator()) return DiagInvalid(DiagCopyAssign); else if (MD && MD->isMoveAssignmentOperator()) return DiagInvalid(DiagMoveAssign); + // [basic.start.main]p3: "The function main shall not be a coroutine." else if (FD->isMain()) return DiagInvalid(DiagMain); // Emit a diagnostics for each of the following conditions which is not met. + // [expr.const]p2: "An expression e is a core constant expression unless the + // evaluation of e [...] would evaluate one of the following expressions: + // [...] an await-expression [...] a yield-expression." if (FD->isConstexpr()) DiagInvalid(DiagConstexpr); + // [dcl.spec.auto]p15: "A function declared with a return type that uses a + // placeholder type shall not be a coroutine." if (FD->getReturnType()->isUndeducedType()) DiagInvalid(DiagAutoRet); + // [dcl.fct.def.coroutine]p1: "The parameter-declaration-clause of the + // coroutine shall not terminate with an ellipsis that is not part of a + // parameter-declaration." if (FD->isVariadic()) DiagInvalid(DiagVarargs); Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=335420&r1=335419&r2=335420&view=diff == --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Sat
r335422 - [Coroutines] Less IR for noexcept await_resume
Author: modocache Date: Sat Jun 23 11:57:26 2018 New Revision: 335422 URL: http://llvm.org/viewvc/llvm-project?rev=335422&view=rev Log: [Coroutines] Less IR for noexcept await_resume Summary: In his review of https://reviews.llvm.org/D45860, @GorNishanov suggested avoiding generating additional exception-handling IR in the case that the resume function was marked as 'noexcept', and exceptions could not occur. This implements that suggestion. Test Plan: `check-clang` Reviewers: GorNishanov, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits, GorNishanov Differential Revision: https://reviews.llvm.org/D47673 Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=335422&r1=335421&r2=335422&view=diff == --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Sat Jun 23 11:57:26 2018 @@ -130,6 +130,16 @@ static SmallString<32> buildSuspendPrefi return Prefix; } +static bool memberCallExpressionCanThrow(const Expr *E) { + if (const auto *CE = dyn_cast(E)) +if (const auto *Proto = +CE->getMethodDecl()->getType()->getAs()) + if (isNoexceptExceptionSpec(Proto->getExceptionSpecType()) && + Proto->canThrow() == CT_Cannot) +return false; + return true; +} + // Emit suspend expression which roughly looks like: // // auto && x = CommonExpr(); @@ -217,8 +227,12 @@ static LValueOrRValue emitSuspendExpress // Emit await_resume expression. CGF.EmitBlock(ReadyBlock); + + // Exception handling requires additional IR. If the 'await_resume' function + // is marked as 'noexcept', we avoid generating this additional IR. CXXTryStmt *TryStmt = nullptr; - if (Coro.ExceptionHandler && Kind == AwaitKind::Init) { + if (Coro.ExceptionHandler && Kind == AwaitKind::Init && + memberCallExpressionCanThrow(S.getResumeExpr())) { Coro.ResumeEHVar = CGF.CreateTempAlloca(Builder.getInt1Ty(), Prefix + Twine("resume.eh")); Builder.CreateFlagStore(true, Coro.ResumeEHVar); @@ -625,12 +639,20 @@ void CodeGenFunction::EmitCoroutineBody( CurCoro.Data->CurrentAwaitKind = AwaitKind::Normal; if (CurCoro.Data->ExceptionHandler) { - BasicBlock *BodyBB = createBasicBlock("coro.resumed.body"); - BasicBlock *ContBB = createBasicBlock("coro.resumed.cont"); - Value *SkipBody = - Builder.CreateFlagLoad(CurCoro.Data->ResumeEHVar, "coro.resumed.eh"); - Builder.CreateCondBr(SkipBody, ContBB, BodyBB); - EmitBlock(BodyBB); + // If we generated IR to record whether an exception was thrown from + // 'await_resume', then use that IR to determine whether the coroutine + // body should be skipped. + // If we didn't generate the IR (perhaps because 'await_resume' was marked + // as 'noexcept'), then we skip this check. + BasicBlock *ContBB = nullptr; + if (CurCoro.Data->ResumeEHVar) { +BasicBlock *BodyBB = createBasicBlock("coro.resumed.body"); +ContBB = createBasicBlock("coro.resumed.cont"); +Value *SkipBody = Builder.CreateFlagLoad(CurCoro.Data->ResumeEHVar, + "coro.resumed.eh"); +Builder.CreateCondBr(SkipBody, ContBB, BodyBB); +EmitBlock(BodyBB); + } auto Loc = S.getLocStart(); CXXCatchStmt Catch(Loc, /*exDecl=*/nullptr, @@ -642,7 +664,8 @@ void CodeGenFunction::EmitCoroutineBody( emitBodyAndFallthrough(*this, S, TryStmt->getTryBlock()); ExitCXXTryStmt(*TryStmt); - EmitBlock(ContBB); + if (ContBB) +EmitBlock(ContBB); } else { emitBodyAndFallthrough(*this, S, S.getBody()); Modified: cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp?rev=335422&r1=335421&r2=335422&view=diff == --- cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp (original) +++ cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp Sat Jun 23 11:57:26 2018 @@ -18,9 +18,9 @@ struct throwing_awaitable { void await_resume() { throw 42; } }; -struct task { +struct throwing_task { struct promise_type { -task get_return_object() { return task{}; } +auto get_return_object() { return throwing_task{}; } auto initial_suspend() { return throwing_awaitable{}; } auto final_suspend() { return coro::suspend_never{}; } void return_void() {} @@ -29,7 +29,7 @@ struct task { }; // CHECK-LABEL: define void @_Z1fv() -task f() { +throwing_task f() { // A variable RESUMETHREW is used to keep track of whether the body // of 'await_resume' threw an exceptio
[clang-tools-extra] r350916 - Adapt to CXXMethodDecl::getThisType change (NFC)
Author: modocache Date: Thu Jan 10 18:12:31 2019 New Revision: 350916 URL: http://llvm.org/viewvc/llvm-project?rev=350916&view=rev Log: Adapt to CXXMethodDecl::getThisType change (NFC) Summary: https://reviews.llvm.org/D56509 changed the API of the CXXMethodDecl::getThisType method. Adapt to the change (and re-apply clang-format) to fix the clang-tidy build. Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp?rev=350916&r1=350915&r2=350916&view=diff == --- clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/bugprone/ParentVirtualCallCheck.cpp Thu Jan 10 18:12:31 2019 @@ -50,9 +50,7 @@ static BasesVector getParentsByGrandPare // TypePtr is the nearest base class to ThisClass between ThisClass and // GrandParent, where MemberDecl is overridden. TypePtr is the class the // check proposes to fix to. -const Type *TypePtr = -ActualMemberDecl->getThisType(ActualMemberDecl->getASTContext()) -.getTypePtr(); +const Type *TypePtr = ActualMemberDecl->getThisType().getTypePtr(); const CXXRecordDecl *RecordDeclType = TypePtr->getPointeeCXXRecordDecl(); assert(RecordDeclType && "TypePtr is not a pointer to CXXRecordDecl!"); if (RecordDeclType->getCanonicalDecl()->isDerivedFrom(&GrandParent)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r346074 - [coroutines] Fix fallthrough warning on try/catch
Author: modocache Date: Sat Nov 3 15:35:17 2018 New Revision: 346074 URL: http://llvm.org/viewvc/llvm-project?rev=346074&view=rev Log: [coroutines] Fix fallthrough warning on try/catch Summary: The test case added in this diff would incorrectly warn that control flow may fall through without returning. Here's a standalone example: https://godbolt.org/z/dCwXEi The same program, but using `return` instead of `co_return`, does not produce a warning: https://godbolt.org/z/mVldqQ The issue was in how Clang analysis would structure its representation of the control-flow graph. Specifically, when constructing the CFG, `CFGBuilder::Visit` had special handling of a `ReturnStmt`, in which it would place object destructors in the same CFG block as a `return` statement, immediately after it. Doing so would allow the logic in `lib/Sema/AnalysisBasedWarning.cpp` `CheckFallThrough` to work properly in the program that used `return`, correctly determining that no "plain edges" preceded the exit block of the function. Because a `co_return` statement would not enjoy the same treatment when it was being built into the control-flow graph, object destructors would not be placed in the same CFG block as the `co_return`, thus resulting in a "plain edge" preceding the exit block of the function, and so the warning logic would be triggered. Add special casing for `co_return` to Clang analysis, thereby remedying the mistaken warning. Test Plan: `check-clang` Reviewers: GorNishanov, tks2103, rsmith Reviewed By: GorNishanov Subscribers: EricWF, lewissbaker, cfe-commits Differential Revision: https://reviews.llvm.org/D54075 Added: cfe/trunk/test/SemaCXX/coreturn-eh.cpp Modified: cfe/trunk/lib/Analysis/CFG.cpp Modified: cfe/trunk/lib/Analysis/CFG.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=346074&r1=346073&r2=346074&view=diff == --- cfe/trunk/lib/Analysis/CFG.cpp (original) +++ cfe/trunk/lib/Analysis/CFG.cpp Sat Nov 3 15:35:17 2018 @@ -571,7 +571,7 @@ private: CFGBlock *VisitObjCForCollectionStmt(ObjCForCollectionStmt *S); CFGBlock *VisitObjCMessageExpr(ObjCMessageExpr *E, AddStmtChoice asc); CFGBlock *VisitPseudoObjectExpr(PseudoObjectExpr *E); - CFGBlock *VisitReturnStmt(ReturnStmt *R); + CFGBlock *VisitReturnStmt(Stmt *S); CFGBlock *VisitSEHExceptStmt(SEHExceptStmt *S); CFGBlock *VisitSEHFinallyStmt(SEHFinallyStmt *S); CFGBlock *VisitSEHLeaveStmt(SEHLeaveStmt *S); @@ -2147,7 +2147,8 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, Ad return VisitPseudoObjectExpr(cast(S)); case Stmt::ReturnStmtClass: - return VisitReturnStmt(cast(S)); +case Stmt::CoreturnStmtClass: + return VisitReturnStmt(S); case Stmt::SEHExceptStmtClass: return VisitSEHExceptStmt(cast(S)); @@ -2877,22 +2878,24 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt return LastBlock; } -CFGBlock *CFGBuilder::VisitReturnStmt(ReturnStmt *R) { +CFGBlock *CFGBuilder::VisitReturnStmt(Stmt *S) { // If we were in the middle of a block we stop processing that block. // - // NOTE: If a "return" appears in the middle of a block, this means that the - // code afterwards is DEAD (unreachable). We still keep a basic block - // for that code; a simple "mark-and-sweep" from the entry block will be - // able to report such dead blocks. + // NOTE: If a "return" or "co_return" appears in the middle of a block, this + // means that the code afterwards is DEAD (unreachable). We still keep + // a basic block for that code; a simple "mark-and-sweep" from the entry + // block will be able to report such dead blocks. + assert(isa(S) || isa(S)); // Create the new block. Block = createBlock(false); - addAutomaticObjHandling(ScopePos, LocalScope::const_iterator(), R); + addAutomaticObjHandling(ScopePos, LocalScope::const_iterator(), S); - findConstructionContexts( - ConstructionContextLayer::create(cfg->getBumpVectorContext(), R), - R->getRetValue()); + if (auto *R = dyn_cast(S)) +findConstructionContexts( +ConstructionContextLayer::create(cfg->getBumpVectorContext(), R), +R->getRetValue()); // If the one of the destructors does not return, we already have the Exit // block as a successor. @@ -2901,7 +2904,7 @@ CFGBlock *CFGBuilder::VisitReturnStmt(Re // Add the return statement to the block. This may create new blocks if R // contains control-flow (short-circuit operations). - return VisitStmt(R, AddStmtChoice::AlwaysAdd); + return VisitStmt(S, AddStmtChoice::AlwaysAdd); } CFGBlock *CFGBuilder::VisitSEHExceptStmt(SEHExceptStmt *ES) { Added: cfe/trunk/test/SemaCXX/coreturn-eh.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coreturn-eh.cpp?rev=346074&view=auto == --- cfe/trunk/test/SemaCXX/core
r356296 - [coroutines][PR40978] Emit error for co_yield within catch block
Author: modocache Date: Fri Mar 15 13:25:49 2019 New Revision: 356296 URL: http://llvm.org/viewvc/llvm-project?rev=356296&view=rev Log: [coroutines][PR40978] Emit error for co_yield within catch block Summary: As reported in https://bugs.llvm.org/show_bug.cgi?id=40978, it's an error to use the `co_yield` or `co_await` keywords outside of a valid "suspension context" as defined by [expr.await]p2 of http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4775.pdf. Whether or not the current scope was in a function-try-block's (https://en.cppreference.com/w/cpp/language/function-try-block) handler could be determined using scope flag `Scope::FnTryCatchScope`. No such flag existed for a simple C++ catch statement, so this commit adds one. Reviewers: GorNishanov, tks2103, rsmith Reviewed By: GorNishanov Subscribers: EricWF, jdoerfert, cfe-commits, lewissbaker Tags: #clang Differential Revision: https://reviews.llvm.org/D59076 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Scope.h cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/Scope.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356296&r1=356295&r2=356296&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Mar 15 13:25:49 2019 @@ -9251,6 +9251,8 @@ def err_coroutine_objc_method : Error< "Objective-C methods as coroutines are not yet supported">; def err_coroutine_unevaluated_context : Error< "'%0' cannot be used in an unevaluated context">; +def err_coroutine_within_handler : Error< + "'%0' cannot be used in the handler of a try block">; def err_coroutine_outside_function : Error< "'%0' cannot be used outside a function">; def err_coroutine_invalid_func_context : Error< Modified: cfe/trunk/include/clang/Sema/Scope.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=356296&r1=356295&r2=356296&view=diff == --- cfe/trunk/include/clang/Sema/Scope.h (original) +++ cfe/trunk/include/clang/Sema/Scope.h Fri Mar 15 13:25:49 2019 @@ -131,6 +131,9 @@ public: /// We are between inheritance colon and the real class/struct definition scope. ClassInheritanceScope = 0x80, + +/// This is the scope of a C++ catch statement. +CatchScope = 0x100, }; private: Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=356296&r1=356295&r2=356296&view=diff == --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Mar 15 13:25:49 2019 @@ -2260,8 +2260,10 @@ StmtResult Parser::ParseCXXCatchBlock(bo // C++ 3.3.2p3: // The name in a catch exception-declaration is local to the handler and // shall not be redeclared in the outermost block of the handler. - ParseScope CatchScope(this, Scope::DeclScope | Scope::ControlScope | - (FnCatch ? Scope::FnTryCatchScope : 0)); + unsigned ScopeFlags = Scope::DeclScope | Scope::ControlScope | +Scope::CatchScope | +(FnCatch ? Scope::FnTryCatchScope : 0); + ParseScope CatchScope(this, ScopeFlags); // exception-declaration is equivalent to '...' or a parameter-declaration // without default arguments. @@ -2290,7 +2292,7 @@ StmtResult Parser::ParseCXXCatchBlock(bo return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); // FIXME: Possible draft standard bug: attribute-specifier should be allowed? - StmtResult Block(ParseCompoundStatement()); + StmtResult Block(ParseCompoundStatement(/*isStmtExpr=*/false, ScopeFlags)); if (Block.isInvalid()) return Block; Modified: cfe/trunk/lib/Sema/Scope.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=356296&r1=356295&r2=356296&view=diff == --- cfe/trunk/lib/Sema/Scope.cpp (original) +++ cfe/trunk/lib/Sema/Scope.cpp Fri Mar 15 13:25:49 2019 @@ -166,7 +166,9 @@ void Scope::dumpImpl(raw_ostream &OS) co {SEHExceptScope, "SEHExceptScope"}, {SEHFilterScope, "SEHFilterScope"}, {CompoundStmtScope, "CompoundStmtScope"}, - {ClassInheritanceScope, "ClassInheritanceScope"}}; + {ClassInheritanceScope, "ClassInheritanceScope"}, + {CatchScope, "CatchScope"}, + }; for (auto Info : FlagInfo) { if (Flags & Info.first) { Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm
r356774 - Revert "[coroutines][PR40978] Emit error for co_yield within catch block"
Author: modocache Date: Fri Mar 22 09:08:29 2019 New Revision: 356774 URL: http://llvm.org/viewvc/llvm-project?rev=356774&view=rev Log: Revert "[coroutines][PR40978] Emit error for co_yield within catch block" The commit https://reviews.llvm.org/rC356296 is causing a regression in nested catch scopes, https://bugs.llvm.org/show_bug.cgi?id=41171. Revert this change for now in order to un-break that problem report. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Scope.h cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/Scope.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356774&r1=356773&r2=356774&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Mar 22 09:08:29 2019 @@ -9271,8 +9271,6 @@ def err_coroutine_objc_method : Error< "Objective-C methods as coroutines are not yet supported">; def err_coroutine_unevaluated_context : Error< "'%0' cannot be used in an unevaluated context">; -def err_coroutine_within_handler : Error< - "'%0' cannot be used in the handler of a try block">; def err_coroutine_outside_function : Error< "'%0' cannot be used outside a function">; def err_coroutine_invalid_func_context : Error< Modified: cfe/trunk/include/clang/Sema/Scope.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=356774&r1=356773&r2=356774&view=diff == --- cfe/trunk/include/clang/Sema/Scope.h (original) +++ cfe/trunk/include/clang/Sema/Scope.h Fri Mar 22 09:08:29 2019 @@ -131,9 +131,6 @@ public: /// We are between inheritance colon and the real class/struct definition scope. ClassInheritanceScope = 0x80, - -/// This is the scope of a C++ catch statement. -CatchScope = 0x100, }; private: Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=356774&r1=356773&r2=356774&view=diff == --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Mar 22 09:08:29 2019 @@ -2260,10 +2260,8 @@ StmtResult Parser::ParseCXXCatchBlock(bo // C++ 3.3.2p3: // The name in a catch exception-declaration is local to the handler and // shall not be redeclared in the outermost block of the handler. - unsigned ScopeFlags = Scope::DeclScope | Scope::ControlScope | -Scope::CatchScope | -(FnCatch ? Scope::FnTryCatchScope : 0); - ParseScope CatchScope(this, ScopeFlags); + ParseScope CatchScope(this, Scope::DeclScope | Scope::ControlScope | + (FnCatch ? Scope::FnTryCatchScope : 0)); // exception-declaration is equivalent to '...' or a parameter-declaration // without default arguments. @@ -2292,7 +2290,7 @@ StmtResult Parser::ParseCXXCatchBlock(bo return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); // FIXME: Possible draft standard bug: attribute-specifier should be allowed? - StmtResult Block(ParseCompoundStatement(/*isStmtExpr=*/false, ScopeFlags)); + StmtResult Block(ParseCompoundStatement()); if (Block.isInvalid()) return Block; Modified: cfe/trunk/lib/Sema/Scope.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=356774&r1=356773&r2=356774&view=diff == --- cfe/trunk/lib/Sema/Scope.cpp (original) +++ cfe/trunk/lib/Sema/Scope.cpp Fri Mar 22 09:08:29 2019 @@ -166,9 +166,7 @@ void Scope::dumpImpl(raw_ostream &OS) co {SEHExceptScope, "SEHExceptScope"}, {SEHFilterScope, "SEHFilterScope"}, {CompoundStmtScope, "CompoundStmtScope"}, - {ClassInheritanceScope, "ClassInheritanceScope"}, - {CatchScope, "CatchScope"}, - }; + {ClassInheritanceScope, "ClassInheritanceScope"}}; for (auto Info : FlagInfo) { if (Flags & Info.first) { Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=356774&r1=356773&r2=356774&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Fri Mar 22 09:08:29 2019 @@ -185,8 +185,21 @@ static QualType lookupCoroutineHandleTyp static bool isValidCoroutineContext(Sema &S, SourceLocation Loc, StringRef Keyword) { - // [expr.await]p2 dictates that 'co_await' and 'c
r356865 - Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"
Author: modocache Date: Sun Mar 24 17:53:10 2019 New Revision: 356865 URL: http://llvm.org/viewvc/llvm-project?rev=356865&view=rev Log: Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block" Summary: https://reviews.llvm.org/D59076 added a new coroutine error that prevented users from using 'co_await' or 'co_yield' within a exception handler. However, it was reverted in https://reviews.llvm.org/rC356774 because it caused a regression in nested scopes in C++ catch statements, as documented by https://bugs.llvm.org/show_bug.cgi?id=41171. The issue was due to an incorrect use of a `clang::ParseScope`. To fix: 1. Add a regression test for catch statement parsing that mimics the bug report from https://bugs.llvm.org/show_bug.cgi?id=41171. 2. Re-apply the coroutines error patch from https://reviews.llvm.org/D59076, but this time with the correct ParseScope behavior. Reviewers: GorNishanov, tks2103, rsmith, riccibruno, jbulow Reviewed By: riccibruno Subscribers: EricWF, jdoerfert, lewissbaker, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59752 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Scope.h cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/Scope.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp cfe/trunk/test/SemaCXX/exceptions.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=356865&r1=356864&r2=356865&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Mar 24 17:53:10 2019 @@ -9271,6 +9271,8 @@ def err_coroutine_objc_method : Error< "Objective-C methods as coroutines are not yet supported">; def err_coroutine_unevaluated_context : Error< "'%0' cannot be used in an unevaluated context">; +def err_coroutine_within_handler : Error< + "'%0' cannot be used in the handler of a try block">; def err_coroutine_outside_function : Error< "'%0' cannot be used outside a function">; def err_coroutine_invalid_func_context : Error< Modified: cfe/trunk/include/clang/Sema/Scope.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=356865&r1=356864&r2=356865&view=diff == --- cfe/trunk/include/clang/Sema/Scope.h (original) +++ cfe/trunk/include/clang/Sema/Scope.h Sun Mar 24 17:53:10 2019 @@ -131,6 +131,9 @@ public: /// We are between inheritance colon and the real class/struct definition scope. ClassInheritanceScope = 0x80, + +/// This is the scope of a C++ catch statement. +CatchScope = 0x100, }; private: Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=356865&r1=356864&r2=356865&view=diff == --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Sun Mar 24 17:53:10 2019 @@ -2261,7 +2261,8 @@ StmtResult Parser::ParseCXXCatchBlock(bo // The name in a catch exception-declaration is local to the handler and // shall not be redeclared in the outermost block of the handler. ParseScope CatchScope(this, Scope::DeclScope | Scope::ControlScope | - (FnCatch ? Scope::FnTryCatchScope : 0)); + Scope::CatchScope | + (FnCatch ? Scope::FnTryCatchScope : 0)); // exception-declaration is equivalent to '...' or a parameter-declaration // without default arguments. Modified: cfe/trunk/lib/Sema/Scope.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Scope.cpp?rev=356865&r1=356864&r2=356865&view=diff == --- cfe/trunk/lib/Sema/Scope.cpp (original) +++ cfe/trunk/lib/Sema/Scope.cpp Sun Mar 24 17:53:10 2019 @@ -166,7 +166,9 @@ void Scope::dumpImpl(raw_ostream &OS) co {SEHExceptScope, "SEHExceptScope"}, {SEHFilterScope, "SEHFilterScope"}, {CompoundStmtScope, "CompoundStmtScope"}, - {ClassInheritanceScope, "ClassInheritanceScope"}}; + {ClassInheritanceScope, "ClassInheritanceScope"}, + {CatchScope, "CatchScope"}, + }; for (auto Info : FlagInfo) { if (Flags & Info.first) { Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=356865&r1=356864&r2=356865&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sun Mar 24 17:53:10
r343949 - [coro]Pass rvalue reference for named local variable to return_value
Author: modocache Date: Sun Oct 7 20:08:39 2018 New Revision: 343949 URL: http://llvm.org/viewvc/llvm-project?rev=343949&view=rev Log: [coro]Pass rvalue reference for named local variable to return_value Summary: Addressing https://bugs.llvm.org/show_bug.cgi?id=37265. Implements [class.copy]/33 of coroutines TS. When the criteria for elision of a copy/move operation are met, but not for an exception-declaration, and the object to be copied is designated by an lvalue, or when the expression in a return or co_return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression, overload resolution to select the constructor for the copy or the return_value overload to call is first performed as if the object were designated by an rvalue. Patch by Tanoy Sinha! Reviewers: modocache, GorNishanov Reviewed By: modocache, GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51741 Added: cfe/trunk/test/SemaCXX/coroutine-rvo.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=343949&r1=343948&r2=343949&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sun Oct 7 20:08:39 2018 @@ -841,6 +841,19 @@ StmtResult Sema::BuildCoreturnStmt(Sourc E = R.get(); } + // Move the return value if we can + if (E) { +auto NRVOCandidate = this->getCopyElisionCandidate(E->getType(), E, CES_AsIfByStdMove); +if (NRVOCandidate) { + InitializedEntity Entity = + InitializedEntity::InitializeResult(Loc, E->getType(), NRVOCandidate); + ExprResult MoveResult = this->PerformMoveOrCopyInitialization( + Entity, NRVOCandidate, E->getType(), E); + if (MoveResult.get()) +E = MoveResult.get(); +} + } + // FIXME: If the operand is a reference to a variable that's about to go out // of scope, we should treat the operand as an xvalue for this overload // resolution. Added: cfe/trunk/test/SemaCXX/coroutine-rvo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-rvo.cpp?rev=343949&view=auto == --- cfe/trunk/test/SemaCXX/coroutine-rvo.cpp (added) +++ cfe/trunk/test/SemaCXX/coroutine-rvo.cpp Sun Oct 7 20:08:39 2018 @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only + +namespace std::experimental { +template struct coroutine_handle { + coroutine_handle() = default; + static coroutine_handle from_address(void *) noexcept; +}; + +template <> struct coroutine_handle { + static coroutine_handle from_address(void *) noexcept; + coroutine_handle() = default; + template + coroutine_handle(coroutine_handle) noexcept; +}; + +template +struct void_t_imp { + using type = void; +}; +template +using void_t = typename void_t_imp::type; + +template +struct traits_sfinae_base {}; + +template +struct traits_sfinae_base> { + using promise_type = typename T::promise_type; +}; + +template +struct coroutine_traits : public traits_sfinae_base {}; +} + +struct suspend_never { + bool await_ready() noexcept; + void await_suspend(std::experimental::coroutine_handle<>) noexcept; + void await_resume() noexcept; +}; + +struct MoveOnly { + MoveOnly() {}; + MoveOnly(const MoveOnly&) = delete; + MoveOnly(MoveOnly&&) noexcept {}; + ~MoveOnly() {}; +}; + +template +struct task { + struct promise_type { +auto initial_suspend() { return suspend_never{}; } +auto final_suspend() { return suspend_never{}; } +auto get_return_object() { return task{}; } +static void unhandled_exception() {} +void return_value(T&& value) {} + }; +}; + +task f() { + MoveOnly value; + co_return value; +} + +int main() { + f(); + return 0; +} + +// expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r352831 - [SemaCXX] Param diagnostic matches overload logic
Author: modocache Date: Thu Jan 31 19:30:29 2019 New Revision: 352831 URL: http://llvm.org/viewvc/llvm-project?rev=352831&view=rev Log: [SemaCXX] Param diagnostic matches overload logic Summary: Given the following test program: ``` class C { public: int A(int a, int& b); }; int C::A(const int a, int b) { return a * b; } ``` Clang would produce an error message that correctly diagnosed the redeclaration of `C::A` to not match the original declaration (the parameters to the two declarations do not match -- the original takes an `int &` as its 2nd parameter, but the redeclaration takes an `int`). However, it also produced a note diagnostic that inaccurately pointed to the first parameter, claiming that `const int` in the redeclaration did not match the unqualified `int` in the original. The diagnostic is misleading because it has nothing to do with why the program does not compile. The logic for checking for a function overload, in `Sema::FunctionParamTypesAreEqual`, discards cv-qualifiers before checking whether the types are equal. Do the same when producing the overload diagnostic. Reviewers: rsmith Reviewed By: rsmith Subscribers: cpplearner, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57032 Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaCXX/function-redecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=352831&r1=352830&r2=352831&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 31 19:30:29 2019 @@ -5087,7 +5087,7 @@ static bool hasSimilarParameters(ASTCont QualType DefParamTy = Definition->getParamDecl(Idx)->getType(); // The parameter types are identical -if (Context.hasSameType(DefParamTy, DeclParamTy)) +if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy)) continue; QualType DeclParamBaseTy = getCoreType(DeclParamTy); Modified: cfe/trunk/test/SemaCXX/function-redecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/function-redecl.cpp?rev=352831&r1=352830&r2=352831&view=diff == --- cfe/trunk/test/SemaCXX/function-redecl.cpp (original) +++ cfe/trunk/test/SemaCXX/function-redecl.cpp Thu Jan 31 19:30:29 2019 @@ -125,3 +125,9 @@ bool Foo::isGood() { // expected-error { } void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}} } + +struct CVQualFun { + void func(int a, int &b); // expected-note {{type of 2nd parameter of member declaration does not match definition ('int &' vs 'int')}} +}; + +void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'CVQualFun'}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r362348 - [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda
Author: modocache Date: Sun Jun 2 17:47:32 2019 New Revision: 362348 URL: http://llvm.org/viewvc/llvm-project?rev=362348&view=rev Log: [coroutines][PR41909] Don't build dependent coroutine statements for generic lambda Summary: https://bugs.llvm.org/show_bug.cgi?id=41909 describes an issue in which a generic lambda that takes a dependent argument `auto set` causes the template instantiation machinery for coroutine body statements to crash with an ICE. The issue is two-fold: 1. The paths taken by the template instantiator contain several asserts that the coroutine promise must not have a dependent type. 2. The template instantiator unconditionally builds corotuine statements that depend on the promise type, which cannot be dependent. To work around the issue, prevent the template instantiator from building dependent coroutine statements if the coroutine promise type is dependent. Since we only expect this to occur in the case of a generic lambda, limit the workaround behavior to just that case. Reviewers: GorNishanov, EricWF, lewissbaker, tks2103 Reviewed By: GorNishanov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62550 Modified: cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/lib/Sema/TreeTransform.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=362348&r1=362347&r2=362348&view=diff == --- cfe/trunk/lib/Sema/TreeTransform.h (original) +++ cfe/trunk/lib/Sema/TreeTransform.h Sun Jun 2 17:47:32 2019 @@ -7163,13 +7163,22 @@ TreeTransform::TransformCorouti Builder.ReturnValue = Res.get(); if (S->hasDependentPromiseType()) { -assert(!Promise->getType()->isDependentType() && - "the promise type must no longer be dependent"); -assert(!S->getFallthroughHandler() && !S->getExceptionHandler() && - !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && - "these nodes should not have been built yet"); -if (!Builder.buildDependentStatements()) - return StmtError(); +// PR41909: We may find a generic coroutine lambda definition within a +// template function that is being instantiated. In this case, the lambda +// will have a dependent promise type, until it is used in an expression +// that creates an instantiation with a non-dependent promise type. We +// should not assert or build coroutine dependent statements for such a +// generic lambda. +auto *MD = dyn_cast_or_null(FD); +if (!MD || !MD->getParent()->isGenericLambda()) { + assert(!Promise->getType()->isDependentType() && + "the promise type must no longer be dependent"); + assert(!S->getFallthroughHandler() && !S->getExceptionHandler() && + !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && + "these nodes should not have been built yet"); + if (!Builder.buildDependentStatements()) +return StmtError(); +} } else { if (auto *OnFallthrough = S->getFallthroughHandler()) { StmtResult Res = getDerived().TransformStmt(OnFallthrough); Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=362348&r1=362347&r2=362348&view=diff == --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Sun Jun 2 17:47:32 2019 @@ -720,6 +720,16 @@ coro ok_static_coawait() co_await 42; } +template void ok_generic_lambda_coawait_PR41909() { + [](auto& arg) -> coro { // expected-warning {{expression result unused}} +co_await 12; + }; + [](auto &arg) -> coro { +co_await 24; + }("argument"); +} +template void ok_generic_lambda_coawait_PR41909(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909' requested here}} + template<> struct std::experimental::coroutine_traits { using promise_type = promise; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r368675 - [CodeGen] Disable UBSan for coroutine functions
Author: modocache Date: Tue Aug 13 05:02:25 2019 New Revision: 368675 URL: http://llvm.org/viewvc/llvm-project?rev=368675&view=rev Log: [CodeGen] Disable UBSan for coroutine functions Summary: As explained in http://lists.llvm.org/pipermail/llvm-dev/2018-March/121924.html, the LLVM coroutines transforms are not yet able to move the instructions for UBSan null checking past coroutine suspend boundaries. For now, disable all UBSan checks when generating code for coroutines functions. I also considered an approach where only '-fsanitize=null' would be disabled, However in practice this led to other LLVM errors when writing object files: "Cannot represent a difference across sections". For now, disable all UBSan checks until coroutine transforms are updated to handle them. Test Plan: 1. check-clang 2. Compile the program in https://gist.github.com/modocache/54a036c3bf9c06882fe85122e105d153 using the '-fsanitize=null' option and confirm it does not crash during LLVM IR generation. Reviewers: GorNishanov, vsk, eric_niebler, lewissbaker Reviewed By: vsk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D44672 Added: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=368675&r1=368674&r2=368675&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Aug 13 05:02:25 2019 @@ -732,6 +732,15 @@ void CodeGenFunction::StartFunction(Glob SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast; } + // Ignore null checks in coroutine functions since the coroutines passes + // are not aware of how to move the extra UBSan instructions across the split + // coroutine boundaries. + if (D && SanOpts.has(SanitizerKind::Null)) +if (const auto *FD = dyn_cast(D)) + if (FD->getBody() && + FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass) +SanOpts.Mask &= ~SanitizerKind::Null; + // Apply xray attributes to the function (as a string, for now) if (D) { if (const auto *XRayAttr = D->getAttr()) { Added: cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp?rev=368675&view=auto == --- cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp (added) +++ cfe/trunk/test/CodeGenCXX/ubsan-coroutines.cpp Tue Aug 13 05:02:25 2019 @@ -0,0 +1,49 @@ +// This test merely verifies that emitting the object file does not cause a +// crash when the LLVM coroutines passes are run. +// RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o + +namespace std::experimental { +template struct coroutine_traits { + using promise_type = typename R::promise_type; +}; + +template struct coroutine_handle; +template <> struct coroutine_handle { + static coroutine_handle from_address(void *) noexcept; + coroutine_handle() = default; + template + coroutine_handle(coroutine_handle) noexcept; +}; +template struct coroutine_handle : coroutine_handle { + coroutine_handle() = default; + static coroutine_handle from_address(void *) noexcept; +}; +} + +struct suspend_always { + bool await_ready() noexcept; + void await_suspend(std::experimental::coroutine_handle<>) noexcept; + void await_resume() noexcept; +}; + +struct task { + struct promise_type { +task get_return_object() { return task(); } +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} +void unhandled_exception() {} + }; +}; + +struct awaitable { + task await() { (void)co_await *this; } + bool await_ready() { return false; } + bool await_suspend(std::experimental::coroutine_handle<> awaiter) { return false; } + bool await_resume() { return false; } +}; + +int main() { + awaitable a; + a.await(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r350501 - [SemaCXX] Fix ICE for unexpanded parameter pack
Author: modocache Date: Sun Jan 6 19:25:59 2019 New Revision: 350501 URL: http://llvm.org/viewvc/llvm-project?rev=350501&view=rev Log: [SemaCXX] Fix ICE for unexpanded parameter pack Summary: The documentation for RecursiveASTVisitor::TraverseDecl states that the Decl being traversed may be null. In fact, this is the case when a CXXCatchStmt with no exception decl is traversed. Because the visitor for diagnosing unexpanded parameter packs does not check for null, it ends up crashing when it attempts to call the Decl::isParameterPack method on a null Decl pointer. Add a null check to prevent an ICE, and a test case that would crash otherwise. Also, because the test requires C++ exceptions and C++14, change the test parameters for the entire test file. (Alternatively, I thought about adding a new test file, but went with this approach for my own convenience.) Co-authored-by: Andreas Molzer Co-authored-by: Mara Bos Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D56271 Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/test/SemaCXX/alias-template.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=350501&r1=350500&r2=350501&view=diff == --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Sun Jan 6 19:25:59 2019 @@ -164,7 +164,7 @@ namespace { // A function parameter pack is a pack expansion, so cannot contain // an unexpanded parameter pack. Likewise for a template parameter // pack that contains any references to other packs. - if (D->isParameterPack()) + if (D && D->isParameterPack()) return true; return inherited::TraverseDecl(D); Modified: cfe/trunk/test/SemaCXX/alias-template.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alias-template.cpp?rev=350501&r1=350500&r2=350501&view=diff == --- cfe/trunk/test/SemaCXX/alias-template.cpp (original) +++ cfe/trunk/test/SemaCXX/alias-template.cpp Sun Jan 6 19:25:59 2019 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=c++14 -fcxx-exceptions %s namespace RedeclAliasTypedef { template using T = int; @@ -189,3 +189,7 @@ int sfinae_me() { return 0; } // expecte int g = sfinae_me(); // expected-error{{no matching function for call to 'sfinae_me'}} } + +namespace NullExceptionDecl { +template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r350914 - [AST] Remove ASTContext from getThisType (NFC)
Author: modocache Date: Thu Jan 10 17:54:53 2019 New Revision: 350914 URL: http://llvm.org/viewvc/llvm-project?rev=350914&view=rev Log: [AST] Remove ASTContext from getThisType (NFC) Summary: https://reviews.llvm.org/D54862 removed the usages of `ASTContext&` from within the `CXXMethodDecl::getThisType` method. Remove the parameter altogether, as well as all usages of it. This does not result in any functional change because the parameter was unused since https://reviews.llvm.org/D54862. Test Plan: check-clang Reviewers: akyrtzi, mikael Reviewed By: mikael Subscribers: mehdi_amini, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D56509 Modified: cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/lib/AST/DeclCXX.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/Analysis/Consumed.cpp cfe/trunk/lib/CodeGen/CGBlocks.cpp cfe/trunk/lib/CodeGen/CGCXXABI.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=350914&r1=350913&r2=350914&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Jan 10 17:54:53 2019 @@ -2180,7 +2180,7 @@ public: /// that for the call operator of a lambda closure type, this returns the /// desugared 'this' type (a pointer to the closure type), not the captured /// 'this' type. - QualType getThisType(ASTContext &C) const; + QualType getThisType() const; static QualType getThisType(const FunctionProtoType *FPT, const CXXRecordDecl *Decl); Modified: cfe/trunk/lib/AST/DeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=350914&r1=350913&r2=350914&view=diff == --- cfe/trunk/lib/AST/DeclCXX.cpp (original) +++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Jan 10 17:54:53 2019 @@ -2181,7 +2181,7 @@ QualType CXXMethodDecl::getThisType(cons return C.getPointerType(ClassTy); } -QualType CXXMethodDecl::getThisType(ASTContext &C) const { +QualType CXXMethodDecl::getThisType() const { // C++ 9.3.2p1: The type of this in a member function of a class X is X*. // If the member function is declared const, the type of this is const X*, // if the member function is declared volatile, the type of this is Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=350914&r1=350913&r2=350914&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Jan 10 17:54:53 2019 @@ -4462,7 +4462,7 @@ static bool HandleFunctionCall(SourceLoc if (!handleLValueToRValueConversion(Info, Args[0], Args[0]->getType(), RHS, RHSValue)) return false; -if (!handleAssignment(Info, Args[0], *This, MD->getThisType(Info.Ctx), +if (!handleAssignment(Info, Args[0], *This, MD->getThisType(), RHSValue)) return false; This->moveInto(Result); Modified: cfe/trunk/lib/Analysis/Consumed.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=350914&r1=350913&r2=350914&view=diff == --- cfe/trunk/lib/Analysis/Consumed.cpp (original) +++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Jan 10 17:54:53 2019 @@ -463,7 +463,6 @@ class ConsumedStmtVisitor : public Const using InfoEntry = MapType::iterator; using ConstInfoEntry = MapType::const_iterator; - AnalysisDeclContext &AC; ConsumedAnalyzer &Analyzer; ConsumedStateMap *StateMap; MapType PropagationMap; @@ -515,9 +514,8 @@ public: void VisitUnaryOperator(const UnaryOperator *UOp); void VisitVarDecl(const VarDecl *Var); - ConsumedStmtVisitor(AnalysisDeclContext &AC, ConsumedAnalyzer &Analyzer, - ConsumedStateMap *StateMap) - : AC(AC), Analyzer(Analyzer), StateMap(StateMap) {} + ConsumedStmtVisitor(ConsumedAnalyzer &Analyzer, ConsumedStateMap *StateMap) + : Analyzer(Analyzer), StateMap(StateMap) {} PropagationInfo getInfo(const Expr
r330530 - Add tests for llvm-bcanalyzer stream types
Author: modocache Date: Sat Apr 21 17:04:35 2018 New Revision: 330530 URL: http://llvm.org/viewvc/llvm-project?rev=330530&view=rev Log: Add tests for llvm-bcanalyzer stream types Summary: Add tests for the improved stream type detection added to `llvm-bcanalyzer` in https://reviews.llvm.org/D41979. Test Plan: `check-clang` Reviewers: pcc, aprantl, mehdi_amini, george.karpenkov Reviewed By: aprantl Subscribers: cfe-commits, a.sidorin Differential Revision: https://reviews.llvm.org/D41980 Added: cfe/trunk/test/Misc/serialized-diags-bcanalyzer.c cfe/trunk/test/PCH/include-stream-type.cpp Added: cfe/trunk/test/Misc/serialized-diags-bcanalyzer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags-bcanalyzer.c?rev=330530&view=auto == --- cfe/trunk/test/Misc/serialized-diags-bcanalyzer.c (added) +++ cfe/trunk/test/Misc/serialized-diags-bcanalyzer.c Sat Apr 21 17:04:35 2018 @@ -0,0 +1,3 @@ +// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 +// RUN: llvm-bcanalyzer -dump %t.diag | FileCheck %s +// CHECK: Stream type: Clang Serialized Diagnostics Added: cfe/trunk/test/PCH/include-stream-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/include-stream-type.cpp?rev=330530&view=auto == --- cfe/trunk/test/PCH/include-stream-type.cpp (added) +++ cfe/trunk/test/PCH/include-stream-type.cpp Sat Apr 21 17:04:35 2018 @@ -0,0 +1,10 @@ +// Test that llvm-bcanalyzer recognizes the stream type of a PCH file. + +// RUN: mkdir -p %t-dir +// Copying files allow for read-only checkouts to run this test. +// RUN: cp %S/Inputs/pragma-once2-pch.h %t-dir +// RUN: cp %S/Inputs/pragma-once2.h %t-dir +// RUN: %clang_cc1 -x c++-header -emit-pch -fmodule-format=raw -o %t %t-dir/pragma-once2-pch.h +// RUN: llvm-bcanalyzer -dump %t | FileCheck %s +// +// CHECK: Stream type: Clang Serialized AST ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r331519 - [Coroutines] Catch exceptions in await_resume
Author: modocache Date: Fri May 4 07:02:37 2018 New Revision: 331519 URL: http://llvm.org/viewvc/llvm-project?rev=331519&view=rev Log: [Coroutines] Catch exceptions in await_resume Summary: http://wg21.link/P0664r2 section "Evolution/Core Issues 24" describes a proposed change to Coroutines TS that would have any exceptions thrown after the initial suspend point of a coroutine be caught by the handler specified by the promise type's 'unhandled_exception' member function. This commit provides a sample implementation of the specified behavior. Test Plan: `check-clang` Reviewers: GorNishanov, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits, lewissbaker, eric_niebler Differential Revision: https://reviews.llvm.org/D45860 Added: cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=331519&r1=331518&r2=331519&view=diff == --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Fri May 4 07:02:37 2018 @@ -44,6 +44,15 @@ struct clang::CodeGen::CGCoroData { // A branch to this block is emitted when coroutine needs to suspend. llvm::BasicBlock *SuspendBB = nullptr; + // The promise type's 'unhandled_exception' handler, if it defines one. + Stmt *ExceptionHandler = nullptr; + + // A temporary i1 alloca that stores whether 'await_resume' threw an + // exception. If it did, 'true' is stored in this variable, and the coroutine + // body must be skipped. If the promise type does not define an exception + // handler, this is null. + llvm::Value *ResumeEHVar = nullptr; + // Stores the jump destination just before the coroutine memory is freed. // This is the destination that every suspend point jumps to for the cleanup // branch. @@ -208,11 +217,32 @@ static LValueOrRValue emitSuspendExpress // Emit await_resume expression. CGF.EmitBlock(ReadyBlock); + CXXTryStmt *TryStmt = nullptr; + if (Coro.ExceptionHandler && Kind == AwaitKind::Init) { +Coro.ResumeEHVar = +CGF.CreateTempAlloca(Builder.getInt1Ty(), Prefix + Twine("resume.eh")); +Builder.CreateFlagStore(true, Coro.ResumeEHVar); + +auto Loc = S.getResumeExpr()->getExprLoc(); +auto *Catch = new (CGF.getContext()) +CXXCatchStmt(Loc, /*exDecl=*/nullptr, Coro.ExceptionHandler); +auto *TryBody = +CompoundStmt::Create(CGF.getContext(), S.getResumeExpr(), Loc, Loc); +TryStmt = CXXTryStmt::Create(CGF.getContext(), Loc, TryBody, Catch); +CGF.EnterCXXTryStmt(*TryStmt); + } + LValueOrRValue Res; if (forLValue) Res.LV = CGF.EmitLValue(S.getResumeExpr()); else Res.RV = CGF.EmitAnyExpr(S.getResumeExpr(), aggSlot, ignoreResult); + + if (TryStmt) { +Builder.CreateFlagStore(false, Coro.ResumeEHVar); +CGF.ExitCXXTryStmt(*TryStmt); + } + return Res; } @@ -588,19 +618,31 @@ void CodeGenFunction::EmitCoroutineBody( EHStack.pushCleanup(EHCleanup); CurCoro.Data->CurrentAwaitKind = AwaitKind::Init; +CurCoro.Data->ExceptionHandler = S.getExceptionHandler(); EmitStmt(S.getInitSuspendStmt()); CurCoro.Data->FinalJD = getJumpDestInCurrentScope(FinalBB); CurCoro.Data->CurrentAwaitKind = AwaitKind::Normal; -if (auto *OnException = S.getExceptionHandler()) { +if (CurCoro.Data->ExceptionHandler) { + BasicBlock *BodyBB = createBasicBlock("coro.resumed.body"); + BasicBlock *ContBB = createBasicBlock("coro.resumed.cont"); + Value *SkipBody = + Builder.CreateFlagLoad(CurCoro.Data->ResumeEHVar, "coro.resumed.eh"); + Builder.CreateCondBr(SkipBody, ContBB, BodyBB); + EmitBlock(BodyBB); + auto Loc = S.getLocStart(); - CXXCatchStmt Catch(Loc, /*exDecl=*/nullptr, OnException); - auto *TryStmt = CXXTryStmt::Create(getContext(), Loc, S.getBody(), &Catch); + CXXCatchStmt Catch(Loc, /*exDecl=*/nullptr, + CurCoro.Data->ExceptionHandler); + auto *TryStmt = + CXXTryStmt::Create(getContext(), Loc, S.getBody(), &Catch); EnterCXXTryStmt(*TryStmt); emitBodyAndFallthrough(*this, S, TryStmt->getTryBlock()); ExitCXXTryStmt(*TryStmt); + + EmitBlock(ContBB); } else { emitBodyAndFallthrough(*this, S, S.getBody()); Added: cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp?rev=331519&view=auto == --- cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp (added) +++ cfe/trunk/test/CodeGenCoroutines/coro-await-resume-eh.cpp Fri May 4 07:02:37 2018 @@ -0,0 +1,81 @@
r335655 - [AST] Fix typo in LazyOffsetPtr::get docs (NFC)
Author: modocache Date: Tue Jun 26 13:05:18 2018 New Revision: 335655 URL: http://llvm.org/viewvc/llvm-project?rev=335655&view=rev Log: [AST] Fix typo in LazyOffsetPtr::get docs (NFC) Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=335655&r1=335654&r2=335655&view=diff == --- cfe/trunk/include/clang/AST/ExternalASTSource.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTSource.h Tue Jun 26 13:05:18 2018 @@ -393,7 +393,7 @@ public: /// Whether this pointer is currently stored as an offset. bool isOffset() const { return Ptr & 0x01; } - /// Retrieve the pointer to the AST node that this lazy pointer + /// Retrieve the pointer to the AST node that this lazy pointer points to. /// /// \param Source the external AST source. /// ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336748 - Remove qualtype qualifier in coroutine error to prevent assert in debug
Author: modocache Date: Tue Jul 10 17:45:48 2018 New Revision: 336748 URL: http://llvm.org/viewvc/llvm-project?rev=336748&view=rev Log: Remove qualtype qualifier in coroutine error to prevent assert in debug Summary: A forward-declared coroutine_traits should trip an error; we need a complete type. Unfortunately, in debug mode only, we trip an assert when attempting to provide the fully qualified type for the error message. If you try to compile a program with a forward-declared coroutine_traits in debug mode, clang will crash. I've included a test for the behavior and removed the q modifier on the error message. This prevents the crash in debug mode and does not change the behavior for the error message on a forward-declaration of a coroutine_traits type. Test Plan: I've included a test for the forward-declaration. Patch by Tanoy Sinha! Reviewers: modocache, GorNishanov Reviewed By: modocache Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49099 Added: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=336748&r1=336747&r2=336748&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 10 17:45:48 2018 @@ -9082,7 +9082,7 @@ def err_coroutine_promise_type_incomplet "this function cannot be a coroutine: %0 is an incomplete type">; def err_coroutine_type_missing_specialization : Error< "this function cannot be a coroutine: missing definition of " - "specialization %q0">; + "specialization %0">; def err_coroutine_promise_incompatible_return_functions : Error< "the coroutine promise type %0 declares both 'return_value' and 'return_void'">; def err_coroutine_promise_requires_return_function : Error< Added: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp?rev=336748&view=auto == --- cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp (added) +++ cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Tue Jul 10 17:45:48 2018 @@ -0,0 +1,21 @@ +// test/SemaCXX/coroutine-traits-undefined-template.cpp + +// This file contains references to sections of the Coroutines TS, which can be +// found at http://wg21.link/coroutines. + +// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result + +namespace std { +namespace experimental { + +template +struct coroutine_traits { + struct promise_type {}; +}; + +template<> struct coroutine_traits; // expected-note {{forward declaration of 'std::experimental::coroutine_traits'}} +}} // namespace std::experimental + +void uses_forward_declaration() { + co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336750 - [SemaCXX] Remove comment from coroutines test, NFC
Author: modocache Date: Tue Jul 10 18:00:53 2018 New Revision: 336750 URL: http://llvm.org/viewvc/llvm-project?rev=336750&view=rev Log: [SemaCXX] Remove comment from coroutines test, NFC Summary: The file name was accidentally included when the test file was added. Test Plan: check-clang Modified: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Modified: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp?rev=336750&r1=336749&r2=336750&view=diff == --- cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Tue Jul 10 18:00:53 2018 @@ -1,5 +1,3 @@ -// test/SemaCXX/coroutine-traits-undefined-template.cpp - // This file contains references to sections of the Coroutines TS, which can be // found at http://wg21.link/coroutines. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r337103 - Add caching when looking up coroutine_traits
Author: modocache Date: Sat Jul 14 11:21:44 2018 New Revision: 337103 URL: http://llvm.org/viewvc/llvm-project?rev=337103&view=rev Log: Add caching when looking up coroutine_traits Summary: Currently clang looks up the coroutine_traits ClassTemplateDecl everytime it looks up the promise type. This is unnecessary as coroutine_traits doesn't change between promise type lookups. This diff caches the coroutine_traits lookup. Patch by Tanoy Sinha! Test Plan: I added log statements in the new lookupCoroutineTraits function to ensure that LookupQualifiedName was only called once even when multiple coroutines existed in the source file. Reviewers: modocache, GorNishanov Reviewed By: modocache Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D48981 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=337103&r1=337102&r2=337103&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Sat Jul 14 11:21:44 2018 @@ -824,6 +824,10 @@ public: /// \. ClassTemplateDecl *StdInitializerList; + /// The C++ "std::coroutine_traits" template, which is defined in + /// \ + ClassTemplateDecl *StdCoroutineTraitsCache; + /// The C++ "type_info" declaration, which is defined in \. RecordDecl *CXXTypeInfoDecl; @@ -8536,6 +8540,8 @@ public: bool buildCoroutineParameterMoves(SourceLocation Loc); VarDecl *buildCoroutinePromise(SourceLocation Loc); void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body); + ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc, + SourceLocation FuncLoc); //======// // OpenCL extensions. Modified: cfe/trunk/lib/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=337103&r1=337102&r2=337103&view=diff == --- cfe/trunk/lib/Sema/Sema.cpp (original) +++ cfe/trunk/lib/Sema/Sema.cpp Sat Jul 14 11:21:44 2018 @@ -131,9 +131,9 @@ Sema::Sema(Preprocessor &pp, ASTContext IsBuildingRecoveryCallExpr(false), Cleanup{}, LateTemplateParser(nullptr), LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), IdResolver(pp), StdExperimentalNamespaceCache(nullptr), StdInitializerList(nullptr), - CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr), NSNumberDecl(nullptr), - NSValueDecl(nullptr), NSStringDecl(nullptr), - StringWithUTF8StringMethod(nullptr), + StdCoroutineTraitsCache(nullptr), CXXTypeInfoDecl(nullptr), + MSVCGuidDecl(nullptr), NSNumberDecl(nullptr), NSValueDecl(nullptr), + NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr), ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr), GlobalNewDeleteDeclared(false), Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=337103&r1=337102&r2=337103&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sat Jul 14 11:21:44 2018 @@ -60,20 +60,8 @@ static QualType lookupPromiseType(Sema & return QualType(); } - LookupResult Result(S, &S.PP.getIdentifierTable().get("coroutine_traits"), - FuncLoc, Sema::LookupOrdinaryName); - if (!S.LookupQualifiedName(Result, StdExp)) { -S.Diag(KwLoc, diag::err_implied_coroutine_type_not_found) -<< "std::experimental::coroutine_traits"; -return QualType(); - } - - ClassTemplateDecl *CoroTraits = Result.getAsSingle(); + ClassTemplateDecl *CoroTraits = S.lookupCoroutineTraits(KwLoc, FuncLoc); if (!CoroTraits) { -Result.suppressDiagnostics(); -// We found something weird. Complain about the first thing we found. -NamedDecl *Found = *Result.begin(); -S.Diag(Found->getLocation(), diag::err_malformed_std_coroutine_traits); return QualType(); } @@ -1538,3 +1526,27 @@ StmtResult Sema::BuildCoroutineBodyStmt( return StmtError(); return Res; } + +ClassTemplateDecl *Sema::lookupCoroutineTraits(SourceLocation KwLoc, + SourceLocation FuncLoc) { + if (!StdCoroutineTraitsCache) { +if (auto StdExp = lookupStdExperimentalNamespace()) { + LookupResult Result(*this, + &PP.getIdentifierTable().get("coroutine_traits"), + FuncLoc, LookupOrdinaryName); + if (!LookupQualif
r375258 - [Format] Add format check for throwing negative numbers
Author: modocache Date: Fri Oct 18 09:59:02 2019 New Revision: 375258 URL: http://llvm.org/viewvc/llvm-project?rev=375258&view=rev Log: [Format] Add format check for throwing negative numbers Summary: The code `throw -1;` is currently formatted by clang-format as `throw - 1;`. This diff adds a fix for this edge case and a test to check for this in the future. For context, I am looking into a related bug in the clang-formatting of coroutine keywords: `co_yield -1;` is also reformatted in this manner as `co_yield - 1;`. A later diff will add these changes and tests for the `co_yield` and `co_return` keywords. Patch by Jonathan Thomas (jonathoma)! Reviewers: modocache, sammccall, Quuxplusone Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang-format, #clang Differential Revision: https://reviews.llvm.org/D69144 Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=375258&r1=375257&r2=375258&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Oct 18 09:59:02 2019 @@ -1757,7 +1757,7 @@ private: // Use heuristics to recognize unary operators. if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square, tok::question, tok::colon, tok::kw_return, - tok::kw_case, tok::at, tok::l_brace)) + tok::kw_case, tok::at, tok::l_brace, tok::kw_throw)) return TT_UnaryOperator; // There can't be two consecutive binary operators. Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=375258&r1=375257&r2=375258&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 18 09:59:02 2019 @@ -6912,6 +6912,7 @@ TEST_F(FormatTest, UnderstandsUnaryOpera verifyFormat("alignof(char);", getGoogleStyle()); verifyFormat("return -1;"); + verifyFormat("throw -1;"); verifyFormat("switch (a) {\n" "case -1:\n" " break;\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r310609 - [Parse] Document PrintStats, SkipFunctionBodies
Author: modocache Date: Thu Aug 10 08:30:35 2017 New Revision: 310609 URL: http://llvm.org/viewvc/llvm-project?rev=310609&view=rev Log: [Parse] Document PrintStats, SkipFunctionBodies Summary: Add documentation for `clang::ParseAST` parameters `PrintStats` and `SkipFunctionBodies`. Also, remove a tiny bit of trailing whitespace. Reviewers: craig.topper, doug.gregor, erikjv Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36530 Modified: cfe/trunk/include/clang/Parse/ParseAST.h Modified: cfe/trunk/include/clang/Parse/ParseAST.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseAST.h?rev=310609&r1=310608&r2=310609&view=diff == --- cfe/trunk/include/clang/Parse/ParseAST.h (original) +++ cfe/trunk/include/clang/Parse/ParseAST.h Thu Aug 10 08:30:35 2017 @@ -29,10 +29,13 @@ namespace clang { /// This operation inserts the parsed decls into the translation /// unit held by Ctx. /// + /// \param PrintStats Whether to print LLVM statistics related to parsing. /// \param TUKind The kind of translation unit being parsed. - /// /// \param CompletionConsumer If given, an object to consume code completion /// results. + /// \param SkipFunctionBodies Whether to skip parsing of function bodies. + /// This option can be used, for example, to speed up searches for + /// delcarations/definitions when indexing. void ParseAST(Preprocessor &pp, ASTConsumer *C, ASTContext &Ctx, bool PrintStats = false, TranslationUnitKind TUKind = TU_Complete, @@ -43,7 +46,7 @@ namespace clang { /// abstract syntax tree. void ParseAST(Sema &S, bool PrintStats = false, bool SkipFunctionBodies = false); - + } // end namespace clang #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r310627 - [Parse] Document Parser::SkipFunctionBodies
Author: modocache Date: Thu Aug 10 10:02:04 2017 New Revision: 310627 URL: http://llvm.org/viewvc/llvm-project?rev=310627&view=rev Log: [Parse] Document Parser::SkipFunctionBodies Reviewers: erikjv, doug.gregor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36531 Modified: cfe/trunk/include/clang/Parse/Parser.h Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=310627&r1=310626&r2=310627&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Thu Aug 10 10:02:04 2017 @@ -253,6 +253,10 @@ class Parser : public CodeCompletionHand /// be NULL. bool ParsingInObjCContainer; + /// Whether to skip parsing of function bodies. + /// + /// This option can be used, for example, to speed up searches for + /// delcarations/definitions when indexing. bool SkipFunctionBodies; /// The location of the expression statement that is being parsed right now. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r310838 - [Parse] Fix typo in header docs (NFC)
Author: modocache Date: Mon Aug 14 07:29:11 2017 New Revision: 310838 URL: http://llvm.org/viewvc/llvm-project?rev=310838&view=rev Log: [Parse] Fix typo in header docs (NFC) Summary: Fix typo "delcarations", added in rL310609 and rL310627. Modified: cfe/trunk/include/clang/Parse/ParseAST.h cfe/trunk/include/clang/Parse/Parser.h Modified: cfe/trunk/include/clang/Parse/ParseAST.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseAST.h?rev=310838&r1=310837&r2=310838&view=diff == --- cfe/trunk/include/clang/Parse/ParseAST.h (original) +++ cfe/trunk/include/clang/Parse/ParseAST.h Mon Aug 14 07:29:11 2017 @@ -35,7 +35,7 @@ namespace clang { /// results. /// \param SkipFunctionBodies Whether to skip parsing of function bodies. /// This option can be used, for example, to speed up searches for - /// delcarations/definitions when indexing. + /// declarations/definitions when indexing. void ParseAST(Preprocessor &pp, ASTConsumer *C, ASTContext &Ctx, bool PrintStats = false, TranslationUnitKind TUKind = TU_Complete, Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=310838&r1=310837&r2=310838&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Mon Aug 14 07:29:11 2017 @@ -256,7 +256,7 @@ class Parser : public CodeCompletionHand /// Whether to skip parsing of function bodies. /// /// This option can be used, for example, to speed up searches for - /// delcarations/definitions when indexing. + /// declarations/definitions when indexing. bool SkipFunctionBodies; /// The location of the expression statement that is being parsed right now. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 627e01f - [coroutines] Don't build promise init with no args
Author: Brian Gesiak Date: 2020-04-02T21:44:54-04:00 New Revision: 627e01feb718dd1aa8e184545976b7229de312a2 URL: https://github.com/llvm/llvm-project/commit/627e01feb718dd1aa8e184545976b7229de312a2 DIFF: https://github.com/llvm/llvm-project/commit/627e01feb718dd1aa8e184545976b7229de312a2.diff LOG: [coroutines] Don't build promise init with no args Summary: In the case of a coroutine that takes no arguments, `Sema::buildCoroutinePromise` constructs a list-initialization (`clang::InitializationKind::InitKind::IK_DirectList`) of the promise variable, using a list of empty arguments. So, if one were to dump the promise `VarDecl` immediately after `Sema::ActOnCoroutineBodyStart` calls `checkCoroutineContext`, for a coroutine function that takes no arguments, they'd see the following: ``` VarDecl 0xb514490 col:3 __promise '' callinit `-ParenListExpr 0xb514510 'NULL TYPE' ``` But after this patch, the `ParenListExpr` is no longer constructed, and the promise variable uses default initialization (`clang::InitializationKind::InitKind::IK_Default`): ``` VarDecl 0x63100012dae0 col:3 __promise '' ``` As far as I know, there's no case in which list-initialization with no arguments differs from default initialization, but if I'm wrong please let me know (and I'll add a test case that demonstrates the change -- but as-is I can't think of a functional test case for this). I think both comply with the wording of C++20 `[dcl.fct.def.coroutine]p5`: > _promise-constructor-arguments_ is determined as follows: overload resolution is performed on a promise constructor call created by assembling an argument list with lvalues `p1 ... pn`. If a viable constructor is found (12.4.2), then _promise-constructor-arguments_ is `(p1, ... , pn)`, otherwise _promise-constructor-arguments_ is empty. Still, I think this patch is an improvement regardless, because it reduces the size of the AST. Reviewers: GorNishanov, rsmith, lewissbaker Subscribers: EricWF, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70555 Added: Modified: clang/lib/Sema/SemaCoroutine.cpp Removed: diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 6dc9e342beb9..5ed0bbd6041d 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -502,8 +502,9 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) { return nullptr; auto *ScopeInfo = getCurFunction(); - // Build a list of arguments, based on the coroutine functions arguments, - // that will be passed to the promise type's constructor. + + // Build a list of arguments, based on the coroutine function's arguments, + // that if present will be passed to the promise type's constructor. llvm::SmallVector CtorArgExprs; // Add implicit object parameter. @@ -519,6 +520,7 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) { } } + // Add the coroutine function's parameters. auto &Moves = ScopeInfo->CoroutineParameterMoves; for (auto *PD : FD->parameters()) { if (PD->getType()->isDependentType()) @@ -540,28 +542,33 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) { CtorArgExprs.push_back(RefExpr.get()); } - // Create an initialization sequence for the promise type using the - // constructor arguments, wrapped in a parenthesized list expression. - Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(), -CtorArgExprs, FD->getLocation()); - InitializedEntity Entity = InitializedEntity::InitializeVariable(VD); - InitializationKind Kind = InitializationKind::CreateForInit( - VD->getLocation(), /*DirectInit=*/true, PLE); - InitializationSequence InitSeq(*this, Entity, Kind, CtorArgExprs, - /*TopLevelOfInitList=*/false, - /*TreatUnavailableAsInvalid=*/false); - - // Attempt to initialize the promise type with the arguments. - // If that fails, fall back to the promise type's default constructor. - if (InitSeq) { -ExprResult Result = InitSeq.Perform(*this, Entity, Kind, CtorArgExprs); -if (Result.isInvalid()) { - VD->setInvalidDecl(); -} else if (Result.get()) { - VD->setInit(MaybeCreateExprWithCleanups(Result.get())); - VD->setInitStyle(VarDecl::CallInit); - CheckCompleteVariableDeclaration(VD); -} + // If we have a non-zero number of constructor arguments, try to use them. + // Otherwise, fall back to the promise type's default constructor. + if (!CtorArgExprs.empty()) { +// Create an initialization sequence for the promise type using the +// constructor arguments, wrapped in a parenthesized list expression. +Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(), + CtorArgExprs, FD->getLocation()); +InitializedEntity Entity
[clang] 048239e - [Coroutines][6/6] Clang schedules new passes
Author: Brian Gesiak Date: 2020-02-19T01:03:28-05:00 New Revision: 048239e46e490d441f21f3e26073ec38f19e8a10 URL: https://github.com/llvm/llvm-project/commit/048239e46e490d441f21f3e26073ec38f19e8a10 DIFF: https://github.com/llvm/llvm-project/commit/048239e46e490d441f21f3e26073ec38f19e8a10.diff LOG: [Coroutines][6/6] Clang schedules new passes Summary: Depends on https://reviews.llvm.org/D71902. The last in a series of six patches that ports the LLVM coroutines passes to the new pass manager infrastructure. This patch has Clang schedule the new coroutines passes when the `-fexperimental-new-pass-manager` option is used. With this and the previous 5 patches, Clang is capable of building and successfully running the test suite of large coroutines projects such as https://github.com/lewissbaker/cppcoro with `ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER=On`. Reviewers: GorNishanov, lewissbaker, chandlerc, junparser Subscribers: EricWF, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71903 Added: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp Modified: clang/lib/CodeGen/BackendUtil.cpp Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 6c71cf793c0f..b244fd499fb0 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -49,6 +49,10 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/Coroutines.h" +#include "llvm/Transforms/Coroutines/CoroCleanup.h" +#include "llvm/Transforms/Coroutines/CoroEarly.h" +#include "llvm/Transforms/Coroutines/CoroElide.h" +#include "llvm/Transforms/Coroutines/CoroSplit.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/AlwaysInliner.h" #include "llvm/Transforms/IPO/LowerTypeTests.h" @@ -957,6 +961,22 @@ static PassBuilder::OptimizationLevel mapToLevel(const CodeGenOptions &Opts) { } } +static void addCoroutinePassesAtO0(ModulePassManager &MPM, + const LangOptions &LangOpts, + const CodeGenOptions &CodeGenOpts) { + if (!LangOpts.Coroutines) +return; + + MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass())); + + CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager); + CGPM.addPass(CoroSplitPass()); + CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass())); + MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); + + MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass())); +} + static void addSanitizersAtO0(ModulePassManager &MPM, const Triple &TargetTriple, const LangOptions &LangOpts, @@ -1076,6 +1096,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; PTO.LoopVectorization = CodeGenOpts.VectorizeLoop; PTO.SLPVectorization = CodeGenOpts.VectorizeSLP; + PTO.Coroutines = LangOpts.Coroutines; PassInstrumentationCallbacks PIC; StandardInstrumentations SI; @@ -1279,6 +1300,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( } if (CodeGenOpts.OptimizationLevel == 0) { + addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts); addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); } } diff --git a/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp new file mode 100644 index ..aed2cf13f892 --- /dev/null +++ b/clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp @@ -0,0 +1,57 @@ +// Tests that coroutine passes are added to and run by the new pass manager +// pipeline, at -O0 and above. + +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \ +// RUN: -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \ +// RUN: -O0 %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \ +// RUN: -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \ +// RUN: -O1 %s 2>&1 | FileCheck %s +// +// CHECK: Starting llvm::Module pass manager run. +// CHECK: Running pass:{{.*}}CoroEarlyPass +// +// The first coro-split pass enqueues a second run of the entire CGSCC pipeline. +// CHECK: Starting CGSCC pass manager run. +// CHECK: Running pass: CoroSplitPass on (_Z3foov) +// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov) +// CHECK: Finished CGSCC pass manager run. +// +// The second coro-split pass splits coroutine 'foo' into funclets +// 'foo.resume', 'foo.destroy', and 'foo.cleanup'. +// CHECK: Starting CGSCC pass manager run. +// CHECK: Running pass: CoroSplitPass on (_Z3foov) +// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov) +// CHECK: Finished CGSCC pass manager run. +// +// CHECK: Running pass:{
[clang] 0b3d1d1 - [coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves
Author: Brian Gesiak Date: 2019-11-22T11:39:13-05:00 New Revision: 0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f URL: https://github.com/llvm/llvm-project/commit/0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f DIFF: https://github.com/llvm/llvm-project/commit/0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f.diff LOG: [coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves Summary: The assertion of CoroutineParameterMoves happens when build coroutine function with arguments multiple time while fails to build promise type. Fix: use return false instead. Test Plan: check-clang Reviewers: modocache, GorNishanov, rjmccall Reviewed By: modocache Subscribers: rjmccall, EricWF, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69022 Patch by junparser (JunMa)! Added: Modified: clang/lib/Sema/SemaCoroutine.cpp clang/test/SemaCXX/coroutines.cpp Removed: diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 7c125e999d00..271c4a10f3e4 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -1527,8 +1527,8 @@ bool Sema::buildCoroutineParameterMoves(SourceLocation Loc) { auto *FD = cast(CurContext); auto *ScopeInfo = getCurFunction(); - assert(ScopeInfo->CoroutineParameterMoves.empty() && - "Should not build parameter moves twice"); + if (!ScopeInfo->CoroutineParameterMoves.empty()) +return false; for (auto *PD : FD->parameters()) { if (PD->getType()->isDependentType()) diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index c8de7b017859..677c6e6ff8d2 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -87,6 +87,11 @@ int no_promise_type() { // expected-error {{this function cannot be a coroutine: co_await a; } +int no_promise_type_multiple_awaits(int) { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits' has no member named 'promise_type'}} + co_await a; + co_await a; +} + template <> struct std::experimental::coroutine_traits { typedef int promise_type; }; double bad_promise_type(double) { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'int') is not a class}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8682d29 - [Format] Add format check for coroutine keywords with negative numbers
Author: Brian Gesiak Date: 2019-11-30T15:47:58-05:00 New Revision: 8682d29a28772bab0283a141b8701bfaea8881a6 URL: https://github.com/llvm/llvm-project/commit/8682d29a28772bab0283a141b8701bfaea8881a6 DIFF: https://github.com/llvm/llvm-project/commit/8682d29a28772bab0283a141b8701bfaea8881a6.diff LOG: [Format] Add format check for coroutine keywords with negative numbers Summary: As a followup to D69144, this diff fixes the coroutine keyword spacing for co_yield / co_returning negative numbers. Reviewers: modocache, sammccall, Quuxplusone Reviewed By: modocache Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69180 Patch by Jonathan Thomas (jonathoma)! Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9fe7fdc9ce93..74ff5b531496 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1829,7 +1829,8 @@ class AnnotatingParser { // Use heuristics to recognize unary operators. if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square, tok::question, tok::colon, tok::kw_return, - tok::kw_case, tok::at, tok::l_brace, tok::kw_throw)) + tok::kw_case, tok::at, tok::l_brace, tok::kw_throw, + tok::kw_co_return, tok::kw_co_yield)) return TT_UnaryOperator; // There can't be two consecutive binary operators. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d89ad44e4577..e6fa829e7ff9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6990,6 +6990,9 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) { verifyFormat("int a = /* confusing comment */ -1;"); // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case. verifyFormat("int a = i /* confusing comment */++;"); + + verifyFormat("co_yield -1;"); + verifyFormat("co_return -1;"); } TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 376cf43 - [coroutines][PR41909] Generalize fix from D62550
Author: Brian Gesiak Date: 2019-12-16T17:43:04-05:00 New Revision: 376cf43729c8025eecbd2969522c5687f2a3919f URL: https://github.com/llvm/llvm-project/commit/376cf43729c8025eecbd2969522c5687f2a3919f DIFF: https://github.com/llvm/llvm-project/commit/376cf43729c8025eecbd2969522c5687f2a3919f.diff LOG: [coroutines][PR41909] Generalize fix from D62550 Summary: In https://reviews.llvm.org/D62550 @rsmith pointed out that there are many situations in which a coroutine body statement may be transformed/rebuilt as part of a template instantiation, and my naive check whether the coroutine was a generic lambda was insufficient. This is indeed true, as I've learned by reading more of the TreeTransform code. Most transformations are written in a way that doesn't assume the resulting types are not dependent types. So the assertion in 'TransformCoroutineBodyStmt', that the promise type must no longer be dependent, is out of place. This patch removes the assertion, spruces up some code comments, and adds a test that would have failed with my naive check from https://reviews.llvm.org/D62550. Reviewers: GorNishanov, rsmith, lewissbaker Reviewed By: rsmith Subscribers: junparser, EricWF, rsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70579 Added: Modified: clang/lib/Sema/TreeTransform.h clang/test/SemaCXX/coroutines.cpp Removed: diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index ade0e6a0c4ce..2e4e91285060 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7190,8 +7190,12 @@ TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) { // that may fail. ScopeInfo->setNeedsCoroutineSuspends(false); - // The new CoroutinePromise object needs to be built and put into the current - // FunctionScopeInfo before any transformations or rebuilding occurs. + // We re-build the coroutine promise object (and the coroutine parameters its + // type and constructor depend on) based on the types used in our current + // function. We must do so, and set it on the current FunctionScopeInfo, + // before attempting to transform the other parts of the coroutine body + // statement, such as the implicit suspend statements (because those + // statements reference the FunctionScopeInfo::CoroutinePromise). if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation())) return StmtError(); auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation()); @@ -7200,8 +7204,9 @@ TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) { getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise}); ScopeInfo->CoroutinePromise = Promise; - // Transform the implicit coroutine statements we built during the initial - // parse. + // Transform the implicit coroutine statements constructed using dependent + // types during the previous parse: initial and final suspensions, the return + // object, and others. We also transform the coroutine function's body. StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt()); if (InitSuspend.isInvalid()) return StmtError(); @@ -7228,17 +7233,13 @@ TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) { return StmtError(); Builder.ReturnValue = Res.get(); + // If during the previous parse the coroutine still had a dependent promise + // statement, we may need to build some implicit coroutine statements + // (such as exception and fallthrough handlers) for the first time. if (S->hasDependentPromiseType()) { -// PR41909: We may find a generic coroutine lambda definition within a -// template function that is being instantiated. In this case, the lambda -// will have a dependent promise type, until it is used in an expression -// that creates an instantiation with a non-dependent promise type. We -// should not assert or build coroutine dependent statements for such a -// generic lambda. -auto *MD = dyn_cast_or_null(FD); -if (!MD || !MD->getParent()->isGenericLambda()) { - assert(!Promise->getType()->isDependentType() && - "the promise type must no longer be dependent"); +// We can only build these statements, however, if the current promise type +// is not dependent. +if (!Promise->getType()->isDependentType()) { assert(!S->getFallthroughHandler() && !S->getExceptionHandler() && !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && "these nodes should not have been built yet"); diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index 677c6e6ff8d2..9e94fe8c9c10 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -731,6 +731,12 @@ template void ok_generic_lambda_coawait_PR41909() { [](auto &arg) -> coro { co_await 24;
r328949 - [Coroutines] Find custom allocators in class scope
Author: modocache Date: Sun Apr 1 15:59:22 2018 New Revision: 328949 URL: http://llvm.org/viewvc/llvm-project?rev=328949&view=rev Log: [Coroutines] Find custom allocators in class scope Summary: https://reviews.llvm.org/rL325291 implemented Coroutines TS N4723 section [dcl.fct.def.coroutine]/7, but it performed lookup of allocator functions within both the global and class scope, whereas the specified behavior is to perform lookup for custom allocators within just the class scope. To fix, add parameters to the `Sema::FindAllocationFunctions` function such that it can be used to lookup allocators in global scope, class scope, or both (instead of just being able to look up in just global scope or in both global and class scope). Then, use those parameters from within the coroutine Sema. This incorrect behavior had the unfortunate side-effect of causing the bug https://bugs.llvm.org/show_bug.cgi?id=36578 (or at least the reports of that bug in C++ programs). That bug would occur for any C++ user with a coroutine frame that took a single pointer argument, since it would then find the global placement form `operator new`, described in the C++ standard 18.6.1.3.1. This patch prevents Clang from generating code that triggers the LLVM assert described in that bug report. Test Plan: `check-clang` Reviewers: GorNishanov, eric_niebler, lewissbaker Reviewed By: GorNishanov Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D44552 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/test/CodeGenCoroutines/coro-alloc.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=328949&r1=328948&r2=328949&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Sun Apr 1 15:59:22 2018 @@ -5140,8 +5140,25 @@ public: bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R); + + /// \brief The scope in which to find allocation functions. + enum AllocationFunctionScope { +/// \brief Only look for allocation functions in the global scope. +AFS_Global, +/// \brief Only look for allocation functions in the scope of the +/// allocated class. +AFS_Class, +/// \brief Look for allocation functions in both the global scope +/// and in the scope of the allocated class. +AFS_Both + }; + + /// \brief Finds the overloads of operator new and delete that are appropriate + /// for the allocation. bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, - bool UseGlobal, QualType AllocType, bool IsArray, + AllocationFunctionScope NewScope, + AllocationFunctionScope DeleteScope, + QualType AllocType, bool IsArray, bool &PassAlignment, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete, Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=328949&r1=328948&r2=328949&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sun Apr 1 15:59:22 2018 @@ -1110,8 +1110,8 @@ bool CoroutineStmtBuilder::makeNewAndDel PlacementArgs.push_back(PDRefExpr.get()); } - S.FindAllocationFunctions(Loc, SourceRange(), -/*UseGlobal*/ false, PromiseType, + S.FindAllocationFunctions(Loc, SourceRange(), /*NewScope*/ Sema::AFS_Class, +/*DeleteScope*/ Sema::AFS_Both, PromiseType, /*isArray*/ false, PassAlignment, PlacementArgs, OperatorNew, UnusedResult, /*Diagnose*/ false); @@ -1121,10 +1121,21 @@ bool CoroutineStmtBuilder::makeNewAndDel // an argument of type std::size_t." if (!OperatorNew && !PlacementArgs.empty()) { PlacementArgs.clear(); -S.FindAllocationFunctions(Loc, SourceRange(), - /*UseGlobal*/ false, PromiseType, - /*isArray*/ false, PassAlignment, - PlacementArgs, OperatorNew, UnusedResult); +S.FindAllocationFunctions(Loc, SourceRange(), /*NewScope*/ Sema::AFS_Class, + /*DeleteScope*/ Sema::AFS_Both, PromiseType, + /*isArray*/ false, PassAlignment, PlacementArgs, + OperatorNew, UnusedResult, /*Diagnose*/ false); + } + + // [dcl
r328951 - [Coroutines] Schedule coro-split before asan
Author: modocache Date: Sun Apr 1 16:55:21 2018 New Revision: 328951 URL: http://llvm.org/viewvc/llvm-project?rev=328951&view=rev Log: [Coroutines] Schedule coro-split before asan Summary: The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that "The second argument, if not null, designates a particular alloca instruction to be a coroutine promise." However, if the address sanitizer pass is run before the `@llvm.coro.id` intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its second argument is converted, as per the https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to an `inttoptr` instruction that accesses the address of the promise. On optimization levels `-O1` and above, the `-asan` pass is run after `-coro-early`, `-coro-split`, and `-coro-elide`, and before `-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan` is run in between `-coro-early` and `-coro-split`, which causes an assertion to be hit when the `inttoptr` instruction is forcibly cast to an `alloca`. Rearrange the passes such that the coroutine passes are registered before the sanitizer passes. Test Plan: Compile a simple C++ program that uses coroutines in `-O0` with `-fsanitize-address`, and confirm no assertion is hit: `clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address -fno-omit-frame-pointer`. Reviewers: GorNishanov, lewissbaker, EricWF Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43927 Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=328951&r1=328950&r2=328951&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sun Apr 1 16:55:21 2018 @@ -541,6 +541,9 @@ void EmitAssemblyHelper::CreatePasses(le addObjCARCOptPass); } + if (LangOpts.CoroutinesTS) +addCoroutinePassesToExtensionPoints(PMBuilder); + if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) { PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate, addBoundsCheckingPass); @@ -599,9 +602,6 @@ void EmitAssemblyHelper::CreatePasses(le addDataFlowSanitizerPass); } - if (LangOpts.CoroutinesTS) -addCoroutinePassesToExtensionPoints(PMBuilder); - if (LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency)) { PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, addEfficiencySanitizerPass); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306862 - [ORE] Use LLVM's "diagnostics hotness" spelling
Author: modocache Date: Fri Jun 30 12:37:11 2017 New Revision: 306862 URL: http://llvm.org/viewvc/llvm-project?rev=306862&view=rev Log: [ORE] Use LLVM's "diagnostics hotness" spelling Summary: Depends on https://reviews.llvm.org/D34864. To unify Clang and LLVM's spelling of "diagnostic[s] hotness", use the new "diagnostics hotness" spelling in LLVM, which was added in https://reviews.llvm.org/D34864. Reviewers: anemet, davidxl Reviewed By: anemet Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34865 Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=306862&r1=306861&r2=306862&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Jun 30 12:37:11 2017 @@ -228,7 +228,7 @@ namespace clang { Ctx.getDiagnosticHandler(); void *OldDiagnosticContext = Ctx.getDiagnosticContext(); Ctx.setDiagnosticHandler(DiagnosticHandler, this); - Ctx.setDiagnosticHotnessRequested(CodeGenOpts.DiagnosticsWithHotness); + Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness); std::unique_ptr OptRecordFile; if (!CodeGenOpts.OptRecordFile.empty()) { @@ -246,7 +246,7 @@ namespace clang { llvm::make_unique(OptRecordFile->os())); if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone) - Ctx.setDiagnosticHotnessRequested(true); + Ctx.setDiagnosticsHotnessRequested(true); } // Link each LinkModule into our module. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306945 - [Driver] Add -fdiagnostics-hotness-threshold
Author: modocache Date: Fri Jun 30 21:44:38 2017 New Revision: 306945 URL: http://llvm.org/viewvc/llvm-project?rev=306945&view=rev Log: [Driver] Add -fdiagnostics-hotness-threshold Summary: Depends on https://reviews.llvm.org/D34867. Add a Clang frontend option to enable optimization remark hotness thresholds, which were added to LLVM in https://reviews.llvm.org/D34867. This prevents diagnostics that do not meet a minimum hotness threshold from being output. When generating optimization remarks for large codebases with a ton of cold code paths, this option can be used to limit the optimization remark output at a reasonable size. Discussion of this change can be read here: http://lists.llvm.org/pipermail/llvm-dev/2017-June/114377.html Reviewers: anemet, davidxl, hfinkel Reviewed By: anemet Subscribers: fhahn, cfe-commits Differential Revision: https://reviews.llvm.org/D34868 Modified: cfe/trunk/docs/UsersManual.rst cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306945&r1=306944&r2=306945&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 21:44:38 2017 @@ -322,18 +322,27 @@ output format of the diagnostics that it by category, so it should be a high level category. We want dozens of these, not hundreds or thousands of them. +.. _opt_fsave-optimization-record: + +**-fsave-optimization-record** + Write optimization remarks to a YAML file. + + This option, which defaults to off, controls whether Clang writes + optimization reports to a YAML file. By recording diagnostics in a file, + using a structured YAML format, users can parse or sort the remarks in a + convenient way. + .. _opt_fdiagnostics-show-hotness: **-f[no-]diagnostics-show-hotness** Enable profile hotness information in diagnostic line. - This option, which defaults to off, controls whether Clang prints the - profile hotness associated with a diagnostics in the presence of - profile-guided optimization information. This is currently supported with - optimization remarks (see :ref:`Options to Emit Optimization Reports - `). The hotness information allows users to focus on the hot - optimization remarks that are likely to be more relevant for run-time - performance. + This option controls whether Clang prints the profile hotness associated + with diagnostics in the presence of profile-guided optimization information. + This is currently supported with optimization remarks (see + :ref:`Options to Emit Optimization Reports `). The hotness information + allows users to focus on the hot optimization remarks that are likely to be + more relevant for run-time performance. For example, in this output, the block containing the callsite of `foo` was executed 3000 times according to the profile data: @@ -344,6 +353,23 @@ output format of the diagnostics that it sum += foo(x, x - 2); ^ + This option is implied when + :ref:`-fsave-optimization-record ` is used. + Otherwise, it defaults to off. + +.. _opt_fdiagnostics-hotness-threshold + +**-fdiagnostics-hotness-threshold** + Prevent optimization remarks from being output if they do not have at least + this hotness value. + + This option, which defaults to zero, controls the minimum hotness an + optimization remark would need in order to be output by Clang. This is + currently supported with optimization remarks (see :ref:`Options to Emit + Optimization Reports `) when profile hotness information in + diagnostics is enabled (see + :ref:`-fdiagnostics-show-hotness `). + .. _opt_fdiagnostics-fixit-info: **-f[no-]diagnostics-fixit-info** Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306945&r1=306944&r2=306945&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 21:44:38 2017 @@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning< def warn_drv_empty_joined_argument : Warning< "joined argument expects additional value: '%0'">, InGroup; -def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning< - "argument '-fdiagnostics-show-hotness'
r306946 - Revert "[Driver] Add -fdiagnostics-hotness-threshold"
Author: modocache Date: Fri Jun 30 21:54:53 2017 New Revision: 306946 URL: http://llvm.org/viewvc/llvm-project?rev=306946&view=rev Log: Revert "[Driver] Add -fdiagnostics-hotness-threshold" Summary: The commit caused a documentation breakage. Modified: cfe/trunk/docs/UsersManual.rst cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306946&r1=306945&r2=306946&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 21:54:53 2017 @@ -322,27 +322,18 @@ output format of the diagnostics that it by category, so it should be a high level category. We want dozens of these, not hundreds or thousands of them. -.. _opt_fsave-optimization-record: - -**-fsave-optimization-record** - Write optimization remarks to a YAML file. - - This option, which defaults to off, controls whether Clang writes - optimization reports to a YAML file. By recording diagnostics in a file, - using a structured YAML format, users can parse or sort the remarks in a - convenient way. - .. _opt_fdiagnostics-show-hotness: **-f[no-]diagnostics-show-hotness** Enable profile hotness information in diagnostic line. - This option controls whether Clang prints the profile hotness associated - with diagnostics in the presence of profile-guided optimization information. - This is currently supported with optimization remarks (see - :ref:`Options to Emit Optimization Reports `). The hotness information - allows users to focus on the hot optimization remarks that are likely to be - more relevant for run-time performance. + This option, which defaults to off, controls whether Clang prints the + profile hotness associated with a diagnostics in the presence of + profile-guided optimization information. This is currently supported with + optimization remarks (see :ref:`Options to Emit Optimization Reports + `). The hotness information allows users to focus on the hot + optimization remarks that are likely to be more relevant for run-time + performance. For example, in this output, the block containing the callsite of `foo` was executed 3000 times according to the profile data: @@ -353,23 +344,6 @@ output format of the diagnostics that it sum += foo(x, x - 2); ^ - This option is implied when - :ref:`-fsave-optimization-record ` is used. - Otherwise, it defaults to off. - -.. _opt_fdiagnostics-hotness-threshold - -**-fdiagnostics-hotness-threshold** - Prevent optimization remarks from being output if they do not have at least - this hotness value. - - This option, which defaults to zero, controls the minimum hotness an - optimization remark would need in order to be output by Clang. This is - currently supported with optimization remarks (see :ref:`Options to Emit - Optimization Reports `) when profile hotness information in - diagnostics is enabled (see - :ref:`-fdiagnostics-show-hotness `). - .. _opt_fdiagnostics-fixit-info: **-f[no-]diagnostics-fixit-info** Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306946&r1=306945&r2=306946&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 21:54:53 2017 @@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning< def warn_drv_empty_joined_argument : Warning< "joined argument expects additional value: '%0'">, InGroup; -def warn_drv_diagnostics_hotness_requires_pgo : Warning< - "argument '%0' requires profile-guided optimization information">, +def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning< + "argument '-fdiagnostics-show-hotness' requires profile-guided optimization information">, InGroup; def warn_drv_clang_unsupported : Warning< "the clang compiler does not support '%0'">; Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=306946&r1=306945&r2=306946&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri
r306948 - Un-revert "[Driver] Add -fdiagnostics-hotness-threshold"
Author: modocache Date: Fri Jun 30 22:45:26 2017 New Revision: 306948 URL: http://llvm.org/viewvc/llvm-project?rev=306948&view=rev Log: Un-revert "[Driver] Add -fdiagnostics-hotness-threshold" Summary: Un-revert https://reviews.llvm.org/D34868, but with a slight tweak to the documentation to fix an error -- I had used the wrong syntax for a link. Modified: cfe/trunk/docs/UsersManual.rst cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/CodeGenAction.cpp cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Frontend/Inputs/optimization-remark-with-hotness-sample.proftext cfe/trunk/test/Frontend/optimization-remark-with-hotness.c Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=306948&r1=306947&r2=306948&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Fri Jun 30 22:45:26 2017 @@ -322,18 +322,27 @@ output format of the diagnostics that it by category, so it should be a high level category. We want dozens of these, not hundreds or thousands of them. +.. _opt_fsave-optimization-record: + +**-fsave-optimization-record** + Write optimization remarks to a YAML file. + + This option, which defaults to off, controls whether Clang writes + optimization reports to a YAML file. By recording diagnostics in a file, + using a structured YAML format, users can parse or sort the remarks in a + convenient way. + .. _opt_fdiagnostics-show-hotness: **-f[no-]diagnostics-show-hotness** Enable profile hotness information in diagnostic line. - This option, which defaults to off, controls whether Clang prints the - profile hotness associated with a diagnostics in the presence of - profile-guided optimization information. This is currently supported with - optimization remarks (see :ref:`Options to Emit Optimization Reports - `). The hotness information allows users to focus on the hot - optimization remarks that are likely to be more relevant for run-time - performance. + This option controls whether Clang prints the profile hotness associated + with diagnostics in the presence of profile-guided optimization information. + This is currently supported with optimization remarks (see + :ref:`Options to Emit Optimization Reports `). The hotness information + allows users to focus on the hot optimization remarks that are likely to be + more relevant for run-time performance. For example, in this output, the block containing the callsite of `foo` was executed 3000 times according to the profile data: @@ -344,6 +353,23 @@ output format of the diagnostics that it sum += foo(x, x - 2); ^ + This option is implied when + :ref:`-fsave-optimization-record ` is used. + Otherwise, it defaults to off. + +.. _opt_fdiagnostics-hotness-threshold: + +**-fdiagnostics-hotness-threshold** + Prevent optimization remarks from being output if they do not have at least + this hotness value. + + This option, which defaults to zero, controls the minimum hotness an + optimization remark would need in order to be output by Clang. This is + currently supported with optimization remarks (see :ref:`Options to Emit + Optimization Reports `) when profile hotness information in + diagnostics is enabled (see + :ref:`-fdiagnostics-show-hotness `). + .. _opt_fdiagnostics-fixit-info: **-f[no-]diagnostics-fixit-info** Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=306948&r1=306947&r2=306948&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 30 22:45:26 2017 @@ -198,8 +198,8 @@ def warn_drv_unused_argument : Warning< def warn_drv_empty_joined_argument : Warning< "joined argument expects additional value: '%0'">, InGroup; -def warn_drv_fdiagnostics_show_hotness_requires_pgo : Warning< - "argument '-fdiagnostics-show-hotness' requires profile-guided optimization information">, +def warn_drv_diagnostics_hotness_requires_pgo : Warning< + "argument '%0' requires profile-guided optimization information">, InGroup; def warn_drv_clang_unsupported : Warning< "the clang compiler does not support '%0'">; Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=306948&r1=306947&r2=306948&view=diff ==
r307193 - Add docs for -foptimization-record-file=
Author: modocache Date: Wed Jul 5 12:55:51 2017 New Revision: 307193 URL: http://llvm.org/viewvc/llvm-project?rev=307193&view=rev Log: Add docs for -foptimization-record-file= Summary: The Clang option was previously not included in the User's Manual. Reviewers: anemet, davidxl, hfinkel Reviewed By: hfinkel Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34928 Modified: cfe/trunk/docs/UsersManual.rst Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=307193&r1=307192&r2=307193&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Wed Jul 5 12:55:51 2017 @@ -332,6 +332,19 @@ output format of the diagnostics that it using a structured YAML format, users can parse or sort the remarks in a convenient way. +.. _opt_foptimization-record-file: + +**-foptimization-record-file** + Control the file to which optimization reports are written. + + When optimization reports are being output (see + :ref:`-fsave-optimization-record `), this + option controls the file to which those reports are written. + + If this option is not used, optimization records are output to a file named + after the primary file being compiled. If that's "foo.c", for example, + optimization records are output to "foo.opt.yaml". + .. _opt_fdiagnostics-show-hotness: **-f[no-]diagnostics-show-hotness** ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308205 - [Basic] Detect Git submodule version in CMake
Author: modocache Date: Mon Jul 17 12:22:57 2017 New Revision: 308205 URL: http://llvm.org/viewvc/llvm-project?rev=308205&view=rev Log: [Basic] Detect Git submodule version in CMake Summary: When searching for Git version control information, libBasic's CMake checks for the path '.git/logs/HEAD'. However, when LLVM is included as a Git submodule, this path does not exist. Instead, it contains a '.git' file with the following: ``` gitdir: ../../.git/modules/external/llvm ``` Where '../..' is the relative path to the root repository that contains the LLVM Git submodule. Because of this discrepancy, `clang --version` does not output source control information if built from a Git submodule. To fix, check whether '.git' is a directory or a file. If it's a directory, simply use the '.git/logs/HEAD' path. If it's a file, read it and check for the tell-tale sign of a Git submodule: the text "gitdir:". If it exists, follow that path and use the 'logs/HEAD' at that location instead. This allows not only the correct revision information to be retrieved, but also uses a file that will change with each source control revision. Test Plan: 1. Before applying this change, build Clang as a Git submodule in a repository that places it in external/clang, and confirm no revision information is output when `clang --version` is invoked (just "clang 5.0.0" is output, no Git hashes). 2. Apply these changes and build Clang as a Git repository nested under llvm/tools/clang, and confirm that `clang --version` displays correct version information. 3. Apply these changes and build Clang as a Git submodule using the structure described in (1), and confirm version control information is output as in (2). Reviewers: jordan_rose, beanz, probinson Reviewed By: jordan_rose Subscribers: chapuni, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D34955 Modified: cfe/trunk/lib/Basic/CMakeLists.txt Modified: cfe/trunk/lib/Basic/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=308205&r1=308204&r2=308205&view=diff == --- cfe/trunk/lib/Basic/CMakeLists.txt (original) +++ cfe/trunk/lib/Basic/CMakeLists.txt Mon Jul 17 12:22:57 2017 @@ -15,8 +15,23 @@ function(find_first_existing_file out_va endfunction() macro(find_first_existing_vc_file out_var path) + set(git_path "${path}/.git") + + # Normally '.git' is a directory that contains a 'logs/HEAD' file that + # is updated as modifications are made to the repository. In case the + # repository is a Git submodule, '.git' is a file that contains text that + # indicates where the repository's Git directory exists. + if (EXISTS "${git_path}" AND NOT IS_DIRECTORY "${git_path}") +FILE(READ "${git_path}" file_contents) +if("${file_contents}" MATCHES "^gitdir: ([^\n]+)") + # '.git' is indeed a link to the submodule's Git directory. + # Use the path to that Git directory. + set(git_path "${path}/${CMAKE_MATCH_1}") +endif() + endif() + find_first_existing_file(${out_var} -"${path}/.git/logs/HEAD" # Git +"${git_path}/logs/HEAD" # Git or Git submodule "${path}/.svn/wc.db" # SVN 1.7 "${path}/.svn/entries" # SVN 1.6 ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322445 - [Driver] Add "did you mean?" suggestions to -cc1as
Author: modocache Date: Sat Jan 13 09:09:11 2018 New Revision: 322445 URL: http://llvm.org/viewvc/llvm-project?rev=322445&view=rev Log: [Driver] Add "did you mean?" suggestions to -cc1as Summary: In https://reviews.llvm.org/D41733, the driver was modified such that, when a user provided a mispelled option such as `-hel`, it would suggest a valid option with a nearby edit distance: "did you mean '-help'?". Add these suggestions to invocations of `clang -cc1as` as well. Test Plan: `check-clang` Reviewers: v.g.vassilev, bruno Reviewed By: v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42001 Modified: cfe/trunk/test/Driver/unknown-arg.c cfe/trunk/tools/driver/cc1as_main.cpp Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=322445&r1=322444&r2=322445&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Sat Jan 13 09:09:11 2018 @@ -12,6 +12,8 @@ // RUN: FileCheck %s --check-prefix=CL-ERROR-DID-YOU-MEAN // RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -Wno-unknown-argument -### -- %s 2>&1 | \ // RUN: FileCheck %s --check-prefix=SILENT +// RUN: not %clang -cc1as -hell --version -debug-info-macros 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CC1AS-DID-YOU-MEAN // CHECK: error: unknown argument: '-cake-is-lie' // CHECK: error: unknown argument: '-%0' @@ -41,6 +43,9 @@ // CL-ERROR-DID-YOU-MEAN: error: unknown argument ignored in clang-cl '-helo' (did you mean '-help'?) // SILENT-NOT: error: // SILENT-NOT: warning: +// CC1AS-DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? +// CC1AS-DID-YOU-MEAN: error: unknown argument '--version', did you mean '-version'? +// CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros', did you mean '-debug-info-macro'? // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Modified: cfe/trunk/tools/driver/cc1as_main.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=322445&r1=322444&r2=322445&view=diff == --- cfe/trunk/tools/driver/cc1as_main.cpp (original) +++ cfe/trunk/tools/driver/cc1as_main.cpp Sat Jan 13 09:09:11 2018 @@ -181,7 +181,13 @@ bool AssemblerInvocation::CreateFromArgs // Issue errors on unknown arguments. for (const Arg *A : Args.filtered(OPT_UNKNOWN)) { -Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args); +auto ArgString = A->getAsString(Args); +std::string Nearest; +if (OptTbl->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1) + Diags.Report(diag::err_drv_unknown_argument) << ArgString; +else + Diags.Report(diag::err_drv_unknown_argument_with_suggestion) + << ArgString << Nearest; Success = false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322447 - [docs] Use monospace for PCH option flags
Author: modocache Date: Sat Jan 13 10:34:07 2018 New Revision: 322447 URL: http://llvm.org/viewvc/llvm-project?rev=322447&view=rev Log: [docs] Use monospace for PCH option flags Summary: Use monospace for option flags in the PCH section, instead of the italics that were being used previously. I believe these used to be links, for which single backticks would have been appropriate, but since they were un-link-ified in https://reviews.llvm.org/rL275560, I believe monospace is now more appropriate, and so two backticks are needed. Test Plan: Build the `docs-clang-html` target and confirm the options are rendered using monospace font. Reviewers: sepavloff, aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42005 Modified: cfe/trunk/docs/UsersManual.rst Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=322447&r1=322446&r2=322447&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Sat Jan 13 10:34:07 2018 @@ -1075,7 +1075,7 @@ location. Building a relocatable precompiled header requires two additional arguments. First, pass the ``--relocatable-pch`` flag to indicate that the resulting PCH file should be relocatable. Second, pass -`-isysroot /path/to/build`, which makes all includes for your library +``-isysroot /path/to/build``, which makes all includes for your library relative to the build directory. For example: .. code-block:: console @@ -1085,9 +1085,9 @@ relative to the build directory. For exa When loading the relocatable PCH file, the various headers used in the PCH file are found from the system header root. For example, ``mylib.h`` can be found in ``/usr/include/mylib.h``. If the headers are installed -in some other system root, the `-isysroot` option can be used provide +in some other system root, the ``-isysroot`` option can be used provide a different system root from which the headers will be based. For -example, `-isysroot /Developer/SDKs/MacOSX10.4u.sdk` will look for +example, ``-isysroot /Developer/SDKs/MacOSX10.4u.sdk`` will look for ``mylib.h`` in ``/Developer/SDKs/MacOSX10.4u.sdk/usr/include/mylib.h``. Relocatable precompiled headers are intended to be used in a limited ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322517 - [Driver] Suggest valid integrated tools
Author: modocache Date: Mon Jan 15 13:05:40 2018 New Revision: 322517 URL: http://llvm.org/viewvc/llvm-project?rev=322517&view=rev Log: [Driver] Suggest valid integrated tools Summary: There are only two valid integrated Clang driver tools: `-cc1` and `-cc1as`. If a user asks for an unknown tool, such as `-cc1asphalt`, an error message is displayed to indicate that there is no such tool, but the message doesn't indicate what the valid options are. Include the valid options in the error message. Test Plan: `check-clang` Reviewers: sepavloff, bkramer, phosek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D42004 Modified: cfe/trunk/test/Driver/unknown-arg.c cfe/trunk/tools/driver/driver.cpp Modified: cfe/trunk/test/Driver/unknown-arg.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unknown-arg.c?rev=322517&r1=322516&r2=322517&view=diff == --- cfe/trunk/test/Driver/unknown-arg.c (original) +++ cfe/trunk/test/Driver/unknown-arg.c Mon Jan 15 13:05:40 2018 @@ -14,6 +14,8 @@ // RUN: FileCheck %s --check-prefix=SILENT // RUN: not %clang -cc1as -hell --version -debug-info-macros 2>&1 | \ // RUN: FileCheck %s --check-prefix=CC1AS-DID-YOU-MEAN +// RUN: not %clang -cc1asphalt -help 2>&1 | \ +// RUN: FileCheck %s --check-prefix=UNKNOWN-INTEGRATED // CHECK: error: unknown argument: '-cake-is-lie' // CHECK: error: unknown argument: '-%0' @@ -46,7 +48,7 @@ // CC1AS-DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? // CC1AS-DID-YOU-MEAN: error: unknown argument '--version', did you mean '-version'? // CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros', did you mean '-debug-info-macro'? - +// UNKNOWN-INTEGRATED: error: unknown integrated tool 'asphalt'. Valid tools include '-cc1' and '-cc1as'. // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Modified: cfe/trunk/tools/driver/driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=322517&r1=322516&r2=322517&view=diff == --- cfe/trunk/tools/driver/driver.cpp (original) +++ cfe/trunk/tools/driver/driver.cpp Mon Jan 15 13:05:40 2018 @@ -311,7 +311,8 @@ static int ExecuteCC1Tool(ArrayRefhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r323381 - [coroutines] Pass coro func args to promise ctor
Author: modocache Date: Wed Jan 24 14:15:42 2018 New Revision: 323381 URL: http://llvm.org/viewvc/llvm-project?rev=323381&view=rev Log: [coroutines] Pass coro func args to promise ctor Summary: Use corutine function arguments to initialize a promise type, but only if the promise type defines a constructor that takes those arguments. Otherwise, fall back to the default constructor. Test Plan: check-clang Reviewers: rsmith, GorNishanov, eric_niebler Reviewed By: GorNishanov Subscribers: toby-allsopp, lewissbaker, EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D41820 Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/CoroutineStmtBuilder.h cfe/trunk/lib/Sema/ScopeInfo.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/CodeGenCoroutines/coro-params.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=323381&r1=323380&r2=323381&view=diff == --- cfe/trunk/include/clang/Sema/ScopeInfo.h (original) +++ cfe/trunk/include/clang/Sema/ScopeInfo.h Wed Jan 24 14:15:42 2018 @@ -22,6 +22,7 @@ #include "clang/Sema/CleanupInfo.h" #include "clang/Sema/Ownership.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSwitch.h" @@ -172,6 +173,10 @@ public: /// \brief The promise object for this coroutine, if any. VarDecl *CoroutinePromise = nullptr; + /// \brief A mapping between the coroutine function parameters that were moved + /// to the coroutine frame, and their move statements. + llvm::SmallMapVector CoroutineParameterMoves; + /// \brief The initial and final coroutine suspend points. std::pair CoroutineSuspends; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=323381&r1=323380&r2=323381&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 24 14:15:42 2018 @@ -8478,6 +8478,7 @@ public: StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit = false); StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs); + bool buildCoroutineParameterMoves(SourceLocation Loc); VarDecl *buildCoroutinePromise(SourceLocation Loc); void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body); Modified: cfe/trunk/lib/Sema/CoroutineStmtBuilder.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CoroutineStmtBuilder.h?rev=323381&r1=323380&r2=323381&view=diff == --- cfe/trunk/lib/Sema/CoroutineStmtBuilder.h (original) +++ cfe/trunk/lib/Sema/CoroutineStmtBuilder.h Wed Jan 24 14:15:42 2018 @@ -51,9 +51,6 @@ public: /// name lookup. bool buildDependentStatements(); - /// \brief Build just parameter moves. To use for rebuilding in TreeTransform. - bool buildParameterMoves(); - bool isInvalid() const { return !this->IsValid; } private: @@ -65,7 +62,6 @@ private: bool makeReturnObject(); bool makeGroDeclAndReturnStmt(); bool makeReturnOnAllocFailure(); - bool makeParamMoves(); }; } // end namespace clang Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=323381&r1=323380&r2=323381&view=diff == --- cfe/trunk/lib/Sema/ScopeInfo.cpp (original) +++ cfe/trunk/lib/Sema/ScopeInfo.cpp Wed Jan 24 14:15:42 2018 @@ -43,6 +43,7 @@ void FunctionScopeInfo::Clear() { // Coroutine state FirstCoroutineStmtLoc = SourceLocation(); CoroutinePromise = nullptr; + CoroutineParameterMoves.clear(); NeedsCoroutineSuspends = true; CoroutineSuspends.first = nullptr; CoroutineSuspends.second = nullptr; Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=323381&r1=323380&r2=323381&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed Jan 24 14:15:42 2018 @@ -494,9 +494,67 @@ VarDecl *Sema::buildCoroutinePromise(Sou CheckVariableDeclarationType(VD); if (VD->isInvalidDecl()) return nullptr; - ActOnUninitializedDecl(VD); + + auto *ScopeInfo = getCurFunction(); + // Build a list of arguments, based on the coroutine functions arguments, + // that will be passed to the promise type's constructor. + llvm::SmallVector
Re: [PATCH] D11773: [libclang] Document IB attribute cursor kinds
modocache added a comment. Because I happen to know what these kinds are! ;) But I agree--they should all be documented. I can look into what the other kinds mean and add appropriate documentation for those as well. Maybe in another commit? http://reviews.llvm.org/D11773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11772: [libclang] Add period to typedef kind docblock
modocache added a comment. I do! Thanks, @compnerd! http://reviews.llvm.org/D11772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12047: test/SemaObjC: Remove cruft in unused getter test
modocache created this revision. modocache added a reviewer: cfe-commits. The tests that verify that accessing a property without using the result emits a warning were needlessly complicated. Remove several layers of abstraction to make the tests much simpler to read and reason about. http://reviews.llvm.org/D12047 Files: test/SemaObjC/access-property-getter.m Index: test/SemaObjC/access-property-getter.m === --- test/SemaObjC/access-property-getter.m +++ test/SemaObjC/access-property-getter.m @@ -1,53 +1,17 @@ // RUN: %clang_cc1 -verify %s -@protocol NSObject -- (oneway void)release; +@protocol Protocol +- (oneway void) method; @end -@protocol XCOutputStreams -@end - - -@interface XCWorkQueueCommandInvocation -{ -id _outputStream; -} -@end - -@interface XCWorkQueueCommandSubprocessInvocation : XCWorkQueueCommandInvocation -@end - -@interface XCWorkQueueCommandLocalSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation -@end - -@interface XCWorkQueueCommandDistributedSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation -@end - -@interface XCWorkQueueCommandCacheFetchInvocation : XCWorkQueueCommandSubprocessInvocation - -@end - -@implementation XCWorkQueueCommandCacheFetchInvocation -- (id)harvestPredictivelyProcessedOutputFiles -{ - _outputStream.release;// expected-warning {{property access result unused - getters should not be used for side effects}} - return 0; +void accessMethodViaPropertySyntaxAndTriggerWarning(id object) { +object.method; // expected-warning {{property access result unused - getters should not be used for side effects}} } -@end // rdar://19137815 #pragma clang diagnostic ignored "-Wunused-getter-return-value" -@interface NSObject @end - -@interface I : NSObject -@property (copy) id window; -@end - -@implementation I -- (void) Meth { - [self window]; - self.window; +void accessMethodViaPropertySyntaxWhenWarningIsIgnoredDoesNotTriggerWarning(id object) { +object.method; } -@end Index: test/SemaObjC/access-property-getter.m === --- test/SemaObjC/access-property-getter.m +++ test/SemaObjC/access-property-getter.m @@ -1,53 +1,17 @@ // RUN: %clang_cc1 -verify %s -@protocol NSObject -- (oneway void)release; +@protocol Protocol +- (oneway void) method; @end -@protocol XCOutputStreams -@end - - -@interface XCWorkQueueCommandInvocation -{ -id _outputStream; -} -@end - -@interface XCWorkQueueCommandSubprocessInvocation : XCWorkQueueCommandInvocation -@end - -@interface XCWorkQueueCommandLocalSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation -@end - -@interface XCWorkQueueCommandDistributedSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation -@end - -@interface XCWorkQueueCommandCacheFetchInvocation : XCWorkQueueCommandSubprocessInvocation - -@end - -@implementation XCWorkQueueCommandCacheFetchInvocation -- (id)harvestPredictivelyProcessedOutputFiles -{ - _outputStream.release; // expected-warning {{property access result unused - getters should not be used for side effects}} - return 0; +void accessMethodViaPropertySyntaxAndTriggerWarning(id object) { +object.method; // expected-warning {{property access result unused - getters should not be used for side effects}} } -@end // rdar://19137815 #pragma clang diagnostic ignored "-Wunused-getter-return-value" -@interface NSObject @end - -@interface I : NSObject -@property (copy) id window; -@end - -@implementation I -- (void) Meth { - [self window]; - self.window; +void accessMethodViaPropertySyntaxWhenWarningIsIgnoredDoesNotTriggerWarning(id object) { +object.method; } -@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12048: Verify no result unused warning on macro expansion
modocache created this revision. modocache added a reviewer: cfe-commits. Depends on http://reviews.llvm.org/D12047. Add a unit test which demonstrates the bug reported in https://llvm.org/bugs/show_bug.cgi?id=24404. If the macro is enclosed within parentheses, the warning is reported as expected. Without parentheses, no warning is emitted--this is a bug. http://reviews.llvm.org/D12048 Files: test/SemaObjC/access-property-getter.m Index: test/SemaObjC/access-property-getter.m === --- test/SemaObjC/access-property-getter.m +++ test/SemaObjC/access-property-getter.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -fblocks -verify %s @protocol Protocol - (oneway void) method; @@ -9,9 +9,27 @@ } // rdar://19137815 +#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-getter-return-value" void accessMethodViaPropertySyntaxWhenWarningIsIgnoredDoesNotTriggerWarning(id object) { object.method; } +#pragma clang diagnostic pop + +@protocol ProtocolWithBlockProperty +@property (readonly) void (^blockProperty)(void); +@end + +id protocolWithBlockPropertyConstructor(void); +#define protocolWithBlockPropertyConstructorMacro protocolWithBlockPropertyConstructor + +void accessBlockPropertyDoesNotTriggerWarning(void) { +protocolWithBlockPropertyConstructorMacro().blockProperty; +} + +void accessBlockPropertyInParenthesesTriggersWarning(void) { +(protocolWithBlockPropertyConstructorMacro()).blockProperty; // expected-warning {{property access result unused - getters should not be used for side effects}} +} + Index: test/SemaObjC/access-property-getter.m === --- test/SemaObjC/access-property-getter.m +++ test/SemaObjC/access-property-getter.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -fblocks -verify %s @protocol Protocol - (oneway void) method; @@ -9,9 +9,27 @@ } // rdar://19137815 +#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-getter-return-value" void accessMethodViaPropertySyntaxWhenWarningIsIgnoredDoesNotTriggerWarning(id object) { object.method; } +#pragma clang diagnostic pop + +@protocol ProtocolWithBlockProperty +@property (readonly) void (^blockProperty)(void); +@end + +id protocolWithBlockPropertyConstructor(void); +#define protocolWithBlockPropertyConstructorMacro protocolWithBlockPropertyConstructor + +void accessBlockPropertyDoesNotTriggerWarning(void) { +protocolWithBlockPropertyConstructorMacro().blockProperty; +} + +void accessBlockPropertyInParenthesesTriggersWarning(void) { +(protocolWithBlockPropertyConstructorMacro()).blockProperty; // expected-warning {{property access result unused - getters should not be used for side effects}} +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12050: docs: Prefer 'check-clang' to 'clang-test'
modocache created this revision. modocache added a subscriber: cfe-commits. r159483 changed the canonical name of the Clang test target from 'clang-test' to 'check-clang'. Although the old name is still a valid alias, update the documentation to use the new, canonical target name. http://reviews.llvm.org/D12050 Files: docs/LibASTMatchersTutorial.rst www/hacking.html Index: www/hacking.html === --- www/hacking.html +++ www/hacking.html @@ -122,7 +122,7 @@ about what is being run. If you built LLVM and Clang using CMake, the test suite can be run - with make clang-test from the top-level LLVM directory. + with make check-clang from the top-level LLVM directory. The tests primarily consist of a test runner script running the compiler under test on individual test files grouped in the directories under the Index: docs/LibASTMatchersTutorial.rst === --- docs/LibASTMatchersTutorial.rst +++ docs/LibASTMatchersTutorial.rst @@ -60,7 +60,7 @@ cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON # Enable tests; default is off. ninja ninja check # Test LLVM only. - ninja clang-test # Test Clang only. + ninja check-clang # Test Clang only. ninja install And we're live. Index: www/hacking.html === --- www/hacking.html +++ www/hacking.html @@ -122,7 +122,7 @@ about what is being run. If you built LLVM and Clang using CMake, the test suite can be run - with make clang-test from the top-level LLVM directory. + with make check-clang from the top-level LLVM directory. The tests primarily consist of a test runner script running the compiler under test on individual test files grouped in the directories under the Index: docs/LibASTMatchersTutorial.rst === --- docs/LibASTMatchersTutorial.rst +++ docs/LibASTMatchersTutorial.rst @@ -60,7 +60,7 @@ cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON # Enable tests; default is off. ninja ninja check # Test LLVM only. - ninja clang-test # Test Clang only. + ninja check-clang # Test Clang only. ninja install And we're live. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12047: test/SemaObjC: Remove cruft in unused getter test
modocache added a comment. > Why do you think it's a cruft? Seems it's a bit more verbose than it should be The verbosity is the cruft, in my opinion. Why spend thirty lines of code to demonstrate behavior that could be demonstrated in just five? > but what is missing in your test is inheritance, which is important. Is it, though? I haven't read the source code completely, but there doesn't seem to be anything in there written specifically to handle inheritence as deep as the test had it. I believe the relevant code is in `Expr::isUnusedResultAWarning()`, which has case statements for `case ObjCMessageExprClass` and `case ObjCPropertyRefExprClass`. The behavior doesn't change based on where those are defined, whether on a base class or, as in this change, on a protocol. > I think the code for the initial test was just extracted from a real project. Yep, based on the header prefix `XC` I'm guessing it was something in Xcode. And while I appreciate the fact that it's a "real-world" example, I think it's valuable to reduce this sort of thing to the minimum amount of code necessary to demonstrate the behavior. http://reviews.llvm.org/D12047 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11772: [libclang] Add period to typedef kind docblock
modocache added a comment. Cool, thanks @compnerd! http://reviews.llvm.org/D11772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D2916: [libclang][python] Add test for Index read
modocache added a reviewer: ddunbar. modocache added a subscriber: ddunbar. modocache added a comment. Adding @ddunbar, who added the original FIXME, as a reviewer. http://reviews.llvm.org/D2916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11797: [libclang] Expose the ElaboratedType
modocache added a subscriber: modocache. Comment at: bindings/python/clang/cindex.py:1875 @@ -1873,1 +1874,3 @@ +def getElabaratedTypeUnderlyingType(self): +""" Awesome, thanks for updating the Python bindings as well! As with the C function, I believe this is a typo--shouldn't it be `getElaboratedTypeUnderlyingType`? Furthermore, the convention in Python (and in this file) is to use snake_case, so this should probably be `get_elaborated_type_underlying_type`. Comment at: include/clang-c/Index.h:2859 @@ -2859,1 +2858,3 @@ + CXType_MemberPointer = 117, + CXType_Elaborated = 118 }; Tangential to this diff, but is there a reason these `CXTypeKind` enum values are undocumented? I can see how many would be familiar to most users, but I don't think "elaborated" is something that many users would immediately recognize. Should these be documented? Comment at: include/clang-c/Index.h:3224 @@ -3222,1 +3223,3 @@ /** + * \brief Return the inner type of elaborated type + * nit: Other `\brief` documentation in this file uses periods at the end of sentences. For example, `clang_getArraySize`, the function immediately prior to this newly added function, has the brief `-\brief Return the array size of a constant array.`--notice the trailing period. Comment at: include/clang-c/Index.h:3226 @@ +3225,3 @@ + * + * If a non-elaborated type passed, CXType_Invalid type returned + */ nit: Rather than reference the `CXType_Invalid` type directly, most of the other documentation in this file states `"an invalid type is returned."` Comment at: include/clang-c/Index.h:3228 @@ +3227,3 @@ + */ +CXType clang_getElabaratedTypeUnderlyingType(CXType T); + I believe this is a typo--shouldn't it be `clang_getElaboratedTypeUnderlyingType`? Comment at: tools/libclang/CXType.cpp:987 @@ +986,3 @@ + if (TP && TP->getTypeClass() == Type::Elaborated) +return MakeCXType(cast(TP)->getNamedType(), GetTU(CT)); + The documentation of `getNamedType()` itself states `"Retrieve the type named by the qualified-id."`. As such, would it make sense to call this function `clang_getNamedTypeUnderlyingElaboratedType`, instead of `clang_getElaboratedTypeUnderlyingType`? http://reviews.llvm.org/D11797 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D11797: [libclang] Expose the ElaboratedType
modocache accepted this revision. modocache added a reviewer: modocache. modocache added a comment. This revision is now accepted and ready to land. Looks good to me! I don't have commit access, though, so you'll probably have to find a committer to review/commit for you, @skalinichev. http://reviews.llvm.org/D11797 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits