[PATCH] D65650: [Analyzer] Iterator Checkers - Fix for Crash on Iterator Differences

2019-08-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.

Cool!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65650/new/

https://reviews.llvm.org/D65650



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


[PATCH] D65693: [driver][riscv] Support riscv64-linux-gnu multiarch paths

2019-08-03 Thread Aurelien Jarno via Phabricator via cfe-commits
aurel32 created this revision.
aurel32 added reviewers: asb, jrtc27.
aurel32 added projects: clang, LLVM.
Herald added subscribers: cfe-commits, s.egerton, lenary, benna, psnobl, PkmX, 
rkruppe, rogfer01, shiva0217, kito-cheng, simoncook.

This change adds support for the `riscv64-linux-gnu` multiarch:

- library path in `getMultiarchTriple`
- include path in `AddClangSystemIncludeArgs`

With this change LLVM is able to find libraries and include files on a debian 
riscv64 system.


Repository:
  rC Clang

https://reviews.llvm.org/D65693

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -150,6 +150,10 @@
 if (D.getVFS().exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
   return "powerpc64le-linux-gnu";
 break;
+  case llvm::Triple::riscv64:
+if (D.getVFS().exists(SysRoot + "/lib/riscv64-linux-gnu"))
+  return "riscv64-linux-gnu";
+break;
   case llvm::Triple::sparc:
 if (D.getVFS().exists(SysRoot + "/lib/sparc-linux-gnu"))
   return "sparc-linux-gnu";
@@ -749,6 +753,8 @@
   "/usr/include/powerpc64-linux-gnu"};
   const StringRef PPC64LEMultiarchIncludeDirs[] = {
   "/usr/include/powerpc64le-linux-gnu"};
+  const StringRef RISCV64MultiarchIncludeDirs[] = {
+  "/usr/include/riscv64-linux-gnu"};
   const StringRef SparcMultiarchIncludeDirs[] = {
   "/usr/include/sparc-linux-gnu"};
   const StringRef Sparc64MultiarchIncludeDirs[] = {
@@ -824,6 +830,9 @@
   case llvm::Triple::ppc64le:
 MultiarchIncludeDirs = PPC64LEMultiarchIncludeDirs;
 break;
+  case llvm::Triple::riscv64:
+MultiarchIncludeDirs = RISCV64MultiarchIncludeDirs;
+break;
   case llvm::Triple::sparc:
 MultiarchIncludeDirs = SparcMultiarchIncludeDirs;
 break;


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -150,6 +150,10 @@
 if (D.getVFS().exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
   return "powerpc64le-linux-gnu";
 break;
+  case llvm::Triple::riscv64:
+if (D.getVFS().exists(SysRoot + "/lib/riscv64-linux-gnu"))
+  return "riscv64-linux-gnu";
+break;
   case llvm::Triple::sparc:
 if (D.getVFS().exists(SysRoot + "/lib/sparc-linux-gnu"))
   return "sparc-linux-gnu";
@@ -749,6 +753,8 @@
   "/usr/include/powerpc64-linux-gnu"};
   const StringRef PPC64LEMultiarchIncludeDirs[] = {
   "/usr/include/powerpc64le-linux-gnu"};
+  const StringRef RISCV64MultiarchIncludeDirs[] = {
+  "/usr/include/riscv64-linux-gnu"};
   const StringRef SparcMultiarchIncludeDirs[] = {
   "/usr/include/sparc-linux-gnu"};
   const StringRef Sparc64MultiarchIncludeDirs[] = {
@@ -824,6 +830,9 @@
   case llvm::Triple::ppc64le:
 MultiarchIncludeDirs = PPC64LEMultiarchIncludeDirs;
 break;
+  case llvm::Triple::riscv64:
+MultiarchIncludeDirs = RISCV64MultiarchIncludeDirs;
+break;
   case llvm::Triple::sparc:
 MultiarchIncludeDirs = SparcMultiarchIncludeDirs;
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65694: Properly instantiate a decltype in argument's default initializer

2019-08-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: sepavloff, rsmith.
Mordante added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65694

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: clang/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- clang/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -114,3 +114,34 @@
 S _a{};
   };
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=28500
+// Failure to resolve the decltype part during instantiation caused an
+// assertion failure
+namespace PR28500 {
+namespace original {
+template 
+void bar(T t = [](decltype(t) i) { return 0; }(0)) {}
+void foo() {
+  bar();
+}
+} // namespace original
+
+namespace cast {
+template 
+void bar(T t = decltype(t)(0)) {}
+void foo() {
+  bar();
+  bar();
+}
+} // namespace cast
+
+namespace value {
+template 
+void bar(T t = decltype(t)()) {}
+void foo() {
+  bar();
+  bar();
+}
+} // namespace value
+} // namespace PR28500
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5287,29 +5287,33 @@
 //   }
 //
 // In this case instantiation of the type of 'g1' requires definition of
-// 'x1', which is defined later. Error recovery may produce an enum used
-// before definition. In these cases we need to instantiate relevant
-// declarations here.
+// 'x1', which is defined later.
+//
+// Error recovery may produce an enum used before definition.
+//
+// Default arguments with a decltype referencing arguments:
+//
+//   template  void bar(T t = decltype(t)()) {}
+//
+// Else we must have a label decl that hasn't been found yet.
+//
+// In these cases we need to instantiate relevant declarations here.
 bool NeedInstantiate = false;
 if (CXXRecordDecl *RD = dyn_cast(D))
   NeedInstantiate = RD->isLocalClass();
 else
-  NeedInstantiate = isa(D);
+  NeedInstantiate =
+  isa(D) || isa(D) || isa(D);
 if (NeedInstantiate) {
   Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
+  assert(Inst && "Failed to instantiate");
   CurrentInstantiationScope->InstantiatedLocal(D, Inst);
-  return cast(Inst);
+  return cast(Inst);
 }
 
-// If we didn't find the decl, then we must have a label decl that hasn't
-// been found yet.  Lazily instantiate it and return it now.
-assert(isa(D));
-
-Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
-assert(Inst && "Failed to instantiate label??");
+assert(0 && "Failed to instantiate");
 
-CurrentInstantiationScope->InstantiatedLocal(D, Inst);
-return cast(Inst);
+return nullptr;
   }
 
   if (CXXRecordDecl *Record = dyn_cast(D)) {
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2974,6 +2974,11 @@
   if (isa(D))
 return nullptr;
 
+  // Default arguments with a decltype referencing arguments prior to definition
+  // may require instantiation.
+  if (isa(D))
+return nullptr;
+
   // If we didn't find the decl, then we either have a sema bug, or we have a
   // forward reference to a label declaration.  Return null to indicate that
   // we have an uninstantiated label.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65616: Ignore -fsemantic-interposition/-fno-semantic-interposition flag for gcc compatibility

2019-08-03 Thread Romain Geissler via Phabricator via cfe-commits
Romain-Geissler-1A added a comment.

Hi,

Thanks Serge. Given that I am only a very occasional contributor, I don't have 
any right to push this commit myself. Would you please commit it for me ?

Thanks,
Romain


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65616/new/

https://reviews.llvm.org/D65616



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


[PATCH] D65695: Implements CWG 1601 in [over.ics.rank/4.2]

2019-08-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: rsmith.
Mordante added a project: clang.

The overload resolution for enums with a fixed underlaying type has changed in 
the C++14 standard. This patch implements the new rule.

  

Note: I don't have access to the CWG 1601 paper, but based on 
https://en.cppreference.com/w/cpp/language/overload_resolution I applied the 
fix retroactively to C++11.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65695

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/drs/dr16xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -9421,7 +9421,7 @@
 http://wg21.link/cwg1601";>1601
 C++14
 Promotion of enumeration with fixed underlying type
-Unknown
+SVN (C++11 onwards)
   
   
 http://wg21.link/cwg1602";>1602
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1007,9 +1007,10 @@
   void j(long); // expected-note {{candidate}}
   int d = j(g); // expected-error {{ambiguous}}
 
-  int k(short); // expected-note {{candidate}}
-  void k(int); // expected-note {{candidate}}
-  int x = k(g); // expected-error {{ambiguous}}
+  // Valid per dr1601
+  int k(short);
+  void k(int);
+  int x = k(g);
 }
 #endif
 
Index: clang/test/CXX/drs/dr16xx.cpp
===
--- clang/test/CXX/drs/dr16xx.cpp
+++ clang/test/CXX/drs/dr16xx.cpp
@@ -23,6 +23,17 @@
 } // std
 #endif
 
+namespace dr1601 { // dr1601
+#if __cplusplus >= 201103L
+enum E : char { e };
+void f(char);
+void f(int);
+void g() {
+  f(e);
+}
+#endif
+} // namespace dr1601
+
 namespace dr1611 { // dr1611: dup 1658
   struct A { A(int); };
   struct B : virtual A { virtual void f() = 0; };
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -3751,6 +3751,26 @@
   !SCS2.IsLvalueReference && SCS2.BindsToFunctionLvalue);
 }
 
+/// Returns the underlaying type of a fixed enum of the \a SCS's @c FromType
+/// if the \a SCS uses an integral promotion. Upon failure an empty type is
+/// returned.
+static QualType
+getFixedEnumUnderlayingType(const StandardConversionSequence &SCS) {
+
+  if (SCS.Second != ICK_Integral_Promotion)
+return QualType();
+
+  QualType FromType = SCS.getFromType();
+  if (!FromType->isEnumeralType())
+return QualType();
+
+  EnumDecl *Enum = FromType->getAs()->getDecl();
+  if (!Enum->isFixed())
+return QualType();
+
+  return Enum->getIntegerType();
+}
+
 /// CompareStandardConversionSequences - Compare two standard
 /// conversion sequences to determine whether one is better than the
 /// other or if they are indistinguishable (C++ 13.3.3.2p3).
@@ -3792,6 +3812,23 @@
  ? ImplicitConversionSequence::Better
  : ImplicitConversionSequence::Worse;
 
+  // C++14 [over.ics.rank]p4b2:
+  // This is retroactively applied to C++11 by CWG 1601.
+  //
+  //   A conversion that promotes an enumeration whose underlying type is fixed
+  //   to its underlying type is better than one that promotes to the promoted
+  //   underlying type, if the two are different.
+  QualType UnderlayingType1 = getFixedEnumUnderlayingType(SCS1);
+  QualType UnderlayingType2 = getFixedEnumUnderlayingType(SCS2);
+  if (!UnderlayingType1.isNull() && !UnderlayingType2.isNull()) {
+if (SCS1.getToType(1) == UnderlayingType1 &&
+SCS2.getToType(1) != UnderlayingType2)
+  return ImplicitConversionSequence::Better;
+else if (SCS1.getToType(1) != UnderlayingType1 &&
+ SCS2.getToType(1) == UnderlayingType2)
+  return ImplicitConversionSequence::Worse;
+  }
+
   // C++ [over.ics.rank]p4b2:
   //
   //   If class B is derived directly or indirectly from class A,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63960: [C++20] Add consteval-specifique semantic

2019-08-03 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

ping @rsmith


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63960/new/

https://reviews.llvm.org/D63960



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


[PATCH] D63134: [clang] improving diagnotics for invalid constexpr defaulted special membres

2019-08-03 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

ping @rsmith


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63134/new/

https://reviews.llvm.org/D63134



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


[PATCH] D65696: Implements CWG 2082 Referring to parameters in unevaluated operands of default arguments

2019-08-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: rsmith.
Mordante added a project: clang.

This implements the current standard wording for [dcl.fct.default]p9 and 
[dcl.fct.default]p7. This has been changed by CWG 2082.

  

Note: I don't have access to the paper therefore I assume it retroactively 
applies to all C++ standards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65696

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p9.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -12307,7 +12307,7 @@
 http://wg21.link/cwg2082";>2082
 CD4
 Referring to parameters in unevaluated operands of default 
arguments
-Unknown
+SVN
   
   
 http://wg21.link/cwg2083";>2083
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-void h()
+void f()
 {
   int i;
-  extern void h2(int x = sizeof(i)); // expected-error {{default argument 
references local variable 'i' of enclosing function}}
+  extern void g(int x = i); // expected-error {{default argument references 
local variable 'i' of enclosing function}}
+  extern void h(int x = sizeof(i));
 }
Index: clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p9.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int a;
+int f(int a, int b = a); // expected-error {{default argument references 
parameter 'a'}}
+typedef int I;
+int g(float I, int b = I(2)); // expected-error {{called object type 'float' 
is not a function or function pointer}}
+int h(int a, int b = sizeof(a));
+
+int b;
+class X {
+  int a;
+  int mem1(int i = a); // expected-error {{invalid use of non-static data 
member 'a'}}
+  int mem2(int i = b);
+  static int b;
+};
+
+int f(int = 0);
+void h() {
+  int j = f(1);
+  int k = f();
+}
+int (*p1)(int) = &f;
+int (*p2)() = &f; // expected-error {{cannot initialize a variable of type 
'int (*)()' with an rvalue of type 'int (*)(int)': different number of 
parameters (0 vs 1)}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -86,20 +86,24 @@
 NamedDecl *Decl = DRE->getDecl();
 if (ParmVarDecl *Param = dyn_cast(Decl)) {
   // C++ [dcl.fct.default]p9
-  //   Default arguments are evaluated each time the function is
-  //   called. The order of evaluation of function arguments is
-  //   unspecified. Consequently, parameters of a function shall not
-  //   be used in default argument expressions, even if they are not
-  //   evaluated. Parameters of a function declared before a default
-  //   argument expression are in scope and can hide namespace and
-  //   class member names.
+  //   A default argument is evaluated each time the function is called
+  //   with no argument for the corresponding parameter. A parameter shall
+  //   not appear as a potentially-evaluated expression in a default
+  //   argument. Parameters of a function declared before a default
+  //   argument are in scope and can hide namespace and class member
+  //   names.
+  if (DRE->isNonOdrUse() == NOUR_Unevaluated)
+return false;
+
   return S->Diag(DRE->getBeginLoc(),
  diag::err_param_default_argument_references_param)
  << Param->getDeclName() << DefaultArg->getSourceRange();
 } else if (VarDecl *VDecl = dyn_cast(Decl)) {
   // C++ [dcl.fct.default]p7
-  //   Local variables shall not be used in default argument
-  //   expressions.
+  //   A local variable cannot be odr-used (6.2) in a default argument.
+  if (DRE->isNonOdrUse() != NOUR_None)
+return false;
+
   if (VDecl->isLocalVarDecl())
 return S->Diag(DRE->getBeginLoc(),
diag::err_param_default_argument_references_local)


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -12307,7 +12307,7 @@
 http://wg21.link/cwg2082";>2082
 CD4
 Referring to parameters in unevaluated operands of default arguments
-Unknown
+SVN
   
   
 http://wg21.link/cwg2083";>2083
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp

r367759 - Use switch instead of series of comparisons

2019-08-03 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sat Aug  3 09:32:49 2019
New Revision: 367759

URL: http://llvm.org/viewvc/llvm-project?rev=367759&view=rev
Log:
Use switch instead of series of comparisons

This is style correction, no functional changes.

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

Modified:
cfe/trunk/include/clang/Basic/TokenKinds.h
cfe/trunk/lib/Basic/TokenKinds.cpp

Modified: cfe/trunk/include/clang/Basic/TokenKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.h?rev=367759&r1=367758&r2=367759&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.h (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.h Sat Aug  3 09:32:49 2019
@@ -90,13 +90,7 @@ inline bool isLiteral(TokenKind K) {
 }
 
 /// Return true if this is any of tok::annot_* kinds.
-inline bool isAnnotation(TokenKind K) {
-#define ANNOTATION(NAME) \
-  if (K == tok::annot_##NAME) \
-return true;
-#include "clang/Basic/TokenKinds.def"
-  return false;
-}
+bool isAnnotation(TokenKind K);
 
 /// Return true if this is an annotation token representing a pragma.
 bool isPragmaAnnotation(TokenKind K);

Modified: cfe/trunk/lib/Basic/TokenKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TokenKinds.cpp?rev=367759&r1=367758&r2=367759&view=diff
==
--- cfe/trunk/lib/Basic/TokenKinds.cpp (original)
+++ cfe/trunk/lib/Basic/TokenKinds.cpp Sat Aug  3 09:32:49 2019
@@ -46,6 +46,16 @@ const char *tok::getKeywordSpelling(Toke
   return nullptr;
 }
 
+bool tok::isAnnotation(TokenKind Kind) {
+  switch (Kind) {
+#define ANNOTATION(X) case annot_ ## X: return true;
+#include "clang/Basic/TokenKinds.def"
+  default:
+break;
+  }
+  return false;
+}
+
 bool tok::isPragmaAnnotation(TokenKind Kind) {
   switch (Kind) {
 #define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;


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


[PATCH] D65670: Use switch instead of series of comparisons

2019-08-03 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367759: Use switch instead of series of comparisons 
(authored by sepavloff, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65670?vs=213100&id=213192#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65670/new/

https://reviews.llvm.org/D65670

Files:
  cfe/trunk/include/clang/Basic/TokenKinds.h
  cfe/trunk/lib/Basic/TokenKinds.cpp


Index: cfe/trunk/include/clang/Basic/TokenKinds.h
===
--- cfe/trunk/include/clang/Basic/TokenKinds.h
+++ cfe/trunk/include/clang/Basic/TokenKinds.h
@@ -90,13 +90,7 @@
 }
 
 /// Return true if this is any of tok::annot_* kinds.
-inline bool isAnnotation(TokenKind K) {
-#define ANNOTATION(NAME) \
-  if (K == tok::annot_##NAME) \
-return true;
-#include "clang/Basic/TokenKinds.def"
-  return false;
-}
+bool isAnnotation(TokenKind K);
 
 /// Return true if this is an annotation token representing a pragma.
 bool isPragmaAnnotation(TokenKind K);
Index: cfe/trunk/lib/Basic/TokenKinds.cpp
===
--- cfe/trunk/lib/Basic/TokenKinds.cpp
+++ cfe/trunk/lib/Basic/TokenKinds.cpp
@@ -46,6 +46,16 @@
   return nullptr;
 }
 
+bool tok::isAnnotation(TokenKind Kind) {
+  switch (Kind) {
+#define ANNOTATION(X) case annot_ ## X: return true;
+#include "clang/Basic/TokenKinds.def"
+  default:
+break;
+  }
+  return false;
+}
+
 bool tok::isPragmaAnnotation(TokenKind Kind) {
   switch (Kind) {
 #define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;


Index: cfe/trunk/include/clang/Basic/TokenKinds.h
===
--- cfe/trunk/include/clang/Basic/TokenKinds.h
+++ cfe/trunk/include/clang/Basic/TokenKinds.h
@@ -90,13 +90,7 @@
 }
 
 /// Return true if this is any of tok::annot_* kinds.
-inline bool isAnnotation(TokenKind K) {
-#define ANNOTATION(NAME) \
-  if (K == tok::annot_##NAME) \
-return true;
-#include "clang/Basic/TokenKinds.def"
-  return false;
-}
+bool isAnnotation(TokenKind K);
 
 /// Return true if this is an annotation token representing a pragma.
 bool isPragmaAnnotation(TokenKind K);
Index: cfe/trunk/lib/Basic/TokenKinds.cpp
===
--- cfe/trunk/lib/Basic/TokenKinds.cpp
+++ cfe/trunk/lib/Basic/TokenKinds.cpp
@@ -46,6 +46,16 @@
   return nullptr;
 }
 
+bool tok::isAnnotation(TokenKind Kind) {
+  switch (Kind) {
+#define ANNOTATION(X) case annot_ ## X: return true;
+#include "clang/Basic/TokenKinds.def"
+  default:
+break;
+  }
+  return false;
+}
+
 bool tok::isPragmaAnnotation(TokenKind Kind) {
   switch (Kind) {
 #define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65699: [Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl

2019-08-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: dalias, phosek, rsmith.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

On a musl-based Linux distribution, stdalign.h stdarg.h stdbool.h stddef.h 
stdint.h stdnoreturn.h are expected to be provided by musl (/usr/include), 
instead of RESOURCE_DIR/include.
Reorder RESOURCE_DIR/include to fix the search order problem.
(Currently musl doesn't provide stdatomic.h. stdatomic.h is still found in 
RESOURCE_DIR/include.)

gcc on musl has a similar search order:

  /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0
  
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/x86_64-alpine-linux-musl
  
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/backward
  /usr/local/include
  /usr/include/fortify
  /usr/include
  /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/include

This is different from a glibc-based distribution where RESOURCE_DIR/include is 
placed before SYSROOT/usr/include.


Repository:
  rC Clang

https://reviews.llvm.org/D65699

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/linux-musl-header-search.cpp


Index: test/Driver/linux-musl-header-search.cpp
===
--- /dev/null
+++ test/Driver/linux-musl-header-search.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-linux-musl -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-X86-64-LIBCXX %s
+
+// RESOURCE_DIR/include comes after /usr/include on linux-musl.
+// This is different from a glibc-based distribution.
+// CHECK-X86-64-LIBCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-X86-64-LIBCXX: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-X86-64-LIBCXX: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only -nobuiltininc 2>&1 
\
+// RUN: -target x86_64-linux-musl \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-NOBUILTININC %s
+
+// CHECK-NOBUILTININC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOBUILTININC-NOT: "-internal-isystem" 
"[[RESOURCE_DIR]]{{/|}}include"
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only -nostdlibinc 2>&1 \
+// RUN: -target x86_64-linux-musl \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN:   | FileCheck --check-prefix=CHECK-NOSTDLIBINC %s
+
+// CHECK-NOSTDLIBINC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem"
+// CHECK-NOSTDLIBINC-NOT: "-internal-isystem"
+// CHECK-NOSTDLIBINC: "-internal-isystem" "[[RESOURCE_DIR]]{{/|}}include"
+// CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem"
+// CHECK-NOSTDLIBINC-NOT: "-internal-isystem"
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -658,11 +658,11 @@
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
 addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
 
-  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
-SmallString<128> P(D.ResourceDir);
-llvm::sys::path::append(P, "include");
-addSystemInclude(DriverArgs, CC1Args, P);
-  }
+  SmallString<128> ResourceDirInclude(D.ResourceDir);
+  llvm::sys::path::append(ResourceDirInclude, "include");
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) &&
+  (!getTriple().isMusl() || DriverArgs.hasArg(options::OPT_nostdlibinc)))
+addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
 
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
@@ -860,6 +860,9 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
+addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
 }
 
 static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,


Index: test/Driver/linux-musl-header-search.cpp
===
--- /dev/null

[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

2019-08-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1495-1496
 
   // For deque-like containers invalidate all iterator positions. For
   // vector-like containers invalidate iterator positions after the insertion.
   const auto *Cont = Pos->getContainer();

baloghadamsoftware wrote:
> Szelethus wrote:
> > >>! In D62525#1523026, @baloghadamsoftware wrote:
> > > For example, an insertion happens into a vector that invalidates all the 
> > > iterators at and after the position where it is inserted.
> > 
> > Is this actually correct?
> > 
> > https://en.cppreference.com/w/cpp/container/deque
> > > std::deque (double-ended queue) is an indexed sequence container that 
> > > allows fast insertion and deletion at both its beginning and its end. In 
> > > addition, insertion and deletion at either end of a deque never 
> > > invalidates pointers or references to the rest of the elements.
> > 
> > https://en.cppreference.com/w/cpp/container/vector
> > 
> > > `insert`, `emplace`, `resize`: If the vector changed capacity, all of the 
> > > iterators are invalidated. If not, only those after the insertion point.
> [[ https://en.cppreference.com/w/cpp/container/deque/insert | 
> https://en.cppreference.com/w/cpp/container/deque/insert ]]
> 
> //All iterators, including the past-the-end iterator, are invalidated.//
> 
> I think I speak here about `insert()`, not about `push_back()` and 
> `push_front()`.
> 
> Since we use a conservative approach we always assume that vectors and 
> double-end queues do not change capacities.
I stand corrected!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62525/new/

https://reviews.llvm.org/D62525



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


[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-08-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

Thanks for starting on this. Can you go ahead and replace the sroa calls with 
mem2reg calls for `O1` and then see what that does to the performance? That 
strikes me as a major change, but certainly one that potentially makes sense, 
so I'd rather we go ahead and test it now before we make decisions about other 
adjustments.

FWIW, I thought that we might run InstCombine less often (or maybe replace it 
with InstSimplify, in some places). Did you try that?




Comment at: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp:362
 
+  // TODO: Investigate the cost/benefit of tail call elimination on debugging.
   MPM.add(createTailCallEliminationPass()); // Eliminate tail calls

By definition, this loses information from the call stack, no?



Comment at: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp:432
 
+  // TODO: Investigate if this is too expensive at O1.
   MPM.add(createAggressiveDCEPass()); // Delete dead instructions

Yes, I'd fall back to using regular DCE.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65410/new/

https://reviews.llvm.org/D65410



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


[PATCH] D61466: [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug

2019-08-03 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 213197.
jdenny added a comment.

Note the reproducer in the implementation's FIXME.  The other FIXME points 
there, so I figure it's best not to duplicate the note.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61466/new/

https://reviews.llvm.org/D61466

Files:
  clang/include/clang/Rewrite/Core/Rewriter.h
  clang/lib/Rewrite/Rewriter.cpp
  clang/unittests/Rewrite/RewriteBufferTest.cpp

Index: clang/unittests/Rewrite/RewriteBufferTest.cpp
===
--- clang/unittests/Rewrite/RewriteBufferTest.cpp
+++ clang/unittests/Rewrite/RewriteBufferTest.cpp
@@ -14,6 +14,16 @@
 
 namespace {
 
+#define EXPECT_OUTPUT(Buf, Output) EXPECT_EQ(Output, writeOutput(Buf))
+
+static std::string writeOutput(const RewriteBuffer &Buf) {
+  std::string Result;
+  raw_string_ostream OS(Result);
+  Buf.write(OS);
+  OS.flush();
+  return Result;
+}
+
 static void tagRange(unsigned Offset, unsigned Len, StringRef tagName,
  RewriteBuffer &Buf) {
   std::string BeginTag;
@@ -40,11 +50,64 @@
   tagRange(Pos, TagStr.size(), "outer", Buf);
   tagRange(Pos, TagStr.size(), "inner", Buf);
 
-  std::string Result;
-  raw_string_ostream OS(Result);
-  Buf.write(OS);
-  OS.flush();
-  EXPECT_EQ(Output, Result);
+  EXPECT_OUTPUT(Buf, Output);
+}
+
+TEST(RewriteBuffer, DISABLED_RemoveLineIfEmpty_XFAIL) {
+  StringRef Input = "def\n"
+"ghi\n"
+"jkl\n";
+  RewriteBuffer Buf;
+  Buf.Initialize(Input);
+
+  // Insert "abc\n" at the start.
+  Buf.InsertText(0, "abc\n");
+  EXPECT_OUTPUT(Buf, "abc\n"
+ "def\n"
+ "ghi\n"
+ "jkl\n");
+
+  // Remove "def\n".
+  //
+  // After the removal of "def", we have:
+  //
+  //   "abc\n"
+  //   "\n"
+  //   "ghi\n"
+  //   "jkl\n"
+  //
+  // Because removeLineIfEmpty=true, RemoveText has to remove the "\n" left on
+  // the line.  This happens correctly for the rewrite buffer itself, so the
+  // next check below passes.
+  //
+  // However, RemoveText's implementation incorrectly records the delta for
+  // removing the "\n" using the rewrite buffer offset, 4, where it was
+  // supposed to use the original input offset, 3.  Interpreted as an original
+  // input offset, 4 points to "g" not to "\n".  Thus, any future modifications
+  // at the original input's "g" will incorrectly see "g" as having become an
+  // empty string and so will map to the next character, "h", in the rewrite
+  // buffer.
+  StringRef RemoveStr0 = "def";
+  Buf.RemoveText(Input.find(RemoveStr0), RemoveStr0.size(),
+ /*removeLineIfEmpty*/ true);
+  EXPECT_OUTPUT(Buf, "abc\n"
+ "ghi\n"
+ "jkl\n");
+
+  // Try to remove "ghi\n".
+  //
+  // As discussed above, the original input offset for "ghi\n" incorrectly
+  // maps to the rewrite buffer offset for "hi\nj", so we end up with:
+  //
+  //   "abc\n"
+  //   "gkl\n"
+  //
+  // To show that removeLineIfEmpty=true is the culprit, change true to false
+  // and append a newline to RemoveStr0 above.  The test then passes.
+  StringRef RemoveStr1 = "ghi\n";
+  Buf.RemoveText(Input.find(RemoveStr1), RemoveStr1.size());
+  EXPECT_OUTPUT(Buf, "abc\n"
+ "jkl\n");
 }
 
 } // anonymous namespace
Index: clang/lib/Rewrite/Rewriter.cpp
===
--- clang/lib/Rewrite/Rewriter.cpp
+++ clang/lib/Rewrite/Rewriter.cpp
@@ -96,6 +96,17 @@
 }
 if (posI != end() && *posI == '\n') {
   Buffer.erase(curLineStartOffs, lineSize + 1/* + '\n'*/);
+  // FIXME: Here, the offset of the start of the line is supposed to be
+  // expressed in terms of the original input not the "real" rewrite
+  // buffer.  How do we compute that reliably?  It might be tempting to use
+  // curLineStartOffs + OrigOffset - RealOffset, but that assumes the
+  // difference between the original and real offset is the same at the
+  // removed text and at the start of the line, but that's not true if
+  // edits were previously made earlier on the line.  This bug is also
+  // documented by a FIXME on the definition of
+  // clang::Rewriter::RewriteOptions::RemoveLineIfEmpty.  A reproducer for
+  // the implementation below is the test RemoveLineIfEmpty in
+  // clang/unittests/Rewrite/RewriteBufferTest.cpp.
   AddReplaceDelta(curLineStartOffs, -(lineSize + 1/* + '\n'*/));
 }
   }
Index: clang/include/clang/Rewrite/Core/Rewriter.h
===
--- clang/include/clang/Rewrite/Core/Rewriter.h
+++ clang/include/clang/Rewrite/Core/Rewriter.h
@@ -46,6 +46,17 @@
 
 /// If true and removing some text leaves a blank line
 /// also remove the empty line (false by default).
+///
+/// FIXME: This sometimes corrupts the file's rewrite buffer due to
+/// incorrec

[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added reviewers: jkorous, compnerd.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

There are cases where the DirectoryWatcherTests just hang in a deadlock when 
there are inotify limits hit, with no error reporting. This patch is a first 
attempt to resolve these issues by bubbling up errors to the user.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65704

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -280,6 +280,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -311,6 +315,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/false);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -331,6 +339,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   fixture.addFile("a");
   fixture.addFile("b");
@@ -356,6 +368,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   // modify the file
   {
@@ -386,6 +402,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   fixture.deleteFile("a");
 
@@ -407,6 +427,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) {
+llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+llvm_unreachable("DirectoryWatcher::create() FAILED!");
+  }
 
   remove_directories(fixture.TestWatchedDir);
 
@@ -427,7 +451,11 @@
   TestConsumer.consume(Events, IsInitial);
 },
 /*waitForInitialSync=*/true);
+if (!DW) {
+  llvm::errs() << llvm::toString(DW.takeError()) << "\n";
+  llvm_unreachable("DirectoryWatcher::create() FAILED!");
+}
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
 }
\ No newline at end of file
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include 
 
@@ -205,7 +206,7 @@
   FSEventStreamRelease(EventStream);
 }
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
@@ -213,12 +214,15 @@
   dispatch_queue_create("DirectoryWatcher", DISPATCH_QUEUE_SERIAL);
 
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());
 
   auto EventStream = createFSEventStream(Path, Receiver, Queue);
-  if (!EventStream) {
-return nullptr;
-  }
+  if (!EventStream)
+return llvm::make_error(
+std::string("createFSEventStream() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());
 
   std::unique_ptr Result =
   llvm::make_unique(EventStream, Receiver, Path);
Index: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
===
--- clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
+++ clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Mutex.

[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:32
 #include 
+#include 
 

This include should be removed. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704



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


[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 213209.
plotfi added a comment.

Cleanup some stuff


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -280,8 +280,8 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
-
-  checkEventualResultWithTimeout(TestConsumer);
+  if (DW)
+checkEventualResultWithTimeout(TestConsumer);
 }
 
 TEST(DirectoryWatcherTest, InitialScanAsync) {
@@ -311,8 +311,8 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/false);
-
-  checkEventualResultWithTimeout(TestConsumer);
+  if (DW)
+checkEventualResultWithTimeout(TestConsumer);
 }
 
 TEST(DirectoryWatcherTest, AddFiles) {
@@ -331,12 +331,12 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
-
-  fixture.addFile("a");
-  fixture.addFile("b");
-  fixture.addFile("c");
-
-  checkEventualResultWithTimeout(TestConsumer);
+  if (DW) {
+fixture.addFile("a");
+fixture.addFile("b");
+fixture.addFile("c");
+checkEventualResultWithTimeout(TestConsumer);
+  }
 }
 
 TEST(DirectoryWatcherTest, ModifyFile) {
@@ -356,17 +356,18 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (DW) {
+// modify the file
+{
+  std::error_code error;
+  llvm::raw_fd_ostream bStream(fixture.getPathInWatched("a"), error,
+   CD_OpenExisting);
+  assert(!error);
+  bStream << "foo";
+}
 
-  // modify the file
-  {
-std::error_code error;
-llvm::raw_fd_ostream bStream(fixture.getPathInWatched("a"), error,
- CD_OpenExisting);
-assert(!error);
-bStream << "foo";
+checkEventualResultWithTimeout(TestConsumer);
   }
-
-  checkEventualResultWithTimeout(TestConsumer);
 }
 
 TEST(DirectoryWatcherTest, DeleteFile) {
@@ -386,10 +387,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
-
-  fixture.deleteFile("a");
-
-  checkEventualResultWithTimeout(TestConsumer);
+  if (DW) {
+fixture.deleteFile("a");
+checkEventualResultWithTimeout(TestConsumer);
+  }
 }
 
 TEST(DirectoryWatcherTest, DeleteWatchedDir) {
@@ -407,10 +408,10 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
-
-  remove_directories(fixture.TestWatchedDir);
-
-  checkEventualResultWithTimeout(TestConsumer);
+  if (DW) {
+remove_directories(fixture.TestWatchedDir);
+checkEventualResultWithTimeout(TestConsumer);
+  }
 }
 
 TEST(DirectoryWatcherTest, InvalidatedWatcher) {
@@ -427,7 +428,9 @@
   TestConsumer.consume(Events, IsInitial);
 },
 /*waitForInitialSync=*/true);
+if (DW)
+  return;
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
 }
\ No newline at end of file
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -11,6 +11,7 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include 
 
@@ -205,7 +206,7 @@
   FSEventStreamRelease(EventStream);
 }
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
@@ -213,12 +214,15 @@
   dispatch_queue_create("DirectoryWatcher", DISPATCH_QUEUE_SERIAL);
 
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());
 
   auto EventStream = createFSEventStream(Path, Receiver, Queue);
-  if (!EventStream) {
-return nullptr;
-  }
+  if (!EventStream)
+return llvm::make_error(
+std::string("createFSEventStream() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());
 
   std::unique_ptr Result =
   llvm::make_unique(EventStream, Receiver, Path);
Index: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
=

[PATCH] D65706: [docs] document -Weveything more betterer

2019-08-03 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65706

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -992,13 +992,24 @@
 Enabling All Diagnostics
 ^
 
-In addition to the traditional ``-W`` flags, one can enable **all**
-diagnostics by passing :option:`-Weverything`. This works as expected
-with
-:option:`-Werror`, and also includes the warnings from :option:`-pedantic`.
-
-Note that when combined with :option:`-w` (which disables all warnings), that
-flag wins.
+In addition to the traditional ``-W`` flags, one can enable **all** diagnostics
+by passing :option:`-Weverything`. This works as expected with
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. 
Some
+diagnostics contradict each other, users :option:`-Weverything` therefore often
+disable many diagnostics such as :option:`-Wno-c++98-compat`
+:option:`-Wno-c++-compat`.
+
+Since :option:`-Weverything` enables every diagnostic, we generally don't
+recommend using it. :option:`-Wall` :option:`-Wextra` are a better choice for
+most projects. Using :option:`-Weverything` means that updating your compiler 
is
+more difficult because you're exposed to experimental diagnostics which might 
be
+of lower quality than the default once. If you do use :option:`-Weverything`
+then we advise that you address all new compiler diagnostics as they get added
+to clang, either by fixing everything they find or explicitly disabling that
+diagnostic with its corresponding `Wno-` option.
+
+Note that when combined with :option:`-w` (which disables all warnings),
+disabling all warnings wins.
 
 Controlling Static Analyzer Diagnostics
 ^^^


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -992,13 +992,24 @@
 Enabling All Diagnostics
 ^
 
-In addition to the traditional ``-W`` flags, one can enable **all**
-diagnostics by passing :option:`-Weverything`. This works as expected
-with
-:option:`-Werror`, and also includes the warnings from :option:`-pedantic`.
-
-Note that when combined with :option:`-w` (which disables all warnings), that
-flag wins.
+In addition to the traditional ``-W`` flags, one can enable **all** diagnostics
+by passing :option:`-Weverything`. This works as expected with
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. Some
+diagnostics contradict each other, users :option:`-Weverything` therefore often
+disable many diagnostics such as :option:`-Wno-c++98-compat`
+:option:`-Wno-c++-compat`.
+
+Since :option:`-Weverything` enables every diagnostic, we generally don't
+recommend using it. :option:`-Wall` :option:`-Wextra` are a better choice for
+most projects. Using :option:`-Weverything` means that updating your compiler is
+more difficult because you're exposed to experimental diagnostics which might be
+of lower quality than the default once. If you do use :option:`-Weverything`
+then we advise that you address all new compiler diagnostics as they get added
+to clang, either by fixing everything they find or explicitly disabling that
+diagnostic with its corresponding `Wno-` option.
+
+Note that when combined with :option:`-w` (which disables all warnings),
+disabling all warnings wins.
 
 Controlling Static Analyzer Diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65706: [docs] document -Weveything more betterer

2019-08-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/docs/UsersManual.rst:998
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. 
Some
+diagnostics contradict each other, users :option:`-Weverything` therefore often
+disable many diagnostics such as :option:`-Wno-c++98-compat`

users *of*


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65706/new/

https://reviews.llvm.org/D65706



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


[PATCH] D65706: [docs] document -Weveything more betterer

2019-08-03 Thread JF Bastien via Phabricator via cfe-commits
jfb updated this revision to Diff 213212.
jfb added a comment.

- Missing 'of'


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65706/new/

https://reviews.llvm.org/D65706

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -992,13 +992,24 @@
 Enabling All Diagnostics
 ^
 
-In addition to the traditional ``-W`` flags, one can enable **all**
-diagnostics by passing :option:`-Weverything`. This works as expected
-with
-:option:`-Werror`, and also includes the warnings from :option:`-pedantic`.
-
-Note that when combined with :option:`-w` (which disables all warnings), that
-flag wins.
+In addition to the traditional ``-W`` flags, one can enable **all** diagnostics
+by passing :option:`-Weverything`. This works as expected with
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. 
Some
+diagnostics contradict each other, users of :option:`-Weverything` therefore
+often disable many diagnostics such as :option:`-Wno-c++98-compat`
+:option:`-Wno-c++-compat`.
+
+Since :option:`-Weverything` enables every diagnostic, we generally don't
+recommend using it. :option:`-Wall` :option:`-Wextra` are a better choice for
+most projects. Using :option:`-Weverything` means that updating your compiler 
is
+more difficult because you're exposed to experimental diagnostics which might 
be
+of lower quality than the default once. If you do use :option:`-Weverything`
+then we advise that you address all new compiler diagnostics as they get added
+to clang, either by fixing everything they find or explicitly disabling that
+diagnostic with its corresponding `Wno-` option.
+
+Note that when combined with :option:`-w` (which disables all warnings),
+disabling all warnings wins.
 
 Controlling Static Analyzer Diagnostics
 ^^^


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -992,13 +992,24 @@
 Enabling All Diagnostics
 ^
 
-In addition to the traditional ``-W`` flags, one can enable **all**
-diagnostics by passing :option:`-Weverything`. This works as expected
-with
-:option:`-Werror`, and also includes the warnings from :option:`-pedantic`.
-
-Note that when combined with :option:`-w` (which disables all warnings), that
-flag wins.
+In addition to the traditional ``-W`` flags, one can enable **all** diagnostics
+by passing :option:`-Weverything`. This works as expected with
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. Some
+diagnostics contradict each other, users of :option:`-Weverything` therefore
+often disable many diagnostics such as :option:`-Wno-c++98-compat`
+:option:`-Wno-c++-compat`.
+
+Since :option:`-Weverything` enables every diagnostic, we generally don't
+recommend using it. :option:`-Wall` :option:`-Wextra` are a better choice for
+most projects. Using :option:`-Weverything` means that updating your compiler is
+more difficult because you're exposed to experimental diagnostics which might be
+of lower quality than the default once. If you do use :option:`-Weverything`
+then we advise that you address all new compiler diagnostics as they get added
+to clang, either by fixing everything they find or explicitly disabling that
+diagnostic with its corresponding `Wno-` option.
+
+Note that when combined with :option:`-w` (which disables all warnings),
+disabling all warnings wins.
 
 Controlling Static Analyzer Diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65706: [docs] Better documentation for -Weverything

2019-08-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this!




Comment at: clang/docs/UsersManual.rst:998
+:option:`-Werror`, and also includes the warnings from :option:`-pedantic`. 
Some
+diagnostics contradict each other, users of :option:`-Weverything` therefore
+often disable many diagnostics such as :option:`-Wno-c++98-compat`

users of -Weverything therefore -> therefore, users of -Weverything



Comment at: clang/docs/UsersManual.rst:999-1000
+diagnostics contradict each other, users of :option:`-Weverything` therefore
+often disable many diagnostics such as :option:`-Wno-c++98-compat`
+:option:`-Wno-c++-compat`.
+

Would you care to propose a more exhaustive list of conflicting diagnostics? 
(Perhaps in a follow-up patch.)



Comment at: clang/docs/UsersManual.rst:1006
+more difficult because you're exposed to experimental diagnostics which might 
be
+of lower quality than the default once. If you do use :option:`-Weverything`
+then we advise that you address all new compiler diagnostics as they get added

once -> ones
Add a comma after -Weverything



Comment at: clang/docs/UsersManual.rst:1008
+then we advise that you address all new compiler diagnostics as they get added
+to clang, either by fixing everything they find or explicitly disabling that
+diagnostic with its corresponding `Wno-` option.

clang -> Clang


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65706/new/

https://reviews.llvm.org/D65706



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


[PATCH] D65625: [clangd] Allow the client to specify multiple compilation databases in the 'initialize' request

2019-08-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for having a look! I filed an issue 
 so some folks who don't 
necessarily have an LLVM Phabricator account can weigh in, let's continue the 
discussion there.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65625/new/

https://reviews.llvm.org/D65625



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


[PATCH] D65696: Implements CWG 2082 Referring to parameters in unevaluated operands of default arguments

2019-08-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:103-105
+  //   A local variable cannot be odr-used (6.2) in a default argument.
+  if (DRE->isNonOdrUse() != NOUR_None)
+return false;

Please add tests for the distinction between "potentially-evaluated" and 
"odr-used" here, for example:

```
void f() {
  const int n = 123;
  void g(int k = n); // ok, not an odr-use
}
```



Comment at: clang/www/cxx_dr_status.html:3
   "http://www.w3.org/TR/html4/strict.dtd";>
 
 

Note that this is an auto-generated file. To update it, you need to add a test 
to the relevant file (`test/CXX/drs/dr20xx.cpp`) with a suitable comment (`// 
dr2082: 10` to mark this implemented in Clang 10), grab a recent 
`cwg_index.html` file, and run the `make_cxx_dr_status` script.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65696/new/

https://reviews.llvm.org/D65696



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


[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

Rather than silently ignoring tests when the DirectoryWatcher isn't created, 
can you please print an error message and exit with an error code to indicate 
the test failed?




Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:331
+return llvm::make_error(
+std::string("Path.empty() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());

I think that this is pointless.  Just make it a constant string: "no path 
specified".  `Path` is a user specified parameter, `errno` doesn't tell us 
anything.



Comment at: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp:218
+return llvm::make_error(
+std::string("Path.empty() error: ") + strerror(errno),
+llvm::inconvertibleErrorCode());

Similar.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704



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


[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

BTW, I think that we should add a test case to ensure that we see the error in 
the case that the inotify fds are exhausted.  We should be able to create a 
process and set the limit for that process to 0/1 and use that to trigger the 
failure.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704



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


[PATCH] D65637: [clangd] [WIP] Semantic highlighting prototype for the vscode extension.

2019-08-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Do you plan to support text decorations other than color, e.g. bold / underline 
/ italic?

Are users going to be able to tweak the color (and other decoration options) 
for specific highlightings in the VSCode Settings?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65637/new/

https://reviews.llvm.org/D65637



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


[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 213218.
plotfi added a comment.

More cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -280,6 +280,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -311,6 +312,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/false);
+  if (!DW) return;
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -331,6 +333,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   fixture.addFile("a");
   fixture.addFile("b");
@@ -356,6 +359,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   // modify the file
   {
@@ -386,6 +390,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   fixture.deleteFile("a");
 
@@ -407,6 +412,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   remove_directories(fixture.TestWatchedDir);
 
@@ -427,7 +433,8 @@
   TestConsumer.consume(Events, IsInitial);
 },
 /*waitForInitialSync=*/true);
+if (!DW) return;
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
 }
\ No newline at end of file
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -11,16 +11,13 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include 
 
 using namespace llvm;
 using namespace clang;
 
-static FSEventStreamRef createFSEventStream(
-StringRef Path,
-std::function, bool)>,
-dispatch_queue_t);
 static void stopFSEventStream(FSEventStreamRef);
 
 namespace {
@@ -149,12 +146,13 @@
   }
 }
 
-FSEventStreamRef createFSEventStream(
+llvm::Expected createFSEventStream(
 StringRef Path,
 std::function, bool)> Receiver,
 dispatch_queue_t Queue) {
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode());
 
   CFMutableArrayRef PathsToWatch = [&]() {
 CFMutableArrayRef PathsToWatch =
@@ -205,7 +203,7 @@
   FSEventStreamRelease(EventStream);
 }
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
@@ -213,12 +211,14 @@
   dispatch_queue_create("DirectoryWatcher", DISPATCH_QUEUE_SERIAL);
 
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode());
+
+  auto EventStreamOrErr = createFSEventStream(Path, Receiver, Queue);
+  if (!EventStreamOrErr)
+return EventStreamOrErr.takeError();
+  auto EventStream = EventStreamOrErr.get();
 
-  auto EventStream = createFSEventStream(Path, Receiver, Queue);
-  if (!EventStream) {
-return nullptr;
-  }
 
   std::unique_ptr Result =
   llvm::make_unique(EventStream, Receiver, Path);
Index: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
===
--- clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
+++ clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -321,16 +322,19 @@
 
 } // namespace
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode());

[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D65704#1613688 , @compnerd wrote:

> Rather than silently ignoring tests when the DirectoryWatcher isn't created, 
> can you please print an error message and exit with an error code to indicate 
> the test failed?


llvm::Expected requires consumption.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704



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


[PATCH] D65708: [NFC][DirectoryWatchedTests] Unlocking mutexes before signaling condition variable.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
plotfi added reviewers: compnerd, jkorous.
Herald added a subscriber: dexonsmith.

This should not affect actual behavior, but should pessimize the threading less 
by avoiding the situation where:

- mutex is still locked
- T1 notifies on condition variable
- T2 wakes to check mutex
- T2 sees mutex is still locked
- T2 waits
- T1 unlocks mutex
- T2 tries again, acquires mutex.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65708

Files:
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp


Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -132,8 +132,10 @@
 } else {
   ExpectedInitial.erase(It);
 }
-if (result())
+if (result()) {
+  L.unlock();
   ResultIsReady.notify_one();
+}
   }
 
   void consumeNonInitial(DirectoryWatcher::Event E) {
@@ -151,8 +153,10 @@
 } else {
   ExpectedNonInitial.erase(It);
 }
-if (result())
+if (result()) {
+  L.unlock();
   ResultIsReady.notify_one();
+}
   }
 
   // This method is used by DirectoryWatcher.


Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -132,8 +132,10 @@
 } else {
   ExpectedInitial.erase(It);
 }
-if (result())
+if (result()) {
+  L.unlock();
   ResultIsReady.notify_one();
+}
   }
 
   void consumeNonInitial(DirectoryWatcher::Event E) {
@@ -151,8 +153,10 @@
 } else {
   ExpectedNonInitial.erase(It);
 }
-if (result())
+if (result()) {
+  L.unlock();
   ResultIsReady.notify_one();
+}
   }
 
   // This method is used by DirectoryWatcher.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65704: DirectoryWatcher::create: Adding better error handling.

2019-08-03 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 213221.
plotfi added a comment.

Fix a linux typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65704/new/

https://reviews.llvm.org/D65704

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -280,6 +280,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -311,6 +312,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/false);
+  if (!DW) return;
 
   checkEventualResultWithTimeout(TestConsumer);
 }
@@ -331,6 +333,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   fixture.addFile("a");
   fixture.addFile("b");
@@ -356,6 +359,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   // modify the file
   {
@@ -386,6 +390,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   fixture.deleteFile("a");
 
@@ -407,6 +412,7 @@
 TestConsumer.consume(Events, IsInitial);
   },
   /*waitForInitialSync=*/true);
+  if (!DW) return;
 
   remove_directories(fixture.TestWatchedDir);
 
@@ -427,7 +433,8 @@
   TestConsumer.consume(Events, IsInitial);
 },
 /*waitForInitialSync=*/true);
+if (!DW) return;
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
 }
\ No newline at end of file
Index: clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
===
--- clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
+++ clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
@@ -11,16 +11,13 @@
 
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include 
 
 using namespace llvm;
 using namespace clang;
 
-static FSEventStreamRef createFSEventStream(
-StringRef Path,
-std::function, bool)>,
-dispatch_queue_t);
 static void stopFSEventStream(FSEventStreamRef);
 
 namespace {
@@ -131,12 +128,13 @@
   }
 }
 
-FSEventStreamRef createFSEventStream(
+llvm::Expected createFSEventStream(
 StringRef Path,
 std::function, bool)> Receiver,
 dispatch_queue_t Queue) {
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode());
 
   CFMutableArrayRef PathsToWatch = [&]() {
 CFMutableArrayRef PathsToWatch =
@@ -187,7 +185,7 @@
   FSEventStreamRelease(EventStream);
 }
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
@@ -195,12 +193,14 @@
   dispatch_queue_create("DirectoryWatcher", DISPATCH_QUEUE_SERIAL);
 
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode());
+
+  auto EventStreamOrErr = createFSEventStream(Path, Receiver, Queue);
+  if (!EventStreamOrErr)
+return EventStreamOrErr.takeError();
+  auto EventStream = EventStreamOrErr.get();
 
-  auto EventStream = createFSEventStream(Path, Receiver, Queue);
-  if (!EventStream) {
-return nullptr;
-  }
 
   std::unique_ptr Result =
   llvm::make_unique(EventStream, Receiver, Path);
Index: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
===
--- clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
+++ clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include 
@@ -321,16 +322,19 @@
 
 } // namespace
 
-std::unique_ptr clang::DirectoryWatcher::create(
+llvm::Expected> clang::DirectoryWatcher::create(
 StringRef Path,
 std::function, bool)> Receiver,
 bool WaitForInitialSync) {
   if (Path.empty())
-return nullptr;
+return llvm::make_error(
+std::string("Path.empty() error: "), llvm::inconvertibleErrorCode(

[PATCH] D59474: [OpenMP 5.0] Codegen support for user-defined mappers

2019-08-03 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367773: [OpenMP 5.0] Codegen support for user-defined 
mappers. (authored by Meinersbur, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59474?vs=212399&id=213223#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59474/new/

https://reviews.llvm.org/D59474

Files:
  cfe/trunk/include/clang/AST/GlobalDecl.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
  cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
  cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Index: cfe/trunk/include/clang/AST/GlobalDecl.h
===
--- cfe/trunk/include/clang/AST/GlobalDecl.h
+++ cfe/trunk/include/clang/AST/GlobalDecl.h
@@ -59,6 +59,7 @@
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
+  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)
Index: cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
===
--- cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
+++ cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
@@ -1,92 +1,414 @@
-///==///
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap %s
-
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap  --check-prefix SIMD-ONLY0 %s
-
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
 
+///==///
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm -femit-all-decls -disable-llvm-passes %s -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -femit-all-decls -disable-llvm-passes -o %t %s
+// RUN: %clang_cc1 -DCK0 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -femit-all-decls -disable-llvm-passes -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix CK0 --check-prefix CK0-64 %s
+// RUN: %clang_cc1 -DCK0 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-un

r367773 - [OpenMP 5.0] Codegen support for user-defined mappers.

2019-08-03 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Sat Aug  3 21:18:42 2019
New Revision: 367773

URL: http://llvm.org/viewvc/llvm-project?rev=367773&view=rev
Log:
[OpenMP 5.0] Codegen support for user-defined mappers.

This patch implements the code generation for OpenMP 5.0 declare mapper
(user-defined mapper) constructs. For each declare mapper, a mapper
function is generated. These mapper functions will be called by the
runtime and/or other mapper functions to achieve user defined mapping.

The design slides can be found at
https://github.com/lingda-li/public-sharing/blob/master/mapper_runtime_design.pptx

Patch by Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Sat Aug  3 21:18:42 2019
@@ -59,6 +59,7 @@ public:
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
+  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug  3 21:18:42 2019
@@ -9860,7 +9860,7 @@ bool ASTContext::DeclMustBeEmitted(const
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
-  else if (isa(D))
+  else if (isa(D) || isa(D))
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return true;

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Aug  3 21:18:42 2019
@@ -2530,10 +2530,11 @@ void CodeGenModule::EmitOMPDeclareReduct
 }
 
 void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
-CodeGenFunction *CGF) {
-  if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
+ CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
+  (!LangOpts.EmitAllDecls && !D->isUsed()))
 return;
-  // FIXME: need to implement mapper code generation
+  getOpenMPRuntime().emitUserDefinedMapper(D, CGF);
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=367773&r1=367772&r2=367773&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sat Aug  3 21:18:42 2019
@@ -752,6 +752,11 @@ enum OpenMPRTLFunction {
   // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t
   // *arg_types);
   OMPRTL__tgt_target_data_update_nowait,
+  // Call to int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
+  OMPRTL__tgt_mapper_num_components,
+  // Call to void __tgt_push_mapper_component(void *rt_mapper_handle, void
+  // *base, void *begin, int64_t size, int64_t type);
+  OMPRTL__tgt_push_mapper_component,
 };
 
 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
@@ -1686,6 +1691,12 @@ void CGOpenMPRuntime::functionFinished(C
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
+  auto I = FunctionUDMMap.find(CGF.CurFn);
+  if (I != FunctionUDMMap.end()) {
+for(auto *D : I->second)
+  UDMMap.erase(D);
+FunctionUDMMap.erase(I);
+  }
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -2459,6 +2470,24 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_target_data_update_nowait");
 break;
   }
+  case OMPRTL__tgt_mapper_num_comp

r367774 - Revert "[OpenMP 5.0] Codegen support for user-defined mappers."

2019-08-03 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Sat Aug  3 22:16:52 2019
New Revision: 367774

URL: http://llvm.org/viewvc/llvm-project?rev=367774&view=rev
Log:
Revert "[OpenMP 5.0] Codegen support for user-defined mappers."

This reverts commit r367773. The test case
OpenMP/declare_mapper_codegen.cpp is failing.

Modified:
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp

Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Sat Aug  3 22:16:52 2019
@@ -59,7 +59,6 @@ public:
   GlobalDecl(const CapturedDecl *D) { Init(D); }
   GlobalDecl(const ObjCMethodDecl *D) { Init(D); }
   GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); }
-  GlobalDecl(const OMPDeclareMapperDecl *D) { Init(D); }
   GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {}
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Aug  3 22:16:52 2019
@@ -9860,7 +9860,7 @@ bool ASTContext::DeclMustBeEmitted(const
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
-  else if (isa(D) || isa(D))
+  else if (isa(D))
 return !D->getDeclContext()->isDependentContext();
   else if (isa(D))
 return true;

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Aug  3 22:16:52 2019
@@ -2530,11 +2530,10 @@ void CodeGenModule::EmitOMPDeclareReduct
 }
 
 void CodeGenModule::EmitOMPDeclareMapper(const OMPDeclareMapperDecl *D,
- CodeGenFunction *CGF) {
-  if (!LangOpts.OpenMP || LangOpts.OpenMPSimd ||
-  (!LangOpts.EmitAllDecls && !D->isUsed()))
+CodeGenFunction *CGF) {
+  if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
 return;
-  getOpenMPRuntime().emitUserDefinedMapper(D, CGF);
+  // FIXME: need to implement mapper code generation
 }
 
 void CodeGenModule::EmitOMPRequiresDecl(const OMPRequiresDecl *D) {

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=367774&r1=367773&r2=367774&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sat Aug  3 22:16:52 2019
@@ -752,11 +752,6 @@ enum OpenMPRTLFunction {
   // arg_num, void** args_base, void **args, int64_t *arg_sizes, int64_t
   // *arg_types);
   OMPRTL__tgt_target_data_update_nowait,
-  // Call to int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
-  OMPRTL__tgt_mapper_num_components,
-  // Call to void __tgt_push_mapper_component(void *rt_mapper_handle, void
-  // *base, void *begin, int64_t size, int64_t type);
-  OMPRTL__tgt_push_mapper_component,
 };
 
 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
@@ -1691,12 +1686,6 @@ void CGOpenMPRuntime::functionFinished(C
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
-  auto I = FunctionUDMMap.find(CGF.CurFn);
-  if (I != FunctionUDMMap.end()) {
-for(auto *D : I->second)
-  UDMMap.erase(D);
-FunctionUDMMap.erase(I);
-  }
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -2470,24 +2459,6 @@ llvm::FunctionCallee CGOpenMPRuntime::cr
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_target_data_update_nowait");
 break;
   }
-  case OMPRTL__tgt_mapper_num_components: {
-// Build int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
-llvm::Type *TypeParams[] = {CGM.VoidPtrTy};
-auto *FnTy =
-llvm::FunctionType::get(CGM.Int64Ty, TypeParams, /*isVarArg*/ false);
-RTLFn = CGM.CreateRuntimeFunction(FnTy, "__tgt_mapper_num_components");
-break;
-  }
-  case OMPRTL__tgt_push_mapper_component: {
-/