[clang] e884e00 - [dataflow] Delete legacy aliases

2023-03-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-03-27T09:29:53+02:00
New Revision: e884e005f36383218641a4512a89a6825059f8cf

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

LOG: [dataflow] Delete legacy aliases

I can't find any trace of use anymore.
I'm not sure renaming the header is worth the break, but leave the FIXME.

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h 
b/clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
index 37894ab37dd8d..9a298478c5100 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines the `MatchSwitch` abstraction for building a "switch"
+//  This file defines the `ASTMatchSwitch` abstraction for building a "switch"
 //  statement, where each case of the switch is defined by an AST matcher. The
 //  cases are considered in order, like pattern matching in functional
 //  languages.
@@ -17,8 +17,7 @@
 //
 
//===--===//
 //
-// FIXME: Rename to ASTMatchSwitch.h and update documentation when all usages 
of
-// `MatchSwitch` are updated to `ASTMatchSwitch`
+// FIXME: Rename to ASTMatchSwitch.h
 
 #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
 #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
@@ -69,11 +68,6 @@ template 
 using ASTMatchSwitch =
 std::function;
 
-// FIXME: Remove this alias when all usages of `MatchSwitch` are updated to
-// `ASTMatchSwitch`.
-template 
-using MatchSwitch = ASTMatchSwitch;
-
 /// Collects cases of a "match switch": a collection of matchers paired with
 /// callbacks, which together define a switch that can be applied to a node
 /// whose type derives from `BaseT`. This structure can simplify the definition
@@ -171,11 +165,6 @@ class ASTMatchSwitchBuilder {
   std::vector> Actions;
 };
 
-// FIXME: Remove this alias when all usages of `MatchSwitchBuilder` are updated
-// to `ASTMatchSwitchBuilder`.
-template 
-using MatchSwitchBuilder = ASTMatchSwitchBuilder;
-
 } // namespace dataflow
 } // namespace clang
 #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_



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


[PATCH] D146864: [dataflow] Delete legacy aliases

2023-03-27 Thread Sam McCall 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 rGe884e005f363: [dataflow] Delete legacy aliases (authored by 
sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146864

Files:
  clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h


Index: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
===
--- clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
+++ clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
@@ -6,7 +6,7 @@
 //
 
//===--===//
 //
-//  This file defines the `MatchSwitch` abstraction for building a "switch"
+//  This file defines the `ASTMatchSwitch` abstraction for building a "switch"
 //  statement, where each case of the switch is defined by an AST matcher. The
 //  cases are considered in order, like pattern matching in functional
 //  languages.
@@ -17,8 +17,7 @@
 //
 
//===--===//
 //
-// FIXME: Rename to ASTMatchSwitch.h and update documentation when all usages 
of
-// `MatchSwitch` are updated to `ASTMatchSwitch`
+// FIXME: Rename to ASTMatchSwitch.h
 
 #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
 #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
@@ -69,11 +68,6 @@
 using ASTMatchSwitch =
 std::function;
 
-// FIXME: Remove this alias when all usages of `MatchSwitch` are updated to
-// `ASTMatchSwitch`.
-template 
-using MatchSwitch = ASTMatchSwitch;
-
 /// Collects cases of a "match switch": a collection of matchers paired with
 /// callbacks, which together define a switch that can be applied to a node
 /// whose type derives from `BaseT`. This structure can simplify the definition
@@ -171,11 +165,6 @@
   std::vector> Actions;
 };
 
-// FIXME: Remove this alias when all usages of `MatchSwitchBuilder` are updated
-// to `ASTMatchSwitchBuilder`.
-template 
-using MatchSwitchBuilder = ASTMatchSwitchBuilder;
-
 } // namespace dataflow
 } // namespace clang
 #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_


Index: clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
===
--- clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
+++ clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-//  This file defines the `MatchSwitch` abstraction for building a "switch"
+//  This file defines the `ASTMatchSwitch` abstraction for building a "switch"
 //  statement, where each case of the switch is defined by an AST matcher. The
 //  cases are considered in order, like pattern matching in functional
 //  languages.
@@ -17,8 +17,7 @@
 //
 //===--===//
 //
-// FIXME: Rename to ASTMatchSwitch.h and update documentation when all usages of
-// `MatchSwitch` are updated to `ASTMatchSwitch`
+// FIXME: Rename to ASTMatchSwitch.h
 
 #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
 #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
@@ -69,11 +68,6 @@
 using ASTMatchSwitch =
 std::function;
 
-// FIXME: Remove this alias when all usages of `MatchSwitch` are updated to
-// `ASTMatchSwitch`.
-template 
-using MatchSwitch = ASTMatchSwitch;
-
 /// Collects cases of a "match switch": a collection of matchers paired with
 /// callbacks, which together define a switch that can be applied to a node
 /// whose type derives from `BaseT`. This structure can simplify the definition
@@ -171,11 +165,6 @@
   std::vector> Actions;
 };
 
-// FIXME: Remove this alias when all usages of `MatchSwitchBuilder` are updated
-// to `ASTMatchSwitchBuilder`.
-template 
-using MatchSwitchBuilder = ASTMatchSwitchBuilder;
-
 } // namespace dataflow
 } // namespace clang
 #endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_MATCHSWITCH_H_
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145671: [clang] Remove legacy -m(no)-code-object-v3 options

2023-03-27 Thread Pierre van Houtryve via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG30e7cd48778b: [clang] Remove legacy -m(no)-code-object-v3 
options (authored by Pierre-vh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145671

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/amdgpu-features-as.s
  clang/test/Driver/amdgpu-features.c
  clang/test/Driver/hip-code-object-version.hip

Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -2,27 +2,16 @@
 
 // Check bundle ID for code object v2.
 
-// RUN: %clang -### --target=x86_64-linux-gnu \
-// RUN:   -mno-code-object-v3 \
-// RUN:   --offload-arch=gfx906 -nogpulib \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=V2,V2-WARN %s
-
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -mcode-object-version=2 \
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V2 %s
 
-// V2-WARN: warning: argument '-mno-code-object-v3' is deprecated, use '-mcode-object-version=2' instead [-Wdeprecated]
 // V2: "-mllvm" "--amdhsa-code-object-version=2"
 // V2: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
 // Check bundle ID for code object v3.
 
-// RUN: %clang -### --target=x86_64-linux-gnu \
-// RUN:   -mcode-object-v3 \
-// RUN:   --offload-arch=gfx906 -nogpulib \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=V3,V3-WARN %s
-
 // RUN: %clang -### --target=x86_64-linux-gnu \
 // RUN:   -mcode-object-version=3 \
 // RUN:   --offload-arch=gfx906 -nogpulib \
@@ -33,7 +22,6 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V3 %s
 
-// V3-WARN: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
 // V3: "-mcode-object-version=3"
 // V3: "-mllvm" "--amdhsa-code-object-version=3"
 // V3: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
@@ -95,14 +83,3 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefix=CC1NEG %s
 
 // CC1NEG-NOT: "-cc1as" {{.*}}"-mcode-object-version=5"
-
-// Check warnings are emitted for legacy options before -mcode-object-version options.
-// Check warnings are emitted only once.
-
-// RUN: %clang -### --target=x86_64-linux-gnu \
-// RUN:   -mno-code-object-v3 -mcode-object-v3 -mcode-object-version=4 \
-// RUN:   --offload-arch=gfx906 -nogpulib \
-// RUN:   %s 2>&1 | FileCheck -check-prefixes=WARN %s
-// WARN: warning: argument '-mno-code-object-v3' is deprecated, use '-mcode-object-version=2' instead [-Wdeprecated]
-// WARN: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
-// WARN-NOT: warning: argument {{.*}} is deprecated
Index: clang/test/Driver/amdgpu-features.c
===
--- clang/test/Driver/amdgpu-features.c
+++ clang/test/Driver/amdgpu-features.c
@@ -1,15 +1,3 @@
-// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx700 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
-// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
-// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
-
-// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx700 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
-// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, use '-mcode-object-version=2' instead [-Wdeprecated]
-// NO-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=2"
-
-// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx700 -mcode-object-v3 -mno-code-object-v3 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=MUL-CODE-OBJECT-V3 %s
-// MUL-CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
-// MUL-CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
-
 // RUN: %clang -### -target amdgcn-amdhsa -mcpu=gfx900:xnack+ %s 2>&1 | FileCheck --check-prefix=XNACK %s
 // XNACK: "-target-feature" "+xnack"
 
Index: clang/test/Driver/amdgpu-features-as.s
===
--- clang/test/Driver/amdgpu-features-as.s
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
-// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
-// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
-
-// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 -mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE

[clang] 30e7cd4 - [clang] Remove legacy -m(no)-code-object-v3 options

2023-03-27 Thread via cfe-commits

Author: pvanhout
Date: 2023-03-27T09:33:59+02:00
New Revision: 30e7cd48778b3fbbf41b666f40423297c3b19d96

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

LOG: [clang] Remove legacy -m(no)-code-object-v3 options

Code object V2 and V3 have been deprecated for a long time.
They're now scheduled to be removed completely from LLVM in the coming 
weeks/months.

There is no reason to support those legacy options anymore as they've
also been deprecated for a long time.

Reviewed By: #amdgpu, yaxunl, artem.tamazov

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/amdgpu-features.c
clang/test/Driver/hip-code-object-version.hip

Removed: 
clang/test/Driver/amdgpu-features-as.s



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6eda29771cf96..2f81f60a63995 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3792,10 +3792,6 @@ def mcode_object_version_EQ : Joined<["-"], 
"mcode-object-version=">, Group,
   MarshallingInfoEnum, "COV_4">;
 
-defm code_object_v3_legacy : SimpleMFlag<"code-object-v3",
-  "Legacy option to specify code object ABI V3",
-  "Legacy option to specify code object ABI V2",
-  " (AMDGPU only)">;
 defm cumode : SimpleMFlag<"cumode",
   "Specify CU wavefront", "Specify WGP wavefront",
   " execution mode (AMDGPU only)", m_amdgpu_Features_Group>;

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 9074b572c3991..4273373f62f35 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2177,11 +2177,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const 
Tool *T,
 
 static llvm::opt::Arg *
 getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) {
-  // The last of -mcode-object-v3, -mno-code-object-v3 and
-  // -mcode-object-version= wins.
-  return Args.getLastArg(options::OPT_mcode_object_v3_legacy,
- options::OPT_mno_code_object_v3_legacy,
- options::OPT_mcode_object_version_EQ);
+  return Args.getLastArg(options::OPT_mcode_object_version_EQ);
 }
 
 void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
@@ -2189,15 +2185,6 @@ void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
   const unsigned MinCodeObjVer = 2;
   const unsigned MaxCodeObjVer = 5;
 
-  // Emit warnings for legacy options even if they are overridden.
-  if (Args.hasArg(options::OPT_mno_code_object_v3_legacy))
-D.Diag(diag::warn_drv_deprecated_arg) << "-mno-code-object-v3"
-  << "-mcode-object-version=2";
-
-  if (Args.hasArg(options::OPT_mcode_object_v3_legacy))
-D.Diag(diag::warn_drv_deprecated_arg) << "-mcode-object-v3"
-  << "-mcode-object-version=3";
-
   if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
 if (CodeObjArg->getOption().getID() ==
 options::OPT_mcode_object_version_EQ) {
@@ -2214,17 +2201,8 @@ void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
 unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
const llvm::opt::ArgList &Args) {
   unsigned CodeObjVer = 4; // default
-  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
-if (CodeObjArg->getOption().getID() ==
-options::OPT_mno_code_object_v3_legacy) {
-  CodeObjVer = 2;
-} else if (CodeObjArg->getOption().getID() ==
-   options::OPT_mcode_object_v3_legacy) {
-  CodeObjVer = 3;
-} else {
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-}
-  }
+  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args))
+StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
   return CodeObjVer;
 }
 

diff  --git a/clang/test/Driver/amdgpu-features-as.s 
b/clang/test/Driver/amdgpu-features-as.s
deleted file mode 100644
index 6e810c167ddf8..0
--- a/clang/test/Driver/amdgpu-features-as.s
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx900 -mcode-object-v3 %s 
2>&1 | FileCheck --check-prefix=CODE-OBJECT-V3 %s
-// CODE-OBJECT-V3: warning: argument '-mcode-object-v3' is deprecated, use 
'-mcode-object-version=3' instead [-Wdeprecated]
-// CODE-OBJECT-V3: "-mllvm" "--amdhsa-code-object-version=3"
-
-// RUN: %clang -### -target amdgcn-amd-amdhsa amdgcn -mcpu=gfx900 
-mno-code-object-v3 %s 2>&1 | FileCheck --check-prefix=NO-CODE-OBJECT-V3 %s
-// NO-CODE-OBJECT-V3: warning: argument '-mno-code-object-v3' is deprecated, 
use '-mcode

[PATCH] D146866: [clang][ExtractAPI] Remove extra pointer indirection from declaration fragments for Obj-C lightweight generics on id

2023-03-27 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav added a comment.

@dang @ributzka Please review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146866

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


[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-03-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 508517.
sammccall marked 4 inline comments as done.
sammccall edited the summary of this revision.
sammccall added a comment.

Address Dmitri's comments
Update demo link


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

Files:
  clang/include/clang/Analysis/FlowSensitive/Logger.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.css
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html
  clang/lib/Analysis/FlowSensitive/HTMLLogger.js
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
  clang/utils/bundle_resources.py

Index: clang/utils/bundle_resources.py
===
--- /dev/null
+++ clang/utils/bundle_resources.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+#===- bundle_resources.py - Generate string constants with file contents. ===
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===--===
+
+# Usage: bundle-resources.py foo.inc a.js path/b.css ...
+# Produces foo.inc containing:
+#   const char a_js[] = "...";
+#   const char b_css[] = "...";
+import os
+import sys
+
+outfile = sys.argv[1]
+infiles = sys.argv[2:]
+
+with open(outfile, 'w') as out:
+  for filename in infiles:
+varname = os.path.basename(filename).replace('.', '_')
+out.write("const char " + varname + "[] = \n");
+# MSVC limits each chunk of string to 2k, so split by lines.
+# The overall limit is 64k, which ought to be enough for anyone.
+for line in open(filename).read().split('\n'):
+  out.write('  R"x(' + line + ')x" "\\n"\n' )
+out.write('  ;\n');
Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -9,6 +9,7 @@
 
 namespace clang::dataflow::test {
 namespace {
+using testing::HasSubstr;
 
 struct TestLattice {
   int Elements = 0;
@@ -83,19 +84,24 @@
   void logText(llvm::StringRef Text) override { OS << Text << "\n"; }
 };
 
-TEST(LoggerTest, Sequence) {
+AnalysisInputs makeInputs() {
   const char *Code = R"cpp(
 int target(bool b, int p, int q) {
   return b ? p : q;
 }
 )cpp";
+  static const std::vector Args = {
+  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
 
   auto Inputs = AnalysisInputs(
   Code, ast_matchers::hasName("target"),
   [](ASTContext &C, Environment &) { return TestAnalysis(C); });
-  std::vector Args = {
-  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
   Inputs.ASTBuildArgs = Args;
+  return Inputs;
+}
+
+TEST(LoggerTest, Sequence) {
+  auto Inputs = makeInputs();
   std::string Log;
   TestLogger Logger(Log);
   Inputs.BuiltinOptions.Log = &Logger;
@@ -148,5 +154,29 @@
 )");
 }
 
+TEST(LoggerTest, HTML) {
+  auto Inputs = makeInputs();
+  std::vector Logs;
+  auto Logger = Logger::html([&]() {
+Logs.emplace_back();
+return std::make_unique(Logs.back());
+  });
+  Inputs.BuiltinOptions.Log = Logger.get();
+
+  ASSERT_THAT_ERROR(checkDataflow(std::move(Inputs),
+[](const AnalysisOutputs &) {}),
+llvm::Succeeded());
+
+  // Simple smoke tests: we can't meaningfully test the behavior.
+  ASSERT_THAT(Logs, testing::SizeIs(1));
+  EXPECT_THAT(Logs[0], HasSubstr("function updateSelection")) << "embeds JS";
+  EXPECT_THAT(Logs[0], HasSubstr("html {")) << "embeds CSS";
+  EXPECT_THAT(Logs[0], HasSubstr("b (ImplicitCastExpr")) << "has CFG elements";
+  EXPECT_THAT(Logs[0], HasSubstr("\"B3:1_B3.1\":"))
+  << "has analysis point state";
+  EXPECT_THAT(Logs[0], HasSubstr("transferBranch(0)")) << "has analysis logs";
+  EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+}
+
 } // namespace
 } // namespace clang::dataflow::test
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.js
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.js
@@ -0,0 +1,210 @@
+//===-- HTMLLogger.js -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Based on selected objects, hide/show sections & populate data from temp

[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-03-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 508518.
sammccall added a comment.

Only show the filename, not the full path, to avoid overflowing the box


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

Files:
  clang/include/clang/Analysis/FlowSensitive/Logger.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.css
  clang/lib/Analysis/FlowSensitive/HTMLLogger.html
  clang/lib/Analysis/FlowSensitive/HTMLLogger.js
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
  clang/utils/bundle_resources.py

Index: clang/utils/bundle_resources.py
===
--- /dev/null
+++ clang/utils/bundle_resources.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+#===- bundle_resources.py - Generate string constants with file contents. ===
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===--===
+
+# Usage: bundle-resources.py foo.inc a.js path/b.css ...
+# Produces foo.inc containing:
+#   const char a_js[] = "...";
+#   const char b_css[] = "...";
+import os
+import sys
+
+outfile = sys.argv[1]
+infiles = sys.argv[2:]
+
+with open(outfile, 'w') as out:
+  for filename in infiles:
+varname = os.path.basename(filename).replace('.', '_')
+out.write("const char " + varname + "[] = \n");
+# MSVC limits each chunk of string to 2k, so split by lines.
+# The overall limit is 64k, which ought to be enough for anyone.
+for line in open(filename).read().split('\n'):
+  out.write('  R"x(' + line + ')x" "\\n"\n' )
+out.write('  ;\n');
Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -9,6 +9,7 @@
 
 namespace clang::dataflow::test {
 namespace {
+using testing::HasSubstr;
 
 struct TestLattice {
   int Elements = 0;
@@ -83,19 +84,24 @@
   void logText(llvm::StringRef Text) override { OS << Text << "\n"; }
 };
 
-TEST(LoggerTest, Sequence) {
+AnalysisInputs makeInputs() {
   const char *Code = R"cpp(
 int target(bool b, int p, int q) {
   return b ? p : q;
 }
 )cpp";
+  static const std::vector Args = {
+  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
 
   auto Inputs = AnalysisInputs(
   Code, ast_matchers::hasName("target"),
   [](ASTContext &C, Environment &) { return TestAnalysis(C); });
-  std::vector Args = {
-  "-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"};
   Inputs.ASTBuildArgs = Args;
+  return Inputs;
+}
+
+TEST(LoggerTest, Sequence) {
+  auto Inputs = makeInputs();
   std::string Log;
   TestLogger Logger(Log);
   Inputs.BuiltinOptions.Log = &Logger;
@@ -148,5 +154,29 @@
 )");
 }
 
+TEST(LoggerTest, HTML) {
+  auto Inputs = makeInputs();
+  std::vector Logs;
+  auto Logger = Logger::html([&]() {
+Logs.emplace_back();
+return std::make_unique(Logs.back());
+  });
+  Inputs.BuiltinOptions.Log = Logger.get();
+
+  ASSERT_THAT_ERROR(checkDataflow(std::move(Inputs),
+[](const AnalysisOutputs &) {}),
+llvm::Succeeded());
+
+  // Simple smoke tests: we can't meaningfully test the behavior.
+  ASSERT_THAT(Logs, testing::SizeIs(1));
+  EXPECT_THAT(Logs[0], HasSubstr("function updateSelection")) << "embeds JS";
+  EXPECT_THAT(Logs[0], HasSubstr("html {")) << "embeds CSS";
+  EXPECT_THAT(Logs[0], HasSubstr("b (ImplicitCastExpr")) << "has CFG elements";
+  EXPECT_THAT(Logs[0], HasSubstr("\"B3:1_B3.1\":"))
+  << "has analysis point state";
+  EXPECT_THAT(Logs[0], HasSubstr("transferBranch(0)")) << "has analysis logs";
+  EXPECT_THAT(Logs[0], HasSubstr("LocToVal")) << "has built-in lattice dump";
+}
+
 } // namespace
 } // namespace clang::dataflow::test
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.js
===
--- /dev/null
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.js
@@ -0,0 +1,210 @@
+//===-- HTMLLogger.js -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Based on selected objects, hide/show sections & populate data from templates.
+//
+// For example, if we the selection is {bb=BB4, el

[clang] 4a9dc94 - [clang] Test for AST Dumping of the template variables

2023-03-27 Thread Tomasz Kamiński via cfe-commits

Author: Tomasz Kamiński
Date: 2023-03-27T09:53:47+02:00
New Revision: 4a9dc94d336ab0c68d718db21d1666ac19868642

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

LOG: [clang] Test for AST Dumping of the template variables

They illustrate unstable behavior of the https://reviews.llvm.org/D139705 after 
serialization.
(`#61680 `).

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/test/AST/ast-dump-template-decls.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index 49760d17c7f22..fe367aefa6020 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -1,12 +1,12 @@
 // Test without serialization:
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s \
-// RUN: | FileCheck -strict-whitespace %s
+// RUN: | FileCheck -strict-whitespace %s --check-prefix=DIRECT
 //
 // Test with serialization:
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -x c++ -std=c++17 -triple x86_64-unknown-unknown 
-include-pch %t -ast-dump-all /dev/null \
 // RUN: | sed -e "s/ //" -e "s/ imported//" \
-// RUN: | FileCheck --strict-whitespace %s
+// RUN: | FileCheck --strict-whitespace %s --check-prefix=SERIALIZED
 
 template 
 // CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <{{.*}}:1, line:[[@LINE+2]]:10> 
col:6 a
@@ -178,3 +178,80 @@ using test1 = D;
 // CHECK-NEXT: `-RecordType 0x{{[^ ]*}} 'subst_default_argument::A'
 // CHECK-NEXT:   `-ClassTemplateSpecialization 0x{{[^ ]*}} 'A'
 } // namespace subst_default_argument
+
+namespace D146733 {
+template
+T unTempl = 1;
+// CHECK:VarTemplateDecl 0x{{[^ ]*}}  
col:3 unTempl
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 T
+// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}}  col:3 unTempl 
'T' cinit
+// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template<>
+int unTempl;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 unTempl 'int'
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 unTempl 'int'
+// CHECK-NEXT: `-TemplateArgument type 'int'
+// CHECK-NEXT: `-BuiltinType 0x{{[^ ]*}} 'int'
+
+template<>
+float unTempl = 1;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
+// CHECK-NEXT: |-TemplateArgument type 'float'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
+// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}}  'float' 

+// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template
+T binTempl = 1;
+// CHECK:  VarTemplateDecl 0x{{[^ ]*}}  col:3 binTempl
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 T
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  col:25 
class depth 0 index 1 U
+// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}}  col:3 
binTempl 'T' cinit
+// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template
+int binTempl;
+// CHECK:  VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} 
 col:5 binTempl 'int'
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 U
+// CHECK-NEXT: |-TemplateArgument type 'int'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int'
+// CHECK-NEXT: `-TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' 
dependent depth 0 index 0
+
+template
+float binTempl = 1;
+// CHECK:  VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} 
 col:7 binTempl 'float' cinit
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 U
+// CHECK-NEXT: |-TemplateArgument type 'float'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
+// CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: | `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' 
dependent depth 0 index 0
+// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}}  'float' 

+// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template<>
+int binTempl;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 binTempl 'int'
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 binTempl 'int'
+// CHECK-NEXT: |-TemplateArgument type 'int'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int'
+// CHECK-NEXT: `-Te

[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-03-27 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

And actually there is issue for this: 
https://github.com/llvm/llvm-project/issues/57758


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145581

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


[PATCH] D146784: [clang] Test for AST Dumping of the template variables

2023-03-27 Thread Tomasz Kamiński 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 rG4a9dc94d336a: [clang] Test for AST Dumping of the template 
variables (authored by tomasz-kaminski-sonarsource).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146784

Files:
  clang/test/AST/ast-dump-template-decls.cpp


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -1,12 +1,12 @@
 // Test without serialization:
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -ast-dump %s \
-// RUN: | FileCheck -strict-whitespace %s
+// RUN: | FileCheck -strict-whitespace %s --check-prefix=DIRECT
 //
 // Test with serialization:
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -x c++ -std=c++17 -triple x86_64-unknown-unknown 
-include-pch %t -ast-dump-all /dev/null \
 // RUN: | sed -e "s/ //" -e "s/ imported//" \
-// RUN: | FileCheck --strict-whitespace %s
+// RUN: | FileCheck --strict-whitespace %s --check-prefix=SERIALIZED
 
 template 
 // CHECK: FunctionTemplateDecl 0x{{[^ ]*}} <{{.*}}:1, line:[[@LINE+2]]:10> 
col:6 a
@@ -178,3 +178,80 @@
 // CHECK-NEXT: `-RecordType 0x{{[^ ]*}} 'subst_default_argument::A'
 // CHECK-NEXT:   `-ClassTemplateSpecialization 0x{{[^ ]*}} 'A'
 } // namespace subst_default_argument
+
+namespace D146733 {
+template
+T unTempl = 1;
+// CHECK:VarTemplateDecl 0x{{[^ ]*}}  
col:3 unTempl
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 T
+// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}}  col:3 unTempl 
'T' cinit
+// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template<>
+int unTempl;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 unTempl 'int'
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 unTempl 'int'
+// CHECK-NEXT: `-TemplateArgument type 'int'
+// CHECK-NEXT: `-BuiltinType 0x{{[^ ]*}} 'int'
+
+template<>
+float unTempl = 1;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
+// CHECK-NEXT: |-TemplateArgument type 'float'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
+// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}}  'float' 

+// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template
+T binTempl = 1;
+// CHECK:  VarTemplateDecl 0x{{[^ ]*}}  col:3 binTempl
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 T
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  col:25 
class depth 0 index 1 U
+// CHECK-NEXT: |-VarDecl 0x{{[^ ]*}}  col:3 
binTempl 'T' cinit
+// CHECK-NEXT: | `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template
+int binTempl;
+// CHECK:  VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} 
 col:5 binTempl 'int'
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 U
+// CHECK-NEXT: |-TemplateArgument type 'int'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int'
+// CHECK-NEXT: `-TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' 
dependent depth 0 index 0
+
+template
+float binTempl = 1;
+// CHECK:  VarTemplatePartialSpecializationDecl 0x{{[^ ]*}} 
 col:7 binTempl 'float' cinit
+// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{[^ ]*}}  
col:16 referenced class depth 0 index 0 U
+// CHECK-NEXT: |-TemplateArgument type 'float'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
+// CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-0'
+// CHECK-NEXT: | `-TemplateTypeParmType 0x{{[^ ]*}} 'type-parameter-0-0' 
dependent depth 0 index 0
+// CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}}  'float' 

+// CHECK-NEXT: `-IntegerLiteral 0x{{[^ ]*}}  'int' 1
+
+template<>
+int binTempl;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 binTempl 'int'
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:5 binTempl 'int'
+// CHECK-NEXT: |-TemplateArgument type 'int'
+// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int'
+// CHECK-NEXT: `-TemplateArgument type 'int'
+// CHECK-NEXT: `-BuiltinType 0x{{[^ ]*}} 'int'
+
+template<>
+float binTempl = 1;
+// FIXME (#61680) - serializing and loading AST should not affect reported 
source range
+// DIRECT:VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 binTempl 'float' cinit
+// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 binTempl 'float' cin

[PATCH] D126959: [C++20][Modules] Introduce an implementation module.

2023-03-27 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

In D126959#4222854 , @iains wrote:

> In D126959#4222637 , @bjope wrote:
>
>> This seem to case problems when building with asan enabled 
>> (LLVM_USE_SANITIZER='Address'):
>
> investigating... do you need the patch reverted?

I've reverted it downstream right now, so personally I don't have a problem 
with this right now. Still, unless it will go quickly to find a fix it might 
help others people if reverting (it was not obvious to me which patch that 
caused the failures, and others might still be bisecting trying to find which 
commit that caused the trouble).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126959

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


[PATCH] D146801: [clang] Fix consteval initializers of temporaries

2023-03-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 508524.
Fznamznon added a comment.

Rebase, maybe this will get "pre-commit" started


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146801

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1050,3 +1050,18 @@
 
 }
 }
+
+namespace GH60286 {
+
+struct A {
+  int i = 0;
+
+  consteval A() {}
+  A(const A&) { i = 1; }
+  consteval int f() { return i; }
+};
+
+constexpr auto B = A{A{}}.f();
+static_assert(B == 0);
+
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1590,6 +1590,9 @@
   Expr *Inner = Result.get();
   if (CXXBindTemporaryExpr *BTE = 
dyn_cast_or_null(Inner))
 Inner = BTE->getSubExpr();
+  if (auto *CE = dyn_cast(Inner);
+  CE && CE->isImmediateInvocation())
+Inner = CE->getSubExpr();
   if (!isa(Inner) &&
   !isa(Inner)) {
 // If we created a CXXTemporaryObjectExpr, that node also represents the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -230,6 +230,9 @@
   antecipation of `CWG2563 
_`.
 - Fix highlighting issue with ``_Complex`` and initialization list with more 
than
   2 items. (`#61518 `_)
+- Fix false-positive diagnostic issued for consteval initializers of temporary
+  objects.
+  (`#60286 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1050,3 +1050,18 @@
 
 }
 }
+
+namespace GH60286 {
+
+struct A {
+  int i = 0;
+
+  consteval A() {}
+  A(const A&) { i = 1; }
+  consteval int f() { return i; }
+};
+
+constexpr auto B = A{A{}}.f();
+static_assert(B == 0);
+
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -1590,6 +1590,9 @@
   Expr *Inner = Result.get();
   if (CXXBindTemporaryExpr *BTE = dyn_cast_or_null(Inner))
 Inner = BTE->getSubExpr();
+  if (auto *CE = dyn_cast(Inner);
+  CE && CE->isImmediateInvocation())
+Inner = CE->getSubExpr();
   if (!isa(Inner) &&
   !isa(Inner)) {
 // If we created a CXXTemporaryObjectExpr, that node also represents the
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -230,6 +230,9 @@
   antecipation of `CWG2563 _`.
 - Fix highlighting issue with ``_Complex`` and initialization list with more than
   2 items. (`#61518 `_)
+- Fix false-positive diagnostic issued for consteval initializers of temporary
+  objects.
+  (`#60286 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146924: [clang] Add support for dollar sign in ud_suffix of numeric constants

2023-03-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

The commit message is certainly not correct, `$` is not allowed in identifiers 
by either the C or C++ standard and its support in compiler is hurting future 
evolution.
that being said, given that we already do do use it in identifiers, why not in 
UCNs.

I would like to see a test that ensures `42$` without underscore is ill-formed 
though, as this would have severe implication for evolution. 
if this aimes to fix the github issue, i think we need to understand why the 
difference of behavior with the euro sign - which should not be (and isn't) 
allowed either.

GCC seems to allow both in non pedantic mode, which may explain the struggles 
of clang format users


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146924

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


[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments

2023-03-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

no you need to run

clang/doc/tools/dump_format_style.py

This will regnerate ClangFormatStyleOptions.rst from the Format.h change you 
have here, you then need to include that rst file in the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146926

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


[PATCH] D146449: [RISCV] Replace RISCV -> RISC-V in comments. NFC

2023-03-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146449

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


[PATCH] D146451: [RISCV] Replace RISCV->RISC-V in strings.

2023-03-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

Not as compelling as user facing strings or comments that clearly refer to the 
RISC-V ISA rather than the "RISCV" LLVM backend. But I don't really see a good 
reason not to be consistent. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146451

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


[PATCH] D146926: [clang-format] Add option to decorate reflowed block comments

2023-03-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/include/clang/Format/Format.h:2022
+  /// \version 17
+  bool DecorateReflowedComments;
+

you are not setting the default value for this so it could be uninitialized, 
you need to set that in the LLVMStyle section

you need to ensure the == operator has been updated

you should be adding a CHECK_PARSE_BOOL() unit test at a minimum but also some 
verifyFormat checks in clang/unittest/Format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146926

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


[PATCH] D146188: [Clang][DOC] Add documentation in for __builtin_flt_rounds and __builtin_set_flt_rounds

2023-03-27 Thread xiongji90 via Phabricator via cfe-commits
xiongji90 added a comment.

Hi, @rjmccall and @sepavloff 
In UserManual, we include a section `Controlling Floating Point Behavior`: 
https://github.com/llvm/llvm-project/blob/main/clang/docs/UsersManual.rst#controlling-floating-point-behavior
 , now we need to add a new section for floating-point environment, do we need 
to add the new section in parallel with `Controlling Floating Point Behavior` 
section or just put the section under `Controlling Floating Point Behavior`? 
And current `Controlling Floating Point Behavior` includes following 
description:
`Clang provides a number of ways to control floating point behavior, including 
with command line options and source pragmas.`
So, we need to update it to `Clang provides a number of ways to control 
floating point behavior, including with command line options, source pragmas 
and builtins.` and mention __builtin_flt_rounds, __builtin_set_flt_rounds in 
this section. Does this meet your expectation?
Thanks very much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146188

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


[PATCH] D142347: [NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in Flang

2023-03-27 Thread Sacha Ballantyne via Phabricator via cfe-commits
SBallantyne updated this revision to Diff 508532.
SBallantyne added a comment.

Clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142347

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/lib/Driver/ToolChains/HIPSPV.h
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  llvm/include/llvm/Frontend/Debug/Options.h

Index: llvm/include/llvm/Frontend/Debug/Options.h
===
--- llvm/include/llvm/Frontend/Debug/Options.h
+++ llvm/include/llvm/Frontend/Debug/Options.h
@@ -6,10 +6,10 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
-#define LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
+#ifndef LLVM_FRONTEND_DEBUG_OPTIONS_H
+#define LLVM_FRONTEND_DEBUG_OPTIONS_H
 
-namespace clang {
+namespace llvm {
 namespace codegenoptions {
 
 enum DebugInfoFormat {
@@ -54,13 +54,9 @@
   UnusedTypeInfo,
 };
 
-enum class DebugTemplateNamesKind {
-  Full,
-  Simple,
-  Mangled
-};
+enum class DebugTemplateNamesKind { Full, Simple, Mangled };
 
 } // end namespace codegenoptions
-} // end namespace clang
+} // end namespace llvm
 
 #endif
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -200,7 +200,7 @@
   Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
-  Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
+  Inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
   Ins->setInvocation(std::move(Inv));
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -165,10 +165,11 @@
   if (std::unique_ptr OS =
   CI.createDefaultOutputFile(false, InFile, "cpp")) {
 if (CI.getLangOpts().ObjCRuntime.isNonFragile())
-  return CreateModernObjCRewriter(
-  std::string(InFile), std::move(OS), CI.getDiagnostics(),
-  CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
-  (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
+  return CreateModernObjCRewriter(std::string(InFile), std::move(OS),
+  CI.getDiagnostics(), CI.getLangOpts(),
+  CI.getDiagnosticOpts().NoRewriteMacros,
+  (CI.getCodeGenOpts().getDebugInfo() !=
+   llvm::codegenoptions::NoDebugInfo));
 return CreateObjCRewriter(std::string(InFile), std::move(OS),
   CI.getDiagnostics(), CI.getLangOpts(),
   CI.getDiagnosticOpts().NoRewriteMacros);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -12,7 +12,6 @@
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/CommentOptions.h"
-#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Basic/DiagnosticOptions.h"
@@ -59,6 +58,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -1397,28 +1397,28 @@
 
   std::optional DebugInfoVal;
   switch (Opts.DebugInfo) {
-  case codegenoptions::DebugLineTablesOnly:
+  case llvm::codegenoptions::DebugLineTablesOnly:
 DebugInfoVal = "line-tables-only";
 break;
-  case codegenoptions::DebugDirectivesOnly:
+  case llvm::codegenoptions::DebugDirectivesOnly:
 DebugInfoVal = "li

[PATCH] D146412: [NFC] Fix potential use-after-free in DumpModuleInfoAction::ExecuteAction()

2023-03-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

In D146412#4220021 , @kastiglione 
wrote:

> I understand the potential for a use after free, since `OutputStream` is a 
> raw pointer, but I don't understand the fix.

Okay, probably commit message is a little confusing. The potential for a use 
after free is that `OutputStream` is a raw pointer as you already noted, but it 
is also accessible outside of `DumpModuleInfoAction::ExecuteAction`. Before the 
patch there was the case where result of local unique_ptr::get was saved there. 
When the function is exited, unique_ptr frees the memory it did hold, making 
`OutputStream` poiniting to freed memory. Since it can be easily accessed 
outside of `DumpModuleInfoAction::ExecuteAction` hence the potential for 
use-after-free. I wasn't sure if assigning `nullptr` to `OutputStream` at the 
end of `DumpModuleInfoAction::ExecuteAction` was a good idea, so I just added 
code avoiding saving result of unique_ptr::get to `OutputStream` .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146412

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


[PATCH] D146814: [Flang] Add debug flag to enable current debug information pass

2023-03-27 Thread Sacha Ballantyne via Phabricator via cfe-commits
SBallantyne updated this revision to Diff 508536.
SBallantyne added a comment.

Attempt 2 to add previous work as stacked patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146814

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90

Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -56,6 +56,8 @@
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
+! HELP-NEXT: -gline-tables-only Emit debug line number tables only
+! HELP-NEXT: -g Generate source-level debug information
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -mllvm=   Alias for -mllvm
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -60,6 +60,8 @@
 ! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! CHECK-NEXT: -funderscoring Appends one trailing underscore to external names
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
+! CHECK-NEXT: -gline-tables-only Emit debug line number tables only
+! CHECK-NEXT: -g Generate source-level debug information
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -mllvm=   Alias for -mllvm
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -606,7 +606,7 @@
 
   // Create the pass pipeline
   fir::createMLIRToLLVMPassPipeline(pm, level, opts.StackArrays,
-opts.Underscoring);
+opts.Underscoring, opts.getDebugInfo());
   mlir::applyPassManagerCLOptions(pm);
 
   // run the pass manager
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/Triple.h"
+#include "llvm/Frontend/Debug/Options.h"
 #include 
 #include 
 
@@ -117,9 +118,43 @@
   return true;
 }
 
+static void parseDebugArgs(Fortran::frontend::CodeGenOptions &opts,
+   llvm::opt::ArgList &args,
+   clang::DiagnosticsEngine &diags) {
+  if (llvm::opt::Arg *arg =
+  args.getLastArg(clang::driver::options::OPT_debug_info_kind_EQ)) {
+unsigned val =
+llvm::StringSwitch(arg->getValue())
+.Case("line-tables-only",
+  llvm::codegenoptions::DebugLineTablesOnly)
+.Case("line-directives-only",
+  llvm::codegenoptions::DebugDirectivesOnly)
+.Case("constructor", llvm::codegenoptions::DebugInfoConstructor)
+.Case("limited", llvm::codegenoptions::LimitedDebugInfo)
+.Case("standalone", llvm::codegenoptions::FullDebugInfo)
+.Case("unused-types", llvm::codegenoptions::UnusedTypeInfo)
+.Default(~0U);
+if (val == ~0U) {
+  diags.Report(clang::diag::err_drv_invalid_value)
+  << arg->getAsString(args) << arg->getValue();
+} else {
+  opts.setDebugInfo(static_cast(val));
+}
+if (val != llvm::codegenoptions::DebugLineTablesOnly &&
+val != llvm::codegenoptions::NoDebugInfo) {
+  // TODO: This is not great, could be improved
+  const auto debugErr =
+  diags.getCustomDiagID(clang::DiagnosticsEngine::Warning,
+"Debug option '%0' is not implemented");
+  diags.Report(debugErr) << arg->getAsString(args);
+}
+  }
+}
+
 static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
  llvm::opt::ArgList &args,
  

[PATCH] D146924: [clang] Add support for dollar sign in ud_suffix of numeric constants

2023-03-27 Thread Anna Arad via Phabricator via cfe-commits
annara added a comment.

After a second look at the standard, you are right.
It's not in the range of any of the universal-character-names.
That being said, it is allowed as an identifier by default in clang (as 
@tahonermann) mentioned.
It also works in current versions of clang if you use the UCN in the numeric 
constant (and leave the user-defined literal operator declaration with a $ 
sign).
As you stated, GCC also accepts this syntax.

I can make sure dollar signs not part of a ud-sufffix will be rejected, if you 
think the general idea is acceptable.

Regarding the difference between the dollar and the euro sign. It seems the 
lexer lexes the euro sign as part of the numeric constant (like any other 
ud_suffix) and probably fails at a later stage (I'm not sure where yet).
I suspect the dollar sign passes at that step because of 
`-fdollars-in-identifiers` being true by default.
But, I need to look into it further to give a real answer.

Please let me know if you think it's worth pursuing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146924

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


[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-03-27 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez updated this revision to Diff 508538.
jmmartinez marked 3 inline comments as done.
jmmartinez added a comment.

- Took remarks into account


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/debug-info-bitfield-0-struct.c

Index: clang/test/CodeGen/debug-info-bitfield-0-struct.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-bitfield-0-struct.c
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=limited %s | FileCheck --check-prefixes NOSEPARATOR,BOTH %s
+// RUN: %clang_cc1 -triple amdgcn-unk-unk -o - -emit-llvm -debug-info-kind=limited %s | FileCheck --check-prefixes SEPARATOR,BOTH %s
+
+struct First {
+  // BOTH-DAG: ![[FIRST:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "First", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRST_ELEMENTS:[0-9]+]])
+  // BOTH-DAG: ![[FIRST_ELEMENTS]] = !{![[FIRST_X:[0-9]+]], ![[FIRST_Y:[0-9]+]]}
+  // BOTH-DAG: ![[FIRST_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // BOTH-DAG: ![[FIRST_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct FirstDuplicate {
+  // BOTH-DAG: ![[FIRSTD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "FirstDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRSTD_ELEMENTS:[0-9]+]])
+  // BOTH-DAG: ![[FIRSTD_ELEMENTS]] = !{![[FIRSTD_X:[0-9]+]], ![[FIRSTD_Y:[0-9]+]]}
+  // BOTH-DAG: ![[FIRSTD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // BOTH-DAG: ![[FIRSTD_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct Second {
+  // BOTH-DAG: ![[SECOND:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Second", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECOND_ELEMENTS:[0-9]+]])
+
+  // NOSEPARATOR-DAG: ![[SECOND_ELEMENTS]] = !{![[SECOND_X:[0-9]+]], ![[SECOND_Y:[0-9]+]]}
+  // SEPARATOR-DAG: ![[SECOND_ELEMENTS]] = !{![[SECOND_X:[0-9]+]], ![[SECOND_ZERO:[0-9]+]], ![[SECOND_Y:[0-9]+]]}
+
+  // BOTH-DAG: ![[SECOND_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // SEPARATOR-DAG: ![[SECOND_ZERO]] = !DIDerivedType(tag: DW_TAG_member, scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  // BOTH-DAG: ![[SECOND_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  int x : 4;
+  int : 0;
+  int y : 4;
+};
+
+struct SecondDuplicate {
+  // BOTH-DAG: ![[SECONDD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SecondDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECONDD_ELEMENTS:[0-9]+]])
+
+  // NOSEPARATOR-DAG: ![[SECONDD_ELEMENTS]] = !{![[SECONDD_X:[0-9]+]], ![[SECONDD_Y:[0-9]+]]}
+  // SEPARATOR-DAG: ![[SECONDD_ELEMENTS]] = !{![[SECONDD_X:[0-9]+]], ![[SECONDD_ZERO:[0-9]+]], ![[SECONDD_Y:[0-9]+]]}
+
+  // BOTH-DAG: ![[SECONDD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // SEPARATOR-DAG: ![[SECONDD_ZERO]] = !DIDerivedType(tag: DW_TAG_member, scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  // BOTH-DAG: ![[SECONDD_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  int x : 4;
+  int : 0;
+  int : 0;
+  int y : 4;
+};
+
+struct Last {
+  // BOTH-DAG: ![[LAST:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Last", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[LAST_ELEMENTS:[0-9]+]])
+  // BOTH-DAG:

[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-03-27 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1563
+
+  assert(PreviousBitfield->isBitField());
+

probinson wrote:
> Is this true for cases like
> ```
> struct nonadjacent {
>   char a : 8;
>   char : 0;
>   int b;
>   char d : 8;
> };
> ```
> where the field `d` has a predecessor that is not a bitfield? (This might be 
> my ignorance of how Decls are put together, but asserting that `advance` is 
> guaranteed to get you a bitfield just seems a little odd.)
In that case the assert is never reached.

When emiting the debug-info for `d`, when looking at the metadata generated for 
the previous field the function should exit early on this condition:
```
  if (!PreviousMDField || !PreviousMDField->isBitField() ||
  PreviousMDField->getSizeInBits() == 0)
return nullptr;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-03-27 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 508539.
4vtomat added a comment.
Herald added subscribers: jobnoorman, luke.

Updated to spec version 20230206.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaeskf2.

[PATCH] D146644: [documentation]Fixed Random Typos

2023-03-27 Thread Sam Tebbs via Phabricator via cfe-commits
samtebbs added a comment.

I was about to commit it for you but think that "Random" should be removed from 
the title, are you OK with that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146644

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


[PATCH] D146644: [documentation]Fixed Random Typos

2023-03-27 Thread Priyanshi Agarwal via Phabricator via cfe-commits
ipriyanshi1708 added a comment.

Yes, I am OK with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146644

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


[PATCH] D146644: [documentation]Fixed Random Typos

2023-03-27 Thread Sam Tebbs via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4071dcf3549f: [documentation] Fix Typos (authored by 
ipriyanshi1708, committed by samtebbs).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146644

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/FileUtilities.cpp
  llvm/test/DebugInfo/macro_link.ll
  llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp


Index: llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
===
--- llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
+++ llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
@@ -7,7 +7,7 @@
 
//===--===//
 //
 // This tool verifies Control Flow Integrity (CFI) instrumentation by static
-// binary anaylsis. See the design document in /docs/CFIVerify.rst for more
+// binary analysis. See the design document in /docs/CFIVerify.rst for more
 // information.
 //
 // This tool is currently incomplete. It currently only does disassembly for
Index: llvm/test/DebugInfo/macro_link.ll
===
--- llvm/test/DebugInfo/macro_link.ll
+++ llvm/test/DebugInfo/macro_link.ll
@@ -1,6 +1,6 @@
 ; RUN: llvm-link %s %s -S -o -| FileCheck %s
 
-; This test checks that DIMacro and DIMacroFile comaprison works correctly.
+; This test checks that DIMacro and DIMacroFile comparison works correctly.
 
 ; CHECK: !llvm.dbg.cu = !{[[CU1:![0-9]*]], [[CU2:![0-9]*]]}
 
Index: llvm/lib/Support/FileUtilities.cpp
===
--- llvm/lib/Support/FileUtilities.cpp
+++ llvm/lib/Support/FileUtilities.cpp
@@ -169,7 +169,7 @@
 
 /// DiffFilesWithTolerance - Compare the two files specified, returning 0 if 
the
 /// files match, 1 if they are different, and 2 if there is a file error.  This
-/// function differs from DiffFiles in that you can specify an absolete and
+/// function differs from DiffFiles in that you can specify an absolute and
 /// relative FP error that is allowed to exist.  If you specify a string to 
fill
 /// in for the error option, it will set the string to an error message if an
 /// error occurs, allowing the caller to distinguish between a failed diff and 
a
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -220,7 +220,7 @@
   static SubCommand &getTopLevel();
 
   // Get the special subcommand that can be used to put an option into all
-  // subcomands.
+  // subcommands.
   static SubCommand &getAll();
 
   void reset();


Index: llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
===
--- llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
+++ llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp
@@ -7,7 +7,7 @@
 //===--===//
 //
 // This tool verifies Control Flow Integrity (CFI) instrumentation by static
-// binary anaylsis. See the design document in /docs/CFIVerify.rst for more
+// binary analysis. See the design document in /docs/CFIVerify.rst for more
 // information.
 //
 // This tool is currently incomplete. It currently only does disassembly for
Index: llvm/test/DebugInfo/macro_link.ll
===
--- llvm/test/DebugInfo/macro_link.ll
+++ llvm/test/DebugInfo/macro_link.ll
@@ -1,6 +1,6 @@
 ; RUN: llvm-link %s %s -S -o -| FileCheck %s
 
-; This test checks that DIMacro and DIMacroFile comaprison works correctly.
+; This test checks that DIMacro and DIMacroFile comparison works correctly.
 
 ; CHECK: !llvm.dbg.cu = !{[[CU1:![0-9]*]], [[CU2:![0-9]*]]}
 
Index: llvm/lib/Support/FileUtilities.cpp
===
--- llvm/lib/Support/FileUtilities.cpp
+++ llvm/lib/Support/FileUtilities.cpp
@@ -169,7 +169,7 @@
 
 /// DiffFilesWithTolerance - Compare the two files specified, returning 0 if the
 /// files match, 1 if they are different, and 2 if there is a file error.  This
-/// function differs from DiffFiles in that you can specify an absolete and
+/// function differs from DiffFiles in that you can specify an absolute and
 /// relative FP error that is allowed to exist.  If you specify a string to fill
 /// in for the error option, it will set the string to an error message if an
 /// error occurs, allowing the caller to distinguish between a failed diff and a
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -220,7 +220,7 @@
   static SubCommand &getTopLevel();
 
   // Get the 

[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to S11

2023-03-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

I've flagged this proposed change on Discourse 

 (more the fact we're looking to change it, rather than the precise register we 
end up with).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

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


[PATCH] D146814: [Flang] Add debug flag to enable current debug information pass

2023-03-27 Thread Sacha Ballantyne via Phabricator via cfe-commits
SBallantyne updated this revision to Diff 508543.
SBallantyne marked an inline comment as done.
SBallantyne added a comment.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle, mehdi_amini, 
thopre.

Add test to check that debug pass is run and not run with appropriate flags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146814

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/mlir-debug-pass-pipeline.f90

Index: flang/test/Driver/mlir-debug-pass-pipeline.f90
===
--- /dev/null
+++ flang/test/Driver/mlir-debug-pass-pipeline.f90
@@ -0,0 +1,74 @@
+! Test the MLIR pass pipeline
+
+! RUN: %flang -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline -o /dev/null %s 2>&1 | FileCheck --check-prefixes=ALL,NO-DEBUG %s
+!
+! RUN: %flang -g0 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,NO-DEBUG %s
+! RUN: %flang -g -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -g1 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -gline-tables-only -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -g2 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -g3 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+
+! REQUIRES: asserts
+
+end program
+
+! ALL: Pass statistics report
+
+! ALL: Fortran::lower::VerifierPass
+! ALL-NEXT: LowerHLFIRIntrinsics
+! ALL-NEXT: BufferizeHLFIR
+! ALL-NEXT: ConvertHLFIRtoFIR
+! ALL-NEXT: CSE
+! Ideally, we need an output with only the pass names, but
+! there is currently no way to get that, so in order to
+! guarantee that the passes are in the expected order
+! (i.e. use -NEXT) we have to check the statistics output as well.
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   ArrayValueCopy
+! ALL-NEXT:   CharacterConversion
+
+! ALL-NEXT: Canonicalizer
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   MemoryAllocationOpt
+
+! ALL-NEXT: Inliner
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   PolymorphicOpConversion
+! ALL-NEXT:   CFGConversion
+
+! ALL-NEXT: SCFToControlFlow
+! ALL-NEXT: Canonicalizer
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+! ALL-NEXT: BoxedProcedurePass
+
+! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func']
+! ALL-NEXT:   'fir.global' Pipeline
+! ALL-NEXT:AbstractResultOnGlobalOpt
+! ALL-NEXT:  'func.func' Pipeline
+! ALL-NEXT:AbstractResultOnFuncOpt
+
+! ALL-NEXT: CodeGenRewrite
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations eliminated
+! ALL-NEXT: TargetRewrite
+! ALL-NEXT: ExternalNameConversion
+! DEBUG-NEXT: AddDebugFoundation
+! NO-DEBUG-NOT: AddDebugFoundation
+! ALL-NEXT: FIRToLLVMLowering
+! ALL-NOT: LLVMIRLoweringPass
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -56,6 +56,8 @@
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
 ! HELP-NEXT: -fxor-operator  

[PATCH] D146715: [NVPTX] Enforce half type support is present for builtins

2023-03-27 Thread Jakub Chlanda via Phabricator via cfe-commits
jchlanda marked an inline comment as done.
jchlanda added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:18313
 // of its member: n*alignof(t)."
-return MakeLdgLdu(Intrinsic::nvvm_ldg_global_i);
-  case NVPTX::BI__nvvm_ldg_h:
-  case NVPTX::BI__nvvm_ldg_h2:
-if (!HasHalfSupport(BuiltinID)) {
-  CGM.Error(E->getExprLoc(),
-getContext().BuiltinInfo.getName(BuiltinID).str() +
-" requires native half type support.");
-  return nullptr;
-}
-[[fallthrough]];
+return MakeLdgLdu(Intrinsic::nvvm_ldg_global_i, *this, E);
   case NVPTX::BI__nvvm_ldg_f:

tra wrote:
> This is where lambda would have some advantage as we could capture what it 
> needs without having to pass 'this' or 'E' explicitly.
> In this case it's not too bad, so I'm fine either way, with a very slight 
> bias towards lambdas. The static functions just don't seem to buy us anything 
> here, IMO.
My reasoning was that it keeps `CodeGenFunction::EmitNVPTXBuiltinExpr` clean, 
all that it does now is to dispatch to a correct handler based on the builtin 
id (with exception of `mma`s); you are right though, it does it at the price of 
making the signatures more verbose.


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

https://reviews.llvm.org/D146715

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


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs and fields

2023-03-27 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

LGTM, but I'm not that familiar with the code that selects the alignment so it 
would be good to get a second opinion.




Comment at: clang/lib/CodeGen/TargetInfo.cpp:5806
   if (!IsWinVariadic && isHomogeneousAggregate(Ty, Base, Members)) {
 if (Kind != AArch64ABIInfo::AAPCS)
   return ABIArgInfo::getDirect(

Should this change cover AAPCS_VFP too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Yeah I think https://reviews.llvm.org/D146358 was first and this patch doesn't 
add much over it, correct me if I'm wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146376: Update static_assert message for redundant cases

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Remember to upload you patches with context.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16732
+// Ignore BO_LOr operators at the toplevel.
+if (Op->getOpcode() == BO_LOr)
+  return;

You can just drop the comment and move this into the `if` statement above, e..g 
 `if (...; BO && BO->getOpcode() != BO_Lor)`.



Comment at: clang/test/SemaCXX/static-assert.cpp:262
+
+  /// Bools are printed with disjunction.
+  static_assert(invert(true) || invert(true), ""); // expected-error 
{{failed}} \

That comment doesn't make a lot of sense?



Comment at: clang/test/SemaCXX/static-assert.cpp:263
+  /// Bools are printed with disjunction.
+  static_assert(invert(true) || invert(true), ""); // expected-error 
{{failed}} \
+

Remove the backslash



Comment at: clang/test/SemaCXX/static-assert.cpp:269
 
+  /// Bools are printed with conjunction.
+  static_assert(true && false, ""); // expected-error {{failed}} \

Neither this one.



Comment at: clang/test/SemaCXX/static-assert.cpp:270
+  /// Bools are printed with conjunction.
+  static_assert(true && false, ""); // expected-error {{failed}} \
+

Remove the backslash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

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


[PATCH] D145545: [clang][Interp] Fix local variable (destructor) management in loop bodies

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping. Please prioritize this patch over the other interpreter patches since the 
others depend on it.


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

https://reviews.llvm.org/D145545

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144943

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D144164: [clang][Interp] Handle PtrMemOps

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144164

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


[PATCH] D143334: [clang][Interp] Fix diagnosing uninitialized ctor record arrays

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143334

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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146030

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


[PATCH] D144709: [clang-format] Improve QualifierAlignment

2023-03-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf added a comment.

Okay thanks. If the + options works let's go with
alexanderhederstaf+l...@gmail.com

Thanks again for the review and answers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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


[PATCH] D146814: [Flang] Add debug flag to enable current debug information pass

2023-03-27 Thread Sacha Ballantyne via Phabricator via cfe-commits
SBallantyne updated this revision to Diff 508552.
SBallantyne marked an inline comment as done.
SBallantyne added a comment.

Update tests to check for warning at higher debug levels, as well as amend 
warning message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146814

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Frontend/CodeGenOptions.h
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/mlir-debug-pass-pipeline.f90

Index: flang/test/Driver/mlir-debug-pass-pipeline.f90
===
--- /dev/null
+++ flang/test/Driver/mlir-debug-pass-pipeline.f90
@@ -0,0 +1,76 @@
+! Test the debug pass pipeline
+
+! RUN: %flang -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline -o /dev/null %s 2>&1 | FileCheck --check-prefixes=ALL,NO-DEBUG %s
+!
+! RUN: %flang -g0 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,NO-DEBUG %s
+! RUN: %flang -g -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -g1 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -gline-tables-only -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG %s
+! RUN: %flang -gline-directives-only -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG,DEBUG-DIRECTIVES %s
+! RUN: %flang -g2 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG,DEBUG-CONSTRUCT %s
+! RUN: %flang -g3 -S -mmlir --mlir-pass-statistics -mmlir --mlir-pass-statistics-display=pipeline %s -o /dev/null 2>&1 | FileCheck --check-prefixes=ALL,DEBUG,DEBUG-CONSTRUCT %s
+
+! REQUIRES: asserts
+
+end program
+! DEBUG-CONSTRUCT: warning: Debug options greater than -g1 not yet implemented
+! DEBUG-DIRECTIVES: warning: Debug options greater than -g1 not yet implemented
+! ALL: Pass statistics report
+
+! ALL: Fortran::lower::VerifierPass
+! ALL-NEXT: LowerHLFIRIntrinsics
+! ALL-NEXT: BufferizeHLFIR
+! ALL-NEXT: ConvertHLFIRtoFIR
+! ALL-NEXT: CSE
+! Ideally, we need an output with only the pass names, but
+! there is currently no way to get that, so in order to
+! guarantee that the passes are in the expected order
+! (i.e. use -NEXT) we have to check the statistics output as well.
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   ArrayValueCopy
+! ALL-NEXT:   CharacterConversion
+
+! ALL-NEXT: Canonicalizer
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   MemoryAllocationOpt
+
+! ALL-NEXT: Inliner
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+
+! ALL-NEXT: 'func.func' Pipeline
+! ALL-NEXT:   PolymorphicOpConversion
+! ALL-NEXT:   CFGConversion
+
+! ALL-NEXT: SCFToControlFlow
+! ALL-NEXT: Canonicalizer
+! ALL-NEXT: SimplifyRegionLite
+! ALL-NEXT: CSE
+! ALL-NEXT:   (S) 0 num-cse'd - Number of operations CSE'd
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations DCE'd
+! ALL-NEXT: BoxedProcedurePass
+
+! ALL-NEXT: Pipeline Collection : ['fir.global', 'func.func']
+! ALL-NEXT:   'fir.global' Pipeline
+! ALL-NEXT:AbstractResultOnGlobalOpt
+! ALL-NEXT:  'func.func' Pipeline
+! ALL-NEXT:AbstractResultOnFuncOpt
+
+! ALL-NEXT: CodeGenRewrite
+! ALL-NEXT:   (S) 0 num-dce'd - Number of operations eliminated
+! ALL-NEXT: TargetRewrite
+! ALL-NEXT: ExternalNameConversion
+! DEBUG-NEXT: AddDebugFoundation
+! NO-DEBUG-NOT: AddDebugFoundation
+! ALL-NEXT: FIRToLLVMLowering
+! ALL-NOT: LLVMIRLoweringPass
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -56,6 +56,8 @@
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscori

[PATCH] D146941: [clangd] Use all inputs to SystemIncludeExtractor in cache key

2023-03-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: nridge.
Herald added a subscriber: arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Instead of passing in a tooling::CompileCommand into system include
extraction, pass a limited set, whose elements are used as keys.

Also fix the issue around accepting `-isysroot=/foo` which isn't a valid
argument (or the directory should be `=/foo` not `/foo`).

Fixes https://github.com/clangd/clangd/issues/1404
Fixes https://github.com/clangd/clangd/issues/1403

This should also unblock https://reviews.llvm.org/D138546


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146941

Files:
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test

Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -14,8 +14,8 @@
 # Check that clangd preserves certain flags like `-nostdinc` from
 # original invocation in compile_commands.json.
 # RUN: echo '[ -z "${args##*"-nostdinc"*}" ] || exit' >> %t.dir/bin/my_driver.sh
-# RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo '[ -z "${args##*"--sysroot /my/sysroot/path"*}" ] || exit' >> %t.dir/bin/my_driver.sh
+# RUN: echo '[ -z "${args##*"-isysroot /isysroot"*}" ] || exit' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/bin/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/bin/my_driver.sh
@@ -32,7 +32,7 @@
 
 # Generate a compile_commands.json that will query the mock driver we've
 # created. Which should add a.h and b.h into include search path.
-# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "my_driver.sh the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
 # On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
@@ -42,7 +42,7 @@
 # Bless the mock driver we've just created so that clangd can execute it.
 # Note: include clangd's stderr in the FileCheck input with "2>&1" so that we
 # can match output lines like "ASTWorker building file"
-# RUN: clangd -lit-test -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test
+# RUN: clangd -lit-test -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test -dump-input=fail
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
 ---
 {
@@ -70,7 +70,7 @@
 {"jsonrpc":"2.0","method":"exit"}
 
 # Generate a different compile_commands.json which does not point to the mock driver
-# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot=/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
+# RUN: echo '[{"directory": "%/t.dir", "command": "gcc the-file.cpp -nostdinc --sysroot /my/sysroot/path -isysroot/isysroot", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
 
 # Generate a clangd config file which points to the mock driver instead
 # RUN: echo 'CompileFlags:' > %t.dir/.clangd
Index: clang-tools-extra/clangd/SystemIncludeExtractor.cpp
===
--- clang-tools-extra/clangd/SystemIncludeExtractor.cpp
+++ clang-tools-extra/clangd/SystemIncludeExtractor.cpp
@@ -32,15 +32,22 @@
 #include "CompileCommands.h"
 #include "GlobalCompilationDatabase.h"
 #include "support/Logger.h"
-#include "support/Path.h"
+#include "support/Threading.h"
 #include "support/Trace.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Driver/Types.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/FileSystem.h"
@@ -49,15 +56,17 @@
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/ScopedPrinter.h"
-#include 
+#include "llvm/Support

[PATCH] D146942: PowerPC ABI incompatibility with GNU on complex arguments

2023-03-27 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 created this revision.
umesh.kalappa0 added a reviewer: nikic.
umesh.kalappa0 added projects: LLVM, clang.
Herald added subscribers: StephenFan, shchenz, nemanjai.
Herald added a project: All.
umesh.kalappa0 requested review of this revision.
Herald added a subscriber: cfe-commits.

Changes : Like GNU GCC passes and returns float/double/long double  complex in 
FPRs .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146942

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4720,6 +4720,7 @@
 IsRetSmallStructInRegABI(RetSmallStructInRegABI) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
 if (!getCXXABI().classifyReturnType(FI))
@@ -4776,6 +4777,15 @@
   return CharUnits::fromQuantity(4);
 }
 
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (Ty->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
+  return DefaultABIInfo::classifyArgumentType(Ty);
+}
+
 ABIArgInfo PPC32_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
   uint64_t Size;
 
@@ -4801,6 +4811,9 @@
 }
   }
 
+  if (RetTy->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
   return DefaultABIInfo::classifyReturnType(RetTy);
 }
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4720,6 +4720,7 @@
 IsRetSmallStructInRegABI(RetSmallStructInRegABI) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
 if (!getCXXABI().classifyReturnType(FI))
@@ -4776,6 +4777,15 @@
   return CharUnits::fromQuantity(4);
 }
 
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (Ty->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
+  return DefaultABIInfo::classifyArgumentType(Ty);
+}
+
 ABIArgInfo PPC32_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
   uint64_t Size;
 
@@ -4801,6 +4811,9 @@
 }
   }
 
+  if (RetTy->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
   return DefaultABIInfo::classifyReturnType(RetTy);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-03-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Sorry I was waiting for D139277  to land, but 
it seems to be stuck so sent out D146941 . 
Let's take a look at this again after that one lands


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

https://reviews.llvm.org/D138546

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


[clang] a826b90 - [clang] source range of variable template specialization should include initializer

2023-03-27 Thread Tomasz Kamiński via cfe-commits

Author: Tomasz Kamiński
Date: 2023-03-27T12:22:06+02:00
New Revision: a826b9034bbd046a5d0708ba656a3d345d179920

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

LOG: [clang] source range of variable template specialization should include 
initializer

This patch adjust the getSourceRange() for the
VarTemplateSpecializationDecl and VarTemplatePartialSpecializationDecl,
such that the initializer is included if present:
```
template
T temp = 1;

template<> double temp = 1;
```
This patch makes it consistent with the behavior of
non-template variables with initializers and restores
behavior that was present before https://reviews.llvm.org/D139705.

n case, when the initializer is not present we still
include the template arguments in the source range,
which was required for fixing zero-initialization fix-it.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclTemplate.h
clang/lib/AST/DeclTemplate.cpp
clang/test/AST/ast-dump-template-decls.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5ea223eca9564..385f7db0e7afa 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -230,6 +230,11 @@ Bug Fixes in This Version
   antecipation of `CWG2563 
_`.
 - Fix highlighting issue with ``_Complex`` and initialization list with more 
than
   2 items. (`#61518 `_)
+- Fix  ``getSourceRange`` on  ``VarTemplateSpecializationDecl`` and
+  ``VarTemplatePartialSpecializationDecl``, which represents variable with
+  the initializer, so it behaves consistently with other ``VarDecls`` and ends
+  on the last token of initializer, instead of right angle bracket of
+  the template argument list.
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index ae2542f4f2311..f2a1e165a70f3 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2926,13 +2926,7 @@ class VarTemplateSpecializationDecl : public VarDecl,
 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
   }
 
-  SourceRange getSourceRange() const override LLVM_READONLY {
-if (isExplicitSpecialization()) {
-  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
-return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
-}
-return VarDecl::getSourceRange();
-  }
+  SourceRange getSourceRange() const override LLVM_READONLY;
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, TemplateArgs->asArray(), getASTContext());
@@ -3091,13 +3085,7 @@ class VarTemplatePartialSpecializationDecl
 return First->InstantiatedFromMember.setInt(true);
   }
 
-  SourceRange getSourceRange() const override LLVM_READONLY {
-if (isExplicitSpecialization()) {
-  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
-return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
-}
-return VarDecl::getSourceRange();
-  }
+  SourceRange getSourceRange() const override LLVM_READONLY;
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),

diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 531be708b6fd5..77dfd58fdd324 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1402,6 +1402,15 @@ void VarTemplateSpecializationDecl::setTemplateArgsInfo(
   ASTTemplateArgumentListInfo::Create(getASTContext(), ArgsInfo);
 }
 
+SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
+  if (isExplicitSpecialization() && !hasInit()) {
+if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
+  return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+  }
+  return VarDecl::getSourceRange();
+}
+
+
 
//===--===//
 // VarTemplatePartialSpecializationDecl Implementation
 
//===--===//
@@ -1447,6 +1456,14 @@ 
VarTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C,
   return new (C, ID) VarTemplatePartialSpecializationDecl(C);
 }
 
+SourceRange VarTemplatePartialSpecializationDecl::getSourceRange() const {
+  if (isExplicitSpecialization() && !hasInit()) {
+if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
+  return SourceRange(getOuterLocStart(), Info->getRAngleLoc());

[PATCH] D146733: [clang] source range of variable template specialization should include initializer

2023-03-27 Thread Tomasz Kamiński 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 rGa826b9034bbd: [clang] source range of variable template 
specialization should include… (authored by tomasz-kaminski-sonarsource).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146733

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/test/AST/ast-dump-template-decls.cpp

Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -197,9 +197,7 @@
 
 template<>
 float unTempl = 1;
-// FIXME (#61680) - serializing and loading AST should not affect reported source range
-// DIRECT: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
-// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
+// CHECK:  VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 unTempl 'float' cinit
 // CHECK-NEXT: |-TemplateArgument type 'float'
 // CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
 // CHECK-NEXT: `-ImplicitCastExpr 0x{{[^ ]*}}  'float' 
@@ -245,9 +243,7 @@
 
 template<>
 float binTempl = 1;
-// FIXME (#61680) - serializing and loading AST should not affect reported source range
-// DIRECT:VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 binTempl 'float' cinit
-// SERIALIZED: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 binTempl 'float' cinit
+// CHECK: VarTemplateSpecializationDecl 0x{{[^ ]*}}  col:7 binTempl 'float' cinit
 // CHECK-NEXT: |-TemplateArgument type 'float'
 // CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'float'
 // CHECK-NEXT: |-TemplateArgument type 'float'
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -1402,6 +1402,15 @@
   ASTTemplateArgumentListInfo::Create(getASTContext(), ArgsInfo);
 }
 
+SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
+  if (isExplicitSpecialization() && !hasInit()) {
+if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
+  return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+  }
+  return VarDecl::getSourceRange();
+}
+
+
 //===--===//
 // VarTemplatePartialSpecializationDecl Implementation
 //===--===//
@@ -1447,6 +1456,14 @@
   return new (C, ID) VarTemplatePartialSpecializationDecl(C);
 }
 
+SourceRange VarTemplatePartialSpecializationDecl::getSourceRange() const {
+  if (isExplicitSpecialization() && !hasInit()) {
+if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
+  return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
+  }
+  return VarDecl::getSourceRange();
+}
+
 static TemplateParameterList *
 createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) {
   // typename T
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -2926,13 +2926,7 @@
 return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
   }
 
-  SourceRange getSourceRange() const override LLVM_READONLY {
-if (isExplicitSpecialization()) {
-  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsInfo())
-return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
-}
-return VarDecl::getSourceRange();
-  }
+  SourceRange getSourceRange() const override LLVM_READONLY;
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, TemplateArgs->asArray(), getASTContext());
@@ -3091,13 +3085,7 @@
 return First->InstantiatedFromMember.setInt(true);
   }
 
-  SourceRange getSourceRange() const override LLVM_READONLY {
-if (isExplicitSpecialization()) {
-  if (const ASTTemplateArgumentListInfo *Info = getTemplateArgsAsWritten())
-return SourceRange(getOuterLocStart(), Info->getRAngleLoc());
-}
-return VarDecl::getSourceRange();
-  }
+  SourceRange getSourceRange() const override LLVM_READONLY;
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
 Profile(ID, getTemplateArgs().asArray(), getTemplateParameters(),
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -230,6 +230,11 @@
   antecipation of `CWG2563 _`.
 - Fix highlighting issue with ``_Complex`` and initialization list with more than
   2 items. (`#61518 

[PATCH] D146892: [documentation]Fixed Random Typo

2023-03-27 Thread Ayushi Shukla via Phabricator via cfe-commits
ayushi-8102 updated this revision to Diff 508557.
ayushi-8102 added a comment.

discarded changes from another commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146892

Files:
  clang/docs/AutomaticReferenceCounting.rst
  clang/docs/ConstantInterpreter.rst
  clang/docs/CrossCompilation.rst
  clang/docs/DataFlowAnalysisIntro.md
  clang/docs/DebuggingCoroutines.rst
  clang/docs/analyzer/developer-docs/nullability.rst
  clang/include/clang/AST/CXXInheritance.h
  clang/include/clang/AST/CommentSema.h
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/DeclarationName.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Analysis/Analyses/Consumed.h

Index: clang/include/clang/Analysis/Analyses/Consumed.h
===
--- clang/include/clang/Analysis/Analyses/Consumed.h
+++ clang/include/clang/Analysis/Analyses/Consumed.h
@@ -258,7 +258,7 @@
 /// Check a function's CFG for consumed violations.
 ///
 /// We traverse the blocks in the CFG, keeping track of the state of each
-/// value who's type has uniquness annotations.  If methods are invoked in
+/// value who's type has uniqueness annotations.  If methods are invoked in
 /// the wrong state a warning is issued.  Each block in the CFG is traversed
 /// exactly once.
 void run(AnalysisDeclContext &AC);
Index: clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
===
--- clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
+++ clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
@@ -28,7 +28,7 @@
 /// \enum IfThen -- then branch of the if statement has no call.
 /// \enum IfElse -- else branch of the if statement has no call.
 /// \enum Switch -- one of the switch cases doesn't have a call.
-/// \enum SwitchSkipped -- there is no call if none of the cases appies.
+/// \enum SwitchSkipped -- there is no call if none of the cases applies.
 /// \enum LoopEntered -- no call when the loop is entered.
 /// \enum LoopSkipped -- no call when the loop is not entered.
 /// \enum FallbackReason -- fallback case when we were not able to figure out
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -135,8 +135,8 @@
   void setDependence(ExprDependence Deps) {
 ExprBits.Dependent = static_cast(Deps);
   }
-  friend class ASTImporter; // Sets dependence dircetly.
-  friend class ASTStmtReader; // Sets dependence dircetly.
+  friend class ASTImporter;   // Sets dependence directly.
+  friend class ASTStmtReader; // Sets dependence directly.
 
 public:
   QualType getType() const { return TR; }
@@ -171,7 +171,7 @@
   }
 
   /// Determines whether the type of this expression depends on
-  ///   - a template paramter (C++ [temp.dep.expr], which means that its type
+  ///   - a template parameter (C++ [temp.dep.expr], which means that its type
   /// could change from one template instantiation to the next)
   ///   - or an error
   ///
@@ -820,7 +820,7 @@
   /// member expression.
   static QualType findBoundMemberType(const Expr *expr);
 
-  /// Skip past any invisble AST nodes which might surround this
+  /// Skip past any invisible AST nodes which might surround this
   /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes,
   /// but also injected CXXMemberExpr and CXXConstructExpr which represent
   /// implicit conversions.
@@ -924,7 +924,7 @@
 return const_cast(this)->IgnoreParenLValueCasts();
   }
 
-  /// Skip past any parenthese and casts which do not change the value
+  /// Skip past any parentheses and casts which do not change the value
   /// (including ptr->int casts of the same size) until reaching a fixed point.
   /// Skips:
   /// * What IgnoreParens() skips
@@ -2815,7 +2815,7 @@
   /// The number of arguments in the call expression.
   unsigned NumArgs;
 
-  /// The location of the right parenthese. This has a different meaning for
+  /// The location of the right parentheses. This has a different meaning for
   /// the derived classes of CallExpr.
   SourceLocation RParenLoc;
 
Index: clang/include/clang/AST/DeclarationName.h
===
--- clang/include/clang/AST/DeclarationName.h
+++ clang/include/clang/AST/DeclarationName.h
@@ -763,7 +763,7 @@
 };
 
 /// DeclarationNameInfo - A collector data type for bundling together
-/// a DeclarationName and the correspnding source/type location info.
+/// a DeclarationName and the corresponding source/type location info.
 struct DeclarationNameInfo {
 private:
   /// Name - The declaration name, also encoding name kind.
Index

[PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

2023-03-27 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 508562.
Michael137 added a comment.

- Refine tests:
  - Check for type of template parameter
  - Add test for chained typedefs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/preferred_name-chain.cpp
  clang/test/CodeGen/preferred_name.cpp
  clang/test/Modules/Inputs/gmodules-preferred-name-alias.h
  clang/test/Modules/Inputs/gmodules-preferred-name-alias.modulemap
  clang/test/Modules/Inputs/gmodules-preferred-name-typedef.h
  clang/test/Modules/Inputs/gmodules-preferred-name-typedef.modulemap
  clang/test/Modules/gmodules-preferred-name-alias.cpp
  clang/test/Modules/gmodules-preferred-name-typedef.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -22,7 +22,7 @@
 
 def make_expected_basic_string_ptr(self) -> str:
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-return f'std::unique_ptr >'
+return f'std::unique_ptr'
 else:
 return 'std::unique_ptr, std::allocator >, ' \
'std::default_delete, std::allocator > > >'
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
@@ -59,13 +59,13 @@
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-string_type = "std::basic_string"
+string_type = "std::string"
 else:
-string_type = "std::basic_string, std::allocator >"
+string_type = "std::basic_string, std::allocator > "
 
 valobj = self.expect_var_path(
 "sp_str",
-type="std::shared_ptr<" + string_type + " >",
+type="std::shared_ptr<" + string_type + ">",
 children=[ValueCheck(name="__ptr_", summary='"hello"')],
 )
 self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$')
Index: clang/test/Modules/gmodules-preferred-name-typedef.cpp
===
--- /dev/null
+++ clang/test/Modules/gmodules-preferred-name-typedef.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-typedef.modulemap \
+// RUN: -fmodules-cache-path=%t -debug-info-kind=standalone -debugger-tuning=lldb \
+// RUN: -fmodules -mllvm -debug-only=pchcontainer -x c++ \
+// RUN: -I %S/Inputs %s &> %t.ll
+// RUN: cat %t.ll | FileCheck %s
+
+#include "gmodules-preferred-name-typedef.h"
+
+// CHECK: ![[#]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[PREF_BASE:[0-9]+]])
+// CHECK: ![[PREF_BASE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
Index: clang/test/Modules/gmodules-preferred-name-alias.cpp
===
--- /dev/null
+++ clang/test/Modules/gmodules-preferred-name-alias.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-alias.modulemap \
+// RUN: -fmodules-cache-path=%t -debug-info-kind=standalone -debugger-tuning=lldb \
+// RUN: -fmodules -mllvm -debug-only=pchcontainer -x c++ \
+// RUN: -I %S/Inputs %s &> %t.ll
+// RUN: cat %t.ll | FileCheck %s
+
+#include "gmodules-preferred-name-alias.h"
+
+// CHECK: ![[#]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[PREF_BASE:[0-9]+]])
+// CHECK: ![[PREF_BASE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
Index: clang/test/Modules/Inputs/gmodules-preferred-name-typedef.modulemap
===

[PATCH] D145803: [clang][DebugInfo] Emit DW_AT_type of preferred name if available

2023-03-27 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 508563.
Michael137 added a comment.

- Fix function docstring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145803

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/preferred_name-chain.cpp
  clang/test/CodeGen/preferred_name.cpp
  clang/test/Modules/Inputs/gmodules-preferred-name-alias.h
  clang/test/Modules/Inputs/gmodules-preferred-name-alias.modulemap
  clang/test/Modules/Inputs/gmodules-preferred-name-typedef.h
  clang/test/Modules/Inputs/gmodules-preferred-name-typedef.modulemap
  clang/test/Modules/gmodules-preferred-name-alias.cpp
  clang/test/Modules/gmodules-preferred-name-typedef.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -22,7 +22,7 @@
 
 def make_expected_basic_string_ptr(self) -> str:
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-return f'std::unique_ptr >'
+return f'std::unique_ptr'
 else:
 return 'std::unique_ptr, std::allocator >, ' \
'std::default_delete, std::allocator > > >'
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
@@ -59,13 +59,13 @@
 self.assertNotEqual(valobj.child[0].unsigned, 0)
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(['>', '16.0']):
-string_type = "std::basic_string"
+string_type = "std::string"
 else:
-string_type = "std::basic_string, std::allocator >"
+string_type = "std::basic_string, std::allocator > "
 
 valobj = self.expect_var_path(
 "sp_str",
-type="std::shared_ptr<" + string_type + " >",
+type="std::shared_ptr<" + string_type + ">",
 children=[ValueCheck(name="__ptr_", summary='"hello"')],
 )
 self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=1$')
Index: clang/test/Modules/gmodules-preferred-name-typedef.cpp
===
--- /dev/null
+++ clang/test/Modules/gmodules-preferred-name-typedef.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-typedef.modulemap \
+// RUN: -fmodules-cache-path=%t -debug-info-kind=standalone -debugger-tuning=lldb \
+// RUN: -fmodules -mllvm -debug-only=pchcontainer -x c++ \
+// RUN: -I %S/Inputs %s &> %t.ll
+// RUN: cat %t.ll | FileCheck %s
+
+#include "gmodules-preferred-name-typedef.h"
+
+// CHECK: ![[#]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[PREF_BASE:[0-9]+]])
+// CHECK: ![[PREF_BASE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
Index: clang/test/Modules/gmodules-preferred-name-alias.cpp
===
--- /dev/null
+++ clang/test/Modules/gmodules-preferred-name-alias.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
+// RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-alias.modulemap \
+// RUN: -fmodules-cache-path=%t -debug-info-kind=standalone -debugger-tuning=lldb \
+// RUN: -fmodules -mllvm -debug-only=pchcontainer -x c++ \
+// RUN: -I %S/Inputs %s &> %t.ll
+// RUN: cat %t.ll | FileCheck %s
+
+#include "gmodules-preferred-name-alias.h"
+
+// CHECK: ![[#]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Bar", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[PREF_BASE:[0-9]+]])
+// CHECK: ![[PREF_BASE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
Index: clang/test/Modules/Inputs/gmodules-preferred-name-typedef.modulemap
===
--- /dev/null
+++ clan

[PATCH] D142347: [NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in Flang

2023-03-27 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

LGTM. This refactoring helps share code between Clang and Flang. Please wait a 
couple of days before submitting.

Additional notes in support of approval:
-> The llvm community approved @jdoerfert 's proposal for llvm/lib/Frontend as 
a common directory for sharing code between multiple frontends. 
https://discourse.llvm.org/t/rfc-create-llvm-lib-frontend/53681
-> In general the flang community would like to have the Flang driver 
independent of Clang. I believe the Clang project is fine with this as OKed in 
a reply to a previous RFC 
(https://lists.llvm.org/pipermail/cfe-dev/2020-August/066488.html)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142347

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


[PATCH] D145671: [clang] Remove legacy -m(no)-code-object-v3 options

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

These changes need a release note. Given that this has been deprecated, is 
there documentation that should have been removed as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145671

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


[PATCH] D145581: [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments.

2023-03-27 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D145581#4215602 , @PiotrZSL wrote:

> Switching status of review, once you will be ready with changes (or your 
> decision), just mark it ready for review again.

Thanks, and sorry for the delayed response on this -- I've been juggling this 
patch with other work.

In D145581#4223185 , @PiotrZSL wrote:

> And actually there is issue for this: 
> https://github.com/llvm/llvm-project/issues/57758

Thanks for making me aware of this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145581

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


[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-03-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.html:19
+Function
+
+

gribozavr2 wrote:
> Could you add the file name and line number of the start location of the 
> function?
> 
> It might be helpful not only for the reader (to confirm that they are 
> debugging the right thing), but also when finding the right html file using 
> grep.
Added filename to the top of the code, and line numbers to each line.
(This seems nice for display, but doesn't allow you to grep for `foo.cpp:42` - 
is that critical?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

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


[PATCH] D146945: Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread Pierre van Houtryve via Phabricator via cfe-commits
Pierre-vh created this revision.
Pierre-vh added a reviewer: aaron.ballman.
Herald added a project: All.
Pierre-vh requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146945

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@
   undefined symbols in the created module to be a linker error. To prevent 
this,
   pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
   --undefined`` if using an offloading language.
+- The deprecated ``-mcode-object-v3`` and ``-mno-code-object-v3`` command-line 
+  options have been removed.
 
 X86 Support
 ^^^


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@
   undefined symbols in the created module to be a linker error. To prevent this,
   pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
   --undefined`` if using an offloading language.
+- The deprecated ``-mcode-object-v3`` and ``-mno-code-object-v3`` command-line 
+  options have been removed.
 
 X86 Support
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145671: [clang] Remove legacy -m(no)-code-object-v3 options

2023-03-27 Thread Pierre van Houtryve via Phabricator via cfe-commits
Pierre-vh added a comment.

In D145671#4223655 , @c wrote:

> These changes need a release note. Given that this has been deprecated, is 
> there documentation that should have been removed as well?

I can't find anything in the docs about `code-object-v3` so I don't think 
there's any documentation left. For the release note, I opened a diff: D146945 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145671

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


[PATCH] D145671: [clang] Remove legacy -m(no)-code-object-v3 options

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D145671#4223674 , @Pierre-vh wrote:

> In D145671#4223655 , @c wrote:
>
>> These changes need a release note. Given that this has been deprecated, is 
>> there documentation that should have been removed as well?
>
> I can't find anything in the docs about `code-object-v3` so I don't think 
> there's any documentation left. For the release note, I opened a diff: 
> D146945 

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145671

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


[PATCH] D146945: Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: clang-vendors.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Adding the clang-vendors group for awareness since this technically could 
break some downstream (I don't expect it to given that this was deprecated, but 
you never know).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146945

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


[PATCH] D146946: [RISCV][MC] Add support for experimental zicond extension

2023-03-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb created this revision.
asb added reviewers: reames, craig.topper.
Herald added subscribers: jobnoorman, luke, wingo, pmatos, VincentWu, vkmr, 
frasercrmck, jdoerfert, evandro, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
asb requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added projects: clang, LLVM.

This patch adds the basic MC layer support for Zicond, based on 1.0-rc1 
. As with other 
extensions, if there are additional changes between release candidates without 
incrementing the version number we won't be able to reflect that in the version 
number. I believe we've previously decided this is not a problem for extensions 
still considered experimental (i.e. not yet ratified).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146946

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicond.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zicond-invalid.s
  llvm/test/MC/RISCV/rv32zicond-valid.s

Index: llvm/test/MC/RISCV/rv32zicond-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zicond-valid.s
@@ -0,0 +1,18 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicond -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicond -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicond < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicond -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicond < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicond -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: czero.eqz t0, a3, ra
+# CHECK-ASM: encoding: [0xb3,0xd2,0x16,0x0e]
+czero.eqz t0, a3, ra
+
+# CHECK-ASM-AND-OBJ: czero.nez a1, gp, t6
+# CHECK-ASM: encoding: [0xb3,0xf5,0xf1,0x0f]
+czero.nez a1, gp, t6
Index: llvm/test/MC/RISCV/rv32zicond-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zicond-invalid.s
@@ -0,0 +1,18 @@
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zicond < %s 2>&1 | FileCheck %s
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zicond < %s 2>&1 | FileCheck %s
+
+# Use of operand modifier on register name
+czero.eqz t1, %lo(t2), t3 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
+
+# Invalid register name
+czero.nez a4, a3, foo # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
+
+# Invalid operand type
+czero.eqz t1, 2, t3 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
+
+# Too many operands
+czero.eqz t1, t2, t3, t4 # CHECK: :[[@LINE]]:23: error: invalid operand for instruction
+czero.nez t1, t2, t3, 4 # CHECK: :[[@LINE]]:23: error: invalid operand for instruction
+
+# Too few operands
+czero.eqz t1, t2 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -236,3 +236,6 @@
 
 .attribute arch, "rv32izfa0p1"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zfa0p1"
+
+.attribute arch, "rv32izicond1p0"
+# CHECK: attribute  5, "rv32i2p0_zicond1p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -64,6 +64,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+experimental-zvks %s -o - | FileCheck --check-prefix=RV32ZVKS %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+experimental-zvksed %s -o - | FileCheck --check-prefix=RV32ZVKSED %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+experimental-zvksh %s -o - | FileCheck --check-prefix=RV32ZVKSH %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zicond %s -o - | FileCheck --check-prefix=RV32ZICOND %s
 
 ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s
@@ -135,6 +136,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zve32x -

[PATCH] D146867: [Diagnostic] printing name of uninitialized subobject instead of its type

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

(Btw, if you no longer plan to work on a patch, it's considered good form to 
"abandon" the patch in Phabricator. You can do this by clicking the Add Action 
drop-down menu and selecting Abandon Changes.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146867

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


[PATCH] D146945: Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread Pierre van Houtryve via Phabricator via cfe-commits
Pierre-vh added a comment.

In D146945#4223677 , @aaron.ballman 
wrote:

> LGTM! Adding the clang-vendors group for awareness since this technically 
> could break some downstream (I don't expect it to given that this was 
> deprecated, but you never know).

Can it land or should I wait for someone from that group to comment first?
Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146945

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


[PATCH] D146945: Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146945#4223702 , @Pierre-vh wrote:

> In D146945#4223677 , @aaron.ballman 
> wrote:
>
>> LGTM! Adding the clang-vendors group for awareness since this technically 
>> could break some downstream (I don't expect it to given that this was 
>> deprecated, but you never know).
>
> Can it land or should I wait for someone from that group to comment first?
> Thanks

Sorry for adding confusion. :-) Feel free to land it -- if someone from 
clang-vendors has concerns, they can raise them here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146945

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


[clang] 4559e8e - Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread via cfe-commits

Author: pvanhout
Date: 2023-03-27T13:41:04+02:00
New Revision: 4559e8e8cd99a92ef4c02db00c0b9dc1dba86f28

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

LOG: Add Release Note for -mcode-object-v3 removal

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 385f7db0e7af..16dbe8ec8d27 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@ AMDGPU Support
   undefined symbols in the created module to be a linker error. To prevent 
this,
   pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
   --undefined`` if using an offloading language.
+- The deprecated ``-mcode-object-v3`` and ``-mno-code-object-v3`` command-line 
+  options have been removed.
 
 X86 Support
 ^^^



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


[PATCH] D146945: Add Release Note for -mcode-object-v3 removal

2023-03-27 Thread Pierre van Houtryve 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 rG4559e8e8cd99: Add Release Note for -mcode-object-v3 removal 
(authored by Pierre-vh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146945

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@
   undefined symbols in the created module to be a linker error. To prevent 
this,
   pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
   --undefined`` if using an offloading language.
+- The deprecated ``-mcode-object-v3`` and ``-mno-code-object-v3`` command-line 
+  options have been removed.
 
 X86 Support
 ^^^


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@
   undefined symbols in the created module to be a linker error. To prevent this,
   pass ``-Wl,--undefined`` if compiling directly, or ``-Xoffload-linker
   --undefined`` if using an offloading language.
+- The deprecated ``-mcode-object-v3`` and ``-mno-code-object-v3`` command-line 
+  options have been removed.
 
 X86 Support
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5ca710a - Revert "Silence unused variable warning in NDEBUG builds"

2023-03-27 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-27T05:01:53-07:00
New Revision: 5ca710ab148b0815c2b7b03fe2af643e637bbc7d

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

LOG: Revert "Silence unused variable warning in NDEBUG builds"

This reverts commit 8c7c1f11ffaacf762e612c65440fd2cbb58ee426.

Reason: Dependent change https://reviews.llvm.org/D126959 broke the ASan
buildbots. See that phabricator review for more comments.

Added: 


Modified: 
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 44c872336ce9c..f2b2d0b8c69f1 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -936,7 +936,6 @@ Module 
*ModuleMap::createModuleForImplementationUnit(SourceLocation Loc,
   // Mark the main source file as being within the newly-created module so that
   // declarations and macros are properly visibility-restricted to it.
   auto *MainFile = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
-  (void)MainFile;
   assert(MainFile && "no input file for module implementation");
 
   return Result;



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


[clang] 074f6fd - Revert "[C++20][Modules] Introduce an implementation module."

2023-03-27 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2023-03-27T05:01:53-07:00
New Revision: 074f6fd61d382ff6bf108472ea701d214b02f64b

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

LOG: Revert "[C++20][Modules] Introduce an implementation module."

This reverts commit c6e9823724ef6bdfee262289ee34d162db436af0.

Reason: Broke the ASan buildbots, see https://reviews.llvm.org/D126959
(the original phabricator review) for more info.

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/include/clang/Lex/ModuleMap.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/module/basic/basic.def.odr/p4.cppm
clang/test/CXX/module/basic/basic.link/p2.cppm
clang/test/CodeGenCXX/module-intializer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index c0c99eb8b6d62..387ce4d6e9b17 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -103,22 +103,16 @@ class alignas(8) Module {
   /// The location of the module definition.
   SourceLocation DefinitionLoc;
 
-  // FIXME: Consider if reducing the size of this enum (having Partition and
-  // Named modules only) then representing interface/implementation separately
-  // is more efficient.
   enum ModuleKind {
 /// This is a module that was defined by a module map and built out
 /// of header files.
 ModuleMapModule,
 
-/// This is a C++ 20 header unit.
-ModuleHeaderUnit,
-
 /// This is a C++20 module interface unit.
 ModuleInterfaceUnit,
 
-/// This is a C++20 module implementation unit.
-ModuleImplementationUnit,
+/// This is a C++ 20 header unit.
+ModuleHeaderUnit,
 
 /// This is a C++ 20 module partition interface.
 ModulePartitionInterface,
@@ -175,16 +169,9 @@ class alignas(8) Module {
   /// Does this Module scope describe part of the purview of a standard named
   /// C++ module?
   bool isModulePurview() const {
-switch (Kind) {
-case ModuleInterfaceUnit:
-case ModuleImplementationUnit:
-case ModulePartitionInterface:
-case ModulePartitionImplementation:
-case PrivateModuleFragment:
-  return true;
-default:
-  return false;
-}
+return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface ||
+   Kind == ModulePartitionImplementation ||
+   Kind == PrivateModuleFragment;
   }
 
   /// Does this Module scope describe a fragment of the global module within
@@ -574,11 +561,6 @@ class alignas(8) Module {
Kind == ModulePartitionImplementation;
   }
 
-  /// Is this a module implementation.
-  bool isModuleImplementation() const {
-return Kind == ModuleImplementationUnit;
-  }
-
   /// Is this module a header unit.
   bool isHeaderUnit() const { return Kind == ModuleHeaderUnit; }
   // Is this a C++20 module interface or a partition.

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index f155c609b06cb..a0ddd13c11bfd 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -560,11 +560,6 @@ class ModuleMap {
   Module *createPrivateModuleFragmentForInterfaceUnit(Module *Parent,
   SourceLocation Loc);
 
-  /// Create a new C++ module with the specified kind, and reparent any pending
-  /// global module fragment(s) to it.
-  Module *createModuleUnitWithKind(SourceLocation Loc, StringRef Name,
-   Module::ModuleKind Kind);
-
   /// Create a new module for a C++ module interface unit.
   /// The module must not already exist, and will be configured for the current
   /// compilation.
@@ -574,13 +569,6 @@ class ModuleMap {
   /// \returns The newly-created module.
   Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name);
 
-  /// Create a new module for a C++ module implementation unit.
-  /// The interface module for this implementation (implicitly imported) must
-  /// exist and be loaded and present in the modules map.
-  ///
-  /// \returns The newly-created module.
-  Module *createModuleForImplementationUnit(SourceLocation Loc, StringRef 
Name);
-
   /// Create a C++20 header unit.
   Module *createHeaderUnit(SourceLocation Loc, StringRef Name,
Module::Header H);

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9f7d58a4a3cd6..92ca3772dbef8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/

[PATCH] D126959: [C++20][Modules] Introduce an implementation module.

2023-03-27 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

Hi, yep, I've reverted upstream. If you could please also integrate 
https://reviews.llvm.org/rG8c7c1f11ffaacf762e612c65440fd2cbb58ee426 in the 
relanding, that would be great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126959

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


[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 508586.
VitaNuo marked 2 inline comments as done.
VitaNuo added a comment.

Address review comments. Use spelling locations for macro arguments, and 
expansion locations for everything else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -33,9 +33,11 @@
   tooling::stdlib::Recognizer Recognizer;
   for (auto *Root : ASTRoots) {
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
-  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
+  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)) &&
+  SM.getDecomposedLoc(SM.getSpellingLoc(Loc)).first !=
+  SM.getPreambleFileID())
 return;
-  // FIXME: Most of the work done here is repetative. It might be useful to
+  // FIXME: Most of the work done here is repetitive. It might be useful to
   // have a cache/batching.
   SymbolReference SymRef{Loc, ND, RT};
   return CB(SymRef, headersForSymbol(ND, SM, PI));
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -160,12 +160,8 @@
   ASSERT_TRUE(BDecl);
   include_cleaner::Symbol B{*BDecl};
   auto Range = MainFile.range("b");
-  size_t Start = llvm::cantFail(positionToOffset(MainFile.code(), Range.start));
-  size_t End = llvm::cantFail(positionToOffset(MainFile.code(), Range.end));
-  syntax::FileRange BRange{SM.getMainFileID(), static_cast(Start),
-   static_cast(End)};
   include_cleaner::Header Header{*SM.getFileManager().getFile("b.h")};
-  MissingIncludeDiagInfo BInfo{B, BRange, {Header}};
+  MissingIncludeDiagInfo BInfo{B, Range, {Header}};
   EXPECT_THAT(Findings.MissingIncludes, ElementsAre(BInfo));
 }
 
@@ -177,27 +173,39 @@
   WithContextValue Ctx(Config::Key, std::move(Cfg));
   Annotations MainFile(R"cpp(
 #include "a.h"
+#include "all.h"
 $insert_b[[]]#include "baz.h"
 #include "dir/c.h"
-$insert_d[[]]#include "fuzz.h"
+$insert_d[[]]$insert_foo[[]]#include "fuzz.h"
 #include "header.h"
 $insert_foobar[[]]#include 
 $insert_f[[]]$insert_vector[[]]
 
-void foo() {
-  $b[[b]]();
+#define DEF(X) const Foo *X;
+#define BAZ(X) const X x
 
-  ns::$bar[[Bar]] bar;
-  bar.d();
-  $f[[f]](); 
+  void foo() {
+$b[[b]]();
 
-  // this should not be diagnosed, because it's ignored in the config
-  buzz(); 
+ns::$bar[[Bar]] bar;
+bar.d();
+$f[[f]](); 
 
-  $foobar[[foobar]]();
+// this should not be diagnosed, because it's ignored in the config
+buzz(); 
 
-  std::$vector[[vector]] v;
-})cpp");
+$foobar[[foobar]]();
+
+std::$vector[[vector]] v;
+
+int var = $FOO[[FOO]];
+
+$DEF[[DEF]](a);
+
+$BAR[[BAR]](b);
+
+BAZ($Foo[[Foo]]);
+})cpp");
 
   TestTU TU;
   TU.Filename = "foo.cpp";
@@ -224,6 +232,13 @@
   namespace std { class vector {}; }
   )cpp");
 
+  TU.AdditionalFiles["all.h"] = guard("#include \"foo.h\"");
+  TU.AdditionalFiles["foo.h"] = guard(R"cpp(
+#define BAR(x) Foo *x
+#define FOO 1
+struct Foo{}; 
+  )cpp");
+
   TU.Code = MainFile.code();
   ParsedAST AST = TU.build();
 
@@ -253,7 +268,23 @@
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
   withFix(Fix(MainFile.range("insert_vector"),
-  "#include \n", "#include ");
+  "#include \n", "#include "))),
+  AllOf(Diag(MainFile.range("FOO"),
+ "No header providing \"FOO\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("DEF"),
+ "No header providing \"Foo\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("BAR"),
+ "No header providing \"BAR\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("Foo"),
+ "No header pro

[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Thanks for the comments!




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:382
 
-auto &Tokens = AST.getTokens();
-auto SpelledForExpanded =
-Tokens.spelledForExpanded(Tokens.expandedTokens(Ref.RefLocation));
-if (!SpelledForExpanded)
+auto ExpansionLoc = SM.getExpansionLoc(Ref.RefLocation);
+const auto *Token = AST.getTokens().spelledTokenAt(ExpansionLoc);

kadircet wrote:
> can you actually get the spelling location first and use expansion location 
> only when it isn't inside the main file?
> that way we get to preserve the behaviour for macro arguments, which warrants 
> a test like:
> ```
> #define FOO(X) const X x
> 
> FOO([[Foo]]); // we should have a missing include for symbol Foo here
> ```
> 
> and can we have a comment about reasons and implications, e.g. something like:
> ```
> Spelling locations can point into preamble section at times. We don't want to 
> emit diagnostics there as the offsets might be off when preamble is stale.
> In such cases we fallback to expansion locations, as they're always in the 
> main file. This means we fail to attach diagnostics to spelling of symbol 
> names inside macro bodies.
> // FIXME: Use presumed locations to make sure we can correctly generate 
> diagnostics even in such cases.
> ```
Sam suggested a magic solution for this, which is 
`SM.getFileLoc(Ref.RefLocation)`. Its documentation says:

```
/// Given \p Loc, if it is a macro location return the expansion
/// location or the spelling location, depending on if it comes from a
/// macro argument or not.
```

Sounds like what we need, right?



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:36
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
-  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
+  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)) &&
+  SM.getDecomposedLoc(SM.getSpellingLoc(Loc)).first !=

kadircet wrote:
> you can directly use expansion location instead of checking both and 
> mentioning preamble file id here, eg: 
> `!SM.isWrittenInMainFile(SM.getExpansionLoc(Loc))`
This actually leads to both `BAR` and `Foo` in `#define BAR(x) Foo *x` in 
`foo.h` being recognized as missing and attaches 2 diagnostics to `[[BAR]](b)` 
in the main file. AFAIU, this is exactly what you're asking me to prevent in 
the previous comment.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

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


[PATCH] D146922: [clang-tidy] Fix false positve for defaulted move constructor in performance-noexcept-move-constructor

2023-03-27 Thread André Schackier via Phabricator via cfe-commits
AMS21 added a comment.

@PiotrZSL thanks for the quick response.

I've tried to work on the `Field` test case but seem to have hit a roadblock. 
From what I can see the `FunctionProtoType` exception specificaion is 
`EST_Unevaluated` which causes it to give up because of the check on Line 41.
I'm not very familiar with the codebase but looked around and found the 
`ResolveExceptionSpec()` function inside `Sema.h` which seems to do exactly 
what I need: tell me if the implicit definition is throwing or not.
But I can't quite seem to figure out how to get a `Sema` object or construct 
one to use said function.
Or maybe there is another more clever way to go about it which I'm not aware of?

Any pointers into the right direction would be kindly appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146922

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


[PATCH] D146947: [docs][clang] Added extra information inside the flag -fsanitize=unsigned-shift-base for UndefinedBehaviorSanitizer Fix : #60712

2023-03-27 Thread Tiwari Abhinav Ashok Kumar via Phabricator via cfe-commits
aabhinavg created this revision.
Herald added a project: All.
aabhinavg requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146947

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst


Index: clang/docs/UndefinedBehaviorSanitizer.rst
===
--- clang/docs/UndefinedBehaviorSanitizer.rst
+++ clang/docs/UndefinedBehaviorSanitizer.rst
@@ -157,7 +157,8 @@
  ``-fsanitize=shift-exponent`` to check only left-hand side or
  right-hand side of shift operation, respectively.
   -  ``-fsanitize=unsigned-shift-base``: check that an unsigned left-hand side 
of
- a left shift operation doesn't overflow.
+ a left shift operation doesn't overflow.Issues caught by this sanitizer 
are 
+ not undefined behavior, but are often unintentional.
   -  ``-fsanitize=signed-integer-overflow``: Signed integer overflow, where the
  result of a signed integer computation cannot be represented in its type.
  This includes all the checks covered by ``-ftrapv``, as well as checks for


Index: clang/docs/UndefinedBehaviorSanitizer.rst
===
--- clang/docs/UndefinedBehaviorSanitizer.rst
+++ clang/docs/UndefinedBehaviorSanitizer.rst
@@ -157,7 +157,8 @@
  ``-fsanitize=shift-exponent`` to check only left-hand side or
  right-hand side of shift operation, respectively.
   -  ``-fsanitize=unsigned-shift-base``: check that an unsigned left-hand side of
- a left shift operation doesn't overflow.
+ a left shift operation doesn't overflow.Issues caught by this sanitizer are 
+ not undefined behavior, but are often unintentional.
   -  ``-fsanitize=signed-integer-overflow``: Signed integer overflow, where the
  result of a signed integer computation cannot be represented in its type.
  This includes all the checks covered by ``-ftrapv``, as well as checks for
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146326: [LinkerWrapper] Do not extract globals with no offloading language

2023-03-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146326

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


[PATCH] D146814: [Flang] Add debug flag to enable current debug information pass

2023-03-27 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

What's the overall design goal here? 100% consistency with Clang? Could this be 
documented?




Comment at: clang/include/clang/Driver/ToolChain.h:23
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Frontend/Debug/Options.h"

Unrelated change?



Comment at: clang/lib/Driver/ToolChains/Clang.h:16
 #include "clang/Driver/Types.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Frontend/Debug/Options.h"

Unrelated change?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:33
+// to the corresponding DebugInfoKind.
+static llvm::codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) {
+  assert(A.getOption().matches(options::OPT_gN_Group) &&

Looks identical to 
https://github.com/llvm/llvm-project/blob/cf60d3f1a688671c8eb7859bf0572c403c3c0cca/clang/lib/Driver/ToolChains/Clang.cpp#L406-L420.
 Why not move to 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/CommonArgs.cpp?



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:127
+unsigned val =
+llvm::StringSwitch(arg->getValue())
+.Case("line-tables-only", 
llvm::codegenoptions::DebugLineTablesOnly)

1. Why `unsigned` instead of [[ 
https://github.com/llvm/llvm-project/blob/cf60d3f1a688671c8eb7859bf0572c403c3c0cca/clang/include/clang/Basic/DebugInfoOptions.h#L20-L55
 | DebugInfoKind ]]
2. Why not use `std::optional`, e.g. 
`llvm::StringSwitch>arg->getValue())`? This way 
you could avoid magic numbers like `~0U`.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:137
+if (val == ~0U) {
+  diags.Report(clang::diag::err_drv_invalid_value)
+  << arg->getAsString(args) << arg->getValue();

Please test this diagnostic. Also, if this is an error then you should return 
immediately and signal that this method has failed (e.g. `return false;`).



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:144
+val != llvm::codegenoptions::NoDebugInfo) {
+  // TODO: This is not a great warning message, could be improved
+  const auto debugErr = diags.getCustomDiagID(

Please improve it :)

In particular, you are testing for `DebugLineTablesOnly` and `NoDebugInfo`, yet 
the diagnostic refers to `-g1`.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:145
+  // TODO: This is not a great warning message, could be improved
+  const auto debugErr = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Warning,

Looks like you are creating a warning rather than an error: `debugErr` --> 
`debugWarn`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146814

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


[PATCH] D146924: [clang] Add support for dollar sign in ud_suffix of numeric constants

2023-03-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I think it's worth pursuing and investigating as long as

- We requires some prefix before the dollar ( like `_`), and `42$ is never valid
- `-Wdollar-in-identifier-extension` is emitted
- We have a better understanding of the current behavior for the euro sign - 
logically the euro sign should be split in its own token too at the moment so 
*maybe* there is another bug there!

Thanks for working on this btw.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146924

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


[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:182-183
 
+  template 
+  bool visitConditional(const AbstractConditionalOperator *E, VisitFn V);
+

erichkeane wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > The template definition isn't available within the header file, so this 
> > > is fragile (impossible to instantiate from anything but 
> > > ByteCodeExprGen.cpp).
> > What's the alternative? If I make it a static function in 
> > `ByteCodeExprGen.cpp`, I'd have to make a lot of members of 
> > `ByteCodeEmitter` etc. public which  is not a very clean solution. Moving 
> > the definition into the header file isn't very nice either, all the others 
> > are in the source file.
> What about making it a static template in `ByteCodeExprGen.cpp`, but make it 
> a 'friend' here?  I think that would work, wouldn't it?  Something like: 
> https://godbolt.org/z/ofYbGvfYa
> 
> You unfortunately cannot make it static, but as it is a template, at least it 
> is inline.  WDYT?
I tried that but I keep running into linker problems:

```
mold: error: undefined symbol: lib/libclangAST.a(ByteCodeExprGen.cpp.o): bool 
clang::interp::visitConditional::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator
 const*)::{lambda(clang::Expr 
const*)#1}>(clang::interp::ByteCodeExprGen*, 
clang::AbstractConditionalOperator const*, 
clang::interp::ByteCodeExprGen::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator
 const*)::{lambda(clang::Expr const*)#1})
```
(and another one for `EvalEmitter`). But I can't investigate more before 
Wednesday.


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

https://reviews.llvm.org/D141497

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


[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:380
+auto Loc = SM.getFileLoc(Ref.RefLocation);
+auto Range = Lexer::makeFileCharRange(
+CharSourceRange{SourceRange{Loc}, true}, SM, AST.getLangOpts());

I don't think you need to re-lex the token here, as `Loc` is already a 
non-macro location in main file, you can still use 
`Tokens.spelledTokenAt(Loc)`. Am i missing something?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:382
 
-auto &Tokens = AST.getTokens();
-auto SpelledForExpanded =
-Tokens.spelledForExpanded(Tokens.expandedTokens(Ref.RefLocation));
-if (!SpelledForExpanded)
+auto ExpansionLoc = SM.getExpansionLoc(Ref.RefLocation);
+const auto *Token = AST.getTokens().spelledTokenAt(ExpansionLoc);

VitaNuo wrote:
> kadircet wrote:
> > can you actually get the spelling location first and use expansion location 
> > only when it isn't inside the main file?
> > that way we get to preserve the behaviour for macro arguments, which 
> > warrants a test like:
> > ```
> > #define FOO(X) const X x
> > 
> > FOO([[Foo]]); // we should have a missing include for symbol Foo here
> > ```
> > 
> > and can we have a comment about reasons and implications, e.g. something 
> > like:
> > ```
> > Spelling locations can point into preamble section at times. We don't want 
> > to emit diagnostics there as the offsets might be off when preamble is 
> > stale.
> > In such cases we fallback to expansion locations, as they're always in the 
> > main file. This means we fail to attach diagnostics to spelling of symbol 
> > names inside macro bodies.
> > // FIXME: Use presumed locations to make sure we can correctly generate 
> > diagnostics even in such cases.
> > ```
> Sam suggested a magic solution for this, which is 
> `SM.getFileLoc(Ref.RefLocation)`. Its documentation says:
> 
> ```
> /// Given \p Loc, if it is a macro location return the expansion
> /// location or the spelling location, depending on if it comes from a
> /// macro argument or not.
> ```
> 
> Sounds like what we need, right?
Rather than doing spelling & falling back to expansion, just doing `getFileLoc` 
definitely makes sense.
But what we actually want here is always map to spelling (e.g. we want `Foo` in 
macro body, rather than macro invocation to be highlighted).
It's just we can't have it all the time because accessing offsets coming from 
stale preamble might result in crashes. Hence can you also add the comment i 
mentioned above so that we don't forget? maybe with a rewording like:
```
// We actually always want to map usages to their spellings, but spelling 
locations can point into preamble section.
// Using these offsets could lead into crashes in presence of stale preambles. 
Hence we use `getFileLoc` instead to make sure it always points into main file.
// FIXME: Use presumed locations to map such usages back to patched locations 
safely.
```



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:36
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
-  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
+  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)) &&
+  SM.getDecomposedLoc(SM.getSpellingLoc(Loc)).first !=

VitaNuo wrote:
> kadircet wrote:
> > you can directly use expansion location instead of checking both and 
> > mentioning preamble file id here, eg: 
> > `!SM.isWrittenInMainFile(SM.getExpansionLoc(Loc))`
> This actually leads to both `BAR` and `Foo` in `#define BAR(x) Foo *x` in 
> `foo.h` being recognized as missing and attaches 2 diagnostics to 
> `[[BAR]](b)` in the main file. AFAIU, this is exactly what you're asking me 
> to prevent in the previous comment.
> 
> 
no you're right, i think i was just confused here.

still might be nicer to clean it up a little:
```
auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
  return;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

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


[PATCH] D142347: [NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in Flang

2023-03-27 Thread Sacha Ballantyne via Phabricator via cfe-commits
SBallantyne updated this revision to Diff 508617.
SBallantyne added a comment.

Remove references to non existing import


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142347

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/HIPSPV.cpp
  clang/lib/Driver/ToolChains/HIPSPV.h
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/tools/clang-import-test/clang-import-test.cpp
  llvm/include/llvm/Frontend/Debug/Options.h

Index: llvm/include/llvm/Frontend/Debug/Options.h
===
--- llvm/include/llvm/Frontend/Debug/Options.h
+++ llvm/include/llvm/Frontend/Debug/Options.h
@@ -6,10 +6,10 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
-#define LLVM_CLANG_BASIC_DEBUGINFOOPTIONS_H
+#ifndef LLVM_FRONTEND_DEBUG_OPTIONS_H
+#define LLVM_FRONTEND_DEBUG_OPTIONS_H
 
-namespace clang {
+namespace llvm {
 namespace codegenoptions {
 
 enum DebugInfoFormat {
@@ -54,13 +54,9 @@
   UnusedTypeInfo,
 };
 
-enum class DebugTemplateNamesKind {
-  Full,
-  Simple,
-  Mangled
-};
+enum class DebugTemplateNamesKind { Full, Simple, Mangled };
 
 } // end namespace codegenoptions
-} // end namespace clang
+} // end namespace llvm
 
 #endif
Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -200,7 +200,7 @@
   Inv->getLangOpts()->CXXExceptions = true;
   // Needed for testing dynamic_cast.
   Inv->getLangOpts()->RTTI = true;
-  Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
+  Inv->getCodeGenOpts().setDebugInfo(llvm::codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
   Ins->setInvocation(std::move(Inv));
Index: clang/lib/Frontend/Rewrite/FrontendActions.cpp
===
--- clang/lib/Frontend/Rewrite/FrontendActions.cpp
+++ clang/lib/Frontend/Rewrite/FrontendActions.cpp
@@ -165,10 +165,11 @@
   if (std::unique_ptr OS =
   CI.createDefaultOutputFile(false, InFile, "cpp")) {
 if (CI.getLangOpts().ObjCRuntime.isNonFragile())
-  return CreateModernObjCRewriter(
-  std::string(InFile), std::move(OS), CI.getDiagnostics(),
-  CI.getLangOpts(), CI.getDiagnosticOpts().NoRewriteMacros,
-  (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo));
+  return CreateModernObjCRewriter(std::string(InFile), std::move(OS),
+  CI.getDiagnostics(), CI.getLangOpts(),
+  CI.getDiagnosticOpts().NoRewriteMacros,
+  (CI.getCodeGenOpts().getDebugInfo() !=
+   llvm::codegenoptions::NoDebugInfo));
 return CreateObjCRewriter(std::string(InFile), std::move(OS),
   CI.getDiagnostics(), CI.getLangOpts(),
   CI.getDiagnosticOpts().NoRewriteMacros);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -12,7 +12,6 @@
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/CommentOptions.h"
-#include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Basic/DiagnosticOptions.h"
@@ -59,6 +58,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/MC/MCTargetOptions.h"
@@ -1397,28 +1397,28 @@
 
   std::optional DebugInfoVal;
   switch (Opts.DebugInfo) {
-  case codegenoptions::DebugLineTablesOnly:
+  case llvm::codegenoptions::DebugLineTablesOnly:
 DebugInfoVal = "line-tables-only";
 break;
-  case codegenoptions::DebugDirectivesOnly:
+  case llvm::codegenoptions::DebugDirectivesO

[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked an inline comment as done.
VitaNuo added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:380
+auto Loc = SM.getFileLoc(Ref.RefLocation);
+auto Range = Lexer::makeFileCharRange(
+CharSourceRange{SourceRange{Loc}, true}, SM, AST.getLangOpts());

kadircet wrote:
> I don't think you need to re-lex the token here, as `Loc` is already a 
> non-macro location in main file, you can still use 
> `Tokens.spelledTokenAt(Loc)`. Am i missing something?
It's for consistency with clangd diagnostic generation 
[here](http://google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp;l=114;rcl=512058308)
 (according to Sam), but both should work. 
Would you rather prefer `Tokens.spelledTokenAt(Loc)`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

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


[PATCH] D146788: [clang][Interp] Fix zero-initializing of floating types

2023-03-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 508619.
tbaeder marked an inline comment as done.

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

https://reviews.llvm.org/D146788

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/floats.cpp


Index: clang/test/AST/Interp/floats.cpp
===
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -78,3 +78,17 @@
   }
   static_assert(f2() == __FLT_MAX__, "");
 }
+
+namespace ZeroInit {
+  template
+  struct A {
+int a;
+FloatT f;
+  };
+
+  constexpr A a{12};
+  static_assert(a.f == 0.0f);
+
+  constexpr A b{12};
+  static_assert(a.f == 0.0);
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1068,8 +1068,10 @@
 return this->emitNullPtr(E);
   case PT_FnPtr:
 return this->emitNullFnPtr(E);
-  case PT_Float:
-assert(false);
+  case PT_Float: {
+return this->emitConstFloat(
+APFloat::getZero(Ctx.getFloatSemantics(E->getType())), E);
+  }
   }
   llvm_unreachable("unknown primitive type");
 }


Index: clang/test/AST/Interp/floats.cpp
===
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -78,3 +78,17 @@
   }
   static_assert(f2() == __FLT_MAX__, "");
 }
+
+namespace ZeroInit {
+  template
+  struct A {
+int a;
+FloatT f;
+  };
+
+  constexpr A a{12};
+  static_assert(a.f == 0.0f);
+
+  constexpr A b{12};
+  static_assert(a.f == 0.0);
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1068,8 +1068,10 @@
 return this->emitNullPtr(E);
   case PT_FnPtr:
 return this->emitNullFnPtr(E);
-  case PT_Float:
-assert(false);
+  case PT_Float: {
+return this->emitConstFloat(
+APFloat::getZero(Ctx.getFloatSemantics(E->getType())), E);
+  }
   }
   llvm_unreachable("unknown primitive type");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145579: [Clang][Flang][AMDGPU] Add support for AMDGPU to Flang driver

2023-03-27 Thread Dominik Adamski via Phabricator via cfe-commits
domada updated this revision to Diff 508618.
domada retitled this revision from "[Flang][AMDGPU] Add support for AMDGPU to 
Flang driver" to "[Clang][Flang][AMDGPU] Add support for AMDGPU to Flang 
driver".
domada edited the summary of this revision.
domada added a comment.

Rebase & applied review remarks


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

https://reviews.llvm.org/D145579

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/target-cpu-features.f90
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/TargetParser/TargetParser.cpp

Index: llvm/lib/TargetParser/TargetParser.cpp
===
--- llvm/lib/TargetParser/TargetParser.cpp
+++ llvm/lib/TargetParser/TargetParser.cpp
@@ -251,3 +251,216 @@
 
   return T.isAMDGCN() ? getArchNameAMDGCN(ProcKind) : getArchNameR600(ProcKind);
 }
+
+void AMDGPU::fillAMDGPUFeatureMap(StringRef GPU, const Triple &T,
+  StringMap &Features) {
+  // XXX - What does the member GPU mean if device name string passed here?
+  if (T.isAMDGCN()) {
+switch (parseArchAMDGCN(GPU)) {
+case GK_GFX1103:
+case GK_GFX1102:
+case GK_GFX1101:
+case GK_GFX1100:
+  Features["ci-insts"] = true;
+  Features["dot5-insts"] = true;
+  Features["dot7-insts"] = true;
+  Features["dot8-insts"] = true;
+  Features["dot9-insts"] = true;
+  Features["dot10-insts"] = true;
+  Features["dl-insts"] = true;
+  Features["16-bit-insts"] = true;
+  Features["dpp"] = true;
+  Features["gfx8-insts"] = true;
+  Features["gfx9-insts"] = true;
+  Features["gfx10-insts"] = true;
+  Features["gfx10-3-insts"] = true;
+  Features["gfx11-insts"] = true;
+  break;
+case GK_GFX1036:
+case GK_GFX1035:
+case GK_GFX1034:
+case GK_GFX1033:
+case GK_GFX1032:
+case GK_GFX1031:
+case GK_GFX1030:
+  Features["ci-insts"] = true;
+  Features["dot1-insts"] = true;
+  Features["dot2-insts"] = true;
+  Features["dot5-insts"] = true;
+  Features["dot6-insts"] = true;
+  Features["dot7-insts"] = true;
+  Features["dot10-insts"] = true;
+  Features["dl-insts"] = true;
+  Features["16-bit-insts"] = true;
+  Features["dpp"] = true;
+  Features["gfx8-insts"] = true;
+  Features["gfx9-insts"] = true;
+  Features["gfx10-insts"] = true;
+  Features["gfx10-3-insts"] = true;
+  Features["s-memrealtime"] = true;
+  Features["s-memtime-inst"] = true;
+  break;
+case GK_GFX1012:
+case GK_GFX1011:
+  Features["dot1-insts"] = true;
+  Features["dot2-insts"] = true;
+  Features["dot5-insts"] = true;
+  Features["dot6-insts"] = true;
+  Features["dot7-insts"] = true;
+  Features["dot10-insts"] = true;
+  [[fallthrough]];
+case GK_GFX1013:
+case GK_GFX1010:
+  Features["dl-insts"] = true;
+  Features["ci-insts"] = true;
+  Features["16-bit-insts"] = true;
+  Features["dpp"] = true;
+  Features["gfx8-insts"] = true;
+  Features["gfx9-insts"] = true;
+  Features["gfx10-insts"] = true;
+  Features["s-memrealtime"] = true;
+  Features["s-memtime-inst"] = true;
+  break;
+case GK_GFX940:
+  Features["gfx940-insts"] = true;
+  Features["fp8-insts"] = true;
+  Features["atomic-ds-pk-add-16-insts"] = true;
+  Features["atomic-flat-pk-add-16-insts"] = true;
+  Features["atomic-global-pk-add-bf16-inst"] = true;
+  [[fallthrough]];
+case GK_GFX90A:
+  Features["gfx90a-insts"] = true;
+  Features["atomic-buffer-global-pk-add-f16-insts"] = true;
+  [[fallthrough]];
+case GK_GFX908:
+  Features["dot3-insts"] = true;
+  Features["dot4-insts"] = true;
+  Features["dot5-insts"] = true;
+  Features["dot6-insts"] = true;
+  Features["mai-insts"] = true;
+  [[fallthrough]];
+case GK_GFX906:
+  Features["dl-insts"] = true;
+  Features["dot1-insts"] = true;
+  Features["dot2-insts"] = true;
+  Features["dot7-insts"] = true;
+  Features["dot10-insts"] = true;
+  [[fallthrough]];
+case GK_GFX90C:
+case GK_GFX909:
+case GK_GFX904:
+case GK_GFX902:
+case GK_GFX900:
+  Features["gfx9-insts"] = true;
+  [[fallthrough]];
+case GK_GFX810:
+case GK_GFX805:
+case GK_GFX803:
+case GK_GFX802:
+case GK_GFX801:
+  Features["gfx8-insts"] = true;
+  Features["16-bit-insts"] = true;
+  Features["dpp"] = true;
+  Features["s-memrealtime"] = true;
+  [[fallthrough]];
+case GK_GFX705:
+case GK_GFX704:
+case GK_GFX703:
+case GK_GFX702:
+case GK_GFX701:
+case GK_GFX700:
+  Features["ci-insts"] = true;
+  [[fallthrough]];
+case GK_GFX602:
+case GK_GFX601:
+case GK_GFX600:
+   

[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:380
+auto Loc = SM.getFileLoc(Ref.RefLocation);
+auto Range = Lexer::makeFileCharRange(
+CharSourceRange{SourceRange{Loc}, true}, SM, AST.getLangOpts());

VitaNuo wrote:
> kadircet wrote:
> > I don't think you need to re-lex the token here, as `Loc` is already a 
> > non-macro location in main file, you can still use 
> > `Tokens.spelledTokenAt(Loc)`. Am i missing something?
> It's for consistency with clangd diagnostic generation 
> [here](http://google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp;l=114;rcl=512058308)
>  (according to Sam), but both should work. 
> Would you rather prefer `Tokens.spelledTokenAt(Loc)`?
I'd rather go with `spelledTokenAt` here, diagnostics code deals with locations 
outside of the main file, hence it makes sense for that logic to re-run the 
lexer. but i feel like re-running lexer here will actually create more 
confusion, as we tend to re-use results in token buffers rather than using raw 
lexer in rest of the codebase, as it confused me above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

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


[PATCH] D146922: [clang-tidy] Fix false positve for defaulted move constructor in performance-noexcept-move-constructor

2023-03-27 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Don't waste time of Sema, no way to access it, as far as I know, it's already 
destroyed when checks are executed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146922

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


[PATCH] D145579: [Clang][Flang][AMDGPU] Add support for AMDGPU to Flang driver

2023-03-27 Thread Dominik Adamski via Phabricator via cfe-commits
domada added inline comments.



Comment at: flang/lib/Frontend/FrontendActions.cpp:139-142
+  // Clang does not append all target features to the clang -cc1 invocation.
+  // Some AMDGPU features are passed implicitly by the Clang frontend.
+  // That's why we need to extract implicit AMDGPU target features and add
+  // them to the target features specified by the user

awarzynski wrote:
> domada wrote:
> > awarzynski wrote:
> > > [nit] IMHO this is documenting an implementation detail that would be 
> > > more relevant inside `getExplicitAndImplicitAMDGPUTargetFeatures`.
> > > 
> > > More importantly, you are suggesting that the driver is doing whatever it 
> > > is doing "because that's what Clang does". Consistency with Clang is 
> > > important (you could call it out in the commit message) :) However, it 
> > > would be even nicer to understand the actual rationale behind these 
> > > implicit features. Any idea? Perhaps there are some clues in git history?
> > > 
> > > Also, perhaps a TODO to share this code with Clang? (to make it even 
> > > clearer that the frontend driver aims for full consistency with Clang 
> > > here).
> > I think that the main difference between Clang and Flang is the lack of 
> > `TargetInfo` class.
> > 
> > [[ https://clang.llvm.org/doxygen/classclang_1_1TargetInfo.html | 
> > TargetInfo classes ]] are Clang specific and they are responsible for 
> > parsing/adding default target features. Every target performs 
> > initialization in different way (compare for example [[ 
> > https://clang.llvm.org/doxygen/Basic_2Targets_2AArch64_8cpp_source.html#l00960
> >  | AArch64 ]] vs [[ 
> > https://clang.llvm.org/doxygen/Basic_2Targets_2AMDGPU_8cpp_source.html#l00179
> >  | AMDGPU ]] target initialization.
> > 
> > I don't want to make TargetInfo class Clang indendent (see discussion: 
> > https://discourse.llvm.org/t/rfc-targetinfo-library/64342 ). I also don't 
> > want to reimplement the whole TargetInfo class in Flang, because Flang 
> > already uses LLVM TargetMachine class (see: 
> > https://llvm.org/doxygen/classllvm_1_1TargetMachine.html and 
> > https://github.com/llvm/llvm-project/blob/main/flang/lib/Frontend/FrontendActions.cpp#L614
> >  )  which can play similar role as Clang TargetInfo IMO.
> > 
> > That's why I decided to implement 
> > `getExplicitAndImplicitAMDGPUTargetFeatures` function which performs 
> > initialization of default AMDGPU target features.
> Thanks for this comprehensive overview! It would be helpful if this rationale 
> was included in the summary (in the spirit of documenting things for our 
> future selves).
> 
> So, there isn't anything special about AMDGPU here, is there? We will have to 
> implement similar hooks for other targets at some point too, right? Or 
> perhaps there's some reason to do this for AMDGPU sooner rather than later?
> 
> I'm not against this change, just want to better understand the wider context.
Hi,
I modified the comment above to be more informative.

IMO, we need to add similar hooks for other targets. For example:

```
clang --target=aarch64 t.c -S -emit-llvm -v 
// I see in the logs explicit target features:
// +neon,  +v8a ,  -fmv
// However, generated t.ll contains 4 target features:
"target-features"="+fp-armv8,+neon,+v8a,-fmv"
// It looks like target feature +fp-armv8 is implicit
```


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

https://reviews.llvm.org/D145579

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


[PATCH] D134475: Add C++11 attribute msvc::constexpr

2023-03-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D134475#4222805 , @RIscRIpt wrote:

> I am sorry for protracting implementation. I am still interested to finish 
> this (if no volunteer takes over sooner).
>
> In D134475#4070995 , @RIscRIpt 
> wrote:
>
>> I asked MSFT 
>> 
>>  to comment, let's see if they can share the spec for this attribute.
>
> They did answer! Thank you Cody! For sake of backup, I'll re-post Cody 
> Miller's comment here
>
>> In Microsoft Developer Community / msvc::constexpr-specification 
>> ,
>>  **Cody Miller** wrote:
>> Hello!
>>
>> We added `[[msvc::constexpr]]` to support `std::construct_at` and 
>> `std::ranges::construct_at`. These functions are used in lieu of placement 
>> new in constexpr contexts to support the forms of dynamic memory allocation 
>> that C++20 supports.
>>
>> We originally implemented this by intercepting the names of the invoked 
>> functions and implemented them within the compiler. We (the compiler team) 
>> ultimately weren’t satisfied with this approach because it added complexity 
>> to the frontend and led to some surprising behavior (such as users 
>> implementing their own `std::construct_at` (technically invoking 
>> undefined-behavior, I think) and seeing behavior that may have differed from 
>> their implementation).
>>
>> We added the attribute to allow limited contexts to invoke placement new 
>> during constexpr evaluation, which allowed the compiler to handle the 
>> standard library’s implementation of the two special functions mentioned 
>> above.
>>
>> The semantics are (from memory on a Sunday evening, apologies for unclear or 
>> forgotten explanations):
>>
>> - A function may be either `[[msvc::constexpr]]`, `constexpr`, or neither, 
>> but no combination of these is allowed.
>> - A function annotated with `[[msvc::constexpr]]` is unofficially called an 
>> “extended constexpr” function and may call other `constexpr` or extended 
>> constexpr functions.
>> - An extended constexpr function has the same restrictions as a constexpr 
>> function, except when otherwise noted here.
>> - A return statement may be annotated with `[[msvc::constexpr]]` to allow 
>> its containing constexpr function to call an extended constexpr function.
>> - An extended constexpr function can call other extended constexpr functions 
>> without a statement-level annotation.
>> - A constexpr function may use placement new within a return statement 
>> annotated with `[[msvc::constexpr]]`.
>>
>> We aimed to add a general mechanism to support this feature, but we only are 
>> officially supporting it for use in `std::construct_at` and 
>> `std::ranges::construct_at` at the moment – feel free to file bugs if you 
>> find issues through experimentation, though!
>>
>> The restriction to the `return` statement is reflective of us wanting to 
>> keep the scope of the attribute small.
>>
>> Here’s a godbolt link that hopefully clearly captures the above.
>>
>> We use the annotation (behind the `_MSVC_CONSTEXPR` macro) in our STL 
>> implementation in two 
>> 
>>  places 
>> .
>>
>> Hope this explanation helps! Let me know if anything is unclear.
>
> Currently I am lingered to decide how to implement checks for constant 
> evaluation in clang/lib/AST/ExprConstant.cpp 
> .
> At the moment I have two ideas:
> Idea 1: Using helper RAII classes like `BlockScopeRAII` keep track of 
> `AttributedStmt` and `ReturnStmt` in `EvalInfo` and/or `CallStackFrame`; then 
> in CheckConstexprFunction 
> 
>  check whether above rules are followed. However I don't see that `EvalInfo` 
> or `CallStackFrame` allow storing references to arbitrary statements, and 
> extending these classes only to support `[[msvc::constexpr]]` does not sound 
> like a reasonable idea.
> Idea 2: Pass `Expr* CallerExpr` to CheckConstexprFunction 
> ,
>  and then traverse parents of `CallerExpr` to check that above rules are 
> followed. This would require implementing a simple `ParentVisitor` class 
> which would use `ParentMapContext`. I'm not completely sure about this idea, 
> because I see that `ParentMapContext` is used seldom and its docs mention 
> about "opportunities for optimization" (sounds like performance problems)

[PATCH] D145579: [Clang][Flang][AMDGPU] Add support for AMDGPU to Flang driver

2023-03-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM about the AMDGPU TargetInfo change.


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

https://reviews.llvm.org/D145579

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-03-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146148#4222306 , @zahiraam wrote:

> In D146148#4221651 , @rjmccall 
> wrote:
>
>> In D146148#4220591 , @zahiraam 
>> wrote:
>>
>>> In D146148#4220495 , 
>>> @aaron.ballman wrote:
>>>
 In D146148#4220433 , @zahiraam 
 wrote:

> In D146148#4220268 , @rjmccall 
> wrote:
>
>> Okay, so modifying `math.h` to use this attribute is acceptable?  That's 
>> great, that's definitely the best outcome for the compiler.
>>
>> Just a minor request about the diagnostic name, but otherwise LGTM.
>
> Yes. Added the attribute inside the included math.h header file.

 How does this work for, say, glibc, musl, or MSVC CRT? Won't those math.h 
 headers lack the attribute and thus run into problems when used with Clang?
>>>
>>> Good point! @rjmccall are you thinking of something in particular with the 
>>> attribute?
>>
>> Zahira, this is what I was asking you when I asked whether modifying the 
>> math.h header was acceptable: whether you were prepared to accept that the 
>> warning would only fire on system math.h headers that we'd modified, or 
>> whether you cared about making it work with non-cooperative headers.  I 
>> wasn't asking if you were willing to change the test code.
>
> Okay sorry about the confusion. I think the diagnostic should fire when the 
> user is including system's math.h and using float_t inside a scope cotaining 
> a #pragma clang fp eval-method. 
> I am not sure what you mean by "cooperative headers"?

Ones that know about the special marking and use it (cooperative) or ones that 
don't use the special marking (uncooperative). My intuition is that we'll want 
this to work with any math.h because the problem still exists if you use an 
older C standard library release with a newer Clang.

>>> If not I guess we will have to rely on string comparison for all the 
>>> typedef in the TU. Aaron pointed out the compile time overhead.
>>
>> Well, the compile-time overhead of doing this on every typedef *declaration* 
>> is way better than the overhead of doing this on every type lookup, at least.
>>
>> Anyway, there are three possibilities I can see:
>>
>> - We accept that this needs cooperative system headers.
>
> Not sure what you mean by cooperative system headers.
>
>> - We add a math.h compiler header that `#include_next`s the system math.h 
>> and then adds the attribute.  I believe you can just add an attribute to a 
>> typedef retroactively with something like `typedef float_t float_t 
>> __attribute__((whatever))`.
>
> So when a user writes:
>
>   #include 
>int foo()
>{
>   #pragma clang fp eval_method(source)
>  return sizeof(float_t);
>}
>
> It would be as though the user wrote:
>
>   #include "math.h"
>   int foo()
>   {
>  #pragma clang fp eval_method(source)
> return sizeof(float_t);
>   }
>
> where the content of this new math header being:
>
>   #include_next 
>   typedef float_t float_t __attribute__((whatever));
>   typedef double_t double_t __attribute__((whatever));

Correct.

> The compiler would have to recognize that the included file is math.h and 
> create a new math.h. Where would this file reside?

Clang's implementation-specific headers live in `clang/lib/Headers` and we 
don't currently have one for `math.h` so you'd have to add it.

>> - We do checks on every typedef declaration.  There's a builtin-identifier 
>> trick that we do with library functions that we should be able to generalize 
>> to typedefs, so you wouldn't need to actually do string comparisons, you'd 
>> just check whether the `IdentifierInfo*` was storing a special ID.  We'd set 
>> that up in `initializeBuiltins` at the start of the translation unit, so the 
>> overhead would just be that we'd create two extra `IdentifierInfo*`s in 
>> every TU.
>>
>> The builtin ID logic is currently specific to builtin *functions*, and I 
>> don't think we'd want to hack typedef names into that.  But the same storage 
>> in `IdentifierInfo*` is also used for identifying the ObjC context-sensitive 
>> keywords, by just offsetting the builtin IDs by the NUM_OBJC_KEYWORD.  You 
>> should be able to generalize that by also introducing a concept of a builtin 
>> *type* name, so that e.g. IDs in [0,NUM_OBJC_KEYWORDS) are ObjCKeywordKinds, 
>> IDs in [NUM_OBJC_KEYWORDS, NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES) are 
>> BuiltinTypeKinds (when you subtract NUM_OBJC_KEYWORDS), and IDs in 
>> [NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES,∞) are builtin function IDs (when you 
>> subtract NUM_OBJC_KEYWORDS+NUM_BUILTIN_TYPES).
>
> Need to look at this more closely to understand what you are suggesting.

Basically, he's saying that instead of doing a string comparison against the 
n

[PATCH] D146326: [LinkerWrapper] Do not extract globals with no offloading language

2023-03-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl 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/D146326/new/

https://reviews.llvm.org/D146326

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


[PATCH] D146420: Document the Clang policies on claiming support for a feature

2023-03-27 Thread Aaron Ballman 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 rGce548b6130b6: Document the Clang policies on claiming 
support for a feature (authored by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146420

Files:
  clang/docs/InternalsManual.rst


Index: clang/docs/InternalsManual.rst
===
--- clang/docs/InternalsManual.rst
+++ clang/docs/InternalsManual.rst
@@ -3268,3 +3268,39 @@
  proper visitation for your expression, enabling various IDE features such
  as syntax highlighting, cross-referencing, and so on.  The
  ``c-index-test`` helper program can be used to test these features.
+
+Feature Test Macros
+===
+Clang implements several ways to test whether a feature is supported or not.
+Some of these feature tests are standardized, like ``__has_cpp_attribute`` or
+``__cpp_lambdas``, while others are Clang extensions, like ``__has_builtin``.
+The common theme among all the various feature tests is that they are a utility
+to tell users that we think a particular feature is complete. However,
+completeness is a difficult property to define because features may still have
+lingering bugs, may only work on some targets, etc. We use the following
+criteria when deciding whether to expose a feature test macro (or particular
+result value for the feature test):
+
+  * Are there known issues where we reject valid code that should be accepted?
+  * Are there known issues where we accept invalid code that should be 
rejected?
+  * Are there known crashes, failed assertions, or miscompilations?
+  * Are there known issues on a particular relevant target?
+
+If the answer to any of these is "yes", the feature test macro should either
+not be defined or there should be very strong rationale for why the issues
+should not prevent defining it. Note, it is acceptable to define the feature
+test macro on a per-target basis if needed.
+
+When in doubt, being conservative is better than being aggressive. If we don't
+claim support for the feature but it does useful things, users can still use it
+and provide us with useful feedback on what is missing. But if we claim support
+for a feature that has significant bugs, we've eliminated most of the utility
+of having a feature testing macro at all because users are then forced to test
+what compiler version is in use to get a more accurate answer.
+
+The status reported by the feature test macro should always be reflected in the
+language support page for the corresponding feature (`C++
+`_, `C
+`_) if applicable. This page can give
+more nuanced information to the user as well, such as claiming partial support
+for a feature and specifying details as to what remains to be done.


Index: clang/docs/InternalsManual.rst
===
--- clang/docs/InternalsManual.rst
+++ clang/docs/InternalsManual.rst
@@ -3268,3 +3268,39 @@
  proper visitation for your expression, enabling various IDE features such
  as syntax highlighting, cross-referencing, and so on.  The
  ``c-index-test`` helper program can be used to test these features.
+
+Feature Test Macros
+===
+Clang implements several ways to test whether a feature is supported or not.
+Some of these feature tests are standardized, like ``__has_cpp_attribute`` or
+``__cpp_lambdas``, while others are Clang extensions, like ``__has_builtin``.
+The common theme among all the various feature tests is that they are a utility
+to tell users that we think a particular feature is complete. However,
+completeness is a difficult property to define because features may still have
+lingering bugs, may only work on some targets, etc. We use the following
+criteria when deciding whether to expose a feature test macro (or particular
+result value for the feature test):
+
+  * Are there known issues where we reject valid code that should be accepted?
+  * Are there known issues where we accept invalid code that should be rejected?
+  * Are there known crashes, failed assertions, or miscompilations?
+  * Are there known issues on a particular relevant target?
+
+If the answer to any of these is "yes", the feature test macro should either
+not be defined or there should be very strong rationale for why the issues
+should not prevent defining it. Note, it is acceptable to define the feature
+test macro on a per-target basis if needed.
+
+When in doubt, being conservative is better than being aggressive. If we don't
+claim support for the feature but it does useful things, users can still use it
+and provide us with useful feedback on what is missing. But if we claim support
+for a feature that has significant bugs, we'

[clang] ce548b6 - Document the Clang policies on claiming support for a feature

2023-03-27 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-03-27T09:55:47-04:00
New Revision: ce548b6130b675a433de7fecb37db8f3b56d5c5a

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

LOG: Document the Clang policies on claiming support for a feature

We do not currently have this written down anywhere, and as a result,
we're sometimes inconsistent with how we handle feature test macros and
the feature status pages. This is an attempt to document what I
understand our existing policies to be instead of defining a new policy.

Note, this is being added to the Clang internals manual because we
don't have a separate document for Clang developer policies. At some
point, I think we may want a standalone document for that, and this
content can be moved there at that time.

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

Added: 


Modified: 
clang/docs/InternalsManual.rst

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index a20fe623a5c8..3ba8ed8c0ef6 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -3268,3 +3268,39 @@ are similar.
  proper visitation for your expression, enabling various IDE features such
  as syntax highlighting, cross-referencing, and so on.  The
  ``c-index-test`` helper program can be used to test these features.
+
+Feature Test Macros
+===
+Clang implements several ways to test whether a feature is supported or not.
+Some of these feature tests are standardized, like ``__has_cpp_attribute`` or
+``__cpp_lambdas``, while others are Clang extensions, like ``__has_builtin``.
+The common theme among all the various feature tests is that they are a utility
+to tell users that we think a particular feature is complete. However,
+completeness is a 
diff icult property to define because features may still have
+lingering bugs, may only work on some targets, etc. We use the following
+criteria when deciding whether to expose a feature test macro (or particular
+result value for the feature test):
+
+  * Are there known issues where we reject valid code that should be accepted?
+  * Are there known issues where we accept invalid code that should be 
rejected?
+  * Are there known crashes, failed assertions, or miscompilations?
+  * Are there known issues on a particular relevant target?
+
+If the answer to any of these is "yes", the feature test macro should either
+not be defined or there should be very strong rationale for why the issues
+should not prevent defining it. Note, it is acceptable to define the feature
+test macro on a per-target basis if needed.
+
+When in doubt, being conservative is better than being aggressive. If we don't
+claim support for the feature but it does useful things, users can still use it
+and provide us with useful feedback on what is missing. But if we claim support
+for a feature that has significant bugs, we've eliminated most of the utility
+of having a feature testing macro at all because users are then forced to test
+what compiler version is in use to get a more accurate answer.
+
+The status reported by the feature test macro should always be reflected in the
+language support page for the corresponding feature (`C++
+`_, `C
+`_) if applicable. This page can give
+more nuanced information to the user as well, such as claiming partial support
+for a feature and specifying details as to what remains to be done.



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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-27 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin updated this revision to Diff 508639.
jrmolin marked 2 inline comments as done.
jrmolin added a comment.

pulled main, re-generated the docs, then re-generated the diff. Also added a 
parse test and collapsed some nested `if` conditions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25388,6 +25388,27 @@
   verifyFormat("auto x = 5s .count() == 5;");
 }
 
+TEST_F(FormatTest, BreakBeforeParameterList) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.AlwaysBreakBeforeFunctionParameters, false);
+
+  const StringRef Code("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n");
+
+  // verify that there is no break by default
+  verifyFormat("int function1(int param1, int param2, int param3);\n"
+   "int function2();\n",
+   Code, Style);
+
+  // verify that there is a break when told to break
+  Style.AlwaysBreakBeforeFunctionParameters = true;
+  verifyFormat("int function1(\n"
+   "int param1,\n"
+   "int param2,\n"
+   "int param3);\n"
+   "int function2();\n",
+   Code, Style);
+}
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -149,6 +149,7 @@
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
+  CHECK_PARSE_BOOL(AlwaysBreakBeforeFunctionParameters);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4782,6 +4782,13 @@
 return true;
   }
 
+  // If AlwaysBreakBeforeFunctionParameters is true, we want to break before
+  // the next parameter, if there is one.
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren) && Left.Previous && Left.Previous->is(TT_FunctionDeclarationName)) {
+  return true;
+  }
+
   // If the last token before a '}', ']', or ')' is a comma or a trailing
   // comment, the intention is to insert a line break after it in order to make
   // shuffling around entries easier. Import statements, especially in
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -870,6 +870,8 @@
Style.AlwaysBreakAfterReturnType);
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",
+   Style.AlwaysBreakBeforeFunctionParameters);
 IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.AlwaysBreakTemplateDeclarations);
 IO.mapOptional("AttributeMacros", Style.AttributeMacros);
@@ -1325,6 +1327,7 @@
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
   LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  LLVMStyle.AlwaysBreakBeforeFunctionParameters = false;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
   LLVMStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_MultiLine;
   LLVMStyle.AttributeMacros.push_back("__capability");
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -354,6 +354,11 @@
 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
 return LambdaBodyLength > getColumnLimit(State);
   }
+  // Check if we want to break before function parameters in declarations
+  if (startsNextParameter(Current, Style) &&
+  Style.AlwaysBreakBeforeFunctionParameters &&
+  State.Line->MustBeDeclaration)
+return true;
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
(Style.BreakBeforeInline

[PATCH] D145579: [Clang][Flang][AMDGPU] Add support for AMDGPU to Flang driver

2023-03-27 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Do you want to move the AMDGPU changes into AMDGPU.cpp next to AMD.cpp? From 
the conversation, there seems to be more target specific behaviours.


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

https://reviews.llvm.org/D145579

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


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-03-27 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin marked an inline comment as done.
jrmolin added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4742-4748
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren) && Left.Previous) {
+  const FormatToken &TwoPrevious = *Left.Previous;
+  if (TwoPrevious.is(TT_FunctionDeclarationName)) {
+  return true;
+  }
+  }

HazardyKnusperkeks wrote:
> That I meant with merge.
Ah, understood. I generally don't collapse `if`s, so I didn't know how much you 
wanted. It seems like ... all of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D146418: Support for OpenMP 5.0 sec 2.12.7 - Declare Target initializer expressions

2023-03-27 Thread Ritanya via Phabricator via cfe-commits
RitanyaB added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:2093-2115
+void ParseImplicitDeclareTargetAttr(Decl *TargetDecl) {
+  if (TargetDecl && TargetDecl->hasAttr() &&
+  isa(TargetDecl)) {
+VarDecl *TargetVarDecl = cast(TargetDecl);
+Expr *Ex = TargetVarDecl->getInit()->IgnoreCasts();
+const DeclRefExpr *DeclRef = nullptr;
+if (Ex && isa(Ex) && TargetVarDecl->hasGlobalStorage()) {

ABataev wrote:
> RitanyaB wrote:
> > ABataev wrote:
> > > It has nothing to do with parsing, sema analysis. Make it part of 
> > > Sema::checkDeclIsAllowedInOpenMPTarget
> > The Declaration in Sema::checkDeclIsAllowedInOpenMPTarget is incomplete. 
> > 
> > ```
> > VarDecl 0x1582b278  col:7 ptr1 'int **'
> > `-OMPDeclareTargetDeclAttr 0x1582b2e0  Implicit MT_To DT_Any 1
> >   `-<<>>
> > 
> > ```  
> > At this point, I do not have access to the initializer expression. Any 
> > suggestions? 
> The try to do it ActOnOpenMPDeclareTargetName
In the absence of a declare target clause, this function is not invoked (in the 
examples used above, the function is never called). Do you have any suggestions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146418

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


[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 508645.
VitaNuo marked 3 inline comments as done.
VitaNuo added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -33,9 +33,10 @@
   tooling::stdlib::Recognizer Recognizer;
   for (auto *Root : ASTRoots) {
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
-  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
+  auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
+  if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
 return;
-  // FIXME: Most of the work done here is repetative. It might be useful to
+  // FIXME: Most of the work done here is repetitive. It might be useful to
   // have a cache/batching.
   SymbolReference SymRef{Loc, ND, RT};
   return CB(SymRef, headersForSymbol(ND, SM, PI));
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -177,27 +177,39 @@
   WithContextValue Ctx(Config::Key, std::move(Cfg));
   Annotations MainFile(R"cpp(
 #include "a.h"
+#include "all.h"
 $insert_b[[]]#include "baz.h"
 #include "dir/c.h"
-$insert_d[[]]#include "fuzz.h"
+$insert_d[[]]$insert_foo[[]]#include "fuzz.h"
 #include "header.h"
 $insert_foobar[[]]#include 
 $insert_f[[]]$insert_vector[[]]
 
-void foo() {
-  $b[[b]]();
+#define DEF(X) const Foo *X;
+#define BAZ(X) const X x
 
-  ns::$bar[[Bar]] bar;
-  bar.d();
-  $f[[f]](); 
+  void foo() {
+$b[[b]]();
 
-  // this should not be diagnosed, because it's ignored in the config
-  buzz(); 
+ns::$bar[[Bar]] bar;
+bar.d();
+$f[[f]](); 
 
-  $foobar[[foobar]]();
+// this should not be diagnosed, because it's ignored in the config
+buzz(); 
 
-  std::$vector[[vector]] v;
-})cpp");
+$foobar[[foobar]]();
+
+std::$vector[[vector]] v;
+
+int var = $FOO[[FOO]];
+
+$DEF[[DEF]](a);
+
+$BAR[[BAR]](b);
+
+BAZ($Foo[[Foo]]);
+})cpp");
 
   TestTU TU;
   TU.Filename = "foo.cpp";
@@ -224,6 +236,13 @@
   namespace std { class vector {}; }
   )cpp");
 
+  TU.AdditionalFiles["all.h"] = guard("#include \"foo.h\"");
+  TU.AdditionalFiles["foo.h"] = guard(R"cpp(
+#define BAR(x) Foo *x
+#define FOO 1
+struct Foo{}; 
+  )cpp");
+
   TU.Code = MainFile.code();
   ParsedAST AST = TU.build();
 
@@ -253,7 +272,23 @@
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
   withFix(Fix(MainFile.range("insert_vector"),
-  "#include \n", "#include ");
+  "#include \n", "#include "))),
+  AllOf(Diag(MainFile.range("FOO"),
+ "No header providing \"FOO\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("DEF"),
+ "No header providing \"Foo\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("BAR"),
+ "No header providing \"BAR\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("Foo"),
+ "No header providing \"Foo\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\"");
 }
 
 TEST(IncludeCleaner, IWYUPragmas) {
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -78,7 +78,6 @@
   return Result;
 }
 
-
 bool isFilteredByConfig(const Config &Cfg, llvm::StringRef HeaderPath) {
   // Convert the path to Unix slashes and try to match against the filter.
   llvm::SmallString<64> NormalizedPath(HeaderPath);
@@ -379,15 +378,16 @@
 Ref.RT != include_cleaner::RefType::Explicit)
   return;
 
-auto &Tokens = AST.g

[PATCH] D142347: [NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in Flang

2023-03-27 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.

LGTM, thanks! As @kiranchandramohan points out, this is in line with the 
overall direction that we agreed on a while back.

This change will very likely affect various downstream consumers - it would be 
helpful to advertise this with a PSA on Discourse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142347

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


[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 508648.
VitaNuo added a comment.

Format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/lib/Analysis.cpp

Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -33,9 +33,10 @@
   tooling::stdlib::Recognizer Recognizer;
   for (auto *Root : ASTRoots) {
 walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
-  if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
+  auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
+  if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
 return;
-  // FIXME: Most of the work done here is repetative. It might be useful to
+  // FIXME: Most of the work done here is repetitive. It might be useful to
   // have a cache/batching.
   SymbolReference SymRef{Loc, ND, RT};
   return CB(SymRef, headersForSymbol(ND, SM, PI));
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -177,27 +177,39 @@
   WithContextValue Ctx(Config::Key, std::move(Cfg));
   Annotations MainFile(R"cpp(
 #include "a.h"
+#include "all.h"
 $insert_b[[]]#include "baz.h"
 #include "dir/c.h"
-$insert_d[[]]#include "fuzz.h"
+$insert_d[[]]$insert_foo[[]]#include "fuzz.h"
 #include "header.h"
 $insert_foobar[[]]#include 
 $insert_f[[]]$insert_vector[[]]
 
-void foo() {
-  $b[[b]]();
+#define DEF(X) const Foo *X;
+#define BAZ(X) const X x
 
-  ns::$bar[[Bar]] bar;
-  bar.d();
-  $f[[f]](); 
+  void foo() {
+$b[[b]]();
 
-  // this should not be diagnosed, because it's ignored in the config
-  buzz(); 
+ns::$bar[[Bar]] bar;
+bar.d();
+$f[[f]](); 
 
-  $foobar[[foobar]]();
+// this should not be diagnosed, because it's ignored in the config
+buzz(); 
 
-  std::$vector[[vector]] v;
-})cpp");
+$foobar[[foobar]]();
+
+std::$vector[[vector]] v;
+
+int var = $FOO[[FOO]];
+
+$DEF[[DEF]](a);
+
+$BAR[[BAR]](b);
+
+BAZ($Foo[[Foo]]);
+})cpp");
 
   TestTU TU;
   TU.Filename = "foo.cpp";
@@ -224,6 +236,13 @@
   namespace std { class vector {}; }
   )cpp");
 
+  TU.AdditionalFiles["all.h"] = guard("#include \"foo.h\"");
+  TU.AdditionalFiles["foo.h"] = guard(R"cpp(
+#define BAR(x) Foo *x
+#define FOO 1
+struct Foo{}; 
+  )cpp");
+
   TU.Code = MainFile.code();
   ParsedAST AST = TU.build();
 
@@ -253,7 +272,23 @@
   Diag(MainFile.range("vector"),
"No header providing \"std::vector\" is directly included"),
   withFix(Fix(MainFile.range("insert_vector"),
-  "#include \n", "#include ");
+  "#include \n", "#include "))),
+  AllOf(Diag(MainFile.range("FOO"),
+ "No header providing \"FOO\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("DEF"),
+ "No header providing \"Foo\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("BAR"),
+ "No header providing \"BAR\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\""))),
+  AllOf(Diag(MainFile.range("Foo"),
+ "No header providing \"Foo\" is directly included"),
+withFix(Fix(MainFile.range("insert_foo"),
+"#include \"foo.h\"\n", "#include \"foo.h\"");
 }
 
 TEST(IncludeCleaner, IWYUPragmas) {
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -78,7 +78,6 @@
   return Result;
 }
 
-
 bool isFilteredByConfig(const Config &Cfg, llvm::StringRef HeaderPath) {
   // Convert the path to Unix slashes and try to match against the filter.
   llvm::SmallString<64> NormalizedPath(HeaderPath);
@@ -315,7 +314,6 @@
 }
 } // namespace
 
-
 std::vector
 getUnused(ParsedAST &AST,
   const llvm::DenseSet &ReferencedFiles,
@@ -379,15 +377,17 @@
 Ref.RT != include_clea

[PATCH] D146947: [docs][clang] Added extra information inside the flag -fsanitize=unsigned-shift-base for UndefinedBehaviorSanitizer Fix : #60712

2023-03-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang/docs/UndefinedBehaviorSanitizer.rst:160
   -  ``-fsanitize=unsigned-shift-base``: check that an unsigned left-hand side 
of
- a left shift operation doesn't overflow.
+ a left shift operation doesn't overflow.Issues caught by this sanitizer 
are 
+ not undefined behavior, but are often unintentional.

Missing space after period.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146947

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


[PATCH] D144709: [clang-format] Improve QualifierAlignment

2023-03-27 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd7ab4b5c168: [clang-format] Improve QualifierAlignment 
(authored by AlexanderHederstaf, committed by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D144709?vs=502563&id=508649#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/QualifierAlignmentFixer.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -156,7 +156,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("const Foo a;", Style);
@@ -167,7 +167,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
 
   verifyFormat("LLVM_NODISCARD const int &Foo();", Style);
   verifyFormat("LLVM_NODISCARD int const &Foo();", Style);
@@ -190,7 +190,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("Foo const a;", Style);
@@ -201,7 +201,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
   verifyFormat("Foo *const b;", Style);
   verifyFormat("Foo const *const b;", Style);
   verifyFormat("auto const v = get_value();", Style);
@@ -218,6 +218,11 @@
   verifyFormat("void foo() const final;", Style);
   verifyFormat("void foo() const final LLVM_READONLY;", Style);
   verifyFormat("void foo() const LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile override;", Style);
+  verifyFormat("void foo() const volatile override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile final;", Style);
+  verifyFormat("void foo() const volatile final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile LLVM_READONLY;", Style);
 
   verifyFormat(
   "template  explicit Action(Action const &action);",
@@ -258,6 +263,7 @@
   verifyFormat("int const volatile;", "volatile const int;", Style);
   verifyFormat("int const volatile;", "const volatile int;", Style);
   verifyFormat("int const volatile;", "const int volatile;", Style);
+
   verifyFormat("int const volatile *restrict;", "volatile const int *restrict;",
Style);
   verifyFormat("int const volatile *restrict;", "const volatile int *restrict;",
@@ -265,9 +271,44 @@
   verifyFormat("int const volatile *restrict;", "const int volatile *restrict;",
Style);
 
+  verifyFormat("long long int const volatile;", "const long long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long const long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long long volatile int const;",
+   Style);
+  verifyFormat("long long int const volatile;", "long volatile long const int;",
+   Style);
+  verifyFormat("long long int const volatile;", "const long long volatile int;",
+   Style);
+
   verifyFormat("static int const bat;", "static const int bat;", Style);
   verifyFormat("static int const bat;", "static int const bat;", Style);
 
+  // static is not configured, unchanged on the left of the right hand
+  // qualifiers.
+  verifyFormat("int static const volatile;", "volatile const int static;",
+   Style);
+  verifyFormat("int static const volatile;", "const volatile int static;",
+   Style);
+  verifyFormat("int static const volatile;", "const int volatile static;",
+   Style);
+  verifyFormat("Foo static const volatile;", "volatile const Foo static;",
+   Style);
+  verifyFormat("Foo static const volatile;", "const volatile Foo static;",
+   Style);
+  verifyFormat("Foo static const volatile;", "const Foo volatile static;",
+   Style);
+
+  verifyFormat("Foo inline static const;", "const Foo inline static;", Style);
+  verifyFormat("Foo inline static const;", "Foo const inline sta

[PATCH] D146727: [clangd] Use expansion location for missing include diagnostics.

2023-03-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

thanks for the comments!




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:380
+auto Loc = SM.getFileLoc(Ref.RefLocation);
+auto Range = Lexer::makeFileCharRange(
+CharSourceRange{SourceRange{Loc}, true}, SM, AST.getLangOpts());

kadircet wrote:
> VitaNuo wrote:
> > kadircet wrote:
> > > I don't think you need to re-lex the token here, as `Loc` is already a 
> > > non-macro location in main file, you can still use 
> > > `Tokens.spelledTokenAt(Loc)`. Am i missing something?
> > It's for consistency with clangd diagnostic generation 
> > [here](http://google3/third_party/llvm/llvm-project/clang-tools-extra/clangd/Diagnostics.cpp;l=114;rcl=512058308)
> >  (according to Sam), but both should work. 
> > Would you rather prefer `Tokens.spelledTokenAt(Loc)`?
> I'd rather go with `spelledTokenAt` here, diagnostics code deals with 
> locations outside of the main file, hence it makes sense for that logic to 
> re-run the lexer. but i feel like re-running lexer here will actually create 
> more confusion, as we tend to re-use results in token buffers rather than 
> using raw lexer in rest of the codebase, as it confused me above.
thank you!



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:382
 
-auto &Tokens = AST.getTokens();
-auto SpelledForExpanded =
-Tokens.spelledForExpanded(Tokens.expandedTokens(Ref.RefLocation));
-if (!SpelledForExpanded)
+auto ExpansionLoc = SM.getExpansionLoc(Ref.RefLocation);
+const auto *Token = AST.getTokens().spelledTokenAt(ExpansionLoc);

kadircet wrote:
> VitaNuo wrote:
> > kadircet wrote:
> > > can you actually get the spelling location first and use expansion 
> > > location only when it isn't inside the main file?
> > > that way we get to preserve the behaviour for macro arguments, which 
> > > warrants a test like:
> > > ```
> > > #define FOO(X) const X x
> > > 
> > > FOO([[Foo]]); // we should have a missing include for symbol Foo here
> > > ```
> > > 
> > > and can we have a comment about reasons and implications, e.g. something 
> > > like:
> > > ```
> > > Spelling locations can point into preamble section at times. We don't 
> > > want to emit diagnostics there as the offsets might be off when preamble 
> > > is stale.
> > > In such cases we fallback to expansion locations, as they're always in 
> > > the main file. This means we fail to attach diagnostics to spelling of 
> > > symbol names inside macro bodies.
> > > // FIXME: Use presumed locations to make sure we can correctly generate 
> > > diagnostics even in such cases.
> > > ```
> > Sam suggested a magic solution for this, which is 
> > `SM.getFileLoc(Ref.RefLocation)`. Its documentation says:
> > 
> > ```
> > /// Given \p Loc, if it is a macro location return the expansion
> > /// location or the spelling location, depending on if it comes from a
> > /// macro argument or not.
> > ```
> > 
> > Sounds like what we need, right?
> Rather than doing spelling & falling back to expansion, just doing 
> `getFileLoc` definitely makes sense.
> But what we actually want here is always map to spelling (e.g. we want `Foo` 
> in macro body, rather than macro invocation to be highlighted).
> It's just we can't have it all the time because accessing offsets coming from 
> stale preamble might result in crashes. Hence can you also add the comment i 
> mentioned above so that we don't forget? maybe with a rewording like:
> ```
> // We actually always want to map usages to their spellings, but spelling 
> locations can point into preamble section.
> // Using these offsets could lead into crashes in presence of stale 
> preambles. Hence we use `getFileLoc` instead to make sure it always points 
> into main file.
> // FIXME: Use presumed locations to map such usages back to patched locations 
> safely.
> ```
thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146727

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


[clang] cd7ab4b - [clang-format] Improve QualifierAlignment

2023-03-27 Thread via cfe-commits

Author: Alexander Hederstaf
Date: 2023-03-27T15:18:29+01:00
New Revision: cd7ab4b5c1684dcc60de027700177adfa096b98c

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

LOG: [clang-format] Improve QualifierAlignment

Qualifiers were not moved for non-pointer non-simple types.
Add additional support for many special cases such as templates,
requires clauses, long qualified names.

Fixes https://github.com/llvm/llvm-project/issues/57154 and
https://github.com/llvm/llvm-project/issues/60898

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/lib/Format/QualifierAlignmentFixer.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 16dbe8ec8d27..b2efa9931325 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -363,6 +363,8 @@ clang-format
   Compared to ``NextLine`` style, ``NextLineOnly`` style will not try to
   put the initializers on the current line first, instead, it will try to
   put the initializers on the next line only.
+- Add additional Qualifier Ordering support for special cases such
+  as templates, requires clauses, long qualified names.
 
 libclang
 

diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index 609b412380f8..5142a83efdd4 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -128,14 +128,12 @@ static void insertQualifierAfter(const SourceManager 
&SourceMgr,
  tooling::Replacements &Fixes,
  const FormatToken *First,
  const std::string &Qualifier) {
-  FormatToken *Next = First->Next;
-  if (!Next)
-return;
-  auto Range = CharSourceRange::getCharRange(Next->getStartOfNonWhitespace(),
- Next->Tok.getEndLoc());
+  auto Range = CharSourceRange::getCharRange(First->Tok.getLocation(),
+ First->Tok.getEndLoc());
 
-  std::string NewText = " " + Qualifier + " ";
-  NewText += Next->TokenText;
+  std::string NewText{};
+  NewText += First->TokenText;
+  NewText += " " + Qualifier;
   replaceToken(SourceMgr, Fixes, Range, NewText);
 }
 
@@ -204,9 +202,33 @@ static void rotateTokens(const SourceManager &SourceMgr,
   replaceToken(SourceMgr, Fixes, Range, NewText);
 }
 
+static bool
+isConfiguredQualifier(const FormatToken *const Tok,
+  const std::vector &Qualifiers) {
+  return Tok && llvm::is_contained(Qualifiers, Tok->Tok.getKind());
+}
+
+static bool isQualifier(const FormatToken *const Tok) {
+  if (!Tok)
+return false;
+
+  switch (Tok->Tok.getKind()) {
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::kw_static:
+  case tok::kw_inline:
+  case tok::kw_constexpr:
+  case tok::kw_restrict:
+  case tok::kw_friend:
+return true;
+  default:
+return false;
+  }
+}
+
 const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
 const SourceManager &SourceMgr, const AdditionalKeywords &Keywords,
-tooling::Replacements &Fixes, const FormatToken *Tok,
+tooling::Replacements &Fixes, const FormatToken *const Tok,
 const std::string &Qualifier, tok::TokenKind QualifierType) {
   // We only need to think about streams that begin with a qualifier.
   if (!Tok->is(QualifierType))
@@ -214,65 +236,141 @@ const FormatToken 
*LeftRightQualifierAlignmentFixer::analyzeRight(
   // Don't concern yourself if nothing follows the qualifier.
   if (!Tok->Next)
 return Tok;
-  if (LeftRightQualifierAlignmentFixer::isPossibleMacro(Tok->Next))
-return Tok;
 
-  auto AnalyzeTemplate =
-  [&](const FormatToken *Tok,
-  const FormatToken *StartTemplate) -> const FormatToken * {
-// Read from the TemplateOpener to TemplateCloser.
-FormatToken *EndTemplate = StartTemplate->MatchingParen;
-if (EndTemplate) {
-  // Move to the end of any template class members e.g.
-  // `Foo::iterator`.
-  if (EndTemplate->startsSequence(TT_TemplateCloser, tok::coloncolon,
-  tok::identifier)) {
-EndTemplate = EndTemplate->Next->Next;
-  }
+  // Skip qualifiers to the left to find what preceeds the qualifiers.
+  // Use isQualifier rather than isConfiguredQualifier to cover all qualifiers.
+  const FormatToken *PreviousCheck = Tok->getPreviousNonComment();
+  while (isQualifier(PreviousCheck))
+PreviousCheck = PreviousCheck->getPrevi

  1   2   3   >