r363804 - Allow copy/move assignment operator to be coroutine as per N4775

2019-06-19 Thread Vivek Pandya via cfe-commits
Author: vivekvpandya
Date: Wed Jun 19 07:12:19 2019
New Revision: 363804

URL: http://llvm.org/viewvc/llvm-project?rev=363804=rev
Log:
Allow copy/move assignment operator to be coroutine as per N4775

This change fixes https://bugs.llvm.org/show_bug.cgi?id=40997.

Reviewers: GorNishanov, rsmith
Reviewed by: GorNishanov
Subscribers: cfe-commits, lewissbaker, modocache, llvm-commits

Differential Revision: https://reviews.llvm.org/D63381

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
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=363804=363803=363804=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 19 07:12:19 
2019
@@ -9432,9 +9432,9 @@ def err_coroutine_outside_function : Err
   "'%0' cannot be used outside a function">;
 def err_coroutine_invalid_func_context : Error<
   "'%1' cannot be used in %select{a constructor|a destructor"
-  "|a copy assignment operator|a move assignment operator|the 'main' function"
-  "|a constexpr function|a function with a deduced return type"
-  "|a varargs function|a consteval function}0">;
+  "|the 'main' function|a constexpr function"
+  "|a function with a deduced return type|a varargs function"
+  "|a consteval function}0">;
 def err_implied_coroutine_type_not_found : Error<
   "%0 type was not found; include  before defining "
   "a coroutine">;

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=363804=363803=363804=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed Jun 19 07:12:19 2019
@@ -204,8 +204,6 @@ static bool isValidCoroutineContext(Sema
   enum InvalidFuncDiag {
 DiagCtor = 0,
 DiagDtor,
-DiagCopyAssign,
-DiagMoveAssign,
 DiagMain,
 DiagConstexpr,
 DiagAutoRet,
@@ -219,23 +217,15 @@ static bool isValidCoroutineContext(Sema
 return false;
   };
 
-  // Diagnose when a constructor, destructor, copy/move assignment operator,
+  // Diagnose when a constructor, destructor
   // or the function 'main' are declared as a coroutine.
   auto *MD = dyn_cast(FD);
-  // [class.ctor]p6: "A constructor shall not be a coroutine."
+  // [class.ctor]p11: "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);

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=363804=363803=363804=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed Jun 19 07:12:19 2019
@@ -296,18 +296,17 @@ struct CtorDtor {
   ~CtorDtor() {
 co_return 0; // expected-error {{'co_return' cannot be used in a 
destructor}}
   }
-  // FIXME: The spec says this is ill-formed.
   void operator=(CtorDtor&) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor const &) {
-co_yield 0; // expected-error {{'co_yield' cannot be used in a copy 
assignment operator}}
+co_yield 0; // OK.
   }
   void operator=(CtorDtor &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(CtorDtor const &&) {
-co_await a; // expected-error {{'co_await' cannot be used in a move 
assignment operator}}
+co_await a; // OK.
   }
   void operator=(int) {
 co_await a; // OK. Not a special member


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33514: [WIP] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled

2017-09-16 Thread vivek pandya via cfe-commits
Thanks for doing this! It has been long time I work on big change for LLVM
so sorry for forgetting that.

On Saturday, September 16, 2017, NAKAMURA Takumi via Phabricator <
revi...@reviews.llvm.org> wrote:

> chapuni added a comment.
>
> Fixed in https://reviews.llvm.org/rL313456.
>
>
>
> 
> Comment at: include/llvm/IR/DiagnosticHandler.h:12
> +//===--
> ===//
> +
> +#include "llvm/ADT/StringRef.h"
> 
> Did you forget include guard here?
>
>
> https://reviews.llvm.org/D33514
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313389 - This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352 LLVM code change is as per https://reviews.llvm.org/D33514

2017-09-15 Thread Vivek Pandya via cfe-commits
Author: vivekvpandya
Date: Fri Sep 15 13:09:55 2017
New Revision: 313389

URL: http://llvm.org/viewvc/llvm-project?rev=313389=rev
Log:
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=32352 LLVM code change 
is as per https://reviews.llvm.org/D33514

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=313389=313388=313389=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Sep 15 13:09:55 2017
@@ -46,6 +46,31 @@ using namespace clang;
 using namespace llvm;
 
 namespace clang {
+  class BackendConsumer;
+  class ClangDiagnosticHandler final : public DiagnosticHandler {
+  public:
+ClangDiagnosticHandler(const CodeGenOptions , BackendConsumer *BCon)
+: CodeGenOpts(CGOpts), BackendCon(BCon) {}
+  
+bool handleDiagnostics(const DiagnosticInfo ) override;
+bool isAnalysisRemarkEnable(const std::string ) {
+  return (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
+  CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName));
+}
+bool isMissedOptRemarkEnable(const std::string ) {
+  return (CodeGenOpts.OptimizationRemarkMissedPattern &&
+  CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName));
+}
+bool isPassedOptRemarkEnable(const std::string ) {
+  return (CodeGenOpts.OptimizationRemarkPattern &&
+  CodeGenOpts.OptimizationRemarkPattern->match(PassName));
+}
+  
+  private:
+const CodeGenOptions 
+BackendConsumer *BackendCon;
+  };
+
   class BackendConsumer : public ASTConsumer {
 using LinkModule = CodeGenAction::LinkModule;
 
@@ -224,10 +249,10 @@ namespace clang {
   void *OldContext = Ctx.getInlineAsmDiagnosticContext();
   Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this);
 
-  LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler =
+  std::unique_ptr OldDiagnosticHandler =
   Ctx.getDiagnosticHandler();
-  void *OldDiagnosticContext = Ctx.getDiagnosticContext();
-  Ctx.setDiagnosticHandler(DiagnosticHandler, this);
+  Ctx.setDiagnosticHandler(llvm::make_unique(
+CodeGenOpts, this));
   Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
   if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
 Ctx.setDiagnosticsHotnessThreshold(
@@ -264,7 +289,7 @@ namespace clang {
 
   Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext);
 
-  Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext);
+  Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
 
   if (OptRecordFile)
 OptRecordFile->keep();
@@ -299,11 +324,6 @@ namespace clang {
   ((BackendConsumer*)Context)->InlineAsmDiagHandler2(SM, Loc);
 }
 
-static void DiagnosticHandler(const llvm::DiagnosticInfo ,
-  void *Context) {
-  ((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI);
-}
-
 /// Get the best possible source location to represent a diagnostic that
 /// may have associated debug info.
 const FullSourceLoc
@@ -343,6 +363,11 @@ namespace clang {
   void BackendConsumer::anchor() {}
 }
 
+bool ClangDiagnosticHandler::handleDiagnostics(const DiagnosticInfo ) {
+  BackendCon->DiagnosticHandlerImpl(DI);
+  return true;
+}
+
 /// ConvertBackendLocation - Convert a location in a temporary llvm::SourceMgr
 /// buffer to be a valid FullSourceLoc.
 static FullSourceLoc ConvertBackendLocation(const llvm::SMDiagnostic ,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits