[PATCH] D130414: [pseudo] Reorganize CXX.h enums

2022-07-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.
sammccall marked 2 inline comments as done.
Closed by commit rG6bdb15fe844c: [pseudo] Reorganize CXX.h enums (authored by 
sammccall).
Herald added a subscriber: mgorny.

Changed prior to commit:
  https://reviews.llvm.org/D130414?vs=447675&id=447939#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130414

Files:
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/unittests/CMakeLists.txt
  clang-tools-extra/pseudo/unittests/CXXTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -109,21 +109,6 @@
   EXPECT_TRUE(G.lookupRule(ruleFor("x")).Guarded);
 }
 
-TEST_F(GrammarTest, MangleName) {
-  build(R"bnf(
-_ := declaration
-
-declaration := ptr-declarator ;
-ptr-declarator := * IDENTIFIER
-
-  )bnf");
-  ASSERT_TRUE(Diags.empty());
-  EXPECT_EQ(G.mangleRule(ruleFor("declaration")),
-"declaration_0ptr_declarator_1semi");
-  EXPECT_EQ(G.mangleRule(ruleFor("ptr-declarator")),
-"ptr_declarator_0star_1identifier");
-}
-
 TEST_F(GrammarTest, Diagnostics) {
   build(R"cpp(
 _ := ,_opt
Index: clang-tools-extra/pseudo/unittests/CXXTest.cpp
===
--- /dev/null
+++ clang-tools-extra/pseudo/unittests/CXXTest.cpp
@@ -0,0 +1,30 @@
+//===--- CXXTest.cpp --===//
+//
+// 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
+//
+//===--===//
+
+#include "clang-pseudo/cxx/CXX.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace pseudo {
+namespace cxx {
+namespace {
+
+TEST(CXX, GeneratedEnums) {
+  const auto &Lang = clang::pseudo::cxx::getLanguage();
+  EXPECT_EQ("iteration-statement",
+Lang.G.symbolName(Symbol::iteration_statement));
+  EXPECT_EQ("iteration-statement := DO statement WHILE ( expression ) ;",
+Lang.G.dumpRule(
+rule::iteration_statement::
+DO__statement__WHILE__L_PAREN__expression__R_PAREN__SEMI));
+}
+
+} // namespace
+} // namespace cxx
+} // namespace pseudo
+} // namespace clang
Index: clang-tools-extra/pseudo/unittests/CMakeLists.txt
===
--- clang-tools-extra/pseudo/unittests/CMakeLists.txt
+++ clang-tools-extra/pseudo/unittests/CMakeLists.txt
@@ -5,6 +5,7 @@
 add_custom_target(ClangPseudoUnitTests)
 add_unittest(ClangPseudoUnitTests ClangPseudoTests
   BracketTest.cpp
+  CXXTest.cpp
   DirectiveTreeTest.cpp
   ForestTest.cpp
   GLRTest.cpp
@@ -22,6 +23,7 @@
 target_link_libraries(ClangPseudoTests
   PRIVATE
   clangPseudo
+  clangPseudoCXX
   clangPseudoGrammar
   LLVMTestingSupport
   )
Index: clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -45,28 +45,6 @@
   return T->Nonterminals[SID].Name;
 }
 
-std::string Grammar::mangleSymbol(SymbolID SID) const {
-  static const char *const TokNames[] = {
-#define TOK(X) #X,
-#define KEYWORD(X, Y) #X,
-#include "clang/Basic/TokenKinds.def"
-  nullptr};
-  if (clang::pseudo::isToken(SID))
-return TokNames[clang::pseudo::symbolToToken(SID)];
-  std::string Name = symbolName(SID).str();
-  // translation-unit -> translation_unit
-  std::replace(Name.begin(), Name.end(), '-', '_');
-  return Name;
-}
-
-std::string Grammar::mangleRule(RuleID RID) const {
-  const auto &R = lookupRule(RID);
-  std::string MangleName = mangleSymbol(R.Target);
-  for (size_t I = 0; I < R.seq().size(); ++I)
-MangleName += llvm::formatv("_{0}{1}", I, mangleSymbol(R.seq()[I]));
-  return MangleName;
-}
-
 llvm::Optional Grammar::findNonterminal(llvm::StringRef Name) const {
   auto It = llvm::partition_point(
   T->Nonterminals,
Index: clang-tools-extra/pseudo/lib/cxx/CXX.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -111,42 +111,41 @@
 }
 
 bool isFunctionDeclarator(const ForestNode *Declarator) {
-  as

[clang-tools-extra] 6bdb15f - [pseudo] Reorganize CXX.h enums

2022-07-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-27T09:03:29+02:00
New Revision: 6bdb15fe844c428f1bf477c73a36901c84e5b5fa

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

LOG: [pseudo] Reorganize CXX.h enums

- Place rules under rule::lhs::rhs__rhs__rhs
- Change mangling of keywords to ALL_CAPS (needed to turn keywords that appear
  alone on RHS into valid identifiers)
- Make enums implicitly convertible to underlying type (though still scoped,
  using alias tricks)

In principle this lets us exhaustively write a switch over all rules of a NT:
  switch ((rule::declarator)N->rule()) {
case rule::declarator::noptr_declarator:
  ...
  }
In practice we don't do this anywhere yet as we're often switching over multiple
nonterminal kinds at once.

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

Added: 
clang-tools-extra/pseudo/unittests/CXXTest.cpp

Modified: 
clang-tools-extra/pseudo/gen/Main.cpp
clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
clang-tools-extra/pseudo/unittests/CMakeLists.txt
clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/gen/Main.cpp 
b/clang-tools-extra/pseudo/gen/Main.cpp
index 27857ca4b3e86..66980580d93b3 100644
--- a/clang-tools-extra/pseudo/gen/Main.cpp
+++ b/clang-tools-extra/pseudo/gen/Main.cpp
@@ -58,6 +58,50 @@ std::string readOrDie(llvm::StringRef Path) {
 }
 } // namespace
 
+namespace clang {
+namespace pseudo {
+namespace {
+
+// Mangles a symbol name into a valid identifier.
+//
+// These follow names in the grammar fairly closely:
+//   nonterminal: `ptr-declartor` becomes `ptr_declarator`;
+//   punctuator: `,` becomes `COMMA`;
+//   keyword: `INT` becomes `INT`;
+//   terminal: `IDENTIFIER` becomes `IDENTIFIER`;
+std::string mangleSymbol(SymbolID SID, const Grammar &G) {
+  static std::string *TokNames = new std::string[]{
+#define TOK(X) llvm::StringRef(#X).upper(),
+#define KEYWORD(Keyword, Condition) llvm::StringRef(#Keyword).upper(),
+#include "clang/Basic/TokenKinds.def"
+  };
+  if (isToken(SID))
+return TokNames[symbolToToken(SID)];
+  std::string Name = G.symbolName(SID).str();
+  // translation-unit -> translation_unit
+  std::replace(Name.begin(), Name.end(), '-', '_');
+  return Name;
+}
+
+// Mangles the RHS of a rule definition into a valid identifier.
+// 
+// These are unique only for a fixed LHS.
+// e.g. for the grammar rule `ptr-declarator := ptr-operator ptr-declarator`,
+// it is `ptr_operator__ptr_declarator`.
+std::string mangleRule(RuleID RID, const Grammar &G) {
+  const auto &R = G.lookupRule(RID);
+  std::string MangleName = mangleSymbol(R.seq().front(), G);
+  for (SymbolID S : R.seq().drop_front()) {
+MangleName.append("__");
+MangleName.append(mangleSymbol(S, G));
+  }
+  return MangleName;
+}
+
+} // namespace
+} // namespace pseudo
+} // namespace clang
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "");
 
@@ -81,21 +125,26 @@ int main(int argc, char *argv[]) {
   case EmitSymbolList:
 Out.os() << R"cpp(
 #ifndef NONTERMINAL
-#define NONTERMINAL(X, Y)
+#define NONTERMINAL(NAME, ID)
 #endif
 #ifndef RULE
-#define RULE(X, Y)
+#define RULE(LHS, RHS, ID)
 #endif
 #ifndef EXTENSION
-#define EXTENSION(X, Y)
+#define EXTENSION(NAME, ID)
 #endif
 )cpp";
 for (clang::pseudo::SymbolID ID = 0; ID < G.table().Nonterminals.size();
- ++ID)
-  Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n", G.mangleSymbol(ID),
-ID);
-for (clang::pseudo::RuleID RID = 0; RID < G.table().Rules.size(); ++RID)
-  Out.os() << llvm::formatv("RULE({0}, {1})\n", G.mangleRule(RID), RID);
+ ++ID) {
+  Out.os() << llvm::formatv("NONTERMINAL({0}, {1})\n",
+clang::pseudo::mangleSymbol(ID, G), ID);
+  for (const clang::pseudo::Rule &R : G.rulesFor(ID)) {
+clang::pseudo::RuleID RID = &R - G.table().Rules.data();
+Out.os() << llvm::formatv("RULE({0}, {1}, {2})\n",
+  clang::pseudo::mangleSymbol(R.Target, G),
+  clang::pseudo::mangleRule(RID, G), RID);
+  }
+}
 for (clang::pseudo::ExtensionID EID = 1 /*skip the sentinel 0 value*/;
  EID < G.table().AttributeValues.size(); ++EID) {
   llvm::StringRef Name = G.table().AttributeValues[EID];

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
index a1426722262e1..7bbb4d2c00201 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/c

[clang-tools-extra] 89f284b - [pseudo] Remove dead header

2022-07-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-27T09:05:59+02:00
New Revision: 89f284bc238b4091482cbc4fa38bc5f7246b81e4

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

LOG: [pseudo] Remove dead header

This was an earlier draft of Language.h that got committed accidentally

Added: 


Modified: 


Removed: 
clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h



diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h
deleted file mode 100644
index fdbc83c26ebe..
--- a/clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===--- ParseLang.h --- -*- 
C++-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef CLANG_PSEUDO_PARSELANG_H
-#define CLANG_PSEUDO_PARSELANG_H
-
-#include "clang-pseudo/grammar/Grammar.h"
-#include "clang-pseudo/grammar/LRTable.h"
-
-namespace clang {
-namespace pseudo {
-
-// Specify a language that can be parsed by the pseduoparser.
-// Manifest generated from a bnf grammar file.
-struct ParseLang {
-  Grammar G;
-  LRTable Table;
-
-  // FIXME: add clang::LangOptions.
-  // FIXME: add default start symbols.
-};
-
-} // namespace pseudo
-} // namespace clang
-
-#endif // CLANG_PSEUDO_PARSELANG_H



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


[clang-tools-extra] afc4958 - [pseudo] Add dangling-else guard to missing if-statement variants

2022-07-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-27T09:08:34+02:00
New Revision: afc4958f5ad004309bb982c24147bc3d562add74

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

LOG: [pseudo] Add dangling-else guard to missing if-statement variants

Added: 


Modified: 
clang-tools-extra/pseudo/lib/cxx/CXX.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/cxx/CXX.cpp 
b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
index fe9eb930469e..a0a252c50b98 100644
--- a/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ b/clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -300,12 +300,17 @@ llvm::DenseMap buildGuards() {
   {rule::contextual_zero::NUMERIC_CONSTANT,
TOKEN_GUARD(numeric_constant, Tok.text() == "0")},
 
-  // FIXME: the init-statement variants are missing?
   {rule::selection_statement::IF__L_PAREN__condition__R_PAREN__statement,
guardNextTokenNotElse},
+  {rule::selection_statement::
+   IF__L_PAREN__init_statement__condition__R_PAREN__statement,
+   guardNextTokenNotElse},
   {rule::selection_statement::
IF__CONSTEXPR__L_PAREN__condition__R_PAREN__statement,
guardNextTokenNotElse},
+  {rule::selection_statement::
+   
IF__CONSTEXPR__L_PAREN__init_statement__condition__R_PAREN__statement,
+   guardNextTokenNotElse},
 
   // The grammar distinguishes (only) user-defined vs plain string 
literals,
   // where the clang lexer distinguishes (only) encoding types.



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


[PATCH] D130414: [pseudo] Reorganize CXX.h enums

2022-07-27 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi @sammccall, your change seems to be causing a build failure on the PS4 linux 
bot, can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/25678

  FAILED: 
tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o 
  CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/g++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/pseudo/gen
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include
 -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/include
 
-I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/pseudo/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
-Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
-Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 
-DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o 
-MF 
tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o.d 
-o 
tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o 
-c 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:
 In function ‘std::string 
clang::pseudo::{anonymous}::mangleSymbol(clang::pseudo::SymbolID, const 
clang::pseudo::Grammar&)’:
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:73:50:
 error: expected primary-expression before ‘]’ token
 73 |   static std::string *TokNames = new std::string[]{
|  ^
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:77:7:
 error: too many initializers for ‘std::string [1]’ {aka 
‘std::__cxx11::basic_string [1]’}
 77 |   };
|   ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130414

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


[PATCH] D129799: [clang-tidy] Add CLANG_MAKE_CONFUSABLE_TABLE cmake cache variable to avoid building when cross compiling

2022-07-27 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D129799#3681524 , @sammccall wrote:

> I'd be tempted by `clang-tidy-confusable-chars-gen` or so but I'm really just 
> painting the bikeshed at this point - up to you.

That sounds like a clearer name to me, thanks! I’ll update D129798 
 and this patch with that name, run some test 
builds with it, push them, and then file backport requests for them, as they 
missed the branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129799

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


[clang] bfe191d - Disable stack-sizes section by default for PS4.

2022-07-27 Thread Ying Yi via cfe-commits

Author: Ying Yi
Date: 2022-07-27T09:37:20+01:00
New Revision: bfe191dfa79bbccb57506055db9c89bfb891f65c

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

LOG: Disable stack-sizes section by default for PS4.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-size-section.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index b62a025c5072..d3ff71ee28e9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5886,9 +5886,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 CmdArgs.push_back(A->getValue());
   }
 
-  if (Args.hasFlag(options::OPT_fstack_size_section,
-   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
-CmdArgs.push_back("-fstack-size-section");
+  Args.addOptInFlag(CmdArgs, options::OPT_fstack_size_section,
+options::OPT_fno_stack_size_section);
 
   if (Args.hasArg(options::OPT_fstack_usage)) {
 CmdArgs.push_back("-stack-usage-file");

diff  --git a/clang/test/Driver/stack-size-section.c 
b/clang/test/Driver/stack-size-section.c
index f50c9767e707..b99b1409bef4 100644
--- a/clang/test/Driver/stack-size-section.c
+++ b/clang/test/Driver/stack-size-section.c
@@ -4,7 +4,7 @@
 // CHECK-ABSENT-NOT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-PRESENT
-// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-PRESENT
+// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ABSENT
 // CHECK-PRESENT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section 
-fno-stack-size-section %s -### 2>&1 \



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


[PATCH] D130493: Disable stack-sizes section by default for PS4.

2022-07-27 Thread Ying Yi 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 rGbfe191dfa79b: Disable stack-sizes section by default for 
PS4. (authored by MaggieYi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130493

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-size-section.c


Index: clang/test/Driver/stack-size-section.c
===
--- clang/test/Driver/stack-size-section.c
+++ clang/test/Driver/stack-size-section.c
@@ -4,7 +4,7 @@
 // CHECK-ABSENT-NOT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-PRESENT
-// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-PRESENT
+// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ABSENT
 // CHECK-PRESENT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section 
-fno-stack-size-section %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5886,9 +5886,8 @@
 CmdArgs.push_back(A->getValue());
   }
 
-  if (Args.hasFlag(options::OPT_fstack_size_section,
-   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
-CmdArgs.push_back("-fstack-size-section");
+  Args.addOptInFlag(CmdArgs, options::OPT_fstack_size_section,
+options::OPT_fno_stack_size_section);
 
   if (Args.hasArg(options::OPT_fstack_usage)) {
 CmdArgs.push_back("-stack-usage-file");


Index: clang/test/Driver/stack-size-section.c
===
--- clang/test/Driver/stack-size-section.c
+++ clang/test/Driver/stack-size-section.c
@@ -4,7 +4,7 @@
 // CHECK-ABSENT-NOT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
-// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PRESENT
+// RUN: %clang -target x86_64-scei-ps4 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ABSENT
 // CHECK-PRESENT: -fstack-size-section
 
 // RUN: %clang -target x86_64-unknown -fstack-size-section -fno-stack-size-section %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5886,9 +5886,8 @@
 CmdArgs.push_back(A->getValue());
   }
 
-  if (Args.hasFlag(options::OPT_fstack_size_section,
-   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
-CmdArgs.push_back("-fstack-size-section");
+  Args.addOptInFlag(CmdArgs, options::OPT_fstack_size_section,
+options::OPT_fno_stack_size_section);
 
   if (Args.hasArg(options::OPT_fstack_usage)) {
 CmdArgs.push_back("-stack-usage-file");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

2022-07-27 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

Currently, I cannot test the option `-fconvert=big-endian` with open statement 
with convert argument using the following code since lowering is not supported. 
I am not sure if it can be tested in runtime.

  $ cat fconvert_option_openfile.f90 
  module fconvert_option_openfile
  
  contains
subroutine open_for_read(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='old')
end
subroutine open_for_read_BE(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='old', 
convert="BIG_ENDIAN")
end
subroutine open_for_read_LE(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='old', 
convert="LITTLE_ENDIAN")
end
subroutine open_for_read_native(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='old', 
convert="NATIVE")
end
  
subroutine open_for_write(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='new')
end
subroutine open_for_write_BE(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='new', 
convert="BIG_ENDIAN")
end
subroutine open_for_write_LE(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='new', 
convert="LITTLE_ENDIAN")
end
subroutine open_for_write_native(fid, file_name)
  integer :: fid
  character(:), allocatable :: file_name
  open (fid, file=file_name, form='UNFORMATTED', status='new', 
convert="NATIVE")
end
  end
  $ cat fconvert_option_readfile.f90 
  module fconvert_option_readfile
  
  contains
subroutine readfile(fid, del_flag, expect, n, t)
  integer :: n, t
  integer :: fid, del_flag
  real :: expect(n)
  real :: buf(n)
  
  read (fid) buf
  if (del_flag .eq. 0) then
close (fid)
  else
close (fid, status='delete')
  end if
  
  do i = 1, n
if (buf(i) .ne. expect(i)) stop (i+t)
  enddo
end
  end
  $ cat fconvert_option_main_1.f90 
  program fconvert_option_main_1
use fconvert_option_openfile
use fconvert_option_readfile
  
integer, parameter :: n = 4
integer :: del_flag = 0 ! 1 for deleting data file after read
real :: arr(n) = [1.0, 2.0, 3.0, 4.0]
character(:), allocatable :: filename
integer :: arglen
  
call get_command_argument(1, length = arglen)
allocate(character(arglen) :: filename)
call get_command_argument(1, value = filename)
  
call open_for_read(10, filename)
call readfile(10, del_flag, arr, n, 0)
  
call open_for_read_LE(11, filename)
call readfile(11, del_flag, arr, n, 4)
  
call open_for_read_native(12, filename)
call readfile(12, del_flag, arr, n, 8)
  
print *, 'PASS'
  end

BTW, can you continue working on the lowering of the convert argument of open 
statement?




Comment at: clang/include/clang/Driver/Options.td:4897
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group, Alias;
+def fconvert_EQ : Joined<["-"], "fconvert=">, Group,
+  HelpText<"Set endian conversion of data for unformatted files">;

awarzynski wrote:
> jpenix-quic wrote:
> > peixin wrote:
> > > Why do you move it here? Maybe it is not implemented now, clang may need 
> > > this option eventually. @MaskRay 
> > I was using the fixed line length options as a reference for how to handle 
> > this--based on the discussion in the review here 
> > (https://reviews.llvm.org/D95460) about forwarding options to gfortran, I 
> > was thinking that it would also be safe to handle fconvert similarly, but 
> > I'm not 100% sure and definitely might be misunderstanding something!
> GFortran support has been effectively broken since LLVM 12 (see e.g. this [[ 
> https://github.com/llvm/llvm-project/commit/6a75496836ea14bcfd2f4b59d35a1cad4ac58cee
>  | change ]]). We would do ourselves a favor if we just removed it altogether 
> (I'm not aware of anyone requiring  it). 
> 
> And if Clang ever needs this option, we can always update this definition 
> accordingly. No need to optimize for hypothetical scenarios that may or may 
> not happen :) To me, this change makes perfect sense.
OK. This sounds reasonable to me.



Comment at: flang/lib/Lower/Bridge.cpp:2757
 
+if (funit.isMainProgram()) {
+  auto conversion = bridge.getConversion();

I think this should be moved into `void 
lowerFunc(Fortran::lower::pft::FunctionLikeUnit &funit)`.



Comment at: fla

[clang-tools-extra] 7b70c2e - [pseudo] Fix initializer of string table

2022-07-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-27T11:04:12+02:00
New Revision: 7b70c2e75cd6b21cf9c2ea2f2ce5f7b9c4202549

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

LOG: [pseudo] Fix initializer of string table

Apparently new string[/*no size*/]{"foo", "bar"} is a clang/gcc extension?

Added: 


Modified: 
clang-tools-extra/pseudo/gen/Main.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/gen/Main.cpp 
b/clang-tools-extra/pseudo/gen/Main.cpp
index 66980580d93b3..5cc33aa3f8b27 100644
--- a/clang-tools-extra/pseudo/gen/Main.cpp
+++ b/clang-tools-extra/pseudo/gen/Main.cpp
@@ -70,7 +70,7 @@ namespace {
 //   keyword: `INT` becomes `INT`;
 //   terminal: `IDENTIFIER` becomes `IDENTIFIER`;
 std::string mangleSymbol(SymbolID SID, const Grammar &G) {
-  static std::string *TokNames = new std::string[]{
+  static auto &TokNames = *new std::vector{
 #define TOK(X) llvm::StringRef(#X).upper(),
 #define KEYWORD(Keyword, Condition) llvm::StringRef(#Keyword).upper(),
 #include "clang/Basic/TokenKinds.def"



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


Re: [PATCH] D130414: [pseudo] Reorganize CXX.h enums

2022-07-27 Thread Sam McCall via cfe-commits
Sorry Doug!
7b70c2e75cd6b21cf9c2ea2f2ce5f7b9c4202549 should fix, not sure why my local
clang accepts it.

On Wed, Jul 27, 2022 at 9:57 AM Douglas Yung via Phabricator <
revi...@reviews.llvm.org> wrote:

> dyung added a comment.
>
> Hi @sammccall, your change seems to be causing a build failure on the PS4
> linux bot, can you take a look?
>
> https://lab.llvm.org/buildbot/#/builders/139/builds/25678
>
>   FAILED:
> tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o
>
>   CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/g++
> -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/pseudo/gen
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/include
> -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/pseudo/include
> -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden
> -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings
> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess
> -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type
> -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment
> -Wmisleading-indentation -fdiagnostics-color -ffunction-sections
> -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3
> -DNDEBUG  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT
> tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o
> -MF
> tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o.d
> -o
> tools/clang/tools/extra/pseudo/gen/CMakeFiles/clang-pseudo-gen.dir/Main.cpp.o
> -c
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp
>
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:
> In function ‘std::string
> clang::pseudo::{anonymous}::mangleSymbol(clang::pseudo::SymbolID, const
> clang::pseudo::Grammar&)’:
>
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:73:50:
> error: expected primary-expression before ‘]’ token
>  73 |   static std::string *TokNames = new std::string[]{
> |  ^
>
> /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/pseudo/gen/Main.cpp:77:7:
> error: too many initializers for ‘std::string [1]’ {aka
> ‘std::__cxx11::basic_string [1]’}
>  77 |   };
> |   ^
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D130414/new/
>
> https://reviews.llvm.org/D130414
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130526: [Driver][PowerPC] Support -mtune=

2022-07-27 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Thanks. We'll eventually start doing something with the option in the back end. 
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130526

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15f3cd6bfc67: [clang] Implement ElaboratedType sugaring for 
types written bare (authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/AST/ast-dump-using.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Anal

[PATCH] D127082: [clangd] Add Macro Expansion to Hover

2022-07-27 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 447962.
daiyousei-qz added a comment.

remove dedicated MacroExpansion variable (reuse Definition)
added empty MACRO test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127082

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -478,15 +478,60 @@
  HI.Definition = "Foo";
}},
 
-  // macro
+  // empty macro
+  {R"cpp(
+#define MACRO
+[[MAC^RO]]
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "MACRO";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define MACRO";
+   }},
+
+  // object-like macro
+  {R"cpp(
+#define MACRO 41
+int x = [[MAC^RO]];
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "MACRO";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define MACRO 41\n\n"
+ "// Expands to\n"
+ "41";
+   }},
+
+  // function-like macro
   {R"cpp(
 // Best MACRO ever.
-#define MACRO(x,y,z) void foo(x, y, z);
+#define MACRO(x,y,z) void foo(x, y, z)
 [[MAC^RO]](int, double d, bool z = false);
 )cpp",
[](HoverInfo &HI) {
- HI.Name = "MACRO", HI.Kind = index::SymbolKind::Macro,
- HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z);";
+ HI.Name = "MACRO";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define MACRO(x, y, z) void foo(x, y, z)\n\n"
+ "// Expands to\n"
+ "void foo(int, double d, bool z = false)";
+   }},
+
+  // nested macro
+  {R"cpp(
+#define STRINGIFY_AUX(s) #s
+#define STRINGIFY(s) STRINGIFY_AUX(s)
+#define DECL_STR(NAME, VALUE) const char *v_##NAME = STRINGIFY(VALUE)
+#define FOO 41
+
+[[DECL^_STR]](foo, FOO);
+)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "DECL_STR";
+ HI.Kind = index::SymbolKind::Macro;
+ HI.Definition = "#define DECL_STR(NAME, VALUE) const char *v_##NAME = "
+ "STRINGIFY(VALUE)\n\n"
+ "// Expands to\n"
+ "const char *v_foo = \"41\"";
}},
 
   // constexprs
@@ -1566,7 +1611,9 @@
   [](HoverInfo &HI) {
 HI.Name = "MACRO";
 HI.Kind = index::SymbolKind::Macro;
-HI.Definition = "#define MACRO 0";
+HI.Definition = "#define MACRO 0\n\n"
+"// Expands to\n"
+"0";
   }},
   {
   R"cpp(// Macro
@@ -1577,6 +1624,8 @@
 HI.Name = "MACRO";
 HI.Kind = index::SymbolKind::Macro;
 HI.Definition = "#define MACRO 0";
+// NOTE MACRO doesn't have expansion since it technically isn't
+// expanded here
   }},
   {
   R"cpp(// Macro
@@ -1590,7 +1639,10 @@
 HI.Kind = index::SymbolKind::Macro;
 HI.Definition =
 R"cpp(#define MACRO  \
-  { return 0; })cpp";
+  { return 0; }
+
+// Expands to
+{ return 0; })cpp";
   }},
   {
   R"cpp(// Forward class declaration
@@ -2986,6 +3038,21 @@
 
 // In test::Bar
 int foo = 3)",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Macro;
+HI.Name = "PLUS_ONE";
+HI.Definition = "#define PLUS_ONE(X) (X+1)\n\n"
+"// Expands to\n"
+"(1 + 1)";
+  },
+  R"(macro PLUS_ONE
+
+#define PLUS_ONE(X) (X+1)
+
+// Expands to
+(1 + 1))",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -641,7 +641,8 @@
 }
 
 /// Generate a \p Hover object given the macro \p MacroDecl.
-HoverInfo getHoverContents(const DefinedMacro &Macro, ParsedAST &AST) {
+HoverInfo getHoverContents(const syntax::Token &Tok, const DefinedMacro &Macro,
+   ParsedAST &AST) {
   HoverInfo HI;
   SourceManager &SM = AST.getSourceManager();
   HI.Name = std::string(Macro.Name);
@@ -672,6 +673,29 @@
 .str();
 }
   }
+
+  if (auto Expansion = AST.getTokens().expansionStartingAt(&Tok)) {
+// We drop expansion that's longer than the threshold.
+// For extremely long expansion text, it's not read

[PATCH] D130553: [clang][lld][cmake] Simplify header dirs

2022-07-27 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne accepted this revision.
sebastian-ne added a comment.
This revision is now accepted and ready to land.

Looks good to me, I left three questions inline.




Comment at: clang/CMakeLists.txt:81
 # path is removed.
-set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(INCLUDE_DIRS ${LLVM_INCLUDE_DIRS})
 set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")

Ericson2314 wrote:
> sebastian-ne wrote:
> > Do we need to add `"${LLVM_BINARY_DIR}/include"` here as well?
> Pretty sure we shouldn't be cause that should be one of the elements of the 
> list when LLVM is also being built in this CMake invocation.
The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)



Comment at: clang/CMakeLists.txt:91
 
-  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_INCLUDE_DIRS ${INCLUDE_DIRS} CACHE PATH "Path to llvm/include and 
any other header dirs needed")
   set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")

The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)



Comment at: clang/CMakeLists.txt:133
 
-  include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
+  include_directories(${LLVM_INCLUDE_DIRS})
   link_directories("${LLVM_LIBRARY_DIR}")

The quotation marks went missing, is this intended? (Same in lld/CMakeLists.txt)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130553

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


[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-07-27 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 447967.
njames93 added a comment.

Fix typo in check list documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/use-early-exits.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-braces.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-split.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
@@ -0,0 +1,164 @@
+// RUN: %check_clang_tidy %s readability-use-early-exits -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2}}"
+
+// Run the check with the braces around statements check also enabled, but
+// ShortStatementLines is set so that we shouldn't add braces.
+// RUN: %check_clang_tidy %s readability-use-early-exits,readability-braces-around-statements -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 2, \
+// RUN:readability-braces-around-statements.ShortStatementLines: 2}}"
+
+// Just to hit the threshold
+void padLines();
+
+void nomralFunc(int *A) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (A) {
+*A = 10;
+  }
+  //   CHECK-FIXES: if (!A)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *A = 10;
+}
+
+void funcWithTrailing(int *B) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (B) {
+*B = 10;
+  }
+  return;
+  ;
+  //   CHECK-FIXES: if (!B)
+  //  CHECK-FIXES-NEXT: return;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: *B = 10;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: ;
+}
+
+void normal(int A, int B) {
+
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A == B) {
+  padLines();
+}
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A != B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  //  CHECK-FIXES-NEXT: }
+
+  // Eat continue and empty nulls
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A != B) {
+  padLines();
+}
+continue;
+;
+continue;
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT:   ;
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: }
+}
+
+void toShort(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+  }
+}
+
+void hasElse(int A, int B) {
+  while (true) {
+if (A == B) {
+
+} else {
+}
+  }
+}
+
+void hasTrailingStmt(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+padLines();
+  }
+}
+
+void nested(int A, int B) {
+  // if (A > B) {
+  // CHECK-MESSAGES: [[@LINE+6]]:5: warning: use early exit
+  // if (B < A) {
+  // CHECK-MESSAGES: [[@LINE+5]]:7: warning: use early exit
+  // if (A == B) {
+  // CHECK-MESSAGES: [[@LINE+4]]:9: warning: use early exit
+  while (true) { // Nested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  }
+}
+  } // EndLoop
+  //   CHECK-FIXES: while (true) { // Nested
+  //  CHECK-FIXES-NEXT: if (A <= B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (B >= A)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: padLines();
+  // CHECK-FIXES-EMPTY:
+  //  CHECK-FIXES-NEXT: } // EndLoop
+}
+
+void badNested(bool B) {
+  // Ensure check doesn't check for nested `if` if outer `if` has else.
+  while (true) {
+if (B) {
+  if (B) {
+  }
+} else {
+}
+  }
+}
+
+void semiNested(int A, int B) {
+  // CHECK-MESSAGES: [[@LINE+2]]:5: warning: use early exit
+  while (true) { // SemiNested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  } else {
+  }
+}
+  }
+  //   

[clang-tools-extra] 61c422f - [clang-tidy] Add execute perms back to add_new_check script

2022-07-27 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-07-27T10:41:34+01:00
New Revision: 61c422f274a07bcf2af9ebbb24f9fde879a8cc30

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

LOG: [clang-tidy] Add execute perms back to add_new_check script

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
old mode 100644
new mode 100755



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


[PATCH] D130620: Fix lack of cc1 flag in llvmcmd sections when assertions are enabled

2022-07-27 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman created this revision.
Herald added a project: All.
aidengrossman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently when assertions are enabled, the cc1 flag is not
inserted into the llvmcmd section of object files with embedded
bitcode. This deviates from the normal behavior where this is
the first flag that is inserted. This error stems from incorrect
use of the function generateCC1CommandLine() which requires
manually adding in the -cc1 flag which is currently not done.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130620

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4544,7 +4544,10 @@
 return CreateFromArgsImpl(Invocation, CommandLineArgs, Diags, Argv0);
   },
   [](CompilerInvocation &Invocation, SmallVectorImpl &Args,
- StringAllocator SA) { Invocation.generateCC1CommandLine(Args, SA); },
+ StringAllocator SA) {
+Invocation.generateCC1CommandLine(Args, SA);
+Args.insert(Args.begin(), "-cc1");
+  },
   Invocation, DummyInvocation, CommandLineArgs, Diags, Argv0);
 }
 


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4544,7 +4544,10 @@
 return CreateFromArgsImpl(Invocation, CommandLineArgs, Diags, Argv0);
   },
   [](CompilerInvocation &Invocation, SmallVectorImpl &Args,
- StringAllocator SA) { Invocation.generateCC1CommandLine(Args, SA); },
+ StringAllocator SA) {
+Invocation.generateCC1CommandLine(Args, SA);
+Args.insert(Args.begin(), "-cc1");
+  },
   Invocation, DummyInvocation, CommandLineArgs, Diags, Argv0);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447973.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111283

Files:
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
  clang/test/SemaCXX/deduced-return-void.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaTemplate/deduction.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111283
Index: clang/test/SemaTemplate/deduction.cpp
===
--- clang/test/SemaTemplate/deduction.cpp
+++ clang/test/SemaTemplate/deduction.cpp
@@ -162,6 +162,15 @@
 
 } // namespace test4
 
+namespace test5 {
+
+template  class a {};
+template  void c(b, b);
+template  void c(a, a);
+void d() { c(a(), a()); }
+
+} // namespace test5
+
 // Verify that we can deduce enum-typed arguments correctly.
 namespace test14 {
   enum E { E0, E1 };
Index: clang/test/SemaCXX/sugared-auto.cpp
===
--- clang/test/SemaCXX/sugared-auto.cpp
+++ clang/test/SemaCXX/sugared-auto.cpp
@@ -1,4 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++20 -fms-extensions -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec -Wno-c++17-compat-mangling
+// RUN: %clang_cc1 -fsyntax-only -verify -xobjective-c++ %s -std=c++14 -fms-extensions -fblocks -fobjc-arc -fobjc-runtime-has-weak -fenable-matrix -Wno-dynamic-exception-spec -Wno-c++17-compat-mangling
+
+namespace std {
+template struct initializer_list {
+  const T *begin, *end;
+  initializer_list();
+};
+} // namespace std
 
 enum class N {};
 
@@ -9,6 +17,26 @@
 using Man = Animal;
 using Dog = Animal;
 
+using ManPtr = Man *;
+using DogPtr = Dog *;
+
+using SocratesPtr = ManPtr;
+
+using ConstMan = const Man;
+using ConstDog = const Dog;
+
+using Virus = void;
+using SARS = Virus;
+using Ebola = Virus;
+
+using Bacteria = float;
+using Bacilli = Bacteria;
+using Vibrio = Bacteria;
+
+struct Plant;
+using Gymnosperm = Plant;
+using Angiosperm = Plant;
+
 namespace variable {
 
 auto x1 = Animal();
@@ -25,6 +53,9 @@
 N t4 = x4; // expected-error {{lvalue of type 'Man' (aka 'int')}}
 N t5 = x5; // expected-error {{lvalue of type 'Dog' (aka 'int')}}
 
+auto x6 = { Man(), Dog() };
+N t6 = x6; // expected-error {{from 'std::initializer_list' (aka 'initializer_list')}}
+
 } // namespace variable
 
 namespace function_basic {
@@ -41,3 +72,160 @@
 N t3 = x3; // expected-error {{lvalue of type 'Animal' (aka 'int')}}
 
 } // namespace function_basic
+
+namespace function_multiple_basic {
+
+N t1 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t2 = []() -> decltype(auto) { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Man();
+  return Dog();
+}();
+
+N t3 = [] { // expected-error {{rvalue of type 'Animal' (aka 'int')}}
+  if (true)
+return Dog();
+  auto x = Man();
+  return x;
+}();
+
+N t4 = [] { // expected-error {{rvalue of type 'int'}}
+  if (true)
+return Dog();
+  return 1;
+}();
+
+N t5 = [] { // expected-error {{rvalue of type 'Virus' (aka 'void')}}
+  if (true)
+return Ebola();
+  return SARS();
+}();
+
+N t6 = [] { // expected-error {{rvalue of type 'void'}}
+  if (true)
+return SARS();
+  return;
+}();
+
+} // namespace function_multiple_basic
+
+#define TEST_AUTO(X, A, B) \
+  static_assert(__is_same(A, B), ""); \
+  auto X(A a, B b) {   \
+if (0) \
+  return a;\
+if (0) \
+  return b;\
+return N();\
+  }
+#define TEST_DAUTO(X, A, B) \
+  static_assert(__is_same(A, B), ""); \
+  decltype(auto) X(A a, B b) {  \
+if (0)  \
+  return static_cast(a); \
+if (0)  \
+  return static_cast(b); \
+return N(); \
+  }
+
+namespace misc {
+
+TEST_AUTO(t1, ManPtr, DogPtr)  // expected-error {{but deduced as 'Animal *' (aka 'int *')}}
+TEST_AUTO(t2, ManPtr, int *)   // expected-error {{but deduced as 'int *'}}
+TEST_AUTO(t3, SocratesPtr, ManPtr) // expected-error {{but deduced as 'ManPtr' (aka 'int *')}}
+
+TEST_AUTO(t4, _Atomic(Man), _Atomic(Dog)) // expected

[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447974.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D111283
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
=

[clang] 7f0387d - [clang][ExtractAPI] Add a space between type and name in property declaration fragments

2022-07-27 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-07-27T11:02:21+01:00
New Revision: 7f0387de4c600af185b2db8d748f530444fe03cd

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

LOG: [clang][ExtractAPI] Add a space between type and name in property 
declaration fragments

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

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 75d360a3ba167..40ba124bc4d81 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -692,6 +692,7 @@ DeclarationFragments 
DeclarationFragmentsBuilder::getFragmentsForObjCProperty(
   return Fragments.appendSpace()
   .append(getFragmentsForType(Property->getType(),
   Property->getASTContext(), After))
+  .appendSpace()
   .append(Property->getName(),
   DeclarationFragments::FragmentKind::Identifier)
   .append(std::move(After));

diff  --git a/clang/test/ExtractAPI/objc_category.m 
b/clang/test/ExtractAPI/objc_category.m
index 946f01eaeb334..56bac43a11cdc 100644
--- a/clang/test/ExtractAPI/objc_category.m
+++ b/clang/test/ExtractAPI/objc_category.m
@@ -317,6 +317,10 @@ + (void)ClassMethod;
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"

diff  --git a/clang/test/ExtractAPI/objc_interface.m 
b/clang/test/ExtractAPI/objc_interface.m
index bd1f23ed1f095..740a215400d9c 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -462,6 +462,10 @@ - (char)getIvar;
   "preciseIdentifier": "c:i",
   "spelling": "unsigned int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"



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


[PATCH] D130583: [clang][ExtractAPI] Add a space between type and name in property declaration fragments

2022-07-27 Thread Daniel Grumberg 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 rG7f0387de4c60: [clang][ExtractAPI] Add a space between type 
and name in property declaration… (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130583

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_interface.m


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -462,6 +462,10 @@
   "preciseIdentifier": "c:i",
   "spelling": "unsigned int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -317,6 +317,10 @@
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"
Index: clang/lib/ExtractAPI/DeclarationFragments.cpp
===
--- clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -692,6 +692,7 @@
   return Fragments.appendSpace()
   .append(getFragmentsForType(Property->getType(),
   Property->getASTContext(), After))
+  .appendSpace()
   .append(Property->getName(),
   DeclarationFragments::FragmentKind::Identifier)
   .append(std::move(After));


Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -462,6 +462,10 @@
   "preciseIdentifier": "c:i",
   "spelling": "unsigned int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"
Index: clang/test/ExtractAPI/objc_category.m
===
--- clang/test/ExtractAPI/objc_category.m
+++ clang/test/ExtractAPI/objc_category.m
@@ -317,6 +317,10 @@
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "Property"
Index: clang/lib/ExtractAPI/DeclarationFragments.cpp
===
--- clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -692,6 +692,7 @@
   return Fragments.appendSpace()
   .append(getFragmentsForType(Property->getType(),
   Property->getASTContext(), After))
+  .appendSpace()
   .append(Property->getName(),
   DeclarationFragments::FragmentKind::Identifier)
   .append(std::move(After));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d3fc779 - [clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"

2022-07-27 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-07-27T11:03:34+01:00
New Revision: d3fc779e4295b0bf726008580ddd99c8e86c2c0c

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

LOG: [clang][ExtractAPI] Ensure that class properties have a kind of "Type 
Property"

Generated symbol graphs should distinguish between type properties and instance
properties.

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

Added: 
clang/test/ExtractAPI/objc_property.m

Modified: 
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Removed: 




diff  --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp 
b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 709b781968bf7..6ef7badfa66f4 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -351,7 +351,7 @@ Object serializeSymbolKind(const APIRecord &Record, 
Language Lang) {
 Kind["displayName"] = "Instance Variable";
 break;
   case APIRecord::RK_ObjCMethod:
-if (dyn_cast(&Record)->IsInstanceMethod) {
+if (cast(&Record)->IsInstanceMethod) {
   Kind["identifier"] = AddLangPrefix("method");
   Kind["displayName"] = "Instance Method";
 } else {
@@ -360,8 +360,13 @@ Object serializeSymbolKind(const APIRecord &Record, 
Language Lang) {
 }
 break;
   case APIRecord::RK_ObjCProperty:
-Kind["identifier"] = AddLangPrefix("property");
-Kind["displayName"] = "Instance Property";
+if (cast(&Record)->isClassProperty()) {
+  Kind["identifier"] = AddLangPrefix("type.property");
+  Kind["displayName"] = "Type Property";
+} else {
+  Kind["identifier"] = AddLangPrefix("property");
+  Kind["displayName"] = "Instance Property";
+}
 break;
   case APIRecord::RK_ObjCInterface:
 Kind["identifier"] = AddLangPrefix("class");

diff  --git a/clang/test/ExtractAPI/objc_property.m 
b/clang/test/ExtractAPI/objc_property.m
new file mode 100644
index 0..7cc17291ac76c
--- /dev/null
+++ b/clang/test/ExtractAPI/objc_property.m
@@ -0,0 +1,745 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx -x 
objective-c-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: 
diff  %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+@protocol Protocol
+@property(class) int myProtocolTypeProp;
+@property int myProtocolInstanceProp;
+@end
+
+@interface Interface
+@property(class) int myInterfaceTypeProp;
+@property int myInterfaceInstanceProp;
+@end
+
+@interface Interface (Category) 
+@property(class) int myCategoryTypeProp;
+@property int myCategoryInstanceProp;
+@end
+// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "conformsTo",
+  "source": "c:objc(cs)Interface",
+  "target": "c:objc(pl)Protocol"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
+  "target": "c:objc(pl)Protocol"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
+  "target": "c:objc(pl)Protocol"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+  

[PATCH] D130581: [clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"

2022-07-27 Thread Daniel Grumberg 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 rGd3fc779e4295: [clang][ExtractAPI] Ensure that class 
properties have a kind of "Type Property" (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130581

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_property.m

Index: clang/test/ExtractAPI/objc_property.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_property.m
@@ -0,0 +1,745 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx -x objective-c-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+@protocol Protocol
+@property(class) int myProtocolTypeProp;
+@property int myProtocolInstanceProp;
+@end
+
+@interface Interface
+@property(class) int myInterfaceTypeProp;
+@property int myInterfaceInstanceProp;
+@end
+
+@interface Interface (Category) 
+@property(class) int myCategoryTypeProp;
+@property int myCategoryInstanceProp;
+@end
+// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "conformsTo",
+  "source": "c:objc(cs)Interface",
+  "target": "c:objc(pl)Protocol"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
+  "target": "c:objc(pl)Protocol"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
+  "target": "c:objc(pl)Protocol"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Interface"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Interface"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "objective-c.class"
+  },
+  "location": {
+"position": {
+  "character": 12,
+  "line": 6
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Interface"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Interface"
+  }
+],
+"title": "Interface"
+  },
+  "pathComponents": [
+"Interface"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@property"
+},
+{
+  "kind": "text",
+  "spelling": " ("
+},
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "atomic"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "assign"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "k

[PATCH] D130585: [Sema] Return primary merged decl as canonical for concepts

2022-07-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 447978.
ilya-biryukov added a comment.

- set canonical decl as primary merged, add tests for the relevant failure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130585

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/merge-concepts.cpp


Index: clang/test/Modules/merge-concepts.cpp
===
--- clang/test/Modules/merge-concepts.cpp
+++ clang/test/Modules/merge-concepts.cpp
@@ -28,6 +28,10 @@
export *
header "concepts.h"
}
+   module "compare" {
+   export *
+   header "compare.h"
+   }
module "format" {
export *
header "format.h"
@@ -47,19 +51,34 @@
 #define SAME_AS_H
 
 template 
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
 
+template 
+concept same_as = same_as_impl && same_as_impl;
 #endif // SAME_AS_H
 
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template  void foo()
+  requires same_as
+{}
+#endif // COMPARE_H
+
 //--- format.h
 #ifndef FORMAT_H
 #define FORMAT_H
 
-#include "concepts.h"
 #include "same_as.h"
+#include "concepts.h"
 
-template  void foo()
+template  void bar()
   requires same_as
 {}
 
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8758,7 +8758,8 @@
 //Other decls (e.g. namespaces) also have this shortcoming.
 return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@
 return isa(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() override {
+return cast(getPrimaryMergedDecl(this));
+  }
+  const ConceptDecl *getCanonicalDecl() const {
+return const_cast(this)->getCanonicalDecl();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }


Index: clang/test/Modules/merge-concepts.cpp
===
--- clang/test/Modules/merge-concepts.cpp
+++ clang/test/Modules/merge-concepts.cpp
@@ -28,6 +28,10 @@
 		export *
 		header "concepts.h"
 	}
+	module "compare" {
+		export *
+		header "compare.h"
+	}
 	module "format" {
 		export *
 		header "format.h"
@@ -47,19 +51,34 @@
 #define SAME_AS_H
 
 template 
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
 
+template 
+concept same_as = same_as_impl && same_as_impl;
 #endif // SAME_AS_H
 
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template  void foo()
+  requires same_as
+{}
+#endif // COMPARE_H
+
 //--- format.h
 #ifndef FORMAT_H
 #define FORMAT_H
 
-#include "concepts.h"
 #include "same_as.h"
+#include "concepts.h"
 
-template  void foo()
+template  void bar()
   requires same_as
 {}
 
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8758,7 +8758,8 @@
 //Other decls (e.g. namespaces) also have this shortcoming.
 return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@
 return isa(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() override {
+return cast(getPrimaryMergedDecl(this));
+  }
+  const ConceptDecl *getCanonicalDecl

[PATCH] D130585: [Sema] Return primary merged decl as canonical for concepts

2022-07-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D130585#3681397 , @ChuanqiXu wrote:

> In D130585#3680189 , @ilya-biryukov 
> wrote:
>
>> I wonder whether the right fix for this should generalize to `Mergeable`.
>> The fact that `Mergeable::getFirstDecl` checks if the decl is coming from 
>> the AST file before looking up its primary merged decl is probably a 
>> performance optimization, not a deliberate semantic.
>
> Agreed. I think we could omit the `isFromASTFile` part. But if we want to 
> generalize to `Mergeable`, we need to add much more tests. I think we 
> could make it in future patches.

Totally agree, the Mergable change needs to be tested more thoroughly.
I have incorporated the `getCanonicalDecl()` call from your patch here and 
added test for the corresponding failure to `merge-concepts.cpp` too.
Otherwise my patch did not fix the failure I was encountering in practice 
(after I double-checked).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130585

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


[clang] 42f87bb - [Sema] Return primary merged decl as canonical for concepts

2022-07-27 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2022-07-27T12:31:20+02:00
New Revision: 42f87bb62d0719848842da60d2a8180b9e4d7c52

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

LOG: [Sema] Return primary merged decl as canonical for concepts

Otherwise we get invalid results for ODR checks. See changed test for an
example: despite the fact that we merge the first concept, its **uses**
were considered different by `Profile`, leading to redefinition errors.

After this change, canonical decl for a concept can come from a
different module and may not be visible. This behavior looks suspicious,
but does not break any tests. We might want to add a mechanism to make
the canonical concept declaration visible if we find code that relies on
this invariant.

Additionally make sure we always merge with the canonical declaration to
avoid chains of merged concepts being reported as redefinitions. An
example was added to the test.

Also change the order of includes in the test. Importing a moduralized
header before its textual part causes the include guard macro to be
exported and the corresponding `#include` becomes a no-op.

Reviewed By: ChuanqiXu

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

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/lib/Sema/SemaTemplate.cpp
clang/test/Modules/merge-concepts.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 725bb0bced9c5..baed5ca22fa75 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@ class ConceptDecl : public TemplateDecl, public 
Mergeable {
 return isa(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() override {
+return cast(getPrimaryMergedDecl(this));
+  }
+  const ConceptDecl *getCanonicalDecl() const {
+return const_cast(this)->getCanonicalDecl();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 8f887ce7829fa..c0bec60f737c8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8754,7 +8754,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
 //Other decls (e.g. namespaces) also have this shortcoming.
 return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation

diff  --git a/clang/test/Modules/merge-concepts.cpp 
b/clang/test/Modules/merge-concepts.cpp
index 9242f27633795..c774157dd85b4 100644
--- a/clang/test/Modules/merge-concepts.cpp
+++ b/clang/test/Modules/merge-concepts.cpp
@@ -28,6 +28,10 @@ module "library" {
export *
header "concepts.h"
}
+   module "compare" {
+   export *
+   header "compare.h"
+   }
module "format" {
export *
header "format.h"
@@ -47,19 +51,34 @@ module "library" {
 #define SAME_AS_H
 
 template 
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
 
+template 
+concept same_as = same_as_impl && same_as_impl;
 #endif // SAME_AS_H
 
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template  void foo()
+  requires same_as
+{}
+#endif // COMPARE_H
+
 //--- format.h
 #ifndef FORMAT_H
 #define FORMAT_H
 
-#include "concepts.h"
 #include "same_as.h"
+#include "concepts.h"
 
-template  void foo()
+template  void bar()
   requires same_as
 {}
 
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H



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


[PATCH] D130585: [Sema] Return primary merged decl as canonical for concepts

2022-07-27 Thread Ilya Biryukov 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 rG42f87bb62d07: [Sema] Return primary merged decl as canonical 
for concepts (authored by ilya-biryukov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130585

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/merge-concepts.cpp


Index: clang/test/Modules/merge-concepts.cpp
===
--- clang/test/Modules/merge-concepts.cpp
+++ clang/test/Modules/merge-concepts.cpp
@@ -28,6 +28,10 @@
export *
header "concepts.h"
}
+   module "compare" {
+   export *
+   header "compare.h"
+   }
module "format" {
export *
header "format.h"
@@ -47,19 +51,34 @@
 #define SAME_AS_H
 
 template 
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
 
+template 
+concept same_as = same_as_impl && same_as_impl;
 #endif // SAME_AS_H
 
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template  void foo()
+  requires same_as
+{}
+#endif // COMPARE_H
+
 //--- format.h
 #ifndef FORMAT_H
 #define FORMAT_H
 
-#include "concepts.h"
 #include "same_as.h"
+#include "concepts.h"
 
-template  void foo()
+template  void bar()
   requires same_as
 {}
 
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8754,7 +8754,8 @@
 //Other decls (e.g. namespaces) also have this shortcoming.
 return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@
 return isa(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() override {
+return cast(getPrimaryMergedDecl(this));
+  }
+  const ConceptDecl *getCanonicalDecl() const {
+return const_cast(this)->getCanonicalDecl();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }


Index: clang/test/Modules/merge-concepts.cpp
===
--- clang/test/Modules/merge-concepts.cpp
+++ clang/test/Modules/merge-concepts.cpp
@@ -28,6 +28,10 @@
 		export *
 		header "concepts.h"
 	}
+	module "compare" {
+		export *
+		header "compare.h"
+	}
 	module "format" {
 		export *
 		header "format.h"
@@ -47,19 +51,34 @@
 #define SAME_AS_H
 
 template 
-concept same_as = __is_same(T, U);
+concept same_as_impl = __is_same(T, U);
 
+template 
+concept same_as = same_as_impl && same_as_impl;
 #endif // SAME_AS_H
 
+
+//--- compare.h
+#ifndef COMPARE_H
+#define COMPARE_H
+
+#include "same_as.h"
+#include "concepts.h"
+
+template  void foo()
+  requires same_as
+{}
+#endif // COMPARE_H
+
 //--- format.h
 #ifndef FORMAT_H
 #define FORMAT_H
 
-#include "concepts.h"
 #include "same_as.h"
+#include "concepts.h"
 
-template  void foo()
+template  void bar()
   requires same_as
 {}
 
-#endif // FORMAT_H
\ No newline at end of file
+#endif // FORMAT_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8754,7 +8754,8 @@
 //Other decls (e.g. namespaces) also have this shortcoming.
 return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@
 return isa(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() overrid

[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447988.
mizvekov marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128113

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/JSONNodeDumper.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-template-decls.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4793,6 +4793,44 @@
   ToD2->getDeclContext(), ToD2->getTemplateParameters()->getParam(0)));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportSubstTemplateTypeParmType) {
+  constexpr auto Code = R"(
+template  struct A {
+  using B = A1(A2...);
+};
+template struct A;
+)";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11, "input.cpp");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+
+  auto testType = [&](ASTContext &Ctx, const char *Name,
+  llvm::Optional PackIndex) {
+const auto *Subst = selectFirst(
+"sttp", match(substTemplateTypeParmType(
+  hasReplacementType(hasCanonicalType(asString(Name
+  .bind("sttp"),
+  Ctx));
+const char *ExpectedTemplateParamName = PackIndex ? "A2" : "A1";
+ASSERT_TRUE(Subst);
+ASSERT_EQ(Subst->getReplacedParameter()->getIdentifier()->getName(),
+  ExpectedTemplateParamName);
+ASSERT_EQ(Subst->getPackIndex(), PackIndex);
+  };
+  auto tests = [&](ASTContext &Ctx) {
+testType(Ctx, "void", None);
+testType(Ctx, "char", 0);
+testType(Ctx, "float", 1);
+testType(Ctx, "int", 2);
+testType(Ctx, "short", 3);
+  };
+
+  tests(FromTU->getASTContext());
+
+  ClassTemplateSpecializationDecl *ToClass = Import(FromClass, Lang_CXX11);
+  tests(ToClass->getASTContext());
+}
+
 const AstTypeMatcher
 substTemplateTypeParmPackType;
 
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
@@ -136,13 +136,13 @@
 };
 using t1 = foo::bind;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 2
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar pack_index 3
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
 
 template  struct D {
@@ -152,13 +152,13 @@
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar pack_index 0
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar pack_index 1
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 inde

[clang] cef232f - [clang][ExtractAPI] Fix objc_property.m reference output

2022-07-27 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-07-27T11:34:17+01:00
New Revision: cef232ff3320ad1c85d403837d0b8c8b5ae7153f

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

LOG: [clang][ExtractAPI] Fix objc_property.m reference output

After landing 7f0387de4c600af185b2db8d748f530444fe03cd I forgot to update this
new test.

Added: 


Modified: 
clang/test/ExtractAPI/objc_property.m

Removed: 




diff  --git a/clang/test/ExtractAPI/objc_property.m 
b/clang/test/ExtractAPI/objc_property.m
index 7cc17291ac76..1b50950d4424 100644
--- a/clang/test/ExtractAPI/objc_property.m
+++ b/clang/test/ExtractAPI/objc_property.m
@@ -195,6 +195,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myInterfaceTypeProp"
@@ -283,6 +287,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myInterfaceInstanceProp"
@@ -379,6 +387,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myCategoryTypeProp"
@@ -467,6 +479,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myCategoryInstanceProp"
@@ -613,6 +629,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myProtocolTypeProp"
@@ -701,6 +721,10 @@ @interface Interface (Category) 
   "preciseIdentifier": "c:I",
   "spelling": "int"
 },
+{
+  "kind": "text",
+  "spelling": " "
+},
 {
   "kind": "identifier",
   "spelling": "myProtocolInstanceProp"



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


[PATCH] D130566: [Driver] Default to DWARF 4 on Linux/sparc64

2022-07-27 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D130566#3681129 , @dblaikie wrote:

>> During a build on Debian 11/sparc64, several binaries fail to link with
>>
>>   /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 
>> 0x23
>
> What's the linker doing parsing DWARF? Any idea what feature this is? And why 
> is it SPARC-specific? Or is it true of other targets on the same Debian 
> version?

I have no idea, actually.  The code in question is `bfd/dwarf2.c` 
(`read_attribute_value`), who's comment states:

  /* Read and fill in the value of attribute ATTR as described by FORM.
 Read data starting from INFO_PTR, but never at or beyond INFO_PTR_END.
 Returns an updated INFO_PTR taking into account the amount of data read.  
*/

So far, I had only seen it with the GNU `ld` 2.38.50 bundled with Debian 
11/sparc64, but couldn't reproduce on Ubuntu 20.04/x86_64 (neither bundled GNU 
`ld`  2.34, nor self-compiled 2.38.90).  Things got even weirder when I tried 
to create a minimal testcase for a binutils bug report: I'd initially seen the 
error when linking `Sanitizer-sparc-Test`.  However, at that time the link also 
failed due to D130571 .  I got the `unhandled 
FORM value` error several times, probably for several different input objects.  
However, when adding `-latomic` to the link, the link did succeed without 
issues.

I've since ran a full build with all pending patches, just without this one, 
and didn't see the DWARF error again.  This is all extremely weird, but until 
the error shows up again, I'll put this patch on hold (not yet abandoning since 
there seems to be no way to unabandon if necessary).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130566

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


[PATCH] D128095: clang: fix checking parameter packs for expansion

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447995.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -469,3 +469,25 @@
   bar(b);
 }
 }
+
+namespace pr56094 {
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+  // expected-error@-1 {{pack expansion contains parameter packs 'T' and 'U' that have different lengths (1 vs. 2)}}
+  template  D(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t1 = D::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::D' requested here}}
+
+template  struct F {};
+template  struct G {};
+template  struct E {
+  template  using B = G...>;
+  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  template  E(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t2 = E::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::E' requested here}}
+} // namespace pr56094
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -88,6 +88,17 @@
   return true;
 }
 
+bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
+  Unexpanded.push_back({T, SourceLocation()});
+  return true;
+}
+
+bool
+VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
+  Unexpanded.push_back({E, E->getParameterPackLocation()});
+  return true;
+}
+
 /// Record occurrences of function and non-type template
 /// parameter packs in an expression.
 bool VisitDeclRefExpr(DeclRefExpr *E) {
@@ -306,7 +317,8 @@
   auto *TTPD = dyn_cast(LocalPack);
   return TTPD && TTPD->getTypeForDecl() == TTPT;
 }
-return declaresSameEntity(Pack.first.get(), LocalPack);
+return declaresSameEntity(Pack.first.get(),
+  LocalPack);
   };
   if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
 LambdaParamPackReferences.push_back(Pack);
@@ -358,7 +370,7 @@
   = Unexpanded[I].first.dyn_cast())
   Name = TTP->getIdentifier();
 else
-  Name = Unexpanded[I].first.get()->getIdentifier();
+  Name = Unexpanded[I].first.get()->getIdentifier();
 
 if (Name && NamesKnown.insert(Name).second)
   Names.push_back(Name);
@@ -421,7 +433,7 @@
   llvm::SmallPtrSet ParmSet(Parms.begin(), Parms.end());
   SmallVector UnexpandedParms;
   for (auto Parm : Unexpanded)
-if (ParmSet.contains(Parm.first.dyn_cast()))
+if (ParmSet.contains(Parm.first.dyn_cast()))
   UnexpandedParms.push_back(Parm);
   if (UnexpandedParms.empty())
 return false;
@@ -681,42 +693,51 @@
 // Compute the depth and index for this parameter pack.
 unsigned Depth = 0, Index = 0;
 IdentifierInfo *Name;
-bool IsVarDeclPack = false;
+unsigned NewPackSize;
+bool NotPack = true;
 
-if (const TemplateTypeParmType *TTP =
+if (const auto *TTP =
 ParmPack.first.dyn_cast()) {
   Depth = TTP->getDepth();
   Index = TTP->getIndex();
   Name = TTP->getIdentifier();
+} else if (const auto *STP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = STP->getNumArgs();
+  Name = STP->getIdentifier();
+  NotPack = false;
+} else if (const auto *SEP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = SEP->getArgumentPack().pack_size();
+  Name = SEP->getParameterPack()->getIdentifier();
+  NotPack = false;
 } else {
-  NamedDecl *ND = ParmPack.first.get();
-  if (isa(ND))
-IsVarDeclPack = true;
-  else
+  const auto *ND = ParmPack.first.get();
+  if (isa(ND)) {
+// Figure out whether we're instantiating to an argument pack or not.
+using DeclArgumentPack = LocalInstantiationScope::DeclArgumentPack;
+llvm::PointerUnion *Instantiation =
+CurrentInstantiationScope->findInstantiationOf(
+ParmPack.first.get());
+if (Instantiation->is()) {
+  // We could expand this function parameter pack.
+  NewPackSize = Instantiation->get()->size();
+} else {
+  // We can't expand this

[PATCH] D130614: [C++20] [Modules] Merge same concept decls in global module fragment

2022-07-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks! Mostly questions to better understand the spec and clang. Please excuse 
me if they sound too basic.
I have read the modules section of the standard, but I couldn't find where it 
specifies whether these redefinition errors should be present or not. Any 
guidance of where to look at?

Could we add a few examples where legitimate redefinition errors do happen?
(private module fragment?




Comment at: clang/lib/Sema/SemaTemplate.cpp:8731
 
-  auto *OldConcept = dyn_cast(Previous.getRepresentativeDecl());
+  NamedDecl *Old = Previous.getRepresentativeDecl();
+  if (auto *USD = dyn_cast(Old))

This follows what `getFoundDecl()` does, but still allows to show errors when 
lookup results contain multiple entities.

A question too: is true that concept is always reachable if it has a reachable 
using decl?
I wonder whether `hasReachableDefinition` should be called on `UsingShadowDecl` 
instead?



Comment at: clang/lib/Sema/SemaTemplate.cpp:8755
+  // old one, we should merge them instead of complaining.
+  !(OldConcept->getOwningModule() &&
+OldConcept->getOwningModule()->isGlobalModule())) {

Would we allow redefinitions inside the same global module fragment?
```
module;

template concept ok = true;
template concept ok = true; // should be an error.
```

could we add a test for that?
or do we only mark declarations coming from actual pcm files as having as 
owning module fragment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130614

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


[PATCH] D130224: [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values

2022-07-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 updated this revision to Diff 447993.
skc7 added a comment.

Changes for code review comments from @aaron.ballman


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

https://reviews.llvm.org/D130224

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-maybeundef-template.cpp
  clang/test/CodeGen/attr-maybeundef.c
  clang/test/CodeGenHIP/maybe_undef-attr-verify.hip
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-maybeundef.c

Index: clang/test/Sema/attr-maybeundef.c
===
--- /dev/null
+++ clang/test/Sema/attr-maybeundef.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+// Decl annotations.
+void f(int __attribute__((maybe_undef)) *a);
+void (*fp)(int __attribute__((maybe_undef)) handle);
+__attribute__((maybe_undef)) int i(); // expected-warning {{'maybe_undef' attribute only applies to parameters}}
+int __attribute__((maybe_undef)) a; // expected-warning {{'maybe_undef' attribute only applies to parameters}}
+int (* __attribute__((maybe_undef)) fpt)(char *); // expected-warning {{'maybe_undef' attribute only applies to parameters}}
+void h(int *a __attribute__((maybe_undef("RandomString"; // expected-error {{'maybe_undef' attribute takes no arguments}}
+
+// Type annotations.
+int __attribute__((maybe_undef)) ta; // expected-warning {{'maybe_undef' attribute only applies to parameters}}
+
+// Typedefs.
+typedef int callback(char *) __attribute__((maybe_undef)); // expected-warning {{'maybe_undef' attribute only applies to parameters}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -83,6 +83,7 @@
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
 // CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_block)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
+// CHECK-NEXT: MaybeUndef (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: MinVectorWidth (SubjectMatchRule_function)
Index: clang/test/CodeGenHIP/maybe_undef-attr-verify.hip
===
--- /dev/null
+++ clang/test/CodeGenHIP/maybe_undef-attr-verify.hip
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -no-opaque-pointers -triple amdgcn-amd-amdhsa -target-cpu gfx906 -x hip -fcuda-is-device -emit-llvm  %s \
+// RUN:   -o - | FileCheck %s
+
+// CHECK: define dso_local amdgpu_kernel void @_Z13shufflekernelv()
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP1:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[TMP2:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[TMP3:%.*]] = addrspacecast i32 addrspace(5)* [[TMP1:%.*]] to i32*
+// CHECK-NEXT:[[TMP4:%.*]] = addrspacecast i32 addrspace(5)* [[TMP2:%.*]] to i32*
+// CHECK-NEXT:[[TMP5:%.*]] = load i32, i32* [[TMP3:%.*]], align 4
+// CHECK-NEXT:[[TMP6:%.*]] = freeze i32 [[TMP5:%.*]]
+// CHECK-NEXT:%call = call noundef i32 @_Z11__shfl_synciii(i32 noundef [[TMP6:%.*]], i32 noundef 64, i32 noundef 0) #4
+// CHECK-NEXT:store i32 %call, i32* [[TMP4:%.*]], align 4
+// CHECK-NEXT:  ret void
+
+// CHECK: define linkonce_odr noundef i32 @_Z11__shfl_synciii(i32 noundef [[TMP1:%.*]], i32 noundef [[TMP2:%.*]], i32 noundef [[TMP3:%.*]])
+
+#define __global__ __attribute__((global))
+#define __device__ __attribute__((device))
+#define __maybe_undef __attribute__((maybe_undef))
+#define WARP_SIZE 64
+
+static constexpr int warpSize = __AMDGCN_WAVEFRONT_SIZE;
+
+__device__ static inline unsigned int __lane_id() {
+return  __builtin_amdgcn_mbcnt_hi(
+-1, __builtin_amdgcn_mbcnt_lo(-1, 0));
+}
+
+__device__
+inline
+int __shfl_sync(int __maybe_undef var, int src_lane, int width = warpSize) {
+int self = __lane_id();
+int index = src_lane + (self & ~(width-1));
+return __builtin_amdgcn_ds_bpermute(index<<2, var);
+}
+
+__global__ void
+shufflekernel()
+{
+int t;
+int res;
+res = __shfl_sync(t, WARP_SIZE, 0);
+}
Index: clang/test/CodeGen/attr-maybeundef.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-maybeundef.c
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - | FileCheck %s
+
+#define __maybe_undef __attribute__((maybe_undef))
+
+// CHECK:  define dso_local void @t1(i32 noundef [[TMP1:%.*]], i32 noundef [[TMP2:%.*]], float noundef [[TMP3:%.*]])
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   [[TMP4:%.*]] = alloca i32, align 4
+// CHECK-

[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-07-27 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

In D123319#3680169 , @aprantl wrote:

> Sorry for the silence — I was out on vacation.
>
> @Michael137 has recently started looking into improving support for C++ 
> lambdas in LLDB.
> Michael, would you be interested in taking a fresh look at this and figure 
> out what the requirements for LLDB are here and how to answer the questions 
> @dblaikie raised specifically?

Sure will have a look what's missing from https://reviews.llvm.org/D105564 and 
whether these clang changes are indeed necessary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123319

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


[PATCH] D130224: [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values

2022-07-27 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2050-2066
+static bool IsArgumentMayBeUndef(const Decl *TargetDecl, unsigned ArgNo) {
+  if (!TargetDecl)
+return false;
+
+  bool ArgHasMayBeUndefAttr = false;
+  if (TargetDecl) {
+if (const FunctionDecl *FD = dyn_cast(TargetDecl)) {

aaron.ballman wrote:
> One question I have is whether you ever need to mark the variadic arguments 
> as being maybe undef. e.g., `void func(int i, ...);` do you need to signal 
> that arguments passed to `...` are maybe undef?
> 
Current change assumes variadic arguments will not have "maybe_undef" 
attribute. If its a function attribute, variadic arguments can inherit them 
(Have seen such cases in clang codebase). But "maybe_undef" is function 
argument attribute and I'm not sure on how to add it to variadic arguments.


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

https://reviews.llvm.org/D130224

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


[PATCH] D130308: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 447997.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1,2 +1,3 @@
 D111283
 D111509
+D130308
Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,77 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
+
+using QX = const SB1 *;
+using QY = const ::SB1 *;
+N t23 = 0 ? (QX){} : (QY){}; // expected-error {{rvalue of type 'const SB1 *' (aka 'const SS1 *')}}
+
+template  using Alias = short;
+N t24 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'Alias' (aka 'short')}}
+N t25 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'short'}}
+
+template  concept C1 = true;
+template  concept C2 = true;
+C1 auto t26_1 = (SB1){};
+C1 auto t26_2 = (::SB1){};
+C2 auto t26_3 = (::SB1){};
+N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}
+N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3776,13 +3776,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
  

[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2022-07-27 Thread Animesh Kumar via Phabricator via cfe-commits
animeshk-amd updated this revision to Diff 447998.
animeshk-amd edited the summary of this revision.
animeshk-amd added a comment.
Herald added subscribers: openmp-commits, steakhal, arphaman.
Herald added a project: OpenMP.

[OpenMP] Update more LIT tests to support OpenMP version upgrade

Some more LIT tests which were specifying version information in RUN 
lines have been modified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/AST/ast-dump-openmp-task.c
  clang/test/Analysis/cfg-openmp.cpp
  clang/test/Index/openmp-tile.c
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_codegen.cpp
  clang/test/OpenMP/align_clause_global_codegen.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/test/OpenMP/allocate_codegen_attr.cpp
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_capture_codegen.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/atomic_messages.c
  clang/test/OpenMP/atomic_messages.cpp
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/critical_codegen_attr.cpp
  clang/test/OpenMP/declare_mapper_ast_print.c
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/OpenMP/declare_mapper_messages.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_variant_clauses_ast_print.c
  clang/test/OpenMP/declare_variant_clauses_ast_print.cpp
  clang/test/OpenMP/declare_variant_clauses_messages.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/default_firstprivate_ast_print.cpp
  clang/test/OpenMP/default_private_ast_print.cpp
  clang/test/OpenMP/depobj_messages.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/flush_ast_print.cpp
  clang/test/OpenMP/flush_messages.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/generic_loop_ast_print.cpp
  clang/test/OpenMP/generic_loop_messages.cpp
  clang/test/OpenMP/interop_ast_print.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/irbuilder_unroll_full.c
  clang/test/OpenMP/irbuilder_unroll_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
  clang/test/OpenMP/masked_ast_print.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/masked_messages_attr.cpp
  clang/test/OpenMP/masked_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/openmp_attribute.cpp
  clang/test/OpenMP/openmp_attribute_compat.cpp
  clang/test/OpenMP/openmp_attribute_parsing.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_generic_loop_ast_print.cpp
  clang/test/OpenMP/parallel_generic_loop_messages.cpp
  clang/test/OpenMP/parallel_masked_default_messages.cpp
  clang/test/OpenMP/parallel_masked_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_lastprivate_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_reduction_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_master_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_messages.cp

[PATCH] D130224: [Clang][Attribute] Introduce maybe_undef attribute for function arguments which accepts undef values

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2050-2066
+static bool IsArgumentMayBeUndef(const Decl *TargetDecl, unsigned ArgNo) {
+  if (!TargetDecl)
+return false;
+
+  bool ArgHasMayBeUndefAttr = false;
+  if (TargetDecl) {
+if (const FunctionDecl *FD = dyn_cast(TargetDecl)) {

skc7 wrote:
> aaron.ballman wrote:
> > One question I have is whether you ever need to mark the variadic arguments 
> > as being maybe undef. e.g., `void func(int i, ...);` do you need to signal 
> > that arguments passed to `...` are maybe undef?
> > 
> Current change assumes variadic arguments will not have "maybe_undef" 
> attribute. If its a function attribute, variadic arguments can inherit them 
> (Have seen such cases in clang codebase). But "maybe_undef" is function 
> argument attribute and I'm not sure on how to add it to variadic arguments.
> Current change assumes variadic arguments will not have "maybe_undef" 
> attribute. If its a function attribute, variadic arguments can inherit them 
> (Have seen such cases in clang codebase). But "maybe_undef" is function 
> argument attribute and I'm not sure on how to add it to variadic arguments.

That's why I was asking if there will be a need either now or in the future -- 
is making this a parameter attribute the right design, or should this be a 
function attribute with positional arguments? (Not that I particularly love 
that design, but this isn't a user-facing attribute so if it's hard to use, I'm 
not that worried. I just want to make sure we don't need to add additional 
attributes in the future in this same space.)


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

https://reviews.llvm.org/D130224

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


[PATCH] D130553: [clang][lld][cmake] Simplify header dirs

2022-07-27 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

@sebastian-ne I didn't quote it because it is a list, but this might be shell 
script habit sneaking through. I am not sure what is best for CMake.

Checking now, 
https://stackoverflow.com/questions/35847655/when-should-i-quote-cmake-variables
 says "If your variable contains a list you normally don't add quotes" but I am 
not comfortable with "normally don't add"-style reasoning :).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130553

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


[PATCH] D130306: [clang][dataflow] Analyze calls to in-TU functions

2022-07-27 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D130306#3681291 , @samestep wrote:

> In D130306#3680942 , @chapuni wrote:
>
>> A few variables cause warinings in -Asserts.
>
> Thanks for pointing this out! How should I address this? Should I just inline 
> the definitions of those variables into the `assert`s themselves?

Someone took care of it: 
https://github.com/llvm/llvm-project/commit/1f8ae9d7e7e4afcc4e76728b28e64941660ca3eb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130306

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


[PATCH] D130626: [pseudo] experiment

2022-07-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added subscribers: usaxena95, kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is not the direction we will persume, but it is an experiment to
see how many ambiguities left if we have the perfect type information
for all identifiers in the parsing file.

Just post the results

Test file clangd/ASTSignals.cpp (no ambiguity!)

Result: 
https://htmlpreview.github.io/?https://gist.githubusercontent.com/hokein/3757357ac5787a0fe64cd1601f5c4d8f/raw/b6024fe27f7c39bcbb8d2e6c967d9561717a5af6/ASTSignals.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130626

Files:
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf

Index: clang-tools-extra/pseudo/lib/cxx/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -34,15 +34,15 @@
 _ := declaration-seq
 
 # gram.key
-typedef-name := IDENTIFIER
-typedef-name := simple-template-id
-namespace-name := IDENTIFIER
-namespace-name := namespace-alias
-namespace-alias := IDENTIFIER
-class-name := IDENTIFIER
-class-name := simple-template-id
-enum-name := IDENTIFIER
-template-name := IDENTIFIER
+typedef-name := IDENTIFIER [guard]
+typedef-name := simple-template-id [guard]
+namespace-name := IDENTIFIER [guard]
+namespace-name := namespace-alias [guard]
+namespace-alias := IDENTIFIER [guard]
+class-name := IDENTIFIER [guard]
+class-name := simple-template-id [guard]
+enum-name := IDENTIFIER [guard]
+template-name := IDENTIFIER [guard]
 
 # gram.basic
 #! Custom modifications to eliminate optional declaration-seq
@@ -58,7 +58,7 @@
 primary-expression := lambda-expression
 primary-expression := fold-expression
 primary-expression := requires-expression
-id-expression := unqualified-id
+id-expression := unqualified-id [guard]
 id-expression := qualified-id
 unqualified-id := IDENTIFIER
 unqualified-id := operator-function-id
Index: clang-tools-extra/pseudo/lib/cxx/CXX.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -13,6 +13,7 @@
 #include "clang-pseudo/grammar/LRTable.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/TokenKinds.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Debug.h"
 #include 
@@ -109,6 +110,48 @@
   assert(RHS.size() == 1 && RHS.front()->symbol() == Kind);
   return *RHS.front();
 }
+enum IDKind : unsigned {
+   // Type
+   Class = 1 << 0,
+   Enum = 1 << 1,
+   Typedef = 1 << 2,
+
+   Namespace = 1 << 3,
+   NamespaceAlias = 1 << 4,
+
+   Function = 1 << 5,
+
+   Template = 1 << 6,
+   TemplateFunction = Template | Function,
+   TemplateClass = Template | Class,
+   TemplateTypedef = Template | Typedef,
+};
+inline IDKind operator|(IDKind L, IDKind R) {
+  return static_cast(static_cast(L) |
+  static_cast(R));
+}
+inline IDKind operator&(IDKind A, IDKind B) {
+  return static_cast(static_cast(A) & static_cast(B));
+}
+
+llvm::StringMap *IDTable = []() {
+  auto *Results = new llvm::StringMap({
+  {"dyn_cast", IDKind::Function | IDKind::Template},
+
+  });
+  for (auto Namespace : {"llvm", "trace", "clangd", "clang", "std"})
+Results->insert({Namespace, IDKind::Namespace});
+  for (auto Class :
+   {"SourceManager", "ReferenceLoc", "NamedDecl", "NamespaceDecl",
+"NamedDecl", "ASTSignals", "ParsedAST", "ASTSignals", "Span",
+"SymbolID", "string", "NamespaceDecl"})
+Results->insert({Class, IDKind::Class});
+  for (auto Expression : {"isInsideMainFile", "findExplicitReferences",
+  "getSymbolID", "printNamespaceScope"})
+Results->insert({Expression, IDKind::Function});
+
+  return Results;
+}();
 
 bool isFunctionDeclarator(const ForestNode *Declarator) {
   assert(Declarator->symbol() == (SymbolID)(cxx::Symbol::declarator));
@@ -266,6 +309,27 @@
 }
 
 llvm::DenseMap buildGuards() {
+#define HAS_BIT(value) \
+  [](const GuardParams &P) -> bool {   \
+const auto &T = P.Tokens.tokens()[P.RHS.front()->startTokenIndex()];   \
+if (T.Kind != tok::identifier) \
+  return true; \
+auto It = IDTable->find(T.text()); \
+if (It == IDTable->end())  \
+  return true; \
+return (value)&It->second; \
+  }
+#define EXACT_BIT(value)

[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-07-27 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne added inline comments.



Comment at: clang/CMakeLists.txt:100
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
-  set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
   if(WIN32 OR CYGWIN)

Just to check if your intention aligns with my understanding, removing the 
suffix here is fine because the destination is in the binary dir and not the 
final install destination?



Comment at: clang/runtime/CMakeLists.txt:90-92
+  -DCMAKE_INSTALL_BINDIR="${CMAKE_INSTALL_BINDIR}"
+  -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+  
-DCMAKE_INSTALL_INCLUDEDIR="${CMAKE_INSTALL_INCLUDEDIR}"

nit: The indentation is wrong



Comment at: compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake:65
   set(output_dir "${LLVM_LIBRARY_OUTPUT_INTDIR}")
-  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib")
 else()

This is an install directory, so should this be something like
```
extend_path(install_dir "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}")
```
instead?



Comment at: compiler-rt/cmake/base-config-ix.cmake:48
   set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
-  set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
+  set(COMPILER_RT_INSTALL_PATH lib/clang/${CLANG_VERSION})
   option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."

This is an install path, so should it use 
`${CMAKE_INSTALL_LIBDIR}/clang/${CLANG_VERSION}` instead?



Comment at: compiler-rt/cmake/base-config-ix.cmake:103
 ${COMPILER_RT_OUTPUT_DIR}/lib)
-  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib)
+  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" 
"${CMAKE_INSTALL_LIBDIR}")
   set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH

What is the result we expect here?
In case that CMAKE_INSTALL_LIBDIR is defined as lib64, this path will change.

In some cases it would have been `lib64/clang/14.0.0/lib`,
but with this patch it would be `lib/clang/14.0.0/lib64` if I understand 
correctly.



Comment at: lldb/source/API/CMakeLists.txt:116
 if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX 
AND NOT APPLE)
-  set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH 
"\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
+  set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH 
"\$ORIGIN/../../../../lib")
 endif()

It looks to me like this path is used for installation, so should it have the 
(potential) suffix?
In AddLLVM.cmake, _install_rpath uses `${CMAKE_INSTALL_LIBDIR}`.



Comment at: mlir/cmake/modules/AddMLIRPython.cmake:412
 set_property(TARGET ${target} APPEND PROPERTY
-  INSTALL_RPATH 
"${_origin_prefix}/${ARG_RELATIVE_INSTALL_ROOT}/lib${LLVM_LIBDIR_SUFFIX}")
+  INSTALL_RPATH "${_origin_prefix}/${ARG_RELATIVE_INSTALL_ROOT}/lib")
   endif()

Same here as above, the rpath should probably use `${CMAKE_INSTALL_LIBDIR}`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

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


[PATCH] D130630: [clang-tidy] Add readability-nested-ifs check

2022-07-27 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Add a check to detect nested if statements which can be combined into one by 
ANDing the conditions.
This reduces indentation making code easier to read.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130630

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/NestedIfsCheck.cpp
  clang-tools-extra/clang-tidy/readability/NestedIfsCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/nested-ifs.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s readability-nested-ifs %t
+
+void foo();
+void bar();
+
+bool cond(int X = 0);
+
+void good() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (cond()) {
+if (cond(1)) {
+  foo();
+  bar();
+}
+  } // End
+  //  CHECK-FIXES: if (cond() && cond(1))
+  // CHECK-FIXES-NEXT: {
+  // CHECK-FIXES-NEXT:   foo();
+  // CHECK-FIXES-NEXT:   bar();
+  // CHECK-FIXES-NEXT: }
+  // CHECK-FIXES-NEXT: // End
+
+  // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: Nested ifs can be combined
+  // CHECK-MESSAGES: :[[@LINE+4]]:7: warning: Nested ifs can be combined
+  if (cond()) {
+if (cond(1)) {
+  foo();
+  if (cond(2)) {
+if (cond(3)) {
+  bar();
+}
+  }
+}
+  } // End
+
+  //  CHECK-FIXES:  if (cond() && cond(1))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  foo();
+  // CHECK-FIXES-NEXT:  if (cond(2) && cond(3))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  bar();
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT: {{ }}
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT:  // End
+
+  // CHECK-MESSAGES: :[[@LINE+2]]:5: warning: Nested ifs can be combined
+  if (bool B = cond()) {
+if (cond(1)) {
+  if (cond(2)) {
+foo();
+  }
+}
+  } // End
+
+  //  CHECK-FIXES:  if (bool B = cond()) {
+  // CHECK-FIXES-NEXT:if (cond(1) && cond(2))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  foo();
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT:  } // End
+}
+
+void bad() {
+  // Condition variable on either nesting can't be converted.
+  if (bool B = cond())
+if (cond())
+  foo();
+  if (cond()) {
+if (bool B = cond())
+  bar();
+  }
+
+  // Can only have a single if statement as the body of the outer if.
+  if (cond()) {
+foo();
+if (cond())
+  bar();
+  }
+  if (cond()) {
+if (cond())
+  foo();
+bar();
+  }
+
+  // Can't have an else statement on either if.
+  if (cond()) {
+if (cond())
+  foo();
+else
+  bar();
+  }
+
+  if (cond()) {
+if (cond())
+  foo();
+  } else {
+bar();
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s readability-nested-ifs %t
+
+// Ensure the check handles if initializers and constexpr if statements
+// correctly.
+
+void foo();
+void bar();
+
+bool cond(int X = 0);
+
+void good() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (bool X = cond(); X) {
+if (cond()) {
+  if (cond(1))
+bar();
+}
+  } // End
+  // CHECK-FIXES: if (bool X = cond(); X && cond() && cond(1))
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT: {{  }}
+  // CHECK-FIXES-NEXT: bar();
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT: // End
+
+  // The initializer doesn't have to be a variable declaration.
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (foo(); true) {
+if (cond())
+  bar();
+  }
+}
+
+void bad() {
+  // Only the outermost `if` statement can have an initializer.
+  if (bool X = cond(); X) {
+if (bool Y = cond(1); Y) {
+  bar();
+}
+  }
+
+  if (cond()) {
+if (bool X = cond(1); X) {
+  bar();
+}
+  }
+}
+
+template  void constexprIfs() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3

[PATCH] D122255: Meta directive runtime support

2022-07-27 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo marked 4 inline comments as done.
abidmalikwaterloo added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:3144
+for (const OMPTraitSelector &Selector : Set.Selectors) {
+  if (Selector.Kind == llvm::omp::TraitSelector::user_condition &&
+  Selector.ScoreOrCondition)

If it is not the user's condition or score then what will happen?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:7439
+  }
+}
+

abidmalikwaterloo wrote:
> jdoerfert wrote:
> > Why does this perform partial trait matching? We should have code for this. 
> > Also, the logic for device_arch and vendor (which is most what there is), 
> > is not what we want. Reuse the existing matching logic instead.
> Ok. What do you mean by `existing matching logic`? 
@jdoerfert I agree that the implementation is incomplete in terms of trait 
matching. It can be completed. However, I am not clear about your comments 
about the `existing matching logic`.  I checked OMPContext.CPP and other files. 
There are functions that can be used to match the traits. But, I could not find 
any existing logic that can be used here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 448016.
quinnp marked 5 inline comments as done.
quinnp added a comment.

Addressing review comments: fixing test cases and improving test case clarity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/function-sections.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll

Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:   g O .bss.var [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .bss [[#%x,]] var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK-NOT:   g O .data (csect: .data) [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .data (csect: .data) [[#%x,]] var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
Index: clang/test/Driver/function-sections.c
===
--- clang/test/Driver/function-sections.c
+++ clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -72,3 +78,18 @@
 // RUN: --target=i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
+
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=

[PATCH] D130470: [clang][analyzer] Add more wide-character functions to CStringChecker

2022-07-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

A related question:
Is it better to have a more generic function like this:

  void CStringChecker::evalMemmove(CheckerContext &C, const CallExpr *CE,
   bool IsRestricted, bool IsMempcpy, bool 
IsWide) const {
// void *memmove(void *dst, const void *src, size_t n);
// The return value is the address of the destination buffer.
DestinationArgExpr Dest = {CE->getArg(0), 0};
SourceArgExpr Src = {CE->getArg(1), 1};
SizeArgExpr Size = {CE->getArg(2), 2};
  
evalCopyCommon(C, CE, C.getState(), Size, Dest, Src, IsRestricted, 
IsMempcpy,
   IsWide);
  }

(Instead of `bool` enums can be used.) Or make additional versions of the eval 
functions and remove the `IsWide` argument (this is even more code repetition)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130470

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


[clang] 3e874bc - ClangLinkerWrapper: explicitly #include

2022-07-27 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2022-07-27T14:57:34+02:00
New Revision: 3e874bcf064283a5f00e2bef3a086057265563cb

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

LOG: ClangLinkerWrapper: explicitly #include 

This code relied on implicitly having std::atomic available via the
ManagedStatic.h header.

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

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 44b55c6a45e15..ff0f3665014af 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -51,6 +51,7 @@
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::opt;



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


[clang] 5a78ac2 - clang: include ManagedStatic.h for llvm_shutdown

2022-07-27 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2022-07-27T14:57:34+02:00
New Revision: 5a78ac21569abe2e419b201ca196b21fc3bb00aa

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

LOG: clang: include ManagedStatic.h for llvm_shutdown

The code relied on ManagedStatic.h being included indirectly. This is
about to change as uses of ManagedStatic are removed throughout the
codebase.

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

Added: 


Modified: 
clang/unittests/Interpreter/InterpreterTest.cpp
clang/utils/TableGen/TableGen.cpp

Removed: 




diff  --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 494926f7c116d..745e36071936a 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -20,6 +20,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
 #include "gmock/gmock.h"

diff  --git a/clang/utils/TableGen/TableGen.cpp 
b/clang/utils/TableGen/TableGen.cpp
index d18a31226e80d..6864ba2040ef9 100644
--- a/clang/utils/TableGen/TableGen.cpp
+++ b/clang/utils/TableGen/TableGen.cpp
@@ -13,6 +13,7 @@
 #include "TableGenBackends.h" // Declares all backends.
 #include "ASTTableGen.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"



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


[PATCH] D130574: ClangLinkerWrapper: explicitly #include

2022-07-27 Thread Nicolai Hähnle 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 rG3e874bcf0642: ClangLinkerWrapper: explicitly #include 
 (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130574

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -51,6 +51,7 @@
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::opt;


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -51,6 +51,7 @@
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::opt;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7132bcd - ManagedStatic: remove from ASTMatchersInternal.h

2022-07-27 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2022-07-27T14:57:34+02:00
New Revision: 7132bcdc428d79258901af0156ace240952b6745

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

LOG: ManagedStatic: remove from ASTMatchersInternal.h

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 49de9a458c3db..6ee82321723e4 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -59,7 +59,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -1931,8 +1930,8 @@ template  class 
MemoizedMatcher {
 
 public:
   static const Matcher &getInstance() {
-static llvm::ManagedStatic Instance;
-return Instance->M;
+static Wrapper Instance;
+return Instance.M;
   }
 };
 

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 4c438f9e4879f..f3c9f6d468f5c 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -28,7 +28,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"



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


[PATCH] D130575: clang: include ManagedStatic.h for llvm_shutdown

2022-07-27 Thread Nicolai Hähnle 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 rG5a78ac21569a: clang: include ManagedStatic.h for 
llvm_shutdown (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130575

Files:
  clang/unittests/Interpreter/InterpreterTest.cpp
  clang/utils/TableGen/TableGen.cpp


Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -13,6 +13,7 @@
 #include "TableGenBackends.h" // Declares all backends.
 #include "ASTTableGen.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"
Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -20,6 +20,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
 #include "gmock/gmock.h"


Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -13,6 +13,7 @@
 #include "TableGenBackends.h" // Declares all backends.
 #include "ASTTableGen.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/TableGen/Error.h"
Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -20,6 +20,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
 #include "gmock/gmock.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130576: ManagedStatic: remove from ASTMatchersInternal.h

2022-07-27 Thread Nicolai Hähnle 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 rG7132bcdc428d: ManagedStatic: remove from 
ASTMatchersInternal.h (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130576

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp


Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -28,7 +28,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -59,7 +59,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -1931,8 +1930,8 @@
 
 public:
   static const Matcher &getInstance() {
-static llvm::ManagedStatic Instance;
-return Instance->M;
+static Wrapper Instance;
+return Instance.M;
   }
 };
 


Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -28,7 +28,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -59,7 +59,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/Casting.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -1931,8 +1930,8 @@
 
 public:
   static const Matcher &getInstance() {
-static llvm::ManagedStatic Instance;
-return Instance->M;
+static Wrapper Instance;
+return Instance.M;
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130600: [clang][dataflow] Handle return statements

2022-07-27 Thread Sam Estep via Phabricator via cfe-commits
samestep added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:338-339
+if (Loc == nullptr) {
+  // The outermost context does not set a storage location for `return`, so
+  // in that case we just ignore `return` statements.
+  return;

sgatev wrote:
> Let's make this a FIXME to set a storage location for the outermost context 
> too.
@sgatev I could add a `FIXME` for that, or I could just do it in this same 
patch; do you have a preference between those two options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130600

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


[PATCH] D130270: [clang][dataflow] Use a dedicated bool to encode which branch was taken

2022-07-27 Thread Sam Estep via Phabricator via cfe-commits
samestep updated this revision to Diff 448026.
samestep added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130270

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -1175,4 +1175,33 @@
   });
 }
 
+TEST_F(FlowConditionTest, JoinBackedge) {
+  std::string Code = R"(
+void target(bool Cond) {
+  bool Foo = true;
+  while (true) {
+(void)0;
+// [[p]]
+Foo = false;
+  }
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment &Env = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None));
+
+EXPECT_FALSE(Env.flowConditionImplies(FooVal));
+EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal)));
+  });
+}
+
 } // namespace
Index: clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -179,7 +179,8 @@
   Context.addFlowConditionConstraint(FC2, C2);
   Context.addFlowConditionConstraint(FC2, C3);
 
-  auto &FC3 = Context.joinFlowConditions(FC1, FC2);
+  auto &B = Context.createAtomicBoolValue();
+  auto &FC3 = Context.joinFlowConditions(FC1, FC2, B);
   EXPECT_FALSE(Context.flowConditionImplies(FC3, C1));
   EXPECT_FALSE(Context.flowConditionImplies(FC3, C2));
   EXPECT_TRUE(Context.flowConditionImplies(FC3, C3));
@@ -500,23 +501,27 @@
   // FC2 = Y
   auto &FC2 = Context.makeFlowConditionToken();
   Context.addFlowConditionConstraint(FC2, Y);
-  // JoinedFC = (FC1 || FC2) && Z = (X || Y) && Z
-  auto &JoinedFC = Context.joinFlowConditions(FC1, FC2);
+  // JoinedFC = ((!B && FC1) || (B && FC2)) && Z = ((!B && X) || (B && Y)) && Z
+  auto &B = Context.createAtomicBoolValue();
+  auto &JoinedFC = Context.joinFlowConditions(FC1, FC2, B);
   Context.addFlowConditionConstraint(JoinedFC, Z);
 
-  // If any of X, Y is true, JoinedFC is equivalent to Z
-  auto &JoinedFCWithXTrue =
-  Context.buildAndSubstituteFlowCondition(JoinedFC, {{&X, &True}});
-  auto &JoinedFCWithYTrue =
-  Context.buildAndSubstituteFlowCondition(JoinedFC, {{&Y, &True}});
+  // If any of (!B && X), (B && Y) is true, JoinedFC is equivalent to Z
+  auto &JoinedFCWithXTrue = Context.buildAndSubstituteFlowCondition(
+  JoinedFC, {{&B, &False}, {&X, &True}});
+  auto &JoinedFCWithYTrue = Context.buildAndSubstituteFlowCondition(
+  JoinedFC, {{&B, &True}, {&Y, &True}});
   EXPECT_TRUE(Context.equivalentBoolValues(JoinedFCWithXTrue, Z));
   EXPECT_TRUE(Context.equivalentBoolValues(JoinedFCWithYTrue, Z));
 
-  // If Z is true, JoinedFC is equivalent to (X || Y)
+  // If Z is true, JoinedFC is equivalent to ((!B && X) || (B && Y))
   auto &JoinedFCWithZTrue =
   Context.buildAndSubstituteFlowCondition(JoinedFC, {{&Z, &True}});
   EXPECT_TRUE(Context.equivalentBoolValues(
-  JoinedFCWithZTrue, Context.getOrCreateDisjunction(X, Y)));
+  JoinedFCWithZTrue,
+  Context.getOrCreateDisjunction(
+  Context.getOrCreateConjunction(Context.getOrCreateNegation(B), X),
+  Context.getOrCreateConjunction(B, Y;
 
   // If any of X, Y is false, JoinedFC is equivalent to the conjunction of the
   // other value and Z
@@ -525,9 +530,13 @@
   auto &JoinedFCWithYFalse =
   Context.buildAndSubstituteFlowCondition(JoinedFC, {{&Y, &False}});
   EXPECT_TRUE(Context.equivalentBoolValues(
-  JoinedFCWithXFalse, Context.getOrCreateConjunction(Y, Z)));
+  JoinedFCWithXFalse,
+  Context.getOrCreateConjunction(Context.getOrCreateConjunction(B, Y), Z)));
   EXPECT_TRUE(Context.equivalentBoolValues(
-  JoinedFCWithYFalse, Context.getOrCreateConjunction(X, Z)));
+  JoinedFCWithYFalse,
+  Context.getOrCreateConjunction(
+  Context.getOrCreateConjunction(Context.getOrCreateNegation(B), X),
+  Z)));
 
   // If Z is false, JoinedFC is false
   auto &JoinedFCWithZFals

[PATCH] D130270: [clang][dataflow] Use a dedicated bool to encode which branch was taken

2022-07-27 Thread Sam Estep via Phabricator via cfe-commits
samestep added a comment.

@gribozavr2 I rebased again, should work now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130270

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, with some minor nits. Also, please be sure to add a release note.

@erichkeane -- should we update the cxx_dr_status.html page for this? We 
currently claim Clang 12 for this DR, but it seems like Clang 16 (or 15 if we 
cherry-pick this) will be the actual release we finished the DR in.




Comment at: clang/include/clang/Basic/DiagnosticASTKinds.td:370
+def note_constexpr_unscoped_enum_out_of_range : Note<
+  "integer value %0 is outside the valid range of values [%1, %2) for this 
enumeration type">;
 def err_experimental_clang_interp_failed : Error<

You should make sure this is flowed to the 80-col limit.



Comment at: clang/lib/AST/ExprConstant.cpp:13526-13531
+  // This corressponds to [expr.static.cast]p10 which says:
+  // A value of integral or enumeration type can be explicitly converted
+  // to a complete enumeration type ... If the enumeration type does not
+  // have a fixed underlying type, the value is unchanged if the original
+  // value is within the range of the enumeration values ([dcl.enum]), and
+  // otherwise, the behavior is undefined.




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

https://reviews.llvm.org/D130058

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Mostly Ok with this.  The diagnostic seems a little subtle with the 
mathematical notation... just looking at the diagnostics I was like, "wait, why 
is 8 NOT included in the range -8, 8 oh wait".  This will be a little 
shocking to others perhaps?

Also, misisng any tests for the E3, I'd like to see the range for that too.




Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

Are we ok with how subtle the `[N, M)` syntax is here?



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2427
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[0, 8) for this enumeration type}}
+
+  constexpr E4 x6 = static_cast(0);

I see no tests for E3? 


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

https://reviews.llvm.org/D130058

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D130058#3682192 , @aaron.ballman 
wrote:

> LGTM, with some minor nits. Also, please be sure to add a release note.
>
> @erichkeane -- should we update the cxx_dr_status.html page for this? We 
> currently claim Clang 12 for this DR, but it seems like Clang 16 (or 15 if we 
> cherry-pick this) will be the actual release we finished the DR in.

Yeah, I suspect we should update the dr-status.


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

https://reviews.llvm.org/D130058

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham 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 rGf565444b486d: [libLTO] Set data-sections by default in 
libLTO. (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/function-sections.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll

Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:   g O .bss.var [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .bss [[#%x,]] var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK-NOT:   g O .data (csect: .data) [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .data (csect: .data) [[#%x,]] var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
Index: clang/test/Driver/function-sections.c
===
--- clang/test/Driver/function-sections.c
+++ clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -72,3 +78,18 @@
 // RUN: --target=i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
+
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-li

[clang] f565444 - [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2022-07-27T08:34:40-05:00
New Revision: f565444b486d49f84297c3a279ca24d785961ea8

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

LOG: [libLTO] Set data-sections by default in libLTO.

This patch changes legacy LTO to set data-sections by default. The user can
explicitly unset data-sections. The reason for this patch is to match the
behaviour of lld and gold plugin. Both lld and gold plugin have data-sections on
by default.

This patch also fixes the forwarding of the clang options -fno-data-sections and
-fno-function-sections to libLTO. Now, when -fno-data/function-sections are
specified in clang, -data/function-sections=0 will be passed to libLTO to
explicitly unset data/function-sections.

Reviewed By: w2yehia, MaskRay

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

Added: 
llvm/test/LTO/PowerPC/data-sections-aix.ll
llvm/test/LTO/PowerPC/data-sections-linux.ll

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/function-sections.c
llvm/lib/LTO/LTOCodeGenerator.cpp

Removed: 
clang/test/Driver/gold-lto-sections.c



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1d2c085d683e1..05afa712a809c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -567,14 +567,16 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
-   options::OPT_fno_function_sections, UseSeparateSections)) {
-CmdArgs.push_back("-plugin-opt=-function-sections");
-  }
+   options::OPT_fno_function_sections, UseSeparateSections))
+CmdArgs.push_back("-plugin-opt=-function-sections=1");
+  else if (Args.hasArg(options::OPT_fno_function_sections))
+CmdArgs.push_back("-plugin-opt=-function-sections=0");
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
-   UseSeparateSections)) {
-CmdArgs.push_back("-plugin-opt=-data-sections");
-  }
+   UseSeparateSections))
+CmdArgs.push_back("-plugin-opt=-data-sections=1");
+  else if (Args.hasArg(options::OPT_fno_data_sections))
+CmdArgs.push_back("-plugin-opt=-data-sections=0");
 
   // Pass an option to enable split machine functions.
   if (auto *A = Args.getLastArg(options::OPT_fsplit_machine_functions,

diff  --git a/clang/test/Driver/function-sections.c 
b/clang/test/Driver/function-sections.c
index bfb6cc6920bd4..4d206ad150291 100644
--- a/clang/test/Driver/function-sections.c
+++ b/clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -72,3 +78,18 @@
 // RUN: --target=i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
+
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-DEFAULT %s
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN: -ffunction-sections -fdata-sections \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-SECTIONS %s
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN: -fno-function-sections -fno-data-sections \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-NO-SECTIONS %s

diff  --git a/clang/test/Driver/gold-lto-sections.c 
b/clang/test/Driver/gold-lto-sections.c
deleted file mode 100644
index 83d72cf7f97b8..0
--- a/clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"

diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp 
b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 2f7c485b9fc8f..8c374e0f2f858 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/ll

[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

erichkeane wrote:
> Are we ok with how subtle the `[N, M)` syntax is here?
FWIW, I pulled this from diagnostics like: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
 and 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541


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

https://reviews.llvm.org/D130058

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

aaron.ballman wrote:
> erichkeane wrote:
> > Are we ok with how subtle the `[N, M)` syntax is here?
> FWIW, I pulled this from diagnostics like: 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
>  and 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
Those aren't particularly high quality diagnostics, the first is for builtin 
ranges (and builtins have notoriously bad diagnostics), the 2nd is for the 
matrix type, which is only slightly better.

That said, if you are ok with it, I'm ok, just somewhat afraid it'll be a touch 
confusing.


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

https://reviews.llvm.org/D130058

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


[clang] cd62604 - Revert "ManagedStatic: remove from ASTMatchersInternal.h"

2022-07-27 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2022-07-27T15:46:21+02:00
New Revision: cd62604d19aea56d79a919e799d899b0636bd6b4

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

LOG: Revert "ManagedStatic: remove from ASTMatchersInternal.h"

This reverts commit 7132bcdc428d79258901af0156ace240952b6745.

It is the likely cause of a clang-tools-extra test regression. Reverting
until I can investigate what's going on.

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 6ee82321723e4..49de9a458c3db 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -59,6 +59,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 
@@ -1930,8 +1931,8 @@ template  class 
MemoizedMatcher {
 
 public:
   static const Matcher &getInstance() {
-static Wrapper Instance;
-return Instance.M;
+static llvm::ManagedStatic Instance;
+return Instance->M;
   }
 };
 

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index f3c9f6d468f5c..4c438f9e4879f 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"



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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > Are we ok with how subtle the `[N, M)` syntax is here?
> > FWIW, I pulled this from diagnostics like: 
> > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> >  and 
> > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> Those aren't particularly high quality diagnostics, the first is for builtin 
> ranges (and builtins have notoriously bad diagnostics), the 2nd is for the 
> matrix type, which is only slightly better.
> 
> That said, if you are ok with it, I'm ok, just somewhat afraid it'll be a 
> touch confusing.
Yeah, it's not the best diagnostic, to be sure. The trouble is that spelling it 
out makes it worse IMO: `integer value %0 is outside the valid range of values 
%1 (inclusive) and %2 (exclusive) for this enumeration type`


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

https://reviews.llvm.org/D130058

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


[clang] 70ec8cd - Revert "[libLTO] Set data-sections by default in libLTO."

2022-07-27 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2022-07-27T08:47:00-05:00
New Revision: 70ec8cd024f3313962878bf68e89a0687c79ad05

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

LOG: Revert "[libLTO] Set data-sections by default in libLTO."

This reverts commit f565444b486d49f84297c3a279ca24d785961ea8.

Added: 
clang/test/Driver/gold-lto-sections.c

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/function-sections.c
llvm/lib/LTO/LTOCodeGenerator.cpp

Removed: 
llvm/test/LTO/PowerPC/data-sections-aix.ll
llvm/test/LTO/PowerPC/data-sections-linux.ll



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 05afa712a809c..1d2c085d683e1 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -567,16 +567,14 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
-   options::OPT_fno_function_sections, UseSeparateSections))
-CmdArgs.push_back("-plugin-opt=-function-sections=1");
-  else if (Args.hasArg(options::OPT_fno_function_sections))
-CmdArgs.push_back("-plugin-opt=-function-sections=0");
+   options::OPT_fno_function_sections, UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-function-sections");
+  }
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
-   UseSeparateSections))
-CmdArgs.push_back("-plugin-opt=-data-sections=1");
-  else if (Args.hasArg(options::OPT_fno_data_sections))
-CmdArgs.push_back("-plugin-opt=-data-sections=0");
+   UseSeparateSections)) {
+CmdArgs.push_back("-plugin-opt=-data-sections");
+  }
 
   // Pass an option to enable split machine functions.
   if (auto *A = Args.getLastArg(options::OPT_fsplit_machine_functions,

diff  --git a/clang/test/Driver/function-sections.c 
b/clang/test/Driver/function-sections.c
index 4d206ad150291..bfb6cc6920bd4 100644
--- a/clang/test/Driver/function-sections.c
+++ b/clang/test/Driver/function-sections.c
@@ -6,12 +6,6 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
-// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
-// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
-// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
-// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
-// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
-// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -78,18 +72,3 @@
 // RUN: --target=i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
-
-
-// RUN: %clang -### %s -flto 2>&1\
-// RUN: --target=x86_64-unknown-linux \
-// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-DEFAULT %s
-
-// RUN: %clang -### %s -flto 2>&1\
-// RUN: --target=x86_64-unknown-linux \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-SECTIONS %s
-
-// RUN: %clang -### %s -flto 2>&1\
-// RUN: --target=x86_64-unknown-linux \
-// RUN: -fno-function-sections -fno-data-sections \
-// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-NO-SECTIONS %s

diff  --git a/clang/test/Driver/gold-lto-sections.c 
b/clang/test/Driver/gold-lto-sections.c
new file mode 100644
index 0..83d72cf7f97b8
--- /dev/null
+++ b/clang/test/Driver/gold-lto-sections.c
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo -O3 \
+// RUN: -ffunction-sections -fdata-sections \
+// RUN: | FileCheck %s
+// CHECK: "-plugin-opt=-function-sections"
+// CHECK: "-plugin-opt=-data-sections"

diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp 
b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 8c374e0f2f858..2f7c485b9fc8f 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,7 +19,6 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
-#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -345,11 +344,6 @@ bool LTOCodeGenerator::determineTarget() {
   Config.CPU = "cyclone";
   }
 
-  // If data-sections is not explicitly set or unset, set data-sections by
-  // default to

[PATCH] D130630: [clang-tidy] Add readability-nested-ifs check

2022-07-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/nested-ifs.rst:58
+  }
+

Excessive newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130630

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

Still want a test for E3, a release note, and updating the cxx_status.html.  
But those don't need review IMO.




Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > FWIW, I pulled this from diagnostics like: 
> > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > >  and 
> > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > Those aren't particularly high quality diagnostics, the first is for 
> > builtin ranges (and builtins have notoriously bad diagnostics), the 2nd is 
> > for the matrix type, which is only slightly better.
> > 
> > That said, if you are ok with it, I'm ok, just somewhat afraid it'll be a 
> > touch confusing.
> Yeah, it's not the best diagnostic, to be sure. The trouble is that spelling 
> it out makes it worse IMO: `integer value %0 is outside the valid range of 
> values %1 (inclusive) and %2 (exclusive) for this enumeration type`
Ok then, I can't think of anything better really (PERHAPS something that says, 
`integer value %0 is outside of the valid range of values (%1 - %2 inclusive) 
for this enumeration type`, so I'm ok living with it until someone proposes 
better in a followup patch.




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

https://reviews.llvm.org/D130058

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


[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2022-07-27 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam accepted this revision.
saiislam added a comment.

Thanks, LGTM!

In the multi-company OpenMP meeting, it was decided to defer this update.
So, please don't land this patch yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

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


[PATCH] D130470: [clang][analyzer] Add more wide-character functions to CStringChecker

2022-07-27 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: rnkovacs.

In D130470#3682131 , @balazske wrote:

> A related question:
> Is it better to have a more generic function like this:
>
>   void CStringChecker::evalMemmove(CheckerContext &C, const CallExpr *CE,
>bool IsRestricted, bool IsMempcpy, bool 
> IsWide) const {
> // void *memmove(void *dst, const void *src, size_t n);
> // The return value is the address of the destination buffer.
> DestinationArgExpr Dest = {CE->getArg(0), 0};
> SourceArgExpr Src = {CE->getArg(1), 1};
> SizeArgExpr Size = {CE->getArg(2), 2};
>   
> evalCopyCommon(C, CE, C.getState(), Size, Dest, Src, IsRestricted, 
> IsMempcpy,
>IsWide);
>   }
>
> (Instead of `bool` enums can be used.) Or make additional versions of the 
> eval functions and remove the `IsWide` argument (this is even more code 
> repetition)?

I'd strive for the least code repetition. But I consider this just some nice to 
have sugar.

LGTM




Comment at: clang/test/Analysis/wstring.c:372-376
+  // else
+  //   analyzer_assert_unknown(n == 0);
+
+  // We can't do the above comparison because n has already been constrained.
+  // On one path n == 0, on the other n != 0.

This comment is probably outdated (I know it has been copied from `bstring.c` 
but still). Perhaps we should have the `else` branch now not just here but also 
in `bstring.c`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130470

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


[PATCH] D130470: [clang][analyzer] Add more wide-character functions to CStringChecker

2022-07-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1334
+ bool IsWide) const {
   // void *memmove(void *dst, const void *src, size_t n);
   // The return value is the address of the destination buffer.

Do you think we should also update these comments?
It no longer matches to only this function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130470

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 448036.
quinnp added a comment.

Adding lit config to mark tests as unsupported for non PPC targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/function-sections.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll
  llvm/test/LTO/PowerPC/lit.local.cfg

Index: llvm/test/LTO/PowerPC/lit.local.cfg
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'PowerPC' in config.root.targets:
+  config.unsupported = True
Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:   g O .bss.var [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .bss [[#%x,]] var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK-NOT:   g O .data (csect: .data) [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .data (csect: .data) [[#%x,]] var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
Index: clang/test/Driver/function-sections.c
===
--- clang/test/Driver/function-sections.c
+++ clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -72,3 +78,18 @@
 // RUN: --target=i386-unknown-li

[PATCH] D130636: [clangd] Upgrade vlog() to log() for preamble build stats

2022-07-27 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
adamcz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is very useful information for better understanding performance and
preamble builds don't happen that often, so it's not that spammy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130636

Files:
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -552,7 +552,7 @@
   }
 
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,
  PreambleTimer.getTime());
 std::vector Diags = PreambleDiagnostics.take();


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -552,7 +552,7 @@
   }
 
   if (BuiltPreamble) {
-vlog("Built preamble of size {0} for file {1} version {2} in {3} seconds",
+log("Built preamble of size {0} for file {1} version {2} in {3} seconds",
  BuiltPreamble->getSize(), FileName, Inputs.Version,
  PreambleTimer.getTime());
 std::vector Diags = PreambleDiagnostics.take();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b6cc5dd - [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2022-07-27T09:39:39-05:00
New Revision: b6cc5ddc94780074e2a027e5c217a254a1b61b05

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

LOG: [libLTO] Set data-sections by default in libLTO.

This patch changes legacy LTO to set data-sections by default. The user can
explicitly unset data-sections. The reason for this patch is to match the
behaviour of lld and gold plugin. Both lld and gold plugin have data-sections on
by default.

This patch also fixes the forwarding of the clang options -fno-data-sections and
-fno-function-sections to libLTO. Now, when -fno-data/function-sections are
specified in clang, -data/function-sections=0 will be passed to libLTO to
explicitly unset data/function-sections.

Reviewed By: w2yehia, MaskRay

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

Added: 
llvm/test/LTO/PowerPC/data-sections-aix.ll
llvm/test/LTO/PowerPC/data-sections-linux.ll
llvm/test/LTO/PowerPC/lit.local.cfg

Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/function-sections.c
llvm/lib/LTO/LTOCodeGenerator.cpp

Removed: 
clang/test/Driver/gold-lto-sections.c



diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1d2c085d683e1..05afa712a809c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -567,14 +567,16 @@ void tools::addLTOOptions(const ToolChain &ToolChain, 
const ArgList &Args,
   isUseSeparateSections(ToolChain.getEffectiveTriple());
 
   if (Args.hasFlag(options::OPT_ffunction_sections,
-   options::OPT_fno_function_sections, UseSeparateSections)) {
-CmdArgs.push_back("-plugin-opt=-function-sections");
-  }
+   options::OPT_fno_function_sections, UseSeparateSections))
+CmdArgs.push_back("-plugin-opt=-function-sections=1");
+  else if (Args.hasArg(options::OPT_fno_function_sections))
+CmdArgs.push_back("-plugin-opt=-function-sections=0");
 
   if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections,
-   UseSeparateSections)) {
-CmdArgs.push_back("-plugin-opt=-data-sections");
-  }
+   UseSeparateSections))
+CmdArgs.push_back("-plugin-opt=-data-sections=1");
+  else if (Args.hasArg(options::OPT_fno_data_sections))
+CmdArgs.push_back("-plugin-opt=-data-sections=0");
 
   // Pass an option to enable split machine functions.
   if (auto *A = Args.getLastArg(options::OPT_fsplit_machine_functions,

diff  --git a/clang/test/Driver/function-sections.c 
b/clang/test/Driver/function-sections.c
index bfb6cc6920bd4..4d206ad150291 100644
--- a/clang/test/Driver/function-sections.c
+++ b/clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 // RUN: --target=i386-unknown-linux \
@@ -72,3 +78,18 @@
 // RUN: --target=i386-unknown-linux \
 // RUN: -fno-unique-section-names \
 // RUN:   | FileCheck --check-prefix=CHECK-NOUS %s
+
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-DEFAULT %s
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN: -ffunction-sections -fdata-sections \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-SECTIONS %s
+
+// RUN: %clang -### %s -flto 2>&1\
+// RUN: --target=x86_64-unknown-linux \
+// RUN: -fno-function-sections -fno-data-sections \
+// RUN:   | FileCheck --check-prefix=CHECK-PLUGIN-NO-SECTIONS %s

diff  --git a/clang/test/Driver/gold-lto-sections.c 
b/clang/test/Driver/gold-lto-sections.c
deleted file mode 100644
index 83d72cf7f97b8..0
--- a/clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"

diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp 
b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 2f7c485b9fc8f..8c374e0f2f858 100644
--- a/ll

[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-27 Thread Quinn Pham 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 rGb6cc5ddc9478: [libLTO] Set data-sections by default in 
libLTO. (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/function-sections.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll
  llvm/test/LTO/PowerPC/lit.local.cfg

Index: llvm/test/LTO/PowerPC/lit.local.cfg
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/lit.local.cfg
@@ -0,0 +1,2 @@
+if not 'PowerPC' in config.root.targets:
+  config.unsupported = True
Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:   g O .bss.var [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .bss [[#%x,]] var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,20 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK-NOT:   g O .data (csect: .data) [[#%x,]] var
+
+; CHECK-NO-DATA-SECTIONS:  g O .data (csect: .data) [[#%x,]] var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
Index: clang/test/Driver/function-sections.c
===
--- clang/test/Driver/function-sections.c
+++ clang/test/Driver/function-sections.c
@@ -6,6 +6,12 @@
 // CHECK-NODS-NOT: -fdata-sections
 // CHECK-US-NOT: -fno-unique-section-names
 // CHECK-NOUS: -fno-unique-section-names
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-function-sections
+// CHECK-PLUGIN-DEFAULT-NOT: "-plugin-opt=-data-sections
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-function-sections=1"
+// CHECK-PLUGIN-SECTIONS: "-plugin-opt=-data-sections=1"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-function-sections=0"
+// CHECK-PLUGIN-NO-SECTIONS: "-plugin-opt=-data-sections=0"
 
 // RUN: %clang -### %s -fsyntax-only 2>&1   \
 //

[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-07-27 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

Thanks so much @sebastian-ne for the thorough review!

Unlike the other patches rather than being cleaned up code that needs more 
testing, this is closer to the original patch we've been using for a while 
(tested but not cleaned up); sorry there were so many things to catch!




Comment at: clang/CMakeLists.txt:100
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
-  set(LLVM_LIBRARY_OUTPUT_INTDIR 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
   if(WIN32 OR CYGWIN)

sebastian-ne wrote:
> Just to check if your intention aligns with my understanding, removing the 
> suffix here is fine because the destination is in the binary dir and not the 
> final install destination?
Yes exactly.

I really should write up the "rules" that I've (a) discovered from reading (b) 
invented somewhere. Any idea where?



Comment at: clang/runtime/CMakeLists.txt:90-92
+  -DCMAKE_INSTALL_BINDIR="${CMAKE_INSTALL_BINDIR}"
+  -DCMAKE_INSTALL_LIBDIR="${CMAKE_INSTALL_LIBDIR}"
+  
-DCMAKE_INSTALL_INCLUDEDIR="${CMAKE_INSTALL_INCLUDEDIR}"

sebastian-ne wrote:
> nit: The indentation is wrong
Oops, thanks.



Comment at: compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake:65
   set(output_dir "${LLVM_LIBRARY_OUTPUT_INTDIR}")
-  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib")
 else()

sebastian-ne wrote:
> This is an install directory, so should this be something like
> ```
> extend_path(install_dir "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}")
> ```
> instead?
Indeed, thanks for catching!

`${CMAKE_INSTALL_FULL_LIBDIR}` also does this.



Comment at: compiler-rt/cmake/base-config-ix.cmake:48
   set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
-  set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
+  set(COMPILER_RT_INSTALL_PATH lib/clang/${CLANG_VERSION})
   option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."

sebastian-ne wrote:
> This is an install path, so should it use 
> `${CMAKE_INSTALL_LIBDIR}/clang/${CLANG_VERSION}` instead?
Yes. Thanks!



Comment at: compiler-rt/cmake/base-config-ix.cmake:103
 ${COMPILER_RT_OUTPUT_DIR}/lib)
-  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" lib)
+  extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" 
"${CMAKE_INSTALL_LIBDIR}")
   set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH

sebastian-ne wrote:
> What is the result we expect here?
> In case that CMAKE_INSTALL_LIBDIR is defined as lib64, this path will change.
> 
> In some cases it would have been `lib64/clang/14.0.0/lib`,
> but with this patch it would be `lib/clang/14.0.0/lib64` if I understand 
> correctly.
Oh good point, yeah this double `lib` is very tricky I will fix and add comment.



Comment at: lldb/source/API/CMakeLists.txt:116
 if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX 
AND NOT APPLE)
-  set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH 
"\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
+  set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH 
"\$ORIGIN/../../../../lib")
 endif()

sebastian-ne wrote:
> It looks to me like this path is used for installation, so should it have the 
> (potential) suffix?
> In AddLLVM.cmake, _install_rpath uses `${CMAKE_INSTALL_LIBDIR}`.
Yes. I'll do an `extend_path` to handle the absolute path case too.



Comment at: mlir/cmake/modules/AddMLIRPython.cmake:412
 set_property(TARGET ${target} APPEND PROPERTY
-  INSTALL_RPATH 
"${_origin_prefix}/${ARG_RELATIVE_INSTALL_ROOT}/lib${LLVM_LIBDIR_SUFFIX}")
+  INSTALL_RPATH "${_origin_prefix}/${ARG_RELATIVE_INSTALL_ROOT}/lib")
   endif()

sebastian-ne wrote:
> Same here as above, the rpath should probably use `${CMAKE_INSTALL_LIBDIR}`?
Agreed, and same extra comment on the fix as above too,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

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


[PATCH] D130600: [clang][dataflow] Handle return statements

2022-07-27 Thread Sam Estep via Phabricator via cfe-commits
samestep updated this revision to Diff 448044.
samestep added a comment.

Set a storage location for the outermost context too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130600

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3903,7 +3903,10 @@
 TEST(TransferTest, ContextSensitiveSetTrue) {
   std::string Code = R"(
 bool GiveBool();
-void SetBool(bool &Var) { Var = true; }
+void SetBool(bool &Var) {
+  Var = true;
+  return;
+}
 
 void target() {
   bool Foo = GiveBool();
@@ -3933,7 +3936,10 @@
 TEST(TransferTest, ContextSensitiveSetFalse) {
   std::string Code = R"(
 bool GiveBool();
-void SetBool(bool &Var) { Var = false; }
+void SetBool(bool &Var) {
+  Var = false;
+  return;
+}
 
 void target() {
   bool Foo = GiveBool();
@@ -4001,4 +4007,60 @@
/*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
 }
 
+TEST(TransferTest, ContextSensitiveReturnTrue) {
+  std::string Code = R"(
+bool GiveBool() { return true; }
+
+void target() {
+  bool Foo = GiveBool();
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment &Env = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+auto &FooVal =
+*cast(Env.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(Env.flowConditionImplies(FooVal));
+  },
+  {/*.ApplyBuiltinTransfer=*/true,
+   /*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
+}
+
+TEST(TransferTest, ContextSensitiveReturnFalse) {
+  std::string Code = R"(
+bool GiveBool() { return false; }
+
+void target() {
+  bool Foo = GiveBool();
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment &Env = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+auto &FooVal =
+*cast(Env.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal)));
+  },
+  {/*.ApplyBuiltinTransfer=*/true,
+   /*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -332,6 +332,21 @@
   std::make_unique(*ThisPointeeLoc)));
   }
 
+  void VisitReturnStmt(const ReturnStmt *S) {
+auto *Ret = S->getRetValue();
+if (Ret == nullptr)
+  return;
+
+auto *Val = Env.getValue(*Ret, SkipPast::Reference);
+if (Val == nullptr)
+  return;
+
+auto *Loc = Env.getReturnStorageLocation();
+assert(Loc != nullptr);
+// FIXME: Model NRVO.
+Env.setValue(*Loc, *Val);
+  }
+
   void VisitMemberExpr(const MemberExpr *S) {
 ValueDecl *Member = S->getMemberDecl();
 assert(Member != nullptr);
@@ -534,7 +549,11 @@
   auto ExitState = (*BlockToOutputState)[ExitBlock];
   assert(ExitState);
 
-  Env.popCall(ExitState->Env);
+  auto &ExitEnv = ExitState->Env;
+  auto *ReturnLoc = ExitEnv.getReturnStorageLocation();
+  assert(ReturnLoc != nullptr);
+  Env.setStorageLocation(*S, *ReturnLoc);
+  Env.popCall(ExitEnv);
 }
   }
 
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -179,6 +179,10 @@
   if (Value *ParamVal = createValue(ParamDecl->getType()))
 setValue(ParamLoc, *ParamVal);
 }
+
+QualType ReturnType = FuncDecl->g

[PATCH] D130020: [OpenMP] Deprecate the old driver for OpenMP offloading

2022-07-27 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

I noticed that in one of my applications, offload to x86 is not fully working 
with static libraries but directly linking all object files resolves the issue. 
So the new driver doesn't cause regression compared to the old driver which 
doesn't work with static libraries anyway. So we can say good bye to the old 
drivers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130020

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > erichkeane wrote:
> > > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > > FWIW, I pulled this from diagnostics like: 
> > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > > >  and 
> > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > > Those aren't particularly high quality diagnostics, the first is for 
> > > builtin ranges (and builtins have notoriously bad diagnostics), the 2nd 
> > > is for the matrix type, which is only slightly better.
> > > 
> > > That said, if you are ok with it, I'm ok, just somewhat afraid it'll be a 
> > > touch confusing.
> > Yeah, it's not the best diagnostic, to be sure. The trouble is that 
> > spelling it out makes it worse IMO: `integer value %0 is outside the valid 
> > range of values %1 (inclusive) and %2 (exclusive) for this enumeration type`
> Ok then, I can't think of anything better really (PERHAPS something that 
> says, `integer value %0 is outside of the valid range of values (%1 - %2 
> inclusive) for this enumeration type`, so I'm ok living with it until someone 
> proposes better in a followup patch.
> 
> 
I've never cared for the `[` vs `(` notation to indicate inclusivity vs 
exclusivity. All I see are unbalanced tokens and I can never remember which 
brace means what; I have to look it up every time and it isn't an easy search, 
especially for people that aren't already somewhat familiar with the notation; 
you have to know to search for something like "range inclusive exclusive 
notation". I urge use of the more elaborate diagnostic.


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

https://reviews.llvm.org/D130058

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: cjdb.
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

tahonermann wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > aaron.ballman wrote:
> > > > > erichkeane wrote:
> > > > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > > > FWIW, I pulled this from diagnostics like: 
> > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > > > >  and 
> > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > > > Those aren't particularly high quality diagnostics, the first is for 
> > > > builtin ranges (and builtins have notoriously bad diagnostics), the 2nd 
> > > > is for the matrix type, which is only slightly better.
> > > > 
> > > > That said, if you are ok with it, I'm ok, just somewhat afraid it'll be 
> > > > a touch confusing.
> > > Yeah, it's not the best diagnostic, to be sure. The trouble is that 
> > > spelling it out makes it worse IMO: `integer value %0 is outside the 
> > > valid range of values %1 (inclusive) and %2 (exclusive) for this 
> > > enumeration type`
> > Ok then, I can't think of anything better really (PERHAPS something that 
> > says, `integer value %0 is outside of the valid range of values (%1 - %2 
> > inclusive) for this enumeration type`, so I'm ok living with it until 
> > someone proposes better in a followup patch.
> > 
> > 
> I've never cared for the `[` vs `(` notation to indicate inclusivity vs 
> exclusivity. All I see are unbalanced tokens and I can never remember which 
> brace means what; I have to look it up every time and it isn't an easy 
> search, especially for people that aren't already somewhat familiar with the 
> notation; you have to know to search for something like "range inclusive 
> exclusive notation". I urge use of the more elaborate diagnostic.
I'm fine with being more verbose in the diagnostic so long as it doesn't go 
overboard. I don't really like the wording Erich suggested because it can be 
misinterpreted as both values being inclusive. I can hold my nose at what we 
have above. We're inconsistent in how we report this kind of information and it 
seems like someday we should improve this whole class of diagnostics (ones with 
ranges) to have a consistent display to the user. (CC @cjdb for awareness for 
his project, nothing actionable though.)


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

https://reviews.llvm.org/D130058

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


[PATCH] D88299: [clang-format] Add MacroUnexpander.

2022-07-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

A bit surprising such a big change...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88299

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

aaron.ballman wrote:
> tahonermann wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > erichkeane wrote:
> > > > > aaron.ballman wrote:
> > > > > > erichkeane wrote:
> > > > > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > > > > FWIW, I pulled this from diagnostics like: 
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > > > > >  and 
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > > > > Those aren't particularly high quality diagnostics, the first is for 
> > > > > builtin ranges (and builtins have notoriously bad diagnostics), the 
> > > > > 2nd is for the matrix type, which is only slightly better.
> > > > > 
> > > > > That said, if you are ok with it, I'm ok, just somewhat afraid it'll 
> > > > > be a touch confusing.
> > > > Yeah, it's not the best diagnostic, to be sure. The trouble is that 
> > > > spelling it out makes it worse IMO: `integer value %0 is outside the 
> > > > valid range of values %1 (inclusive) and %2 (exclusive) for this 
> > > > enumeration type`
> > > Ok then, I can't think of anything better really (PERHAPS something that 
> > > says, `integer value %0 is outside of the valid range of values (%1 - %2 
> > > inclusive) for this enumeration type`, so I'm ok living with it until 
> > > someone proposes better in a followup patch.
> > > 
> > > 
> > I've never cared for the `[` vs `(` notation to indicate inclusivity vs 
> > exclusivity. All I see are unbalanced tokens and I can never remember which 
> > brace means what; I have to look it up every time and it isn't an easy 
> > search, especially for people that aren't already somewhat familiar with 
> > the notation; you have to know to search for something like "range 
> > inclusive exclusive notation". I urge use of the more elaborate diagnostic.
> I'm fine with being more verbose in the diagnostic so long as it doesn't go 
> overboard. I don't really like the wording Erich suggested because it can be 
> misinterpreted as both values being inclusive. I can hold my nose at what we 
> have above. We're inconsistent in how we report this kind of information and 
> it seems like someday we should improve this whole class of diagnostics (ones 
> with ranges) to have a consistent display to the user. (CC @cjdb for 
> awareness for his project, nothing actionable though.)
My intent WAS for both values to be inclusive!  That is, we'd say `integer 
value -8 is outside the valid range of values(0 - 7 inclusive) for this 
enumeration type`), but the additional logic there is likely a PITA for minor 
improvement.

I'm ALSO ok with holding my nose here, but would welcome a patch to improve 
this diagnostic (and, as Aaron said, ALL range diagnostics!). I, however, am 
not clever enough to come up with it.


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

https://reviews.llvm.org/D130058

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

aaron.ballman wrote:
> tahonermann wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > erichkeane wrote:
> > > > > aaron.ballman wrote:
> > > > > > erichkeane wrote:
> > > > > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > > > > FWIW, I pulled this from diagnostics like: 
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > > > > >  and 
> > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > > > > Those aren't particularly high quality diagnostics, the first is for 
> > > > > builtin ranges (and builtins have notoriously bad diagnostics), the 
> > > > > 2nd is for the matrix type, which is only slightly better.
> > > > > 
> > > > > That said, if you are ok with it, I'm ok, just somewhat afraid it'll 
> > > > > be a touch confusing.
> > > > Yeah, it's not the best diagnostic, to be sure. The trouble is that 
> > > > spelling it out makes it worse IMO: `integer value %0 is outside the 
> > > > valid range of values %1 (inclusive) and %2 (exclusive) for this 
> > > > enumeration type`
> > > Ok then, I can't think of anything better really (PERHAPS something that 
> > > says, `integer value %0 is outside of the valid range of values (%1 - %2 
> > > inclusive) for this enumeration type`, so I'm ok living with it until 
> > > someone proposes better in a followup patch.
> > > 
> > > 
> > I've never cared for the `[` vs `(` notation to indicate inclusivity vs 
> > exclusivity. All I see are unbalanced tokens and I can never remember which 
> > brace means what; I have to look it up every time and it isn't an easy 
> > search, especially for people that aren't already somewhat familiar with 
> > the notation; you have to know to search for something like "range 
> > inclusive exclusive notation". I urge use of the more elaborate diagnostic.
> I'm fine with being more verbose in the diagnostic so long as it doesn't go 
> overboard. I don't really like the wording Erich suggested because it can be 
> misinterpreted as both values being inclusive. I can hold my nose at what we 
> have above. We're inconsistent in how we report this kind of information and 
> it seems like someday we should improve this whole class of diagnostics (ones 
> with ranges) to have a consistent display to the user. (CC @cjdb for 
> awareness for his project, nothing actionable though.)
Maybe `[%1 <= x < %2]`? Feels a bit clumsy, but it disambiguates


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

https://reviews.llvm.org/D130058

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


[PATCH] D130581: [clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"

2022-07-27 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan added a comment.

Hi, this new test is failing on AIX, could you take a look please?
https://lab.llvm.org/buildbot/#/builders/214/builds/2544/steps/6/logs/FAIL__Clang__objc_property_m


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130581

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


[PATCH] D130018: [HLSL] Add HLSLResource attribute

2022-07-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:6473-6475
+The HLSL ``resource`` attribute is not valid to manually specify in
+HLSL. It is applied by the compiler to HLSL resource type objects enabling them
+to be handled appropriately in CodeGen.

aaron.ballman wrote:
> Because the attribute cannot be written by the user, it seems like we 
> shouldn't bother documenting this attribute at all. WDYT? If you agree, you 
> can mark the attribute as `Undocumented` in Attr.td.
Yea... I am kinda split mind on this myself, and I think the tl;dr is that this 
is the wrong place to document this.

The existing HLSL compiler and HLSL language are woefully short on 
documentation, so I'm trying to at least make a best-effort at documenting 
things as I implement them in clang. Since the AttrDocs are really intended to 
be user-facing documentation this is probably the wrong place to document it.

I'll pull this out and maybe separately create a folder under clang's docs 
directory for HLSL-related documentation so that it lives with the more 
project-centric docs. Does that make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130018

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


[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-07-27 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 448053.
Ericson2314 marked an inline comment as done.
Ericson2314 added a comment.

Fix review comments. Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/caches/Android-stage2.cmake
  clang/cmake/caches/Android.cmake
  clang/cmake/modules/AddClang.cmake
  clang/cmake/modules/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  cmake/Modules/GNUInstallPackageDir.cmake
  compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/docs/BuildingCompilerRT.rst
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/cmake/modules/CMakeLists.txt
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/API/CMakeLists.txt
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/tools/intel-features/CMakeLists.txt
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/CMake.rst
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
  llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/cmake/modules/AddMLIRPython.cmake
  mlir/cmake/modules/CMakeLists.txt
  mlir/test/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/README.rst
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  polly/test/CMakeLists.txt
  pstl/CMakeLists.txt
  third-party/benchmark/src/CMakeLists.txt
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -68,7 +68,7 @@
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
 
 /* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR ""
Index: third-party/benchmark/src/CMakeLists.txt
===
--- third-party/benchmark/src/CMakeLists.txt
+++ third-party/benchmark/src/CMakeLists.txt
@@ -79,7 +79,7 @@
 configure_package_config_file (
   ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
   ${project_config}
-  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
   NO_SET_AND_CHECK_MACRO
   NO_CHECK_REQUIRED_COMPONENTS_MACRO
 )
@@ -100,8 +100,8 @@
   install(
 TARGETS ${targets_to_export}
 EXPORT ${targets_export_name}
-ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -88,10 +88,10 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(DIRECTORY include/
 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
 PATTERN "*.in"

[PATCH] D130639: [clang-tidy] Fix readability-redundant-string-c-str fix for overloaded operator->

2022-07-27 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, LegalizeAdulthood.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/56705.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130639

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
@@ -246,3 +246,15 @@
   Foo.func2((Str.c_str()));
 }
 } // namespace PR45286
+
+template
+struct SmartPtr{
+  T* operator->()const;
+  T& operator*()const;
+};
+
+void smartPtrTest(SmartPtr X){
+  f1(X->c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: f1(*X);
+}
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -38,29 +38,6 @@
   return false;
 }
 
-// Format a pointer to an expression: prefix with '*' but simplify
-// when it already begins with '&'.  Return empty string on failure.
-std::string
-formatDereference(const ast_matchers::MatchFinder::MatchResult &Result,
-  const Expr &ExprNode) {
-  if (const auto *Op = dyn_cast(&ExprNode)) {
-if (Op->getOpcode() == UO_AddrOf) {
-  // Strip leading '&'.
-  return std::string(tooling::fixit::getText(
-  *Op->getSubExpr()->IgnoreParens(), *Result.Context));
-}
-  }
-  StringRef Text = tooling::fixit::getText(ExprNode, *Result.Context);
-
-  if (Text.empty())
-return std::string();
-  // Add leading '*'.
-  if (needParensAfterUnaryOperator(ExprNode)) {
-return (llvm::Twine("*(") + Text + ")").str();
-  }
-  return (llvm::Twine("*") + Text).str();
-}
-
 AST_MATCHER(MaterializeTemporaryExpr, isBoundToLValue) {
   return Node.isBoundToLvalueReference();
 }
@@ -180,18 +157,19 @@
   const auto *Call = Result.Nodes.getNodeAs("call");
   const auto *Arg = Result.Nodes.getNodeAs("arg");
   const auto *Member = Result.Nodes.getNodeAs("member");
-  bool Arrow = Member->isArrow();
-  // Replace the "call" node with the "arg" node, prefixed with '*'
-  // if the call was using '->' rather than '.'.
-  std::string ArgText =
-  Arrow ? formatDereference(Result, *Arg)
-: tooling::fixit::getText(*Arg, *Result.Context).str();
-  if (ArgText.empty())
-return;
-
-  diag(Call->getBeginLoc(), "redundant call to %0")
-  << Member->getMemberDecl()
-  << FixItHint::CreateReplacement(Call->getSourceRange(), ArgText);
+
+  auto D = diag(Call->getBeginLoc(), "redundant call to %0")
+   << Member->getMemberDecl()
+   << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  {Member->getOperatorLoc(), Call->getEndLoc()}));
+
+  if (Member->isArrow()) {
+if (needParensAfterUnaryOperator(*Arg))
+  D << FixItHint::CreateInsertion(Arg->getBeginLoc(), "*(")
+<< FixItHint::CreateInsertion(Member->getOperatorLoc(), ")");
+else
+  D << FixItHint::CreateInsertion(Arg->getBeginLoc(), "*");
+  }
 }
 
 } // namespace readability


Index: clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
@@ -246,3 +246,15 @@
   Foo.func2((Str.c_str()));
 }
 } // namespace PR45286
+
+template
+struct SmartPtr{
+  T* operator->()const;
+  T& operator*()const;
+};
+
+void smartPtrTest(SmartPtr X){
+  f1(X->c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: f1(*X);
+}
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -38,29 +38,6 @@
   return false;
 }
 
-// Format a pointer to an expression: prefix with '*' but simplify
-// when it already begins with '&'.  Return empty string on failure.
-std::string
-formatDereference(const ast_matchers::MatchFinder

[PATCH] D130372: [analyzer] Add a new factory function RangeSet::Factory::invert

2022-07-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> The motivation is to extend the set of operations that can be performed on 
> range sets. Specifically, this function is needed for the next patch in the 
> stack.

Would be great to see the motivation clearly and early. What will be the next 
patch about?




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:711
 
+RangeSet RangeSet::Factory::invert(RangeSet What) {
+  assert(!What.isEmpty());

Could you please document this function and its complexity? (O(N) where N is 
the number of elements of the RangeSet.)



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:728-729
+  ContainerType Result;
+  Result.reserve(What.size() + 1 - bool(What.getMinValue() != MIN) -
+ bool(What.getMaxValue() != MAX));
+

There might be a flaw here. Should this be `==` instead of `!=` ?
Consider e.g. when `What` has two elements `[[MIN, -1], [1, MAX]]` then the 
inverse should be `[0,0]` which has size `1`.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734-735
+
+  if (It->From() == MIN)
+goto loop;
+

No `goto` please. There are better alternatives, e.g. you could have two 
different `while` loops for each cases.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:281
+RangeSet Result = F.invert(What);
+EXPECT_EQ(Result, Expected) << "while inverting " << toString(What);
+  }

I think, it would make sense to test the composition of two invert operations 
to identity. 
```
EXPECT_EQ(What, F.invert(F.invert(What));
```
This, of course requires that empty set is a possible input.



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:1101
 
+TYPED_TEST(RangeSetTest, RangeSetInvertTest) {
+  using TV = TestValues;

Good tests!



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:1130
+  // Check inverting single range.
+  this->checkInvert({{MIN, MAX}}, {});
+  this->checkInvert({{MIN, MID}}, {{MID + 1, MAX}});

I'd expect that inversion on finite sets is an invert-able function thus
```
this->checkInvert({}, {MIN, MAX});
```
would make sense instead of assertion.

Besides, it would make sense to test the composition of two invert operations 
to identity. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130372

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


[PATCH] D130055: Clang extensions yolo, woot & kaboom

2022-07-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D130055#3677743 , @dblaikie wrote:

> Any chance this could be a generalization of 
> https://clang.llvm.org/doxygen/Consumed_8cpp_source.html ?

I'm not really familiar with that code, but at glance there seems to be some 
similarities between the cases covered by Consumed and UninitializedValues. I 
built off UninitializedValues mostly just because the existing analysis for 
builtin types seemed consistent with the analysis I needed, so the changes to 
the analysis are pretty minimal.

IIUC from skimming the code, Consumed also does IPC to track usage across call 
boundaries, which is really cool, but I don't know if it fully covers the use 
cases without annotations. For example with a tagged union the default object 
might be initialized to some known state (Uninitialized and zero'd), but the 
semantic state of the object is still "uninitialized".

I can imagine a more general implementation of these annotations to basically 
emulate the states of a state machine. Constructors setting to different 
default states, methods being annotated as to which states they are valid to 
call in, and the compiler tracking values through their possible states... that 
is probably a bit much, and certainly overkill for the problem I'm trying to 
solve.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130055

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


[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-07-27 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 448058.
Ericson2314 added a comment.

Add deprecation notice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/caches/Android-stage2.cmake
  clang/cmake/caches/Android.cmake
  clang/cmake/modules/AddClang.cmake
  clang/cmake/modules/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  cmake/Modules/GNUInstallPackageDir.cmake
  compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/docs/BuildingCompilerRT.rst
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/cmake/modules/CMakeLists.txt
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/API/CMakeLists.txt
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/tools/intel-features/CMakeLists.txt
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/CMake.rst
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
  llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/cmake/modules/AddMLIRPython.cmake
  mlir/cmake/modules/CMakeLists.txt
  mlir/test/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/README.rst
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  polly/test/CMakeLists.txt
  pstl/CMakeLists.txt
  third-party/benchmark/src/CMakeLists.txt
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -68,7 +68,7 @@
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
 
 /* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR ""
Index: third-party/benchmark/src/CMakeLists.txt
===
--- third-party/benchmark/src/CMakeLists.txt
+++ third-party/benchmark/src/CMakeLists.txt
@@ -79,7 +79,7 @@
 configure_package_config_file (
   ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
   ${project_config}
-  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
   NO_SET_AND_CHECK_MACRO
   NO_CHECK_REQUIRED_COMPONENTS_MACRO
 )
@@ -100,8 +100,8 @@
   install(
 TARGETS ${targets_to_export}
 EXPORT ${targets_export_name}
-ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -88,10 +88,10 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(DIRECTORY include/
 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
 PATTERN "*.in" EXCLUDE)
Index: polly/test/CMakeLists.txt
===

[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-07-27 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 marked 6 inline comments as done.
Ericson2314 added inline comments.



Comment at: compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake:65
   set(output_dir "${LLVM_LIBRARY_OUTPUT_INTDIR}")
-  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}")
+  set(install_dir "${CMAKE_INSTALL_PREFIX}/lib")
 else()

Ericson2314 wrote:
> sebastian-ne wrote:
> > This is an install directory, so should this be something like
> > ```
> > extend_path(install_dir "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_LIBDIR}")
> > ```
> > instead?
> Indeed, thanks for catching!
> 
> `${CMAKE_INSTALL_FULL_LIBDIR}` also does this.
Actually, it will do the `CMAKE_INSTALL_PREFIX` part by default (and the other 
branch is already a potentially relative path) so just 
`${CMAKE_INSTALL_LIBDIR}` will suffice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

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


[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-07-27 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman updated this revision to Diff 448060.
Codesbyusman added a comment.

updating the code suggestions and test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130510

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Sema/warn-bitwise-compare.c
  clang/test/SemaCXX/warn-unreachable.cpp

Index: clang/test/SemaCXX/warn-unreachable.cpp
===
--- clang/test/SemaCXX/warn-unreachable.cpp
+++ clang/test/SemaCXX/warn-unreachable.cpp
@@ -399,13 +399,13 @@
   // TODO: Extend warning to the following code:
   if (x < -1)
 calledFun();
-  if (x == -1)
-calledFun();
+  if (x == -1)   // expected-note {{silence}}
+calledFun(); // expected-warning {{will never be executed}}
 
-  if (x != -1)
+  if (x != -1)   // expected-note {{silence}}
 calledFun();
   else
-calledFun();
+calledFun(); // expected-warning {{will never be executed}}
   if (-1 > x)
 calledFun();
   else
Index: clang/test/Sema/warn-bitwise-compare.c
===
--- clang/test/Sema/warn-bitwise-compare.c
+++ clang/test/Sema/warn-bitwise-compare.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-unused %s
 
 #define mydefine 2
+#define mydefine2 -2
 
 enum {
   ZERO,
@@ -11,29 +12,67 @@
 void f(int x) {
   if ((8 & x) == 3) {}  // expected-warning {{bitwise comparison always evaluates to false}}
   if ((x & 8) == 4) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+  if ((-8 & x) == 3) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+  if ((x & -8) == 4) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+
   if ((x & 8) != 4) {}  // expected-warning {{bitwise comparison always evaluates to true}}
   if ((2 & x) != 4) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  if ((x & -8) != 4) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  if ((-2 & x) != 3) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  
   if ((x | 4) == 3) {}  // expected-warning {{bitwise comparison always evaluates to false}}
   if ((x | 3) != 4) {}  // expected-warning {{bitwise comparison always evaluates to true}}
   if ((5 | x) != 3) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  
+  if ((x | -4) == 3) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+  if ((x | -3) != 4) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  if ((-5 | x) != 3) {}  // expected-warning {{bitwise comparison always evaluates to true}}
+  
+
   if ((x & 0x15) == 0x13) {} // expected-warning {{bitwise comparison always evaluates to false}}
+  if ((x & 0xFFEB) == 0x13) {} // expected-warning {{bitwise comparison always evaluates to false}}
+
   if ((0x23 | x) == 0x155){} // expected-warning {{bitwise comparison always evaluates to false}}
+  if ((0xFFDD | x) == 0x155){} // expected-warning {{bitwise comparison always evaluates to false}}
 
   if (!!((8 & x) == 3)) {}  // expected-warning {{bitwise comparison always evaluates to false}}
-  int y = ((8 & x) == 3) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to false}}
+  if (!!((-8 & x) == 3)) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+
+  int y = ((8 & x)  == 3) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to false}}
+  y = ((-8 & x) == 3) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to false}}
+  y = ((3 | x)  != 5) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to true}}
+  y = ((-3 | x) != 5) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to true}}
 
   if ((x & 8) == 8) {}
   if ((x & 8) != 8) {}
   if ((x | 4) == 4) {}
   if ((x | 4) != 4) {}
 
+  if ((-2 & x) != 4) {}
+  if ((x & -8) == -8) {}
+  if ((x & -8) != -8) {}
+  if ((x | -4) == -4) {}
+  if ((x | -4) != -4) {}
+
+
   if ((x & 9) == 8) {}
   if ((x & 9) != 8) {}
   if ((x | 4) == 5) {}
   if ((x | 4) != 5) {}
 
+  if ((x & -9) == -10) {}
+  if ((x & -9) != -10) {}
+  if ((x | -4) == -3) {}
+  if ((x | -4) != -3) {}
+
+  if ((x^0) == 0){}
+
   if ((x & mydefine) == 8) {}
   if ((x | mydefine) == 4) {}
+
+  if ((x & mydefine2) == 8) {}
+  if ((x | mydefine2) == 4) {}
+
 }
 
 void g(int x) {
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -964,43 +964,44 @@
 const Expr *LHSExpr = B->getLHS()->IgnoreParens();
 const Expr *RHSExpr = B->getRHS()->IgnoreParens();
 
-const IntegerLiteral *IntLiteral = dyn_cast(LHSExpr);
-const Expr *BoolExpr = RHSExpr;
+const Expr *BoolExpr = nullptr; // To store the expression.
+Expr::EvalResult Int

[PATCH] D130641: [clang-tidy] Extend redundant-string-c-str to also flag constructing a string_view.

2022-07-27 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, alexfh, LegalizeAdulthood.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
njames93 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130641

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
@@ -48,6 +48,16 @@
 typedef basic_string, 
std::allocator> wstring;
 typedef basic_string, std::allocator> 
u16string;
 typedef basic_string, std::allocator> 
u32string;
+
+template
+struct basic_string_view {
+  basic_string_view(const C*);
+};
+
+typedef basic_string_view> string_view;
+typedef basic_string_view> wstring_voew;
+typedef basic_string_view> u16string_view;
+typedef basic_string_view> u32string_view;
 }
 
 std::string operator+(const std::string&, const std::string&);
@@ -170,6 +180,14 @@
   tmp.insert(1, s.c_str(), 2);
 }
 
+void f7(const std::string_view&) {
+  std::string S;
+  f7(S.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}std::string S;{{$}}
+  // CHECK-FIXES-NEXT: {{^  }}f7(S);{{$}}
+}
+
 // Tests for std::wstring.
 
 void g1(const std::wstring &s) {
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -11,6 +11,8 @@
 
//===--===//
 
 #include "RedundantStringCStrCheck.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/FixIt.h"
 
@@ -65,6 +67,12 @@
   return Node.isBoundToLvalueReference();
 }
 
+AST_MATCHER_P(CXXConstructExpr, forClass,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const CXXRecordDecl *Parent = Node.getConstructor()->getParent();
+  return Parent && InnerMatcher.matches(*Parent, Finder, Builder);
+}
+
 } // end namespace
 
 void RedundantStringCStrCheck::registerMatchers(
@@ -157,22 +165,21 @@
 
   // Detect redundant 'c_str()' calls through a StringRef constructor.
   Finder->addMatcher(
-  traverse(
-  TK_AsIs,
-  cxxConstructExpr(
-  // Implicit constructors of these classes are overloaded
-  // wrt. string types and they internally make a StringRef
-  // referring to the argument.  Passing a string directly to
-  // them is preferred to passing a char pointer.
-  hasDeclaration(cxxMethodDecl(hasAnyName(
-  "::llvm::StringRef::StringRef", "::llvm::Twine::Twine"))),
-  argumentCountIs(1),
-  // The only argument must have the form x.c_str() or p->c_str()
-  // where the method is string::c_str().  StringRef also has
-  // a constructor from string which is more efficient (avoids
-  // strlen), so we can construct StringRef from the string
-  // directly.
-  hasArgument(0, StringCStrCallExpr))),
+  traverse(TK_AsIs,
+   cxxConstructExpr(
+   // Implicit constructors of these classes are overloaded
+   // wrt. string types and they internally make a StringRef
+   // referring to the argument.  Passing a string directly to
+   // them is preferred to passing a char pointer.
+   forClass(hasAnyName("::std::basic_string_view",
+   "::llvm::StringRef", "::llvm::Twine")),
+   argumentCountIs(1),
+   // The only argument must have the form x.c_str() or
+   // p->c_str() where the method is string::c_str().  
StringRef
+   // also has a constructor from string which is more 
efficient
+   // (avoids strlen), so we can construct StringRef from the
+   // string directly.
+   hasArgument(0, StringCStrCallExpr))),
   this);
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-

[PATCH] D130131: [HLSL] CodeGen hlsl cbuffer/tbuffer.

2022-07-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:61
+
+GlobalVariable *replaceCBuffer(CGHLSLRuntime::CBuffer &CB) {
+  const unsigned CBufferAddressSpace = 4;

I don't think I understand the intent of this function along with 
`CGHLSLRuntime::addConstant` that populates this collection.



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:62
+GlobalVariable *replaceCBuffer(CGHLSLRuntime::CBuffer &CB) {
+  const unsigned CBufferAddressSpace = 4;
+  const unsigned TBufferAddressSpace = 5;

It might be better to avoid using hard-coded constants. Are you adding new 
entires in clang's `AddressSpace` enum to represent different logical memory 
segment of the language?



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:142
+  if (!Inner) {
+DiagnosticsEngine &Diags = CGM.getDiags();
+unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,

Is this case covered by the test?



Comment at: clang/lib/CodeGen/CGHLSLRuntime.h:39
+llvm::StringRef Name;
+bool IsCBuffer;
+unsigned Reg;

what does this field represent?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130131

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


[PATCH] D130630: [clang-tidy] Add readability-nested-ifs check

2022-07-27 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 448064.
njames93 marked an inline comment as done.
njames93 added a comment.

Remove Excessive Newline.
Hopefully fix the windows test failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130630

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/NestedIfsCheck.cpp
  clang-tools-extra/clang-tidy/readability/NestedIfsCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/nested-ifs.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs.cpp
@@ -0,0 +1,101 @@
+// RUN: %check_clang_tidy %s readability-nested-ifs %t
+
+void foo();
+void bar();
+
+bool cond(int X = 0);
+
+void good() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (cond()) {
+if (cond(1)) {
+  foo();
+  bar();
+}
+  } // End
+  //  CHECK-FIXES: if (cond() && cond(1))
+  // CHECK-FIXES-NEXT: {
+  // CHECK-FIXES-NEXT:   foo();
+  // CHECK-FIXES-NEXT:   bar();
+  // CHECK-FIXES-NEXT: }
+  // CHECK-FIXES-NEXT: // End
+
+  // CHECK-MESSAGES: :[[@LINE+2]]:3: warning: Nested ifs can be combined
+  // CHECK-MESSAGES: :[[@LINE+4]]:7: warning: Nested ifs can be combined
+  if (cond()) {
+if (cond(1)) {
+  foo();
+  if (cond(2)) {
+if (cond(3)) {
+  bar();
+}
+  }
+}
+  } // End
+
+  //  CHECK-FIXES:  if (cond() && cond(1))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  foo();
+  // CHECK-FIXES-NEXT:  if (cond(2) && cond(3))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  bar();
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT: {{ }}
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT:  // End
+
+  // CHECK-MESSAGES: :[[@LINE+2]]:5: warning: Nested ifs can be combined
+  if (bool B = cond()) {
+if (cond(1)) {
+  if (cond(2)) {
+foo();
+  }
+}
+  } // End
+
+  //  CHECK-FIXES:  if (bool B = cond()) {
+  // CHECK-FIXES-NEXT:if (cond(1) && cond(2))
+  // CHECK-FIXES-NEXT:{
+  // CHECK-FIXES-NEXT:  foo();
+  // CHECK-FIXES-NEXT:}
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT:  } // End
+}
+
+void bad() {
+  // Condition variable on either nesting can't be converted.
+  if (bool B = cond())
+if (cond())
+  foo();
+  if (cond()) {
+if (bool B = cond())
+  bar();
+  }
+
+  // Can only have a single if statement as the body of the outer if.
+  if (cond()) {
+foo();
+if (cond())
+  bar();
+  }
+  if (cond()) {
+if (cond())
+  foo();
+bar();
+  }
+
+  // Can't have an else statement on either if.
+  if (cond()) {
+if (cond())
+  foo();
+else
+  bar();
+  }
+
+  if (cond()) {
+if (cond())
+  foo();
+  } else {
+bar();
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/nested-ifs-cxx17.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s readability-nested-ifs %t -- -- -fno-delayed-template-parsing
+
+// Ensure the check handles if initializers and constexpr if statements
+// correctly.
+
+void foo();
+void bar();
+
+bool cond(int X = 0);
+
+void good() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (bool X = cond(); X) {
+if (cond()) {
+  if (cond(1))
+bar();
+}
+  } // End
+  // CHECK-FIXES: if (bool X = cond(); X && cond() && cond(1))
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT: {{  }}
+  // CHECK-FIXES-NEXT: bar();
+  // CHECK-FIXES-NEXT: {{}}
+  // CHECK-FIXES-NEXT: // End
+
+  // The initializer doesn't have to be a variable declaration.
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if (foo(); true) {
+if (cond())
+  bar();
+  }
+}
+
+void bad() {
+  // Only the outermost `if` statement can have an initializer.
+  if (bool X = cond(); X) {
+if (bool Y = cond(1); Y) {
+  bar();
+}
+  }
+f
+  if (cond()) {
+if (bool X = cond(1); X) {
+  bar();
+}
+  }
+}
+
+template  void constexprIfs() {
+  // CHECK-MESSAGES: :[[@LINE+1]]:3: warning: Nested ifs can be combined
+  if constexpr (B) {
+if constexpr (C) {
+  bar();
+}
+  } // End
+  // CHECK-FIXES: if constexpr (B && C)
+  // C

[PATCH] D130018: [HLSL] Add HLSLResource attribute

2022-07-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:6473-6475
+The HLSL ``resource`` attribute is not valid to manually specify in
+HLSL. It is applied by the compiler to HLSL resource type objects enabling them
+to be handled appropriately in CodeGen.

beanz wrote:
> aaron.ballman wrote:
> > Because the attribute cannot be written by the user, it seems like we 
> > shouldn't bother documenting this attribute at all. WDYT? If you agree, you 
> > can mark the attribute as `Undocumented` in Attr.td.
> Yea... I am kinda split mind on this myself, and I think the tl;dr is that 
> this is the wrong place to document this.
> 
> The existing HLSL compiler and HLSL language are woefully short on 
> documentation, so I'm trying to at least make a best-effort at documenting 
> things as I implement them in clang. Since the AttrDocs are really intended 
> to be user-facing documentation this is probably the wrong place to document 
> it.
> 
> I'll pull this out and maybe separately create a folder under clang's docs 
> directory for HLSL-related documentation so that it lives with the more 
> project-centric docs. Does that make sense?
> I'll pull this out and maybe separately create a folder under clang's docs 
> directory for HLSL-related documentation so that it lives with the more 
> project-centric docs. Does that make sense?

I'm fine with that approach. FWIW, I've struggled with this a bit as well. We 
want all new attributes to be documented, and it's a sometimes super fuzzy line 
between "this is an implementation detail" and "users can use this with wild 
abandon". However, in this case, because the attribute has no spelling, it's 
pretty clearly an implementation detail. So putting that into the "using clang 
as a library" or other internal documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130018

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


[PATCH] D130058: [Clang] Diagnose ill-formed constant expression when setting a non fixed enum to a value outside the range of the enumeration values

2022-07-27 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2420
+  constexpr E1 x2 = static_cast(8); // expected-error {{must be 
initialized by a constant expression}}
+  // expected-note@-1 {{integer value 8 is outside the valid range of values 
[-8, 8) for this enumeration type}}
+

erichkeane wrote:
> royjacobson wrote:
> > aaron.ballman wrote:
> > > tahonermann wrote:
> > > > erichkeane wrote:
> > > > > aaron.ballman wrote:
> > > > > > erichkeane wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > erichkeane wrote:
> > > > > > > > > Are we ok with how subtle the `[N, M)` syntax is here?
> > > > > > > > FWIW, I pulled this from diagnostics like: 
> > > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L9904
> > > > > > > >  and 
> > > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11541
> > > > > > > Those aren't particularly high quality diagnostics, the first is 
> > > > > > > for builtin ranges (and builtins have notoriously bad 
> > > > > > > diagnostics), the 2nd is for the matrix type, which is only 
> > > > > > > slightly better.
> > > > > > > 
> > > > > > > That said, if you are ok with it, I'm ok, just somewhat afraid 
> > > > > > > it'll be a touch confusing.
> > > > > > Yeah, it's not the best diagnostic, to be sure. The trouble is that 
> > > > > > spelling it out makes it worse IMO: `integer value %0 is outside 
> > > > > > the valid range of values %1 (inclusive) and %2 (exclusive) for 
> > > > > > this enumeration type`
> > > > > Ok then, I can't think of anything better really (PERHAPS something 
> > > > > that says, `integer value %0 is outside of the valid range of values 
> > > > > (%1 - %2 inclusive) for this enumeration type`, so I'm ok living with 
> > > > > it until someone proposes better in a followup patch.
> > > > > 
> > > > > 
> > > > I've never cared for the `[` vs `(` notation to indicate inclusivity vs 
> > > > exclusivity. All I see are unbalanced tokens and I can never remember 
> > > > which brace means what; I have to look it up every time and it isn't an 
> > > > easy search, especially for people that aren't already somewhat 
> > > > familiar with the notation; you have to know to search for something 
> > > > like "range inclusive exclusive notation". I urge use of the more 
> > > > elaborate diagnostic.
> > > I'm fine with being more verbose in the diagnostic so long as it doesn't 
> > > go overboard. I don't really like the wording Erich suggested because it 
> > > can be misinterpreted as both values being inclusive. I can hold my nose 
> > > at what we have above. We're inconsistent in how we report this kind of 
> > > information and it seems like someday we should improve this whole class 
> > > of diagnostics (ones with ranges) to have a consistent display to the 
> > > user. (CC @cjdb for awareness for his project, nothing actionable though.)
> > Maybe `[%1 <= x < %2]`? Feels a bit clumsy, but it disambiguates
> My intent WAS for both values to be inclusive!  That is, we'd say `integer 
> value -8 is outside the valid range of values(0 - 7 inclusive) for this 
> enumeration type`), but the additional logic there is likely a PITA for minor 
> improvement.
> 
> I'm ALSO ok with holding my nose here, but would welcome a patch to improve 
> this diagnostic (and, as Aaron said, ALL range diagnostics!). I, however, am 
> not clever enough to come up with it.
While I like `[%1, %2)` (because I nerd out over maths), I think `%1 <= x < %2` 
will be more accessible to folks who haven't taken university calculus or 
discrete maths.

For @tahonermann specifically: a potential mnemonic is that closed intervals 
use a straight line, which intersects an axis, whereas open intervals are 
curved, which represents them being asymptotic.


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

https://reviews.llvm.org/D130058

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


[PATCH] D105255: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-07-27 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 448086.
abidmalikwaterloo added a comment.

Added assembly format
changed the type of mape_type_modifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105255

Files:
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td


Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -625,7 +625,7 @@
  Variadic:$map_type_modifier_operands);

   let regions = (region AnyRegion:$region); 
-   
+  
   let assemblyFormat = [{
 (`if` `(` $if_expr^ `)` )?
 (`device` `(` $device^ `:` type($device) `)` )?


Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -625,7 +625,7 @@
  Variadic:$map_type_modifier_operands);

   let regions = (region AnyRegion:$region); 
-   
+  
   let assemblyFormat = [{
 (`if` `(` $if_expr^ `)` )?
 (`device` `(` $device^ `:` type($device) `)` )?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129884: [clang][deps] Include canonical invocation in ContextHash

2022-07-27 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

In D129884#3677435 , @jansvoboda11 
wrote:

> Would it make sense for this to replace the existing strict context hash 
> implementation?

It's not clear to me whether this would be a good tradeoff or not: the explicit 
build canonicalizes its invocation, but the implicit build does not do so to 
the same extent. Some of that could be improved with some effort, but for 
example the optimizations we use for search path pruning in the explicit build 
cannot be done up-front in the implicit build, since we don't yet know which 
paths are relevant.  I think we should consider this separately.

One necessary difference is that after scanning dependencies we want to hash 
the module dependencies (name + context hash), but we cannot do that in the 
implicit build since the dependencies are not discovered yet. The rest of the 
invocation hashing implementation could be shared though, if we decided it is 
the right approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129884

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


[PATCH] D105255: [MLIR][OpenMP] Added target data, exit data, and enter data operation definition for MLIR.

2022-07-27 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo added a comment.

I just updated the patch. Something went wrong. I used arc `diff --update 
 ` for uploading. However, it seems it is not comparing the last 
submitted patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105255

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


  1   2   >