[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366405.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;

+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && &&Ctor->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);

   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;

+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && &&Ctor->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);

   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366407.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366410.

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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366411.

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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor()) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366413.
peterjc123 added a comment.

Skip in template classes


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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 { HasDtor o; };
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0391165 - [clang-format] NFC update the ClangFormatStyleOption.rst following previous change

2021-08-14 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-08-14T10:41:58+01:00
New Revision: 0391165134fc2d19fd13170d87724c3b7bd7366e

URL: 
https://github.com/llvm/llvm-project/commit/0391165134fc2d19fd13170d87724c3b7bd7366e
DIFF: 
https://github.com/llvm/llvm-project/commit/0391165134fc2d19fd13170d87724c3b7bd7366e.diff

LOG: [clang-format] NFC update the ClangFormatStyleOption.rst following 
previous change

clang/docs/tool/dump_format_style.py was not run as part of  {D99840}

Bring ClangFormatStyleOptions.rst back in line.

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 96d89db7a5ccf..5bd5ae1f080e4 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -741,8 +741,7 @@ the configuration (without a prefix: ``Auto``).
 enum { A, B } myEnum;
 
 false:
-enum
-{
+enum {
   A,
   B
 } myEnum;



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


[PATCH] D107958: [clang-format] NFC update the ClangFormatStyleOption.rst following previous change

2021-08-14 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0391165134fc: [clang-format] NFC update the 
ClangFormatStyleOption.rst following previous… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107958

Files:
  clang/docs/ClangFormatStyleOptions.rst


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -741,8 +741,7 @@
 enum { A, B } myEnum;
 
 false:
-enum
-{
+enum {
   A,
   B
 } myEnum;


Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -741,8 +741,7 @@
 enum { A, B } myEnum;
 
 false:
-enum
-{
+enum {
   A,
   B
 } myEnum;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366416.
peterjc123 added a comment.

clang-format


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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108067: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 created this revision.
peterjc123 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108067

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
  utils/arcanist/clang-format.sh


Index: utils/arcanist/clang-format.sh
===
--- utils/arcanist/clang-format.sh
+++ utils/arcanist/clang-format.sh
@@ -12,6 +12,8 @@
 
 # advice severity level is completely non-disruptive.
 # switch to warning or error if you want to prompt the user.
+export PATH=$PATH:/d/Test/llvm/build/Release/bin
+
 if ! hash clang-format >/dev/null; then
   echo "advice"
   echo "clang-format not found in user’s local PATH; not linting file."
Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: utils/arcanist/clang-format.sh
===
--- utils/arcanist/clang-format.sh
+++ utils/arcanist/clang-format.sh
@@ -12,6 +12,8 @@
 
 # advice severity level is completely non-disruptive.
 # switch to warning or error if you want to prompt the user.
+export PATH=$PATH:/d/Test/llvm/build/Release/bin
+
 if ! hash clang-format >/dev/null; then
   echo "advice"
   echo "clang-format not found in user’s local PATH; not linting file."
Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108068: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 created this revision.
peterjc123 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108068

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108069: [CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-08-14 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: LLVM, VE.
kaz7 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Need to update a clang regression test for VE after
https://reviews.llvm.org/D93769.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108069

Files:
  clang/test/Preprocessor/init-ve.c


Index: clang/test/Preprocessor/init-ve.c
===
--- clang/test/Preprocessor/init-ve.c
+++ clang/test/Preprocessor/init-ve.c
@@ -32,7 +32,6 @@
 // VE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // VE:#define __FLT_DIG__ 6
 // VE:#define __FLT_EPSILON__ 1.19209290e-7F
-// VE:#define __FLT_EVAL_METHOD__ 0
 // VE:#define __FLT_HAS_DENORM__ 1
 // VE:#define __FLT_HAS_INFINITY__ 1
 // VE:#define __FLT_HAS_QUIET_NAN__ 1


Index: clang/test/Preprocessor/init-ve.c
===
--- clang/test/Preprocessor/init-ve.c
+++ clang/test/Preprocessor/init-ve.c
@@ -32,7 +32,6 @@
 // VE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // VE:#define __FLT_DIG__ 6
 // VE:#define __FLT_EPSILON__ 1.19209290e-7F
-// VE:#define __FLT_EVAL_METHOD__ 0
 // VE:#define __FLT_HAS_DENORM__ 1
 // VE:#define __FLT_HAS_INFINITY__ 1
 // VE:#define __FLT_HAS_QUIET_NAN__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95168: [clang-format] Add InsertBraces option

2021-08-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Any thoughts about actually removing braces? eliding braces on single line 
functions would be very useful for LLVM, its like the most common review 
comment!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95168

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


[PATCH] D108021: [dllexport] Instantiate default ctor default args

2021-08-14 Thread Peter Jiachen via Phabricator via cfe-commits
peterjc123 updated this revision to Diff 366423.
peterjc123 added a comment.

clang-tidy


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

https://reviews.llvm.org/D108021

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void 
@"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto *CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is


Index: clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-ctor-closure-nested.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \
+// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \
+// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \
+// RUN:FileCheck %s
+
+struct HasDtor {
+  ~HasDtor();
+  int o;
+};
+struct HasImplicitDtor1 {
+  HasDtor o;
+};
+struct __declspec(dllexport) CtorClosureOuter {
+  struct __declspec(dllexport) CtorClosureInner {
+CtorClosureInner(const HasImplicitDtor1 &v = {}) {}
+  };
+};
+
+// CHECK-LABEL: $"??1HasImplicitDtor1@@QAE@XZ" = comdat any
+// CHECK-LABEL: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FCtorClosureInner@CtorClosureOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6005,6 +6005,15 @@
   if (TSK == TSK_ImplicitInstantiation && !ClassAttr->isInherited())
 continue;
 
+  // If this is an MS ABI dllexport default constructor, instantiate any
+  // default arguments.
+  if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+auto *CD = dyn_cast(MD);
+if (CD && CD->isDefaultConstructor() && TSK == TSK_Undeclared) {
+  S.InstantiateDefaultCtorDefaultArgs(CD);
+}
+  }
+
   S.MarkFunctionReferenced(Class->getLocation(), MD);
 
   // The function will be passed to the consumer when its definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] fe86632 - [clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

2021-08-14 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-08-14T12:05:21+01:00
New Revision: fe866327c1f98a327767e80290dd08cedeadbfd6

URL: 
https://github.com/llvm/llvm-project/commit/fe866327c1f98a327767e80290dd08cedeadbfd6
DIFF: 
https://github.com/llvm/llvm-project/commit/fe866327c1f98a327767e80290dd08cedeadbfd6.diff

LOG: [clang-tidy] [PR50069] readability-braces-around-statements doesn't work 
well with [[likely]] [[unlikely]]

https://bugs.llvm.org/show_bug.cgi?id=50069

When clang-tidy sees:

```
if (true) [[unlikely]] {
...
}
```

It thinks the braces are missing and add them again.

```
if (true)  { [[unlikely]] {
...
  }
}
```

This revision aims to prevent that incorrect code generation

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp

Modified: 
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index fe25f7a7ccbcc..7dc519c152828 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -186,6 +186,10 @@ BracesAroundStatementsCheck::findRParenLoc(const 
IfOrWhileStmt *S,
 bool BracesAroundStatementsCheck::checkStmt(
 const MatchFinder::MatchResult &Result, const Stmt *S,
 SourceLocation InitialLoc, SourceLocation EndLocHint) {
+
+  while (const auto *AS = dyn_cast(S))
+S = AS->getSubStmt();
+
   // 1) If there's a corresponding "else" or "while", the check inserts "} "
   // right before that token.
   // 2) If there's a multi-line block comment starting on the same line after

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
new file mode 100644
index 0..e799614a1f7b0
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy  -std=c++20-or-later %s 
readability-braces-around-statements %t
+
+void test(bool b) {
+  if (b) {
+return;
+  }
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  }
+
+  if (b) [[likely]]
+// CHECK-FIXES: if (b) {{[[][[]}}likely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+  if (b) [[unlikely]]
+// CHECK-FIXES: if (b) {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+}



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


[PATCH] D105479: [clang-tidy] [PR50069] readability-braces-around-statements doesn't work well with [[likely]] [[unlikely]]

2021-08-14 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe866327c1f9: [clang-tidy] [PR50069] 
readability-braces-around-statements doesn't work well… (authored by 
MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105479

Files:
  clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy  -std=c++20-or-later %s 
readability-braces-around-statements %t
+
+void test(bool b) {
+  if (b) {
+return;
+  }
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  }
+
+  if (b) [[likely]]
+// CHECK-FIXES: if (b) {{[[][[]}}likely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+  if (b) [[unlikely]]
+// CHECK-FIXES: if (b) {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+}
Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -186,6 +186,10 @@
 bool BracesAroundStatementsCheck::checkStmt(
 const MatchFinder::MatchResult &Result, const Stmt *S,
 SourceLocation InitialLoc, SourceLocation EndLocHint) {
+
+  while (const auto *AS = dyn_cast(S))
+S = AS->getSubStmt();
+
   // 1) If there's a corresponding "else" or "while", the check inserts "} "
   // right before that token.
   // 2) If there's a multi-line block comment starting on the same line after


Index: clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy  -std=c++20-or-later %s readability-braces-around-statements %t
+
+void test(bool b) {
+  if (b) {
+return;
+  }
+  if (b) [[likely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} {
+return;
+  }
+  if (b) [[unlikely]] {
+// CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  }
+
+  if (b) [[likely]]
+// CHECK-FIXES: if (b) {{[[][[]}}likely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+  if (b) [[unlikely]]
+// CHECK-FIXES: if (b) {{[[][[]}}unlikely{{[]][]]}} {
+return;
+  // CHECK-FIXES: }
+}
Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -186,6 +186,10 @@
 bool BracesAroundStatementsCheck::checkStmt(
 const MatchFinder::MatchResult &Result, const Stmt *S,
 SourceLocation InitialLoc, SourceLocation EndLocHint) {
+
+  while (const auto *AS = dyn_cast(S))
+S = AS->getSubStmt();
+
   // 1) If there's a corresponding "else" or "while", the check inserts "} "
   // right before that token.
   // 2) If there's a multi-line block comment starting on the same line after
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104975: Implement P1949

2021-08-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 366425.
cor3ntin added a comment.

- Support superseeding DRs with paper in make_cxx_dr_status (ie //drXXX: sup 
P)

- Better diagnostic message when a codepoint is identifier continue but not 
identifier start
- Provide a different diagnostic message for Unicode codepoints that are not 
identifier part and are not part of a pp-identifier.
- When parsing an identifier, for non-ascii, non-whitespace codepoints, emit an 
error and then pretend the codepoint is valid for better recovery.
- Restore the previously removed DR tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

Files:
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/UnicodeCharSets.h
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/FixIt/fixit-unicode.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/assembler-with-cpp.c
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Preprocessor/utf8-allowed-chars.c
  clang/www/cxx_dr_status.html
  clang/www/cxx_status.html
  clang/www/make_cxx_dr_status
  llvm/include/llvm/Support/UnicodeCharRanges.h

Index: llvm/include/llvm/Support/UnicodeCharRanges.h
===
--- llvm/include/llvm/Support/UnicodeCharRanges.h
+++ llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -62,6 +62,14 @@
   /// Returns true if the character set contains the Unicode code point
   /// \p C.
   bool contains(uint32_t C) const {
+if (C < 127) {
+  for (const auto &R : Ranges) {
+if (R.Lower <= C && R.Upper >= C)
+  return true;
+if (R.Lower > C)
+  return false;
+  }
+}
 return std::binary_search(Ranges.begin(), Ranges.end(), C);
   }
 
Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -135,12 +135,16 @@
 avail_style = ' class="na"'
   elif status.startswith('sup '):
 dup = status.split(' ', 1)[1]
-avail = 'Superseded by %s' % (dup, dup)
-try:
-  _, avail_style = availability(int(dup))
-except:
-  print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
-  avail_style = ' class="none"'
+if dup.startswith('P'):
+  avail = 'Superseded by %s' % (dup, dup)
+  avail_style = ' class="na"'
+else:
+  avail = 'Superseded by %s' % (dup, dup)
+  try:
+_, avail_style = availability(int(dup))
+  except:
+print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
+avail_style = ' class="none"'
   elif status.startswith('dup '):
 dup = int(status.split(' ', 1)[1])
 avail = 'Duplicate of %s' % (dup, dup)
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1314,7 +1314,7 @@
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7";>P1949R7
-  No
+  Clang 14
 
 
   Mixed string literal concatenation
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -824,7 +824,7 @@
 https://wg21.link/cwg131";>131
 TC1
 Typo in Lao characters
-Yes
+Superseded by P1949
   
   
 https://wg21.link/cwg132";>132
@@ -1527,7 +1527,7 @@
 https://wg21.link/cwg248";>248
 C++11
 Identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg249";>249
@@ -4020,7 +4020,7 @@
 https://wg21.link/cwg663";>663
 CD1
 Valid Cyrillic identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg664";>664
Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -18,51 +18,41 @@
 
 // Identifier initial characters
 extern char ๐; // C++03, C11, C++11
-extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
-
-
-
-
+extern char ̀; // disallowed initially in C11/C++, always in C99
 
 
 
 
 #if __cplusplus
-# if __cplusplus >= 201103L
-// C++11
-// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@21 {{exp

[PATCH] D104975: Implement P1949

2021-08-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 366426.
cor3ntin added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

Files:
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/UnicodeCharSets.h
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/FixIt/fixit-unicode.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/assembler-with-cpp.c
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Preprocessor/utf8-allowed-chars.c
  clang/www/cxx_dr_status.html
  clang/www/cxx_status.html
  clang/www/make_cxx_dr_status
  llvm/include/llvm/Support/UnicodeCharRanges.h

Index: llvm/include/llvm/Support/UnicodeCharRanges.h
===
--- llvm/include/llvm/Support/UnicodeCharRanges.h
+++ llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -62,6 +62,14 @@
   /// Returns true if the character set contains the Unicode code point
   /// \p C.
   bool contains(uint32_t C) const {
+if (C < 127) {
+  for (const auto &R : Ranges) {
+if (R.Lower <= C && R.Upper >= C)
+  return true;
+if (R.Lower > C)
+  return false;
+  }
+}
 return std::binary_search(Ranges.begin(), Ranges.end(), C);
   }
 
Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -135,12 +135,16 @@
 avail_style = ' class="na"'
   elif status.startswith('sup '):
 dup = status.split(' ', 1)[1]
-avail = 'Superseded by %s' % (dup, dup)
-try:
-  _, avail_style = availability(int(dup))
-except:
-  print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
-  avail_style = ' class="none"'
+if dup.startswith('P'):
+  avail = 'Superseded by %s' % (dup, dup)
+  avail_style = ' class="na"'
+else:
+  avail = 'Superseded by %s' % (dup, dup)
+  try:
+_, avail_style = availability(int(dup))
+  except:
+print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
+avail_style = ' class="none"'
   elif status.startswith('dup '):
 dup = int(status.split(' ', 1)[1])
 avail = 'Duplicate of %s' % (dup, dup)
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1314,7 +1314,7 @@
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7";>P1949R7
-  No
+  Clang 14
 
 
   Mixed string literal concatenation
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -824,7 +824,7 @@
 https://wg21.link/cwg131";>131
 TC1
 Typo in Lao characters
-Yes
+Superseded by P1949
   
   
 https://wg21.link/cwg132";>132
@@ -1527,7 +1527,7 @@
 https://wg21.link/cwg248";>248
 C++11
 Identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg249";>249
@@ -4020,7 +4020,7 @@
 https://wg21.link/cwg663";>663
 CD1
 Valid Cyrillic identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg664";>664
Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -18,51 +18,41 @@
 
 // Identifier initial characters
 extern char ๐; // C++03, C11, C++11
-extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
-
-
-
-
+extern char ̀; // disallowed initially in C11/C++, always in C99
 
 
 
 
 #if __cplusplus
-# if __cplusplus >= 201103L
-// C++11
-// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@21 {{expected unqualified-id}}
+// expected-error@11 {{not allowed in an identifier}}
+// expected-error@13 {{not allowed in an identifier}}
+// expected-error@20 {{character  not allowed at the start of an identifier}}
+// expected-error@21 {{character  not allowed at the start of an identifier}}
+// expected-warning@20 {{declaration does not declare anything}}
+// expected-warning@21 {{declaration does not declare anything}}
 
-# else
-// C++03
-// expected-error@9 {{non-ASCII characters are

[PATCH] D104975: Implement P1949

2021-08-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D104975#2944703 , @rsmith wrote:

> In D104975#2944313 , @cor3ntin 
> wrote:
>
>> @rsmith: I modified the script locally to support dxx: dup P - let me 
>> know if you think that's a good solution
>
> Not sure if that's a typo: did you mean "sup" rather than "dup"? In this 
> case, it seems like "sup" is right if the old DR resolution no longer 
> applies. (If the old resolution does still apply, but was generalized, then I 
> think we should just leave the DR status table alone for that issue, because 
> that issue's resolution is still implemented.)

yep, I meant sup, sorry.
I made the change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

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


[PATCH] D104975: Implement P1949

2021-08-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin marked 2 inline comments as done.
cor3ntin added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:117
+def err_character_not_allowed : Error<
+  "character  not allowed in identifiers">;
 def ext_unicode_whitespace : ExtWarn<

rsmith wrote:
> The old diagnostic text here was bad in the case where the character was 
> supposed to be part of an identifier. The new diagnostic text is bad in the 
> case where the character is not supposed to be part of an identifier (eg, if 
> you copy-paste a smart-quote into the source file). Is there some way we can 
> phrase this diagnostic so it's reasonable regardless of the programmer's 
> intent?
> 
> Perhaps the best we can do is to say that if an identifier is immediately 
> followed by one or more "bad" Unicode characters that were probably intended 
> to be identifier characters (things we don't recognize as whitespace or 
> homoglyphs or anything else), then produce the nice "not allowed in 
> identifiers" diagnostic (and maybe even treat the characters as part of the 
> identifier for error recovery purposes), and otherwise diagnose as simply 
> "unexpected character "? I also wonder if perhaps we should treat all 
> unexpected characters as identifier characters for error recovery purposes.
I changed the PR so that, at the start of an identifier, if the Unicode 
character is neither a whitespace, identifier start or identifier continue,
we display `unexpected character `.
It's not perfect because we make no effort to distinguish pp-numbers from 
identifiers, but it seems good enough! Certainly an improvement :)

I also recover nicely for non-leading invalid Unicode codepoints. I am not sure 
we should do that for the leading case though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

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


[PATCH] D104975: Implement P1949

2021-08-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 366430.
cor3ntin added a comment.

Fix test formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104975

Files:
  clang/include/clang/Basic/CharInfo.h
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/UnicodeCharSets.h
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/FixIt/fixit-unicode.c
  clang/test/Lexer/unicode.c
  clang/test/Parser/cxx11-user-defined-literals.cpp
  clang/test/Preprocessor/assembler-with-cpp.c
  clang/test/Preprocessor/ucn-allowed-chars.c
  clang/test/Preprocessor/utf8-allowed-chars.c
  clang/www/cxx_dr_status.html
  clang/www/cxx_status.html
  clang/www/make_cxx_dr_status
  llvm/include/llvm/Support/UnicodeCharRanges.h

Index: llvm/include/llvm/Support/UnicodeCharRanges.h
===
--- llvm/include/llvm/Support/UnicodeCharRanges.h
+++ llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -62,6 +62,14 @@
   /// Returns true if the character set contains the Unicode code point
   /// \p C.
   bool contains(uint32_t C) const {
+if (C < 127) {
+  for (const auto &R : Ranges) {
+if (R.Lower <= C && R.Upper >= C)
+  return true;
+if (R.Lower > C)
+  return false;
+  }
+}
 return std::binary_search(Ranges.begin(), Ranges.end(), C);
   }
 
Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -135,12 +135,16 @@
 avail_style = ' class="na"'
   elif status.startswith('sup '):
 dup = status.split(' ', 1)[1]
-avail = 'Superseded by %s' % (dup, dup)
-try:
-  _, avail_style = availability(int(dup))
-except:
-  print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
-  avail_style = ' class="none"'
+if dup.startswith('P'):
+  avail = 'Superseded by %s' % (dup, dup)
+  avail_style = ' class="na"'
+else:
+  avail = 'Superseded by %s' % (dup, dup)
+  try:
+_, avail_style = availability(int(dup))
+  except:
+print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
+avail_style = ' class="none"'
   elif status.startswith('dup '):
 dup = int(status.split(' ', 1)[1])
 avail = 'Duplicate of %s' % (dup, dup)
Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1314,7 +1314,7 @@
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7";>P1949R7
-  No
+  Clang 14
 
 
   Mixed string literal concatenation
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -824,7 +824,7 @@
 https://wg21.link/cwg131";>131
 TC1
 Typo in Lao characters
-Yes
+Superseded by P1949
   
   
 https://wg21.link/cwg132";>132
@@ -1527,7 +1527,7 @@
 https://wg21.link/cwg248";>248
 C++11
 Identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg249";>249
@@ -4020,7 +4020,7 @@
 https://wg21.link/cwg663";>663
 CD1
 Valid Cyrillic identifier characters
-Yes (C++11 onwards)
+Superseded by P1949
   
   
 https://wg21.link/cwg664";>664
Index: clang/test/Preprocessor/utf8-allowed-chars.c
===
--- clang/test/Preprocessor/utf8-allowed-chars.c
+++ clang/test/Preprocessor/utf8-allowed-chars.c
@@ -18,51 +18,41 @@
 
 // Identifier initial characters
 extern char ๐; // C++03, C11, C++11
-extern char ̀; // disallowed initially in C11/C++11, always in C99/C++03
-
-
-
-
+extern char ̀; // disallowed initially in C11/C++, always in C99
 
 
 
 
 #if __cplusplus
-# if __cplusplus >= 201103L
-// C++11
-// expected-warning@9 {{using this character in an identifier is incompatible with C++98}}
-// expected-warning@10 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@13 {{non-ASCII characters are not allowed outside of literals and identifiers}}
-// expected-warning@14 {{using this character in an identifier is incompatible with C++98}}
-// expected-error@21 {{expected unqualified-id}}
+// expected-error@11 {{not allowed in an identifier}}
+// expected-error@13 {{not allowed in an identifier}}
+// expected-error@20 {{character  not allowed at the start of an identifier}}
+// expected-error@21 {{character  not allowed at the start of an identifier}}
+// expected-warning@20 {{declaration does not declare anything}}
+// expected-warning@21 {{declaration does not declare anything}}
 
-# else
-// C++03
-// expected-error@9 {{non-ASCII chara

[clang] f6928cf - [clang-format] Distinguish K&R C function definition and attribute

2021-08-14 Thread via cfe-commits

Author: Owen
Date: 2021-08-14T05:00:40-07:00
New Revision: f6928cf45516503deb48f8175a982becc579dc8c

URL: 
https://github.com/llvm/llvm-project/commit/f6928cf45516503deb48f8175a982becc579dc8c
DIFF: 
https://github.com/llvm/llvm-project/commit/f6928cf45516503deb48f8175a982becc579dc8c.diff

LOG: [clang-format] Distinguish K&R C function definition and attribute

This is a follow-up to https://reviews.llvm.org/D107950 which
missed user-defined types in K&R C.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 0c4cacab5050..fae77ab48612 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -14,7 +14,6 @@
 
 #include "UnwrappedLineParser.h"
 #include "FormatToken.h"
-#include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -995,6 +994,13 @@ static bool isJSDeclOrStmt(const AdditionalKeywords 
&Keywords,
   Keywords.kw_import, tok::kw_export);
 }
 
+// Checks whether a token is a type in K&R C (aka C78).
+static bool isC78Type(const FormatToken &Tok) {
+  return Tok.isOneOf(tok::kw_char, tok::kw_short, tok::kw_int, tok::kw_long,
+ tok::kw_unsigned, tok::kw_float, tok::kw_double,
+ tok::identifier);
+}
+
 // This function checks whether a token starts the first parameter declaration
 // in a K&R C (aka C78) function definition, e.g.:
 //   int f(a, b)
@@ -1006,9 +1012,8 @@ static bool isC78ParameterDecl(const FormatToken *Tok) {
   if (!Tok)
 return false;
 
-  if (!Tok->isOneOf(tok::kw_int, tok::kw_char, tok::kw_float, tok::kw_double,
-tok::kw_struct, tok::kw_union, tok::kw_long, tok::kw_short,
-tok::kw_unsigned, tok::kw_register))
+  if (!isC78Type(*Tok) &&
+  !Tok->isOneOf(tok::kw_register, tok::kw_struct, tok::kw_union))
 return false;
 
   Tok = Tok->Previous;
@@ -1369,7 +1374,7 @@ void UnwrappedLineParser::parseStructuralElement(bool 
IsTopLevel) {
 case tok::r_brace:
   addUnwrappedLine();
   return;
-case tok::l_paren:
+case tok::l_paren: {
   parseParens();
   // Break the unwrapped line if a K&R C function definition has a 
parameter
   // declaration.
@@ -1377,14 +1382,22 @@ void UnwrappedLineParser::parseStructuralElement(bool 
IsTopLevel) {
 break;
   if (!Previous || Previous->isNot(tok::identifier))
 break;
-  if (Previous->Previous && Previous->Previous->is(tok::at))
+  const FormatToken *PrevPrev = Previous->Previous;
+  if (!PrevPrev || (!isC78Type(*PrevPrev) && PrevPrev->isNot(tok::star)))
 break;
-  if (!Line->Tokens.begin()->Tok->is(tok::kw_typedef) &&
-  isC78ParameterDecl(FormatTok)) {
+  const unsigned Position = Tokens->getPosition() + 1;
+  if (Position == AllTokens.size())
+break;
+  assert(Position < AllTokens.size());
+  const FormatToken *Next = AllTokens[Position];
+  if (Next && Next->isOneOf(tok::l_paren, tok::semi))
+break;
+  if (isC78ParameterDecl(FormatTok)) {
 addUnwrappedLine();
 return;
   }
   break;
+}
 case tok::kw_operator:
   nextToken();
   if (FormatTok->isBinaryOperator())

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1283aa67b337..383c2cf9e6c4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8247,6 +8247,20 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
"  return a + b < c;\n"
"};",
Style);
+  verifyFormat("byte *\n" // Break here.
+   "f(a)\n"   // Break here.
+   "byte a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}",
+   Style);
+  verifyFormat("bool f(int a, int) override;\n"
+   "Bar g(int a, Bar) final;\n"
+   "Bar h(a, Bar) final;",
+   Style);
+  verifyFormat("int\n"
+   "f(a)",
+   Style);
 
   // The return breaking style doesn't affect:
   // * function and object definitions with attribute-like macros



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


[PATCH] D107961: [clang-format] Distinguish K&R C function definition and attribute

2021-08-14 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6928cf45516: [clang-format] Distinguish K&R C function 
definition and attribute (authored by Owen 
, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107961

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8247,6 +8247,20 @@
"  return a + b < c;\n"
"};",
Style);
+  verifyFormat("byte *\n" // Break here.
+   "f(a)\n"   // Break here.
+   "byte a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}",
+   Style);
+  verifyFormat("bool f(int a, int) override;\n"
+   "Bar g(int a, Bar) final;\n"
+   "Bar h(a, Bar) final;",
+   Style);
+  verifyFormat("int\n"
+   "f(a)",
+   Style);
 
   // The return breaking style doesn't affect:
   // * function and object definitions with attribute-like macros
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -14,7 +14,6 @@
 
 #include "UnwrappedLineParser.h"
 #include "FormatToken.h"
-#include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -995,6 +994,13 @@
   Keywords.kw_import, tok::kw_export);
 }
 
+// Checks whether a token is a type in K&R C (aka C78).
+static bool isC78Type(const FormatToken &Tok) {
+  return Tok.isOneOf(tok::kw_char, tok::kw_short, tok::kw_int, tok::kw_long,
+ tok::kw_unsigned, tok::kw_float, tok::kw_double,
+ tok::identifier);
+}
+
 // This function checks whether a token starts the first parameter declaration
 // in a K&R C (aka C78) function definition, e.g.:
 //   int f(a, b)
@@ -1006,9 +1012,8 @@
   if (!Tok)
 return false;
 
-  if (!Tok->isOneOf(tok::kw_int, tok::kw_char, tok::kw_float, tok::kw_double,
-tok::kw_struct, tok::kw_union, tok::kw_long, tok::kw_short,
-tok::kw_unsigned, tok::kw_register))
+  if (!isC78Type(*Tok) &&
+  !Tok->isOneOf(tok::kw_register, tok::kw_struct, tok::kw_union))
 return false;
 
   Tok = Tok->Previous;
@@ -1369,7 +1374,7 @@
 case tok::r_brace:
   addUnwrappedLine();
   return;
-case tok::l_paren:
+case tok::l_paren: {
   parseParens();
   // Break the unwrapped line if a K&R C function definition has a 
parameter
   // declaration.
@@ -1377,14 +1382,22 @@
 break;
   if (!Previous || Previous->isNot(tok::identifier))
 break;
-  if (Previous->Previous && Previous->Previous->is(tok::at))
+  const FormatToken *PrevPrev = Previous->Previous;
+  if (!PrevPrev || (!isC78Type(*PrevPrev) && PrevPrev->isNot(tok::star)))
 break;
-  if (!Line->Tokens.begin()->Tok->is(tok::kw_typedef) &&
-  isC78ParameterDecl(FormatTok)) {
+  const unsigned Position = Tokens->getPosition() + 1;
+  if (Position == AllTokens.size())
+break;
+  assert(Position < AllTokens.size());
+  const FormatToken *Next = AllTokens[Position];
+  if (Next && Next->isOneOf(tok::l_paren, tok::semi))
+break;
+  if (isC78ParameterDecl(FormatTok)) {
 addUnwrappedLine();
 return;
   }
   break;
+}
 case tok::kw_operator:
   nextToken();
   if (FormatTok->isBinaryOperator())


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8247,6 +8247,20 @@
"  return a + b < c;\n"
"};",
Style);
+  verifyFormat("byte *\n" // Break here.
+   "f(a)\n"   // Break here.
+   "byte a[];\n"
+   "{\n"
+   "  return a;\n"
+   "}",
+   Style);
+  verifyFormat("bool f(int a, int) override;\n"
+   "Bar g(int a, Bar) final;\n"
+   "Bar h(a, Bar) final;",
+   Style);
+  verifyFormat("int\n"
+   "f(a)",
+   Style);
 
   // The return breaking style doesn't affect:
   // * function and object definitions with attribute-like macros
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParse

[PATCH] D107775: [Clang][AST] Resolve FIXME: Remove ObjCObjectPointer from isSpecifierType

2021-08-14 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 366451.
gAlfonso-bit added a comment.

Add ObjectPointerType to GetBaseType


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

https://reviews.llvm.org/D107775

Files:
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -151,13 +151,16 @@
   // FIXME: This should be on the Type class!
   QualType BaseType = T;
   while (!BaseType->isSpecifierType()) {
-if (const PointerType *PTy = BaseType->getAs())
+if (const ObjCObjectPointerType *OPT =
+BaseType->getAs())
+  BaseType = OPT->getPointeeType();
+else if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2785,7 +2785,6 @@
   case DependentTemplateSpecialization:
   case ObjCInterface:
   case ObjCObject:
-  case ObjCObjectPointer: // FIXME: object pointers aren't really specifiers
 return true;
   default:
 return false;
Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -151,13 +151,16 @@
   // FIXME: This should be on the Type class!
   QualType BaseType = T;
   while (!BaseType->isSpecifierType()) {
-if (const PointerType *PTy = BaseType->getAs())
+if (const ObjCObjectPointerType *OPT =
+BaseType->getAs())
+  BaseType = OPT->getPointeeType();
+else if (const PointerType *PTy = BaseType->getAs())
   BaseType = PTy->getPointeeType();
 else if (const BlockPointerType *BPy = BaseType->getAs())
   BaseType = BPy->getPointeeType();
-else if (const ArrayType* ATy = dyn_cast(BaseType))
+else if (const ArrayType *ATy = dyn_cast(BaseType))
   BaseType = ATy->getElementType();
-else if (const FunctionType* FTy = BaseType->getAs())
+else if (const FunctionType *FTy = BaseType->getAs())
   BaseType = FTy->getReturnType();
 else if (const VectorType *VTy = BaseType->getAs())
   BaseType = VTy->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107873: [WIP][clang-tidy] adds a const-qualified parameter check

2021-08-14 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 366456.
cjdb marked 9 inline comments as done.
cjdb added a comment.

- adds user options

- removes use of `auto`
- fixes header comment
- removes unused type
- fixes documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107873

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.cpp
  clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  
clang-tools-extra/docs/clang-tidy/checks/performance-const-parameter-value-or-ref.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/custom-max-size.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
@@ -12,6 +12,7 @@
 "//llvm/lib/Support",
   ]
   sources = [
+"ConstParameterValueOrRef.cpp",
 "FasterStringFindCheck.cpp",
 "ForRangeCopyCheck.cpp",
 "ImplicitConversionInLoopCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s performance-const-parameter-value-or-ref %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN: {key: performance-const-parameter-value-or-ref.ForwardDeclarationsSuppressWarnings,\
+// RUN:  value: false}\
+// RUN:   ]}"
+
+class NotTriviallyCopyable {
+public:
+  NotTriviallyCopyable() = default;
+
+  NotTriviallyCopyable(const NotTriviallyCopyable &);
+};
+
+void f1(NotTriviallyCopyable);
+void f1(const NotTriviallyCopyable) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'const NotTriviallyCopyable' is not trivially copyable: pass by reference-to-const instead
+// CHECK-FIXES: void f1(const NotTriviallyCopyable&) {}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
@@ -0,0 +1,260 @@
+// RUN: %check_clang_tidy %s performance-const-parameter-value-or-ref %t
+
+template 
+struct array {
+  T base[N];
+};
+
+using MaxSmall = array;
+using MinLarge = array;
+
+class NotTriviallyCopyable {
+public:
+  NotTriviallyCopyable() = default;
+
+  NotTriviallyCopyable(const NotTriviallyCopyable &) {}
+};
+
+// No warnings for forward declarations: this is the domain of
+// readability-avoid-const-params-in-decls
+void f1(const __int128);
+void f1(const MaxSmall);
+void f1(const MinLarge);
+void f1(const NotTriviallyCopyable);
+
+struct S1 {
+  void f(const __int128);
+  void f(const MaxSmall);
+  void f(const MinLarge);
+  void f(const NotTriviallyCopyable);
+};
+
+void f2(const __int128 &);
+void f2(const MaxSmall &);
+void f2(const MinLarge &);
+void f2(const NotTriviallyCopyable &);
+void f2(const array &);
+
+struct S2 {
+  void f(const __int128 &);
+  void f(const MaxSmall &);
+  void f(const MinLarge &);
+  void f(const NotTriviallyCopyable &);
+  void f(const array &);
+};
+
+// No warnings for function definitions that have been forward declared (pass
+// by value only).
+void f1(const MinLarge) {}
+void f1(const NotTriviallyCopyable) {}
+
+// No warnings when passing by value + mutable parameter
+void f3(__int128) {}
+void f3(MaxSmall) {}
+void f3(MinLarge) {}
+void f3(NotTriviallyCopyable) {}
+void f3(array) {}
+
+struct S3 {
+  void f(__int128) {}
+  void f(MaxSmall) {}
+  void f(MinLarge) {}
+  void f(NotTriviallyCopyable) {}
+  void f(array) {}
+};
+
+// No warnings when passing by value + "small" parameter
+void f4(const __int128) {}
+void f4(const MaxSmall) {}
+
+struct S4 {
+  void f(const __int128) {}
+  void f(const MaxSmall) {}
+};
+
+// No warnings when passing by reference-to-const + "large"/non-trivial parameter
+void f5(const MinLarge &) {}
+void f5(const NotTriviallyCopyable &) {}
+void f5(const array &) {}
+
+struct S5 

[PATCH] D107873: [WIP][clang-tidy] adds a const-qualified parameter check

2021-08-14 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb marked an inline comment as done.
cjdb added a comment.

@jmarrec I believe you wanted to import a discussion from D107900 
?




Comment at: 
clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.cpp:57
+namespace {
+bool isSharedPtr(const QualType &T) {
+  if (auto R = T->getAsCXXRecordDecl())

Eugene.Zelenko wrote:
> Please use `static`, not anonymous namespace for functions.
Hmm... there are lots of instances of `namespace {` in clang-tidy.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance-const-parameter-value-or-ref.rst:104
+various `boards `_. The benchmark can be found on
+`Compiler Explorer `_, with the used to inform
+the threshold.

jmarrec wrote:
> typo here, not sure what the intent was.
I think this is something I put at the end first, and then moved to the start 
of the sentence, but forgot to delete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107873

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


[PATCH] D107873: [clang-tidy] adds a const-qualified parameter check

2021-08-14 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 366457.
cjdb retitled this revision from "[WIP][clang-tidy] adds a const-qualified 
parameter check" to "[clang-tidy] adds a const-qualified parameter check".
cjdb added a comment.

removes WIP tag from patch name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107873

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.cpp
  clang-tools-extra/clang-tidy/performance/ConstParameterValueOrRef.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  
clang-tools-extra/docs/clang-tidy/checks/performance-const-parameter-value-or-ref.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/custom-max-size.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/performance/BUILD.gn
@@ -12,6 +12,7 @@
 "//llvm/lib/Support",
   ]
   sources = [
+"ConstParameterValueOrRef.cpp",
 "FasterStringFindCheck.cpp",
 "ForRangeCopyCheck.cpp",
 "ImplicitConversionInLoopCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/forward-declarations-suppress-warnings-false.cpp
@@ -0,0 +1,17 @@
+// RUN: %check_clang_tidy %s performance-const-parameter-value-or-ref %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN: {key: performance-const-parameter-value-or-ref.ForwardDeclarationsSuppressWarnings,\
+// RUN:  value: false}\
+// RUN:   ]}"
+
+class NotTriviallyCopyable {
+public:
+  NotTriviallyCopyable() = default;
+
+  NotTriviallyCopyable(const NotTriviallyCopyable &);
+};
+
+void f1(NotTriviallyCopyable);
+void f1(const NotTriviallyCopyable) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'const NotTriviallyCopyable' is not trivially copyable: pass by reference-to-const instead
+// CHECK-FIXES: void f1(const NotTriviallyCopyable&) {}
Index: clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-const-parameter-value-or-ref/defaults.cpp
@@ -0,0 +1,260 @@
+// RUN: %check_clang_tidy %s performance-const-parameter-value-or-ref %t
+
+template 
+struct array {
+  T base[N];
+};
+
+using MaxSmall = array;
+using MinLarge = array;
+
+class NotTriviallyCopyable {
+public:
+  NotTriviallyCopyable() = default;
+
+  NotTriviallyCopyable(const NotTriviallyCopyable &) {}
+};
+
+// No warnings for forward declarations: this is the domain of
+// readability-avoid-const-params-in-decls
+void f1(const __int128);
+void f1(const MaxSmall);
+void f1(const MinLarge);
+void f1(const NotTriviallyCopyable);
+
+struct S1 {
+  void f(const __int128);
+  void f(const MaxSmall);
+  void f(const MinLarge);
+  void f(const NotTriviallyCopyable);
+};
+
+void f2(const __int128 &);
+void f2(const MaxSmall &);
+void f2(const MinLarge &);
+void f2(const NotTriviallyCopyable &);
+void f2(const array &);
+
+struct S2 {
+  void f(const __int128 &);
+  void f(const MaxSmall &);
+  void f(const MinLarge &);
+  void f(const NotTriviallyCopyable &);
+  void f(const array &);
+};
+
+// No warnings for function definitions that have been forward declared (pass
+// by value only).
+void f1(const MinLarge) {}
+void f1(const NotTriviallyCopyable) {}
+
+// No warnings when passing by value + mutable parameter
+void f3(__int128) {}
+void f3(MaxSmall) {}
+void f3(MinLarge) {}
+void f3(NotTriviallyCopyable) {}
+void f3(array) {}
+
+struct S3 {
+  void f(__int128) {}
+  void f(MaxSmall) {}
+  void f(MinLarge) {}
+  void f(NotTriviallyCopyable) {}
+  void f(array) {}
+};
+
+// No warnings when passing by value + "small" parameter
+void f4(const __int128) {}
+void f4(const MaxSmall) {}
+
+struct S4 {
+  void f(const __int128) {}
+  void f(const MaxSmall) {}
+};
+
+// No warnings when passing by reference-to-const + "large"/non-trivial parameter
+void f5(const MinLarge &) {}
+void f5(const NotTriviallyCopyable &) {}
+void f5

[clang] 73c4c32 - [X86] Use __builtin_bit_cast _mm_extract_ps instead of type punning through a union. NFC

2021-08-14 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-08-14T16:35:55-07:00
New Revision: 73c4c3276720b20525ce9ef5f8e4f0c20fd93862

URL: 
https://github.com/llvm/llvm-project/commit/73c4c3276720b20525ce9ef5f8e4f0c20fd93862
DIFF: 
https://github.com/llvm/llvm-project/commit/73c4c3276720b20525ce9ef5f8e4f0c20fd93862.diff

LOG: [X86] Use __builtin_bit_cast _mm_extract_ps instead of type punning 
through a union. NFC

Added: 


Modified: 
clang/lib/Headers/smmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index 3ee58c9d79370..c55e6dc65c49d 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -865,10 +865,8 @@ _mm_max_epu32 (__m128i __V1, __m128i __V2)
 ///10: Bits [95:64] of parameter \a X are returned. \n
 ///11: Bits [127:96] of parameter \a X are returned.
 /// \returns A 32-bit integer containing the extracted 32 bits of float data.
-#define _mm_extract_ps(X, N) (__extension__  \
-  ({ union { int __i; float __f; } __t;  \
- __t.__f = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); \
- __t.__i;}))
+#define _mm_extract_ps(X, N) \
+  __builtin_bit_cast(int, __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), 
(int)(N)))
 
 /* Miscellaneous insert and extract macros.  */
 /* Extract a single-precision float from X at index N into D.  */



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


[clang] d2cb189 - [X86] Use a do {} while (0) in the _MM_EXTRACT_FLOAT implementation.

2021-08-14 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-08-14T16:41:55-07:00
New Revision: d2cb18918498b8a39657af2a495eba3e983c159b

URL: 
https://github.com/llvm/llvm-project/commit/d2cb18918498b8a39657af2a495eba3e983c159b
DIFF: 
https://github.com/llvm/llvm-project/commit/d2cb18918498b8a39657af2a495eba3e983c159b.diff

LOG: [X86] Use a do {} while (0) in the _MM_EXTRACT_FLOAT implementation.

Previously we just used {}, but that doesn't work in situations
like this.

if (1)
  _MM_EXTRACT_FLOAT(d, x, n);
else
  ...

The semicolon would terminate the if.

Added: 


Modified: 
clang/lib/Headers/smmintrin.h

Removed: 




diff  --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h
index c55e6dc65c49..8913a196144b 100644
--- a/clang/lib/Headers/smmintrin.h
+++ b/clang/lib/Headers/smmintrin.h
@@ -871,7 +871,7 @@ _mm_max_epu32 (__m128i __V1, __m128i __V2)
 /* Miscellaneous insert and extract macros.  */
 /* Extract a single-precision float from X at index N into D.  */
 #define _MM_EXTRACT_FLOAT(D, X, N) \
-  { (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); }
+  do { (D) = __builtin_ia32_vec_ext_v4sf((__v4sf)(__m128)(X), (int)(N)); } 
while (0)
 
 /* Or together 2 sets of indexes (X and Y) with the zeroing bits (Z) to create
an index suitable for _mm_insert_ps.  */



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


[PATCH] D105264: [X86] AVX512FP16 instructions enabling 2/6

2021-08-14 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf1de9d6dae17: [X86] AVX512FP16 instructions enabling 2/6 
(authored by pengfei).

Changed prior to commit:
  https://reviews.llvm.org/D105264?vs=366194&id=366468#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105264

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avx512vlfp16intrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vlfp16-builtins.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86InstPrinterCommon.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFoldTables.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/test/CodeGen/X86/avx512fp16-arith-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith-vl-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith.ll
  llvm/test/CodeGen/X86/avx512fp16-fmaxnum.ll
  llvm/test/CodeGen/X86/avx512fp16-fminnum.ll
  llvm/test/CodeGen/X86/avx512fp16-fold-load-binops.ll
  llvm/test/CodeGen/X86/avx512fp16-fold-xmm-zero.ll
  llvm/test/CodeGen/X86/avx512fp16-fp-logic.ll
  llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-machine-combiner.ll
  llvm/test/CodeGen/X86/avx512fp16-mov.ll
  llvm/test/CodeGen/X86/avx512fp16-unsafe-fp-math.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-cmp-fp16.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fp16.ll
  llvm/test/CodeGen/X86/pseudo_cmov_lower-fp16.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16vl.ll
  llvm/test/CodeGen/X86/vec-strict-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-512-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-cmp-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-cmp-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-cmp-512-fp16.ll
  llvm/test/CodeGen/X86/vector-reduce-fmax-nnan.ll
  llvm/test/CodeGen/X86/vector-reduce-fmin-nnan.ll
  llvm/test/MC/Disassembler/X86/avx512fp16.txt
  llvm/test/MC/Disassembler/X86/avx512fp16vl.txt
  llvm/test/MC/X86/avx512fp16.s
  llvm/test/MC/X86/avx512fp16vl.s
  llvm/test/MC/X86/intel-syntax-avx512fp16.s
  llvm/test/MC/X86/intel-syntax-avx512fp16vl.s

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


[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-14 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

I have sent the following patches for the Linux kernel. These were the only 
instances of the warning that I found across the code base in all of the 
configurations that we usually test so thank you for the heads up so I could 
send fixes before this lands.

https://lore.kernel.org/r/20210814234248.1755703-1-nat...@kernel.org/
https://lore.kernel.org/r/20210814235625.1780033-1-nat...@kernel.org/
https://lore.kernel.org/r/20210815004154.1781834-1-nat...@kernel.org/

Is there a reason `-Wbool-operation` is not in `-Wall`? It is with GCC 
(although now, their `-Wbool-operation` is equivalent to just 
`Wbool-operation-negation`. I know that is tangential to this patch but if we 
want to take advantage of this new warning, we will have to explicitly enable 
`-Wbool-operation` in the kernel's Makefile.


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

https://reviews.llvm.org/D108003

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


[PATCH] D105265: [X86] AVX512FP16 instructions enabling 3/6

2021-08-14 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 366470.
pengfei marked an inline comment as done.
pengfei added a comment.

Rebased.
Add extra parentheses for macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105265

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avx512vlfp16intrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vlfp16-builtins.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/RuntimeLibcalls.def
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFoldTables.cpp
  llvm/lib/Target/X86/X86InstrFragmentsSIMD.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/test/CodeGen/X86/avx512fp16-arith-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith-vl-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-arith.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt-ph-w-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt-ph-w-vl-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-cvt.ll
  llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16vl-intrinsics.ll
  llvm/test/CodeGen/X86/cvt16-2.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fp16.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-fptoint-fp16.ll
  llvm/test/CodeGen/X86/fp-strict-scalar-inttofp-fp16.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16vl.ll
  llvm/test/CodeGen/X86/vec-strict-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-512-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-fptoint-512-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-128-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-256-fp16.ll
  llvm/test/CodeGen/X86/vec-strict-inttofp-512-fp16.ll
  llvm/test/MC/Disassembler/X86/avx512fp16.txt
  llvm/test/MC/Disassembler/X86/avx512fp16vl.txt
  llvm/test/MC/X86/avx512fp16.s
  llvm/test/MC/X86/avx512fp16vl.s
  llvm/test/MC/X86/intel-syntax-avx512fp16.s
  llvm/test/MC/X86/intel-syntax-avx512fp16vl.s

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


[clang] 4357852 - [Remarks] Emit optimization remarks for atomics generating CAS loop

2021-08-14 Thread Anshil Gandhi via cfe-commits

Author: Anshil Gandhi
Date: 2021-08-14T23:37:23-06:00
New Revision: 435785214f73ff0c92e97f2ade6356e3ba3bf661

URL: 
https://github.com/llvm/llvm-project/commit/435785214f73ff0c92e97f2ade6356e3ba3bf661
DIFF: 
https://github.com/llvm/llvm-project/commit/435785214f73ff0c92e97f2ade6356e3ba3bf661.diff

LOG: [Remarks] Emit optimization remarks for atomics generating CAS loop

Implements ORE in AtomicExpand pass to report atomics generating
a compare and swap loop.

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

Added: 
clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
llvm/test/CodeGen/AMDGPU/atomics-remarks-gfx90a.ll

Modified: 
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/test/CodeGen/AArch64/O0-pipeline.ll
llvm/test/CodeGen/AArch64/O3-pipeline.ll
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
llvm/test/CodeGen/ARM/O3-pipeline.ll
llvm/test/CodeGen/PowerPC/O3-pipeline.ll
llvm/test/CodeGen/X86/O0-pipeline.ll
llvm/test/CodeGen/X86/opt-pipeline.ll

Removed: 




diff  --git a/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu 
b/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
new file mode 100644
index 0..96892286fd75e
--- /dev/null
+++ b/clang/test/CodeGenCUDA/atomics-remarks-gfx90a.cu
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -target-cpu gfx90a -Rpass=atomic-expand -S -o - 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=GFX90A-CAS
+
+// REQUIRES: amdgpu-registered-target
+
+#include "Inputs/cuda.h"
+#include 
+
+// GFX90A-CAS: A compare and swap loop was generated for an atomic fadd 
operation at system memory scope
+// GFX90A-CAS-LABEL: _Z14atomic_add_casPf
+// GFX90A-CAS:  flat_atomic_cmpswap v0, v[2:3], v[4:5] glc
+// GFX90A-CAS:  s_cbranch_execnz
+__device__ float atomic_add_cas(float *p) {
+  return __atomic_fetch_add(p, 1.0f, memory_order_relaxed);
+}

diff  --git a/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl 
b/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
new file mode 100644
index 0..2d8b68f83b9d6
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/atomics-remarks-gfx90a.cl
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu 
gfx90a \
+// RUN: -Rpass=atomic-expand -S -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=REMARK
+
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -triple=amdgcn-amd-amdhsa -target-cpu 
gfx90a \
+// RUN: -Rpass=atomic-expand -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s --check-prefix=GFX90A-CAS
+
+// REQUIRES: amdgpu-registered-target
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef enum memory_scope {
+  memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM,
+  memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP,
+  memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE,
+  memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES,
+#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
+  memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
+#endif
+} memory_scope;
+
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at workgroup-one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at agent-one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at one-as memory scope [-Rpass=atomic-expand]
+// REMARK: remark: A compare and swap loop was generated for an atomic fadd 
operation at wavefront-one-as memory scope [-Rpass=atomic-expand]
+// GFX90A-CAS-LABEL: @atomic_cas
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("workgroup-one-as") monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("agent-one-as") monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} syncscope("one-as") 
monotonic
+// GFX90A-CAS: atomicrmw fadd float addrspace(1)* {{.*}} 
syncscope("wavefront-one-as") monotonic
+float atomic_cas(__global atomic_float *d, float a) {
+  float ret1 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_work_group);
+  float ret2 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_device);
+  float ret3 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_all_svm_devices);
+  float ret4 = __opencl_atomic_fetch_add(d, a, memory_order_relaxed, 
memory_scope_sub_group);
+}
+
+
+

diff  --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp 
b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index 125a3be585cb5..5b5458e1058e8 100644
--- a/ll

[PATCH] D108083: [DRAFT] add sanitizer support to hexagon

2021-08-14 Thread Brian Cain via Phabricator via cfe-commits
bcain created this revision.
bcain added a reviewer: sidneym.
Herald added subscribers: s.egerton, cryptoad, simoncook, fedor.sergeev, mgorny.
bcain requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This patch will need some iteration and decomposition, just putting some 
initial content out there as a basis for discussion before serious review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108083

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/profile/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_common.h
  compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
  compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
  compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc
  compiler-rt/lib/scudo/standalone/CMakeLists.txt
  compiler-rt/test/asan/CMakeLists.txt

Index: compiler-rt/test/asan/CMakeLists.txt
===
--- compiler-rt/test/asan/CMakeLists.txt
+++ compiler-rt/test/asan/CMakeLists.txt
@@ -16,7 +16,7 @@
 macro(get_bits_for_arch arch bits)
   if (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|arm64|mips64|mips64el|s390x|sparcv9|riscv64")
 set(${bits} 64)
-  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc")
+  elseif (${arch} MATCHES "i386|arm|mips|mipsel|sparc|hexagon")
 set(${bits} 32)
   else()
 message(FATAL_ERROR "Unknown target architecture: ${arch}")
Index: compiler-rt/lib/scudo/standalone/CMakeLists.txt
===
--- compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -14,7 +14,9 @@
 append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format SCUDO_CFLAGS)
 
 # Remove -stdlib= which is unused when passing -nostdinc++.
+if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "")
 string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+endif()
 
 append_list_if(COMPILER_RT_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden SCUDO_CFLAGS)
 
Index: compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc
===
--- /dev/null
+++ compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_hexagon.inc
@@ -0,0 +1,132 @@
+//===-- sanitizer_syscall_linux_hexagon.inc -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implementations of internal_syscall and internal_iserror for Linux/hexagon.
+//
+//===--===//
+
+#define SYSCALL(name) __NR_ ## name
+
+#define __internal_syscall_LL_E(x) \
+((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
+((union { long long ll; long l[2]; }){ .ll = x }).l[1]
+#define __internal_syscall_LL_O(x) 0, __SYSCALL_LL_E((x))
+
+#define __asm_syscall(...) do { \
+__asm__ __volatile__ ( "trap0(#1)" \
+: "=r"(r0) : __VA_ARGS__ : "memory"); \
+return r0; \
+} while (0)
+
+#define __internal_syscall0(n) \
+  (__internal_syscall)(n)
+
+static uptr __internal_syscall(long n)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0");
+  __asm_syscall("r"(r6));
+}
+
+#define __internal_syscall1(n, a1) \
+  (__internal_syscall)(n, (long)(a1))
+
+static uptr __internal_syscall(long n, long a)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  __asm_syscall("r"(r6), "0"(r0));
+}
+
+#define __internal_syscall2(n, a1, a2) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2))
+
+static uptr __internal_syscall(long n, long a, long b)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  __asm_syscall("r"(r6), "0"(r0), "r"(r1));
+}
+
+#define __internal_syscall3(n, a1, a2, a3) \
+  (__internal_syscall)(n, (long)(a1), (long)(a2), (long)(a3))
+
+static uptr __internal_syscall(long n, long a, long b, long c)
+{
+  register long r6 __asm__("r6") = n;
+  register long r0 __asm__("r0") = a;
+  register long r1 __asm__("r1") = b;
+  register long r2 __asm__("r2") = c;
+  __asm