[PATCH] D156588: feat: Add support for Rocky Linux to LLVM Distro

2023-07-31 Thread xufei via Phabricator via cfe-commits
zkkxu added a comment.

nice ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156588

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


[PATCH] D156648: [Tooling/Inclusion] Add std::range symbols in the mapping.

2023-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156648

Files:
  clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -242,6 +242,11 @@
 (symbol_index_root, "filesystem.html", "std::filesystem::"),
 (symbol_index_root, "pmr.html", "std::pmr::"),
 (symbol_index_root, "ranges.html", "std::ranges::"),
+
+(symbol_index_root, "views.html", "std::ranges::views::"),
+# std::ranges::views can be accessed as std::views.
+(symbol_index_root, "views.html", "std::views::"),
+
 (symbol_index_root, "regex_constants.html", 
"std::regex_constants::"),
 (symbol_index_root, "this_thread.html", "std::this_thread::"),
 # Zombie symbols that were available from the Standard Library, 
but are
Index: clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -3773,6 +3773,33 @@
 SYMBOL(wistream_view, std::ranges::, )
 SYMBOL(zip_transform_view, std::ranges::, )
 SYMBOL(zip_view, std::ranges::, )
+SYMBOL(all, std::ranges::views::, )
+SYMBOL(all_t, std::ranges::views::, )
+SYMBOL(as_const, std::ranges::views::, )
+SYMBOL(as_rvalue, std::ranges::views::, )
+SYMBOL(common, std::ranges::views::, )
+SYMBOL(counted, std::ranges::views::, )
+SYMBOL(drop, std::ranges::views::, )
+SYMBOL(drop_while, std::ranges::views::, )
+SYMBOL(elements, std::ranges::views::, )
+SYMBOL(empty, std::ranges::views::, )
+SYMBOL(filter, std::ranges::views::, )
+SYMBOL(iota, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(join, std::ranges::views::, )
+SYMBOL(join_with, std::ranges::views::, )
+SYMBOL(keys, std::ranges::views::, )
+SYMBOL(lazy_split, std::ranges::views::, )
+SYMBOL(reverse, std::ranges::views::, )
+SYMBOL(single, std::ranges::views::, )
+SYMBOL(split, std::ranges::views::, )
+SYMBOL(take, std::ranges::views::, )
+SYMBOL(take_while, std::ranges::views::, )
+SYMBOL(transform, std::ranges::views::, )
+SYMBOL(values, std::ranges::views::, )
+SYMBOL(zip, std::ranges::views::, )
+SYMBOL(zip_transform, std::ranges::views::, )
 SYMBOL(ECMAScript, std::regex_constants::, )
 SYMBOL(awk, std::regex_constants::, )
 SYMBOL(basic, std::regex_constants::, )
@@ -3817,3 +3844,30 @@
 SYMBOL(sleep_for, std::this_thread::, )
 SYMBOL(sleep_until, std::this_thread::, )
 SYMBOL(yield, std::this_thread::, )
+SYMBOL(all, std::views::, )
+SYMBOL(all_t, std::views::, )
+SYMBOL(as_const, std::views::, )
+SYMBOL(as_rvalue, std::views::, )
+SYMBOL(common, std::views::, )
+SYMBOL(counted, std::views::, )
+SYMBOL(drop, std::views::, )
+SYMBOL(drop_while, std::views::, )
+SYMBOL(elements, std::views::, )
+SYMBOL(empty, std::views::, )
+SYMBOL(filter, std::views::, )
+SYMBOL(iota, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(join, std::views::, )
+SYMBOL(join_with, std::views::, )
+SYMBOL(keys, std::views::, )
+SYMBOL(lazy_split, std::views::, )
+SYMBOL(reverse, std::views::, )
+SYMBOL(single, std::views::, )
+SYMBOL(split, std::views::, )
+SYMBOL(take, std::views::, )
+SYMBOL(take_while, std::views::, )
+SYMBOL(transform, std::views::, )
+SYMBOL(values, std::views::, )
+SYMBOL(zip, std::views::, )
+SYMBOL(zip_transform, std::views::, )


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -242,6 +242,11 @@
 (symbol_index_root, "filesystem.html", "std::filesystem::"),
 (symbol_index_root, "pmr.html", "std::pmr::"),
 (symbol_index_root, "ranges.html", "std::ranges::"),
+
+(symbol_index_root, "views.html", "std::ranges::views::"),
+# std::ranges::views can be accessed as std::views.
+(symbol_index_root, "views.html", "std::views::"),
+
 (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
 (symbol_index_root, "this_thread.html", "std::this_thread::"),
 # Zombie symbols that were available from the Standard Library, but are
Index: clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ clang/lib/Tooling/Inclusion

[clang] f444f39 - [clang][Interp] Implement __builtin_isfinite

2023-07-31 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-31T09:12:32+02:00
New Revision: f444f396863ceba0e0572a721d102fb48e8ca1b3

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

LOG: [clang][Interp] Implement __builtin_isfinite

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

Added: 


Modified: 
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/AST/Interp/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index b5e19af5c37288..6fe9bc7628efef 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -187,6 +187,15 @@ static bool interp__builtin_isinf(InterpState &S, CodePtr 
OpPC,
   return true;
 }
 
+static bool interp__builtin_isfinite(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isFinite()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -263,6 +272,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F) {
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_isfinite:
+if (interp__builtin_isfinite(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }

diff  --git a/clang/test/AST/Interp/builtin-functions.cpp 
b/clang/test/AST/Interp/builtin-functions.cpp
index 7eb3e187d28ead..9457100a15f528 100644
--- a/clang/test/AST/Interp/builtin-functions.cpp
+++ b/clang/test/AST/Interp/builtin-functions.cpp
@@ -76,4 +76,7 @@ namespace fmin {
 namespace inf {
   static_assert(__builtin_isinf(__builtin_inf()), "");
   static_assert(!__builtin_isinf(1.0), "");
+
+  static_assert(__builtin_isfinite(1.0), "");
+  static_assert(!__builtin_isfinite(__builtin_inf()), "");
 }



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


[PATCH] D155372: [clang][Interp] Implement __builtin_isfinite

2023-07-31 Thread Timm Bäder 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 rGf444f396863c: [clang][Interp] Implement __builtin_isfinite 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155372

Files:
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -76,4 +76,7 @@
 namespace inf {
   static_assert(__builtin_isinf(__builtin_inf()), "");
   static_assert(!__builtin_isinf(1.0), "");
+
+  static_assert(__builtin_isfinite(1.0), "");
+  static_assert(!__builtin_isfinite(__builtin_inf()), "");
 }
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -187,6 +187,15 @@
   return true;
 }
 
+static bool interp__builtin_isfinite(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isFinite()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -263,6 +272,11 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_isfinite:
+if (interp__builtin_isfinite(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -76,4 +76,7 @@
 namespace inf {
   static_assert(__builtin_isinf(__builtin_inf()), "");
   static_assert(!__builtin_isinf(1.0), "");
+
+  static_assert(__builtin_isfinite(1.0), "");
+  static_assert(!__builtin_isfinite(__builtin_inf()), "");
 }
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -187,6 +187,15 @@
   return true;
 }
 
+static bool interp__builtin_isfinite(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isFinite()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -263,6 +272,11 @@
   return Ret(S, OpPC, Dummy);
 break;
 
+  case Builtin::BI__builtin_isfinite:
+if (interp__builtin_isfinite(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d37f1e9 - [clang][Interp] Implement __builtin_isnormal

2023-07-31 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-07-31T09:14:16+02:00
New Revision: d37f1e9965bd07bb8e05388aec0140addaf15e40

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

LOG: [clang][Interp] Implement __builtin_isnormal

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

Added: 


Modified: 
clang/lib/AST/Interp/Floating.h
clang/lib/AST/Interp/InterpBuiltin.cpp
clang/test/AST/Interp/builtin-functions.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Floating.h b/clang/lib/AST/Interp/Floating.h
index f98f49a7afb70e..c997323837c1c1 100644
--- a/clang/lib/AST/Interp/Floating.h
+++ b/clang/lib/AST/Interp/Floating.h
@@ -89,6 +89,7 @@ class Floating final {
   bool isNan() const { return F.isNaN(); }
   bool isInf() const { return F.isInfinity(); }
   bool isFinite() const { return F.isFinite(); }
+  bool isNormal() const { return F.isNormal(); }
 
   ComparisonCategoryResult compare(const Floating &RHS) const {
 llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);

diff  --git a/clang/lib/AST/Interp/InterpBuiltin.cpp 
b/clang/lib/AST/Interp/InterpBuiltin.cpp
index 6fe9bc7628efef..8c71f2f016252a 100644
--- a/clang/lib/AST/Interp/InterpBuiltin.cpp
+++ b/clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -196,6 +196,15 @@ static bool interp__builtin_isfinite(InterpState &S, 
CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isNormal()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -276,6 +285,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const 
Function *F) {
 if (interp__builtin_isfinite(S, OpPC, Frame, F))
   return Ret(S, OpPC, Dummy);
 break;
+  case Builtin::BI__builtin_isnormal:
+if (interp__builtin_isnormal(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;

diff  --git a/clang/test/AST/Interp/builtin-functions.cpp 
b/clang/test/AST/Interp/builtin-functions.cpp
index 9457100a15f528..924914f9f942bd 100644
--- a/clang/test/AST/Interp/builtin-functions.cpp
+++ b/clang/test/AST/Interp/builtin-functions.cpp
@@ -79,4 +79,7 @@ namespace inf {
 
   static_assert(__builtin_isfinite(1.0), "");
   static_assert(!__builtin_isfinite(__builtin_inf()), "");
+
+  static_assert(__builtin_isnormal(1.0), "");
+  static_assert(!__builtin_isnormal(__builtin_inf()), "");
 }



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


[PATCH] D155374: [clang][Interp] Implement __builtin_isnormal

2023-07-31 Thread Timm Bäder 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 rGd37f1e9965bd: [clang][Interp] Implement __builtin_isnormal 
(authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D155374?vs=540700&id=545523#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155374

Files:
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -79,4 +79,7 @@
 
   static_assert(__builtin_isfinite(1.0), "");
   static_assert(!__builtin_isfinite(__builtin_inf()), "");
+
+  static_assert(__builtin_isnormal(1.0), "");
+  static_assert(!__builtin_isnormal(__builtin_inf()), "");
 }
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -196,6 +196,15 @@
   return true;
 }
 
+static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isNormal()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -276,6 +285,10 @@
 if (interp__builtin_isfinite(S, OpPC, Frame, F))
   return Ret(S, OpPC, Dummy);
 break;
+  case Builtin::BI__builtin_isnormal:
+if (interp__builtin_isnormal(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;
Index: clang/lib/AST/Interp/Floating.h
===
--- clang/lib/AST/Interp/Floating.h
+++ clang/lib/AST/Interp/Floating.h
@@ -89,6 +89,7 @@
   bool isNan() const { return F.isNaN(); }
   bool isInf() const { return F.isInfinity(); }
   bool isFinite() const { return F.isFinite(); }
+  bool isNormal() const { return F.isNormal(); }
 
   ComparisonCategoryResult compare(const Floating &RHS) const {
 llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -79,4 +79,7 @@
 
   static_assert(__builtin_isfinite(1.0), "");
   static_assert(!__builtin_isfinite(__builtin_inf()), "");
+
+  static_assert(__builtin_isnormal(1.0), "");
+  static_assert(!__builtin_isnormal(__builtin_inf()), "");
 }
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -196,6 +196,15 @@
   return true;
 }
 
+static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+  const Floating &Arg = S.Stk.peek();
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isNormal()));
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -276,6 +285,10 @@
 if (interp__builtin_isfinite(S, OpPC, Frame, F))
   return Ret(S, OpPC, Dummy);
 break;
+  case Builtin::BI__builtin_isnormal:
+if (interp__builtin_isnormal(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;
Index: clang/lib/AST/Interp/Floating.h
===
--- clang/lib/AST/Interp/Floating.h
+++ clang/lib/AST/Interp/Floating.h
@@ -89,6 +89,7 @@
   bool isNan() const { return F.isNaN(); }
   bool isInf() const { return F.isInfinity(); }
   bool isFinite() const { return F.isFinite(); }
+  bool isNormal() const { return F.isNormal(); }
 
   ComparisonCategoryResult compare(const Floating &RHS) const {
 llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D154688: [clang] Show verify prefix in error messages

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

Ping


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

https://reviews.llvm.org/D154688

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


[PATCH] D155393: [clang][Interp] Implement __builtin_isfpclass

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155393

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


[PATCH] D155430: [clang][Interp] Implement __arithmethic_fence for floating types

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155430

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


[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

see the issue https://github.com/llvm/llvm-project/issues/64191


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156650

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -76,6 +76,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -84,10 +86,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -74,7 +74,8 @@
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
   if (Inc.Written.front() == '<')
-return tooling::stdlib::Header::named(Inc.Written).has_value();
+return tooling::stdlib::Header::named(Inc.Written).has_value() &&
+   !(PI && PI->shouldKeep(Inc.HashLine + 1));
   assert(Inc.HeaderID);
   auto HID = static_cast(*Inc.HeaderID);
   auto FE = AST.getSourceManager().getFileManager().getFileRef(


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -76,6 +76,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -84,10 +86,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -74,7 +74,8 @@
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
   if (Inc.Written.front() == '<')
-return tooling::stdlib::Header::named(Inc.Written).has_value();
+return tooling::stdlib::Header::named(Inc.Written).has_value() &&
+   !(PI && PI->shouldKeep(Inc.HashLine + 1));
   assert(Inc.HeaderID);
   auto HID = static_cast(*Inc.HeaderID);
   auto FE = AST.getSourceManager().getFileManager().getFileRef(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3f75d38 - [clang] Improve hermeticity of clang header tests.

2023-07-31 Thread Simi Pallipurath via cfe-commits

Author: Simi Pallipurath
Date: 2023-07-31T08:25:36+01:00
New Revision: 3f75d38a4d4d9e30d6ad1f805b225f1e073d21e0

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

LOG: [clang] Improve hermeticity of clang header tests.

At the moment the below header tests fail with the multilib error in LLVM 
Embedded Toolchain for Arm because there is no corresponding aarch64 big endian 
library variant  exist. Specifying --sysroot to its own testing directory 
clang/test/Headers/Inputs (which does not have any dependency library) prevents 
these header tests  from being located in standard library directories.

 1. clang/test/Headers/arm-neon-header.c
 2. clang/test/Headers/arm-fp16-header.c

Reviewed By: michaelplatings

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

Added: 


Modified: 
clang/test/Headers/arm-fp16-header.c
clang/test/Headers/arm-neon-header.c

Removed: 




diff  --git a/clang/test/Headers/arm-fp16-header.c 
b/clang/test/Headers/arm-fp16-header.c
index 556854023dff89..b1a87faebfe0bd 100644
--- a/clang/test/Headers/arm-fp16-header.c
+++ b/clang/test/Headers/arm-fp16-header.c
@@ -1,20 +1,20 @@
-// RUN: %clang -fsyntax-only  -ffreestanding  
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only  -ffreestanding  
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs 
-xc %s
 
-// RUN: %clang -fsyntax-only -ffreestanding   
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only -ffreestanding   
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs 
-xc %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 --sysroot=%S/Inputs 
-xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 --sysroot=%S/Inputs 
-xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 --sysroot=%S/Inputs 
-xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 --sysroot=%S/Inputs 
-xc++ %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 
--sysroot=%S/Inputs -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -n

[PATCH] D156427: [clang] Improve hermeticity of clang header tests.

2023-07-31 Thread Simi Pallipurath 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 rG3f75d38a4d4d: [clang] Improve hermeticity of clang header 
tests. (authored by simpal01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156427

Files:
  clang/test/Headers/arm-fp16-header.c
  clang/test/Headers/arm-neon-header.c


Index: clang/test/Headers/arm-neon-header.c
===
--- clang/test/Headers/arm-neon-header.c
+++ clang/test/Headers/arm-neon-header.c
@@ -2,27 +2,27 @@
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 
-// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c89 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c99 --sysroot=%S/Inputs 
-xc %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c11 --sysroot=%S/Inputs 
-xc %s
 
-// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc %s
+// RUN: %clang -fsyntax-only   -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c89 -xc 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c99 -xc 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c11 -xc 
--sysroot=%S/Inputs %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ 
--sysroot=%S/Inputs %s
 
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ %s
-// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++98 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++11 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++14 -xc++ 
--sysroot=%S/Inputs %s
+// RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding -nostdinc++ 
--target=aarch64_be-none-elf -march=armv8.2-a+fp16 -std=c++17 -xc++ 
-

[PATCH] D154475: [clang][Interp] Fix ignoring MaterializeTemporaryExprs

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154475

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


[PATCH] D155370: [CodeComplete] Improve FunctionCanBeCall

2023-07-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I'm not sure how I feel about dropping the parameters from the signature in the 
`CanBeCall = false` case.

I can see arguments in both directions:

- On the one hand, dropping the parameters makes the text that is inserted more 
consistent with the text that is shown for the proposal.
- On the other hand, imagine you're typing in a `CanBeCall = false` context 
(e.g. `&ClassName::Prefix^`), and there are several matching method names that 
begin with `Prefix` that you are trying to choose from. Seeing their signatures 
might be a useful piece of additional context to help you choose the right one 
(e.g. maybe you're looking for one with a particular parameter type).

On the whole, I think I lean towards the second point being more important, and 
therefore towards keeping the signatures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155370

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


[clang] 063b37e - Reapply [IR] Mark and/or constant expressions as undesirable

2023-07-31 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-07-31T09:54:24+02:00
New Revision: 063b37e7b40ace03184923213bc9ead6aadee540

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

LOG: Reapply [IR] Mark and/or constant expressions as undesirable

Reapply after D156401, which stops PatternMatch from recognizing
binop constant expressions, which should avoid the infinite loops
and assertion failures this patch previously exposed.

-

In preparation for removing support for and/or expressions, mark
them as undesirable. As such, we will no longer implicitly create
such expressions, but they still exist.

Added: 


Modified: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp
llvm/test/CodeGen/Hexagon/atomic-opaque-basic.ll
llvm/test/Transforms/InstCombine/and-or.ll
llvm/test/Transforms/InstCombine/and-xor-or.ll
llvm/test/Transforms/InstCombine/and.ll
llvm/test/Transforms/InstCombine/bswap-fold.ll
llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
llvm/test/Transforms/InstSimplify/compare.ll

Removed: 




diff  --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index 551ccc4810bcd3..0e0a9b157464a6 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -303,7 +303,8 @@ char *one_zero(void) {
 char *one_one_OK(void) {
   // CHECK:   define{{.*}} ptr @one_one_OK()
   // CHECK-NEXT:  [[ENTRY:.*]]:
-  // CHECK-SANITIZE-C-NEXT: br i1 and (i1 icmp ne (ptr inttoptr 
(i64 1 to ptr), ptr null), i1 icmp ne (i64 add (i64 sub (i64 ptrtoint (ptr 
getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 1) to i64), i64 
1), i64 1), i64 0)), label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE-C-NEXT: %[[AND:.*]] = and i1 icmp ne (ptr 
inttoptr (i64 1 to ptr), ptr null), icmp ne (i64 add (i64 sub (i64 ptrtoint 
(ptr getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 1) to i64), 
i64 1), i64 1), i64 0), !nosanitize
+  // CHECK-SANITIZE-C-NEXT: br i1 %[[AND]], label %[[CONT:.*]], 
label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE-CPP-NEXT:   br i1 xor (i1 icmp eq (ptr inttoptr 
(i64 1 to ptr), ptr null), i1 icmp ne (i64 add (i64 sub (i64 ptrtoint (ptr 
getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 1) to i64), i64 
1), i64 1), i64 0)), label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
   // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(ptr @[[LINE_1100]], i64 1, i64 add (i64 
sub (i64 ptrtoint (ptr getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), 
i64 1) to i64), i64 1), i64 1))
@@ -321,7 +322,8 @@ char *one_one_OK(void) {
 char *one_allones_BAD(void) {
   // CHECK:   define{{.*}} ptr @one_allones_BAD()
   // CHECK-NEXT:  [[ENTRY:.*]]:
-  // CHECK-SANITIZE-C-NEXT: br i1 and (i1 icmp ne (ptr inttoptr 
(i64 1 to ptr), ptr null), i1 icmp ne (i64 add (i64 sub (i64 ptrtoint (ptr 
getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 -1) to i64), i64 
1), i64 1), i64 0)), label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE-C-NEXT: %[[AND:.*]] = and i1 icmp ne (ptr 
inttoptr (i64 1 to ptr), ptr null), icmp ne (i64 add (i64 sub (i64 ptrtoint 
(ptr getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 -1) to i64), 
i64 1), i64 1), i64 0), !nosanitize
+  // CHECK-SANITIZE-C-NEXT: br i1 %[[AND]], label %[[CONT:.*]], 
label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE-CPP-NEXT:   br i1 xor (i1 icmp eq (ptr inttoptr 
(i64 1 to ptr), ptr null), i1 icmp ne (i64 add (i64 sub (i64 ptrtoint (ptr 
getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), i64 -1) to i64), i64 
1), i64 1), i64 0)), label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
   // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(ptr @[[LINE_1200]], i64 1, i64 add (i64 
sub (i64 ptrtoint (ptr getelementptr inbounds (i8, ptr inttoptr (i64 1 to ptr), 
i64 -1) to i64), i64 1), i64 1))
@@ -390,7 +392,8 @@ char *allones_zero_OK(void) {
 char *allones_one_BAD(void) {
   // CHECK: define{{.*}} ptr @allones_one_BAD()
   // CHECK-NEXT: [[ENTRY:.*]]:
-  // CHECK-SANITIZE-C-NEXT:  

[clang] e90f4fc - [clang][ExprConstant] Print template arguments when describing stack frame

2023-07-31 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-07-31T17:05:56+09:00
New Revision: e90f4fc6acaffd216e06e47df0aee6a8b5b2d4a9

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

LOG: [clang][ExprConstant] Print template arguments when describing stack frame

This patch adds additional printing of template argument list when the 
described function is a template specialization.
This can be useful when handling complex template functions in constexpr 
evaluator.

Reviewed By: cjdb, dblaikie
Differential Revision: https://reviews.llvm.org/D154366

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/test/AST/Interp/literals.cpp
clang/test/SemaCXX/builtin-align-cxx.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/constant-expression-cxx14.cpp
clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
clang/test/SemaCXX/constexpr-frame-describe.cpp
clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4b8a323093ccd5..d369af7944ebeb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -95,6 +95,8 @@ Attribute Changes in Clang
 
 Improvements to Clang's diagnostics
 ---
+- Clang constexpr evaluator now prints template arguments when displaying
+  template-specialization function calls.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c06ca3c405370e..c688467a2fef74 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1950,7 +1950,8 @@ void CallStackFrame::describe(raw_ostream &Out) const {
   cast(Callee)->isInstance();
 
   if (!IsMemberCall)
-Out << *Callee << '(';
+Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(),
+ /*Qualified=*/false);
 
   if (This && IsMemberCall) {
 if (const auto *MCE = dyn_cast_if_present(CallExpr)) {
@@ -1975,10 +1976,13 @@ void CallStackFrame::describe(raw_ostream &Out) const {
   Info.Ctx.getLValueReferenceType(This->Designator.MostDerivedType));
   Out << ".";
 }
-Out << *Callee << '(';
+Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(),
+ /*Qualified=*/false);
 IsMemberCall = false;
   }
 
+  Out << '(';
+
   for (FunctionDecl::param_const_iterator I = Callee->param_begin(),
E = Callee->param_end(); I != E; ++I, ++ArgIndex) {
 if (ArgIndex > (unsigned)IsMemberCall)

diff  --git a/clang/test/AST/Interp/literals.cpp 
b/clang/test/AST/Interp/literals.cpp
index d2b5f4a5a1901f..ad0adc23b42e40 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -502,22 +502,22 @@ namespace IncDec {
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral 
constant expression}} \
-  // ref-note {{in call to 
'uninit()'}} \
+  // ref-note {{in call to 
'uninit()'}} \
   // expected-error {{not an integral 
constant expression}} \
   // expected-note {{in call to 
'uninit()'}}
 
   static_assert(uninit(), ""); // ref-error {{not an integral 
constant expression}} \
-   // ref-note {{in call to 
'uninit()'}} \
+   // ref-note {{in call to 
'uninit()'}} \
// expected-error {{not an integral 
constant expression}} \
// expected-note {{in call to 
'uninit()'}}
 
   static_assert(uninit(), ""); // ref-error {{not an integral 
constant expression}} \
-// ref-note {{in call to 
'uninit()'}} \
+// ref-note {{in call to 
'uninit()'}} \
 // expected-error {{not an 
integral constant expression}} \
 // expected-note {{in call to 
'uninit()'}}
 
   static_assert(uninit(), ""); // ref-error {{not an integral 
constant expression}} \
- // ref-note {{in call to 
'uninit()'}} \
+ // ref-note {{in call to 
'uninit()'}} \
  // expected-error {{not an 
integral constant expression}} \
  // expected-note {{in call to 
'uninit(

[PATCH] D154366: [clang][ExprConstant] Print template arguments when describing stack frame

2023-07-31 Thread Takuya Shimizu 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 rGe90f4fc6acaf: [clang][ExprConstant] Print template arguments 
when describing stack frame (authored by hazohelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154366

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-frame-describe.cpp
  clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -45,7 +45,7 @@
 }
 
 int i = hh(); // expected-error {{call to immediate function 'examples::hh' is not a constant expression}} \
-   // expected-note {{in call to 'hh()'}}
+   // expected-note {{in call to 'hh()'}}
 
 struct A {
   int x;
@@ -180,7 +180,7 @@
 
 void test_runtime() {
 (void)immediate(0); // expected-error {{call to immediate function 'Aggregate::immediate' is not a constant expression}} \
-// expected-note {{in call to 'immediate(0)'}}
+// expected-note {{in call to 'immediate(0)'}}
 }
 consteval int f(int i) {
 return i;
Index: clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
===
--- clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
+++ clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp
@@ -88,11 +88,11 @@
 void ohno() {
   int bar[stack_array<1024>()];
   int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \
-// expected-note {{in call to 'stack_array()'}}
+// expected-note {{in call to 'stack_array<1025>()'}}
 
   constexpr int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \
   // expected-error {{constexpr variable cannot have non-literal type 'const int[stack_array<1025>()]'}} \
-  // expected-note {{in call to 'stack_array()'}}
+  // expected-note {{in call to 'stack_array<1025>()'}}
 }
 
 }
Index: clang/test/SemaCXX/constexpr-frame-describe.cpp
===
--- clang/test/SemaCXX/constexpr-frame-describe.cpp
+++ clang/test/SemaCXX/constexpr-frame-describe.cpp
@@ -58,3 +58,24 @@
 constexpr D d{};
 static_assert(d.c->b.a->foo() == 1); // expected-error {{constant expression}} \
 expected-note {{in call to 'd.c->b.a->foo()'}}
+
+template 
+struct Bar {
+  template 
+  constexpr int fail1() const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+  template 
+  constexpr int fail2() const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+  template 
+  constexpr int fail3(Args... args) const { return 1 / 0; } // expected-warning {{division by zero}} \
+// expected-note {{division by zero}}
+};
+
+constexpr Bar bar;
+static_assert(bar.fail1()); // expected-error {{constant expression}} \
+ // expected-note {{in call to 'bar.fail1()'}}
+static_assert(bar.fail2()); // expected-error {{constant expression}} \
+  // expected-note {{in call to 'bar.fail2()'}}
+static_assert(bar.fail3(3, 4UL, bar, &bar)); // expected-error {{constant expression}} \
+ // expected-note {{in call to 'bar.fail3, const Bar *>(3, 4, {}, &bar)'}}
Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -117,11 +117,11 @@
 
   constexpr pad pir{4, 4};
   // expected-error@+2 {{constexpr variable 'piw' must be initialized by a constant expression}}
-  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
+  // expected-note@+1 {{in call to 'bit_cast(pir)'}}
   constexpr int piw = bit_cast(pir).x;
 
   // expected-error@+2 {{constexpr variable 'bad' must be initialized by a constant expression}

[PATCH] D156300: [clangd] Avoid unexpected desugaring in isSugaredTemplateParameter

2023-07-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:198
 bool isSugaredTemplateParameter(QualType QT) {
   static auto PeelWrappers = [](QualType QT) {
 // Neither `PointerType` nor `ReferenceType` is considered as sugared

nit: since it's only doing one level of peeling, let's call it `PeelWrapper` 
(no `s`)



Comment at: clang-tools-extra/clangd/InlayHints.cpp:202
 QualType Next;
-while (!(Next = QT->getPointeeType()).isNull())
+if (!(Next = QT->getPointeeType()).isNull())
   QT = Next;

Now that the function is not looping, we can simplify the body a bit:

```
QualType Peeled = QT->getPointeeType();
return Peeled.isNull() ? QT : Peeled;
```



Comment at: clang-tools-extra/clangd/InlayHints.cpp:207
+
+  // This is a bit tricky: we traverse the type structure and find whether or
+  // not a type in the desugaring process is of SubstTemplateTypeParmType.

Nice find, this is indeed pretty tricky. I remember running into a similar 
issue before in https://reviews.llvm.org/D124690#inline-1205484.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156300

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


[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:85-86
   if (PI) {
 if (PI->shouldKeep(Inc.HashLine + 1))
   return false;
 // Check if main file is the public interface for a private header. If so 
we

can you unify this and the previous check and just have a single:
```
if (PI && PI->shouldKeep(Inc.HashLine + 1))
  return false;
```

at the top of the function?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156650

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


[PATCH] D156648: [Tooling/Inclusion] Add std::range symbols in the mapping.

2023-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

can you also create a cherry-pick request for this patch once it lands?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156648

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


[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

also we should get this cherry-picked too. `keep` pragmas on includes are not 
common, but people do have export pragmas often enough to cause some annoyance 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156650

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


[PATCH] D156655: [clang-format] Handle goto labels preceded by C++11 attributes

2023-07-31 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156655

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3023,6 +3023,26 @@
"  some_other_code();\n"
"}\n"
"}");
+  verifyFormat("{\n"
+   "L0:\n"
+   "[[foo]] L1:\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1: {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "  [[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}");
   FormatStyle Style = getLLVMStyle();
   Style.IndentGotoLabels = false;
   verifyFormat("void f() {\n"
@@ -3046,12 +3066,22 @@
"  some_code();\n"
"test_label:;\n"
"  int i = 0;\n"
-   "}");
+   "}",
+   Style);
   verifyFormat("{\n"
"  some_code();\n"
"test_label: { some_other_code(); }\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}",
+   Style);
   // The opening brace may either be on the same unwrapped line as the colon or
   // on a separate one. The formatter should recognize both.
   Style = getLLVMStyle();
@@ -3064,6 +3094,14 @@
"}\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "{\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, MultiLineControlStatements) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1398,7 +1398,10 @@
 return;
   }
 
-  if (Style.isVerilog()) {
+  if (Style.isCpp()) {
+while (FormatTok->is(tok::l_square) && handleCppAttributes()) {
+}
+  } else if (Style.isVerilog()) {
 if (Keywords.isVerilogStructuredProcedure(*FormatTok)) {
   parseForOrWhileLoop(/*HasParens=*/false);
   return;
@@ -1634,6 +1637,17 @@
   parseNamespace();
   return;
 }
+// In Verilog labels can be any expression, so we don't do them here.
+if (!Style.isVerilog() && Tokens->peekNextToken()->is(tok::colon) &&
+!Line->MustBeDeclaration) {
+  nextToken();
+  Line->Tokens.begin()->Tok->MustBreakBefore = true;
+  FormatTok->setFinalizedType(TT_GotoLabelColon);
+  parseLabel(!Style.IndentGotoLabels);
+  if (HasLabel)
+*HasLabel = true;
+  return;
+}
 // In all other cases, parse the declaration.
 break;
   default:
@@ -1938,16 +1952,6 @@
 return I != E && (++I == E);
   };
   if (OneTokenSoFar()) {
-// In Verilog labels can be any expression, so we don't do them here.
-if (!Style.isVerilog() && FormatTok->is(tok::colon) &&
-!Line->MustBeDeclaration) {
-  Line->Tokens.begin()->Tok->MustBreakBefore = true;
-  FormatTok->setFinalizedType(TT_GotoLabelColon);
-  parseLabel(!Style.IndentGotoLabels);
-  if (HasLabel)
-*HasLabel = true;
-  return;
-}
 // Recognize function-like macro usages without trailing semicolon as
 // well as free-standing macros like Q_OBJECT.
 bool FunctionLike = FormatTok->is(tok::l_paren);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150124: [index][clangd] Consider labels when indexing function bodies

2023-07-31 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 545551.
ckandeler added a comment.

Addressed another review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150124

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexBody.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -218,6 +218,28 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexLabels) {
+  std::string Code = R"cpp(
+int main() {
+  goto theLabel;
+  theLabel:
+return 1;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("theLabel"), WrittenAt(Position(3, 16)),
+ DeclAt(Position(4, 11);
+
+  Opts.IndexFunctionLocals = false;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Not(Contains(QName("theLabel";
+}
+
 TEST(IndexTest, IndexExplicitTemplateInstantiation) {
   std::string Code = R"cpp(
 template 
Index: clang/lib/Index/IndexBody.cpp
===
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -144,6 +144,17 @@
 Parent, ParentDC, Roles, Relations, E);
   }
 
+  bool VisitGotoStmt(GotoStmt *S) {
+return IndexCtx.handleReference(S->getLabel(), S->getLabelLoc(), Parent,
+ParentDC);
+  }
+
+  bool VisitLabelStmt(LabelStmt *S) {
+if (IndexCtx.shouldIndexFunctionLocalSymbols())
+  return IndexCtx.handleDecl(S->getDecl());
+return true;
+  }
+
   bool VisitMemberExpr(MemberExpr *E) {
 SourceLocation Loc = E->getMemberLoc();
 if (Loc.isInvalid())
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -125,6 +125,13 @@
   [Foo [[x]]:2 [[^y]]:4];
 }
   )cpp",
+  R"cpp( // Label
+int main() {
+  goto [[^theLabel]];
+  [[theLabel]]:
+return 1;
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -218,6 +218,28 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexLabels) {
+  std::string Code = R"cpp(
+int main() {
+  goto theLabel;
+  theLabel:
+return 1;
+}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("theLabel"), WrittenAt(Position(3, 16)),
+ DeclAt(Position(4, 11);
+
+  Opts.IndexFunctionLocals = false;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, Not(Contains(QName("theLabel";
+}
+
 TEST(IndexTest, IndexExplicitTemplateInstantiation) {
   std::string Code = R"cpp(
 template 
Index: clang/lib/Index/IndexBody.cpp
===
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -144,6 +144,17 @@
 Parent, ParentDC, Roles, Relations, E);
   }
 
+  bool VisitGotoStmt(GotoStmt *S) {
+return IndexCtx.handleReference(S->getLabel(), S->getLabelLoc(), Parent,
+ParentDC);
+  }
+
+  bool VisitLabelStmt(LabelStmt *S) {
+if (IndexCtx.shouldIndexFunctionLocalSymbols())
+  return IndexCtx.handleDecl(S->getDecl());
+return true;
+  }
+
   bool VisitMemberExpr(MemberExpr *E) {
 SourceLocation Loc = E->getMemberLoc();
 if (Loc.isInvalid())
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -125,6 +125,13 @@
   [Foo [[x]]:2 [[^y]]:4];
 }
   )cpp",
+  R"cpp( // Label
+int main() {
+  goto [[^theLabel]];
+  [[theLabel]]:
+return 1;
+}
+  )c

[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-31 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

> I agree this is a bug in libc++ and we should fix it. As mentioned I'm not 
> too familiar with ranges.

Thanks! I submitted https://github.com/llvm/llvm-project/issues/64250 so we 
don't forget about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The only entries in `ExprToLoc` that will be read by a different block are the
direct children of the block terminator (if one exists). For the purposes of
determining whether `ExprToLoc` has converged, it is therefore sufficient to
look at these entries, as any differences in other entries will not be seen by
other blocks.

The other entries in `ExprToLoc` are only read during processing of the block
that contains the corresponding expressions. To be clear, these entries can
affect the results of the block, but only indirectly, in one of two ways:

- If they are indirect descendants of the terminator and therefore affect the 
values of the terminator's direct children.

- If they affect the entries in one of the other mappings in `Environment`.

Before this patch, we were comparing all entries in `ExprToLoc`, even if they
were never accessed by other blocks, which could cause non-convergence. This
patch adds two tests that demonstrate this; they do not converge without the
other changes in this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156658

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.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
@@ -3836,6 +3836,58 @@
   });
 }
 
+TEST(TransferTest, LoopDereferencingChangingPointerConverges) {
+  std::string Code = R"cc(
+bool some_condition();
+
+void target(int i1, int i2) {
+  int *p = &i1;
+  while (true) {
+(void)*p;
+if (some_condition())
+  p = &i1;
+else
+  p = &i2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
+TEST(TransferTest, LoopDereferencingChangingRecordPointerConverges) {
+  std::string Code = R"cc(
+struct Lookup {
+  int x;
+};
+
+bool some_condition();
+
+void target(Lookup l1, Lookup l2) {
+  Lookup *l = &l1;
+  while (true) {
+(void)l->x;
+if (some_condition())
+  l = &l1;
+else
+  l = &l2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, DoesNotCrashOnUnionThisExpr) {
   std::string Code = R"(
 union Union {
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -574,7 +574,8 @@
 }
   } else if (Analysis.isEqualTypeErased(OldBlockState->Lattice,
 NewBlockState.Lattice) &&
- OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis)) {
+ OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis,
+ Block->getTerminatorStmt())) {
 // The state of `Block` didn't change after transfer so there's no need
 // to revisit its successors.
 AC.Log.blockConverged();
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -414,8 +414,33 @@
   }
 }
 
+static bool exprToLocEquivalent(const Environment &Env1,
+const Environment &Env2,
+const Stmt *Terminator) {
+  if (Terminator == nullptr)
+return true;
+
+  for (const Stmt *Child : Terminator->children()) {
+auto *E = dyn_cast(Child);
+if (E == nullptr)
+  continue;
+
+if (E->isGLValue()) {
+  if (Env1.getStorageLocationStrict(*E) !=
+  Env2.getStorageLocationStrict(*E))
+return false;
+} else {
+  if (Env1.getValue(*E) != Env2.getValue(*E))
+return fa

[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

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

Retracting from review momentarily -- I've just realized that I should be 
comparing values the same way this is done for the `LocToVal` map.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156658

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


[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 545561.
mboehme added a comment.

Make check for `Value` equivalence consistent with the corresponding check for
`LocToVal`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156658

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.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
@@ -3836,6 +3836,58 @@
   });
 }
 
+TEST(TransferTest, LoopDereferencingChangingPointerConverges) {
+  std::string Code = R"cc(
+bool some_condition();
+
+void target(int i1, int i2) {
+  int *p = &i1;
+  while (true) {
+(void)*p;
+if (some_condition())
+  p = &i1;
+else
+  p = &i2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
+TEST(TransferTest, LoopDereferencingChangingRecordPointerConverges) {
+  std::string Code = R"cc(
+struct Lookup {
+  int x;
+};
+
+bool some_condition();
+
+void target(Lookup l1, Lookup l2) {
+  Lookup *l = &l1;
+  while (true) {
+(void)l->x;
+if (some_condition())
+  l = &l1;
+else
+  l = &l2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, DoesNotCrashOnUnionThisExpr) {
   std::string Code = R"(
 union Union {
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -574,7 +574,8 @@
 }
   } else if (Analysis.isEqualTypeErased(OldBlockState->Lattice,
 NewBlockState.Lattice) &&
- OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis)) {
+ OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis,
+ Block->getTerminatorStmt())) {
 // The state of `Block` didn't change after transfer so there's no need
 // to revisit its successors.
 AC.Log.blockConverged();
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -414,8 +414,45 @@
   }
 }
 
+static bool exprToLocEquivalent(const Environment &Env1,
+const Environment &Env2, const Stmt *Terminator,
+Environment::ValueModel &Model) {
+  if (Terminator == nullptr)
+return true;
+
+  for (const Stmt *Child : Terminator->children()) {
+auto *E = dyn_cast(Child);
+if (E == nullptr)
+  continue;
+
+if (E->isGLValue()) {
+  if (Env1.getStorageLocationStrict(*E) !=
+  Env2.getStorageLocationStrict(*E))
+return false;
+} else {
+  // For prvalues, locations don't matter -- just look at whether they map
+  // to equivalent values.
+  Value *Val1 = Env1.getValue(*E);
+  Value *Val2 = Env2.getValue(*E);
+
+  if (Val1 == nullptr || Val2 == nullptr) {
+if (Val1 == nullptr && Val2 == nullptr)
+  continue;
+return false;
+  }
+
+  if (!areEquivalentValues(*Val1, *Val2) &&
+  !compareDistinctValues(E->getType(), *Val1, Env1, *Val2, Env2, Model))
+return false;
+}
+  }
+
+  return true;
+}
+
 bool Environment::equivalentTo(const Environment &Other,
-   Environment::ValueModel &Model) const {
+   Environment::ValueModel &Model,
+   const Stmt *Terminator) const {
   assert(DACtx == Other.DACtx);
 
   if (ReturnVal != Other.ReturnVal)
@@ -430,7 +467,7 @@
   if (DeclToLoc != Other.DeclToLoc)
 return false;
 
-  if (ExprToLoc != Other.ExprToLoc)
+  if (!exprToLocEquivalent(*this, Other, Terminator, Model))
 return false;
 
   // Compar

[PATCH] D156247: [Clang] Add a warning on uses of coroutine keywords

2023-07-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov abandoned this revision.
ilya-biryukov added a comment.

Marking the revision as abandoned to reflect the status of the RFC.
Thanks everyone for your feedback and sorry about the timing of this change 
again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156247

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


[PATCH] D156659: [clangd] Rollforward include-cleaner library usage in symbol collector.

2023-07-31 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156659

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/IndexActionTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc

Index: clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -360,6 +360,11 @@
 SYMBOL(make_index_sequence, std::, )
 SYMBOL(make_integer_sequence, std::, )
 
+// generated symbol map is missing these symbols.
+// Remove them when the cause(s) are identified.
+SYMBOL(div, std::, )
+SYMBOL(abort, std::, )
+
 // The std::placeholder symbols (_1, ..., _N) are listed in the cppreference
 // placeholder.html, but the index only contains a single entry with "_1, _2, ..., _N"
 // text, which are not handled by the script.
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -123,7 +123,7 @@
 if (FD->getNumParams() == 1)
   // move(T&& t)
   return tooling::stdlib::Header::named("");
-if (FD->getNumParams() == 3)
+if (FD->getNumParams() == 3 || FD->getNumParams() == 4)
   // move(InputIt first, InputIt last, OutputIt dest);
   return tooling::stdlib::Header::named("");
   } else if (FName == "remove") {
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -14,6 +14,7 @@
 #include "index/SymbolCollector.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/IndexingOptions.h"
@@ -1554,6 +1555,8 @@
 // Move overloads have special handling.
 template  T&& move(_T&& __value);
 template  _O move(_I, _I, _O);
+template  _O move(
+  _T&&, _O, _O, _I);
   }
   )cpp",
   /*Main=*/"");
@@ -1565,7 +1568,8 @@
 includeHeader("")),
   // Parameter names are demangled.
   AllOf(labeled("move(T &&value)"), includeHeader("")),
-  AllOf(labeled("move(I, I, O)"), includeHeader("";
+  AllOf(labeled("move(I, I, O)"), includeHeader("")),
+  AllOf(labeled("move(T &&, O, O, I)"), includeHeader("";
 }
 
 TEST_F(SymbolCollectorTest, IWYUPragma) {
@@ -1592,7 +1596,7 @@
  includeHeader("\"the/good/header.h\"";
 }
 
-TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) {
+TEST_F(SymbolCollectorTest, IWYUPragmaExport) {
   CollectorOpts.CollectIncludePath = true;
   const std::string Header = R"cpp(#pragma once
 #include "exporter.h"
@@ -1978,6 +1982,24 @@
   qName("A"), hasKind(clang::index::SymbolKind::Concept;
 }
 
+TEST_F(SymbolCollectorTest, IncludeHeaderForwardDecls) {
+  CollectorOpts.CollectIncludePath = true;
+  const std::string Header = R"cpp(#pragma once 
+struct Foo;
+#include "full.h"
+)cpp";
+  auto FullFile = testPath("full.h");
+  InMemoryFileSystem->addFile(FullFile, 0,
+  llvm::MemoryBuffer::getMemBuffer(R"cpp(
+#pragma once 
+struct Foo {};)cpp"));
+  runSymbolCollector(Header, /*Main=*/"",
+ /*ExtraArgs=*/{"-I", testRoot()});
+  EXPECT_THAT(Symbols, UnorderedElementsAre(AllOf(
+   qName("Foo"),
+   includeHeader(URI::create(FullFile).toString()
+  << *Symbols.begin();
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/IndexActionTests.cpp
===
--- clang-tools-extra/clangd/unittests/IndexActionTests.cpp
+++ clang-tools-extra/clangd/unittests/IndexActionTests.cpp
@@ -8,11 +8,15 @@
 
 #include "Headers.h"
 #include "TestFS.h"
+#include "URI.h"
 #include "index/IndexAction.h"
 #include "index/Serialization.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
 #include "cl

[PATCH] D156660: [CodeGen] Assert that EmittedDeferredDecls is empty

2023-07-31 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: v.g.vassilev, junaire, rjmccall.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Its contents are transferred into `DeferredDecls` in `Release()`, so it
should be empty in `moveLazyEmissionStates()`. This matches the code
downstream in Cling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156660

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7455,6 +7455,8 @@
   assert(NewBuilder->DeferredDecls.empty() &&
  "Newly created module should not have deferred decls");
   NewBuilder->DeferredDecls = std::move(DeferredDecls);
+  assert(EmittedDeferredDecls.empty() &&
+ "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   assert(NewBuilder->DeferredVTables.empty() &&
  "Newly created module should not have deferred vtables");
@@ -7470,10 +7472,5 @@
 
   NewBuilder->TBAA = std::move(TBAA);
 
-  assert(NewBuilder->EmittedDeferredDecls.empty() &&
- "Still have (unmerged) EmittedDeferredDecls deferred decls");
-
-  NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
-
   NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7455,6 +7455,8 @@
   assert(NewBuilder->DeferredDecls.empty() &&
  "Newly created module should not have deferred decls");
   NewBuilder->DeferredDecls = std::move(DeferredDecls);
+  assert(EmittedDeferredDecls.empty() &&
+ "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   assert(NewBuilder->DeferredVTables.empty() &&
  "Newly created module should not have deferred vtables");
@@ -7470,10 +7472,5 @@
 
   NewBuilder->TBAA = std::move(TBAA);
 
-  assert(NewBuilder->EmittedDeferredDecls.empty() &&
- "Still have (unmerged) EmittedDeferredDecls deferred decls");
-
-  NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
-
   NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156660: [CodeGen] Assert that EmittedDeferredDecls is empty

2023-07-31 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156660

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


[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 545571.
mboehme added a comment.

Use `dyn_cast_or_null` instead of `dyn_cast`. (Children can be null.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156658

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.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
@@ -3836,6 +3836,58 @@
   });
 }
 
+TEST(TransferTest, LoopDereferencingChangingPointerConverges) {
+  std::string Code = R"cc(
+bool some_condition();
+
+void target(int i1, int i2) {
+  int *p = &i1;
+  while (true) {
+(void)*p;
+if (some_condition())
+  p = &i1;
+else
+  p = &i2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
+TEST(TransferTest, LoopDereferencingChangingRecordPointerConverges) {
+  std::string Code = R"cc(
+struct Lookup {
+  int x;
+};
+
+bool some_condition();
+
+void target(Lookup l1, Lookup l2) {
+  Lookup *l = &l1;
+  while (true) {
+(void)l->x;
+if (some_condition())
+  l = &l1;
+else
+  l = &l2;
+  }
+}
+  )cc";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {});
+}
+
 TEST(TransferTest, DoesNotCrashOnUnionThisExpr) {
   std::string Code = R"(
 union Union {
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -574,7 +574,8 @@
 }
   } else if (Analysis.isEqualTypeErased(OldBlockState->Lattice,
 NewBlockState.Lattice) &&
- OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis)) {
+ OldBlockState->Env.equivalentTo(NewBlockState.Env, Analysis,
+ Block->getTerminatorStmt())) {
 // The state of `Block` didn't change after transfer so there's no need
 // to revisit its successors.
 AC.Log.blockConverged();
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -414,8 +414,45 @@
   }
 }
 
+static bool exprToLocEquivalent(const Environment &Env1,
+const Environment &Env2, const Stmt *Terminator,
+Environment::ValueModel &Model) {
+  if (Terminator == nullptr)
+return true;
+
+  for (const Stmt *Child : Terminator->children()) {
+auto *E = dyn_cast_or_null(Child);
+if (E == nullptr)
+  continue;
+
+if (E->isGLValue()) {
+  if (Env1.getStorageLocationStrict(*E) !=
+  Env2.getStorageLocationStrict(*E))
+return false;
+} else {
+  // For prvalues, locations don't matter -- just look at whether they map
+  // to equivalent values.
+  Value *Val1 = Env1.getValue(*E);
+  Value *Val2 = Env2.getValue(*E);
+
+  if (Val1 == nullptr || Val2 == nullptr) {
+if (Val1 == nullptr && Val2 == nullptr)
+  continue;
+return false;
+  }
+
+  if (!areEquivalentValues(*Val1, *Val2) &&
+  !compareDistinctValues(E->getType(), *Val1, Env1, *Val2, Env2, Model))
+return false;
+}
+  }
+
+  return true;
+}
+
 bool Environment::equivalentTo(const Environment &Other,
-   Environment::ValueModel &Model) const {
+   Environment::ValueModel &Model,
+   const Stmt *Terminator) const {
   assert(DACtx == Other.DACtx);
 
   if (ReturnVal != Other.ReturnVal)
@@ -430,7 +467,7 @@
   if (DeclToLoc != Other.DeclToLoc)
 return false;
 
-  if (ExprToLoc != Other.ExprToLoc)
+  if (!exprToLocEquivalent(*this, Other, Terminator, Model))
 return false;
 
   // Compare the content

[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-07-31 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D156363#4545474 , @MaskRay wrote:

> In D156363#4545215 , @dyung wrote:
>
>> If you cannot reproduce this issue, I can take my buildbot offline and try 
>> to reproduce it to pinpoint which command is causing the problem, but I 
>> won’t be able to do so until Monday.
>
> Thank you, knowing which command caused the failure will be very helpful.
> `clang/test/Driver/fsanitize.c` has the most mysterious failure I have dealt 
> with for this patch.
>
> FWIW I've checked that the test passes even if `/usr` does not exist 
> (emulated by proot) => there is as if no host GCC installation that could 
> affect Driver's behavior
>
>   % cat /tmp/Rel/bin/xxx
>   #!/bin/zsh
>   d=$(dirname "$0")
>   exec proot -R /tmp -b /bin -b /lib64 -b /lib $d/clang 
> --target=aarch64-linux-musl "$@"
>   % cd clang/test/Driver
>   % CLANG=/tmp/Rel/bin/xxx /tmp/Rel/bin/llvm-lit -vv fsanitize.c
>   .. passed

I have to run, but I did a quick -vv run with this commit and it seems to fail 
on the RUN line on 588:

  + : 'RUN: at line 581'
  + /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
--target=i386-apple-ios-simulator -fsanitize=leak 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 -###
  + 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 --check-prefix=CHECK-LSAN-I386-IOSSIMULATOR
  + : 'RUN: at line 584'
  + /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
--target=i386-apple-tvos-simulator -fsanitize=leak 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 -###
  + 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 --check-prefix=CHECK-LSAN-I386-TVOSSIMULATOR
  + : 'RUN: at line 588'
  + not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
--target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -c 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 -###
  + 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
 --check-prefix=CHECK-CFI
  
  --
  
  
  
  Failed Tests (1):
Clang :: Driver/fsanitize.c

I'll try to look more later when I get more time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

2023-07-31 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Thanks everyone for the comments!




Comment at: clang/test/Lexer/cxx1z-trigraphs.cpp:24
 // expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
-// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} 
expected-note@13 {{evaluates to ''?' == '#''}}
+// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} 
expected-note@13 {{evaluates to '63 == 35'}}
 // expected-error@16 {{}}

cor3ntin wrote:
> tahonermann wrote:
> > aaron.ballman wrote:
> > > I think the original diagnostic was actually more understandable as it 
> > > relates more closely to what's written in the static assertion. I could 
> > > imagine something like `evaluates to '?' (63) == '#' (35)` would also be 
> > > reasonable.
> > I agree. I would also be ok with printing the integer value as primary with 
> > the character as secondary:
> >   evaluates to 63 ('?') == 35 ('#')
> > 
> > There are two kinds of non-printable characters:
> >   # Control characters (including new-line)
> >   # character values that don't correspond to a character (e.g., lone 
> > trailing characters or invalid code unit values).
> > For the first case, I would support printing them as either C escapes or 
> > universal-character-names. e.g.,
> >   evaluates to 0 ('\0') == 1 (\u0001)
> > For the second case, I would support printing them as C hex escapes. e.g, 
> >   evaluates to -128 ('\x80') == -123 ('\x85')
> > 
> > 
> > For the first case, I would support printing them as either C escapes or 
> > universal-character-names. e.g.,
> 
> As mentioned before, we should be consistent with what we do for diagnostics 
> messages in general - (`ie `pushEscapedString`).
> I check and we already do that. https://godbolt.org/z/doah9YGMT
> 
> Question is, why do we sometimes don't?
> Note that in general i don't have an opinion about displaying the value of 
> characters literal _in addition_ of the character itself, it seems like a 
> good thing)
The character escape in the current error message is handled in 
`CharacterLiteral::print` 
(https://github.com/llvm/llvm-project/blob/fcb6a9c07cf7a2bc63d364e3b7f60aaadadd57cc/clang/lib/AST/Expr.cpp#L1064-L1083),
 and the reason for `'\0'` being escaped to `\x00` and `'\u{9}'` escaped to 
`\t` is that `escapeCStyle` does not escape null character 
(https://github.com/llvm/llvm-project/blob/c1c86f9eae73786bcdacddaab248817c4f176935/clang/include/clang/Basic/CharInfo.h#L174-L200).
`pushEscapedString` does not escape whitespace characters, so we should use 
`escapeCStyle` if we are to use c-style escape for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155610

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


[PATCH] D155661: [clang][ASTImporter] Fix friend class template import within dependent context

2023-07-31 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2862-2866
+  bool ShouldAddRedecl = !(IsFriendTemplate && IsDependentContext);
+
   // We may already have a record of the same name; try to find and match it.
   RecordDecl *PrevDecl = nullptr;
   if (!DC->isFunctionOrMethod() && !D->isLambda()) {

The code seems to work but I was confused by the different conditions used (is 
it possible that `IsFriendTemplate` and `ShouldAddRedecl` is true at the same 
time?). I had the observation that if `ShouldAddRedecl` is false we do not need 
the whole search for previous decl. At a friend template we shall not find a 
definition, the loop would just find the last declaration (this value is not 
used). So I have the idea of this code (could not find the "suggest edit" 
command):

```
  bool DependentFriend = IsFriendTemplate && IsDependentContext;

  // We may already have a record of the same name; try to find and match it.
  RecordDecl *PrevDecl = nullptr;
  if (!DependentFriend && !DC->isFunctionOrMethod() && !D->isLambda()) {

```



Comment at: clang/lib/AST/ASTImporter.cpp:2904
 
-if (IsStructuralMatch(D, FoundRecord)) {
+if (IsFriendTemplate || IsStructuralMatch(D, FoundRecord)) {
   RecordDecl *FoundDef = FoundRecord->getDefinition();

This change is not needed if the code above is used.



Comment at: clang/lib/AST/ASTImporter.cpp:2976
+  D2CXX, D, Importer.getToContext(), D->getTagKind(), DC,
+  *BeginLocOrErr, Loc, Name.getAsIdentifierInfo(),
+  ShouldAddRedecl ? cast_or_null(PrevDecl)

This change is not needed if the code above is used.



Comment at: clang/lib/AST/ASTImporter.cpp:5805-5812
+  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+: DC->isDependentContext();
+  bool ShouldAddRedecl = !(IsFriendTemplate && IsDependentContext);
+
   ClassTemplateDecl *FoundByLookup = nullptr;
 
   // We may already have a template of the same name; try to find and match it.

Similar change here:
```
  bool DependentFriend = IsFriendTemplate && IsDependentContext;

  ClassTemplateDecl *FoundByLookup = nullptr;

  // We may already have a template of the same name; try to find and match it.
  if (!DependentFriend && !DC->isFunctionOrMethod()) {
```
`IsFriendTemplate` and `ShouldAddRedecl` is not needed (no changes in the later 
lines).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155661

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


[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

2023-07-31 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 545582.
hazohelet added a comment.

Address review comments

- Print the character representation only when the type of the expressions is 
`char` or `char8_t`
- Use `pushEscapedString` in the printing so that we can reuse its escaping 
logic
- Use `escapeCStyle` to escape whitespace characters
- `wchar_t` and `charN_t` are not handled yet


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

https://reviews.llvm.org/D155610

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Diagnostic.h
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Lexer/cxx1z-trigraphs.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -262,7 +262,19 @@
 return 'c';
   }
   static_assert(getChar() == 'a', ""); // expected-error {{failed}} \
-   // expected-note {{evaluates to ''c' == 'a''}}
+   // expected-note {{evaluates to ''c' (99) == 'a' (97)'}}
+  static_assert((char)9 == '\x61', ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''\t' (9) == 'a' (97)'}}
+  static_assert((char)10 == '\0', ""); // expected-error {{failed}} \
+   // expected-note {{n' (10) == '\u' (0)'}}
+  // The note above is intended to match "evaluates to '\n' (10) == '\u' (0)'", but if we write it as it is,
+  // the "\n" cannot be consumed by the diagnostic consumer.
+  static_assert((signed char)10 == (char)-123, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to '10 == '\x85' (-123)'}}
+  static_assert((char)-4 == (unsigned char)-8, ""); // expected-error {{failed}} \
+// expected-note {{evaluates to ''\xfc' (-4) == 248'}}
+  static_assert((char)-128 == (char)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\x80' (-128) == '\x85' (-123)'}}
 
   /// Bools are printed as bools.
   constexpr bool invert(bool b) {
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- clang/test/SemaCXX/static-assert-cxx26.cpp
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -289,3 +289,10 @@
 Bad b; // expected-note {{in instantiation}}
 
 }
+
+namespace EscapeInDiagnostic {
+static_assert('\u{9}' == (char)1, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\t' (9) == '\u0001' (1)'}}
+static_assert((char8_t)-128 == (char8_t)-123, ""); // expected-error {{failed}} \
+   // expected-note {{evaluates to ''\x80' (128) == '\x85' (133)'}}
+}
Index: clang/test/Lexer/cxx1z-trigraphs.cpp
===
--- clang/test/Lexer/cxx1z-trigraphs.cpp
+++ clang/test/Lexer/cxx1z-trigraphs.cpp
@@ -21,7 +21,7 @@
 
 #if !ENABLED_TRIGRAPHS
 // expected-error@11 {{}} expected-warning@11 {{trigraph ignored}}
-// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' == '#''}}
+// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' (63) == '#' (35)'}}
 // expected-error@16 {{}}
 // expected-error@20 {{}}
 #else
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16817,13 +16817,31 @@
  "Bool type, but value is not 0 or 1");
   llvm::raw_svector_ostream OS(Str);
   OS << (BoolValue ? "true" : "false");
-} else if (T->isCharType()) {
+} else {
   // Same is true for chars.
-  Str.push_back('\'');
-  Str.push_back(V.getInt().getExtValue());
-  Str.push_back('\'');
-} else
-  V.getInt().toString(Str);
+  // We want to print the character representation for `char` type
+  // and need to escape it if it is not printable.
+  const auto *BTy = T->getAs();
+  if (BTy && (BTy->getKind() == BuiltinType::Char_S ||
+  BTy->getKind() == BuiltinType::Char_U ||
+  BTy->getKind() == BuiltinType::Char8)) {
+llvm::raw_svector_ostream OS(Str);
+int64_t CharVal = V.getInt().getExtValue();
+Str.push_back('\'');
+StringRef Escaped = escapeCStyle(CharVal);
+if (!Escaped.empty()) {
+  OS << Escaped;
+} else {
+  const char CharArr[] = {static_cast(CharVal)};
+  pushEscapedString(StringRef(CharArr, sizeof(

[clang] 171868d - [Tooling/Inclusion] Add std::range symbols in the mapping.

2023-07-31 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-07-31T13:05:47+02:00
New Revision: 171868dc2cd60c6e3eaeb3861b18ba0e22461291

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

LOG: [Tooling/Inclusion] Add std::range symbols in the mapping.

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

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

Added: 


Modified: 
clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
clang/tools/include-mapping/gen_std.py

Removed: 




diff  --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index a08ec11e77a4a9..b46bd2e4d7a4b5 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -3773,6 +3773,33 @@ SYMBOL(viewable_range, std::ranges::, )
 SYMBOL(wistream_view, std::ranges::, )
 SYMBOL(zip_transform_view, std::ranges::, )
 SYMBOL(zip_view, std::ranges::, )
+SYMBOL(all, std::ranges::views::, )
+SYMBOL(all_t, std::ranges::views::, )
+SYMBOL(as_const, std::ranges::views::, )
+SYMBOL(as_rvalue, std::ranges::views::, )
+SYMBOL(common, std::ranges::views::, )
+SYMBOL(counted, std::ranges::views::, )
+SYMBOL(drop, std::ranges::views::, )
+SYMBOL(drop_while, std::ranges::views::, )
+SYMBOL(elements, std::ranges::views::, )
+SYMBOL(empty, std::ranges::views::, )
+SYMBOL(filter, std::ranges::views::, )
+SYMBOL(iota, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(join, std::ranges::views::, )
+SYMBOL(join_with, std::ranges::views::, )
+SYMBOL(keys, std::ranges::views::, )
+SYMBOL(lazy_split, std::ranges::views::, )
+SYMBOL(reverse, std::ranges::views::, )
+SYMBOL(single, std::ranges::views::, )
+SYMBOL(split, std::ranges::views::, )
+SYMBOL(take, std::ranges::views::, )
+SYMBOL(take_while, std::ranges::views::, )
+SYMBOL(transform, std::ranges::views::, )
+SYMBOL(values, std::ranges::views::, )
+SYMBOL(zip, std::ranges::views::, )
+SYMBOL(zip_transform, std::ranges::views::, )
 SYMBOL(ECMAScript, std::regex_constants::, )
 SYMBOL(awk, std::regex_constants::, )
 SYMBOL(basic, std::regex_constants::, )
@@ -3817,3 +3844,30 @@ SYMBOL(get_id, std::this_thread::, )
 SYMBOL(sleep_for, std::this_thread::, )
 SYMBOL(sleep_until, std::this_thread::, )
 SYMBOL(yield, std::this_thread::, )
+SYMBOL(all, std::views::, )
+SYMBOL(all_t, std::views::, )
+SYMBOL(as_const, std::views::, )
+SYMBOL(as_rvalue, std::views::, )
+SYMBOL(common, std::views::, )
+SYMBOL(counted, std::views::, )
+SYMBOL(drop, std::views::, )
+SYMBOL(drop_while, std::views::, )
+SYMBOL(elements, std::views::, )
+SYMBOL(empty, std::views::, )
+SYMBOL(filter, std::views::, )
+SYMBOL(iota, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(join, std::views::, )
+SYMBOL(join_with, std::views::, )
+SYMBOL(keys, std::views::, )
+SYMBOL(lazy_split, std::views::, )
+SYMBOL(reverse, std::views::, )
+SYMBOL(single, std::views::, )
+SYMBOL(split, std::views::, )
+SYMBOL(take, std::views::, )
+SYMBOL(take_while, std::views::, )
+SYMBOL(transform, std::views::, )
+SYMBOL(values, std::views::, )
+SYMBOL(zip, std::views::, )
+SYMBOL(zip_transform, std::views::, )

diff  --git a/clang/tools/include-mapping/gen_std.py 
b/clang/tools/include-mapping/gen_std.py
index 2390ff1f2cced7..57a5a6772ba894 100755
--- a/clang/tools/include-mapping/gen_std.py
+++ b/clang/tools/include-mapping/gen_std.py
@@ -242,6 +242,11 @@ def main():
 (symbol_index_root, "filesystem.html", "std::filesystem::"),
 (symbol_index_root, "pmr.html", "std::pmr::"),
 (symbol_index_root, "ranges.html", "std::ranges::"),
+
+(symbol_index_root, "views.html", "std::ranges::views::"),
+# std::ranges::views can be accessed as std::views.
+(symbol_index_root, "views.html", "std::views::"),
+
 (symbol_index_root, "regex_constants.html", 
"std::regex_constants::"),
 (symbol_index_root, "this_thread.html", "std::this_thread::"),
 # Zombie symbols that were available from the Standard Library, 
but are



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


[PATCH] D156648: [Tooling/Inclusion] Add std::range symbols in the mapping.

2023-07-31 Thread Haojian Wu 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 rG171868dc2cd6: [Tooling/Inclusion] Add std::range symbols in 
the mapping. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156648

Files:
  clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -242,6 +242,11 @@
 (symbol_index_root, "filesystem.html", "std::filesystem::"),
 (symbol_index_root, "pmr.html", "std::pmr::"),
 (symbol_index_root, "ranges.html", "std::ranges::"),
+
+(symbol_index_root, "views.html", "std::ranges::views::"),
+# std::ranges::views can be accessed as std::views.
+(symbol_index_root, "views.html", "std::views::"),
+
 (symbol_index_root, "regex_constants.html", 
"std::regex_constants::"),
 (symbol_index_root, "this_thread.html", "std::this_thread::"),
 # Zombie symbols that were available from the Standard Library, 
but are
Index: clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
===
--- clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -3773,6 +3773,33 @@
 SYMBOL(wistream_view, std::ranges::, )
 SYMBOL(zip_transform_view, std::ranges::, )
 SYMBOL(zip_view, std::ranges::, )
+SYMBOL(all, std::ranges::views::, )
+SYMBOL(all_t, std::ranges::views::, )
+SYMBOL(as_const, std::ranges::views::, )
+SYMBOL(as_rvalue, std::ranges::views::, )
+SYMBOL(common, std::ranges::views::, )
+SYMBOL(counted, std::ranges::views::, )
+SYMBOL(drop, std::ranges::views::, )
+SYMBOL(drop_while, std::ranges::views::, )
+SYMBOL(elements, std::ranges::views::, )
+SYMBOL(empty, std::ranges::views::, )
+SYMBOL(filter, std::ranges::views::, )
+SYMBOL(iota, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(istream, std::ranges::views::, )
+SYMBOL(join, std::ranges::views::, )
+SYMBOL(join_with, std::ranges::views::, )
+SYMBOL(keys, std::ranges::views::, )
+SYMBOL(lazy_split, std::ranges::views::, )
+SYMBOL(reverse, std::ranges::views::, )
+SYMBOL(single, std::ranges::views::, )
+SYMBOL(split, std::ranges::views::, )
+SYMBOL(take, std::ranges::views::, )
+SYMBOL(take_while, std::ranges::views::, )
+SYMBOL(transform, std::ranges::views::, )
+SYMBOL(values, std::ranges::views::, )
+SYMBOL(zip, std::ranges::views::, )
+SYMBOL(zip_transform, std::ranges::views::, )
 SYMBOL(ECMAScript, std::regex_constants::, )
 SYMBOL(awk, std::regex_constants::, )
 SYMBOL(basic, std::regex_constants::, )
@@ -3817,3 +3844,30 @@
 SYMBOL(sleep_for, std::this_thread::, )
 SYMBOL(sleep_until, std::this_thread::, )
 SYMBOL(yield, std::this_thread::, )
+SYMBOL(all, std::views::, )
+SYMBOL(all_t, std::views::, )
+SYMBOL(as_const, std::views::, )
+SYMBOL(as_rvalue, std::views::, )
+SYMBOL(common, std::views::, )
+SYMBOL(counted, std::views::, )
+SYMBOL(drop, std::views::, )
+SYMBOL(drop_while, std::views::, )
+SYMBOL(elements, std::views::, )
+SYMBOL(empty, std::views::, )
+SYMBOL(filter, std::views::, )
+SYMBOL(iota, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(istream, std::views::, )
+SYMBOL(join, std::views::, )
+SYMBOL(join_with, std::views::, )
+SYMBOL(keys, std::views::, )
+SYMBOL(lazy_split, std::views::, )
+SYMBOL(reverse, std::views::, )
+SYMBOL(single, std::views::, )
+SYMBOL(split, std::views::, )
+SYMBOL(take, std::views::, )
+SYMBOL(take_while, std::views::, )
+SYMBOL(transform, std::views::, )
+SYMBOL(values, std::views::, )
+SYMBOL(zip, std::views::, )
+SYMBOL(zip_transform, std::views::, )


Index: clang/tools/include-mapping/gen_std.py
===
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -242,6 +242,11 @@
 (symbol_index_root, "filesystem.html", "std::filesystem::"),
 (symbol_index_root, "pmr.html", "std::pmr::"),
 (symbol_index_root, "ranges.html", "std::ranges::"),
+
+(symbol_index_root, "views.html", "std::ranges::views::"),
+# std::ranges::views can be accessed as std::views.
+(symbol_index_root, "views.html", "std::views::"),
+
 (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
 (symbol_index_root, "this_thread.html", "std::this_thread::"),
 # Zombie symbols that were available from the Standard Library, but are
Index: clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
===
-

[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 545589.
hokein marked an inline comment as done.
hokein added a comment.

address review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156650

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -78,6 +78,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -71,6 +71,8 @@
 bool mayConsiderUnused(
 const Inclusion &Inc, ParsedAST &AST,
 const include_cleaner::PragmaIncludes *PI) {
+  if (PI && PI->shouldKeep(Inc.HashLine + 1))
+  return false;
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@
   AST.getIncludeStructure().getRealPath(HID));
   assert(FE);
   if (PI) {
-if (PI->shouldKeep(Inc.HashLine + 1))
-  return false;
 // Check if main file is the public interface for a private header. If so 
we
 // shouldn't diagnose it as unused.
 if (auto PHeader = PI->getPublic(*FE); !PHeader.empty()) {


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -78,6 +78,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -71,6 +71,8 @@
 bool mayConsiderUnused(
 const Inclusion &Inc, ParsedAST &AST,
 const include_cleaner::PragmaIncludes *PI) {
+  if (PI && PI->shouldKeep(Inc.HashLine + 1))
+  return false;
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@
   AST.getIncludeStructure().getRealPath(HID));
   assert(FE);
   if (PI) {
-if (PI->shouldKeep(Inc.HashLine + 1))
-  return false;
 // Check if main file is the public interface for a private header. If so we
 // shouldn't diagnose it as unused.
 if (auto PHeader = PI->getPublic(*FE); !PHeader.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] dcb2824 - [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-07-31T13:21:54+02:00
New Revision: dcb28244faa88cb566a852533790bcac75daaa0f

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

LOG: [clangd] Respect IWYU keep pragma for standard headers.

see the issue https://github.com/llvm/llvm-project/issues/64191

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 8da42dba78f877..4a1ba484bfc492 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -71,6 +71,8 @@ bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter 
IgnoreHeaders) {
 bool mayConsiderUnused(
 const Inclusion &Inc, ParsedAST &AST,
 const include_cleaner::PragmaIncludes *PI) {
+  if (PI && PI->shouldKeep(Inc.HashLine + 1))
+  return false;
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@ bool mayConsiderUnused(
   AST.getIncludeStructure().getRealPath(HID));
   assert(FE);
   if (PI) {
-if (PI->shouldKeep(Inc.HashLine + 1))
-  return false;
 // Check if main file is the public interface for a private header. If so 
we
 // shouldn't diagnose it as unused.
 if (auto PHeader = PI->getPublic(*FE); !PHeader.empty()) {

diff  --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp 
b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
index c5d6ecfe4dcf61..afaba8aa68d1a7 100644
--- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -78,6 +78,8 @@ TEST(IncludeCleaner, StdlibUnused) {
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@ TEST(IncludeCleaner, StdlibUnused) {
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);



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


[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Haojian Wu 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 rGdcb28244faa8: [clangd] Respect IWYU keep pragma for standard 
headers. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156650

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -78,6 +78,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -71,6 +71,8 @@
 bool mayConsiderUnused(
 const Inclusion &Inc, ParsedAST &AST,
 const include_cleaner::PragmaIncludes *PI) {
+  if (PI && PI->shouldKeep(Inc.HashLine + 1))
+  return false;
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@
   AST.getIncludeStructure().getRealPath(HID));
   assert(FE);
   if (PI) {
-if (PI->shouldKeep(Inc.HashLine + 1))
-  return false;
 // Check if main file is the public interface for a private header. If so 
we
 // shouldn't diagnose it as unused.
 if (auto PHeader = PI->getPublic(*FE); !PHeader.empty()) {


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -78,6 +78,8 @@
   auto TU = TestTU::withCode(R"cpp(
 #include 
 #include 
+#include  // IWYU pragma: keep
+#include  // IWYU pragma: export
 std::list x;
   )cpp");
   // Layout of std library impl is not relevant.
@@ -86,10 +88,13 @@
 namespace std {
   template  class list {};
   template  class queue {};
+  template  class vector {};
 }
   )cpp";
   TU.AdditionalFiles["list"] = "#include ";
   TU.AdditionalFiles["queue"] = "#include ";
+  TU.AdditionalFiles["vector"] = "#include ";
+  TU.AdditionalFiles["string"] = "#include ";
   TU.ExtraArgs = {"-isystem", testRoot()};
   auto AST = TU.build();
   IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -71,6 +71,8 @@
 bool mayConsiderUnused(
 const Inclusion &Inc, ParsedAST &AST,
 const include_cleaner::PragmaIncludes *PI) {
+  if (PI && PI->shouldKeep(Inc.HashLine + 1))
+  return false;
   // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
   // System headers are likely to be standard library headers.
   // Until we have good support for umbrella headers, don't warn about them.
@@ -82,8 +84,6 @@
   AST.getIncludeStructure().getRealPath(HID));
   assert(FE);
   if (PI) {
-if (PI->shouldKeep(Inc.HashLine + 1))
-  return false;
 // Check if main file is the public interface for a private header. If so we
 // shouldn't diagnose it as unused.
 if (auto PHeader = PI->getPublic(*FE); !PHeader.empty()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5ea647d - [CodeGen] Assert that EmittedDeferredDecls is empty

2023-07-31 Thread Jonas Hahnfeld via cfe-commits

Author: Jonas Hahnfeld
Date: 2023-07-31T13:40:00+02:00
New Revision: 5ea647dea6355304b641bf7bc407db497c6d9d21

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

LOG: [CodeGen] Assert that EmittedDeferredDecls is empty

Its contents are transferred into DeferredDecls in Release(), so it
should be empty in moveLazyEmissionStates(). This matches the code
downstream in Cling.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 80c7ecedc28755..8d2abc69c330e7 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -7455,6 +7455,8 @@ void CodeGenModule::moveLazyEmissionStates(CodeGenModule 
*NewBuilder) {
   assert(NewBuilder->DeferredDecls.empty() &&
  "Newly created module should not have deferred decls");
   NewBuilder->DeferredDecls = std::move(DeferredDecls);
+  assert(EmittedDeferredDecls.empty() &&
+ "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   assert(NewBuilder->DeferredVTables.empty() &&
  "Newly created module should not have deferred vtables");
@@ -7470,10 +7472,5 @@ void CodeGenModule::moveLazyEmissionStates(CodeGenModule 
*NewBuilder) {
 
   NewBuilder->TBAA = std::move(TBAA);
 
-  assert(NewBuilder->EmittedDeferredDecls.empty() &&
- "Still have (unmerged) EmittedDeferredDecls deferred decls");
-
-  NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
-
   NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }



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


[PATCH] D156660: [CodeGen] Assert that EmittedDeferredDecls is empty

2023-07-31 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ea647dea635: [CodeGen] Assert that EmittedDeferredDecls is 
empty (authored by Hahnfeld).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156660

Files:
  clang/lib/CodeGen/CodeGenModule.cpp


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7455,6 +7455,8 @@
   assert(NewBuilder->DeferredDecls.empty() &&
  "Newly created module should not have deferred decls");
   NewBuilder->DeferredDecls = std::move(DeferredDecls);
+  assert(EmittedDeferredDecls.empty() &&
+ "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   assert(NewBuilder->DeferredVTables.empty() &&
  "Newly created module should not have deferred vtables");
@@ -7470,10 +7472,5 @@
 
   NewBuilder->TBAA = std::move(TBAA);
 
-  assert(NewBuilder->EmittedDeferredDecls.empty() &&
- "Still have (unmerged) EmittedDeferredDecls deferred decls");
-
-  NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
-
   NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }


Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -7455,6 +7455,8 @@
   assert(NewBuilder->DeferredDecls.empty() &&
  "Newly created module should not have deferred decls");
   NewBuilder->DeferredDecls = std::move(DeferredDecls);
+  assert(EmittedDeferredDecls.empty() &&
+ "Still have (unmerged) EmittedDeferredDecls deferred decls");
 
   assert(NewBuilder->DeferredVTables.empty() &&
  "Newly created module should not have deferred vtables");
@@ -7470,10 +7472,5 @@
 
   NewBuilder->TBAA = std::move(TBAA);
 
-  assert(NewBuilder->EmittedDeferredDecls.empty() &&
- "Still have (unmerged) EmittedDeferredDecls deferred decls");
-
-  NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
-
   NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156259: Fix a bug that erroneously placed function arguments on a new line despite all arguments being able to fit on the same line.

2023-07-31 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 545594.
jp4a50 added a comment.

Refactor DisallowLineBreaksOnThisLine lambda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156259

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22177,8 +22177,25 @@
"  }\n"
"};");
 
-  // Multiple lambdas in the same parentheses change indentation rules. These
-  // lambdas are forced to start on new lines.
+  // Lambdas that fit on a single line within an argument list are not forced
+  // onto new lines.
+  verifyFormat("SomeFunction([] {});");
+  verifyFormat("SomeFunction(0, [] {});");
+  verifyFormat("SomeFunction([] {}, 0);");
+  verifyFormat("SomeFunction(0, [] {}, 0);");
+  verifyFormat("SomeFunction([] { return 0; }, 0);");
+  verifyFormat("SomeFunction(a, [] { return 0; }, b);");
+  verifyFormat("SomeFunction([] { return 0; }, [] { return 0; });");
+  verifyFormat("SomeFunction([] { return 0; }, [] { return 0; }, b);");
+  verifyFormat("auto lng =\n"
+   "SomeFunction([] { return 0; }, [] { return 0; }, b);");
+  // Exceeded column limit. We need to break.
+  verifyFormat("auto lngName = SomeFunction(\n"
+   "[] { return anotherLooonngName; }, [] { "
+   "return 0; }, b);");
+
+  // Multiple multi-line lambdas in the same parentheses change indentation
+  // rules. These lambdas are always forced to start on new lines.
   verifyFormat("SomeFunction(\n"
"[]() {\n"
"  //\n"
@@ -22187,7 +22204,7 @@
"  //\n"
"});");
 
-  // A lambda passed as arg0 is always pushed to the next line.
+  // A multi-line lambda passed as arg0 is always pushed to the next line.
   verifyFormat("SomeFunction(\n"
"[this] {\n"
"  //\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5203,30 +5203,6 @@
   return true;
   }
 
-  // Deal with lambda arguments in C++ - we want consistent line breaks whether
-  // they happen to be at arg0, arg1 or argN. The selection is a bit nuanced
-  // as aggressive line breaks are placed when the lambda is not the last arg.
-  if ((Style.Language == FormatStyle::LK_Cpp ||
-   Style.Language == FormatStyle::LK_ObjC) &&
-  Left.is(tok::l_paren) && Left.BlockParameterCount > 0 &&
-  !Right.isOneOf(tok::l_paren, TT_LambdaLSquare)) {
-// Multiple lambdas in the same function call force line breaks.
-if (Left.BlockParameterCount > 1)
-  return true;
-
-// A lambda followed by another arg forces a line break.
-if (!Left.Role)
-  return false;
-auto Comma = Left.Role->lastComma();
-if (!Comma)
-  return false;
-auto Next = Comma->getNextNonComment();
-if (!Next)
-  return false;
-if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
-  return true;
-  }
-
   return false;
 }
 
Index: clang/lib/Format/ContinuationIndenter.h
===
--- clang/lib/Format/ContinuationIndenter.h
+++ clang/lib/Format/ContinuationIndenter.h
@@ -433,6 +433,9 @@
   /// literal sequence, 0 otherwise.
   unsigned StartOfStringLiteral;
 
+  /// Disallow line breaks for this line.
+  bool NoLineBreak;
+
   /// A stack keeping track of properties applying to parenthesis
   /// levels.
   SmallVector Stack;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -260,6 +260,7 @@
/*NoLineBreak=*/false));
   State.NoContinuation = false;
   State.StartOfStringLiteral = 0;
+  State.NoLineBreak = false;
   State.StartOfLineLevel = 0;
   State.LowestLevelOnLine = 0;
   State.IgnoreStackForComparison = false;
@@ -342,7 +343,7 @@
 return true;
   }
 
-  return !CurrentState.NoLineBreak;
+  return !State.NoLineBreak && !CurrentState.NoLineBreak;
 }
 
 bool ContinuationIndenter::mustBreak(const LineState &State) {
@@ -653,6 +654,47 @@
   const FormatToken &Previous = *State.NextToken->Previous;
   auto &CurrentState = State.Stack.back();
 
+  bool DisallowLineBreaksOnThisLine = [&Style = this->Style, &Current] {
+// Deal with lambda arguments in C++. The aim here is to ensure that we
+

[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Basic/Diagnostic.cpp:838-858
+  if (UseUCN)
+OutStream << "\\u"
+  << llvm::format_hex_no_prefix(CodepointValue, /*Width=*/4,
+/*Upper=*/false);
+  else
+OutStream << "(CharVal)};
+  pushEscapedString(StringRef(CharArr, sizeof(CharArr)), Str,
+/*UseUCN=*/true);
+}

A  different way to do that would be to have a 'Escape Whitespaces' parameter 
on pushEscapedString that would also escape \t, \n, etc (I don't think we want 
to escape SPACE)


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

https://reviews.llvm.org/D155610

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


[PATCH] D156259: Fix a bug that erroneously placed function arguments on a new line despite all arguments being able to fit on the same line.

2023-07-31 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 marked 3 inline comments as done.
jp4a50 added a comment.

All comments addressed. PTAL and let me know if there are any other blockers 
for merge.




Comment at: clang/lib/Format/ContinuationIndenter.cpp:664-666
+if ((Style.Language == FormatStyle::LK_Cpp ||
+ Style.Language == FormatStyle::LK_ObjC) &&
+!Current.is(tok::comment) && PrevNonComment &&

HazardyKnusperkeks wrote:
> jp4a50 wrote:
> > HazardyKnusperkeks wrote:
> > > jp4a50 wrote:
> > > > HazardyKnusperkeks wrote:
> > > > > Could move this out of the lambda.
> > > > Not sure exactly what you're referring to here. Initialization of 
> > > > `PrevNonComment`?
> > > > Not sure exactly what you're referring to here. Initialization of 
> > > > `PrevNonComment`?
> > > 
> > > No everything in the if before you go into the `PrevNonComment`. It is 
> > > highlighted if you hover the comment.
> > Ah, I see, thanks. Technically I could move that outside the lambda. I'm 
> > just not sure how it's better? Are you making the suggestion because it 
> > would make it clearer that this logic only applies to cpp/objc and/or 
> > because it means we could avoid capturing `Style`?
> Can do how you want, I think avoid capturing `Style` would be nice. And you 
> wouldn't search for `PrevNonComment` if you don't need to. This could also be 
> done be reordering the statements and a new `return`.
I kept all conditions inside the lambda in the end since moving any out would 
have made the `DisallowLineBreaksOnThisLine` not reflect all conditions and I 
wanted to keep that.

Instead I've changed all conditions to the style of early return for 
consistency and ordered them in the way that I think makes them most readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156259

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


[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This eliminates all uses of the deprecated accessors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156672

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp

Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -141,30 +141,26 @@
   Env.setValue(*LHSLoc, *RHSVal);
 
   // Assign a storage location for the whole expression.
-  Env.setStorageLocation(*S, *LHSLoc);
+  Env.setStorageLocationStrict(*S, *LHSLoc);
   break;
 }
 case BO_LAnd:
 case BO_LOr: {
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-
   BoolValue &LHSVal = getLogicOperatorSubExprValue(*LHS);
   BoolValue &RHSVal = getLogicOperatorSubExprValue(*RHS);
 
   if (S->getOpcode() == BO_LAnd)
-Env.setValue(Loc, Env.makeAnd(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeAnd(LHSVal, RHSVal));
   else
-Env.setValue(Loc, Env.makeOr(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeOr(LHSVal, RHSVal));
   break;
 }
 case BO_NE:
 case BO_EQ: {
   auto &LHSEqRHSValue = evaluateBooleanEquality(*LHS, *RHS, Env);
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-  Env.setValue(Loc, S->getOpcode() == BO_EQ ? LHSEqRHSValue
-: Env.makeNot(LHSEqRHSValue));
+  Env.setValueStrict(*S, S->getOpcode() == BO_EQ
+ ? LHSEqRHSValue
+ : Env.makeNot(LHSEqRHSValue));
   break;
 }
 case BO_Comma: {
@@ -238,7 +234,7 @@
   VisitDeclRefExpr(DE);
   VisitMemberExpr(ME);
 
-  if (auto *Loc = Env.getStorageLocation(*ME, SkipPast::Reference))
+  if (auto *Loc = Env.getStorageLocationStrict(*ME))
 Env.setStorageLocation(*B, *Loc);
 } else if (auto *VD = B->getHoldingVar()) {
   // Holding vars are used to back the `BindingDecl`s of tuple-like
@@ -283,9 +279,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, *SubExprVal);
+  Env.setValueStrict(*S, *SubExprVal);
   break;
 }
 
@@ -308,12 +302,9 @@
   break;
 }
 case CK_NullToPointer: {
-  auto &Loc = Env.createStorageLocation(S->getType());
-  Env.setStorageLocation(*S, Loc);
-
   auto &NullPointerVal =
   Env.getOrCreateNullPointerValue(S->getType()->getPointeeType());
-  Env.setValue(Loc, NullPointerVal);
+  Env.setValueStrict(*S, NullPointerVal);
   break;
 }
 case CK_NullToMemberPointer:
@@ -321,15 +312,11 @@
   // with this expression.
   break;
 case CK_FunctionToPointerDecay: {
-  StorageLocation *PointeeLoc =
-  Env.getStorageLocation(*SubExpr, SkipPast::Reference);
+  StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
   if (PointeeLoc == nullptr)
 break;
 
-  auto &PointerLoc = Env.createStorageLocation(*S);
-  auto &PointerVal = Env.create(*PointeeLoc);
-  Env.setStorageLocation(*S, PointerLoc);
-  Env.setValue(PointerLoc, PointerVal);
+  Env.setValueStrict(*S, Env.create(*PointeeLoc));
   break;
 }
 case CK_BuiltinFnToFnPtr:
@@ -371,9 +358,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, Env.makeNot(*SubExprVal));
+  Env.setValueStrict(*S, Env.makeNot(*SubExprVal));
   break;
 }
 default:
@@ -388,16 +373,12 @@
   // `this` expression's pointee.
   return;
 
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
-Env.setValue(Loc, Env.create(*ThisPointeeLoc));
+Env.setValueStrict(*S, Env.create(*ThisPointeeLoc));
   }
 
   void VisitCXXNewExpr(const CXXNewExpr *S) {
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
 if (Value *Val = Env.createValue(S->getType()))
-  Env.setValue(Loc, *Val);
+  Env.setValueStrict(*S, *Val);
   }
 
   void VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
@@ -450,7 +431,7 @@
 if (VarDeclLoc == nullptr)
   return;
 
-Env.setStorageLocation(*S, *VarDeclLoc);
+ 

[PATCH] D156673: [clang][dataflow] Remove deprecated accessors as well as `SkipPast`.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends On D156672 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156673

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -618,12 +618,6 @@
   return Loc;
 }
 
-void Environment::setStorageLocation(const Expr &E, StorageLocation &Loc) {
-  const Expr &CanonE = ignoreCFGOmittedNodes(E);
-  assert(!ExprToLoc.contains(&CanonE));
-  ExprToLoc[&CanonE] = &Loc;
-}
-
 void Environment::setStorageLocationStrict(const Expr &E,
StorageLocation &Loc) {
   // `DeclRefExpr`s to builtin function types aren't glvalues, for some reason,
@@ -631,26 +625,14 @@
   // so allow these as an exception.
   assert(E.isGLValue() ||
  E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
-  setStorageLocation(E, Loc);
-}
-
-StorageLocation *Environment::getStorageLocation(const Expr &E,
- SkipPast SP) const {
-  // FIXME: Add a test with parens.
-  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
-  return It == ExprToLoc.end() ? nullptr : &*It->second;
+  setStorageLocationInternal(E, Loc);
 }
 
 StorageLocation *Environment::getStorageLocationStrict(const Expr &E) const {
   // See comment in `setStorageLocationStrict()`.
   assert(E.isGLValue() ||
  E.getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn));
-  StorageLocation *Loc = getStorageLocation(E, SkipPast::None);
-
-  if (Loc == nullptr)
-return nullptr;
-
-  return Loc;
+  return getStorageLocationInternal(E);
 }
 
 AggregateStorageLocation *Environment::getThisPointeeStorageLocation() const {
@@ -662,12 +644,11 @@
   assert(RecordPRValue.getType()->isRecordType());
   assert(RecordPRValue.isPRValue());
 
-  if (StorageLocation *ExistingLoc =
-  getStorageLocation(RecordPRValue, SkipPast::None))
+  if (StorageLocation *ExistingLoc = getStorageLocationInternal(RecordPRValue))
 return *cast(ExistingLoc);
   auto &Loc = cast(
   DACtx->getStableStorageLocation(RecordPRValue));
-  setStorageLocation(RecordPRValue, Loc);
+  setStorageLocationInternal(RecordPRValue, Loc);
   return Loc;
 }
 
@@ -690,18 +671,18 @@
 cast_or_null(getValue(E)))
   assert(&ExistingVal->getAggregateLoc() == &StructVal->getAggregateLoc());
 if ([[maybe_unused]] StorageLocation *ExistingLoc =
-getStorageLocation(E, SkipPast::None))
+getStorageLocationInternal(E))
   assert(ExistingLoc == &StructVal->getAggregateLoc());
 else
-  setStorageLocation(E, StructVal->getAggregateLoc());
+  setStorageLocationInternal(E, StructVal->getAggregateLoc());
 setValue(StructVal->getAggregateLoc(), Val);
 return;
   }
 
-  StorageLocation *Loc = getStorageLocation(E, SkipPast::None);
+  StorageLocation *Loc = getStorageLocationInternal(E);
   if (Loc == nullptr) {
 Loc = &createStorageLocation(E);
-setStorageLocation(E, *Loc);
+setStorageLocationInternal(E, *Loc);
   }
   setValue(*Loc, Val);
 }
@@ -717,16 +698,11 @@
   return getValue(*Loc);
 }
 
-Value *Environment::getValue(const Expr &E, SkipPast SP) const {
-  auto *Loc = getStorageLocation(E, SP);
-  if (Loc == nullptr)
+Value *Environment::getValue(const Expr &E) const {
+  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
+  if (It == ExprToLoc.end())
 return nullptr;
-  return getValue(*Loc);
-}
-
-Value *Environment::getValueStrict(const Expr &E) const {
-  assert(E.isPRValue());
-  return getValue(E);
+  return getValue(*It->second);
 }
 
 Value *Environment::createValue(QualType Type) {
@@ -741,6 +717,18 @@
   return Val;
 }
 
+void Environment::setStorageLocationInternal(const Expr &E,
+ StorageLocation &Loc) {
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+  assert(!ExprToLoc.contains(&CanonE));
+  ExprToLoc[&CanonE] = &Loc;
+}
+
+StorageLocation *Environment::getStorageLocationInternal(const Expr &E) const {
+  auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
+  return It == ExprToLoc.end() ? nullptr : &*It->second;
+}
+
 Value *Environment::createValueUnlessSelfReferential(
 QualType Type, llvm::DenseSet &Visited, int Depth,
 int &CreatedValuesCount) {
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensiti

[PATCH] D156674: [clang][dataflow] Remove `Strict` suffix from accessors.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For the time being, we're keeping the `Strict` versions around as deprecated
synonyms so that clients can be migrated, but these synonyms will be removed
soon.

Depends On D156673 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156674

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
  clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.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
@@ -1243,7 +1243,7 @@
 match(callExpr(callee(functionDecl(hasName("makeTop".bind("top"),
   *S, getASTContext());
 if (const auto *E = selectFirst("top", Matches)) {
-  Env.setValueStrict(*E, Env.makeTopBoolValue());
+  Env.setValue(*E, Env.makeTopBoolValue());
 }
   }
 
Index: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -117,7 +117,7 @@
   auto *UnaryOpValue = State.Env.getValue(*UO);
   if (!UnaryOpValue) {
 UnaryOpValue = &State.Env.makeAtomicBoolValue();
-State.Env.setValueStrict(*UO, *UnaryOpValue);
+State.Env.setValue(*UO, *UnaryOpValue);
   }
 
   // Properties for the operand (sub expression).
@@ -137,7 +137,7 @@
 Comp = &V->formula();
   } else {
 Comp = &A.makeAtomRef(A.makeAtom());
-State.Env.setValueStrict(*BO, A.makeBoolValue(*Comp));
+State.Env.setValue(*BO, A.makeBoolValue(*Comp));
   }
 
   // FIXME Use this as well:
@@ -260,10 +260,10 @@
 Value *getOrCreateValue(const Expr *E, Environment &Env) {
   Value *Val = nullptr;
   if (E->isGLValue()) {
-StorageLocation *Loc = Env.getStorageLocationStrict(*E);
+StorageLocation *Loc = Env.getStorageLocation(*E);
 if (!Loc) {
   Loc = &Env.createStorageLocation(*E);
-  Env.setStorageLocationStrict(*E, *Loc);
+  Env.setStorageLocation(*E, *Loc);
 }
 Val = Env.getValue(*Loc);
 if (!Val) {
@@ -274,7 +274,7 @@
 Val = Env.getValue(*E);
 if (!Val) {
   Val = Env.createValue(E->getType());
-  Env.setValueStrict(*E, *Val);
+  Env.setValue(*E, *Val);
 }
   }
   assert(Val != nullptr);
Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -279,9 +279,9 @@
   ASSERT_THAT(DRE, NotNull());
 
   Environment Env(DAContext, *Target);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), IsNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), IsNull());
   refreshStructValue(*DRE, Env);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), NotNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), NotNull());
 }
 
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -135,7 +135,7 @@
 // for the condition expression, even if just an atom.
 if (Val == nullptr) {
   Val = &Env.makeAtomicBoolValue();
-  Env.setValueStrict(Cond, *Val);
+  Env.setValue(Cond, *Val);
 }
 
 bool ConditionValue = true;
@@ -402,7 +402,7 @@
   // the `AggregateStorageLocation` already exists. We should explore if there's
   // anything that we can do to change this.
   if (Member->getType()->isReferenceType()) {
-auto *InitExprLoc = Env.getStorageLocationStrict(*InitExpr);
+auto *InitExprLoc = Env.getStorageLocation(*InitExpr);
 if (InitExprLoc == nullptr)
   return;
 
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/

[PATCH] D156122: [include-cleaner] Introduce support for always_keep pragma

2023-07-31 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added inline comments.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Record.h:63
+  bool shouldKeep(unsigned HashLineNumber) const;
+  bool shouldKeep(const FileEntry *FE) const;
 

Why wouldn't you actually inline the implementation for both these functions? 
The implementations seem trivial enough. 



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:37
 #include 
+#include 
 

I don't think you've added a dependency on all these headers in this patch. 
Nice if you've actually fixed the missing include violations all over the file, 
but please double-check that there are no debugging etc. artefacts left.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:272
 
+FileID CommentFID = SM.getFileID(Range.getBegin());
+auto *FE = SM.getFileEntryForID(CommentFID);

You might want to inline this call, it seems to have a single usage right below.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:288
+if (Pragma->consume_front("always_keep")) {
+  Out->AlwaysKeep.insert(FE->getUniqueID());
+  return false;

I believe you need to check `FE` for `nullptr`, similar to private pragma 
handling above. 
Also, the code above does `FE->getLastRef().getUniqueID()`, is there any 
difference to `FE->getUniqueID()`? I wouldn't expect so, but then you could 
maybe unify this one with the above, this way or the other.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:421
+  return AlwaysKeep.contains(FE->getUniqueID());
+}
+

As mentioned above, consider inlining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156122

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


[PATCH] D156123: [include-cleaner] Unify always_keep with rest of the keep logic

2023-07-31 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added inline comments.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:248
+  if (Top.SeenAtFile == SM.getMainFileID() && IncludedFile)
+Out->ShouldKeep.insert(IncludedFile->getUniqueID());
 }

If I understand correctly, you should be able to extract `IncludedFile` from 
`IncludedHeader->physical()` and then you don't need the extra parameter.

Also, technically this and the below code used to work for standard and 
verbatim headers before this change. Now it probably won't, since there will be 
no corresponding `IncludedFile`. Is this actually something to worry about?



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:262
+  Out->ShouldKeep.insert(IncludedFile->getUniqueID());
+}
 

nit: remove braces.



Comment at: clang-tools-extra/include-cleaner/lib/Record.cpp:419
 bool PragmaIncludes::shouldKeep(const FileEntry *FE) const {
-  return AlwaysKeep.contains(FE->getUniqueID());
+  return ShouldKeep.contains(FE->getUniqueID());
 }

Consider inlining this function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156123

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


[PATCH] D156597: [Clang] Handle static_assert messages with an expression started by a literal

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1019
 
-if (isTokenStringLiteral())
-  AssertMessage = ParseUnevaluatedStringLiteralExpression();
-else if (getLangOpts().CPlusPlus26)
+bool ParseAsExression = false;
+if(getLangOpts().CPlusPlus26) {

tbaeder wrote:
> 
Oups, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156597

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


[PATCH] D156648: [Tooling/Inclusion] Add std::range symbols in the mapping.

2023-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D156648#4545863 , @kadircet wrote:

> can you also create a cherry-pick request for this patch once it lands?

Filed https://github.com/llvm/llvm-project/issues/64261.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156648

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


[PATCH] D156650: [clangd] Respect IWYU keep pragma for standard headers.

2023-07-31 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D156650#4545867 , @kadircet wrote:

> also we should get this cherry-picked too. `keep` pragmas on includes are not 
> common, but people do have export pragmas often enough to cause some 
> annoyance here.

Filed https://github.com/llvm/llvm-project/issues/64260.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156650

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


[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:542
+State.Env.getStorageLocationStrict(*E));
+if (!Loc) {
+  Loc =

`loc == nullptr`



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:545
+  &cast(State.Env.createStorageLocation(*E));
+  State.Env.setStorageLocationStrict(*E, *Loc);
+}

Should this line instead be outside of this `if`? So that the flow is
```
Loc = get
if (!Loc) Loc = create
set(Loc)
```



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:473-474
   if (S->isElidable()) {
-Env.setStorageLocation(*S, *ArgLoc);
-  } else if (auto *ArgVal = cast_or_null(Env.getValue(*Arg))) 
{
+if (Value *Val = Env.getValue(*ArgLoc))
+  Env.setValueStrict(*S, *Val);
+  } else {

What happens otherwise? I gather that `S` just isn't associated with anything?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156672

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


[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 545611.
mboehme added a comment.

Use `Loc == nullptr` instead of `!Loc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156672

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp

Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -141,30 +141,26 @@
   Env.setValue(*LHSLoc, *RHSVal);
 
   // Assign a storage location for the whole expression.
-  Env.setStorageLocation(*S, *LHSLoc);
+  Env.setStorageLocationStrict(*S, *LHSLoc);
   break;
 }
 case BO_LAnd:
 case BO_LOr: {
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-
   BoolValue &LHSVal = getLogicOperatorSubExprValue(*LHS);
   BoolValue &RHSVal = getLogicOperatorSubExprValue(*RHS);
 
   if (S->getOpcode() == BO_LAnd)
-Env.setValue(Loc, Env.makeAnd(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeAnd(LHSVal, RHSVal));
   else
-Env.setValue(Loc, Env.makeOr(LHSVal, RHSVal));
+Env.setValueStrict(*S, Env.makeOr(LHSVal, RHSVal));
   break;
 }
 case BO_NE:
 case BO_EQ: {
   auto &LHSEqRHSValue = evaluateBooleanEquality(*LHS, *RHS, Env);
-  auto &Loc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, Loc);
-  Env.setValue(Loc, S->getOpcode() == BO_EQ ? LHSEqRHSValue
-: Env.makeNot(LHSEqRHSValue));
+  Env.setValueStrict(*S, S->getOpcode() == BO_EQ
+ ? LHSEqRHSValue
+ : Env.makeNot(LHSEqRHSValue));
   break;
 }
 case BO_Comma: {
@@ -238,7 +234,7 @@
   VisitDeclRefExpr(DE);
   VisitMemberExpr(ME);
 
-  if (auto *Loc = Env.getStorageLocation(*ME, SkipPast::Reference))
+  if (auto *Loc = Env.getStorageLocationStrict(*ME))
 Env.setStorageLocation(*B, *Loc);
 } else if (auto *VD = B->getHoldingVar()) {
   // Holding vars are used to back the `BindingDecl`s of tuple-like
@@ -283,9 +279,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, *SubExprVal);
+  Env.setValueStrict(*S, *SubExprVal);
   break;
 }
 
@@ -308,12 +302,9 @@
   break;
 }
 case CK_NullToPointer: {
-  auto &Loc = Env.createStorageLocation(S->getType());
-  Env.setStorageLocation(*S, Loc);
-
   auto &NullPointerVal =
   Env.getOrCreateNullPointerValue(S->getType()->getPointeeType());
-  Env.setValue(Loc, NullPointerVal);
+  Env.setValueStrict(*S, NullPointerVal);
   break;
 }
 case CK_NullToMemberPointer:
@@ -321,15 +312,11 @@
   // with this expression.
   break;
 case CK_FunctionToPointerDecay: {
-  StorageLocation *PointeeLoc =
-  Env.getStorageLocation(*SubExpr, SkipPast::Reference);
+  StorageLocation *PointeeLoc = Env.getStorageLocationStrict(*SubExpr);
   if (PointeeLoc == nullptr)
 break;
 
-  auto &PointerLoc = Env.createStorageLocation(*S);
-  auto &PointerVal = Env.create(*PointeeLoc);
-  Env.setStorageLocation(*S, PointerLoc);
-  Env.setValue(PointerLoc, PointerVal);
+  Env.setValueStrict(*S, Env.create(*PointeeLoc));
   break;
 }
 case CK_BuiltinFnToFnPtr:
@@ -371,9 +358,7 @@
   if (SubExprVal == nullptr)
 break;
 
-  auto &ExprLoc = Env.createStorageLocation(*S);
-  Env.setStorageLocation(*S, ExprLoc);
-  Env.setValue(ExprLoc, Env.makeNot(*SubExprVal));
+  Env.setValueStrict(*S, Env.makeNot(*SubExprVal));
   break;
 }
 default:
@@ -388,16 +373,12 @@
   // `this` expression's pointee.
   return;
 
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
-Env.setValue(Loc, Env.create(*ThisPointeeLoc));
+Env.setValueStrict(*S, Env.create(*ThisPointeeLoc));
   }
 
   void VisitCXXNewExpr(const CXXNewExpr *S) {
-auto &Loc = Env.createStorageLocation(*S);
-Env.setStorageLocation(*S, Loc);
 if (Value *Val = Env.createValue(S->getType()))
-  Env.setValue(Loc, *Val);
+  Env.setValueStrict(*S, *Val);
   }
 
   void VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
@@ -450,7 +431,7 @@
 if (VarDeclLoc == nullptr)
   return;
 
-Env.setStorageLocation(*S, *VarDeclLoc);
+Env.setStorageLocationStrict(*S, *VarDeclLoc);
 return;
   }
 }
@@ -484,16 +465,17 @@
   assert(Arg

[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked 2 inline comments as done.
mboehme added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:545
+  &cast(State.Env.createStorageLocation(*E));
+  State.Env.setStorageLocationStrict(*E, *Loc);
+}

ymandel wrote:
> Should this line instead be outside of this `if`? So that the flow is
> ```
> Loc = get
> if (!Loc) Loc = create
> set(Loc)
> ```
I don't understand -- wouldn't this just be doing unnecessary work?

If

```
Loc = cast_or_null(
State.Env.getStorageLocationStrict(*E));
```

returns a non-null `Loc`, we don't create a new `Loc`, hence

```
State.Env.setStorageLocationStrict(*E, *Loc);
```

is a no-op, as `E` is already associated with `Loc`.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:473-474
   if (S->isElidable()) {
-Env.setStorageLocation(*S, *ArgLoc);
-  } else if (auto *ArgVal = cast_or_null(Env.getValue(*Arg))) 
{
+if (Value *Val = Env.getValue(*ArgLoc))
+  Env.setValueStrict(*S, *Val);
+  } else {

ymandel wrote:
> What happens otherwise? I gather that `S` just isn't associated with anything?
Correct. The idea being that if `S` is elidable, i.e. just a pass-through, we 
want to pass through any `StructValue` that we got, and so if we didn't get a 
`StructValue`, then we shouldn't pass one through.

I guess we could also just create a `StructValue` from scratch and associate it 
with `ArgLoc`, but I'm not sure that it makes much of a difference in practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156672

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


[PATCH] D156674: [clang][dataflow] Remove `Strict` suffix from accessors.

2023-07-31 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 545615.
mboehme added a comment.

Rebased to head


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156674

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
  clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.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
@@ -1243,7 +1243,7 @@
 match(callExpr(callee(functionDecl(hasName("makeTop".bind("top"),
   *S, getASTContext());
 if (const auto *E = selectFirst("top", Matches)) {
-  Env.setValueStrict(*E, Env.makeTopBoolValue());
+  Env.setValue(*E, Env.makeTopBoolValue());
 }
   }
 
Index: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp
@@ -117,7 +117,7 @@
   auto *UnaryOpValue = State.Env.getValue(*UO);
   if (!UnaryOpValue) {
 UnaryOpValue = &State.Env.makeAtomicBoolValue();
-State.Env.setValueStrict(*UO, *UnaryOpValue);
+State.Env.setValue(*UO, *UnaryOpValue);
   }
 
   // Properties for the operand (sub expression).
@@ -137,7 +137,7 @@
 Comp = &V->formula();
   } else {
 Comp = &A.makeAtomRef(A.makeAtom());
-State.Env.setValueStrict(*BO, A.makeBoolValue(*Comp));
+State.Env.setValue(*BO, A.makeBoolValue(*Comp));
   }
 
   // FIXME Use this as well:
@@ -260,10 +260,10 @@
 Value *getOrCreateValue(const Expr *E, Environment &Env) {
   Value *Val = nullptr;
   if (E->isGLValue()) {
-StorageLocation *Loc = Env.getStorageLocationStrict(*E);
+StorageLocation *Loc = Env.getStorageLocation(*E);
 if (!Loc) {
   Loc = &Env.createStorageLocation(*E);
-  Env.setStorageLocationStrict(*E, *Loc);
+  Env.setStorageLocation(*E, *Loc);
 }
 Val = Env.getValue(*Loc);
 if (!Val) {
@@ -274,7 +274,7 @@
 Val = Env.getValue(*E);
 if (!Val) {
   Val = Env.createValue(E->getType());
-  Env.setValueStrict(*E, *Val);
+  Env.setValue(*E, *Val);
 }
   }
   assert(Val != nullptr);
Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -279,9 +279,9 @@
   ASSERT_THAT(DRE, NotNull());
 
   Environment Env(DAContext, *Target);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), IsNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), IsNull());
   refreshStructValue(*DRE, Env);
-  EXPECT_THAT(Env.getStorageLocationStrict(*DRE), NotNull());
+  EXPECT_THAT(Env.getStorageLocation(*DRE), NotNull());
 }
 
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -135,7 +135,7 @@
 // for the condition expression, even if just an atom.
 if (Val == nullptr) {
   Val = &Env.makeAtomicBoolValue();
-  Env.setValueStrict(Cond, *Val);
+  Env.setValue(Cond, *Val);
 }
 
 bool ConditionValue = true;
@@ -402,7 +402,7 @@
   // the `AggregateStorageLocation` already exists. We should explore if there's
   // anything that we can do to change this.
   if (Member->getType()->isReferenceType()) {
-auto *InitExprLoc = Env.getStorageLocationStrict(*InitExpr);
+auto *InitExprLoc = Env.getStorageLocation(*InitExpr);
 if (InitExprLoc == nullptr)
   return;
 
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -74,7 +74,7 @@
 // value, if any unpacking occured. Also, does the lvalue-to-rvalue conversion,
 // by skipping past the reference.
 static Value *maybeUnpackLValueExpr(const Expr &E, Environment &Env) {
-  auto *Loc = Env.getStorageLocationStrict(E);
+  auto *Loc = Env.getStorage

[PATCH] D156597: [Clang] Handle static_assert messages with an expression started by a literal

2023-07-31 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 aside from minor nits.




Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1022
+  for(unsigned I = 0; ; ++I) {
+const Token & T = GetLookAheadToken(I);
+if(T.is(tok::r_paren))




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156597

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


[PATCH] D155393: [clang][Interp] Implement __builtin_isfpclass

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:225
+  const CallExpr *CE = cast(E);
+  PrimType FPClassArgT = *S.getContext().classify(CE->getArgs()[1]->getType());
+  APSInt FPClassArg = peekToAPSInt(S.Stk, FPClassArgT);

Should we add an assert that `[1]` is a valid index to read from?



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:232
+  static_cast((F.classify() & FPClassArg).getZExtValue());
+  S.Stk.push>(Integral<32, true>::from(Result));
+

Shouldn't this be pushing an `int`? (e.g., might not be 32 bits) -- same for 
the other builtins, now that I look at them.



Comment at: clang/lib/AST/Interp/PrimType.h:135
+default:   
\
+  llvm_unreachable("Not an integer value");
\
+}  
\

BitInt comes to mind. ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155393

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


[PATCH] D155430: [clang][Interp] Implement __arithmethic_fence for floating types

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: Izaron.
aaron.ballman added a comment.

Hmmm, something is weird here. The original patch adding the LLVM intrinsic is 
https://reviews.llvm.org/D99675 and that says: `The invocation of 
__arithmetic_fence is not a C/C++ constant expression, even if the operands are 
constant.` yet https://reviews.llvm.org/D136036 changed arithmetic fence to be 
a constant expression. I think that was a mistake and we should back that bit 
of the change out. WDYT @Izaron ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155430

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


[PATCH] D156286: [docs] Bump minimum GCC version to 7.5

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156286#4544631 , @MaskRay wrote:

> In D156286#4534968 , @aaron.ballman 
> wrote:
>
>> There's a mention on the RFC thread that Ubuntu 18.04 still ships with GCC 
>> 7.3. That's an LTS release but it EOLed just last month, so it's not clear 
>> how disruptive this would be. (To be clear, I'm not saying I'm opposed to 
>> the changes.)
>
> The entire 16.x releases `LLVMAnalysis` cannot be built with GCC 7.3, so this 
> CMake change shouldn't be a larger disruption to any GCC <= 7.3 user.
> And we should get the GCC bump patch into 17.x so that users will not get 
> confused by the supportness.
>
> The question is whether we bump to 7.4 or 7.5. I'd prefer 7.5, as there 
> appears to be more users on 7.5 and can verify that 7.5 works reliably.
>
> There is a user who prefers 7.4 but 7.5 works for them.
> https://discourse.llvm.org/t/require-gcc-7-5-as-gcc-7-3-cannot-build-llvm-16-x-or-main/72310/29
>  says that Ubuntu 18.04 (End of Standard Support in June 2023) gets GCC 7.5 
> updates.

Okay, it sounds like the changes won't be particularly disruptive then, so this 
is reasonable to me. Thank you!




Comment at: llvm/docs/GettingStarted.rst:284-298
 `python `_  >=3.6
Automated test suite\ :sup:`2`
 `zlib `_   >=1.2.3.4
Compression library\ :sup:`3`
 `GNU Make `_ 3.79, 3.79.1 
Makefile/build processor\ :sup:`4`
 ===  
==
 
 .. note::
 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D156286: [docs] Bump minimum GCC version to 7.5

2023-07-31 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.

LG with the minor cleanup I found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D156604: [clang][ExprConst] Use call source range for 'in call to' diags

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> As you can see I have a test case, but I didn't attach it in 
> test/Misc/constexpr-source-ranges.cpp because I can't get 
> -fdiagnostics-print-source-range-info to actually print anything for them.

That's odd; have you investigated what's going on/filed an issue?

The changes LG, but the lack of test coverage gives me pause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156604

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


[PATCH] D156259: Fix a bug that erroneously placed function arguments on a new line despite all arguments being able to fit on the same line.

2023-07-31 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 updated this revision to Diff 545622.
jp4a50 marked an inline comment as done.
jp4a50 added a comment.

Formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156259

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22177,8 +22177,25 @@
"  }\n"
"};");
 
-  // Multiple lambdas in the same parentheses change indentation rules. These
-  // lambdas are forced to start on new lines.
+  // Lambdas that fit on a single line within an argument list are not forced
+  // onto new lines.
+  verifyFormat("SomeFunction([] {});");
+  verifyFormat("SomeFunction(0, [] {});");
+  verifyFormat("SomeFunction([] {}, 0);");
+  verifyFormat("SomeFunction(0, [] {}, 0);");
+  verifyFormat("SomeFunction([] { return 0; }, 0);");
+  verifyFormat("SomeFunction(a, [] { return 0; }, b);");
+  verifyFormat("SomeFunction([] { return 0; }, [] { return 0; });");
+  verifyFormat("SomeFunction([] { return 0; }, [] { return 0; }, b);");
+  verifyFormat("auto lng =\n"
+   "SomeFunction([] { return 0; }, [] { return 0; }, b);");
+  // Exceeded column limit. We need to break.
+  verifyFormat("auto lngName = SomeFunction(\n"
+   "[] { return anotherLooonngName; }, [] { "
+   "return 0; }, b);");
+
+  // Multiple multi-line lambdas in the same parentheses change indentation
+  // rules. These lambdas are always forced to start on new lines.
   verifyFormat("SomeFunction(\n"
"[]() {\n"
"  //\n"
@@ -22187,7 +22204,7 @@
"  //\n"
"});");
 
-  // A lambda passed as arg0 is always pushed to the next line.
+  // A multi-line lambda passed as arg0 is always pushed to the next line.
   verifyFormat("SomeFunction(\n"
"[this] {\n"
"  //\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5203,30 +5203,6 @@
   return true;
   }
 
-  // Deal with lambda arguments in C++ - we want consistent line breaks whether
-  // they happen to be at arg0, arg1 or argN. The selection is a bit nuanced
-  // as aggressive line breaks are placed when the lambda is not the last arg.
-  if ((Style.Language == FormatStyle::LK_Cpp ||
-   Style.Language == FormatStyle::LK_ObjC) &&
-  Left.is(tok::l_paren) && Left.BlockParameterCount > 0 &&
-  !Right.isOneOf(tok::l_paren, TT_LambdaLSquare)) {
-// Multiple lambdas in the same function call force line breaks.
-if (Left.BlockParameterCount > 1)
-  return true;
-
-// A lambda followed by another arg forces a line break.
-if (!Left.Role)
-  return false;
-auto Comma = Left.Role->lastComma();
-if (!Comma)
-  return false;
-auto Next = Comma->getNextNonComment();
-if (!Next)
-  return false;
-if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
-  return true;
-  }
-
   return false;
 }
 
Index: clang/lib/Format/ContinuationIndenter.h
===
--- clang/lib/Format/ContinuationIndenter.h
+++ clang/lib/Format/ContinuationIndenter.h
@@ -433,6 +433,9 @@
   /// literal sequence, 0 otherwise.
   unsigned StartOfStringLiteral;
 
+  /// Disallow line breaks for this line.
+  bool NoLineBreak;
+
   /// A stack keeping track of properties applying to parenthesis
   /// levels.
   SmallVector Stack;
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -260,6 +260,7 @@
/*NoLineBreak=*/false));
   State.NoContinuation = false;
   State.StartOfStringLiteral = 0;
+  State.NoLineBreak = false;
   State.StartOfLineLevel = 0;
   State.LowestLevelOnLine = 0;
   State.IgnoreStackForComparison = false;
@@ -342,7 +343,7 @@
 return true;
   }
 
-  return !CurrentState.NoLineBreak;
+  return !State.NoLineBreak && !CurrentState.NoLineBreak;
 }
 
 bool ContinuationIndenter::mustBreak(const LineState &State) {
@@ -653,6 +654,48 @@
   const FormatToken &Previous = *State.NextToken->Previous;
   auto &CurrentState = State.Stack.back();
 
+  bool DisallowLineBreaksOnThisLine = [&Style = this->Style, &Current] {
+// Deal with lambda arguments in C++. The aim here is to ensure that w

[PATCH] D156686: [AST] Simplify Type::isSizelessBuiltinType(). NFC.

2023-07-31 Thread Jim Lin via Phabricator via cfe-commits
Jim created this revision.
Herald added subscribers: ctetreau, s.egerton, simoncook.
Herald added a project: All.
Jim requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

Reuse isSVESizelessBuiltinType() and isRVVSizelessBuiltinType().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156686

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2353,14 +2353,14 @@
 }
 
 bool Type::isSizelessBuiltinType() const {
+  if (isSVESizelessBuiltinType())
+return true;
+
+  if (isRVVSizelessBuiltinType())
+return true;
+
   if (const BuiltinType *BT = getAs()) {
 switch (BT->getKind()) {
-  // SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/RISCVVTypes.def"
-  return true;
   // WebAssembly reference types
 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/WebAssemblyReferenceTypes.def"


Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2353,14 +2353,14 @@
 }
 
 bool Type::isSizelessBuiltinType() const {
+  if (isSVESizelessBuiltinType())
+return true;
+
+  if (isRVVSizelessBuiltinType())
+return true;
+
   if (const BuiltinType *BT = getAs()) {
 switch (BT->getKind()) {
-  // SVE Types
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/AArch64SVEACLETypes.def"
-#define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
-#include "clang/Basic/RISCVVTypes.def"
-  return true;
   // WebAssembly reference types
 #define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156597: [Clang] Handle static_assert messages with an expression started by a literal

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 545627.
cor3ntin added a comment.

Typo + format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156597

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp


Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- clang/test/SemaCXX/static-assert-cxx26.cpp
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -65,6 +65,10 @@
 }
 };
 
+constexpr string_view operator+(auto, string_view S) {
+return S;
+}
+
 constexpr const char g_[] = "long string";
 
 template 
@@ -79,6 +83,11 @@
 };
 
 static_assert(false, string_view("test")); // expected-error {{static 
assertion failed: test}}
+static_assert(false, "Literal" + string_view("test")); // expected-error 
{{static assertion failed: test}}
+static_assert(false, L"Wide Literal" + string_view("test")); // expected-error 
{{static assertion failed: test}}
+static_assert(false, "Wild" "Literal" "Concatenation" + string_view("test")); 
// expected-error {{static assertion failed: test}}
+static_assert(false, "Wild" "Literal" L"Concatenation" + string_view("test")); 
// expected-error {{static assertion failed: test}}
+static_assert(false, "Wild" u"Literal" L"Concatenation" + 
string_view("test")); // expected-error {{unsupported non-standard 
concatenation of string literals}}
 static_assert(false, string_view("😀")); // expected-error {{static assertion 
failed: 😀}}
 static_assert(false, string_view(0, nullptr)); // expected-error {{static 
assertion failed:}}
 static_assert(false, string_view(1, "ABC")); // expected-error {{static 
assertion failed: A}}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1016,10 +1016,23 @@
   return nullptr;
 }
 
-if (isTokenStringLiteral())
-  AssertMessage = ParseUnevaluatedStringLiteralExpression();
-else if (getLangOpts().CPlusPlus26)
+bool ParseAsExpression = false;
+if (getLangOpts().CPlusPlus26) {
+  for (unsigned I = 0;; ++I) {
+const Token &T = GetLookAheadToken(I);
+if (T.is(tok::r_paren))
+  break;
+if (T.isNot(tok::string_literal)) {
+  ParseAsExpression = true;
+  break;
+}
+  }
+}
+
+if (ParseAsExpression)
   AssertMessage = ParseConstantExpressionInExprEvalContext();
+else if (isTokenStringLiteral())
+  AssertMessage = ParseUnevaluatedStringLiteralExpression();
 else {
   Diag(Tok, diag::err_expected_string_literal)
   << /*Source='static_assert'*/ 1;


Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- clang/test/SemaCXX/static-assert-cxx26.cpp
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -65,6 +65,10 @@
 }
 };
 
+constexpr string_view operator+(auto, string_view S) {
+return S;
+}
+
 constexpr const char g_[] = "long string";
 
 template 
@@ -79,6 +83,11 @@
 };
 
 static_assert(false, string_view("test")); // expected-error {{static assertion failed: test}}
+static_assert(false, "Literal" + string_view("test")); // expected-error {{static assertion failed: test}}
+static_assert(false, L"Wide Literal" + string_view("test")); // expected-error {{static assertion failed: test}}
+static_assert(false, "Wild" "Literal" "Concatenation" + string_view("test")); // expected-error {{static assertion failed: test}}
+static_assert(false, "Wild" "Literal" L"Concatenation" + string_view("test")); // expected-error {{static assertion failed: test}}
+static_assert(false, "Wild" u"Literal" L"Concatenation" + string_view("test")); // expected-error {{unsupported non-standard concatenation of string literals}}
 static_assert(false, string_view("😀")); // expected-error {{static assertion failed: 😀}}
 static_assert(false, string_view(0, nullptr)); // expected-error {{static assertion failed:}}
 static_assert(false, string_view(1, "ABC")); // expected-error {{static assertion failed: A}}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1016,10 +1016,23 @@
   return nullptr;
 }
 
-if (isTokenStringLiteral())
-  AssertMessage = ParseUnevaluatedStringLiteralExpression();
-else if (getLangOpts().CPlusPlus26)
+bool ParseAsExpression = false;
+if (getLangOpts().CPlusPlus26) {
+  for (unsigned I = 0;; ++I) {
+const Token &T = GetLookAheadToken(I);
+if (T.is(tok::r_paren))
+  break;
+if (T.isNot(tok::string_literal)) {
+  ParseAsExpression = true;
+  break;
+}
+  }
+}
+
+if (ParseAsExpression)
   AssertMessage = ParseConstantExpressio

[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-07-31 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! Do you need me to commit this on your behalf? If so, what name and email 
address would you like me to use for patch attribution?


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

https://reviews.llvm.org/D151373

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-07-31 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

Looking pretty good, if you can address the last few bits of feedback I am 
happy to merge this.




Comment at: clang/include/clang/ExtractAPI/API.h:770
+template <>
+struct has_function_signature : public std::true_type {};
+

Does `CXXInstanceMethodRecord` need one of these as well?



Comment at: clang/include/clang/ExtractAPI/DeclarationFragments.h:26
 #include "clang/AST/DeclObjC.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Lex/MacroInfo.h"

Are these necessary?



Comment at: clang/include/clang/ExtractAPI/DeclarationFragments.h:190
+public:
+  AccessControl() = default;
+

For ergonomics would it make more sense to have a constructor that takes the 
string in directly and moves it to `Access`? I don't think there are any 
situation where you want to change the access string after the fact?



Comment at: clang/include/clang/ExtractAPI/DeclarationFragments.h:251
+  template 
+  static FunctionSignature getFunctionSignature(const FunctionT *Function) {
+FunctionSignature Signature;

I assume the implementation of this moved because it was needed for C++ 
methods? Can you update the comment and maybe move the implementation to the 
bottom of the `.h` file?



Comment at: clang/lib/ExtractAPI/DeclarationFragments.cpp:614
+  } else if (isa(Method))
+// TODO: add '~'
+Name = cast(Method->getDeclContext())->getName();

Please address this, it's pretty important imo.



Comment at: clang/test/ExtractAPI/methods.cpp:13
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:

I think these are redundant since you have `// expected-no-diagnostics` below 
and pass ``--verify`` to cc1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D154038: [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

2023-07-31 Thread Daniel Grumberg via Phabricator via cfe-commits
dang accepted this revision.
dang added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154038

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


[PATCH] D154130: [lit][clang] Avoid realpath on Windows due to MAX_PATH limitations

2023-07-31 Thread Tristan Labelle via Phabricator via cfe-commits
MrTrillian marked 4 inline comments as done.
MrTrillian added a comment.

Resolved remaining comments addressed with the FileManager.cpp change to branch 
on the native path format being Windows. This is ready to merge!


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

https://reviews.llvm.org/D154130

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


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: hubert.reinterpretcast.
aaron.ballman added a comment.

Please add more details to the patch summary explaining why you're making these 
changes. Also, I assume this is to be backported to Clang 17? If so, I'd like 
@hubert.reinterpretcast to mention if this works for his needs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156596

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


[PATCH] D154189: [clang][Interp] Implement zero-init of record types

2023-07-31 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


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

https://reviews.llvm.org/D154189

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


[PATCH] D155809: [NFC] [Clang] Fix strict weak ordering in ItaniumVTableBuilder

2023-07-31 Thread Danila Kutenin via Phabricator via cfe-commits
danlark added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155809

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


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Oups, sorry, the context is this PR https://reviews.llvm.org/D105759#4543246


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156596

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


[PATCH] D156596: [Clang] Produce a warning instead of an error in unevaluated strings before C++26

2023-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156596#4546787 , @cor3ntin wrote:

> Oups, sorry, the context is this PR https://reviews.llvm.org/D105759#4543246

I kind of figured. :-) But we want the context in the patch summary since 
that's what typically makes it to the commit message, and we don't want folks 
doing code archeology to have to click through to figure that context out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156596

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


[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

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

Retracting from review. I think I was overly hasty with this change:

- There are edges between expressions that cross CFG block boundaries but don't 
involve block terminators. Here's an example  
-- [B1 .1] has [B2 
.1] as a child, yet [B2 
] doesn't even have a terminator.

- More fundamentally, convergence is not only important when considering the 
environment as an input to successor blocks, but also as a basis for the 
diagnostics that we will emit, which may look at arbitrary expressions in the 
block. So we really want all expressions to be fully converged.

It looks as if, instead, what we should be doing to improve convergence in a 
sound manner is to implement widening for `ExprToLoc`. I'll submit a 
corresponding patch shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156658

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-07-31 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D156363#4546171 , @dyung wrote:

> In D156363#4545474 , @MaskRay wrote:
>
>> In D156363#4545215 , @dyung wrote:
>>
>>> If you cannot reproduce this issue, I can take my buildbot offline and try 
>>> to reproduce it to pinpoint which command is causing the problem, but I 
>>> won’t be able to do so until Monday.
>>
>> Thank you, knowing which command caused the failure will be very helpful.
>> `clang/test/Driver/fsanitize.c` has the most mysterious failure I have dealt 
>> with for this patch.
>>
>> FWIW I've checked that the test passes even if `/usr` does not exist 
>> (emulated by proot) => there is as if no host GCC installation that could 
>> affect Driver's behavior
>>
>>   % cat /tmp/Rel/bin/xxx
>>   #!/bin/zsh
>>   d=$(dirname "$0")
>>   exec proot -R /tmp -b /bin -b /lib64 -b /lib $d/clang 
>> --target=aarch64-linux-musl "$@"
>>   % cd clang/test/Driver
>>   % CLANG=/tmp/Rel/bin/xxx /tmp/Rel/bin/llvm-lit -vv fsanitize.c
>>   .. passed
>
> I have to run, but I did a quick -vv run with this commit and it seems to 
> fail on the RUN line on 588:
>
>   + : 'RUN: at line 581'
>   + /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
> --target=i386-apple-ios-simulator -fsanitize=leak 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  -###
>   + 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  --check-prefix=CHECK-LSAN-I386-IOSSIMULATOR
>   + : 'RUN: at line 584'
>   + /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
> --target=i386-apple-tvos-simulator -fsanitize=leak 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  -###
>   + 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  --check-prefix=CHECK-LSAN-I386-TVOSSIMULATOR
>   + : 'RUN: at line 588'
>   + not 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
> --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -c 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  -###
>   + 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>  --check-prefix=CHECK-CFI
>   
>   --
>   
>   
>   
>   Failed Tests (1):
> Clang :: Driver/fsanitize.c
>
> I'll try to look more later when I get more time.

It appears that the clang command in the RUN line returns 0 which the `not` you 
added inverts it causing the test to fail:

  
buildbot@6a3c0c51ae89:~/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver$
 /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
--target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -c 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize2.c
 -###
  clang version 18.0.0 (https://github.com/llvm/llvm-project.git 
8c3550b1a78fde7bf28f420da8447d9fde37017f)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin
   (in-process)
   
"/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang-18" 
"-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-flto=full" 
"-flto-unit" "-disable-free" "-clear-ast-before-backend" "-main-file-name" 
"fsanitize2.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" 
"-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" 
"-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" 
"generic" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver"
 "-resource-dir" 
"/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/18" 
"-internal-isystem" 
"/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/18/include"
 "-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include" 
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
"-internal-externc-isystem" "/include" "-internal-externc-isystem" 
"/usr/include" 
"-fdebug-compilation-dir=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver"
 "-ferror-limit" "19" "-fvisibility=hidden" 
"-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfca

[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

In D156539#4542836 , @rjmccall wrote:

> We should probably write this code to work properly in case we add a target 
> that makes `__builtin_alloca` return a pointer in the private address space.  
> Could you recover the target AS from the type of the expression instead of 
> assuming `LangAS::Default`?

I believe it should work as written (it is possible that I misunderstand the 
objection, case in which I do apologise). The issue is precisely that for some 
targets (amdgcn being one) `alloca` returns a pointer to private, which doesn't 
compose with the default AS being unspecified / nonexistent, for some languages 
(e.g. HIP,  C/C++ etc.). For the OCL case @arsenm mentions, I believe that we 
make a choice based on `LangOpts.OpenCLGenericAddressSpace`, and the code above 
would only be valid from the OCL language perspective iff that is true. I've 
put together a short Godbolt that captures these (and the bug the patch should 
fix, please see the bitcasts between ASes in the non-OCL case): 
https://gcc.godbolt.org/z/sYGK76zqv.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156539

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


[PATCH] D156693: [clang][ASTImporter]Don't add template decl as in friend decl

2023-07-31 Thread Qizhi Hu via Phabricator via cfe-commits
jcsxky created this revision.
jcsxky added reviewers: a.sidorin, shafik, balazske, steakhal.
jcsxky added a project: clang.
Herald added a subscriber: martong.
Herald added a project: All.
jcsxky requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.

There is no need to add a ``` NameDecl ``` into ``` LookupTable ```when it is 
declared in friend declaration located in the template class definition. If 
it's ``` FriendType ```, then ``` VisitFriendDecl ``` can help us do it, or it 
is in declaring in current class definition, this has been processed by ``` 
VisitNamedDecl ``` before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156693

Files:
  clang/lib/AST/ASTImporterLookupTable.cpp
  clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
  clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
  clang/test/Analysis/Inputs/ctu-friend-template.h
  clang/test/Analysis/ctu-friend-template.cpp


Index: clang/test/Analysis/ctu-friend-template.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-friend-template.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-friend-template-other.cpp.ast 
%S/Inputs/ctu-friend-template-other.cpp
+// RUN: cp %S/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt 
%t/ctudir/externalDefMap.txt
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -Werror=ctu \
+// RUN:   -verify %s
+
+// CHECK: CTU loaded AST file
+
+#include "Inputs/ctu-friend-template.h"
+
+void bar();
+
+int main(){
+   bar(); // expected-no-diagnostics
+}
Index: clang/test/Analysis/Inputs/ctu-friend-template.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.h
@@ -0,0 +1,20 @@
+namespace __1{
+
+template
+class A;
+
+template
+class A{
+public:
+   template
+   friend class A;
+
+   A(T x):x(x){}
+   
+   void foo(){}
+   
+private:
+   T x;
+};
+
+}
Index: 
clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
@@ -0,0 +1 @@
+9:c:@F@bar# ctu-friend-template-other.cpp.ast
Index: clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
@@ -0,0 +1,6 @@
+#include "ctu-friend-template.h"
+
+void bar(){
+   __1::A a1(0);
+   a1.foo();
+}
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/ASTImporterLookupTable.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/ParentMapContext.h"
 #include "llvm/Support/FormatVariadic.h"
 
 namespace clang {
@@ -38,6 +39,10 @@
   }
 
   bool VisitNamedDecl(NamedDecl *D) {
+auto Parents = D->getASTContext().getParents(*D);
+if (!Parents.empty() && nullptr != Parents.begin()->get()) {
+  return true;
+}
 LT.add(D);
 return true;
   }


Index: clang/test/Analysis/ctu-friend-template.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-friend-template.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-friend-template-other.cpp.ast %S/Inputs/ctu-friend-template-other.cpp
+// RUN: cp %S/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt %t/ctudir/externalDefMap.txt
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -Werror=ctu \
+// RUN:   -verify %s
+
+// CHECK: CTU loaded AST file
+
+#include "Inputs/ctu-friend-template.h"
+
+void bar();
+
+int main(){
+	bar(); // expected-no-diagnostics
+}
Index: clang/test/Analysis/Inputs/ctu-friend-template.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.h
@@ -0,0 +1,20 @@
+namespace __1{
+
+template
+class A;
+
+template
+class A{
+public:
+	template
+	friend class A;
+
+	A(T x):x(x){}
+	
+	void foo(){}
+	
+p

[PATCH] D156588: feat: Add support for Rocky Linux to LLVM Distro

2023-07-31 Thread xufei via Phabricator via cfe-commits
zkkxu added a comment.

nice ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156588

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


[PATCH] D156672: [clang][dataflow] Use `Strict` accessors where we weren't using them yet.

2023-07-31 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.

SGTM




Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:545
+  &cast(State.Env.createStorageLocation(*E));
+  State.Env.setStorageLocationStrict(*E, *Loc);
+}

mboehme wrote:
> ymandel wrote:
> > Should this line instead be outside of this `if`? So that the flow is
> > ```
> > Loc = get
> > if (!Loc) Loc = create
> > set(Loc)
> > ```
> I don't understand -- wouldn't this just be doing unnecessary work?
> 
> If
> 
> ```
> Loc = cast_or_null(
> State.Env.getStorageLocationStrict(*E));
> ```
> 
> returns a non-null `Loc`, we don't create a new `Loc`, hence
> 
> ```
> State.Env.setStorageLocationStrict(*E, *Loc);
> ```
> 
> is a no-op, as `E` is already associated with `Loc`.
Right, I was not paying enough attention. I was thinking specifically about the 
value. basically, i confused line 545 for line 549.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156672

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


[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

2023-07-31 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

> It looks as if, instead, what we should be doing to improve convergence in a 
> sound manner is to implement widening for ExprToLoc. I'll submit a 
> corresponding patch shortly.

+1, I believe we want `ExprToLoc` to converge. That being said, if we can get 
away with not checking some parts, it could potentially be implemented as an 
optimization. In that case, I'd expect to still have full checking in debug 
builds and a strong argument why is it OK to not compare some parts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156658

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-07-31 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D156363#4546818 , @dyung wrote:

> In D156363#4546171 , @dyung wrote:
>
>> In D156363#4545474 , @MaskRay 
>> wrote:
>>
>>> In D156363#4545215 , @dyung wrote:
>>>
 If you cannot reproduce this issue, I can take my buildbot offline and try 
 to reproduce it to pinpoint which command is causing the problem, but I 
 won’t be able to do so until Monday.
>>>
>>> Thank you, knowing which command caused the failure will be very helpful.
>>> `clang/test/Driver/fsanitize.c` has the most mysterious failure I have 
>>> dealt with for this patch.
>>>
>>> FWIW I've checked that the test passes even if `/usr` does not exist 
>>> (emulated by proot) => there is as if no host GCC installation that could 
>>> affect Driver's behavior
>>>
>>>   % cat /tmp/Rel/bin/xxx
>>>   #!/bin/zsh
>>>   d=$(dirname "$0")
>>>   exec proot -R /tmp -b /bin -b /lib64 -b /lib $d/clang 
>>> --target=aarch64-linux-musl "$@"
>>>   % cd clang/test/Driver
>>>   % CLANG=/tmp/Rel/bin/xxx /tmp/Rel/bin/llvm-lit -vv fsanitize.c
>>>   .. passed
>>
>> I have to run, but I did a quick -vv run with this commit and it seems to 
>> fail on the RUN line on 588:
>>
>>   + : 'RUN: at line 581'
>>   + 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
>> --target=i386-apple-ios-simulator -fsanitize=leak 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  -###
>>   + 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck
>>  
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  --check-prefix=CHECK-LSAN-I386-IOSSIMULATOR
>>   + : 'RUN: at line 584'
>>   + 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
>> --target=i386-apple-tvos-simulator -fsanitize=leak 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  -###
>>   + 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck
>>  
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  --check-prefix=CHECK-LSAN-I386-TVOSSIMULATOR
>>   + : 'RUN: at line 588'
>>   + not 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
>> --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -c 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  -###
>>   + 
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck
>>  
>> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize.c
>>  --check-prefix=CHECK-CFI
>>   
>>   --
>>   
>>   
>>   
>>   Failed Tests (1):
>> Clang :: Driver/fsanitize.c
>>
>> I'll try to look more later when I get more time.
>
> It appears that the clang command in the RUN line returns 0 which the `not` 
> you added inverts it causing the test to fail:
>
>   
> buildbot@6a3c0c51ae89:~/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver$
>  /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
> --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -c 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver/fsanitize2.c
>  -###
>   clang version 18.0.0 (https://github.com/llvm/llvm-project.git 
> 8c3550b1a78fde7bf28f420da8447d9fde37017f)
>   Target: x86_64-unknown-linux-gnu
>   Thread model: posix
>   InstalledDir: 
> /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin
>(in-process)
>
> "/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang-18"
>  "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-llvm-bc" "-flto=full" 
> "-flto-unit" "-disable-free" "-clear-ast-before-backend" "-main-file-name" 
> "fsanitize2.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" 
> "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" 
> "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" 
> "-tune-cpu" "generic" "-debugger-tuning=gdb" 
> "-fcoverage-compilation-dir=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Driver"
>  "-resource-dir" 
> "/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/18"
>  "-internal-isystem" 
> "/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/18/include"
>  "-internal-isystem" "/usr/local/include" "-internal-isystem" 
> "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include" 
> "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" 
> "-internal-externc-isystem" "/include" "-internal-ext

[PATCH] D151834: Include math-errno with fast-math

2023-07-31 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 545666.
zahiraam marked an inline comment as done.

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

https://reviews.llvm.org/D151834

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/math-errno.c

Index: clang/test/CodeGen/math-errno.c
===
--- /dev/null
+++ clang/test/CodeGen/math-errno.c
@@ -0,0 +1,64 @@
+// -O2
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math -O2 -emit-llvm -o - %s \
+// RUN: | FileCheck %s
+
+// -ffast-math
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -menable-no-infs -menable-no-nans -fapprox-func \
+// RUN: -funsafe-math-optimizations -fno-signed-zeros -mreassociate \
+// RUN: -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math \
+// RUN: -ffinite-math-only -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix=FAST
+
+// -O0
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math -O0 \
+// RUN: -emit-llvm -o - %s | FileCheck %s -check-prefix=NOOPT
+
+#pragma float_control(precise,on)
+float f1(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f1
+// CHECK: tail call float @sqrtf(float noundef {{.*}}) #[[ATTR4_O2:[0-9]+]]
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f1
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR3_FAST:[0-9]+]]
+
+// NOOPT-LABEL: define dso_local float @f1
+// NOOPT: call float @sqrtf(float noundef {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
+
+#pragma float_control(precise,off)
+float f2(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f2
+// CHECK: tail call float @llvm.sqrt.f32(float {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f2
+// FAST: call fast float @llvm.sqrt.f32(float {{.*}})
+
+// NOOPT-LABEL: define dso_local float @f2
+// NOOPT: call float @sqrtf(float {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
+
+__attribute__((optnone))
+float f3(float x) {
+  x = sqrtf(x);
+  return x;
+}
+
+// CHECK-LABEL: define dso_local float @f3
+// CHECK: call float @sqrtf(float noundef {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f3
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR4_FAST:[0-9]+]]
+
+// NOOPT-LABEL: define dso_local float @f3
+// NOOPT:  call float @sqrtf(float noundef %0) #[[ATTR4_NOOPT:[0-9]+]]
+
+// CHECK: [[ATTR4_O2]] = { nounwind }
+// FAST: [[ATTR3_FAST]] =  { nounwind willreturn memory(none) }
+// NOOPT: [[ATTR4_NOOPT]] = { nounwind }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1252,6 +1252,12 @@
   llvm::AttributeList &Attrs, unsigned &CallingConv,
   bool AttrOnCallSite, bool IsThunk);
 
+  /// Adjust Memory attribute to ensure that the BE gets the right attribute
+  // in order to generate the library call or the intrinsic for the function
+  // name 'Name'.
+  void AdjustMemoryAttribute(StringRef Name, CGCalleeInfo CalleeInfo,
+ llvm::AttributeList &Attrs);
+
   /// Adds attributes to F according to our CodeGenOptions and LangOptions, as
   /// though we had emitted it ourselves.  We remove any attributes on F that
   /// conflict with the attributes we add here.
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2247,6 +2247,17 @@
   return Mask;
 }
 
+void CodeGenModule::AdjustMemoryAttribute(StringRef Name,
+  CGCalleeInfo CalleeInfo,
+  llvm::AttributeList &Attrs) {
+  if (Attrs.getMemoryEffects().getModRef() == llvm::ModRefInfo::NoModRef) {
+Attrs = Attrs.removeFnAttribute(getLLVMContext(), llvm::Attribute::Memory);
+llvm::Attribute MemoryAttr = llvm::Attribute::getWithMemoryEffects(
+getLLVMContext(), llvm::MemoryEffects::writeOnly());
+Attrs = Attrs.addFnAttribute(getLLVMContext(), MemoryAttr);
+  }
+}
+
 /// Construct the IR attribute list of a function or call.
 ///
 /// When adding an attribute, please consider where it should be handled:
@@ -5442,11 +5453,18 @@
  /*AttrOnCallSite=*/true,
  /*IsThunk=*/false);
 
-  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
+  if (const FunctionDecl *FD = dyn_cast_or_null

[PATCH] D156286: [docs] Bump minimum GCC version to 7.5

2023-07-31 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Given that folks have successfully tested with GCC 7.4, and the lateness of the 
change in the release process for LLVM 17, I think it'd be better to require 
GCC 7.4 (the earliest that actually works), instead of increasing the 
requirement to 7.5.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156286

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


[PATCH] D155393: [clang][Interp] Implement __builtin_isfpclass

2023-07-31 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:232
+  static_cast((F.classify() & FPClassArg).getZExtValue());
+  S.Stk.push>(Integral<32, true>::from(Result));
+

aaron.ballman wrote:
> Shouldn't this be pushing an `int`? (e.g., might not be 32 bits) -- same for 
> the other builtins, now that I look at them.
Yes, this is also covered by https://reviews.llvm.org/D155568


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155393

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


[clang] ab68df5 - [Driver][test] Add -resource-dir= and -fvisibility=hidden to -fsanitize=cfi commands

2023-07-31 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-31T08:20:21-07:00
New Revision: ab68df505e5bb8808ee44f53044b50ca7575098e

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

LOG: [Driver][test] Add -resource-dir= and -fvisibility=hidden to 
-fsanitize=cfi commands

Similar to fsanitize-ignorelist.c.
Otherwise there may or may not be an error, depending on whether
share/cfi_ignorelist.txt is present in the default resource directory.

Exposed by D156363

Added: 
clang/test/Driver/Inputs/resource_dir/share/cfi_ignorelist.txt

Modified: 
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/test/Driver/Inputs/resource_dir/share/cfi_ignorelist.txt 
b/clang/test/Driver/Inputs/resource_dir/share/cfi_ignorelist.txt
new file mode 100644
index 00..e69de29bb2d1d6

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 182de9f486444a..d38e2647496621 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -585,21 +585,21 @@
 // CHECK-LSAN-I386-TVOSSIMULATOR-NOT: unsupported option
 
 
-// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=x86_64-apple-darwin10 -fvisibility=hidden 
-fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=x86_64-pc-win32 -fvisibility=hidden -fsanitize=cfi 
-flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOMFCALL
-// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-fsanitize-cfi-cross-dso -flto -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-NOMFCALL
-// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden 
-fsanitize=cfi-derived-cast -flto -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-DCAST
-// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden 
-fsanitize=cfi-unrelated-cast -flto -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-UCAST
-// RUN: %clang --target=x86_64-linux-gnu -flto -fvisibility=hidden 
-fsanitize=cfi-nvcall -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-NVCALL
-// RUN: %clang --target=x86_64-linux-gnu -flto -fvisibility=hidden 
-fsanitize=cfi-vcall -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-VCALL
-// RUN: %clang --target=arm-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto 
-c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=aarch64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=arm-linux-android -fvisibility=hidden -fsanitize=cfi 
-flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=aarch64-linux-android -fvisibility=hidden 
-fsanitize=cfi -flto -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto -c 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto -c %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
-// RUN: %clang --target=riscv64 -fvisibility=hidden -fsanitize=cfi -flto -c %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
+// RUN: %clang --target=x86_64-apple-darwin10 -fvisibility=hidden 
-fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang --target=x86_64-pc-win32 -fvisibility=hidden -fsanitize=cfi 
-flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI-NOMFCALL
+// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden -fsanitize=cfi 
-fsanitize-cfi-cross-dso -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOMFCALL
+// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden 
-fsanitize=cfi-derived-cast -flto -resource-dir=%S/Inputs/resource_dir -c %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-DCAST
+// RUN: %clang --target=x86_64-linux-gnu -fvisibility=hidden 
-fsanitize=cfi-unrelated-cast -flto -resource-dir=%S/Inputs/resource_dir -c %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-UCAST
+// RUN: %clang --target=x86_64-linux-gnu -flto -fvisibility=hidden 
-fsanitize=cfi-nvcall -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-CFI-NVCALL
+// RUN: %clang --target=x86_64-linux-gnu -flto -fvisibility=hidden 
-fsanitize=cfi-vcall -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | 
FileCheck %s --check-prefix

[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 545679.
AlexVlx added a reviewer: arsenm.
AlexVlx added a comment.
Herald added a subscriber: wdng.

Incorporated review feedback. Updated test.


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

https://reviews.llvm.org/D156539

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/dynamic-alloca-with-address-space.c


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s
+
+void allocas(unsigned long n) {
+char *a = (char *)__builtin_alloca(n);
+char *uninitialized_a = (char *)__builtin_alloca_uninitialized(n);
+char *aligned_a = (char *)__builtin_alloca_with_align(n, 8);
+char *aligned_uninitialized_a = (char 
*)__builtin_alloca_with_align_uninitialized(n, 8);
+}
+
+// CHECK: @allocas(
+// CHECK: store i64 %n, ptr %n.addr.ascast, align 8
+// CHECK: %0 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %1 = alloca i8, i64 %0, align 8, addrspace(5)
+// CHECK: %2 = addrspacecast ptr addrspace(5) %1 to ptr
+// CHECK: store ptr %2, ptr %a.ascast, align 8
+// CHECK: %3 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %4 = alloca i8, i64 %3, align 8, addrspace(5)
+// CHECK: %5 = addrspacecast ptr addrspace(5) %4 to ptr
+// CHECK: store ptr %5, ptr %uninitialized_a.ascast, align 8
+// CHECK: %6 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %7 = alloca i8, i64 %6, align 1, addrspace(5)
+// CHECK: %8 = addrspacecast ptr addrspace(5) %7 to ptr
+// CHECK: store ptr %8, ptr %aligned_a.ascast, align 8
+// CHECK: %9 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %10 = alloca i8, i64 %9, align 1, addrspace(5)
+// CHECK: %11 = addrspacecast ptr addrspace(5) %10 to ptr
+// CHECK: store ptr %11, ptr %aligned_uninitialized_a.ascast, align 8
+// CHECK: ret void
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3514,6 +3514,12 @@
 return RValue::get(Result);
   }
 
+  // An alloca will always return a pointer to the alloca (stack) address
+  // space. This address space need not be the same as the AST / Language
+  // default (e.g. in C / C++ auto vars are in the generic address space). At
+  // the AST level this is handled within CreateTempAlloca et al., but for the
+  // builtin / dynamic alloca we have to handle it here. We use an explicit 
cast
+  // instead of passing an AS to CreateAlloca so as to not inhibit 
optimisation.
   case Builtin::BIalloca:
   case Builtin::BI_alloca:
   case Builtin::BI__builtin_alloca_uninitialized:
@@ -3529,6 +3535,8 @@
 AI->setAlignment(SuitableAlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_uninitialized)
   initializeAlloca(*this, AI, Size, SuitableAlignmentInBytes);
+if (getASTAllocaAddressSpace() != LangAS::Default)
+  return RValue::get(Builder.CreateAddrSpaceCast(AI, CGM.Int8PtrTy));
 return RValue::get(AI);
   }
 
@@ -3544,6 +3552,8 @@
 AI->setAlignment(AlignmentInBytes);
 if (BuiltinID != Builtin::BI__builtin_alloca_with_align_uninitialized)
   initializeAlloca(*this, AI, Size, AlignmentInBytes);
+if (getASTAllocaAddressSpace() != LangAS::Default)
+  return RValue::get(Builder.CreateAddrSpaceCast(AI, CGM.Int8PtrTy));
 return RValue::get(AI);
   }
 


Index: clang/test/CodeGen/dynamic-alloca-with-address-space.c
===
--- /dev/null
+++ clang/test/CodeGen/dynamic-alloca-with-address-space.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s
+
+void allocas(unsigned long n) {
+char *a = (char *)__builtin_alloca(n);
+char *uninitialized_a = (char *)__builtin_alloca_uninitialized(n);
+char *aligned_a = (char *)__builtin_alloca_with_align(n, 8);
+char *aligned_uninitialized_a = (char *)__builtin_alloca_with_align_uninitialized(n, 8);
+}
+
+// CHECK: @allocas(
+// CHECK: store i64 %n, ptr %n.addr.ascast, align 8
+// CHECK: %0 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %1 = alloca i8, i64 %0, align 8, addrspace(5)
+// CHECK: %2 = addrspacecast ptr addrspace(5) %1 to ptr
+// CHECK: store ptr %2, ptr %a.ascast, align 8
+// CHECK: %3 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %4 = alloca i8, i64 %3, align 8, addrspace(5)
+// CHECK: %5 = addrspacecast ptr addrspace(5) %4 to ptr
+// CHECK: store ptr %5, ptr %uninitialized_a.ascast, align 8
+// CHECK: %6 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %7 = alloca i8, i64 %6, align 1, addrspace(5)
+// CHECK: %8 = addrspacecast ptr addrspace(5) %7 to ptr
+// CHECK: store ptr %8, ptr %aligned_a.ascast, align 8
+// CHECK: %9 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %10

[PATCH] D156312: [analyzer] Upstream BitwiseShiftChecker

2023-07-31 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

I like this, especially, that the functionality of UBOR can be merged and 
extended in a much cleaner way (architecturally).




Comment at: clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp:301-302
+  pluralSuffix(MaximalAllowedShift));
+R->addNote(LeftNote, PathDiagnosticLocation{LHS, Ctx.getSourceManager(),
+Ctx.getLocationContext()});
+Ctx.emitReport(std::move(R));

donat.nagy wrote:
> NoQ wrote:
> > Can we just append this to the warning? The `addNote()` is useful for notes 
> > that need to be placed in code outside of the execution path, but if it's 
> > always next to the warning, it probably doesn't make sense to display it 
> > separately.
> I didn't append this to the warning because I felt that the warning text is 
> already too long. (By the way, an earlier internal variant of this checker 
> produced two separate notes next to the warning message.)
> 
> I tweaked the messages of this checker before initiating this review, but I 
> feel that there's still some room for improvements. (E.g. in this particular 
> case perhaps we could omit some of the details that are not immediately 
> useful and could be manually calculated from other parts of the message...) 
Just a thought on simplifying the diagnostics a bit:

Warning: "Right operand is negative in left shift"
Note: "The result of left shift is undefined because the right operand is 
negative"
Shortened: "Undefined left shift due to negative right operand"

Warning: "Left shift by '34' overflows the capacity of 'int'"
Note: "The result of left shift is undefined because the right operand '34' is 
not smaller than 32, the capacity of 'int'"
Shortened: "Undefined left shift: '34' exceeds 'int' capacity (32 bits)"

The more complex notes are a bit sketchy, as relevant information can be lost, 
and the following solution is probably a bit too much, but could prove to be an 
inspiration:

Warning: "Left shift of '1024' overflows the capacity of 'int'"
CXX Note: "Left shift of '1024' is undefined because 'int' can hold only 32 
bits (including the sign bit), so some bits overflow"
CXX Note: "The value '1024' is represented by 11 bits, allowing at most 21 bits 
for bitshift"
C Note: "Left shift of '1024' is undefined because 'int' can hold only 31 bits 
(excluding the sign bit), so some bits overflow"
C Note: "The value '1024' is represented by 11 bits, allowing at most 20 bits 
for bitshift"

Shortened:
CXX Warning: "Undefined left shift: '1024' (11 bits) exceeds 'int' capacity (32 
bits, including sign)"
C Warning: "Undefined left shift: '1024' (11 bits) exceeds 'int' capacity (31 
bits, excluding sign)"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156312

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


[PATCH] D156274: [NFC] Avoid potential dereferencing of nullptr.

2023-07-31 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added a comment.

In D156274#4545581 , @schittir wrote:

> Test failure seems unrelated to change. Driver/fsanitize.c lit test passes in 
> my local testing. Restarting build.

The build is now green. Landing the patch.


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

https://reviews.llvm.org/D156274

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


[PATCH] D156274: [NFC] Avoid potential dereferencing of nullptr.

2023-07-31 Thread Sindhu Chittireddy via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG235390d930be: [NFC] Avoid potential dereferencing of 
nullptr. (authored by schittir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156274

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/Sema/SemaCodeComplete.cpp


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6601,7 +6601,7 @@
   // The "template" keyword can follow "::" in the grammar, but only
   // put it into the grammar if the nested-name-specifier is dependent.
   // FIXME: results is always empty, this appears to be dead.
-  if (!Results.empty() && NNS->isDependent())
+  if (!Results.empty() && NNS && NNS->isDependent())
 Results.AddResult("template");
 
   // If the scope is a concept-constrained type parameter, infer nested
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -1656,6 +1656,7 @@
   // Otherwise, use the complete destructor name. This is relevant if a
   // class with a destructor is declared within a destructor.
   mangleCXXDtorType(Dtor_Complete);
+assert(ND);
 writeAbiTags(ND, AdditionalAbiTags);
 break;
 


Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6601,7 +6601,7 @@
   // The "template" keyword can follow "::" in the grammar, but only
   // put it into the grammar if the nested-name-specifier is dependent.
   // FIXME: results is always empty, this appears to be dead.
-  if (!Results.empty() && NNS->isDependent())
+  if (!Results.empty() && NNS && NNS->isDependent())
 Results.AddResult("template");
 
   // If the scope is a concept-constrained type parameter, infer nested
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -1656,6 +1656,7 @@
   // Otherwise, use the complete destructor name. This is relevant if a
   // class with a destructor is declared within a destructor.
   mangleCXXDtorType(Dtor_Complete);
+assert(ND);
 writeAbiTags(ND, AdditionalAbiTags);
 break;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 235390d - [NFC] Avoid potential dereferencing of nullptr.

2023-07-31 Thread Sindhu Chittireddy via cfe-commits

Author: Sindhu Chittireddy
Date: 2023-07-31T08:33:26-07:00
New Revision: 235390d930be41c32c71f877d90470fc83e2cb89

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

LOG: [NFC] Avoid potential dereferencing of nullptr.

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/lib/Sema/SemaCodeComplete.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index f08286a0d4baef..16f0d90451f7ad 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -1656,6 +1656,7 @@ void CXXNameMangler::mangleUnqualifiedName(
   // Otherwise, use the complete destructor name. This is relevant if a
   // class with a destructor is declared within a destructor.
   mangleCXXDtorType(Dtor_Complete);
+assert(ND);
 writeAbiTags(ND, AdditionalAbiTags);
 break;
 

diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index b5d29b2e956c3d..476baad734f70e 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -6601,7 +6601,7 @@ void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec 
&SS,
   // The "template" keyword can follow "::" in the grammar, but only
   // put it into the grammar if the nested-name-specifier is dependent.
   // FIXME: results is always empty, this appears to be dead.
-  if (!Results.empty() && NNS->isDependent())
+  if (!Results.empty() && NNS && NNS->isDependent())
 Results.AddResult("template");
 
   // If the scope is a concept-constrained type parameter, infer nested



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


[PATCH] D156704: [clang][HeaderSearch] Treat framework headers as System for suggestPath

2023-07-31 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
dgoldman requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

All callers will use the IsSystem flag to decide whether to use <> or ""
style includes, so we treat all frameworks as System since by convention
they use <> style includes.

Also update clangd's custom logic for frameworks accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156704

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp

Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -47,14 +47,18 @@
 Search.AddSearchPath(DL, /*isAngled=*/false);
   }
 
-  void addSystemFrameworkSearchDir(llvm::StringRef Dir) {
+  void addFrameworkSearchDir(llvm::StringRef Dir, bool IsSystem = true) {
 VFS->addFile(
 Dir, 0, llvm::MemoryBuffer::getMemBuffer(""), /*User=*/std::nullopt,
 /*Group=*/std::nullopt, llvm::sys::fs::file_type::directory_file);
 auto DE = FileMgr.getOptionalDirectoryRef(Dir);
 assert(DE);
-auto DL = DirectoryLookup(*DE, SrcMgr::C_System, /*isFramework=*/true);
-Search.AddSystemSearchPath(DL);
+auto DL = DirectoryLookup(*DE,
+IsSystem ? SrcMgr::C_System : SrcMgr::C_User, /*isFramework=*/true);
+if (IsSystem)
+  Search.AddSystemSearchPath(DL);
+else
+  Search.AddSearchPath(DL, /*isAngled=*/true);
   }
 
   void addHeaderMap(llvm::StringRef Filename,
@@ -175,7 +179,7 @@
 }
 
 TEST_F(HeaderSearchTest, SdkFramework) {
-  addSystemFrameworkSearchDir(
+  addFrameworkSearchDir(
   "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/Frameworks/");
   bool IsSystem = false;
   EXPECT_EQ(Search.suggestPathToFileForDiagnostics(
@@ -185,10 +189,22 @@
 /*MainFile=*/"", &IsSystem),
 "AppKit/NSView.h");
   EXPECT_TRUE(IsSystem);
+
+  addFrameworkSearchDir(
+  "/System/Developer/Library/Framworks/", /*IsSystem*/false);
+  EXPECT_EQ(Search.suggestPathToFileForDiagnostics(
+"/System/Developer/Library/Framworks/"
+"Foo.framework/Headers/Foo.h",
+/*WorkingDir=*/"",
+/*MainFile=*/"", &IsSystem),
+"Foo/Foo.h");
+  // Expect to be true even though we passed false to IsSystem earlier since
+  // all frameworks should be treated as <>.
+  EXPECT_TRUE(IsSystem);
 }
 
 TEST_F(HeaderSearchTest, NestedFramework) {
-  addSystemFrameworkSearchDir("/Platforms/MacOSX/Frameworks");
+  addFrameworkSearchDir("/Platforms/MacOSX/Frameworks");
   EXPECT_EQ(Search.suggestPathToFileForDiagnostics(
 "/Platforms/MacOSX/Frameworks/AppKit.framework/Frameworks/"
 "Sub.framework/Headers/Sub.h",
@@ -199,7 +215,7 @@
 
 TEST_F(HeaderSearchTest, HeaderFrameworkLookup) {
   std::string HeaderPath = "/tmp/Frameworks/Foo.framework/Headers/Foo.h";
-  addSystemFrameworkSearchDir("/tmp/Frameworks");
+  addFrameworkSearchDir("/tmp/Frameworks");
   VFS->addFile(HeaderPath, 0,
llvm::MemoryBuffer::getMemBufferCopy("", HeaderPath),
/*User=*/std::nullopt, /*Group=*/std::nullopt,
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -2003,8 +2003,10 @@
 } else if (DL.isFramework()) {
   StringRef Dir = DL.getFrameworkDirRef()->getName();
   if (CheckDir(Dir)) {
+// Framework includes by convention use <> so mark these as system
+// so the caller know to use <> instead of "" as well.
 if (IsSystem)
-  *IsSystem = BestPrefixLength && isSystem(DL.getDirCharacteristic());
+  *IsSystem = BestPrefixLength;
 BestPrefixIsFramework = true;
   }
 }
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -702,9 +702,9 @@
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
-  AllOf(qName("NSObject"), includeHeader("\"Foundation/NSObject.h\"")),
+  AllOf(qName("NSObject"), includeHeader("")),
   AllOf(qName("PrivateClass"),
-includeHeader("\"Foundation/NSObject+Private.h\"")),
+includeHeader("")),
   AllOf(qName("Container";
 
   // After adding the umbrella headers, we should use that spelling instead.
@@ -725,9 +725,9 @@
   EXPECT_THAT(Symbols,
 

[PATCH] D156705: [clang-format] Fix braced initializer formatting with templated base class initializer

2023-07-31 Thread Galen Elias via Phabricator via cfe-commits
galenelias created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
galenelias requested review of this revision.

This fixes https://github.com/llvm/llvm-project/issues/64134 which
is a regression from https://reviews.llvm.org/D150403 where I
added logic to distinguish adjacent braces blocks between being braced
initializers or adjacent scopes by looking at the token before the first
opening brace to see if it is part of a class initializer list.

However, this logic fails to match initialization of a templated base
class initializer, because in that scenario the 'identifier' actually
ends in a `>`, so isn't detected.  I am extending the logic to just also
detect `>` explicitly to be recognized as the braced initializer syntax.
Hopefully there aren't many more holes in the detection logic here.


https://reviews.llvm.org/D156705

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13458,6 +13458,7 @@
   verifyFormat(
   "class A {\n"
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
   "  A(int b) : b(b) {}\n"
   "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
   "  int a, b;\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -581,7 +581,8 @@
   ProbablyBracedList =
   ProbablyBracedList ||
   (NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
-   LBraceStack.back().PrevTok->is(tok::identifier));
+   LBraceStack.back().PrevTok->isOneOf(tok::identifier,
+   tok::greater));
 
   ProbablyBracedList =
   ProbablyBracedList ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13458,6 +13458,7 @@
   verifyFormat(
   "class A {\n"
   "  A() : a{} {}\n"
+  "  A() : Base{} {}\n"
   "  A(int b) : b(b) {}\n"
   "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
   "  int a, b;\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -581,7 +581,8 @@
   ProbablyBracedList =
   ProbablyBracedList ||
   (NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
-   LBraceStack.back().PrevTok->is(tok::identifier));
+   LBraceStack.back().PrevTok->isOneOf(tok::identifier,
+   tok::greater));
 
   ProbablyBracedList =
   ProbablyBracedList ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/dynamic-alloca-with-address-space.c:1
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s
+

Can you add an opencl 1.2 and 2.0 run line too



Comment at: clang/test/CodeGen/dynamic-alloca-with-address-space.c:12
+// CHECK: store i64 %n, ptr %n.addr.ascast, align 8
+// CHECK: %0 = load i64, ptr %n.addr.ascast, align 8
+// CHECK: %1 = alloca i8, i64 %0, align 8, addrspace(5)

Use generated checks


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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added inline comments.



Comment at: clang/test/CodeGen/dynamic-alloca-with-address-space.c:1
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s
+

arsenm wrote:
> Can you add an opencl 1.2 and 2.0 run line too
This is not valid 1.2 code, for 2.0 sure.


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

https://reviews.llvm.org/D156539

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


[PATCH] D156539: [Clang][CodeGen] `__builtin_alloca`s should care about address spaces too

2023-07-31 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/dynamic-alloca-with-address-space.c:1
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s
+

AlexVlx wrote:
> arsenm wrote:
> > Can you add an opencl 1.2 and 2.0 run line too
> This is not valid 1.2 code, for 2.0 sure.
well also need a 1.2 flavored version then with the __privates in it (or use 
some macro trickery)


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

https://reviews.llvm.org/D156539

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


[PATCH] D156711: [clang][ExprConstant] Fix assertion failure in constant expression folding

2023-07-31 Thread antoine moynault via Phabricator via cfe-commits
antmo created this revision.
Herald added a project: All.
antmo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Since D140059 , clang asserts on constant 
calls of string functions
(memchr, strncmp, memcmp, ...) when the last argument (length) does not
fit in an UInt63:

  strncmp("11", "12", -1);

Fix this by directly calling getZExtValue, as an unsigned value is
needed here


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156711

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-string.cpp


Index: clang/test/SemaCXX/constexpr-string.cpp
===
--- clang/test/SemaCXX/constexpr-string.cpp
+++ clang/test/SemaCXX/constexpr-string.cpp
@@ -93,6 +93,7 @@
 
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 6) == -1);
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 7) == -1); // FIXME: 
Should we reject this?
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, (size_t)-1) == -1); 
// Check that this does not assert
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 6) == 0);
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 7) == 0); // 
expected-error {{not an integral constant}} expected-note {{dereferenced 
one-past-the-end}}
 
@@ -377,6 +378,7 @@
 
   static_assert(__builtin_memchr(kStr, 'a', 0) == nullptr);
   static_assert(__builtin_memchr(kStr, 'a', 1) == kStr);
+  static_assert(__builtin_memchr(kStr, 'a', (size_t)-1) == kStr); // Check 
that this does not assert
   static_assert(__builtin_memchr(kStr, '\0', 5) == nullptr);
   static_assert(__builtin_memchr(kStr, '\0', 6) == kStr + 5);
   static_assert(__builtin_memchr(kStr, '\xff', 8) == kStr + 4);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9346,7 +9346,7 @@
   APSInt N;
   if (!EvaluateInteger(E->getArg(2), N, Info))
 return false;
-  MaxLength = N.getExtValue();
+  MaxLength = N.getZExtValue();
 }
 // We cannot find the value if there are no candidates to match against.
 if (MaxLength == 0u)
@@ -12356,7 +12356,7 @@
   APSInt N;
   if (!EvaluateInteger(E->getArg(2), N, Info))
 return false;
-  MaxLength = N.getExtValue();
+  MaxLength = N.getZExtValue();
 }
 
 // Empty substrings compare equal by definition.


Index: clang/test/SemaCXX/constexpr-string.cpp
===
--- clang/test/SemaCXX/constexpr-string.cpp
+++ clang/test/SemaCXX/constexpr-string.cpp
@@ -93,6 +93,7 @@
 
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 6) == -1);
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 7) == -1); // FIXME: Should we reject this?
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, (size_t)-1) == -1); // Check that this does not assert
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 6) == 0);
   static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 7) == 0); // expected-error {{not an integral constant}} expected-note {{dereferenced one-past-the-end}}
 
@@ -377,6 +378,7 @@
 
   static_assert(__builtin_memchr(kStr, 'a', 0) == nullptr);
   static_assert(__builtin_memchr(kStr, 'a', 1) == kStr);
+  static_assert(__builtin_memchr(kStr, 'a', (size_t)-1) == kStr); // Check that this does not assert
   static_assert(__builtin_memchr(kStr, '\0', 5) == nullptr);
   static_assert(__builtin_memchr(kStr, '\0', 6) == kStr + 5);
   static_assert(__builtin_memchr(kStr, '\xff', 8) == kStr + 4);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9346,7 +9346,7 @@
   APSInt N;
   if (!EvaluateInteger(E->getArg(2), N, Info))
 return false;
-  MaxLength = N.getExtValue();
+  MaxLength = N.getZExtValue();
 }
 // We cannot find the value if there are no candidates to match against.
 if (MaxLength == 0u)
@@ -12356,7 +12356,7 @@
   APSInt N;
   if (!EvaluateInteger(E->getArg(2), N, Info))
 return false;
-  MaxLength = N.getExtValue();
+  MaxLength = N.getZExtValue();
 }
 
 // Empty substrings compare equal by definition.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >