[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks Christian! Sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

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


[clang-tools-extra] 63667c1 - [clangd] Trace per-token time in clangd --check

2021-11-09 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-11-10T08:22:48+01:00
New Revision: 63667c1896e11a4b2c389c681a2413e2d5a6b594

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

LOG: [clangd] Trace per-token time in clangd --check

Added: 


Modified: 
clang-tools-extra/clangd/tool/Check.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/Check.cpp 
b/clang-tools-extra/clangd/tool/Check.cpp
index 6672b7d968de..65638dc88a60 100644
--- a/clang-tools-extra/clangd/tool/Check.cpp
+++ b/clang-tools-extra/clangd/tool/Check.cpp
@@ -37,6 +37,7 @@
 #include "index/FileIndex.h"
 #include "refactor/Tweak.h"
 #include "support/ThreadsafeFS.h"
+#include "support/Trace.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Format/Format.h"
@@ -195,6 +196,7 @@ class Checker {
   void testLocationFeatures(
   llvm::function_ref ShouldCheckLine,
   const bool EnableCodeCompletion) {
+trace::Span Trace("testLocationFeatures");
 log("Testing features at each token (may be slow in large files)");
 auto  = AST->getSourceManager();
 auto SpelledTokens = AST->getTokens().spelledTokens(SM.getMainFileID());
@@ -210,6 +212,10 @@ class Checker {
   if (!ShouldCheckLine(Pos))
 continue;
 
+  trace::Span Trace("Token");
+  SPAN_ATTACH(Trace, "pos", Pos);
+  SPAN_ATTACH(Trace, "text", Tok.text(AST->getSourceManager()));
+
   // FIXME: dumping the tokens may leak sensitive code into bug reports.
   // Add an option to turn this off, once we decide how options work.
   vlog("  {0} {1}", Pos, Tok.text(AST->getSourceManager()));



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


[PATCH] D112996: [CodeCompletion] Generally consider header files without extension

2021-11-09 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7500a4ef7bd: [CodeCompletion] Generally consider header 
files without extension (authored by ckandeler, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112996

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-files.cpp

Index: clang/test/CodeCompletion/included-files.cpp
===
--- clang/test/CodeCompletion/included-files.cpp
+++ clang/test/CodeCompletion/included-files.cpp
@@ -1,35 +1,57 @@
-// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a
-// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a && mkdir %t/QtCore && mkdir %t/Headers %t/Some.framework %t/Some.framework/Headers
+// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h && touch %t/QtCore/foosys %t/QtCore/foo.h
+// RUN: touch %t/Headers/foosys %t/Headers/foo.h %t/Some.framework/Headers/foosys %t/Some.framework/Headers/foo.h
 
 // Quoted string shows header-ish files from CWD, and all from system.
 #include "foo.h"
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:6:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
 // CHECK-1-NOT: foo.cc"
 // CHECK-1: foo.h"
 // CHECK-1: foosys"
 
 // Quoted string with dir shows header-ish files in that subdir.
 #include "a/foosys"
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:12:13 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:13:13 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
 // CHECK-2-NOT: foo.h"
 // CHECK-2: foosys.h"
 // CHECK-2-NOT: foosys"
 
 // Angled shows headers from system dirs.
 #include 
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:19:13 %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:20:13 %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
 // CHECK-3-NOT: foo.cc>
 // CHECK-3-NOT: foo.h>
 // CHECK-3: foosys>
 
 // With -I rather than -isystem, the header extension is required.
 #include 
-// RUN: %clang -fsyntax-only -I %t/a -Xclang -code-completion-at=%t/main.cc:26:13 %t/main.cc | FileCheck -check-prefix=CHECK-4 %s
+// RUN: %clang -fsyntax-only -I %t/a -Xclang -code-completion-at=%t/main.cc:27:13 %t/main.cc | FileCheck -check-prefix=CHECK-4 %s
 // CHECK-4-NOT: foo.cc>
 // CHECK-4-NOT: foo.h>
 // CHECK-4-NOT: foosys>
 
 // Backslash handling.
 #include "a\foosys"
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:33:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-5 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang -code-completion-at=%t/main.cc:34:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-5 %s
 // CHECK-5: foosys.h"
+
+// Qt headers don't necessarily have extensions.
+#include 
+// RUN: %clang -fsyntax-only -I %t/QtCore -Xclang -code-completion-at=%t/main.cc:39:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-6 %s
+// CHECK-6-NOT: foo.cc>
+// CHECK-6: foo.h>
+// CHECK-6: foosys>
+
+// If the include path directly points into a framework's Headers/ directory, we allow extension-less headers.
+#include 
+// RUN: %clang -fsyntax-only -I %t/Some.framework/Headers -Xclang -code-completion-at=%t/main.cc:46:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-7 %s
+// CHECK-7-NOT: foo.cc>
+// CHECK-7: foo.h>
+// CHECK-7: foosys>
+
+// Simply naming a directory "Headers" is not enough to allow extension-less headers.
+#include 
+// RUN: %clang -fsyntax-only -I %t/Headers -Xclang -code-completion-at=%t/main.cc:53:13 %t/main.cc -fms-compatibility | FileCheck -check-prefix=CHECK-8 %s
+// CHECK-8-NOT: foo.cc>
+// CHECK-8: foo.h>
+// CHECK-8-NOT: foosys>
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@
   }
 }
 
+const StringRef  = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders =
+IsSystem || isQt || Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,18 +9643,19 @@
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that 

[clang] f7500a4 - [CodeCompletion] Generally consider header files without extension

2021-11-09 Thread Sam McCall via cfe-commits

Author: Christian Kandeler
Date: 2021-11-10T08:22:48+01:00
New Revision: f7500a4ef7bd7820b42e1b934392bb2566083b27

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

LOG: [CodeCompletion] Generally consider header files without extension

Real-world use case: The Qt framework's headers have the same name
as the respective class defined in them, and Qt's traditional qmake
build tool uses -I (rather than -isystem) to pull them in.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/included-files.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 2186eec955bf..26e982686cfb 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -9613,6 +9613,10 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, 
bool Angled) {
   }
 }
 
+const StringRef  = llvm::sys::path::filename(Dir);
+const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+const bool ExtensionlessHeaders =
+IsSystem || isQt || Dir.endswith(".framework/Headers");
 std::error_code EC;
 unsigned Count = 0;
 for (auto It = FS.dir_begin(Dir, EC);
@@ -9639,18 +9643,19 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef 
Dir, bool Angled) {
 
 AddCompletion(Filename, /*IsDirectory=*/true);
 break;
-  case llvm::sys::fs::file_type::regular_file:
-// Only files that really look like headers. (Except in system dirs).
-if (!IsSystem) {
-  // Header extensions from Types.def, which we can't depend on here.
-  if (!(Filename.endswith_insensitive(".h") ||
-Filename.endswith_insensitive(".hh") ||
-Filename.endswith_insensitive(".hpp") ||
-Filename.endswith_insensitive(".inc")))
-break;
-}
+  case llvm::sys::fs::file_type::regular_file: {
+// Only files that really look like headers. (Except in special dirs).
+// Header extensions from Types.def, which we can't depend on here.
+const bool IsHeader = Filename.endswith_insensitive(".h") ||
+  Filename.endswith_insensitive(".hh") ||
+  Filename.endswith_insensitive(".hpp") ||
+  Filename.endswith_insensitive(".inc") ||
+  (ExtensionlessHeaders && 
!Filename.contains('.'));
+if (!IsHeader)
+  break;
 AddCompletion(Filename, /*IsDirectory=*/false);
 break;
+  }
   default:
 break;
   }

diff  --git a/clang/test/CodeCompletion/included-files.cpp 
b/clang/test/CodeCompletion/included-files.cpp
index ba153e6e2754..ae5c3cff9378 100644
--- a/clang/test/CodeCompletion/included-files.cpp
+++ b/clang/test/CodeCompletion/included-files.cpp
@@ -1,35 +1,57 @@
-// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a
-// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/a && mkdir 
%t/QtCore && mkdir %t/Headers %t/Some.framework %t/Some.framework/Headers
+// RUN: touch %t/foo.h && touch %t/foo.cc && touch %t/a/foosys %t/a/foosys.h 
&& touch %t/QtCore/foosys %t/QtCore/foo.h
+// RUN: touch %t/Headers/foosys %t/Headers/foo.h 
%t/Some.framework/Headers/foosys %t/Some.framework/Headers/foo.h
 
 // Quoted string shows header-ish files from CWD, and all from system.
 #include "foo.h"
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-1 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:6:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-1 %s
 // CHECK-1-NOT: foo.cc"
 // CHECK-1: foo.h"
 // CHECK-1: foosys"
 
 // Quoted string with dir shows header-ish files in that subdir.
 #include "a/foosys"
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:12:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-2 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:13:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-2 %s
 // CHECK-2-NOT: foo.h"
 // CHECK-2: foosys.h"
 // CHECK-2-NOT: foosys"
 
 // Angled shows headers from system dirs.
 #include 
-// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:19:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-3 %s
+// RUN: %clang -fsyntax-only -isystem %t/a -Xclang 
-code-completion-at=%t/main.cc:20:13 %t/main.cc | FileCheck 
-check-prefix=CHECK-3 %s
 // CHECK-3-NOT: foo.cc>
 // CHECK-3-NOT: foo.h>
 // CHECK-3: 

[PATCH] D113523: Add toggling for -fnew-infallible/-fno-new-infallible

2021-11-09 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 386059.
modimo added a comment.

Add driver test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113523

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCXX/new-infallible.cpp
  clang/test/Driver/new-infallible.cpp


Index: clang/test/Driver/new-infallible.cpp
===
--- /dev/null
+++ clang/test/Driver/new-infallible.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang -### -S -fno-new-infallible -fnew-infallible %s 2>&1 | 
FileCheck --check-prefix=NEW-INFALLIBLE %s
+// NEW-INFALLIBLE: "-fnew-infallible"
+
+// RUN: %clang -### -S -fnew-infallible -fno-new-infallible %s 2>&1 | 
FileCheck --check-prefix=NO-NEW-INFALLIBLE %s
+// NO-NEW-INFALLIBLE-NOT: "-fnew-infallible"
\ No newline at end of file
Index: clang/test/CodeGenCXX/new-infallible.cpp
===
--- clang/test/CodeGenCXX/new-infallible.cpp
+++ clang/test/CodeGenCXX/new-infallible.cpp
@@ -1,7 +1,16 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible -o - 
%s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible 
-fnew-infallible -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -o 
- %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible 
-fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
 
 // CHECK: call noalias nonnull i8* @_Znwm(i64 4)
 
 // CHECK: ; Function Attrs: nobuiltin nounwind allocsize(0)
 // CHECK-NEXT: declare nonnull i8* @_Znwm(i64)
+
+// NO-NEW-INFALLIBLE: call noalias nonnull i8* @_Znwm(i64 4)
+
+// NO-NEW-INFALLIBLE: ; Function Attrs: nobuiltin allocsize(0)
+// NO-NEW-INFALLIBLE-NEXT: declare nonnull i8* @_Znwm(i64)
+
 int *new_infallible = new int;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5810,9 +5810,12 @@
   Args.AddLastArg(CmdArgs, 
options::OPT_fvisibility_inlines_hidden_static_local_var,

options::OPT_fno_visibility_inlines_hidden_static_local_var);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
-  Args.AddLastArg(CmdArgs, options::OPT_fnew_infallible);
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fnew_infallible,
+   options::OPT_fno_new_infallible, false))
+CmdArgs.push_back("-fnew-infallible");
+
   if (Args.hasFlag(options::OPT_fno_operator_names,
options::OPT_foperator_names, false))
 CmdArgs.push_back("-fno-operator-names");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2786,10 +2786,11 @@
 def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
   HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
-def fnew_infallible : Flag<["-"], "fnew-infallible">, Group,
-  HelpText<"Treats throwing global C++ operator new as always returning valid 
memory "
-  "(annotates with __attribute__((returns_nonnull)) and throw()). This is 
detectable in source.">,
-  Flags<[CC1Option]>, MarshallingInfoFlag>;
+defm new_infallible : BoolFOption<"new-infallible",
+  LangOpts<"NewInfallible">, DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[CC1Option], " treating throwing global C++ operator new as always 
returning valid memory "
+  "(annotates with __attribute__((returns_nonnull)) and throw()). This is 
detectable in source.">>;
 defm whole_program_vtables : BoolFOption<"whole-program-vtables",
   CodeGenOpts<"WholeProgramVTables">, DefaultFalse,
   PosFlag,
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -1941,9 +1941,9 @@
 
 Specifies the largest alignment guaranteed by '::operator new(size\_t)'
 
-.. option:: -fnew-infallible
+.. option:: -fnew-infallible, -fno-new-infallible
 
-Treats throwing global C++ operator new as always returning valid memory 
(annotates with \_\_attribute\_\_((returns\_nonnull)) and throw()). This is 
detectable in source.
+Enable treating throwing global C++ operator new as always returning valid 
memory (annotates with \_\_attribute\_\_((returns\_nonnull)) and throw()). This 
is detectable in source.
 
 .. option:: -fnext-runtime
 


Index: 

[PATCH] D113450: [clang-tidy] Fix llvm-header-guard so that it works with Windows paths

2021-11-09 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added a comment.

@aaron.ballman -
I've added the unit test for UNC path as you suggested. Since you've already 
given the LGTM, I assume you don't need to see the patch again, so I have gone 
ahead with the commit.
Anyway, I'll be around to address any problems if they crop up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113450

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


[PATCH] D113450: [clang-tidy] Fix llvm-header-guard so that it works with Windows paths

2021-11-09 Thread Salman Javed via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb4f6f1c9369e: [clang-tidy] Fix llvm-header-guard so that it 
works with Windows paths (authored by salman-javed-nz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113450

Files:
  clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
  clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp


Index: clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -9,8 +9,6 @@
 namespace tidy {
 namespace test {
 
-// FIXME: It seems this might be incompatible to dos path. Investigating.
-#if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine ,
Optional ExpectedWarning) {
   std::vector Errors;
@@ -220,8 +218,47 @@
 runHeaderGuardCheck(
 "", "/llvm-project/clang-tools-extra/clangd/foo.h",
 StringRef("header is missing header guard")));
-}
+
+#ifdef WIN32
+  // Check interaction with Windows-style path separators (\).
+  EXPECT_EQ(
+  "#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "\n"
+  "\n"
+  "#endif\n",
+  runHeaderGuardCheck("", "llvm-project\\clang-tools-extra\\clangd\\foo.h",
+  StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"", "C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"",
+"SMBShare\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"", 
"?\\C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
 #endif
+}
 
 } // namespace test
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "HeaderGuardCheck.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tidy {
@@ -21,6 +22,10 @@
  StringRef OldGuard) {
   std::string Guard = tooling::getAbsolutePath(Filename);
 
+  // When running under Windows, need to convert the path separators from
+  // `\` to `/`.
+  Guard = llvm::sys::path::convert_to_slash(Guard);
+
   // Sanitize the path. There are some rules for compatibility with the 
historic
   // style in include/llvm and include/clang which we want to preserve.
 


Index: clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -9,8 +9,6 @@
 namespace tidy {
 namespace test {
 
-// FIXME: It seems this might be incompatible to dos path. Investigating.
-#if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine ,
Optional ExpectedWarning) {
   std::vector Errors;
@@ -220,8 +218,47 @@
 runHeaderGuardCheck(
 "", "/llvm-project/clang-tools-extra/clangd/foo.h",
 StringRef("header is missing header guard")));
-}
+
+#ifdef WIN32
+  // Check interaction with Windows-style path separators (\).
+  EXPECT_EQ(
+  "#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "\n"
+  "\n"
+  "#endif\n",
+  runHeaderGuardCheck("", "llvm-project\\clang-tools-extra\\clangd\\foo.h",
+  StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+ 

[clang-tools-extra] b4f6f1c - [clang-tidy] Fix llvm-header-guard so that it works with Windows paths

2021-11-09 Thread Salman Javed via cfe-commits

Author: Salman Javed
Date: 2021-11-10T18:35:57+13:00
New Revision: b4f6f1c9369ec4bb1c10852283a8c7e8c39e1a8d

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

LOG: [clang-tidy] Fix llvm-header-guard so that it works with Windows paths

Fixes pr40372 (https://bugs.llvm.org/show_bug.cgi?id=40372).

The llvm-header-guard check does not take into account that the path
separator on Windows is `\`, not `/`.

This means that instead of suggesting a header guard in the form of:
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FOO_H

it incorrectly suggests:
C:\LLVM_PROJECT\CLANG_TOOLS_EXTRA\CLANG_TIDY\FOO_H

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
index 8f8bd7a77ceb3..53c1e3c6b833f 100644
--- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "HeaderGuardCheck.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tidy {
@@ -21,6 +22,10 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef 
Filename,
  StringRef OldGuard) {
   std::string Guard = tooling::getAbsolutePath(Filename);
 
+  // When running under Windows, need to convert the path separators from
+  // `\` to `/`.
+  Guard = llvm::sys::path::convert_to_slash(Guard);
+
   // Sanitize the path. There are some rules for compatibility with the 
historic
   // style in include/llvm and include/clang which we want to preserve.
 

diff  --git a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
index b86f8e63fb899..6b312413b870d 100644
--- a/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp
@@ -9,8 +9,6 @@ namespace clang {
 namespace tidy {
 namespace test {
 
-// FIXME: It seems this might be incompatible to dos path. Investigating.
-#if !defined(_WIN32)
 static std::string runHeaderGuardCheck(StringRef Code, const Twine ,
Optional ExpectedWarning) {
   std::vector Errors;
@@ -220,8 +218,47 @@ TEST(LLVMHeaderGuardCheckTest, FixHeaderGuards) {
 runHeaderGuardCheck(
 "", "/llvm-project/clang-tools-extra/clangd/foo.h",
 StringRef("header is missing header guard")));
-}
+
+#ifdef WIN32
+  // Check interaction with Windows-style path separators (\).
+  EXPECT_EQ(
+  "#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+  "\n"
+  "\n"
+  "#endif\n",
+  runHeaderGuardCheck("", "llvm-project\\clang-tools-extra\\clangd\\foo.h",
+  StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"", "C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"",
+"SMBShare\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
+
+  EXPECT_EQ("#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FOO_H\n"
+"\n"
+"\n"
+"#endif\n",
+runHeaderGuardCheck(
+"", 
"?\\C:\\llvm-project\\clang-tools-extra\\clangd\\foo.h",
+StringRef("header is missing header guard")));
 #endif
+}
 
 } // namespace test
 } // namespace tidy



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


[clang] 770ddf5 - Fix unused variable warning in release build

2021-11-09 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2021-11-09T19:48:42-08:00
New Revision: 770ddf599d28e8b0aef38166bed899b0194f4d8b

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

LOG: Fix unused variable warning in release build

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index e8207511813c..6d8d1f470f1d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -397,8 +397,7 @@ class CodeGenFunction : public CodeGenTypeCache {
 if (!PostAllocaInsertPt) {
   assert(AllocaInsertPt &&
  "Expected static alloca insertion point at function prologue");
-  auto *EBB = AllocaInsertPt->getParent();
-  assert(EBB->isEntryBlock() &&
+  assert(AllocaInsertPt->getParent()->isEntryBlock() &&
  "EBB should be entry block of the current code gen function");
   PostAllocaInsertPt = AllocaInsertPt->clone();
   PostAllocaInsertPt->setName("postallocapt");



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


[PATCH] D113472: [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)

2021-11-09 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 386047.
salman-javed-nz added a comment.

Revert to using simple string literals. I was being too clever for my own good 
with the Twine.
I think this should no longer cause ASan issues. WDYT?

This was meant to be a simple patch, so sorry for all the trouble.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113472

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -376,10 +376,10 @@
Context.getCurrentBuildDirectory(), false);
   StringRef Message =
   IsNolintBegin
-  ? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
-"comment"
-  : "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
-"comment";
+  ? ("unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINT"
+ "END' comment")
+  : ("unmatched 'NOLINTEND' comment without a previous 'NOLINT"
+ "BEGIN' comment");
   Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
   return Error;
 }


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -376,10 +376,10 @@
Context.getCurrentBuildDirectory(), false);
   StringRef Message =
   IsNolintBegin
-  ? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
-"comment"
-  : "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
-"comment";
+  ? ("unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINT"
+ "END' comment")
+  : ("unmatched 'NOLINTEND' comment without a previous 'NOLINT"
+ "BEGIN' comment");
   Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
   return Error;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113538: OpenMP: Start calling setTargetAttributes for generated kernels

2021-11-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: jdoerfert, JonChesterfield, ronlieb, gregrodgers.
Herald added subscribers: guansong, yaxunl, jvesely.
arsenm requested review of this revision.
Herald added subscribers: sstefan1, wdng.

This wasn't setting any of the attributes the target would expect to
emit for kernels.


https://reviews.llvm.org/D113538

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp

Index: clang/test/OpenMP/amdgcn-attributes.cpp
===
--- /dev/null
+++ clang/test/OpenMP/amdgcn-attributes.cpp
@@ -0,0 +1,30 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefixes=DEFAULT,ALL %s
+// RUN: %clang_cc1 -target-cpu gfx900 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefixes=CPU,ALL %s
+
+// RUN: %clang_cc1 -menable-no-nans -mno-amdgpu-ieee -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefixes=NOIEEE,ALL %s
+// RUN: %clang_cc1 -munsafe-fp-atomics -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefixes=UNSAFEATOMIC,ALL %s
+
+// expected-no-diagnostics
+
+#define N 100
+
+// Check that the target attributes are set on the generated kernel
+int func() {
+  // ALL-LABEL: amdgpu_kernel void @__omp_offloading{{.*}} #0
+  // DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+  // CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst" }
+  // NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-ieee"="false" "amdgpu-implicitarg-num-bytes"="56" "frame-pointer"="none" "min-legal-vector-width"="0" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+  // UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-unsafe-fp-atomics"="true" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+
+  int arr[N];
+
+#pragma omp target
+  for (int i = 0; i < N; i++) {
+arr[i] = 1;
+  }
+
+  return arr[0];
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9143,6 +9143,10 @@
 public:
   AMDGPUTargetCodeGenInfo(CodeGenTypes )
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+
+  void setFunctionDeclAttributes(const FunctionDecl *FD, llvm::Function *F,
+ CodeGenModule ) const;
+
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;
   unsigned getOpenCLKernelCallingConv() const override;
@@ -9182,36 +9186,13 @@
cast(D)->getType()->isCUDADeviceBuiltinTextureType()));
 }
 
-void AMDGPUTargetCodeGenInfo::setTargetAttributes(
-const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
-  if (requiresAMDGPUProtectedVisibility(D, GV)) {
-GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
-GV->setDSOLocal(true);
-  }
-
-  if (GV->isDeclaration())
-return;
-  const FunctionDecl *FD = dyn_cast_or_null(D);
-  if (!FD)
-return;
-
-  llvm::Function *F = cast(GV);
-
-  const auto *ReqdWGS = M.getLangOpts().OpenCL ?
-FD->getAttr() : nullptr;
-
-
-  const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
-  FD->hasAttr();
-  const bool IsHIPKernel = M.getLangOpts().HIP &&
-   FD->hasAttr();
-  if ((IsOpenCLKernel || IsHIPKernel) &&
-  (M.getTriple().getOS() == llvm::Triple::AMDHSA))
-F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
-
-  if (IsHIPKernel)
-F->addFnAttr("uniform-work-group-size", 

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-09 Thread Mahesha S via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b9a85d10ac7: [CFE][Codegen] Make sure to maintain the 
contiguity of all the static allocas (authored by hsmhsm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
  clang/test/CodeGenCXX/amdgcn-func-arg.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
  clang/test/CodeGenCXX/vla.cpp
  clang/test/CodeGenSYCL/address-space-deduction.cpp
  clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp

Index: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
===
--- clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
+++ clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp
@@ -12,7 +12,9 @@
   int arr[N];
 
   // CHECK:  [[VAR_ADDR:%.+]] = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: [[VAR2_ADDR:%.+]] = alloca i32, align 4, addrspace(5)
   // CHECK-NEXT: [[VAR_ADDR_CAST:%.+]] = addrspacecast [100 x i32]* addrspace(5)* [[VAR_ADDR]] to [100 x i32]**
+  // CHECK-NEXT: [[VAR2_ADDR_CAST:%.+]] = addrspacecast i32 addrspace(5)* [[VAR2_ADDR]] to i32*
   // CHECK:  store [100 x i32]* [[VAR:%.+]], [100 x i32]** [[VAR_ADDR_CAST]], align 8
 
 #pragma omp target
Index: clang/test/CodeGenSYCL/address-space-deduction.cpp
===
--- clang/test/CodeGenSYCL/address-space-deduction.cpp
+++ clang/test/CodeGenSYCL/address-space-deduction.cpp
@@ -1,34 +1,33 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple spir64 -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
 
-
 // CHECK-LABEL: @_Z4testv(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[I_ASCAST:%.*]] = addrspacecast i32* [[I]] to i32 addrspace(4)*
 // CHECK-NEXT:[[PPTR:%.*]] = alloca i32 addrspace(4)*, align 8
-// CHECK-NEXT:[[PPTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[PPTR]] to i32 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[IS_I_PTR:%.*]] = alloca i8, align 1
-// CHECK-NEXT:[[IS_I_PTR_ASCAST:%.*]] = addrspacecast i8* [[IS_I_PTR]] to i8 addrspace(4)*
 // CHECK-NEXT:[[VAR23:%.*]] = alloca i32, align 4
-// CHECK-NEXT:[[VAR23_ASCAST:%.*]] = addrspacecast i32* [[VAR23]] to i32 addrspace(4)*
 // CHECK-NEXT:[[CP:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[CP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CP]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[ARR:%.*]] = alloca [42 x i32], align 4
-// CHECK-NEXT:[[ARR_ASCAST:%.*]] = addrspacecast [42 x i32]* [[ARR]] to [42 x i32] addrspace(4)*
 // CHECK-NEXT:[[CPP:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[CPP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CPP]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[APTR:%.*]] = alloca i32 addrspace(4)*, align 8
-// CHECK-NEXT:[[APTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[APTR]] to i32 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[STR:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[STR]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[PHI_STR:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[PHI_STR_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[PHI_STR]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_NULL:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[SELECT_NULL_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_NULL]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_STR_TRIVIAL1:%.*]] = alloca i8 addrspace(4)*, align 8
-// CHECK-NEXT:[[SELECT_STR_TRIVIAL1_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[SELECT_STR_TRIVIAL1]] to i8 addrspace(4)* addrspace(4)*
 // CHECK-NEXT:[[SELECT_STR_TRIVIAL2:%.*]] = alloca i8 addrspace(4)*, align 8
+// CHECK-NEXT:[[I_ASCAST:%.*]] = addrspacecast i32* [[I]] to i32 addrspace(4)*
+// CHECK-NEXT:[[PPTR_ASCAST:%.*]] = addrspacecast i32 addrspace(4)** [[PPTR]] to i32 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[IS_I_PTR_ASCAST:%.*]] = addrspacecast i8* [[IS_I_PTR]] to i8 addrspace(4)*
+// CHECK-NEXT:[[VAR23_ASCAST:%.*]] = addrspacecast i32* [[VAR23]] to i32 addrspace(4)*
+// CHECK-NEXT:[[CP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:[[ARR_ASCAST:%.*]] = addrspacecast [42 x i32]* [[ARR]] to [42 x i32] addrspace(4)*
+// CHECK-NEXT:[[CPP_ASCAST:%.*]] = addrspacecast i8 addrspace(4)** [[CPP]] to i8 addrspace(4)* addrspace(4)*
+// CHECK-NEXT:

[clang] 3b9a85d - [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-09 Thread via cfe-commits

Author: hsmahesha
Date: 2021-11-10T08:45:21+05:30
New Revision: 3b9a85d10ac7a073c95b35adca379281ac6ecbcb

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

LOG: [CFE][Codegen] Make sure to maintain the contiguity of all the static 
allocas

at the start of the entry block, which in turn would aid better code 
transformation/optimization.

Reviewed By: rnk

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

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenCUDA/builtins-amdgcn.cu
clang/test/CodeGenCXX/amdgcn-automatic-variable.cpp
clang/test/CodeGenCXX/amdgcn-func-arg.cpp
clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
clang/test/CodeGenCXX/vla.cpp
clang/test/CodeGenSYCL/address-space-deduction.cpp
clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0d83d6a0d9665..4332e74dbb244 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -95,7 +95,7 @@ Address CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, 
CharUnits Align,
 // otherwise alloca is inserted at the current insertion point of the
 // builder.
 if (!ArraySize)
-  Builder.SetInsertPoint(AllocaInsertPt);
+  Builder.SetInsertPoint(getPostAllocaInsertPoint());
 V = getTargetHooks().performAddrSpaceCast(
 *this, V, getASTAllocaAddressSpace(), LangAS::Default,
 Ty->getPointerTo(DestAddrSpace), /*non-null*/ true);

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index c3c2899e93ec7..d87cf2d497209 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -424,6 +424,14 @@ void CodeGenFunction::FinishFunction(SourceLocation 
EndLoc) {
   AllocaInsertPt = nullptr;
   Ptr->eraseFromParent();
 
+  // PostAllocaInsertPt, if created, was lazily created when it was required,
+  // remove it now since it was just created for our own convenience.
+  if (PostAllocaInsertPt) {
+llvm::Instruction *PostPtr = PostAllocaInsertPt;
+PostAllocaInsertPt = nullptr;
+PostPtr->eraseFromParent();
+  }
+
   // If someone took the address of a label but never did an indirect goto, we
   // made a zero entry PHI node, which is illegal, zap it now.
   if (IndirectBranch) {

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index dd60e21b0ce18..e8207511813c4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -379,6 +379,35 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// we prefer to insert allocas.
   llvm::AssertingVH AllocaInsertPt;
 
+private:
+  /// PostAllocaInsertPt - This is a place in the prologue where code can be
+  /// inserted that will be dominated by all the static allocas. This helps
+  /// achieve two things:
+  ///   1. Contiguity of all static allocas (within the prologue) is 
maintained.
+  ///   2. All other prologue code (which are dominated by static allocas) do
+  ///  appear in the source order immediately after all static allocas.
+  ///
+  /// PostAllocaInsertPt will be lazily created when it is *really* required.
+  llvm::AssertingVH PostAllocaInsertPt = nullptr;
+
+public:
+  /// Return PostAllocaInsertPt. If it is not yet created, then insert it
+  /// immediately after AllocaInsertPt.
+  llvm::Instruction *getPostAllocaInsertPoint() {
+if (!PostAllocaInsertPt) {
+  assert(AllocaInsertPt &&
+ "Expected static alloca insertion point at function prologue");
+  auto *EBB = AllocaInsertPt->getParent();
+  assert(EBB->isEntryBlock() &&
+ "EBB should be entry block of the current code gen function");
+  PostAllocaInsertPt = AllocaInsertPt->clone();
+  PostAllocaInsertPt->setName("postallocapt");
+  PostAllocaInsertPt->insertAfter(AllocaInsertPt);
+}
+
+return PostAllocaInsertPt;
+  }
+
   /// API for captured statement code generation.
   class CGCapturedStmtInfo {
   public:

diff  --git a/clang/test/CodeGenCUDA/builtins-amdgcn.cu 
b/clang/test/CodeGenCUDA/builtins-amdgcn.cu
index 6ba606b4e82c2..e1054d7d3bfba 100644
--- a/clang/test/CodeGenCUDA/builtins-amdgcn.cu
+++ b/clang/test/CodeGenCUDA/builtins-amdgcn.cu
@@ -12,10 +12,10 @@
 // CHECK-LABEL: @_Z16use_dispatch_ptrPi(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[OUT:%.*]] = alloca i32*, align 8, addrspace(5)
-// CHECK-NEXT:[[OUT_ASCAST:%.*]] = addrspacecast i32* addrspace(5)* 
[[OUT]] to i32**
 // CHECK-NEXT:[[OUT_ADDR:%.*]] = alloca i32*, align 8, addrspace(5)
-// CHECK-NEXT:[[OUT_ADDR_ASCAST:%.*]] = addrspacecast 

[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-09 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm added a comment.

Thanks @rnk and @yaxunl .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D113168: [clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitches.inc

2021-11-09 Thread Igor Kudrin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7352f42cdc3c: [clang-tblgen] Fix non-determinism in 
generating… (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113168

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -2043,7 +2044,7 @@
   OS << "  return None;\n";
   OS << "}\n\n";
 
-  std::map>
+  llvm::MapVector>
   SubMatchRules;
   for (const auto  : Rules) {
 if (!Rule.isSubRule())


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -2043,7 +2044,7 @@
   OS << "  return None;\n";
   OS << "}\n\n";
 
-  std::map>
+  llvm::MapVector>
   SubMatchRules;
   for (const auto  : Rules) {
 if (!Rule.isSubRule())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113477: [clang-tblgen] Fix non-determinism in generating AttributeReference.rst

2021-11-09 Thread Igor Kudrin 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 rG5b7ea8e62921: [clang-tblgen] Fix non-determinism in 
generating AttributeReference.rst (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113477

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4433,7 +4433,13 @@
   // Gather the Documentation lists from each of the attributes, based on the
   // category provided.
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::map> SplitDocs;
+  struct CategoryLess {
+bool operator()(const Record *L, const Record *R) const {
+  return L->getValueAsString("Name") < R->getValueAsString("Name");
+}
+  };
+  std::map, CategoryLess>
+  SplitDocs;
   for (const auto *A : Attrs) {
 const Record  = *A;
 std::vector Docs = Attr.getValueAsListOfDefs("Documentation");


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4433,7 +4433,13 @@
   // Gather the Documentation lists from each of the attributes, based on the
   // category provided.
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::map> SplitDocs;
+  struct CategoryLess {
+bool operator()(const Record *L, const Record *R) const {
+  return L->getValueAsString("Name") < R->getValueAsString("Name");
+}
+  };
+  std::map, CategoryLess>
+  SplitDocs;
   for (const auto *A : Attrs) {
 const Record  = *A;
 std::vector Docs = Attr.getValueAsListOfDefs("Documentation");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7352f42 - [clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitches.inc

2021-11-09 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2021-11-10T10:08:06+07:00
New Revision: 7352f42cdc3c44038408edcdc4eb9890546020eb

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

LOG: [clang-tblgen] Fix non-determinism in generating 
AttrSubMatchRulesParserStringSwitches.inc

llvm::MapVector, compared to std::map, guarantees the same iteration
order in different runs.

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

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 2a55a5eb59581..c692e8b5b6bc8 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
@@ -2043,7 +2044,7 @@ void 
PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream ) {
   OS << "  return None;\n";
   OS << "}\n\n";
 
-  std::map>
+  llvm::MapVector>
   SubMatchRules;
   for (const auto  : Rules) {
 if (!Rule.isSubRule())



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


[clang] 5b7ea8e - [clang-tblgen] Fix non-determinism in generating AttributeReference.rst

2021-11-09 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2021-11-10T10:08:07+07:00
New Revision: 5b7ea8e62921e53fdea73d948eb0d48c071d4b73

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

LOG: [clang-tblgen] Fix non-determinism in generating AttributeReference.rst

As for now, the categories are printed in an arbitrary order which
depends on the addresses of dynamically allocated objects. The patch
sorts them in an alphabetical order thus making the output stable.

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

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index c692e8b5b6bc..fe05a3466af1 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4433,7 +4433,13 @@ void EmitClangAttrDocs(RecordKeeper , 
raw_ostream ) {
   // Gather the Documentation lists from each of the attributes, based on the
   // category provided.
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::map> SplitDocs;
+  struct CategoryLess {
+bool operator()(const Record *L, const Record *R) const {
+  return L->getValueAsString("Name") < R->getValueAsString("Name");
+}
+  };
+  std::map, CategoryLess>
+  SplitDocs;
   for (const auto *A : Attrs) {
 const Record  = *A;
 std::vector Docs = Attr.getValueAsListOfDefs("Documentation");



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


[PATCH] D113425: gcc extension # NNN directive lines

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:4058
+
+* ``1`:` Push the current source file name onto the include stack and
+  enter a new file.

urnathan wrote:
> aaronpuchert wrote:
> > Produces
> > 
> > ```
> > /home/buildbot/llvm-build-dir/clang-sphinx-docs/llvm/build/tools/clang/docs/LanguageExtensions.rst:4059:Inline
> >  literal start-string without end-string.
> > ```
> > 
> > I guess the problem is that the characters are swapped.
> I've pushed the obvious fix, but how did I not see this in my local build?  I 
> thought I was building docs -- is there some target I need to name?
I think docs aren't built by default, you might need 
`-DLLVM_ENABLE_SPHINX:BOOL=ON -DLLVM_BUILD_DOCS:BOOL=ON` on the CMake command 
line. Then the target should be `docs-clang-html`.

Of course you'll need to have Sphinx installed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113425

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


[PATCH] D113391: [Modules] Don't support clang module and c++20 module at the same time

2021-11-09 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu abandoned this revision.
ChuanqiXu added a comment.

Oh, OK. If this is not the direction the community want, we might not go on 
this direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113391

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


[PATCH] D107994: Making the code compliant to the documentation about Floating Point support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT (FMA is enabled).

2021-11-09 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/test/CodeGen/ffp-model.c:4
+// RUN: | FileCheck %s \
+// RUN: --check-prefixes=CHECK,CHECK-FAST --strict-whitespace
+

Why did you add the strict-whitespace option?



Comment at: clang/test/CodeGen/ffp-model.c:10
+
+// RUN: %clang -S -emit-llvm -ffp-model=strict %s -o - \
+// RUN: | FileCheck %s \

This is still going to have problems with targets that don't support strictfp 
unless you add an explicit target to the run line.


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

https://reviews.llvm.org/D107994

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


[PATCH] D113529: [asan] Minimal fix for PR52382

2021-11-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a subscriber: ormris.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Alternative to a55c4ec1cee7683d9095327d9d33e7137ec25292 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113529

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1156,11 +1156,11 @@
 llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
 CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
+MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
+CompileKernel, Recover, UseAfterScope, UseAfterReturn)));
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
 DestructorKind));
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-CompileKernel, Recover, UseAfterScope, UseAfterReturn)));
   }
 };
 ASanPass(SanitizerKind::Address, false);


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1156,11 +1156,11 @@
 llvm::AsanDetectStackUseAfterReturnMode UseAfterReturn =
 CodeGenOpts.getSanitizeAddressUseAfterReturn();
 MPM.addPass(RequireAnalysisPass());
+MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
+CompileKernel, Recover, UseAfterScope, UseAfterReturn)));
 MPM.addPass(ModuleAddressSanitizerPass(
 CompileKernel, Recover, ModuleUseAfterScope, UseOdrIndicator,
 DestructorKind));
-MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
-CompileKernel, Recover, UseAfterScope, UseAfterReturn)));
   }
 };
 ASanPass(SanitizerKind::Address, false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113369: [clang-format] Extend SpaceBeforeParens for requires

2021-11-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3145-3148
+  else {
+assert(Left.is(TT_RequiresExpression));
+return Style.SpaceBeforeParensOptions.AfterRequiresExpression;
+  }

Nit: remove `else`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113369

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


[PATCH] D113523: Add toggling for -fnew-infallible/-fno-new-infallible

2021-11-09 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi @modimo, can you also add a driver test to check (`clang/test/Driver/...`) 
that nothing is added to cc1 cmdline when `-fno-new-infallible` is used or take 
precendence?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113523

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


[PATCH] D107994: Making the code compliant to the documentation about Floating Point support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT (FMA is enabled).

2021-11-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 386014.

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

https://reviews.llvm.org/D107994

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/ffp-contract-option.c
  clang/test/CodeGen/ffp-model.c
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c
  clang/test/Driver/fp-model.c
  clang/test/Misc/ffp-contract.c

Index: clang/test/Misc/ffp-contract.c
===
--- /dev/null
+++ clang/test/Misc/ffp-contract.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=aarch64-apple-darwin \
+// RUN: -S -o - %s | FileCheck --check-prefix=CHECK-FMADD %s
+// REQUIRES: aarch64-registered-target
+
+float fma_test1(float a, float b, float c) {
+  // CHECK-FMADD: fmadd
+  float x = a * b;
+  float y = x + c;
+  return y;
+}
Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -99,7 +99,7 @@
 // RUN: %clang -### -nostdinc -ffp-model=precise -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-FPM-PRECISE %s
 // CHECK-FPM-PRECISE: "-cc1"
-// CHECK-FPM-PRECISE: "-ffp-contract=fast"
+// CHECK-FPM-PRECISE: "-ffp-contract=on"
 // CHECK-FPM-PRECISE: "-fno-rounding-math"
 
 // RUN: %clang -### -nostdinc -ffp-model=strict -c %s 2>&1 \
Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -2,11 +2,11 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 // RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
Index: clang/test/CodeGen/ppc-emmintrin.c
===
--- clang/test/CodeGen/ppc-emmintrin.c
+++ clang/test/CodeGen/ppc-emmintrin.c
@@ -2,9 +2,9 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:  -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:  -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN:   -ffp-contract=off -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 
 // CHECK-BE-DAG: @_mm_movemask_pd.perm_mask = internal constant <4 x i32> , align 16
 // CHECK-BE-DAG: @_mm_shuffle_epi32.permute_selectors = internal constant [4 x i32] [i32 66051, i32 67438087, i32 134810123, i32 202182159], align 4
Index: clang/test/CodeGen/ffp-model.c
===
--- /dev/null
+++ clang/test/CodeGen/ffp-model.c
@@ -0,0 +1,52 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -S -emit-llvm -ffp-model=fast -emit-llvm %s -o - \
+// RUN: | FileCheck %s \
+// RUN: --check-prefixes=CHECK,CHECK-FAST --strict-whitespace
+
+// RUN: %clang -S -emit-llvm -ffp-model=precise %s -o - \
+// RUN: | FileCheck %s \
+// RUN: --check-prefixes=CHECK,CHECK-PRECISE --strict-whitespace
+
+// RUN: %clang -S -emit-llvm -ffp-model=strict %s -o - \
+// RUN: | FileCheck %s \
+// RUN: --check-prefixes=CHECK,CHECK-STRICT --strict-whitespace
+
+// RUN: %clang -S -emit-llvm -ffp-model=strict -ffast-math \
+// RUN: %s -o - | FileCheck %s \

[PATCH] D113517: Correct handling of the 'throw()' exception specifier in C++17.

2021-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

What's the motivation for this change? I believe the current behavior is still 
conforming: `set_unexpected` is no longer (officially) part of the standard 
library (though it still exists as a zombie name), and the default `unexpected` 
handler calls `terminate`, so calling `unexpected` rather than `terminate` 
should have the same effect, except in non-conforming programs that call 
`std::set_unexpected` anyway. Do we generate better code if we call `terminate` 
rather than `unexpected`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113517

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


[PATCH] D113425: gcc extension # NNN directive lines

2021-11-09 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan marked an inline comment as done.
urnathan added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:4058
+
+* ``1`:` Push the current source file name onto the include stack and
+  enter a new file.

aaronpuchert wrote:
> Produces
> 
> ```
> /home/buildbot/llvm-build-dir/clang-sphinx-docs/llvm/build/tools/clang/docs/LanguageExtensions.rst:4059:Inline
>  literal start-string without end-string.
> ```
> 
> I guess the problem is that the characters are swapped.
I've pushed the obvious fix, but how did I not see this in my local build?  I 
thought I was building docs -- is there some target I need to name?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113425

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


[PATCH] D113523: Add toggling for -fnew-infallible/-fno-new-infallible

2021-11-09 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 385996.
modimo added a comment.

Remove whitespace change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113523

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCXX/new-infallible.cpp


Index: clang/test/CodeGenCXX/new-infallible.cpp
===
--- clang/test/CodeGenCXX/new-infallible.cpp
+++ clang/test/CodeGenCXX/new-infallible.cpp
@@ -1,7 +1,16 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible -o - 
%s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible 
-fnew-infallible -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -o 
- %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible 
-fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
 
 // CHECK: call noalias nonnull i8* @_Znwm(i64 4)
 
 // CHECK: ; Function Attrs: nobuiltin nounwind allocsize(0)
 // CHECK-NEXT: declare nonnull i8* @_Znwm(i64)
+
+// NO-NEW-INFALLIBLE: call noalias nonnull i8* @_Znwm(i64 4)
+
+// NO-NEW-INFALLIBLE: ; Function Attrs: nobuiltin allocsize(0)
+// NO-NEW-INFALLIBLE-NEXT: declare nonnull i8* @_Znwm(i64)
+
 int *new_infallible = new int;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5810,9 +5810,12 @@
   Args.AddLastArg(CmdArgs, 
options::OPT_fvisibility_inlines_hidden_static_local_var,

options::OPT_fno_visibility_inlines_hidden_static_local_var);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
-  Args.AddLastArg(CmdArgs, options::OPT_fnew_infallible);
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fnew_infallible,
+   options::OPT_fno_new_infallible, false))
+CmdArgs.push_back("-fnew-infallible");
+
   if (Args.hasFlag(options::OPT_fno_operator_names,
options::OPT_foperator_names, false))
 CmdArgs.push_back("-fno-operator-names");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2786,10 +2786,11 @@
 def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
   HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
-def fnew_infallible : Flag<["-"], "fnew-infallible">, Group,
-  HelpText<"Treats throwing global C++ operator new as always returning valid 
memory "
-  "(annotates with __attribute__((returns_nonnull)) and throw()). This is 
detectable in source.">,
-  Flags<[CC1Option]>, MarshallingInfoFlag>;
+defm new_infallible : BoolFOption<"new-infallible",
+  LangOpts<"NewInfallible">, DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[CC1Option], " treating throwing global C++ operator new as always 
returning valid memory "
+  "(annotates with __attribute__((returns_nonnull)) and throw()). This is 
detectable in source.">>;
 defm whole_program_vtables : BoolFOption<"whole-program-vtables",
   CodeGenOpts<"WholeProgramVTables">, DefaultFalse,
   PosFlag,
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -1941,9 +1941,9 @@
 
 Specifies the largest alignment guaranteed by '::operator new(size\_t)'
 
-.. option:: -fnew-infallible
+.. option:: -fnew-infallible, -fno-new-infallible
 
-Treats throwing global C++ operator new as always returning valid memory 
(annotates with \_\_attribute\_\_((returns\_nonnull)) and throw()). This is 
detectable in source.
+Enable treating throwing global C++ operator new as always returning valid 
memory (annotates with \_\_attribute\_\_((returns\_nonnull)) and throw()). This 
is detectable in source.
 
 .. option:: -fnext-runtime
 


Index: clang/test/CodeGenCXX/new-infallible.cpp
===
--- clang/test/CodeGenCXX/new-infallible.cpp
+++ clang/test/CodeGenCXX/new-infallible.cpp
@@ -1,7 +1,16 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -fnew-infallible -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
+// RUN: 

[clang] da979f6 - [clang] Fix restructured markup

2021-11-09 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-11-09T18:41:22-05:00
New Revision: da979f6cf82111d58285a96bce1febd486d65b34

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

LOG: [clang] Fix restructured markup

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 1acf8961e588..087228be14f9 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -4056,7 +4056,7 @@ The filename is optional, and if unspecified indicates no 
change in
 source filename. The header-type is an optional, whitespace-delimited,
 sequence of magic numbers as follows.
 
-* ``1`:` Push the current source file name onto the include stack and
+* ``1:`` Push the current source file name onto the include stack and
   enter a new file.
 
 * ``2``: Pop the include stack and return to the specified file. If



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


[PATCH] D113523: Add toggling for -fnew-infallible/-fno-new-infallible

2021-11-09 Thread Di Mo via Phabricator via cfe-commits
modimo created this revision.
Herald added subscribers: hoy, wenlei, lxfind, dang.
modimo requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113523

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCXX/new-infallible.cpp


Index: clang/test/CodeGenCXX/new-infallible.cpp
===
--- clang/test/CodeGenCXX/new-infallible.cpp
+++ clang/test/CodeGenCXX/new-infallible.cpp
@@ -1,7 +1,16 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible -o - 
%s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible 
-fnew-infallible -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fno-new-infallible -o 
- %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu -fnew-infallible 
-fno-new-infallible -o - %s | FileCheck %s --check-prefix=NO-NEW-INFALLIBLE
 
 // CHECK: call noalias nonnull i8* @_Znwm(i64 4)
 
 // CHECK: ; Function Attrs: nobuiltin nounwind allocsize(0)
 // CHECK-NEXT: declare nonnull i8* @_Znwm(i64)
+
+// NO-NEW-INFALLIBLE: call noalias nonnull i8* @_Znwm(i64 4)
+
+// NO-NEW-INFALLIBLE: ; Function Attrs: nobuiltin allocsize(0)
+// NO-NEW-INFALLIBLE-NEXT: declare nonnull i8* @_Znwm(i64)
+
 int *new_infallible = new int;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5810,9 +5810,12 @@
   Args.AddLastArg(CmdArgs, 
options::OPT_fvisibility_inlines_hidden_static_local_var,

options::OPT_fno_visibility_inlines_hidden_static_local_var);
   Args.AddLastArg(CmdArgs, options::OPT_fvisibility_global_new_delete_hidden);
-  Args.AddLastArg(CmdArgs, options::OPT_fnew_infallible);
   Args.AddLastArg(CmdArgs, options::OPT_ftlsmodel_EQ);
 
+  if (Args.hasFlag(options::OPT_fnew_infallible,
+   options::OPT_fno_new_infallible, false))
+CmdArgs.push_back("-fnew-infallible");
+
   if (Args.hasFlag(options::OPT_fno_operator_names,
options::OPT_foperator_names, false))
 CmdArgs.push_back("-fno-operator-names");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2433,13 +2433,13 @@
   HelpText<"Enable debugging in the OpenMP offloading device RTL">;
 def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, 
Group, Flags<[NoArgumentUnused]>;
 def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">, 
+def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">, 
+def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">, 
+def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
+def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
   LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
@@ -2786,10 +2786,11 @@
 def fvisibility_global_new_delete_hidden : Flag<["-"], 
"fvisibility-global-new-delete-hidden">, Group,
   HelpText<"Give global C++ operator new and delete declarations hidden 
visibility">, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
-def fnew_infallible : Flag<["-"], "fnew-infallible">, Group,
-  HelpText<"Treats throwing global C++ operator new as always returning valid 
memory "
-  "(annotates with __attribute__((returns_nonnull)) and throw()). This is 
detectable in source.">,
-  Flags<[CC1Option]>, MarshallingInfoFlag>;
+defm new_infallible : BoolFOption<"new-infallible",
+  LangOpts<"NewInfallible">, DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[CC1Option], " treating throwing global C++ operator new as 

[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D112492#3119892 , @tra wrote:

> Yes, we do need to merge identical functions with **identical names** for 
> templates.
>
> The comdat-folding issue is different. IIUIC, it allows merging two functions 
> with identical code and **different names**, into one function with two 
> names. That will break CUDA as we do need to have each stub to have a unique 
> address as we use it to find the matching GPU-side kernel.

Well, yes, ICF breaks function pointer identity. There's no way around that, 
and it is documented:
https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=msvc-170
CUDA users will have to remove /OPT:ICF from their linker flags.

Maybe you could make this work by embedding an ICF-breaking device into all the 
stubs. Something like a volatile asm blob that takes the current function as an 
argument and puts it in a register.


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

https://reviews.llvm.org/D112492

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


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-09 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.

LGTM as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113304

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


[PATCH] D112890: headers: optionalise some generated resource headers

2021-11-09 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

And I don't see any AArch64 or ARM maintainers ACKing this. You haven't even 
tagged any as reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112890

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


[PATCH] D112663: [clang-repl] Allow Interpreter::getSymbolAddress to take a mangled name.

2021-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Interpreter/Interpreter.h:72
+
+  ///\returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses
+  /// the CodeGenModule's internal mangling cache to avoid recomputing the

Add a space before `\returns` please (here and below).



Comment at: clang/unittests/Interpreter/IncrementalProcessingTest.cpp:20
 #include "clang/Sema/Sema.h"
+#include "clang/Sema/TemplateDeduction.h"
 #include "llvm/ADT/Triple.h"

Given that this file is unchanged, do we need the new includes?



Comment at: clang/unittests/Interpreter/InterpreterTest.cpp:166
+  auto Addr = cantFail(Interp->getSymbolAddress(MangledName));
+  EXPECT_TRUE(Addr != 0);
+  GlobalDecl GD(FD);

Use `EXPECT_EQ` and `EXPECT_NE` as appropriate.



Comment at: clang/unittests/Interpreter/InterpreterTest.cpp:214
+  auto PTUDeclRange = PTU.TUPart->decls();
+  EXPECT_TRUE(std::distance(PTUDeclRange.begin(), PTUDeclRange.end()));
+

`EXPECT_TRUE` on an integer seems surprising.


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

https://reviews.llvm.org/D112663

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


[PATCH] D112890: headers: optionalise some generated resource headers

2021-11-09 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

This change seems pretty counter to Clang's ability to spit out IR for anything 
regardless of what backends you have. The right fix should be to shrink the 
headers, not mask the problem by changing the principles of how Clang works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112890

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


[PATCH] D112890: headers: optionalise some generated resource headers

2021-11-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

But thanks for the work: people not enabling RISCV should not incur so much 
overhead. I hope that RISC-V vector contributors can really bear the cost in 
mind.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112890

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


[PATCH] D113451: [PowerPC] [Clang] Enable Intel intrinsics support on FreeBSD

2021-11-09 Thread Alfredo Dal'Ava JĂşnior via Phabricator via cfe-commits
adalava updated this revision to Diff 385985.
adalava added a comment.

fix style


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113451

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/PPCFreeBSD.cpp
  clang/lib/Driver/ToolChains/PPCFreeBSD.h
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/mm_malloc.h
  clang/lib/Headers/ppc_wrappers/mmintrin.h
  clang/lib/Headers/ppc_wrappers/pmmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/lib/Headers/ppc_wrappers/tmmintrin.h
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/ppc-mm-malloc-le.c
  clang/test/CodeGen/ppc-mm-malloc.c
  clang/test/CodeGen/ppc-mmintrin.c
  clang/test/CodeGen/ppc-pmmintrin.c
  clang/test/CodeGen/ppc-smmintrin.c
  clang/test/CodeGen/ppc-tmmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c

Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -10,6 +10,15 @@
 // RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang -x c++ -fsyntax-only -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns
+
 #include 
 
 __m128 res, m1, m2;
Index: clang/test/CodeGen/ppc-tmmintrin.c
===
--- clang/test/CodeGen/ppc-tmmintrin.c
+++ clang/test/CodeGen/ppc-tmmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+
 #include 
 
 __m64 res, m1, m2;
Index: clang/test/CodeGen/ppc-smmintrin.c
===
--- clang/test/CodeGen/ppc-smmintrin.c
+++ clang/test/CodeGen/ppc-smmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
 
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+
 #include 
 
 __m128i mi, m1, m2;
Index: clang/test/CodeGen/ppc-pmmintrin.c
===
--- clang/test/CodeGen/ppc-pmmintrin.c
+++ clang/test/CodeGen/ppc-pmmintrin.c
@@ -6,6 +6,11 @@
 // RUN: %clang -S -emit-llvm -target powerpc64le-gnu-linux -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
 // RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
 
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr8 -DNO_MM_MALLOC -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 

[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Yes, we do need to merge identical functions with **identical names** for 
templates.

The comdat-folding issue is different. IIUIC, it allows merging two functions 
with identical code and **different names**, into one function with two names. 
That will break CUDA as we do need to have each stub to have a unique address 
as we use it to find the matching GPU-side kernel.


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

https://reviews.llvm.org/D112492

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


[PATCH] D112890: headers: optionalise some generated resource headers

2021-11-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I remember that `NOTE: Assertions have been autogenerated by 
utils/update_cc_test_checks.py` needs to be the first line...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112890

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


[PATCH] D113304: [NewPM] Only invalidate modified functions' analyses in CGSCC passes + turn on eagerly invalidate analyses

2021-11-09 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait to see if @nikic has additional comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113304

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


[PATCH] D111463: [OpenMP] Remove doing assumption propagation in the front end.

2021-11-09 Thread Joseph Huber 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 rG4b5c3e591d74: [OpenMP] Remove doing assumption propagation 
in the front end. (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D111463?vs=378347=385978#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111463

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp

Index: clang/test/OpenMP/assumes_include_nvptx.cpp
===
--- clang/test/OpenMP/assumes_include_nvptx.cpp
+++ clang/test/OpenMP/assumes_include_nvptx.cpp
@@ -24,7 +24,7 @@
 // CHECK:   attributes [[attr1]]
 // CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 // CHECK:   attributes [[attr2]]
-// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations,ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
+// CHECK-SAME:  "llvm.assume"="ompx_check_that_this_is_attached_to_included_functions_and_template_instantiations"
 
 
 template 
Index: clang/test/OpenMP/assumes_codegen.cpp
===
--- clang/test/OpenMP/assumes_codegen.cpp
+++ clang/test/OpenMP/assumes_codegen.cpp
@@ -67,20 +67,6 @@
 }
 #pragma omp end assumes
 
-void no_assume() {
-  foo();
-}
-
-#pragma omp begin assumes ext_call_site
-void assume() {
-  foo();
-}
-
-void assembly() {
-  asm ("nop");
-}
-#pragma omp end assumes ext_call_site
-
 // AST:  void foo() __attribute__((assume("omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses"))) __attribute__((assume("omp_no_openmp"))) {
 // AST-NEXT: }
 // AST-NEXT: class BAR {
@@ -129,41 +115,29 @@
 // CHECK: define{{.*}} void @_Z3barv()
 // CHECK-SAME: [[attr1:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC1Ev(%class.BAR*{{.*}} %b)
-// CHECK-SAME: [[attr10:#[0-9]]]
+// CHECK-SAME: [[attr9:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BARC1Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr2:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BARC2Ev(%class.BAR*{{.*}} %this1)
-// CHECK-SAME: [[attr10]]
+// CHECK-SAME: [[attr9]]
 // CHECK: define{{.*}} void @_ZN3BARC2Ev(%class.BAR*{{.*}} %this)
 // CHECK-SAME: [[attr3:#[0-9]]]
 // CHECK: define{{.*}} void @_Z3bazv()
 // CHECK-SAME: [[attr4:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %b)
-// CHECK-SAME: [[attr11:#[0-9]]]
+// CHECK-SAME: [[attr10:#[0-9]]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC1Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr5:#[0-9]]]
 // CHECK:   call{{.*}} @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this1)
-// CHECK-SAME: [[attr12:#[0-9]]]
+// CHECK-SAME: [[attr10]]
 // CHECK: define{{.*}} void @_ZN3BAZIfEC2Ev(%class.BAZ*{{.*}} %this)
 // CHECK-SAME: [[attr6:#[0-9]]]
 // CHECK: define{{.*}} i32 @_Z12lambda_outerv()
 // CHECK-SAME: [[attr7:#[0-9]]]
 // CHECK: call{{.*}} @"_ZZ12lambda_outervENK3$_0clEv"
-// CHECK-SAME: [[attr13:#[0-9]]]
+// CHECK-SAME: [[attr11:#[0-9]]]
 // CHECK: define{{.*}} i32 @"_ZZ12lambda_outervENK3$_0clEv"(%class.anon*{{.*}} %this)
 // CHECK-SAME: [[attr8:#[0-9]]]
-// CHECK: define{{.*}} void @_Z9no_assumev()
-// CHECK-SAME: [[attr0:#[0-9]]]
-// CHECK: call{{.*}} @_Z3foov()
-// CHECK-SAME: [[attr14:#[0-9]]]
-// CHECK: define{{.*}} void @_Z6assumev()
-// CHECK-SAME: [[attr9:#[0-9]]]
-// CHECK: call{{.*}} @_Z3foov()
-// CHECK-SAME: [[attr15:#[0-9]]]
-// CHECK: define{{.*}} void @_Z8assemblyv()
-// CHECK-SAME: [[attr9:#[0-9]]]
-// CHECK: call{{.*}} void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
-// CHECK-SAME: [[attr16:#[0-9]]]
 
 // CHECK: attributes [[attr0]]
 // CHECK-SAME:  "llvm.assume"="omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
@@ -184,18 +158,8 @@
 // CHECK: attributes [[attr8]]
 // CHECK-SAME:  "llvm.assume"="ompx_lambda_assumption,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr9]]
-// CHECK-SAME:  "llvm.assume"="ompx_call_site,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
 // CHECK: attributes [[attr10]]
-// CHECK-SAME:  "llvm.assume"="ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp,ompx_range_bar_only,ompx_range_bar_only_2,omp_no_openmp_routines,ompx_another_warning,ompx_after_invalid_clauses,omp_no_openmp"
+// CHECK-SAME:  

[clang] 4b5c3e5 - [OpenMP] Remove doing assumption propagation in the front end.

2021-11-09 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2021-11-09T17:39:24-05:00
New Revision: 4b5c3e591d74f0f5810608b45ede58f3d489e14d

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

LOG: [OpenMP] Remove doing assumption propagation in the front end.

This patch removes the assumption propagation that was added in D110655
primarily to get assumption informatino on opaque call sites for
optimizations. The analysis done in D111445 allows us to do this more
intelligently in the back-end.

Depends on D111445

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/OpenMP/assumes_codegen.cpp
clang/test/OpenMP/assumes_include_nvptx.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index daea09be3e70..d830a7e01709 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1748,8 +1748,7 @@ static void AddAttributesFromFunctionProtoType(ASTContext 
,
 }
 
 static void AddAttributesFromAssumes(llvm::AttrBuilder ,
- const Decl *Callee, const Decl *Caller,
- bool AssumptionOnCallSite) {
+ const Decl *Callee) {
   if (!Callee)
 return;
 
@@ -1758,10 +1757,6 @@ static void AddAttributesFromAssumes(llvm::AttrBuilder 
,
   for (const AssumptionAttr *AA : Callee->specific_attrs())
 AA->getAssumption().split(Attrs, ",");
 
-  if (Caller && Caller->hasAttrs() && AssumptionOnCallSite)
-for (const AssumptionAttr *AA : Caller->specific_attrs())
-  AA->getAssumption().split(Attrs, ",");
-
   if (!Attrs.empty())
 FuncAttrs.addAttribute(llvm::AssumptionAttrKey,
llvm::join(Attrs.begin(), Attrs.end(), ","));
@@ -2019,10 +2014,12 @@ static bool DetermineNoUndef(QualType QTy, CodeGenTypes 
,
 /// attributes that restrict how the frontend generates code must be
 /// added here rather than getDefaultFunctionAttributes.
 ///
-void CodeGenModule::ConstructAttributeList(
-StringRef Name, const CGFunctionInfo , CGCalleeInfo CalleeInfo,
-llvm::AttributeList , unsigned , bool AttrOnCallSite,
-bool IsThunk, const Decl *Caller) {
+void CodeGenModule::ConstructAttributeList(StringRef Name,
+   const CGFunctionInfo ,
+   CGCalleeInfo CalleeInfo,
+   llvm::AttributeList ,
+   unsigned ,
+   bool AttrOnCallSite, bool IsThunk) {
   llvm::AttrBuilder FuncAttrs;
   llvm::AttrBuilder RetAttrs;
 
@@ -2040,12 +2037,9 @@ void CodeGenModule::ConstructAttributeList(
 
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl().getDecl();
 
-  // Only attach assumptions to call sites in OpenMP mode.
-  bool AssumptionOnCallSite = getLangOpts().OpenMP && AttrOnCallSite;
-
   // Attach assumption attributes to the declaration. If this is a call
   // site, attach assumptions from the caller to the call as well.
-  AddAttributesFromAssumes(FuncAttrs, TargetDecl, Caller, 
AssumptionOnCallSite);
+  AddAttributesFromAssumes(FuncAttrs, TargetDecl);
 
   bool HasOptnone = false;
   // The NoBuiltinAttr attached to the target FunctionDecl.
@@ -5180,7 +5174,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.ConstructAttributeList(CalleePtr->getName(), CallInfo,
  Callee.getAbstractInfo(), Attrs, CallingConv,
  /*AttrOnCallSite=*/true,
- /*IsThunk=*/false, CurFuncDecl);
+ /*IsThunk=*/false);
 
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())

diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 6768a72319b0..7492aa441056 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2224,20 +2224,6 @@ static void UpdateAsmCallInst(llvm::CallBase , 
bool HasSideEffect,
   Result.addFnAttr(llvm::Attribute::ReadOnly);
   }
 
-  // Attach OpenMP assumption attributes from the caller, if they exist.
-  if (CGF.CGM.getLangOpts().OpenMP) {
-SmallVector Attrs;
-
-for (const AssumptionAttr *AA :
- CGF.CurFuncDecl->specific_attrs())
-  AA->getAssumption().split(Attrs, ",");
-
-if (!Attrs.empty())
-  Result.addFnAttr(
-  llvm::Attribute::get(CGF.getLLVMContext(), llvm::AssumptionAttrKey,
-   llvm::join(Attrs.begin(), Attrs.end(), ",")));
-  }
-
   // Slap the source 

[PATCH] D113447: [sancov] add tracing for loads and store

2021-11-09 Thread Kostya Serebryany 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 rGb7f3a4f4fa14: [sancov] add tracing for loads and store 
(authored by kcc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113447

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_loads_stores.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/trace-loads-stores.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/trace-loads-stores.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/trace-loads-stores.ll
@@ -0,0 +1,33 @@
+; Test -sanitizer-coverage-inline-8bit-counters=1
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-loads=1  -S | FileCheck %s --check-prefix=LOADS
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-stores=1  -S | FileCheck %s --check-prefix=STORES
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16) {
+; === loads
+  %1 = load i8, i8* %p1
+  %2 = load i16, i16* %p2
+  %3 = load i32, i32* %p4
+  %4 = load i64, i64* %p8
+  %5 = load i128, i128* %p16
+; LOADS: call void @__sanitizer_cov_load1(i8* %p1)
+; LOADS: call void @__sanitizer_cov_load2(i16* %p2)
+; LOADS: call void @__sanitizer_cov_load4(i32* %p4)
+; LOADS: call void @__sanitizer_cov_load8(i64* %p8)
+; LOADS: call void @__sanitizer_cov_load16(i128* %p16)
+
+; === stores
+  store i8   %1, i8*   %p1
+  store i16  %2, i16*  %p2
+  store i32  %3, i32*  %p4
+  store i64  %4, i64*  %p8
+  store i128 %5, i128* %p16
+; STORES: call void @__sanitizer_cov_store1(i8* %p1)
+; STORES: call void @__sanitizer_cov_store2(i16* %p2)
+; STORES: call void @__sanitizer_cov_store4(i32* %p4)
+; STORES: call void @__sanitizer_cov_store8(i64* %p8)
+; STORES: call void @__sanitizer_cov_store16(i128* %p16)
+
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -55,6 +55,16 @@
 const char SanCovTraceConstCmp2[] = "__sanitizer_cov_trace_const_cmp2";
 const char SanCovTraceConstCmp4[] = "__sanitizer_cov_trace_const_cmp4";
 const char SanCovTraceConstCmp8[] = "__sanitizer_cov_trace_const_cmp8";
+const char SanCovLoad1[] = "__sanitizer_cov_load1";
+const char SanCovLoad2[] = "__sanitizer_cov_load2";
+const char SanCovLoad4[] = "__sanitizer_cov_load4";
+const char SanCovLoad8[] = "__sanitizer_cov_load8";
+const char SanCovLoad16[] = "__sanitizer_cov_load16";
+const char SanCovStore1[] = "__sanitizer_cov_store1";
+const char SanCovStore2[] = "__sanitizer_cov_store2";
+const char SanCovStore4[] = "__sanitizer_cov_store4";
+const char SanCovStore8[] = "__sanitizer_cov_store8";
+const char SanCovStore16[] = "__sanitizer_cov_store16";
 const char SanCovTraceDiv4[] = "__sanitizer_cov_trace_div4";
 const char SanCovTraceDiv8[] = "__sanitizer_cov_trace_div8";
 const char SanCovTraceGep[] = "__sanitizer_cov_trace_gep";
@@ -122,6 +132,14 @@
   cl::desc("Tracing of DIV instructions"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClLoadTracing("sanitizer-coverage-trace-loads",
+   cl::desc("Tracing of load instructions"),
+   cl::Hidden, cl::init(false));
+
+static cl::opt ClStoreTracing("sanitizer-coverage-trace-stores",
+cl::desc("Tracing of store instructions"),
+cl::Hidden, cl::init(false));
+
 static cl::opt ClGEPTracing("sanitizer-coverage-trace-geps",
   cl::desc("Tracing of GEP instructions"),
   cl::Hidden, cl::init(false));
@@ -175,9 +193,11 @@
   Options.PCTable |= ClCreatePCTable;
   Options.NoPrune |= !ClPruneBlocks;
   Options.StackDepth |= ClStackDepth;
+  Options.TraceLoads |= ClLoadTracing;
+  Options.TraceStores |= ClStoreTracing;
   if (!Options.TracePCGuard && !Options.TracePC &&
   

[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I think probably it is necessary to merge linkonce_odr symbols for them to work 
properly.

Consider the following testcase:

  // a.cu
  template
  __global__ void foo(T x) {}
  
  void test1() {
  foo<<<1,1>>>(1);
  }
  
  // b.cu
  template
  __global__ void foo(T x) {}
  
  void test2() {
  foo<<<1,1>>>(1);
  }
  
  // c.cu
  template
  __global__ void foo(T x);
  
  int main() {
  foo<<<1,1>>>(1);
  }

Assume a.cu, b.cu, and c.cu are compiled with default -fno-gpu-rdc option and 
linked together.

Both a.obj and b.obj contain a global symbol foo as the kernel stub 
function. c.obj contains reference to foo, so it has to resolve to 
foo in a.obj or b.obj. It only makes sense for linker to merge foo in 
a.obj and b.obj and let c.obj resolve to the merged symbol. This also requires 
that the fat binary embedded in a.obj and b.obj must contain the identical 
definition of kernel foo. That is, if ODR is followed, even though there 
are two fat binaries containing kernel foo, only one of them will be used 
(it is fine since they are identical), which corresponds to the merged symbol 
for the kernel stub foo.

The implication is that, we have to ask users to follow ODR even with the 
default -fno-gpu-rdc option. And users cannot have different definitions for 
the same template instantiation (e.g. foo) in different TU's, otherwise 
there will be UB.

Considering ODR is a fundamental assumption for C++, I think it is justifiable 
to request users to follow that no matter whether -fgpu-rdc or -fno-gpu-rdc.


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

https://reviews.llvm.org/D112492

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


[PATCH] D113518: [clang] Create delegating constructors even in templates

2021-11-09 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: rsmith, dblaikie, carlosgalvezp.
fwolff added a project: clang.
Herald added subscribers: kbarton, nemanjai.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.
Herald added a project: clang-tools-extra.

This fixes a bug in clang-tidy (PR#37902), even though the code for the 
`cppcoreguidelines-pro-type-member-init` check itself is perfectly fine. It 
uses the `isDelegatingConstructor()` matcher, which does not match delegating 
constructors in templates because the AST contains incorrect information 
(constructors in templates are never marked as delegating). This patch fixes 
this behavior by constructing a correct `CXXCtorInitializer` for delegating 
constructors in templates.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113518

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -4496,6 +4496,8 @@
   // (broken) code in a non-template! SetCtorInitializers does not expect this.
   bool Dependent = CurContext->isDependentContext() &&
(BaseType->isDependentType() || Init->isTypeDependent());
+  bool Delegating = Context.hasSameUnqualifiedType(
+  QualType(ClassDecl->getTypeForDecl(), 0), BaseType);
 
   SourceRange InitRange = Init->getSourceRange();
   if (EllipsisLoc.isValid()) {
@@ -4519,8 +4521,7 @@
   const CXXBaseSpecifier *DirectBaseSpec = nullptr;
   const CXXBaseSpecifier *VirtualBaseSpec = nullptr;
   if (!Dependent) {
-if (Context.hasSameUnqualifiedType(QualType(ClassDecl->getTypeForDecl(),0),
-   BaseType))
+if (Delegating)
   return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
 
 FindBaseInitializer(*this, ClassDecl, BaseType, DirectBaseSpec,
@@ -4548,10 +4549,14 @@
   if (Dependent) {
 DiscardCleanupsInEvaluationContext();
 
-return new (Context) CXXCtorInitializer(Context, BaseTInfo,
-/*IsVirtual=*/false,
-InitRange.getBegin(), Init,
-InitRange.getEnd(), EllipsisLoc);
+if (!Delegating)
+  return new (Context)
+  CXXCtorInitializer(Context, BaseTInfo,
+ /*IsVirtual=*/false, InitRange.getBegin(), Init,
+ InitRange.getEnd(), EllipsisLoc);
+else
+  return new (Context) CXXCtorInitializer(
+  Context, BaseTInfo, InitRange.getBegin(), Init, InitRange.getEnd());
   }
 
   // C++ [base.class.init]p2:
@@ -5063,14 +5068,16 @@
   memcpy(initializer, , sizeof (CXXCtorInitializer*));
   Constructor->setCtorInitializers(initializer);
 
-  if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
-MarkFunctionReferenced(Initializer->getSourceLocation(), Dtor);
-DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
-  }
+  if (!Constructor->isDependentContext()) {
+if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
+  MarkFunctionReferenced(Initializer->getSourceLocation(), Dtor);
+  DiagnoseUseOfDecl(Dtor, Initializer->getSourceLocation());
+}
 
-  DelegatingCtorDecls.push_back(Constructor);
+DelegatingCtorDecls.push_back(Constructor);
 
-  DiagnoseUninitializedFields(*this, Constructor);
+DiagnoseUninitializedFields(*this, Constructor);
+  }
 
   return false;
 }
Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -372,8 +372,6 @@
 class PositiveSelfInitialization : NegativeAggregateType
 {
   PositiveSelfInitialization() : PositiveSelfInitialization() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NegativeAggregateType
-  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), 
PositiveSelfInitialization() {}
 };
 
 class PositiveIndirectMember {
@@ -552,3 +550,11 @@
   int A;
   // CHECK-FIXES-NOT: int A{};
 };
+
+// Check that a delegating constructor in a template does not trigger false 
positives (PR#37902).
+template 
+struct TemplateWithDelegatingCtor {
+  int X;
+  TemplateWithDelegatingCtor() : X{} {};
+  TemplateWithDelegatingCtor(int) : TemplateWithDelegatingCtor(){};
+};


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -4496,6 +4496,8 @@
   // (broken) code in a 

[PATCH] D113517: Correct handling of the 'throw()' exception specifier in C++17.

2021-11-09 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added a reviewer: aaron.ballman.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per C++17 [except.spec], 'throw()' has become equivalent to
'noexcept', and should therefore call std::terminate, not
std::unexpected.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113517

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CXX/except/except.spec/p9-dynamic.cpp


Index: clang/test/CXX/except/except.spec/p9-dynamic.cpp
===
--- clang/test/CXX/except/except.spec/p9-dynamic.cpp
+++ clang/test/CXX/except/except.spec/p9-dynamic.cpp
@@ -1,12 +1,26 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - 
-fcxx-exceptions -fexceptions | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - 
-fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-PRE17
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++17 
-Wno-dynamic-exception-spec -emit-llvm -o - -fcxx-exceptions -fexceptions | 
FileCheck %s --check-prefixes=CHECK,CHECK-17
 
 void external();
 
+// CHECK-LABEL: _Z6targetv(
+// CHECK: invoke void @_Z8externalv()
+// CHECK:  landingpad { i8*, i32 }
+// CHECK-NEXT:   filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
+// CHECK:  call void @__cxa_call_unexpected
 void target() throw(int)
 {
-  // CHECK: invoke void @_Z8externalv()
   external();
 }
-// CHECK:  landingpad { i8*, i32 }
-// CHECK-NEXT:   filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
-// CHECK:  call void @__cxa_call_unexpected
+
+// CHECK-LABEL: _Z7target2v(
+// CHECK: invoke void @_Z8externalv()
+// CHECK:landingpad { i8*, i32 }
+// CHECK-PRE17-NEXT:   filter [0 x i8*] zeroinitializer
+// CHECK-17-NEXT:  catch i8* null
+// CHECK-PRE17:  call void @__cxa_call_unexpected
+// CHECK-17: call void @__clang_call_terminate
+void target2() throw()
+{
+  external();
+}
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -477,7 +477,10 @@
 return;
 
   ExceptionSpecificationType EST = Proto->getExceptionSpecType();
-  if (isNoexceptExceptionSpec(EST) && Proto->canThrow() == CT_Cannot) {
+  // In C++17 and later, 'throw()' aka EST_DynamicNone is treated the same way
+  // as noexcept. In earlier standards, it is handled separately, below.
+  if ((getLangOpts().CPlusPlus17 || EST != EST_DynamicNone) &&
+  Proto->canThrow() == CT_Cannot) {
 // noexcept functions are simple terminate scopes.
 if (!getLangOpts().EHAsynch) // -EHa: HW exception still can occur
   EHStack.pushTerminate();
@@ -580,7 +583,8 @@
 return;
 
   ExceptionSpecificationType EST = Proto->getExceptionSpecType();
-  if (isNoexceptExceptionSpec(EST) && Proto->canThrow() == CT_Cannot &&
+  if ((getLangOpts().CPlusPlus17 || EST != EST_DynamicNone) &&
+  Proto->canThrow() == CT_Cannot &&
   !EHStack.empty() /* possible empty when under async exceptions */) {
 EHStack.popTerminate();
   } else if (EST == EST_Dynamic || EST == EST_DynamicNone) {


Index: clang/test/CXX/except/except.spec/p9-dynamic.cpp
===
--- clang/test/CXX/except/except.spec/p9-dynamic.cpp
+++ clang/test/CXX/except/except.spec/p9-dynamic.cpp
@@ -1,12 +1,26 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-PRE17
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -std=c++17 -Wno-dynamic-exception-spec -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s --check-prefixes=CHECK,CHECK-17
 
 void external();
 
+// CHECK-LABEL: _Z6targetv(
+// CHECK: invoke void @_Z8externalv()
+// CHECK:  landingpad { i8*, i32 }
+// CHECK-NEXT:   filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
+// CHECK:  call void @__cxa_call_unexpected
 void target() throw(int)
 {
-  // CHECK: invoke void @_Z8externalv()
   external();
 }
-// CHECK:  landingpad { i8*, i32 }
-// CHECK-NEXT:   filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
-// CHECK:  call void @__cxa_call_unexpected
+
+// CHECK-LABEL: _Z7target2v(
+// CHECK: invoke void @_Z8externalv()
+// CHECK:landingpad { i8*, i32 }
+// CHECK-PRE17-NEXT:   filter [0 x i8*] zeroinitializer
+// CHECK-17-NEXT:  catch i8* null
+// CHECK-PRE17:  call void @__cxa_call_unexpected
+// CHECK-17: call void @__clang_call_terminate
+void target2() throw()
+{
+  external();
+}
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp

[clang] 50082e1 - Fix test after aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7.

2021-11-09 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2021-11-09T16:59:45-05:00
New Revision: 50082e1882ae7fe101e563c5e18a27e0804d517b

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

LOG: Fix test after aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7.

(Apparently no buildbots enable both examples and plugins!)

Added: 


Modified: 
clang/test/Frontend/plugin-attribute.cpp

Removed: 




diff  --git a/clang/test/Frontend/plugin-attribute.cpp 
b/clang/test/Frontend/plugin-attribute.cpp
index f02932d56c687..8b38e57974bbb 100644
--- a/clang/test/Frontend/plugin-attribute.cpp
+++ b/clang/test/Frontend/plugin-attribute.cpp
@@ -9,7 +9,7 @@ void fn1a() __attribute__((example)) {}
 [[plugin::example]] void fn1c() {}
 void fn2() __attribute__((example("somestring", 1, 2.0))) {}
 // CHECK-COUNT-4: -AnnotateAttr 0x{{[0-9a-z]+}} {{}} "example"
-// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 
'const char [{{[0-9]+}}]' lvalue "somestring"
+// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{}} 
'const char[{{[0-9]+}}]' lvalue "somestring"
 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{}} 
'int' 1
 // CHECK: -FloatingLiteral 0x{{[0-9a-z]+}} {{}} 
'double' 2.00e+00
 



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


[PATCH] D113352: [clang] Run LLVM Verifier in modes without CodeGen too

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9efce0baee4b: [clang] Run LLVM Verifier in modes without 
CodeGen too (authored by ibookstein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113352

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/lto-newpm-pipeline.c


Index: clang/test/CodeGen/lto-newpm-pipeline.c
===
--- clang/test/CodeGen/lto-newpm-pipeline.c
+++ clang/test/CodeGen/lto-newpm-pipeline.c
@@ -32,6 +32,8 @@
 // CHECK-FULL-O0-NEXT: Running pass: CoroCleanupPass
 // CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
+// CHECK-FULL-O0-NEXT: Running pass: VerifierPass
+// CHECK-FULL-O0-NEXT: Running analysis: VerifierAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: BitcodeWriterPass
 
 // CHECK-THIN-O0: Running pass: AlwaysInlinerPass
@@ -40,6 +42,8 @@
 // CHECK-THIN-O0: Running pass: CoroCleanupPass
 // CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
+// CHECK-THIN-O0-NEXT: Running pass: VerifierPass
+// CHECK-THIN-O0-NEXT: Running analysis: VerifierAnalysis
 // CHECK-THIN-O0-NEXT: Running pass: ThinLTOBitcodeWriterPass
 
 // TODO: The LTO pre-link pipeline currently invokes
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -5034,7 +5034,7 @@
   llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
   llvm::Type *ResolverTy = llvm::GlobalIFunc::getResolverFunctionType(DeclTy);
   llvm::Constant *Resolver =
-  GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, GD,
+  GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, {},
   /*ForVTable=*/false);
   llvm::GlobalIFunc *GIF =
   llvm::GlobalIFunc::create(DeclTy, 0, llvm::Function::ExternalLinkage,
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -487,6 +487,11 @@
   }
 }
 
+static bool actionRequiresCodeGen(BackendAction Action) {
+  return Action != Backend_EmitNothing && Action != Backend_EmitBC &&
+ Action != Backend_EmitLL;
+}
+
 static bool initTargetOptions(DiagnosticsEngine ,
   llvm::TargetOptions ,
   const CodeGenOptions ,
@@ -977,9 +982,7 @@
 
   setCommandLineOpts(CodeGenOpts);
 
-  bool UsesCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
+  bool UsesCodeGen = actionRequiresCodeGen(Action);
   CreateTargetMachine(UsesCodeGen);
 
   if (UsesCodeGen && !TM)
@@ -1006,6 +1009,12 @@
 
   CreatePasses(PerModulePasses, PerFunctionPasses);
 
+  // Add a verifier pass if requested. We don't have to do this if the action
+  // requires code generation because there will already be a verifier pass in
+  // the code-generation pipeline.
+  if (!UsesCodeGen && CodeGenOpts.VerifyModule)
+PerModulePasses.add(createVerifierPass());
+
   legacy::PassManager CodeGenPasses;
   CodeGenPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
@@ -1425,6 +1434,13 @@
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
+
+  // Add a verifier pass if requested. We don't have to do this if the action
+  // requires code generation because there will already be a verifier pass in
+  // the code-generation pipeline.
+  if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
+MPM.addPass(VerifierPass());
+
   switch (Action) {
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
@@ -1514,8 +1530,7 @@
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC && Action != 
Backend_EmitLL);
+  bool RequiresCodeGen = actionRequiresCodeGen(Action);
   CreateTargetMachine(RequiresCodeGen);
 
   if (RequiresCodeGen && !TM)


Index: clang/test/CodeGen/lto-newpm-pipeline.c
===
--- clang/test/CodeGen/lto-newpm-pipeline.c
+++ clang/test/CodeGen/lto-newpm-pipeline.c
@@ -32,6 +32,8 @@
 // CHECK-FULL-O0-NEXT: Running pass: CoroCleanupPass
 // CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
 // CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
+// CHECK-FULL-O0-NEXT: Running pass: VerifierPass
+// CHECK-FULL-O0-NEXT: Running analysis: VerifierAnalysis
 // CHECK-FULL-O0-NEXT: Running pass: 

[clang] 9efce0b - [clang] Run LLVM Verifier in modes without CodeGen too

2021-11-09 Thread Itay Bookstein via cfe-commits

Author: Itay Bookstein
Date: 2021-11-09T23:57:13+02:00
New Revision: 9efce0baee4bdda9d824716668ac3d3027bfa318

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

LOG: [clang] Run LLVM Verifier in modes without CodeGen too

Previously, the Backend_Emit{Nothing,BC,LL} modes did
not run the LLVM verifier since it is usually added via
the TargetMachine::addPassesToEmitFile method according
to the DisableVerify parameter. This is called from
EmitAssemblyHelper::AddEmitPasses, which is only relevant
for BackendAction-s that require CodeGen.

Note:
* In these particular situations the verifier is added
  to the optimization pipeline rather than the codegen
  pipeline so that it runs prior to the BC/LL emission
  pass.
* This change applies to both the old and the new PMs.
* Because the clang tests use -emit-llvm ubiquitously,
  this change will enable the verifier for them.
* A small bug is fixed in emitIFuncDefinition so that
  the clang/test/CodeGen/ifunc.c test would pass:
  the emitIFuncDefinition incorrectly passed the
  GlobalDecl of the IFunc itself to the call to
  GetOrCreateLLVMFunction for creating the resolver.

Signed-off-by: Itay Bookstein 

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/lto-newpm-pipeline.c

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 2d467e8dea81..1f583e639c57 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -487,6 +487,11 @@ static CodeGenFileType getCodeGenFileType(BackendAction 
Action) {
   }
 }
 
+static bool actionRequiresCodeGen(BackendAction Action) {
+  return Action != Backend_EmitNothing && Action != Backend_EmitBC &&
+ Action != Backend_EmitLL;
+}
+
 static bool initTargetOptions(DiagnosticsEngine ,
   llvm::TargetOptions ,
   const CodeGenOptions ,
@@ -977,9 +982,7 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
 
   setCommandLineOpts(CodeGenOpts);
 
-  bool UsesCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC &&
-  Action != Backend_EmitLL);
+  bool UsesCodeGen = actionRequiresCodeGen(Action);
   CreateTargetMachine(UsesCodeGen);
 
   if (UsesCodeGen && !TM)
@@ -1006,6 +1009,12 @@ void 
EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager(
 
   CreatePasses(PerModulePasses, PerFunctionPasses);
 
+  // Add a verifier pass if requested. We don't have to do this if the action
+  // requires code generation because there will already be a verifier pass in
+  // the code-generation pipeline.
+  if (!UsesCodeGen && CodeGenOpts.VerifyModule)
+PerModulePasses.add(createVerifierPass());
+
   legacy::PassManager CodeGenPasses;
   CodeGenPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
@@ -1425,6 +1434,13 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
   MPM.addPass(ModuleMemProfilerPass());
 }
   }
+
+  // Add a verifier pass if requested. We don't have to do this if the action
+  // requires code generation because there will already be a verifier pass in
+  // the code-generation pipeline.
+  if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
+MPM.addPass(VerifierPass());
+
   switch (Action) {
   case Backend_EmitBC:
 if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
@@ -1514,8 +1530,7 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction 
Action,
   TimeRegion Region(CodeGenOpts.TimePasses ?  : nullptr);
   setCommandLineOpts(CodeGenOpts);
 
-  bool RequiresCodeGen = (Action != Backend_EmitNothing &&
-  Action != Backend_EmitBC && Action != 
Backend_EmitLL);
+  bool RequiresCodeGen = actionRequiresCodeGen(Action);
   CreateTargetMachine(RequiresCodeGen);
 
   if (RequiresCodeGen && !TM)

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 8e4d9dc751dd..d36cff82f9dd 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5034,7 +5034,7 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
   llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
   llvm::Type *ResolverTy = llvm::GlobalIFunc::getResolverFunctionType(DeclTy);
   llvm::Constant *Resolver =
-  GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, GD,
+  GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, {},
   /*ForVTable=*/false);
   llvm::GlobalIFunc *GIF =
   llvm::GlobalIFunc::create(DeclTy, 0, llvm::Function::ExternalLinkage,

diff  

[PATCH] D112868: [CodeGen] Diagnose and reject non-function ifunc resolvers

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b1fd19357be: [CodeGen] Diagnose and reject non-function 
ifunc resolvers (authored by ibookstein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-ifunc.c

Index: clang/test/CodeGen/attr-ifunc.c
===
--- clang/test/CodeGen/attr-ifunc.c
+++ clang/test/CodeGen/attr-ifunc.c
@@ -13,8 +13,7 @@
 void f1() __attribute__((ifunc("f1_ifunc")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
-void *f2_a() __attribute__((ifunc("f2_b")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((alias("f2_b")));
 void *f2_b() __attribute__((ifunc("f2_a")));
 // expected-error@-1 {{ifunc definition is part of a cycle}}
 
@@ -27,6 +26,15 @@
 void f4() __attribute__((ifunc("f4_ifunc")));
 // expected-error@-1 {{ifunc resolver function must return a pointer}}
 
+int f5_resolver_gvar;
+void f5() __attribute__((ifunc("f5_resolver_gvar")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
+void *f6_resolver_resolver() { return 0; }
+void *f6_resolver() __attribute__((ifunc("f6_resolver_resolver")));
+void f6() __attribute__((ifunc("f6_resolver")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
 #else
 void f1a() __asm("f1");
 void f1a() {}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -313,21 +313,57 @@
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
-  llvm::SmallPtrSet Visited;
-  for (;;) {
-if (!GV || !Visited.insert(GV).second)
-  return nullptr;
-
-const llvm::Constant *C;
-if (auto *GA = dyn_cast(GV))
-  C = GA->getAliasee();
-else if (auto *GI = dyn_cast(GV))
-  C = GI->getResolver();
-else
-  return GV;
+  const llvm::Constant *C;
+  if (auto *GA = dyn_cast(GV))
+C = GA->getAliasee();
+  else if (auto *GI = dyn_cast(GV))
+C = GI->getResolver();
+  else
+return GV;
+
+  const auto *AliaseeGV = dyn_cast(C->stripPointerCasts());
+  if (!AliaseeGV)
+return nullptr;
+
+  const llvm::GlobalValue *FinalGV = AliaseeGV->getAliaseeObject();
+  if (FinalGV == GV)
+return nullptr;
+
+  return FinalGV;
+}
+
+static bool checkAliasedGlobal(DiagnosticsEngine ,
+   SourceLocation Location, bool IsIFunc,
+   const llvm::GlobalValue *Alias,
+   const llvm::GlobalValue *) {
+  GV = getAliasedGlobal(Alias);
+  if (!GV) {
+Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
+return false;
+  }
+
+  if (GV->isDeclaration()) {
+Diags.Report(Location, diag::err_alias_to_undefined) << IsIFunc << IsIFunc;
+return false;
+  }
+
+  if (IsIFunc) {
+// Check resolver function type.
+const auto *F = dyn_cast(GV);
+if (!F) {
+  Diags.Report(Location, diag::err_alias_to_undefined)
+  << IsIFunc << IsIFunc;
+  return false;
+}
 
-GV = dyn_cast(C->stripPointerCasts());
+llvm::FunctionType *FTy = F->getFunctionType();
+if (!FTy->getReturnType()->isPointerTy()) {
+  Diags.Report(Location, diag::err_ifunc_resolver_return);
+  return false;
+}
   }
+
+  return true;
 }
 
 void CodeGenModule::checkAliases() {
@@ -344,23 +380,13 @@
   Location = A->getLocation();
 else
   llvm_unreachable("Not an alias or ifunc?");
+
 StringRef MangledName = getMangledName(GD);
 llvm::GlobalValue *Alias = GetGlobalValue(MangledName);
-const llvm::GlobalValue *GV = getAliasedGlobal(Alias);
-if (!GV) {
-  Error = true;
-  Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
-} else if (GV->isDeclaration()) {
+const llvm::GlobalValue *GV = nullptr;
+if (!checkAliasedGlobal(Diags, Location, IsIFunc, Alias, GV)) {
   Error = true;
-  Diags.Report(Location, diag::err_alias_to_undefined)
-  << IsIFunc << IsIFunc;
-} else if (IsIFunc) {
-  // Check resolver function type.
-  llvm::FunctionType *FTy = dyn_cast(
-  GV->getType()->getPointerElementType());
-  assert(FTy);
-  if (!FTy->getReturnType()->isPointerTy())
-Diags.Report(Location, diag::err_ifunc_resolver_return);
+  continue;
 }
 
 llvm::Constant *Aliasee =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce91540beeff: [clang][test][NFC] Move attr-ifunc.c test from 
Sema to CodeGen (authored by ibookstein).

Changed prior to commit:
  https://reviews.llvm.org/D113431?vs=385923=385966#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

Files:
  clang/test/CodeGen/attr-ifunc.c
  clang/test/Sema/attr-ifunc.c




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


[PATCH] D113504: [clang][test][NFC] clang-format attr-ifunc.c test

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f04f7d816f3: [clang][test][NFC] clang-format attr-ifunc.c 
test (authored by ibookstein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113504

Files:
  clang/test/Sema/attr-ifunc.c


Index: clang/test/Sema/attr-ifunc.c
===
--- clang/test/Sema/attr-ifunc.c
+++ clang/test/Sema/attr-ifunc.c
@@ -5,39 +5,39 @@
 #if defined(_WIN32)
 void foo() {}
 void bar() __attribute__((ifunc("foo")));
-//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
+// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
 
 #else
 #if defined(CHECK_ALIASES)
-void* f1_ifunc();
+void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{ifunc must point to a defined function}}
+// expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
-void* f2_b() __attribute__((ifunc("f2_a")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((ifunc("f2_b")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_b() __attribute__((ifunc("f2_a")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
 
-void* f3_a() __attribute__((ifunc("f3_b")));
-//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
-void* f3_b() __attribute__((weak, alias("f3_c")));
-void* f3_c() { return 0; }
+void *f3_a() __attribute__((ifunc("f3_b")));
+// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
+void *f3_b() __attribute__((weak, alias("f3_c")));
+void *f3_c() { return 0; }
 
 void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
-//expected-error@-1 {{ifunc resolver function must return a pointer}}
+// expected-error@-1 {{ifunc resolver function must return a pointer}}
 
 #else
 void f1a() __asm("f1");
 void f1a() {}
-//expected-note@-1 {{previous definition is here}}
+// expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
-void* f1_ifunc() { return 0; }
+// expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
+void *f1_ifunc() { return 0; }
 
-void* f6_ifunc(int i);
+void *f6_ifunc(int i);
 void __attribute__((ifunc("f6_ifunc"))) f6() {}
-//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
 
 #endif
 #endif


Index: clang/test/Sema/attr-ifunc.c
===
--- clang/test/Sema/attr-ifunc.c
+++ clang/test/Sema/attr-ifunc.c
@@ -5,39 +5,39 @@
 #if defined(_WIN32)
 void foo() {}
 void bar() __attribute__((ifunc("foo")));
-//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
+// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
 
 #else
 #if defined(CHECK_ALIASES)
-void* f1_ifunc();
+void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{ifunc must point to a defined function}}
+// expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
-void* f2_b() __attribute__((ifunc("f2_a")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((ifunc("f2_b")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_b() __attribute__((ifunc("f2_a")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
 
-void* f3_a() __attribute__((ifunc("f3_b")));
-//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
-void* f3_b() __attribute__((weak, alias("f3_c")));
-void* f3_c() { return 0; }
+void *f3_a() __attribute__((ifunc("f3_b")));
+// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
+void *f3_b() __attribute__((weak, alias("f3_c")));
+void *f3_c() { return 0; }
 
 void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
-//expected-error@-1 {{ifunc resolver function must return a pointer}}
+// expected-error@-1 {{ifunc resolver function must return a pointer}}
 
 #else
 void f1a() __asm("f1");
 void f1a() {}
-//expected-note@-1 {{previous definition is here}}
+// expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
-void* f1_ifunc() { return 0; }
+// expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
+void *f1_ifunc() { return 

[clang] 3b1fd19 - [CodeGen] Diagnose and reject non-function ifunc resolvers

2021-11-09 Thread Itay Bookstein via cfe-commits

Author: Itay Bookstein
Date: 2021-11-09T23:51:36+02:00
New Revision: 3b1fd19357be50cec8a5be8660806e0e02e84aa1

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

LOG: [CodeGen] Diagnose and reject non-function ifunc resolvers

Signed-off-by: Itay Bookstein 

Reviewed By: MaskRay, erichkeane

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-ifunc.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index df5e02e9812f..8e4d9dc751dd 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -313,21 +313,57 @@ void CodeGenModule::applyGlobalValReplacements() {
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
-  llvm::SmallPtrSet Visited;
-  for (;;) {
-if (!GV || !Visited.insert(GV).second)
-  return nullptr;
-
-const llvm::Constant *C;
-if (auto *GA = dyn_cast(GV))
-  C = GA->getAliasee();
-else if (auto *GI = dyn_cast(GV))
-  C = GI->getResolver();
-else
-  return GV;
+  const llvm::Constant *C;
+  if (auto *GA = dyn_cast(GV))
+C = GA->getAliasee();
+  else if (auto *GI = dyn_cast(GV))
+C = GI->getResolver();
+  else
+return GV;
+
+  const auto *AliaseeGV = dyn_cast(C->stripPointerCasts());
+  if (!AliaseeGV)
+return nullptr;
+
+  const llvm::GlobalValue *FinalGV = AliaseeGV->getAliaseeObject();
+  if (FinalGV == GV)
+return nullptr;
+
+  return FinalGV;
+}
+
+static bool checkAliasedGlobal(DiagnosticsEngine ,
+   SourceLocation Location, bool IsIFunc,
+   const llvm::GlobalValue *Alias,
+   const llvm::GlobalValue *) {
+  GV = getAliasedGlobal(Alias);
+  if (!GV) {
+Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
+return false;
+  }
+
+  if (GV->isDeclaration()) {
+Diags.Report(Location, diag::err_alias_to_undefined) << IsIFunc << IsIFunc;
+return false;
+  }
+
+  if (IsIFunc) {
+// Check resolver function type.
+const auto *F = dyn_cast(GV);
+if (!F) {
+  Diags.Report(Location, diag::err_alias_to_undefined)
+  << IsIFunc << IsIFunc;
+  return false;
+}
 
-GV = dyn_cast(C->stripPointerCasts());
+llvm::FunctionType *FTy = F->getFunctionType();
+if (!FTy->getReturnType()->isPointerTy()) {
+  Diags.Report(Location, diag::err_ifunc_resolver_return);
+  return false;
+}
   }
+
+  return true;
 }
 
 void CodeGenModule::checkAliases() {
@@ -344,23 +380,13 @@ void CodeGenModule::checkAliases() {
   Location = A->getLocation();
 else
   llvm_unreachable("Not an alias or ifunc?");
+
 StringRef MangledName = getMangledName(GD);
 llvm::GlobalValue *Alias = GetGlobalValue(MangledName);
-const llvm::GlobalValue *GV = getAliasedGlobal(Alias);
-if (!GV) {
-  Error = true;
-  Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
-} else if (GV->isDeclaration()) {
+const llvm::GlobalValue *GV = nullptr;
+if (!checkAliasedGlobal(Diags, Location, IsIFunc, Alias, GV)) {
   Error = true;
-  Diags.Report(Location, diag::err_alias_to_undefined)
-  << IsIFunc << IsIFunc;
-} else if (IsIFunc) {
-  // Check resolver function type.
-  llvm::FunctionType *FTy = dyn_cast(
-  GV->getType()->getPointerElementType());
-  assert(FTy);
-  if (!FTy->getReturnType()->isPointerTy())
-Diags.Report(Location, diag::err_ifunc_resolver_return);
+  continue;
 }
 
 llvm::Constant *Aliasee =

diff  --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 6fac48a5afe2..1a5c38545177 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -13,8 +13,7 @@ void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
-void *f2_a() __attribute__((ifunc("f2_b")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((alias("f2_b")));
 void *f2_b() __attribute__((ifunc("f2_a")));
 // expected-error@-1 {{ifunc definition is part of a cycle}}
 
@@ -27,6 +26,15 @@ void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
 // expected-error@-1 {{ifunc resolver function must return a pointer}}
 
+int f5_resolver_gvar;
+void f5() __attribute__((ifunc("f5_resolver_gvar")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
+void *f6_resolver_resolver() { return 0; }
+void *f6_resolver() 

[clang] ce91540 - [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Itay Bookstein via cfe-commits

Author: Itay Bookstein
Date: 2021-11-09T23:51:29+02:00
New Revision: ce91540beeff08ddef826c0819fbaabfd4aefc86

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

LOG: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

Signed-off-by: Itay Bookstein 

Reviewed By: erichkeane

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

Added: 
clang/test/CodeGen/attr-ifunc.c

Modified: 


Removed: 
clang/test/Sema/attr-ifunc.c



diff  --git a/clang/test/Sema/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
similarity index 100%
rename from clang/test/Sema/attr-ifunc.c
rename to clang/test/CodeGen/attr-ifunc.c



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


[clang] 4f04f7d - [clang][test][NFC] clang-format attr-ifunc.c test

2021-11-09 Thread Itay Bookstein via cfe-commits

Author: Itay Bookstein
Date: 2021-11-09T23:51:22+02:00
New Revision: 4f04f7d816f3cb5c83c87fdf0468f8090ea9e44d

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

LOG: [clang][test][NFC] clang-format attr-ifunc.c test

Signed-off-by: Itay Bookstein 

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/test/Sema/attr-ifunc.c

Removed: 




diff  --git a/clang/test/Sema/attr-ifunc.c b/clang/test/Sema/attr-ifunc.c
index 907b61c4451e..6fac48a5afe2 100644
--- a/clang/test/Sema/attr-ifunc.c
+++ b/clang/test/Sema/attr-ifunc.c
@@ -5,39 +5,39 @@
 #if defined(_WIN32)
 void foo() {}
 void bar() __attribute__((ifunc("foo")));
-//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
+// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
 
 #else
 #if defined(CHECK_ALIASES)
-void* f1_ifunc();
+void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{ifunc must point to a defined function}}
+// expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
-void* f2_b() __attribute__((ifunc("f2_a")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((ifunc("f2_b")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_b() __attribute__((ifunc("f2_a")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
 
-void* f3_a() __attribute__((ifunc("f3_b")));
-//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
-void* f3_b() __attribute__((weak, alias("f3_c")));
-void* f3_c() { return 0; }
+void *f3_a() __attribute__((ifunc("f3_b")));
+// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
+void *f3_b() __attribute__((weak, alias("f3_c")));
+void *f3_c() { return 0; }
 
 void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
-//expected-error@-1 {{ifunc resolver function must return a pointer}}
+// expected-error@-1 {{ifunc resolver function must return a pointer}}
 
 #else
 void f1a() __asm("f1");
 void f1a() {}
-//expected-note@-1 {{previous definition is here}}
+// expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
-void* f1_ifunc() { return 0; }
+// expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
+void *f1_ifunc() { return 0; }
 
-void* f6_ifunc(int i);
+void *f6_ifunc(int i);
 void __attribute__((ifunc("f6_ifunc"))) f6() {}
-//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
 
 #endif
 #endif



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


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein added a comment.

Right; well, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

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


[PATCH] D113425: gcc extension # NNN directive lines

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:4058
+
+* ``1`:` Push the current source file name onto the include stack and
+  enter a new file.

Produces

```
/home/buildbot/llvm-build-dir/clang-sphinx-docs/llvm/build/tools/clang/docs/LanguageExtensions.rst:4059:Inline
 literal start-string without end-string.
```

I guess the problem is that the characters are swapped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113425

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


[PATCH] D112868: [CodeGen] Diagnose and reject non-function ifunc resolvers

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein added a comment.

Yeah, it's real ugly from a CFE/LLVM separation POV. I also can't avoid seeing 
it as a duplication of the verifier's logic. But emitting diagnoses is better 
than asserting/crashing...
For the recursion, maybe an equivalent of `getAliaseeObject` on `GlobalDecl`-s 
could work? For the rest - not steeped in the code enough to say...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

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


[PATCH] D112914: Misleading identifier detection

2021-11-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D112914#3119704 , @thakis wrote:

> The test seems to trigger an assert: http://45.33.8.238/linux/60293/step_9.txt
>
> Please take a look!

It's getting late here: Reverted, I'll have a look tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112914

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


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

In D113431#3119716 , @ibookstein 
wrote:

> If you meant fusing the clang-format commit with this one, doing it in the 
> same commit results in git no longer detecting the connection between them 
> (similarity too low), so it loses the history. When searching I found a 
> recommendation  to avoid combining 
> renames with modifications where git history matters, so I thought I might as 
> well :)

I'd thought about it on the other review where it was questioned to be moved, 
but i don't care that much...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

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


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein added a comment.

If you meant fusing the clang-format commit with this one, doing it in the same 
commit results in git no longer detecting the connection between them 
(similarity too low), so it loses the history. When searching I found a 
recommendation  to avoid combining 
renames with modifications where git history matters, so I thought I might as 
well :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

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


[PATCH] D113491: [HIP] Fix device stub name for Windows

2021-11-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:975-976
+  llvm::SmallString<128> Buf;
+  mangleSourceName((llvm::Twine("__device_stub__") + II->getName())
+   .toStringRef(Buf));
+} else

tra wrote:
> Can we just use `(llvm::Twine("__device_stub__") + II->getName()).str()`? Or  
> `std::string("__device__stub") + II->getName().str()`  ?
> 
> `std::string` should be convertible to StringRef and using a temporary 
> variable here is fine.
I will use (llvm::Twine("__device_stub__") + II->getName()).str()


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

https://reviews.llvm.org/D113491

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


[PATCH] D112914: Misleading identifier detection

2021-11-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

The test seems to trigger an assert: http://45.33.8.238/linux/60293/step_9.txt

Please take a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112914

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


[PATCH] D111266: Comment AST: Add support for variable templates

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rG63ef0e17e288: Comment AST: Add support for variable 
templates (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D111266?vs=377663=385955#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111266

Files:
  clang/include/clang/AST/Comment.h
  clang/lib/AST/Comment.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1323,6 +1323,17 @@
  */
 int (*functionPointerVariable)(int i);
 
+#if __cplusplus >= 201402L
+/**
+ * functionPointerVariableTemplate
+ *
+ * @param i is something.
+ * @returns integer.
+ */
+template
+int (*functionPointerVariableTemplate)(T i);
+#endif
+
 struct HasFields {
   /**
* functionPointerField
@@ -1331,6 +1342,18 @@
* @returns integer.
*/
   int (*functionPointerField)(int i);
+
+#if __cplusplus >= 201402L
+  /**
+   * functionPointerTemplateMember
+   *
+   * @tparam T some type.
+   * @param i is integer.
+   * @returns integer.
+   */
+  template
+  static int (*functionPointerTemplateMember)(int i);
+#endif
 };
 
 // expected-warning@+5 {{parameter 'p' not found in the function declaration}}
@@ -1343,6 +1366,23 @@
  */
 void (*functionPointerVariableThatLeadsNowhere)();
 
+#if __cplusplus >= 201402L
+// expected-warning@+8 {{template parameter 'X' not found in the template declaration}}
+// expected-note@+7 {{did you mean 'T'?}}
+// expected-warning@+7 {{parameter 'p' not found in the function declaration}}
+// expected-note@+6 {{did you mean 'x'?}}
+// expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}}
+/**
+ * functionPointerVariable
+ *
+ * \tparam X typo
+ * \param p not here.
+ * \returns integer.
+ */
+template
+void (*functionPointerVariableTemplateThatLeadsNowhere)(T x);
+#endif
+
 // Still warn about param/returns commands for variables that don't specify
 // the type directly:
 
Index: clang/lib/AST/Comment.cpp
===
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -294,6 +294,12 @@
 Kind = ClassKind;
 break;
   case Decl::Var:
+if (const VarTemplateDecl *VTD =
+cast(CommentDecl)->getDescribedVarTemplate()) {
+  TemplateKind = TemplateSpecialization;
+  TemplateParameters = VTD->getTemplateParameters();
+}
+LLVM_FALLTHROUGH;
   case Decl::Field:
   case Decl::EnumConstant:
   case Decl::ObjCIvar:
@@ -305,6 +311,15 @@
   TSI = PD->getTypeSourceInfo();
 Kind = VariableKind;
 break;
+  case Decl::VarTemplate: {
+const VarTemplateDecl *VTD = cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = Template;
+TemplateParameters = VTD->getTemplateParameters();
+if (const VarDecl *VD = VTD->getTemplatedDecl())
+  TSI = VD->getTypeSourceInfo();
+break;
+  }
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;
Index: clang/include/clang/AST/Comment.h
===
--- clang/include/clang/AST/Comment.h
+++ clang/include/clang/AST/Comment.h
@@ -1031,8 +1031,8 @@
 ClassKind,
 
 /// Something that we consider a "variable":
-/// \li namespace scope variables;
-/// \li static and non-static class data members;
+/// \li namespace scope variables and variable templates;
+/// \li static and non-static class data members and member templates;
 /// \li enumerators.
 VariableKind,
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111264: Comment AST: Declare function pointer variables as functions

2021-11-09 Thread Aaron Puchert 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 rG4d6382430066: Comment AST: Declare function pointer 
variables as functions (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D111264?vs=377659=385954#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111264

Files:
  clang/include/clang/AST/Comment.h
  clang/include/clang/AST/CommentSema.h
  clang/lib/AST/Comment.cpp
  clang/lib/AST/CommentSema.cpp
  clang/test/Sema/warn-documentation.cpp
  clang/test/Sema/warn-documentation.m

Index: clang/test/Sema/warn-documentation.m
===
--- clang/test/Sema/warn-documentation.m
+++ clang/test/Sema/warn-documentation.m
@@ -248,6 +248,7 @@
   int (^blockPointerFields)(int i);
 };
 
+// expected-warning@+5 {{parameter 'p' not found in the function declaration}}
 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
 /**
  * functionPointerVariable
Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -1333,6 +1333,7 @@
   int (*functionPointerField)(int i);
 };
 
+// expected-warning@+5 {{parameter 'p' not found in the function declaration}}
 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
 /**
  * functionPointerVariable
Index: clang/lib/AST/CommentSema.cpp
===
--- clang/lib/AST/CommentSema.cpp
+++ clang/lib/AST/CommentSema.cpp
@@ -86,7 +86,7 @@
   new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID,
   CommandMarker);
 
-  if (!isFunctionDecl() && !isFunctionOrBlockPointerVarLikeDecl())
+  if (!isFunctionDecl())
 Diag(Command->getLocation(),
  diag::warn_doc_param_not_attached_to_a_function_decl)
   << CommandMarker
@@ -588,7 +588,7 @@
   // to document the value that the property getter returns.
   if (isObjCPropertyDecl())
 return;
-  if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+  if (isFunctionDecl()) {
 assert(!ThisDeclInfo->ReturnType.isNull() &&
"should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
@@ -871,36 +871,6 @@
   return false;
 }
 
-bool Sema::isFunctionOrBlockPointerVarLikeDecl() {
-  if (!ThisDeclInfo)
-return false;
-  if (!ThisDeclInfo->IsFilled)
-inspectThisDecl();
-  if (ThisDeclInfo->getKind() != DeclInfo::VariableKind ||
-  !ThisDeclInfo->CurrentDecl)
-return false;
-  QualType QT;
-  if (const auto *VD = dyn_cast(ThisDeclInfo->CurrentDecl))
-QT = VD->getType();
-  else if (const auto *PD =
-   dyn_cast(ThisDeclInfo->CurrentDecl))
-QT = PD->getType();
-  else
-return false;
-  // We would like to warn about the 'returns'/'param' commands for
-  // variables that don't directly specify the function type, so type aliases
-  // can be ignored.
-  if (QT->getAs())
-return false;
-  if (const auto *P = QT->getAs())
-if (P->getPointeeType()->getAs())
-  return false;
-  if (const auto *P = QT->getAs())
-if (P->getPointeeType()->getAs())
-  return false;
-  return QT->isFunctionPointerType() || QT->isBlockPointerType();
-}
-
 bool Sema::isObjCPropertyDecl() {
   if (!ThisDeclInfo)
 return false;
Index: clang/lib/AST/Comment.cpp
===
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -333,8 +333,7 @@
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
 FunctionTypeLoc FTL;
 if (getFunctionTypeLoc(TL, FTL)) {
-  if (Kind == TypedefKind)
-Kind = FunctionKind;
+  Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
 }
Index: clang/include/clang/AST/CommentSema.h
===
--- clang/include/clang/AST/CommentSema.h
+++ clang/include/clang/AST/CommentSema.h
@@ -207,10 +207,6 @@
   /// \returns \c true if declaration that this comment is attached to declares
   /// a function pointer.
   bool isFunctionPointerVarDecl();
-  /// \returns \c true if the declaration that this comment is attached to
-  /// declares a variable or a field whose type is a function or a block
-  /// pointer.
-  bool isFunctionOrBlockPointerVarLikeDecl();
   bool isFunctionOrMethodVariadic();
   bool isObjCMethodDecl();
   bool isObjCPropertyDecl();
Index: clang/include/clang/AST/Comment.h
===
--- clang/include/clang/AST/Comment.h
+++ 

[clang] 63ef0e1 - Comment AST: Add support for variable templates

2021-11-09 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-11-09T22:30:09+01:00
New Revision: 63ef0e17e28827eae53133b3467bdac7d9729318

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

LOG: Comment AST: Add support for variable templates

We treat them as variables of course, though if they have function
pointer type we treat them as functions, i.e. allow parameter and return
value specifications. Just like VarDecls.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/include/clang/AST/Comment.h
clang/lib/AST/Comment.cpp
clang/test/Sema/warn-documentation.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index e394e9608426..50ed7eec8208 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -1031,8 +1031,8 @@ struct DeclInfo {
 ClassKind,
 
 /// Something that we consider a "variable":
-/// \li namespace scope variables;
-/// \li static and non-static class data members;
+/// \li namespace scope variables and variable templates;
+/// \li static and non-static class data members and member templates;
 /// \li enumerators.
 VariableKind,
 

diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index ce90abf55294..5e6a7de5b563 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -294,6 +294,12 @@ void DeclInfo::fill() {
 Kind = ClassKind;
 break;
   case Decl::Var:
+if (const VarTemplateDecl *VTD =
+cast(CommentDecl)->getDescribedVarTemplate()) {
+  TemplateKind = TemplateSpecialization;
+  TemplateParameters = VTD->getTemplateParameters();
+}
+LLVM_FALLTHROUGH;
   case Decl::Field:
   case Decl::EnumConstant:
   case Decl::ObjCIvar:
@@ -305,6 +311,15 @@ void DeclInfo::fill() {
   TSI = PD->getTypeSourceInfo();
 Kind = VariableKind;
 break;
+  case Decl::VarTemplate: {
+const VarTemplateDecl *VTD = cast(CommentDecl);
+Kind = VariableKind;
+TemplateKind = Template;
+TemplateParameters = VTD->getTemplateParameters();
+if (const VarDecl *VD = VTD->getTemplatedDecl())
+  TSI = VD->getTypeSourceInfo();
+break;
+  }
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;

diff  --git a/clang/test/Sema/warn-documentation.cpp 
b/clang/test/Sema/warn-documentation.cpp
index f30f05fccd71..3a25c31f76f5 100644
--- a/clang/test/Sema/warn-documentation.cpp
+++ b/clang/test/Sema/warn-documentation.cpp
@@ -1323,6 +1323,17 @@ namespace AllowParamAndReturnsOnFunctionPointerVars {
  */
 int (*functionPointerVariable)(int i);
 
+#if __cplusplus >= 201402L
+/**
+ * functionPointerVariableTemplate
+ *
+ * @param i is something.
+ * @returns integer.
+ */
+template
+int (*functionPointerVariableTemplate)(T i);
+#endif
+
 struct HasFields {
   /**
* functionPointerField
@@ -1331,6 +1342,18 @@ struct HasFields {
* @returns integer.
*/
   int (*functionPointerField)(int i);
+
+#if __cplusplus >= 201402L
+  /**
+   * functionPointerTemplateMember
+   *
+   * @tparam T some type.
+   * @param i is integer.
+   * @returns integer.
+   */
+  template
+  static int (*functionPointerTemplateMember)(int i);
+#endif
 };
 
 // expected-warning@+5 {{parameter 'p' not found in the function declaration}}
@@ -1343,6 +1366,23 @@ struct HasFields {
  */
 void (*functionPointerVariableThatLeadsNowhere)();
 
+#if __cplusplus >= 201402L
+// expected-warning@+8 {{template parameter 'X' not found in the template 
declaration}}
+// expected-note@+7 {{did you mean 'T'?}}
+// expected-warning@+7 {{parameter 'p' not found in the function declaration}}
+// expected-note@+6 {{did you mean 'x'?}}
+// expected-warning@+6 {{'\returns' command used in a comment that is attached 
to a function returning void}}
+/**
+ * functionPointerVariable
+ *
+ * \tparam X typo
+ * \param p not here.
+ * \returns integer.
+ */
+template
+void (*functionPointerVariableTemplateThatLeadsNowhere)(T x);
+#endif
+
 // Still warn about param/returns commands for variables that don't specify
 // the type directly:
 



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


[clang] 4d63824 - Comment AST: Declare function pointer variables as functions

2021-11-09 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-11-09T22:30:08+01:00
New Revision: 4d6382430066465774f6f696ea3f4c402da1d705

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

LOG: Comment AST: Declare function pointer variables as functions

We were doing this already for type aliases, and it deduplicates the
code looking through aliases and pointers to find a function type. As
a side effect, this finds two warnings that we apparently missed before.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/include/clang/AST/Comment.h
clang/include/clang/AST/CommentSema.h
clang/lib/AST/Comment.cpp
clang/lib/AST/CommentSema.cpp
clang/test/Sema/warn-documentation.cpp
clang/test/Sema/warn-documentation.m

Removed: 




diff  --git a/clang/include/clang/AST/Comment.h 
b/clang/include/clang/AST/Comment.h
index 54a4b0a9cfe66..e394e96084264 100644
--- a/clang/include/clang/AST/Comment.h
+++ b/clang/include/clang/AST/Comment.h
@@ -1019,6 +1019,7 @@ struct DeclInfo {
 /// \li member function template,
 /// \li member function template specialization,
 /// \li ObjC method,
+/// \li variable of function pointer, member function pointer or block 
type,
 /// \li a typedef for a function pointer, member function pointer,
 /// ObjC block.
 FunctionKind,

diff  --git a/clang/include/clang/AST/CommentSema.h 
b/clang/include/clang/AST/CommentSema.h
index 6dfe0f4920d06..4a5174e08bff6 100644
--- a/clang/include/clang/AST/CommentSema.h
+++ b/clang/include/clang/AST/CommentSema.h
@@ -207,10 +207,6 @@ class Sema {
   /// \returns \c true if declaration that this comment is attached to declares
   /// a function pointer.
   bool isFunctionPointerVarDecl();
-  /// \returns \c true if the declaration that this comment is attached to
-  /// declares a variable or a field whose type is a function or a block
-  /// pointer.
-  bool isFunctionOrBlockPointerVarLikeDecl();
   bool isFunctionOrMethodVariadic();
   bool isObjCMethodDecl();
   bool isObjCPropertyDecl();

diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 94f65466ad102..ce90abf552947 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -333,8 +333,7 @@ void DeclInfo::fill() {
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
 FunctionTypeLoc FTL;
 if (getFunctionTypeLoc(TL, FTL)) {
-  if (Kind == TypedefKind)
-Kind = FunctionKind;
+  Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
 }

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index e385c5817ef23..3977e6c20a88a 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -86,7 +86,7 @@ ParamCommandComment *Sema::actOnParamCommandStart(
   new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID,
   CommandMarker);
 
-  if (!isFunctionDecl() && !isFunctionOrBlockPointerVarLikeDecl())
+  if (!isFunctionDecl())
 Diag(Command->getLocation(),
  diag::warn_doc_param_not_attached_to_a_function_decl)
   << CommandMarker
@@ -588,7 +588,7 @@ void Sema::checkReturnsCommand(const BlockCommandComment 
*Command) {
   // to document the value that the property getter returns.
   if (isObjCPropertyDecl())
 return;
-  if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+  if (isFunctionDecl()) {
 assert(!ThisDeclInfo->ReturnType.isNull() &&
"should have a valid return type");
 if (ThisDeclInfo->ReturnType->isVoidType()) {
@@ -871,36 +871,6 @@ bool Sema::isFunctionPointerVarDecl() {
   return false;
 }
 
-bool Sema::isFunctionOrBlockPointerVarLikeDecl() {
-  if (!ThisDeclInfo)
-return false;
-  if (!ThisDeclInfo->IsFilled)
-inspectThisDecl();
-  if (ThisDeclInfo->getKind() != DeclInfo::VariableKind ||
-  !ThisDeclInfo->CurrentDecl)
-return false;
-  QualType QT;
-  if (const auto *VD = dyn_cast(ThisDeclInfo->CurrentDecl))
-QT = VD->getType();
-  else if (const auto *PD =
-   dyn_cast(ThisDeclInfo->CurrentDecl))
-QT = PD->getType();
-  else
-return false;
-  // We would like to warn about the 'returns'/'param' commands for
-  // variables that don't directly specify the function type, so type aliases
-  // can be ignored.
-  if (QT->getAs())
-return false;
-  if (const auto *P = QT->getAs())
-if (P->getPointeeType()->getAs())
-  return false;
-  if (const auto *P = QT->getAs())
-if (P->getPointeeType()->getAs())
-  return false;
-  return QT->isFunctionPointerType() || QT->isBlockPointerType();
-}
-
 bool Sema::isObjCPropertyDecl() {
   if (!ThisDeclInfo)
 return false;

diff 

[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rG3506e42ab67e: Comment AST: Factor out function type 
extraction in DeclInfo::fill (NFC) (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111262

Files:
  clang/lib/AST/Comment.cpp

Index: clang/lib/AST/Comment.cpp
===
--- clang/lib/AST/Comment.cpp
+++ clang/lib/AST/Comment.cpp
@@ -221,6 +221,7 @@
   CurrentDecl = CommentDecl;
 
   Decl::Kind K = CommentDecl->getKind();
+  const TypeSourceInfo *TSI = nullptr;
   switch (K) {
   default:
 // Defaults are should be good for declarations we don't handle explicitly.
@@ -297,72 +298,46 @@
   case Decl::EnumConstant:
   case Decl::ObjCIvar:
   case Decl::ObjCAtDefsField:
-  case Decl::ObjCProperty: {
-const TypeSourceInfo *TSI;
+  case Decl::ObjCProperty:
 if (const auto *VD = dyn_cast(CommentDecl))
   TSI = VD->getTypeSourceInfo();
 else if (const auto *PD = dyn_cast(CommentDecl))
   TSI = PD->getTypeSourceInfo();
-else
-  TSI = nullptr;
-if (TSI) {
-  TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
-  FunctionTypeLoc FTL;
-  if (getFunctionTypeLoc(TL, FTL)) {
-ParamVars = FTL.getParams();
-ReturnType = FTL.getReturnLoc().getType();
-  }
-}
 Kind = VariableKind;
 break;
-  }
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;
   case Decl::TypeAlias:
-  case Decl::Typedef: {
+  case Decl::Typedef:
 Kind = TypedefKind;
-// If this is a typedef / using to something we consider a function, extract
-// arguments and return type.
-const TypeSourceInfo *TSI =
-K == Decl::Typedef
-? cast(CommentDecl)->getTypeSourceInfo()
-: cast(CommentDecl)->getTypeSourceInfo();
-if (!TSI)
-  break;
-TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
-FunctionTypeLoc FTL;
-if (getFunctionTypeLoc(TL, FTL)) {
-  Kind = FunctionKind;
-  ParamVars = FTL.getParams();
-  ReturnType = FTL.getReturnLoc().getType();
-}
+TSI = cast(CommentDecl)->getTypeSourceInfo();
 break;
-  }
   case Decl::TypeAliasTemplate: {
 const TypeAliasTemplateDecl *TAT = cast(CommentDecl);
 Kind = TypedefKind;
 TemplateKind = Template;
 TemplateParameters = TAT->getTemplateParameters();
-TypeAliasDecl *TAD = TAT->getTemplatedDecl();
-if (!TAD)
-  break;
+if (TypeAliasDecl *TAD = TAT->getTemplatedDecl())
+  TSI = TAD->getTypeSourceInfo();
+break;
+  }
+  case Decl::Enum:
+Kind = EnumKind;
+break;
+  }
 
-const TypeSourceInfo *TSI = TAD->getTypeSourceInfo();
-if (!TSI)
-  break;
+  // If the type is a typedef / using to something we consider a function,
+  // extract arguments and return type.
+  if (TSI) {
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
 FunctionTypeLoc FTL;
 if (getFunctionTypeLoc(TL, FTL)) {
-  Kind = FunctionKind;
+  if (Kind == TypedefKind)
+Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
 }
-break;
-  }
-  case Decl::Enum:
-Kind = EnumKind;
-break;
   }
 
   IsFilled = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3506e42 - Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

2021-11-09 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-11-09T22:30:08+01:00
New Revision: 3506e42ab67eef41a1f27e180e7c552a27bb

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

LOG: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/lib/AST/Comment.cpp

Removed: 




diff  --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index a02cc9d119fe..94f65466ad10 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -221,6 +221,7 @@ void DeclInfo::fill() {
   CurrentDecl = CommentDecl;
 
   Decl::Kind K = CommentDecl->getKind();
+  const TypeSourceInfo *TSI = nullptr;
   switch (K) {
   default:
 // Defaults are should be good for declarations we don't handle explicitly.
@@ -297,72 +298,46 @@ void DeclInfo::fill() {
   case Decl::EnumConstant:
   case Decl::ObjCIvar:
   case Decl::ObjCAtDefsField:
-  case Decl::ObjCProperty: {
-const TypeSourceInfo *TSI;
+  case Decl::ObjCProperty:
 if (const auto *VD = dyn_cast(CommentDecl))
   TSI = VD->getTypeSourceInfo();
 else if (const auto *PD = dyn_cast(CommentDecl))
   TSI = PD->getTypeSourceInfo();
-else
-  TSI = nullptr;
-if (TSI) {
-  TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
-  FunctionTypeLoc FTL;
-  if (getFunctionTypeLoc(TL, FTL)) {
-ParamVars = FTL.getParams();
-ReturnType = FTL.getReturnLoc().getType();
-  }
-}
 Kind = VariableKind;
 break;
-  }
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;
   case Decl::TypeAlias:
-  case Decl::Typedef: {
+  case Decl::Typedef:
 Kind = TypedefKind;
-// If this is a typedef / using to something we consider a function, 
extract
-// arguments and return type.
-const TypeSourceInfo *TSI =
-K == Decl::Typedef
-? cast(CommentDecl)->getTypeSourceInfo()
-: cast(CommentDecl)->getTypeSourceInfo();
-if (!TSI)
-  break;
-TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
-FunctionTypeLoc FTL;
-if (getFunctionTypeLoc(TL, FTL)) {
-  Kind = FunctionKind;
-  ParamVars = FTL.getParams();
-  ReturnType = FTL.getReturnLoc().getType();
-}
+TSI = cast(CommentDecl)->getTypeSourceInfo();
 break;
-  }
   case Decl::TypeAliasTemplate: {
 const TypeAliasTemplateDecl *TAT = 
cast(CommentDecl);
 Kind = TypedefKind;
 TemplateKind = Template;
 TemplateParameters = TAT->getTemplateParameters();
-TypeAliasDecl *TAD = TAT->getTemplatedDecl();
-if (!TAD)
-  break;
+if (TypeAliasDecl *TAD = TAT->getTemplatedDecl())
+  TSI = TAD->getTypeSourceInfo();
+break;
+  }
+  case Decl::Enum:
+Kind = EnumKind;
+break;
+  }
 
-const TypeSourceInfo *TSI = TAD->getTypeSourceInfo();
-if (!TSI)
-  break;
+  // If the type is a typedef / using to something we consider a function,
+  // extract arguments and return type.
+  if (TSI) {
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
 FunctionTypeLoc FTL;
 if (getFunctionTypeLoc(TL, FTL)) {
-  Kind = FunctionKind;
+  if (Kind == TypedefKind)
+Kind = FunctionKind;
   ParamVars = FTL.getParams();
   ReturnType = FTL.getReturnLoc().getType();
 }
-break;
-  }
-  case Decl::Enum:
-Kind = EnumKind;
-break;
   }
 
   IsFilled = true;



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


[PATCH] D111264: Comment AST: Declare function pointer variables as functions

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D111264#3115104 , @gribozavr2 
wrote:

> I feel uneasy about claiming that variable decls of function type are 
> FunctionKind for the purposes of comment parsing (even doing it for typedefs 
> is questionable). It seems like a better way would be to make "is function 
> like" an extra dimension that can be combined with any decl kind.

Agreed, I'll try to write a patch for that. Essentially we want to know if some 
kind of function type (or maybe just `FunctionProtoType`?) is involved in that 
declaration (without desugaring), either of a type declaration, or of the 
declared type of a non-type declaration. That's pretty much orthogonal to the 
kind. (Though it's of course incompatible with some kinds, such as `EnumKind` 
or `NamespaceKind`.)

I'm wondering about global lambdas declarations. These should have class type, 
but also have parameters like a function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111264

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2021-11-09 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added a comment.

Ping.

`clang-format` is the only check failing as of now (attempting to reformat the 
`` links in doc comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[PATCH] D113474: [clang] Don't crash on an incomplete-type base specifier in template context.

2021-11-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG603c1a62f859: [clang] Dont crash on an incomplete-type 
base specifier in template context. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113474

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/base-class-ambiguity-check.cpp
  clang/test/SemaCXX/ms-interface.cpp


Index: clang/test/SemaCXX/ms-interface.cpp
===
--- clang/test/SemaCXX/ms-interface.cpp
+++ clang/test/SemaCXX/ms-interface.cpp
@@ -106,3 +106,10 @@
 static_assert(!__is_interface_class(IUnknown), "oops");
 static_assert(!__is_interface_class(IFaceStruct), "oops");
 static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");
+
+template
+class TemplateContext {
+  class Base;
+  // Should not crash on an incomplete-type and dependent base specifier.
+  __interface Foo : Base {};
+};
Index: clang/test/SemaCXX/base-class-ambiguity-check.cpp
===
--- clang/test/SemaCXX/base-class-ambiguity-check.cpp
+++ clang/test/SemaCXX/base-class-ambiguity-check.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  class Foo {
   struct Base : T {};
@@ -7,3 +6,14 @@
   // Test that this code no longer causes a crash in Sema. rdar://23291875
   struct Derived : Base, T {};
 };
+
+
+template  struct Foo2 {
+  struct Base1; // expected-note{{member is declared here}}
+  struct Base2; // expected-note{{member is declared here}}
+  // Should not crash on an incomplete-type and dependent base specifier.
+  struct Derived : Base1, Base2 {}; // expected-error {{implicit instantiation 
of undefined member 'Foo2::Base1'}} \
+   expected-error {{implicit instantiation 
of undefined member 'Foo2::Base2'}}
+};
+
+Foo2::Derived a; // expected-note{{in instantiation of member class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2729,6 +2729,8 @@
   KnownBase = Bases[idx];
   Bases[NumGoodBases++] = Bases[idx];
 
+  if (NewBaseType->isDependentType())
+continue;
   // Note this base's direct & indirect bases, if there could be ambiguity.
   if (Bases.size() > 1)
 NoteIndirectBases(Context, IndirectBaseTypes, NewBaseType);
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -178,6 +178,8 @@
   SmallVector WorkList = {StartRD};
   while (!WorkList.empty()) {
 const CXXRecordDecl *RD = WorkList.pop_back_val();
+if (RD->getTypeForDecl()->isDependentType())
+  continue;
 for (const CXXBaseSpecifier  : RD->bases()) {
   if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) {
 if (!SeenBaseTypes.insert(B).second)


Index: clang/test/SemaCXX/ms-interface.cpp
===
--- clang/test/SemaCXX/ms-interface.cpp
+++ clang/test/SemaCXX/ms-interface.cpp
@@ -106,3 +106,10 @@
 static_assert(!__is_interface_class(IUnknown), "oops");
 static_assert(!__is_interface_class(IFaceStruct), "oops");
 static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");
+
+template
+class TemplateContext {
+  class Base;
+  // Should not crash on an incomplete-type and dependent base specifier.
+  __interface Foo : Base {};
+};
Index: clang/test/SemaCXX/base-class-ambiguity-check.cpp
===
--- clang/test/SemaCXX/base-class-ambiguity-check.cpp
+++ clang/test/SemaCXX/base-class-ambiguity-check.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  class Foo {
   struct Base : T {};
@@ -7,3 +6,14 @@
   // Test that this code no longer causes a crash in Sema. rdar://23291875
   struct Derived : Base, T {};
 };
+
+
+template  struct Foo2 {
+  struct Base1; // expected-note{{member is declared here}}
+  struct Base2; // expected-note{{member is declared here}}
+  // Should not crash on an incomplete-type and dependent base specifier.
+  struct Derived : Base1, Base2 {}; // expected-error {{implicit instantiation of undefined member 'Foo2::Base1'}} \
+   expected-error {{implicit instantiation of undefined member 'Foo2::Base2'}}
+};
+
+Foo2::Derived a; // expected-note{{in instantiation of member class}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2729,6 +2729,8 @@
   KnownBase = Bases[idx];
  

[clang] 603c1a6 - [clang] Don't crash on an incomplete-type base specifier in template context.

2021-11-09 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-11-09T22:17:47+01:00
New Revision: 603c1a62f8595f70c3e96ecbec8976d411c0cc08

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

LOG: [clang] Don't crash on an incomplete-type base specifier in template 
context.

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

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/base-class-ambiguity-check.cpp
clang/test/SemaCXX/ms-interface.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 945c935640d54..1780358cc3484 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -178,6 +178,8 @@ static bool hasRepeatedBaseClass(const CXXRecordDecl 
*StartRD) {
   SmallVector WorkList = {StartRD};
   while (!WorkList.empty()) {
 const CXXRecordDecl *RD = WorkList.pop_back_val();
+if (RD->getTypeForDecl()->isDependentType())
+  continue;
 for (const CXXBaseSpecifier  : RD->bases()) {
   if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) {
 if (!SeenBaseTypes.insert(B).second)

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 562d10313ec93..d67e039dd26cc 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2729,6 +2729,8 @@ bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class,
   KnownBase = Bases[idx];
   Bases[NumGoodBases++] = Bases[idx];
 
+  if (NewBaseType->isDependentType())
+continue;
   // Note this base's direct & indirect bases, if there could be ambiguity.
   if (Bases.size() > 1)
 NoteIndirectBases(Context, IndirectBaseTypes, NewBaseType);

diff  --git a/clang/test/SemaCXX/base-class-ambiguity-check.cpp 
b/clang/test/SemaCXX/base-class-ambiguity-check.cpp
index fc1c4c2cea5ec..a7f5ee1d77106 100644
--- a/clang/test/SemaCXX/base-class-ambiguity-check.cpp
+++ b/clang/test/SemaCXX/base-class-ambiguity-check.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 template  class Foo {
   struct Base : T {};
@@ -7,3 +6,14 @@ template  class Foo {
   // Test that this code no longer causes a crash in Sema. rdar://23291875
   struct Derived : Base, T {};
 };
+
+
+template  struct Foo2 {
+  struct Base1; // expected-note{{member is declared here}}
+  struct Base2; // expected-note{{member is declared here}}
+  // Should not crash on an incomplete-type and dependent base specifier.
+  struct Derived : Base1, Base2 {}; // expected-error {{implicit instantiation 
of undefined member 'Foo2::Base1'}} \
+   expected-error {{implicit instantiation 
of undefined member 'Foo2::Base2'}}
+};
+
+Foo2::Derived a; // expected-note{{in instantiation of member class}}

diff  --git a/clang/test/SemaCXX/ms-interface.cpp 
b/clang/test/SemaCXX/ms-interface.cpp
index c827f4c5703c4..67294f761d030 100644
--- a/clang/test/SemaCXX/ms-interface.cpp
+++ b/clang/test/SemaCXX/ms-interface.cpp
@@ -106,3 +106,10 @@ static_assert(!__is_interface_class(HasProp), "oops");
 static_assert(!__is_interface_class(IUnknown), "oops");
 static_assert(!__is_interface_class(IFaceStruct), "oops");
 static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");
+
+template
+class TemplateContext {
+  class Base;
+  // Should not crash on an incomplete-type and dependent base specifier.
+  __interface Foo : Base {};
+};



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


[PATCH] D112868: [CodeGen] Diagnose and reject non-function ifunc resolvers

2021-11-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

I assume that dancing with GlobalValue makes this difficult to implement in 
lib/Sema.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

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


[PATCH] D113320: [clang-format] Address fixme

2021-11-09 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66336056911e: [clang-format] Address fixme (authored by 
HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113320

Files:
  clang/lib/Format/TokenAnnotator.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h


Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -19,8 +19,8 @@
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
-#include 
 #include 
+#include 
 
 namespace clang {
 namespace format {
@@ -36,9 +36,8 @@
 struct UnwrappedLine {
   UnwrappedLine();
 
-  // FIXME: Don't use std::list here.
   /// The \c Tokens comprising this \c UnwrappedLine.
-  std::list Tokens;
+  std::vector Tokens;
 
   /// The indent level of the \c UnwrappedLine.
   unsigned Level;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -3034,24 +3034,15 @@
   llvm::dbgs() << Prefix << "Line(" << Line.Level
<< ", FSC=" << Line.FirstStartColumn << ")"
<< (Line.InPPDirective ? " MACRO" : "") << ": ";
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-llvm::dbgs() << I->Tok->Tok.getName() << "["
- << "T=" << (unsigned)I->Tok->getType()
- << ", OC=" << I->Tok->OriginalColumn << "] ";
-  }
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-const UnwrappedLineNode  = *I;
-for (SmallVectorImpl::const_iterator
- I = Node.Children.begin(),
- E = Node.Children.end();
- I != E; ++I) {
-  printDebugInfo(*I, "\nChild: ");
-}
+  for (const auto  : Line.Tokens) {
+llvm::dbgs() << Node.Tok->Tok.getName() << "["
+ << "T=" << static_cast(Node.Tok->getType())
+ << ", OC=" << Node.Tok->OriginalColumn << "] ";
   }
+  for (const auto  : Line.Tokens)
+for (const auto  : Node.Children)
+  printDebugInfo(ChildNode, "\nChild: ");
+
   llvm::dbgs() << "\n";
 }
 
Index: clang/lib/Format/TokenAnnotator.h
===
--- clang/lib/Format/TokenAnnotator.h
+++ clang/lib/Format/TokenAnnotator.h
@@ -53,9 +53,7 @@
 // left them in a different state.
 First->Previous = nullptr;
 FormatToken *Current = First;
-for (std::list::const_iterator I = 
++Line.Tokens.begin(),
-  E = Line.Tokens.end();
- I != E; ++I) {
+for (auto I = ++Line.Tokens.begin(), E = Line.Tokens.end(); I != E; ++I) {
   const UnwrappedLineNode  = *I;
   Current->Next = I->Tok;
   I->Tok->Previous = Current;


Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -19,8 +19,8 @@
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
-#include 
 #include 
+#include 
 
 namespace clang {
 namespace format {
@@ -36,9 +36,8 @@
 struct UnwrappedLine {
   UnwrappedLine();
 
-  // FIXME: Don't use std::list here.
   /// The \c Tokens comprising this \c UnwrappedLine.
-  std::list Tokens;
+  std::vector Tokens;
 
   /// The indent level of the \c UnwrappedLine.
   unsigned Level;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -3034,24 +3034,15 @@
   llvm::dbgs() << Prefix << "Line(" << Line.Level
<< ", FSC=" << Line.FirstStartColumn << ")"
<< (Line.InPPDirective ? " MACRO" : "") << ": ";
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-llvm::dbgs() << I->Tok->Tok.getName() << "["
- << "T=" << (unsigned)I->Tok->getType()
- << ", OC=" << I->Tok->OriginalColumn << "] ";
-  }
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-const UnwrappedLineNode  = *I;
-for (SmallVectorImpl::const_iterator
- I = Node.Children.begin(),
- E = 

[clang] 6facafe - [clang-format] Refactor SpaceBeforeParens to add options

2021-11-09 Thread Björn Schäpers via cfe-commits

Author: C. Rayroud
Date: 2021-11-09T21:51:45+01:00
New Revision: 6facafe7da59eb02e8c1519670b503efda2f4b58

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

LOG: [clang-format] Refactor SpaceBeforeParens to add options

The coding style of some projects requires to have more control on space
before opening parentheses.
The goal is to add the support of clang-format to more projects.
For example adding a space only for function definitions or
declarations.
This revision adds SpaceBeforeParensOptions to configure each option
independently from one another.

Differentiel Revision: https://reviews.llvm.org/D110833

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 2d4e1b56dcb59..5fd9f225f753a 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3618,7 +3618,7 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
-**SpaceBeforeParens** (``SpaceBeforeParensOptions``) 
:versionbadge:`clang-format 3.5`
+**SpaceBeforeParens** (``SpaceBeforeParensStyle``) :versionbadge:`clang-format 
3.5`
   Defines in which cases to put a space before opening parentheses.
 
   Possible values:
@@ -3688,6 +3688,78 @@ the configuration (without a prefix: ``Auto``).
  }
}
 
+  * ``SBPO_Custom`` (in configuration: ``Custom``)
+Configure each individual space before parentheses in
+`SpaceBeforeParensOptions`.
+
+
+
+**SpaceBeforeParensOptions** (``SpaceBeforeParensCustom``) 
:versionbadge:`clang-format 14`
+  Control of individual space before parentheses.
+
+  If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
+  how each individual space before parentheses case should be handled.
+  Otherwise, this is ignored.
+
+  .. code-block:: yaml
+
+# Example of usage:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+  AfterControlStatements: true
+  AfterFunctionDefinitionName: true
+
+  Nested configuration flags:
+
+
+  * ``bool AfterControlStatements`` If ``true``, put space betwee control 
statement keywords
+(for/if/while...) and opening parentheses.
+
+.. code-block:: c++
+
+   true:  false:
+   if (...) {} vs.if(...) {}
+
+  * ``bool AfterForeachMacros`` If ``true``, put space between foreach macros 
and opening parentheses.
+
+.. code-block:: c++
+
+   true:  false:
+   FOREACH (...)   vs.FOREACH(...)
+ 
+
+  * ``bool AfterFunctionDeclarationName`` If ``true``, put a space between 
function declaration name and opening
+parentheses.
+
+.. code-block:: c++
+
+   true:  false:
+   void f ();  vs.void f();
+
+  * ``bool AfterFunctionDefinitionName`` If ``true``, put a space between 
function definition name and opening
+parentheses.
+
+.. code-block:: c++
+
+   true:  false:
+   void f () {}vs.void f() {}
+
+  * ``bool AfterIfMacros`` If ``true``, put space between if macros and 
opening parentheses.
+
+.. code-block:: c++
+
+   true:  false:
+   IF (...)vs.IF(...)
+  
+
+  * ``bool BeforeNonEmptyParentheses`` If ``true``, put a space before opening 
parentheses only if the
+parentheses are not empty.
+
+.. code-block:: c++
+
+   true:  false:
+   void f (int a); vs.void f();
+   f (a); f();
 
 
 **SpaceBeforeRangeBasedForLoopColon** (``Boolean``) 
:versionbadge:`clang-format 7`

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fd3217c29e67e..57c5150becae7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -244,6 +244,10 @@ clang-format
   `const` `volatile` `static` `inline` `constexpr` `restrict`
   to be controlled relative to the `type`.
 
+- Add a ``Custom`` style to ``SpaceBeforeParens``, to better configure the
+  space before parentheses. The custom options can be set using
+  ``SpaceBeforeParensOptions``.
+
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 

[clang] 6633605 - [clang-format] Address fixme

2021-11-09 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2021-11-09T21:51:44+01:00
New Revision: 66336056911ec1377837ebfe323814521f78d367

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

LOG: [clang-format] Address fixme

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.h 
b/clang/lib/Format/TokenAnnotator.h
index 0f9c02dbeb34b..6e5e62cd4d82a 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -53,9 +53,7 @@ class AnnotatedLine {
 // left them in a 
diff erent state.
 First->Previous = nullptr;
 FormatToken *Current = First;
-for (std::list::const_iterator I = 
++Line.Tokens.begin(),
-  E = Line.Tokens.end();
- I != E; ++I) {
+for (auto I = ++Line.Tokens.begin(), E = Line.Tokens.end(); I != E; ++I) {
   const UnwrappedLineNode  = *I;
   Current->Next = I->Tok;
   I->Tok->Previous = Current;

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index ef1785bd54692..ae38e387f1df2 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -3034,24 +3034,15 @@ LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const 
UnwrappedLine ,
   llvm::dbgs() << Prefix << "Line(" << Line.Level
<< ", FSC=" << Line.FirstStartColumn << ")"
<< (Line.InPPDirective ? " MACRO" : "") << ": ";
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-llvm::dbgs() << I->Tok->Tok.getName() << "["
- << "T=" << (unsigned)I->Tok->getType()
- << ", OC=" << I->Tok->OriginalColumn << "] ";
-  }
-  for (std::list::const_iterator I = Line.Tokens.begin(),
-E = Line.Tokens.end();
-   I != E; ++I) {
-const UnwrappedLineNode  = *I;
-for (SmallVectorImpl::const_iterator
- I = Node.Children.begin(),
- E = Node.Children.end();
- I != E; ++I) {
-  printDebugInfo(*I, "\nChild: ");
-}
+  for (const auto  : Line.Tokens) {
+llvm::dbgs() << Node.Tok->Tok.getName() << "["
+ << "T=" << static_cast(Node.Tok->getType())
+ << ", OC=" << Node.Tok->OriginalColumn << "] ";
   }
+  for (const auto  : Line.Tokens)
+for (const auto  : Node.Children)
+  printDebugInfo(ChildNode, "\nChild: ");
+
   llvm::dbgs() << "\n";
 }
 

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index f22bb6323e3d7..457d41655a628 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -19,8 +19,8 @@
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
-#include 
 #include 
+#include 
 
 namespace clang {
 namespace format {
@@ -36,9 +36,8 @@ struct UnwrappedLineNode;
 struct UnwrappedLine {
   UnwrappedLine();
 
-  // FIXME: Don't use std::list here.
   /// The \c Tokens comprising this \c UnwrappedLine.
-  std::list Tokens;
+  std::vector Tokens;
 
   /// The indent level of the \c UnwrappedLine.
   unsigned Level;



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


[PATCH] D111262: Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

2021-11-09 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked an inline comment as done.
aaronpuchert added a comment.

Thanks for the review!




Comment at: clang/lib/AST/Comment.cpp:337
+  if (Kind == TypedefKind)
+Kind = FunctionKind;
   ParamVars = FTL.getParams();

gribozavr2 wrote:
> Phabricator shows a `>>` chevron on this line, which might be an accidental 
> tab. If it is one, please replace with spaces.
This seems to be Phabricator's way of indicating that the line has been 
indented. Not sure why they're using this (arguably misleading) symbol for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111262

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


[PATCH] D98895: [X86][clang] Disable long double type for -mno-x87 option

2021-11-09 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

> @asavonic I spoke offline with @erichkeane. I was mistaken. There are only 2 
> error diagnostics generated (upstream) after this patch. The additional 
> diagnostic generated at `bar ` after your patch is correct. We just need to 
> remove the third diagnostic downstream. So nothing needs to be done here. I 
> apologize for the confusion and trouble.

No worries. Thanks a lot for checking this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895

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


[PATCH] D112221: Mark ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT as deprecated

2021-11-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

> I don't know enough about libc++ to feel comfortable making those changes 
> yet. For example, does libc++ need to work with other compilers than Clang 
> (compilers which might give diagnostics if you fail to use ATOMIC_VAR_INIT in 
> some language mode)? The deprecation is not really a DR, so should the uses 
> be wrapped in language version checks, etc. Or are you saying I don't have to 
> worry about any of that and I can rip this stuff out of libc++ with wild 
> abandon?

@ldionne will be the ultimate arbiter, but FWIW, //I think// you can rip with 
wild abandon — certainly from `libcxx/src/`.
For some background (and further links, including p0883 which you've already 
dug up), see
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2139r2.html#3.24

There are two kinds of places libc++ uses these macros: `src/` and `test/`. 
Everywhere in `src/` is compiled with C++17, so it's totally safe to use 
`atomic a{init};` instead of `atomic a = ATOMIC_VAR_INIT(init);`.
But everywhere in `test/` we need to keep working, by definition. They might 
have to gain a line `ADDITIONAL_COMPILE_FLAGS: 
-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS` or (new and therefore worse) 
`ADDITIONAL_COMPILE_FLAGS: -Wno-deprecated`, but that's all.

Here's the diffs in `src/` AFAICT [untested code]:

  diff --git a/libcxx/src/barrier.cpp b/libcxx/src/barrier.cpp
  index 9ee476993b81..8e13ad088052 100644
  --- a/libcxx/src/barrier.cpp
  +++ b/libcxx/src/barrier.cpp
  @@ -22,7 +22,7 @@ public:
   struct alignas(64) /* naturally-align the heap state */ __state_t
   {
   struct {
  -__atomic_base<__barrier_phase_t> __phase = ATOMIC_VAR_INIT(0);
  +__atomic_base<__barrier_phase_t> __phase{0};
   } __tickets[64];
   };
   
  diff --git a/libcxx/src/experimental/memory_resource.cpp 
b/libcxx/src/experimental/memory_resource.cpp
  index 5f9d3b8a4cbe..77a1d654d60f 100644
  --- a/libcxx/src/experimental/memory_resource.cpp
  +++ b/libcxx/src/experimental/memory_resource.cpp
  @@ -97,8 +97,7 @@ static memory_resource *
   __default_memory_resource(bool set = false, memory_resource * new_res = 
nullptr) noexcept
   {
   #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
  -_LIBCPP_SAFE_STATIC static atomic __res =
  -ATOMIC_VAR_INIT(_init.resources.new_delete_res);
  +_LIBCPP_SAFE_STATIC static atomic 
__res{_init.resources.new_delete_res};
   if (set) {
   new_res = new_res ? new_res : new_delete_resource();
   // TODO: Can a weaker ordering be used?
  diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp
  index a8a99015a977..338636b2220e 100644
  --- a/libcxx/src/ios.cpp
  +++ b/libcxx/src/ios.cpp
  @@ -137,7 +137,7 @@ ios_base::getloc() const
   
   // xalloc
   #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
  -atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
  +atomic ios_base::__xindex_{0};
   #else
   int ios_base::__xindex_ = 0;
   #endif
  diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp 
b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
  index 365b895e0603..beee6f8fcfdd 100644
  --- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
  +++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
  @@ -33,7 +33,7 @@
   typedef std::chrono::high_resolution_clock Clock;
   typedef std::chrono::milliseconds ms;
   
  -std::atomic_bool invoked = ATOMIC_VAR_INIT(false);
  +std::atomic_bool invoked{false};
   
   int f0()
   {




Comment at: clang/lib/Headers/stdatomic.h:42-47
 #define ATOMIC_VAR_INIT(value) (value)
+#if __STDC_VERSION__ >= 201710L || __cplusplus >= 202002L
+/* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
+#pragma clang deprecated(ATOMIC_VAR_INIT)
+#endif
 #define atomic_init __c11_atomic_init

Hmm, I do think there ought to be some way for the C++20 programmer to suppress 
the deprecation warning for these macros (specifically, not just via 
`-Wno-deprecated` in their whole project). For deprecations in the C++ standard 
library, libc++ offers an all-or-nothing flag: basically you'd do
```
#if (__STDC_VERSION__ >= 201710L || __cplusplus >= 202002L) && 
!defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
/* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
#pragma clang deprecated(ATOMIC_VAR_INIT)
#endif
```
(This also makes it easy for libcxx/test/ to suppress the deprecation warning 
for the purposes of testing.)

However, I'm not sure if it's appropriate to mention 
`_LIBCPP_DISABLE_DEPRECATION_WARNINGS` in this header located in 
clang/lib/Headers/ instead of libcxx/include/. Someone else will have to make 
that call.

It might be that the only way for the programmer (or libcxx/test/) to work 
around the warning will be for them to pass `-Wno-deprecated` globally; IMO 
that is suboptimal but quite far from disastrous.


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


[PATCH] D113490: [NFC] Let Microsoft mangler accept GlobalDecl

2021-11-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:47
+  if (auto *CD = dyn_cast(DC))
+GD = GlobalDecl(CD, Ctor_Complete);
+  else if (auto *DD = dyn_cast(DC))

I would prefer if you passed Ctor_Base and Dtor_Base here. I believe MSVC 
models the variants as separate compiler-generated functions. I believe the 
user code is always emitted into the "base" variant. That's consistent with 
what the user can observe in `__FUNCDNAME__`, see here:
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/Expr.cpp#L635



Comment at: clang/lib/AST/MicrosoftMangle.cpp:345
 
   MicrosoftCXXNameMangler(MicrosoftMangleContextImpl , raw_ostream _,
   const CXXConstructorDecl *D, CXXCtorType Type)

I would like to remove these constructor overloads, but I don't feel like I can 
ask you to do it.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:1250
   if (const FunctionDecl *FD = dyn_cast(ND)) {
-mangle(FD, "?");
+mangle(getGlobalDeclAsDeclContext(FD), "?");
 break;

So, nested calls to `mangle` seem like they mostly come up when you have 
entities inside function scopes. I think when we have things inside structors, 
we want to mangle using the base ctor/dtor variant.


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

https://reviews.llvm.org/D113490

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


[PATCH] D113428: [AIX] Define WCHAR_T_TYPE as unsigned int on 64-bit AIX for wchar.c test

2021-11-09 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113428

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


[PATCH] D113507: [clang-tidy] Include constructor initializers in `bugprone-exception-escape` check

2021-11-09 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: alexfh, aaron.ballman.
fwolff added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes PR#52435.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113507

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
@@ -288,6 +288,15 @@
   return recursion_helper(n);
 }
 
+struct super_throws {
+  super_throws() noexcept(false) { throw 42; }
+};
+
+struct sub_throws : super_throws {
+  sub_throws() noexcept : super_throws() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in 
function 'sub_throws' which should not throw exceptions
+};
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'main' which should not throw exceptions
   throw 1;
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -119,6 +119,16 @@
 CallStack.insert(Func);
 ExceptionInfo Result =
 throwsException(Body, ExceptionInfo::Throwables(), CallStack);
+
+// For a constructor, we also have to check the initializers.
+if (const auto *Ctor = dyn_cast(Func)) {
+  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+ExceptionInfo Excs = throwsException(
+Init->getInit(), ExceptionInfo::Throwables(), CallStack);
+Result.merge(Excs);
+  }
+}
+
 CallStack.erase(Func);
 return Result;
   }
@@ -195,6 +205,10 @@
   ExceptionInfo Excs = throwsException(Func, CallStack);
   Results.merge(Excs);
 }
+  } else if (const auto *Construct = dyn_cast(St)) {
+ExceptionInfo Excs =
+throwsException(Construct->getConstructor(), CallStack);
+Results.merge(Excs);
   } else {
 for (const Stmt *Child : St->children()) {
   ExceptionInfo Excs = throwsException(Child, Caught, CallStack);


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
@@ -288,6 +288,15 @@
   return recursion_helper(n);
 }
 
+struct super_throws {
+  super_throws() noexcept(false) { throw 42; }
+};
+
+struct sub_throws : super_throws {
+  sub_throws() noexcept : super_throws() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function 'sub_throws' which should not throw exceptions
+};
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'main' which should not throw exceptions
   throw 1;
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -119,6 +119,16 @@
 CallStack.insert(Func);
 ExceptionInfo Result =
 throwsException(Body, ExceptionInfo::Throwables(), CallStack);
+
+// For a constructor, we also have to check the initializers.
+if (const auto *Ctor = dyn_cast(Func)) {
+  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+ExceptionInfo Excs = throwsException(
+Init->getInit(), ExceptionInfo::Throwables(), CallStack);
+Result.merge(Excs);
+  }
+}
+
 CallStack.erase(Func);
 return Result;
   }
@@ -195,6 +205,10 @@
   ExceptionInfo Excs = throwsException(Func, CallStack);
   Results.merge(Excs);
 }
+  } else if (const auto *Construct = dyn_cast(St)) {
+ExceptionInfo Excs =
+throwsException(Construct->getConstructor(), CallStack);
+Results.merge(Excs);
   } else {
 for (const Stmt *Child : St->children()) {
   ExceptionInfo Excs = throwsException(Child, Caught, CallStack);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I've got no problem with this, but it could just as easily have happened in the 
other review.  Is there a reason not to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

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


[PATCH] D112868: [CodeGen] Diagnose and reject non-function ifunc resolvers

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein updated this revision to Diff 385926.
ibookstein added a comment.

rebase fix after adding parent NFC commits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112868

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-ifunc.c

Index: clang/test/CodeGen/attr-ifunc.c
===
--- clang/test/CodeGen/attr-ifunc.c
+++ clang/test/CodeGen/attr-ifunc.c
@@ -13,8 +13,7 @@
 void f1() __attribute__((ifunc("f1_ifunc")));
 // expected-error@-1 {{ifunc must point to a defined function}}
 
-void *f2_a() __attribute__((ifunc("f2_b")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((alias("f2_b")));
 void *f2_b() __attribute__((ifunc("f2_a")));
 // expected-error@-1 {{ifunc definition is part of a cycle}}
 
@@ -27,6 +26,15 @@
 void f4() __attribute__((ifunc("f4_ifunc")));
 // expected-error@-1 {{ifunc resolver function must return a pointer}}
 
+int f5_resolver_gvar;
+void f5() __attribute__((ifunc("f5_resolver_gvar")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
+void *f6_resolver_resolver() { return 0; }
+void *f6_resolver() __attribute__((ifunc("f6_resolver_resolver")));
+void f6() __attribute__((ifunc("f6_resolver")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+
 #else
 void f1a() __asm("f1");
 void f1a() {}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -318,21 +318,57 @@
 // This is only used in aliases that we created and we know they have a
 // linear structure.
 static const llvm::GlobalValue *getAliasedGlobal(const llvm::GlobalValue *GV) {
-  llvm::SmallPtrSet Visited;
-  for (;;) {
-if (!GV || !Visited.insert(GV).second)
-  return nullptr;
-
-const llvm::Constant *C;
-if (auto *GA = dyn_cast(GV))
-  C = GA->getAliasee();
-else if (auto *GI = dyn_cast(GV))
-  C = GI->getResolver();
-else
-  return GV;
+  const llvm::Constant *C;
+  if (auto *GA = dyn_cast(GV))
+C = GA->getAliasee();
+  else if (auto *GI = dyn_cast(GV))
+C = GI->getResolver();
+  else
+return GV;
+
+  const auto *AliaseeGV = dyn_cast(C->stripPointerCasts());
+  if (!AliaseeGV)
+return nullptr;
+
+  const llvm::GlobalValue *FinalGV = AliaseeGV->getAliaseeObject();
+  if (FinalGV == GV)
+return nullptr;
+
+  return FinalGV;
+}
+
+static bool checkAliasedGlobal(DiagnosticsEngine ,
+   SourceLocation Location, bool IsIFunc,
+   const llvm::GlobalValue *Alias,
+   const llvm::GlobalValue *) {
+  GV = getAliasedGlobal(Alias);
+  if (!GV) {
+Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
+return false;
+  }
+
+  if (GV->isDeclaration()) {
+Diags.Report(Location, diag::err_alias_to_undefined) << IsIFunc << IsIFunc;
+return false;
+  }
+
+  if (IsIFunc) {
+// Check resolver function type.
+const auto *F = dyn_cast(GV);
+if (!F) {
+  Diags.Report(Location, diag::err_alias_to_undefined)
+  << IsIFunc << IsIFunc;
+  return false;
+}
 
-GV = dyn_cast(C->stripPointerCasts());
+llvm::FunctionType *FTy = F->getFunctionType();
+if (!FTy->getReturnType()->isPointerTy()) {
+  Diags.Report(Location, diag::err_ifunc_resolver_return);
+  return false;
+}
   }
+
+  return true;
 }
 
 void CodeGenModule::checkAliases() {
@@ -349,23 +385,13 @@
   Location = A->getLocation();
 else
   llvm_unreachable("Not an alias or ifunc?");
+
 StringRef MangledName = getMangledName(GD);
 llvm::GlobalValue *Alias = GetGlobalValue(MangledName);
-const llvm::GlobalValue *GV = getAliasedGlobal(Alias);
-if (!GV) {
-  Error = true;
-  Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
-} else if (GV->isDeclaration()) {
+const llvm::GlobalValue *GV = nullptr;
+if (!checkAliasedGlobal(Diags, Location, IsIFunc, Alias, GV)) {
   Error = true;
-  Diags.Report(Location, diag::err_alias_to_undefined)
-  << IsIFunc << IsIFunc;
-} else if (IsIFunc) {
-  // Check resolver function type.
-  llvm::FunctionType *FTy = dyn_cast(
-  GV->getType()->getPointerElementType());
-  assert(FTy);
-  if (!FTy->getReturnType()->isPointerTy())
-Diags.Report(Location, diag::err_ifunc_resolver_return);
+  continue;
 }
 
 llvm::Constant *Aliasee =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113505: [NFC] Inclusive language: replace masterPort with mainPort

2021-11-09 Thread Quinn Pham via Phabricator via cfe-commits
quinnp created this revision.
quinnp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[NFC] This patch replaces `masterPort` with `mainPort` in these
testcases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113505

Files:
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/retain-release-inline.m
  clang/test/Analysis/retain-release.m
  clang/test/Analysis/retain-release.mm

Index: clang/test/Analysis/retain-release.mm
===
--- clang/test/Analysis/retain-release.mm
+++ clang/test/Analysis/retain-release.mm
@@ -175,14 +175,14 @@
 typedef io_object_t io_service_t;
 typedef struct IONotificationPort * IONotificationPortRef;
 typedef void (*IOServiceMatchingCallback)(  void * refcon,  io_iterator_t iterator );
-io_service_t IOServiceGetMatchingService(  mach_port_t masterPort,  CFDictionaryRef matching );
-kern_return_t IOServiceGetMatchingServices(  mach_port_t masterPort,  CFDictionaryRef matching,  io_iterator_t * existing );
-kern_return_t IOServiceAddNotification(  mach_port_t masterPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated));
+io_service_t IOServiceGetMatchingService(  mach_port_t mainPort,  CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices(  mach_port_t mainPort,  CFDictionaryRef matching,  io_iterator_t * existing );
+kern_return_t IOServiceAddNotification(  mach_port_t mainPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated));
 kern_return_t IOServiceAddMatchingNotification(  IONotificationPortRef notifyPort,  const io_name_t notificationType,  CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon,  io_iterator_t * notification );
 CFMutableDictionaryRef IOServiceMatching(  const char * name );
 CFMutableDictionaryRef IOServiceNameMatching(  const char * name );
-CFMutableDictionaryRef IOBSDNameMatching(  mach_port_t masterPort,  uint32_t options,  const char * bsdName );
-CFMutableDictionaryRef IOOpenFirmwarePathMatching(  mach_port_t masterPort,  uint32_t options,  const char * path );
+CFMutableDictionaryRef IOBSDNameMatching(  mach_port_t mainPort,  uint32_t options,  const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching(  mach_port_t mainPort,  uint32_t options,  const char * path );
 CFMutableDictionaryRef IORegistryEntryIDMatching(  uint64_t entryID );
 typedef struct __DASession * DASessionRef;
 extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
Index: clang/test/Analysis/retain-release.m
===
--- clang/test/Analysis/retain-release.m
+++ clang/test/Analysis/retain-release.m
@@ -233,14 +233,14 @@
 typedef io_object_t io_service_t;
 typedef struct IONotificationPort * IONotificationPortRef;
 typedef void (*IOServiceMatchingCallback)(  void * refcon,  io_iterator_t iterator );
-io_service_t IOServiceGetMatchingService(  mach_port_t masterPort,  CFDictionaryRef matching );
-kern_return_t IOServiceGetMatchingServices(  mach_port_t masterPort,  CFDictionaryRef matching,  io_iterator_t * existing );
-kern_return_t IOServiceAddNotification(  mach_port_t masterPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' has been explicitly marked deprecated here}}
+io_service_t IOServiceGetMatchingService(  mach_port_t mainPort,  CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices(  mach_port_t mainPort,  CFDictionaryRef matching,  io_iterator_t * existing );
+kern_return_t IOServiceAddNotification(  mach_port_t mainPort,  const io_name_t notificationType,  CFDictionaryRef matching,  mach_port_t wakePort,  uintptr_t reference,  io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' has been explicitly marked deprecated here}}
 kern_return_t IOServiceAddMatchingNotification(  IONotificationPortRef notifyPort,  const io_name_t notificationType,  CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon,  io_iterator_t * notification );
 CFMutableDictionaryRef IOServiceMatching(  const char * name );
 CFMutableDictionaryRef IOServiceNameMatching(  const char * name );
-CFMutableDictionaryRef IOBSDNameMatching(  mach_port_t masterPort,  uint32_t options,  const char * bsdName );

[PATCH] D113504: [clang][test][NFC] clang-format attr-ifunc.c test

2021-11-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This is something you can do as review-after-commit if you wish in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113504

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


[PATCH] D113431: [clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein updated this revision to Diff 385923.
ibookstein added a comment.

add parent clang-format commit to pass CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113431

Files:
  clang/test/CodeGen/attr-ifunc.c
  clang/test/Sema/attr-ifunc.c


Index: clang/test/Sema/attr-ifunc.c
===
--- /dev/null
+++ clang/test/Sema/attr-ifunc.c
@@ -1,43 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
-
-#if defined(_WIN32)
-void foo() {}
-void bar() __attribute__((ifunc("foo")));
-// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
-
-#else
-#if defined(CHECK_ALIASES)
-void *f1_ifunc();
-void f1() __attribute__((ifunc("f1_ifunc")));
-// expected-error@-1 {{ifunc must point to a defined function}}
-
-void *f2_a() __attribute__((ifunc("f2_b")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
-void *f2_b() __attribute__((ifunc("f2_a")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
-
-void *f3_a() __attribute__((ifunc("f3_b")));
-// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
-void *f3_b() __attribute__((weak, alias("f3_c")));
-void *f3_c() { return 0; }
-
-void f4_ifunc() {}
-void f4() __attribute__((ifunc("f4_ifunc")));
-// expected-error@-1 {{ifunc resolver function must return a pointer}}
-
-#else
-void f1a() __asm("f1");
-void f1a() {}
-// expected-note@-1 {{previous definition is here}}
-void f1() __attribute__((ifunc("f1_ifunc")));
-// expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
-void *f1_ifunc() { return 0; }
-
-void *f6_ifunc(int i);
-void __attribute__((ifunc("f6_ifunc"))) f6() {}
-// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
-
-#endif
-#endif


Index: clang/test/Sema/attr-ifunc.c
===
--- /dev/null
+++ clang/test/Sema/attr-ifunc.c
@@ -1,43 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_ALIASES %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
-
-#if defined(_WIN32)
-void foo() {}
-void bar() __attribute__((ifunc("foo")));
-// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
-
-#else
-#if defined(CHECK_ALIASES)
-void *f1_ifunc();
-void f1() __attribute__((ifunc("f1_ifunc")));
-// expected-error@-1 {{ifunc must point to a defined function}}
-
-void *f2_a() __attribute__((ifunc("f2_b")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
-void *f2_b() __attribute__((ifunc("f2_a")));
-// expected-error@-1 {{ifunc definition is part of a cycle}}
-
-void *f3_a() __attribute__((ifunc("f3_b")));
-// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
-void *f3_b() __attribute__((weak, alias("f3_c")));
-void *f3_c() { return 0; }
-
-void f4_ifunc() {}
-void f4() __attribute__((ifunc("f4_ifunc")));
-// expected-error@-1 {{ifunc resolver function must return a pointer}}
-
-#else
-void f1a() __asm("f1");
-void f1a() {}
-// expected-note@-1 {{previous definition is here}}
-void f1() __attribute__((ifunc("f1_ifunc")));
-// expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
-void *f1_ifunc() { return 0; }
-
-void *f6_ifunc(int i);
-void __attribute__((ifunc("f6_ifunc"))) f6() {}
-// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
-
-#endif
-#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113504: [clang][test][NFC] clang-format attr-ifunc.c test

2021-11-09 Thread Itay Bookstein via Phabricator via cfe-commits
ibookstein created this revision.
ibookstein added reviewers: erichkeane, aaron.ballman.
ibookstein requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Itay Bookstein 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113504

Files:
  clang/test/Sema/attr-ifunc.c


Index: clang/test/Sema/attr-ifunc.c
===
--- clang/test/Sema/attr-ifunc.c
+++ clang/test/Sema/attr-ifunc.c
@@ -5,39 +5,39 @@
 #if defined(_WIN32)
 void foo() {}
 void bar() __attribute__((ifunc("foo")));
-//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
+// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
 
 #else
 #if defined(CHECK_ALIASES)
-void* f1_ifunc();
+void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{ifunc must point to a defined function}}
+// expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
-void* f2_b() __attribute__((ifunc("f2_a")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((ifunc("f2_b")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_b() __attribute__((ifunc("f2_a")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
 
-void* f3_a() __attribute__((ifunc("f3_b")));
-//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
-void* f3_b() __attribute__((weak, alias("f3_c")));
-void* f3_c() { return 0; }
+void *f3_a() __attribute__((ifunc("f3_b")));
+// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak 
definition of f3_b is overridden}}
+void *f3_b() __attribute__((weak, alias("f3_c")));
+void *f3_c() { return 0; }
 
 void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
-//expected-error@-1 {{ifunc resolver function must return a pointer}}
+// expected-error@-1 {{ifunc resolver function must return a pointer}}
 
 #else
 void f1a() __asm("f1");
 void f1a() {}
-//expected-note@-1 {{previous definition is here}}
+// expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
-void* f1_ifunc() { return 0; }
+// expected-error@-1 {{definition with same mangled name 'f1' as another 
definition}}
+void *f1_ifunc() { return 0; }
 
-void* f6_ifunc(int i);
+void *f6_ifunc(int i);
 void __attribute__((ifunc("f6_ifunc"))) f6() {}
-//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+// expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
 
 #endif
 #endif


Index: clang/test/Sema/attr-ifunc.c
===
--- clang/test/Sema/attr-ifunc.c
+++ clang/test/Sema/attr-ifunc.c
@@ -5,39 +5,39 @@
 #if defined(_WIN32)
 void foo() {}
 void bar() __attribute__((ifunc("foo")));
-//expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
+// expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
 
 #else
 #if defined(CHECK_ALIASES)
-void* f1_ifunc();
+void *f1_ifunc();
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{ifunc must point to a defined function}}
+// expected-error@-1 {{ifunc must point to a defined function}}
 
-void* f2_a() __attribute__((ifunc("f2_b")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
-void* f2_b() __attribute__((ifunc("f2_a")));
-//expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_a() __attribute__((ifunc("f2_b")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
+void *f2_b() __attribute__((ifunc("f2_a")));
+// expected-error@-1 {{ifunc definition is part of a cycle}}
 
-void* f3_a() __attribute__((ifunc("f3_b")));
-//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
-void* f3_b() __attribute__((weak, alias("f3_c")));
-void* f3_c() { return 0; }
+void *f3_a() __attribute__((ifunc("f3_b")));
+// expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
+void *f3_b() __attribute__((weak, alias("f3_c")));
+void *f3_c() { return 0; }
 
 void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
-//expected-error@-1 {{ifunc resolver function must return a pointer}}
+// expected-error@-1 {{ifunc resolver function must return a pointer}}
 
 #else
 void f1a() __asm("f1");
 void f1a() {}
-//expected-note@-1 {{previous definition is here}}
+// expected-note@-1 {{previous definition is here}}
 void f1() __attribute__((ifunc("f1_ifunc")));
-//expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
-void* f1_ifunc() { return 0; }
+// expected-error@-1 {{definition with same mangled name 'f1' as another definition}}
+void *f1_ifunc() { return 0; }
 

[PATCH] D98895: [X86][clang] Disable long double type for -mno-x87 option

2021-11-09 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D98895#3119027 , @asavonic wrote:

> In D98895#3118821 , @eandrews wrote:
>
>> This patch causes a regression.
>>
>> To reproduce - `clang -cc1 -fsycl-is-device -triple spir64 test.cpp`
>>
>>   test.cpp:x:3: error: 'bar<__float128>' requires 128 bit size '__float128' 
>> type support, but target 'spir64' does not support it
>>   T bar() { return T(); };
>> ^
>>
>> I looked at it briefly, and I believe the issue is call to 
>> `checkTypeSupport()` in `ActOnFinishFunctionBody()`. I tried deleting the 
>> call but it breaks tests (E.g. L26 in x86_64-no-x87.cpp). @asavonic Please 
>> take a look. I will be reverting the patch if this cannot be fixed soon.
>
> The diagnostic seems to be correct - this instance of `bar` returns an 
> unsupported type. Why do you think it should not be diagnosed?

@asavonic I spoke offline with @erichkeane. I was mistaken. There are only 2 
error diagnostics generated (upstream) after this patch. The additional 
diagnostic generated at `bar ` after your patch is correct. We just need to 
remove the third diagnostic downstream. So nothing needs to be done here. I 
apologize for the confusion and trouble.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-11-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

I believe you have addressed John's comments, and I think the IR changes mainly 
affect AMDGPU users, so I don't think this will be too disruptive.

Sorry about the delay, there's a bit of a bystander effect at play here with 
multiple reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4290-4293
-  // Do not set COMDAT attribute for CUDA/HIP stub functions to prevent
-  // them being "merged" by the COMDAT Folding linker optimization.
-  if (D.hasAttr())
-return false;

rnk wrote:
> tra wrote:
> > This was added in D63277 specifically to deal with comdat-related issue on 
> > windows. 
> > 
> > We do need to have unique addresses for each kernel stub. Placing stubs 
> > into comdat may allow them to be merged into one and that would be a 
> > problem.
> > https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=vs-2019
> >  
> > 
> > @rnk,@kpyzhov -- how do we make sure that identical functions are placed in 
> > comdat (needed for templates) but do not get comdat-folded with `/OPT:ICF`? 
> > 
> These are readonly global variables. I believe MSVC's ICF implementation 
> changed behavior here a few times over the years. I think the current state 
> is that they don't merge such globals. If you are using LLD, you can use safe 
> ICF to avoid merging such globals.
> 
> @zequanwu reviewed the state of ICF in LLD in the last year, so he may know 
> more about the current status, and he may be more helpful if you have more 
> questions.
> 
> Finally, you could mark these globals as mutable if you really want to block 
> ICF. That will work reliably with any linker.
Broadly, I think this change is correct. If I had reviewed D63277, I probably 
would have objected to it and not approved it.


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

https://reviews.llvm.org/D112492

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


[PATCH] D113369: [clang-format] Extend SpaceBeforeParens for requires

2021-11-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM (nit the clang-format check)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113369

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


[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: zequanwu.
rnk added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4290-4293
-  // Do not set COMDAT attribute for CUDA/HIP stub functions to prevent
-  // them being "merged" by the COMDAT Folding linker optimization.
-  if (D.hasAttr())
-return false;

tra wrote:
> This was added in D63277 specifically to deal with comdat-related issue on 
> windows. 
> 
> We do need to have unique addresses for each kernel stub. Placing stubs into 
> comdat may allow them to be merged into one and that would be a problem.
> https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=vs-2019
>  
> 
> @rnk,@kpyzhov -- how do we make sure that identical functions are placed in 
> comdat (needed for templates) but do not get comdat-folded with `/OPT:ICF`? 
> 
These are readonly global variables. I believe MSVC's ICF implementation 
changed behavior here a few times over the years. I think the current state is 
that they don't merge such globals. If you are using LLD, you can use safe ICF 
to avoid merging such globals.

@zequanwu reviewed the state of ICF in LLD in the last year, so he may know 
more about the current status, and he may be more helpful if you have more 
questions.

Finally, you could mark these globals as mutable if you really want to block 
ICF. That will work reliably with any linker.


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

https://reviews.llvm.org/D112492

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


[PATCH] D113391: [Modules] Don't support clang module and c++20 module at the same time

2021-11-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

The ideal situation here would be to have a single semantic model that is a 
superset of the various combinations of behaviors we want. Further entrenching 
Clang modules and C++20 modules as being different things would be a backwards 
step, and would be harmful for users of Clang modules who want to incrementally 
adopt C++20 modules. We shouldn't have a separate language option flag for 
"clang modules" -- that should be a different kind of module, not a different 
compilation mode; if a clang header module needs different treatment from a 
C++20 header unit, we should base that on the kind of the current 
`clang::Module`, not on a language option.

In terms of what the various `LangOptions` flags mean:

`LangOptions::Modules` corresponds to the expectation that modular headers will 
be imported rather than entered textually.
`LangOptions::ModulesTS` enables C++ Modules TS language syntax. This 
corresponds to `-fmodules-ts`. We should probably deprecate it.
`LangOptions::CPlusPlusModules` enables C++20 modules syntax. This is enabled 
by `-std=c++20`.
`LangOptions::ModulesLocalVisibility` indicates that in this compilation, 
visibility is not monotonically increasing. This corresponds to 
`-fmodules-local-submodule-visibility`. This is the case when we might compile 
multiple source files or header units into a single AST, and we want to reset 
the visibility state at the end of each  such unit. For example, this happens 
when building a Clang module containing multiple headers. This really should be 
enabled automatically when appropriate, but for now it's enabled by default 
with `CPlusPlusModules` and `ModulesTS`.

The only combination that's incompatible here is `ModulesTS` plus 
`CPlusPlusModules`, because they have overlapping but different syntax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113391

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


[clang-tools-extra] 74add1b - Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"

2021-11-09 Thread Jorge Gorbe Moya via cfe-commits

Author: Jorge Gorbe Moya
Date: 2021-11-09T11:28:48-08:00
New Revision: 74add1b6d6d377ab2cdce26699cf798110817e42

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

LOG: Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp 
(NFC)"

The change causes multiple clang-tidy tests to fail under ASan.

This reverts commit 00769572025f9b0d36dc832d3c1bc61500091ed5.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 9771d90de63df..456de0e979dbd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -374,11 +374,13 @@ static ClangTidyError createNolintError(const 
ClangTidyContext ,
 bool IsNolintBegin) {
   ClangTidyError Error("clang-tidy-nolint", ClangTidyError::Error,
Context.getCurrentBuildDirectory(), false);
-  auto Message = Twine("unmatched 'NOLINT") +
- (IsNolintBegin ? "BEGIN" : "END") + "' comment without a " +
- (IsNolintBegin ? "subsequent" : "previous") + " 'NOLINT" +
- (IsNolintBegin ? "END" : "BEGIN") + "' comment";
-  Error.Message = tooling::DiagnosticMessage(Message.str(), SM, Loc);
+  StringRef Message =
+  IsNolintBegin
+  ? "unmatched 'NOLINTBEGIN' comment without a subsequent 'NOLINTEND' "
+"comment"
+  : "unmatched 'NOLINTEND' comment without a previous 'NOLINTBEGIN' "
+"comment";
+  Error.Message = tooling::DiagnosticMessage(Message, SM, Loc);
   return Error;
 }
 



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


[PATCH] D113472: [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)

2021-11-09 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added a comment.

In D113472#3119292 , @jgorbe wrote:

> This change is causing asan errors when running the clang-tidy checks under 
> ASan, most likely because of the reason akuegel pointed out in his comment. 
> I'm going to revert the patch to unbreak HEAD until the problem can be fixed.

If you could do that, that would be appreciated. Thank you. I won't be able to 
get back to my desk to revert myself for at least half an hour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113472

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


[PATCH] D113472: [clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)

2021-11-09 Thread Jorge Gorbe Moya via Phabricator via cfe-commits
jgorbe added a comment.

This change is causing asan errors when running the clang-tidy checks under 
ASan, most likely because of the reason akuegel pointed out in his comment. I'm 
going to revert the patch to unbreak HEAD until the problem can be fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113472

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


[PATCH] D113447: [sancov] add tracing for loads and store

2021-11-09 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113447

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


[PATCH] D112492: [CUDA][HIP] Allow comdat for kernels

2021-11-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added subscribers: kpyzhov, rnk.
tra added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4290-4293
-  // Do not set COMDAT attribute for CUDA/HIP stub functions to prevent
-  // them being "merged" by the COMDAT Folding linker optimization.
-  if (D.hasAttr())
-return false;

This was added in D63277 specifically to deal with comdat-related issue on 
windows. 

We do need to have unique addresses for each kernel stub. Placing stubs into 
comdat may allow them to be merged into one and that would be a problem.
https://docs.microsoft.com/en-us/cpp/build/reference/opt-optimizations?view=vs-2019
 

@rnk,@kpyzhov -- how do we make sure that identical functions are placed in 
comdat (needed for templates) but do not get comdat-folded with `/OPT:ICF`? 



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

https://reviews.llvm.org/D112492

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


  1   2   3   >