[clang] 0604241 - [clang-repl] Fix ambiguous initializer list.

2022-12-03 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2022-12-03T08:16:34Z
New Revision: 060424178ae3720eeba6a31b579cf2025d47d852

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

LOG: [clang-repl] Fix ambiguous initializer list.

Some platforms report that GlobalTopLevelStmtBlockInFlight cannot be initalized
with '{}' due to operator '=' being ambiguous.

This patch is a follow up to https://reviews.llvm.org/D127284 trying to appease
the bots.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0327d535968b..073e88016b72 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ void CodeGenModule::Release() {
   GlobalTopLevelStmtBlockInFlight.first) {
 const TopLevelStmtDecl *TLSD = GlobalTopLevelStmtBlockInFlight.second;
 GlobalTopLevelStmtBlockInFlight.first->FinishFunction(TLSD->getEndLoc());
-GlobalTopLevelStmtBlockInFlight = {};
+GlobalTopLevelStmtBlockInFlight = {nullptr, nullptr};
   }
 
   if (CXX20ModuleInits && Primary && Primary->isInterfaceOrPartition())



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


[PATCH] D139173: [clang] Add test for CWG600

2022-12-03 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 479818.
Endill added a comment.

Add a comment per @shafik request


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

https://reviews.llvm.org/D139173

Files:
  clang/test/CXX/drs/dr6xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3642,7 +3642,7 @@
 https://wg21.link/cwg600";>600
 CD6
 Does access control apply to members or to names?
-Unknown
+Yes
   
   
 https://wg21.link/cwg601";>601
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -3,6 +3,22 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors -fno-spell-checking
+
+namespace dr600 { // dr600: yes
+struct S {
+  void f(int);
+
+private:
+  void f(double); // expected-note {{declared private here}}
+};
+
+void g(S *sp) {
+  sp->f(2);
+  // access control is applied after overload resolution
+  sp->f(2.2); // expected-error {{is a private member}}
+}
+} // namespace dr600
 
 namespace std {
   struct type_info {};


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3642,7 +3642,7 @@
 https://wg21.link/cwg600";>600
 CD6
 Does access control apply to members or to names?
-Unknown
+Yes
   
   
 https://wg21.link/cwg601";>601
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -3,6 +3,22 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+
+namespace dr600 { // dr600: yes
+struct S {
+  void f(int);
+
+private:
+  void f(double); // expected-note {{declared private here}}
+};
+
+void g(S *sp) {
+  sp->f(2);
+  // access control is applied after overload resolution
+  sp->f(2.2); // expected-error {{is a private member}}
+}
+} // namespace dr600
 
 namespace std {
   struct type_info {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139172: [clang] Mark CWG554 as N/A

2022-12-03 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

@shafik Would it be fine by you to proceed without changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139172

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


[PATCH] D138746: [clang-format] Add .inc extension to git-clang-format

2022-12-03 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae918c78b51a: [clang-format] Add .inc extension to 
git-clang-format (authored by aganea).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138746

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -88,7 +88,7 @@
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx', 'inc',  # C++
   'ccm', 'cppm', 'cxxm', 'c++m',  # C++ Modules
   'cu', 'cuh',  # CUDA
   # Other languages that clang-format supports


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -88,7 +88,7 @@
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx', 'inc',  # C++
   'ccm', 'cppm', 'cxxm', 'c++m',  # C++ Modules
   'cu', 'cuh',  # CUDA
   # Other languages that clang-format supports
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ae918c7 - [clang-format] Add .inc extension to git-clang-format

2022-12-03 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2022-12-03T09:24:03-05:00
New Revision: ae918c78b51ae7e19053b9ae9deb9fee35084256

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

LOG: [clang-format] Add .inc extension to git-clang-format

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

Added: 


Modified: 
clang/tools/clang-format/git-clang-format

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 7ce6b60a8e65..054978c3dbdf 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -88,7 +88,7 @@ def main():
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hh', 'hpp', 'hxx', 'inc',  # C++
   'ccm', 'cppm', 'cxxm', 'c++m',  # C++ Modules
   'cu', 'cuh',  # CUDA
   # Other languages that clang-format supports



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


[clang] 4178671 - [clang][Windows]Ignore Options '/d1'

2022-12-03 Thread via cfe-commits

Author: qfrost
Date: 2022-12-03T22:47:59+08:00
New Revision: 4178671b2ed3d8c1ffec6f723808e22572601242

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

LOG: [clang][Windows]Ignore Options '/d1'

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 5d7305f2af76..11f6253db744 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6932,6 +6932,7 @@ def _SLASH_AI : CLJoinedOrSeparate<"AI">;
 def _SLASH_Bt : CLFlag<"Bt">;
 def _SLASH_Bt_plus : CLFlag<"Bt+">;
 def _SLASH_clr : CLJoined<"clr">;
+def _SLASH_d1 : CLJoined<"d1">;
 def _SLASH_d2 : CLJoined<"d2">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_experimental : CLJoined<"experimental:">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index b4525e61a1a3..1d588bdfc1b0 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -426,6 +426,8 @@
 // RUN: /Bt \
 // RUN: /Bt+ \
 // RUN: /clr:pure \
+// RUN: /d1import_no_registry \
+// RUN: /d1nodatetime \
 // RUN: /d2FH4 \
 // RUN: /docname \
 // RUN: /experimental:external \



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


[PATCH] D138358: [clang-format] Match all block braces

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

This wouldn't work for deeply nested loops:

  $ cat test.cpp
  for (;;) {
for (;;) {
  for (;;) {
a;
  }
}
  }
  $ clang-format -style='{RemoveBracesLLVM: true}' test.cpp
  for (;;)
for (;;)
  for (;;)
a;

Expected output:

  for (;;) {
for (;;)
  for (;;)
a;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138358

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


[PATCH] D139257: [clang-format][NFC] Link braces of a block in UnwrappedLineParser

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, rymiel, klimek.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This includes TT_MacroBlockBegin and TT_MacroBlockEnd as well.

We can no longer use MatchingParen of FormatToken as an indicator to mark 
optional braces. Instead, we directly set Optional of an l_brace first and 
reset it later if it turns out that the braces are not optional.

Also added a test case for deeply nested loops.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139257

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

Index: clang/unittests/Format/BracesRemoverTest.cpp
===
--- clang/unittests/Format/BracesRemoverTest.cpp
+++ clang/unittests/Format/BracesRemoverTest.cpp
@@ -204,6 +204,20 @@
"while (j < 0) { ++j; }",
Style);
 
+  verifyFormat("for (;;) {\n"
+   "  for (;;)\n"
+   "for (;;)\n"
+   "  a;\n"
+   "}",
+   "for (;;) {\n"
+   "  for (;;) {\n"
+   "for (;;) {\n"
+   "  a;\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -934,6 +934,9 @@
 return IfLBrace;
   }
 
+  Tok->MatchingParen = FormatTok;
+  FormatTok->MatchingParen = Tok;
+
   const bool IsFunctionRBrace =
   FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace);
 
@@ -967,10 +970,7 @@
 }
 return mightFitOnOneLine((*CurrentLines)[Index], Tok);
   };
-  if (RemoveBraces()) {
-Tok->MatchingParen = FormatTok;
-FormatTok->MatchingParen = Tok;
-  }
+  Tok->Optional = RemoveBraces();
 
   size_t PPEndHash = computePPHash();
 
@@ -2707,10 +2707,16 @@
 
   assert(RightBrace->is(tok::r_brace));
   assert(RightBrace->MatchingParen == LeftBrace);
-  assert(LeftBrace->Optional == RightBrace->Optional);
 
-  LeftBrace->Optional = true;
-  RightBrace->Optional = true;
+  RightBrace->Optional = LeftBrace->Optional;
+}
+
+static void resetOptional(FormatToken *LBrace) {
+  if (!LBrace)
+return;
+
+  const auto *RBrace = LBrace->MatchingParen;
+  LBrace->Optional = RBrace && RBrace->Optional;
 }
 
 void UnwrappedLineParser::handleAttributes() {
@@ -2770,8 +2776,7 @@
 
   if (Style.RemoveBracesLLVM) {
 assert(!NestedTooDeep.empty());
-KeepIfBraces = KeepIfBraces ||
-   (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
+KeepIfBraces = KeepIfBraces || (IfLeftBrace && !IfLeftBrace->Optional) ||
NestedTooDeep.back() || IfBlockKind == IfStmtKind::IfOnly ||
IfBlockKind == IfStmtKind::IfElseIf;
   }
@@ -2802,8 +2807,9 @@
  ElseBlockKind == IfStmtKind::IfElseIf;
   } else if (FollowedByIf && IfLBrace && !IfLBrace->Optional) {
 KeepElseBraces = true;
+assert(ElseLeftBrace->Optional);
 assert(ElseLeftBrace->MatchingParen);
-markOptionalBraces(ElseLeftBrace);
+ElseLeftBrace->MatchingParen->Optional = true;
   }
   addUnwrappedLine();
 } else if (FormatTok->is(tok::kw_if)) {
@@ -2838,7 +2844,7 @@
 
   assert(!NestedTooDeep.empty());
   KeepElseBraces = KeepElseBraces ||
-   (ElseLeftBrace && !ElseLeftBrace->MatchingParen) ||
+   (ElseLeftBrace && !ElseLeftBrace->Optional) ||
NestedTooDeep.back();
 
   NestedTooDeep.pop_back();
@@ -2846,17 +2852,11 @@
   if (!KeepIfBraces && !KeepElseBraces) {
 markOptionalBraces(IfLeftBrace);
 markOptionalBraces(ElseLeftBrace);
-  } else if (IfLeftBrace) {
-FormatToken *IfRightBrace = IfLeftBrace->MatchingParen;
-if (IfRightBrace) {
-  assert(IfRightBrace->MatchingParen == IfLeftBrace);
-  assert(!IfLeftBrace->Optional);
-  assert(!IfRightBrace->Optional);
-  IfLeftBrace->MatchingParen = nullptr;
-  IfRightBrace->MatchingParen = nullptr;
-}
   }
 
+  resetOptional(IfLeftBrace);
+  resetOptional(ElseLeftBrace);
+
   if (IfKind)
 *IfKind = Kind;
 
@@ -3071,6 +3071,7 @@
   if (!NestedTooDeep.back())
 markOptionalBraces(LeftBrace);
 }
+resetOptional(LeftBrace);
 if (WrapRightBrace)
   addUnwrappedLine();
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138358: [clang-format] Match all block braces

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Please see D139257  for a different approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138358

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


[PATCH] D135658: demangle OptFunction trace names

2022-12-03 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

Well last time I checked it this code was still in use. When is it going to be 
deleted?
Also the test has value to ensure the new pass manager emits these entries as 
before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135658

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


[PATCH] D139167: [clang][Windows]Ignore Options '/d1nodatetime' and '/d1import_no_registry'

2022-12-03 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D139167#3967123 , @efriedma wrote:

> FYI, there's some discussion of /d1nodatetime floating around, even though it 
> isn't formally documented: it disables the definition of the `__DATE__`, 
> `__TIME__`, and `__TIMESTAMP__` macros.
>
> (No idea about d1import_no_registry, though.)

Those two options were introduced (I believe) along with the cl flag 
`/experimental:deterministic` (they actually alias to that flag, like -cc1 
flags do in Clang). `/d1import_no_registry` simply adds this attribute 
 
to all `#import` directives, to make them deterministic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139167

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


[clang] 8c7c20f - Convert Optional to std::optional

2022-12-03 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2022-12-03T12:08:47-06:00
New Revision: 8c7c20f033c7036a8bf231ca6f9e02172cb581f0

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

LOG: Convert Optional to std::optional

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
lld/Common/TargetOptionsCommandFlags.cpp
lld/include/lld/Common/TargetOptionsCommandFlags.h
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h
llvm/include/llvm/IR/Module.h
llvm/include/llvm/LTO/Config.h
llvm/include/llvm/MC/TargetRegistry.h
llvm/include/llvm/Target/CodeGenCWrappers.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp
llvm/lib/IR/Module.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.h
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
llvm/lib/Target/AMDGPU/R600TargetMachine.cpp
llvm/lib/Target/AMDGPU/R600TargetMachine.h
llvm/lib/Target/ARC/ARCTargetMachine.cpp
llvm/lib/Target/ARC/ARCTargetMachine.h
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/ARM/ARMTargetMachine.h
llvm/lib/Target/AVR/AVRTargetMachine.cpp
llvm/lib/Target/AVR/AVRTargetMachine.h
llvm/lib/Target/BPF/BPFTargetMachine.cpp
llvm/lib/Target/BPF/BPFTargetMachine.h
llvm/lib/Target/CSKY/CSKYTargetMachine.cpp
llvm/lib/Target/CSKY/CSKYTargetMachine.h
llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
llvm/lib/Target/DirectX/DirectXTargetMachine.h
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.h
llvm/lib/Target/Lanai/LanaiTargetMachine.cpp
llvm/lib/Target/Lanai/LanaiTargetMachine.h
llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
llvm/lib/Target/LoongArch/LoongArchTargetMachine.h
llvm/lib/Target/M68k/M68kTargetMachine.cpp
llvm/lib/Target/M68k/M68kTargetMachine.h
llvm/lib/Target/MSP430/MSP430TargetMachine.cpp
llvm/lib/Target/MSP430/MSP430TargetMachine.h
llvm/lib/Target/Mips/MipsTargetMachine.cpp
llvm/lib/Target/Mips/MipsTargetMachine.h
llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
llvm/lib/Target/NVPTX/NVPTXTargetMachine.h
llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
llvm/lib/Target/PowerPC/PPCTargetMachine.h
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
llvm/lib/Target/RISCV/RISCVTargetMachine.h
llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
llvm/lib/Target/SPIRV/SPIRVTargetMachine.h
llvm/lib/Target/Sparc/SparcTargetMachine.cpp
llvm/lib/Target/Sparc/SparcTargetMachine.h
llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
llvm/lib/Target/SystemZ/SystemZTargetMachine.h
llvm/lib/Target/TargetMachineC.cpp
llvm/lib/Target/VE/VETargetMachine.cpp
llvm/lib/Target/VE/VETargetMachine.h
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.h
llvm/lib/Target/XCore/XCoreTargetMachine.cpp
llvm/lib/Target/XCore/XCoreTargetMachine.h
llvm/tools/llc/llc.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 2b241967f5e7b..cefeb8c255858 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -92,6 +92,7 @@
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
 #include 
+#include 
 using namespace clang;
 using namespace llvm;
 
@@ -312,7 +313,7 @@ static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions 
&CodeGenOpts) {
   }
 }
 
-static Optional
+static std::optional
 getCodeModel(const CodeGenOptions &CodeGenOpts) {
   unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel)
.Case("tiny", llvm::CodeModel::Tiny)
@@ -324,7 +325,7 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) {
.Default(~0u);
   assert(CodeModel != ~0u && "invalid code model!");
   if (CodeModel == ~1u)
-return None;
+return std::nullopt;
   return static_cast(CodeModel);
 }
 
@@ -572,7 +573,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool 
MustCreateTM) {
 return;
   }
 
-  Optional CM = getCodeModel(CodeGenOpts);
+  std::optional CM = getCodeModel(CodeGenOpts);
   std::string FeaturesStr =
   llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ",");
   llvm::Reloc::Model RM = CodeGenOpts.RelocationModel;

diff  --git a/

[PATCH] D139258: Remove the enableIncrementalProcesing logic in favor of -fincremental-extensions

2022-12-03 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: aaron.ballman, rsmith, shafik.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
v.g.vassilev requested review of this revision.

As we have discussed in https://reviews.llvm.org/D127284 we would like to phase 
out `enableIncrementalProcesing` and use a better integrated option.

https://reviews.llvm.org/D127284 introduces a `LangOpt` called 
`IncrementalExtensions`, however, we also have a `TU_Incremental` kind. I am 
not entirely sure when we should use that because generally most of our actions 
(even if we pass `-fincremental-extensions`) we still get `TU_Complete`.

@aaron.ballman, @rsmith, do you have an idea how to harmonize this?


https://reviews.llvm.org/D139258

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/unittests/Frontend/FrontendActionTest.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -609,7 +609,8 @@
   "-target",
   arch.GetTriple().str(),
   "-fmodules-validate-system-headers",
-  "-Werror=non-modular-include-in-framework-module"};
+  "-Werror=non-modular-include-in-framework-module",
+  "-Xclang=-fincremental-extensions"};
 
   target.GetPlatform()->AddClangModuleCompilationOptions(
   &target, compiler_invocation_arguments);
@@ -701,8 +702,6 @@
instance->getFrontendOpts().Inputs[0]))
 return nullptr;
 
-  instance->getPreprocessor().enableIncrementalProcessing();
-
   instance->createASTReader();
 
   instance->createSema(action->getTranslationUnitKind(), nullptr);
Index: clang/unittests/Frontend/FrontendActionTest.cpp
===
--- clang/unittests/Frontend/FrontendActionTest.cpp
+++ clang/unittests/Frontend/FrontendActionTest.cpp
@@ -30,22 +30,12 @@
 
 class TestASTFrontendAction : public ASTFrontendAction {
 public:
-  TestASTFrontendAction(bool enableIncrementalProcessing = false,
-bool actOnEndOfTranslationUnit = false)
-: EnableIncrementalProcessing(enableIncrementalProcessing),
-  ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit) { }
+  TestASTFrontendAction(bool actOnEndOfTranslationUnit = false)
+  : ActOnEndOfTranslationUnit(actOnEndOfTranslationUnit) {}
 
-  bool EnableIncrementalProcessing;
   bool ActOnEndOfTranslationUnit;
   std::vector decl_names;
 
-  bool BeginSourceFileAction(CompilerInstance &ci) override {
-if (EnableIncrementalProcessing)
-  ci.getPreprocessor().enableIncrementalProcessing();
-
-return ASTFrontendAction::BeginSourceFileAction(ci);
-  }
-
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  StringRef InFile) override {
 return std::make_unique(CI, ActOnEndOfTranslationUnit,
@@ -108,11 +98,12 @@
   FrontendInputFile("test.cc", Language::CXX));
   invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  invocation->getLangOpts()->IncrementalExtensions = 1;
   CompilerInstance compiler;
   compiler.setInvocation(std::move(invocation));
   compiler.createDiagnostics();
 
-  TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true);
+  TestASTFrontendAction test_action;
   ASSERT_TRUE(compiler.ExecuteAction(test_action));
   ASSERT_EQ(2U, test_action.decl_names.size());
   EXPECT_EQ("main", test_action.decl_names[0]);
@@ -123,6 +114,7 @@
   auto invocation = std::make_shared();
   invocation->getLangOpts()->CPlusPlus = true;
   invocation->getLangOpts()->DelayedTemplateParsing = true;
+  invocation->getLangOpts()->IncrementalExtensions = 1;
   invocation->getPreprocessorOpts().addRemappedFile(
 "test.cc", MemoryBuffer::getMemBuffer(
   "template struct A { A(T); T data; };\n"
@@ -139,8 +131,7 @@
   compiler.setInvocation(std::move(invocation));
   compiler.createDiagnostics();
 
-  TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true,
-/*actOnEndOfTranslationUnit=*/true);
+  TestASTFrontendAction test_action(/*actOnEndOfTranslationUnit=*/true);
   ASSERT_TRUE(compiler.ExecuteAction(test_action));
   ASSERT_EQ(13U, test_action.decl_names.size());
   EXPECT_EQ("A", test_action.decl_names[0]);
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1166,9 +1166,9 @@

[clang] 8595f2e - [Sema] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:13:39-08:00
New Revision: 8595f2e54d2df80e8d0f9de415324eaae510a84a

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

LOG: [Sema] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprObjC.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/include/clang/Sema/CodeCompleteConsumer.h 
b/clang/include/clang/Sema/CodeCompleteConsumer.h
index db1f3850984c1..e0c7424220f5d 100644
--- a/clang/include/clang/Sema/CodeCompleteConsumer.h
+++ b/clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -368,11 +368,11 @@ class CodeCompletionContext {
 public:
   /// Construct a new code-completion context of the given kind.
   CodeCompletionContext(Kind CCKind)
-  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(None) {}
+  : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(std::nullopt) {}
 
   /// Construct a new code-completion context of the given kind.
   CodeCompletionContext(Kind CCKind, QualType T,
-ArrayRef SelIdents = None)
+ArrayRef SelIdents = std::nullopt)
   : CCKind(CCKind), IsUsingDeclaration(false), SelIdents(SelIdents) {
 if (CCKind == CCC_DotMemberAccess || CCKind == CCC_ArrowMemberAccess ||
 CCKind == CCC_ObjCPropertyAccess || CCKind == CCC_ObjCClassMessage ||
@@ -425,7 +425,7 @@ class CodeCompletionContext {
   llvm::Optional getCXXScopeSpecifier() {
 if (ScopeSpecifier)
   return &*ScopeSpecifier;
-return llvm::None;
+return std::nullopt;
   }
 };
 

diff  --git a/clang/include/clang/Sema/Overload.h 
b/clang/include/clang/Sema/Overload.h
index 29d0fa63369f0..f7773bd9c56d6 100644
--- a/clang/include/clang/Sema/Overload.h
+++ b/clang/include/clang/Sema/Overload.h
@@ -1146,8 +1146,9 @@ class Sema;
 
 /// Add a new candidate with NumConversions conversion sequence slots
 /// to the overload set.
-OverloadCandidate &addCandidate(unsigned NumConversions = 0,
-ConversionSequenceList Conversions = None) 
{
+OverloadCandidate &
+addCandidate(unsigned NumConversions = 0,
+ ConversionSequenceList Conversions = std::nullopt) {
   assert((Conversions.empty() || Conversions.size() == NumConversions) &&
  "preallocated conversion sequence has wrong length");
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 55f3f0e0a1cce..7a493c052ab1f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2886,12 +2886,10 @@ class Sema final {
 LookupResult &Previous);
   NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl 
*D,
   LookupResult &Previous, bool &Redeclaration);
-  NamedDecl *ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
- TypeSourceInfo *TInfo,
- LookupResult &Previous,
- MultiTemplateParamsArg TemplateParamLists,
- bool &AddToScope,
- ArrayRef Bindings = None);
+  NamedDecl *ActOnVariableDeclarator(
+ 

[clang] e31564a - [AST] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:13:41-08:00
New Revision: e31564afc3670d512274ccaa49e4fdd905f6b3d6

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

LOG: [AST] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ASTImporterSharedState.h
clang/include/clang/AST/CommentSema.h
clang/include/clang/AST/DeclFriend.h
clang/include/clang/AST/DeclObjC.h
clang/include/clang/AST/DeclOpenMP.h
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/ExprObjC.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/AST/TemplateName.h
clang/include/clang/AST/Type.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/AttrImpl.cpp
clang/lib/AST/Comment.cpp
clang/lib/AST/CommentParser.cpp
clang/lib/AST/ComparisonCategories.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/DeclOpenMP.cpp
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ExternalASTSource.cpp
clang/lib/AST/FormatString.cpp
clang/lib/AST/ItaniumCXXABI.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Linkage.h
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/Type.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index ba53880d86e62..63f48d9ae9871 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2293,7 +2293,7 @@ class ASTContext : public RefCountedBase {
 
   Optional getTypeSizeInCharsIfKnown(QualType Ty) const {
 if (Ty->isIncompleteType() || Ty->isDependentType())
-  return None;
+  return std::nullopt;
 return getTypeSizeInChars(Ty);
   }
 

diff  --git a/clang/include/clang/AST/ASTImporterSharedState.h 
b/clang/include/clang/AST/ASTImporterSharedState.h
index e374dbd0d4bf7..27f27a538bcb7 100644
--- a/clang/include/clang/AST/ASTImporterSharedState.h
+++ b/clang/include/clang/AST/ASTImporterSharedState.h
@@ -70,7 +70,7 @@ class ASTImporterSharedState {
 if (Pos != ImportErrors.end())
   return Pos->second;
 else
-  return None;
+  return std::nullopt;
   }
 
   void setImportDeclError(Decl *To, ASTImportError Error) {

diff  --git a/clang/include/clang/AST/CommentSema.h 
b/clang/include/clang/AST/CommentSema.h
index 5e30ff8adb915..9c2ca5f8e6037 100644
--- a/clang/include/clang/AST/CommentSema.h
+++ b/clang/include/clang/AST/CommentSema.h
@@ -80,7 +80,7 @@ class Sema {
   ArrayRef copyArray(ArrayRef Source) {
 if (!Source.empty())
   return Source.copy(Allocator);
-return None;
+return std::nullopt;
   }
 
   ParagraphComment *actOnParagraphComment(

diff  --git a/clang/include/clang/AST/DeclFriend.h 
b/clang/include/clang/AST/DeclFriend.h
index 6f8306c6025e4..d1de5c504ac4a 100644
--- a/clang/include/clang/AST/DeclFriend.h
+++ b/clang/include/clang/AST/DeclFriend.h
@@ -108,11 +108,10 @@ class FriendDecl final
   friend class ASTNodeImporter;
   friend TrailingObjects;
 
-  static FriendDecl *Create(ASTContext &C, DeclContext *DC,
-SourceLocation L, FriendUnion Friend_,
-SourceLocation FriendL,
-ArrayRef FriendTypeTPLists
-= None);
+  static FriendDecl *
+  Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_,
+ SourceLocation FriendL,
+ ArrayRef FriendTypeTPLists = std::nullopt);
   static FriendDecl *CreateDeserialized(ASTContext &C, unsigned ID,
 unsigned FriendTypeNumTPLists);
 

diff  --git a/clang/include/clang/AST/DeclObjC.h 
b/clang/include/clang/AST/DeclObjC.h
index 6e83060d5a4d4..657f7ffb10ef0 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -389,9 +389,8 @@ class ObjCMethodDecl : public NamedDecl, public DeclContext 
{
   /// Sets the method's parameter

[clang] bb666c6 - [CodeGen] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:13:43-08:00
New Revision: bb666c69300c962c6a259c9d8e504601e557bc30

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

LOG: [CodeGen] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGCleanup.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGLoopInfo.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/CodeGenPGO.h
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/CodeGen/SanitizerMetadata.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index cefeb8c25585..15e78908a6e8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -512,7 +512,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
 static Optional getGCOVOptions(const CodeGenOptions &CodeGenOpts,
 const LangOptions &LangOpts) {
   if (!CodeGenOpts.EmitGcovArcs && !CodeGenOpts.EmitGcovNotes)
-return None;
+return std::nullopt;
   // Not using 'GCOVOptions::getDefault' allows us to avoid exiting if
   // LLVM's -default-gcov-version flag is set to something invalid.
   GCOVOptions Options;
@@ -530,7 +530,7 @@ static Optional
 getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
 const LangOptions &LangOpts) {
   if (!CodeGenOpts.hasProfileClangInstr())
-return None;
+return std::nullopt;
   InstrProfOptions Options;
   Options.NoRedZone = CodeGenOpts.DisableRedZone;
   Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 403dfe4ff6e8..2b717208313f 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1180,7 +1180,7 @@ translateArmToMsvcIntrin(unsigned BuiltinID) {
   using MSVCIntrin = CodeGenFunction::MSVCIntrin;
   switch (BuiltinID) {
   default:
-return None;
+return std::nullopt;
   case clang::ARM::BI_BitScanForward:
   case clang::ARM::BI_BitScanForward64:
 return MSVCIntrin::_BitScanForward;
@@ -1326,7 +1326,7 @@ translateAarch64ToMsvcIntrin(unsigned BuiltinID) {
   using MSVCIntrin = CodeGenFunction::MSVCIntrin;
   switch (BuiltinID) {
   default:
-return None;
+return std::nullopt;
   case clang::AArch64::BI_BitScanForward:
   case clang::AArch64::BI_BitScanForward64:
 return MSVCIntrin::_BitScanForward;
@@ -1480,7 +1480,7 @@ translateX86ToMsvcIntrin(unsigned BuiltinID) {
   using MSVCIntrin = CodeGenFunction::MSVCIntrin;
   switch (BuiltinID) {
   default:
-return None;
+return std::nullopt;
   case clang::X86::BI_BitScanForward:
   case clang::X86::BI_BitScanForward64:
 return MSVCIntrin::_BitScanForward;
@@ -1715,7 +1715,7 @@ Value *CodeGenFunction::EmitCheckedArgForBuiltin(const 
Expr *E,
 SanitizerHandler::InvalidBuiltin,
 {EmitCheckSourceLocation(E->getExprLoc()),
  llvm::ConstantInt::get(Builder.getInt8Ty(), Kind)},
-None);
+std::nullopt);
   return ArgValue;
 }
 
@@ -16780,7 +16780,7 @@ Value *EmitAMDGPUWorkGroupSize(CodeGenFunction &CGF, 
unsigned Index) {
   APInt(16, CGF.getTarget().getMaxOpenCLWorkGroupSize() + 1));
   LD->setMetadata(llvm::LLVMContext::MD_range, RNode);
   LD->setMetadata(llvm::LLVMContext::MD_invariant_load,
-  llvm::MDNode::get(CGF.getLLVMContext(), None));
+  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
   return LD;
 }
 
@@ -16797,7 +16797,7 @@ Val

[PATCH] D139095: [clang] Add test for CWG405

2022-12-03 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 479858.
Endill retitled this revision from "[clang] Mark CWG405 as a duplicate of 
CWG218" to "[clang] Add test for CWG405".
Endill edited the summary of this revision.
Endill added a comment.

Reuse a part of CWG218 test, adding cross-references.


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

https://reviews.llvm.org/D139095

Files:
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -2470,7 +2470,7 @@
 https://wg21.link/cwg405";>405
 CD6
 Unqualified function name lookup
-Unknown
+Yes
   
   
 https://wg21.link/cwg406";>406
Index: clang/test/CXX/drs/dr4xx.cpp
===
--- clang/test/CXX/drs/dr4xx.cpp
+++ clang/test/CXX/drs/dr4xx.cpp
@@ -3,6 +3,7 @@
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 
%s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 
%s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++20 
%s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++2b 
%s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
 __extension__ typedef __SIZE_TYPE__ size_t;
@@ -79,6 +80,40 @@
 // dr404: na
 // (NB: also sup 594)
 
+namespace dr405 { // dr405: yes
+  // NB: also dup 218
+  namespace A {
+struct S {};
+void f(S);
+  }
+  namespace B {
+struct S {};
+void f(S);
+  }
+
+  struct C {
+int f;
+void test1(A::S as) { f(as); } // expected-error {{called object type 
'int'}}
+void test2(A::S as) { void f(); f(as); } // expected-error {{too many 
arguments}} expected-note {{}}
+void test3(A::S as) { using A::f; f(as); } // ok
+void test4(A::S as) { using B::f; f(as); } // ok
+void test5(A::S as) { int f; f(as); } // expected-error {{called object 
type 'int'}}
+void test6(A::S as) { struct f {}; (void) f(as); } // expected-error {{no 
matching conversion}} expected-note +{{}}
+  };
+
+  namespace D {
+struct S {};
+struct X { void operator()(S); } f;
+  }
+  void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}}
+
+  namespace E {
+struct S {};
+struct f { f(S); };
+  }
+  void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}}
+}
+
 namespace dr406 { // dr406: yes
   typedef struct {
 static int n; // expected-error {{static data member 'n' not allowed in 
anonymous struct}}
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -141,6 +141,7 @@
 }
 
 namespace dr218 { // dr218: yes
+  // NB: also dup 405
   namespace A {
 struct S {};
 void f(S);


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -2470,7 +2470,7 @@
 https://wg21.link/cwg405";>405
 CD6
 Unqualified function name lookup
-Unknown
+Yes
   
   
 https://wg21.link/cwg406";>406
Index: clang/test/CXX/drs/dr4xx.cpp
===
--- clang/test/CXX/drs/dr4xx.cpp
+++ clang/test/CXX/drs/dr4xx.cpp
@@ -3,6 +3,7 @@
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
 __extension__ typedef __SIZE_TYPE__ size_t;
@@ -79,6 +80,40 @@
 // dr404: na
 // (NB: also sup 594)
 
+namespace dr405 { // dr405: yes
+  // NB: also dup 218
+  namespace A {
+struct S {};
+void f(S);
+  }
+  namespace B {
+struct S {};
+void f(S);
+  }
+
+  struct C {
+int f;
+void test1(A::S as) { f(as); } // expected-error {{called object type 'int'}}
+void test2(A::S as) { void f(); f(as); } // expected-error {{too many arguments}} expected-note {{}}
+void test3(A::S as) { using A::f; f(as); } // ok
+void test4(A::S as) { using B::f; f(

[clang] 1806006 - [StaticAnalyzer] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:34:24-08:00
New Revision: 180600660bbbdf8e74f7372a00e24edb219f0868

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

LOG: [StaticAnalyzer] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/Yaml.h
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CallDescription.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
clang/lib/StaticAnalyzer/Core/Store.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 9ec5bcc875546..e1e4e285c52a5 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -629,14 +629,14 @@ class BugReporter {
   void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker,
StringRef BugName, StringRef BugCategory,
StringRef BugStr, PathDiagnosticLocation Loc,
-   ArrayRef Ranges = None,
-   ArrayRef Fixits = None);
+   ArrayRef Ranges = std::nullopt,
+   ArrayRef Fixits = std::nullopt);
 
   void EmitBasicReport(const Decl *DeclWithIssue, CheckerNameRef CheckerName,
StringRef BugName, StringRef BugCategory,
StringRef BugStr, PathDiagnosticLocation Loc,
-   ArrayRef Ranges = None,
-   ArrayRef Fixits = None);
+   ArrayRef Ranges = std::nullopt,
+   ArrayRef Fixits = std::nullopt);
 
 private:
   llvm::StringMap> StrBugTypes;
@@ -783,7 +783,7 @@ class NoteTag : public DataTag {
 PathSensitiveBugReport &R) const {
 std::string Msg = Cb(BRC, R);
 if (Msg.empty())
-  return None;
+  return std::nullopt;
 
 return std::move(Msg);
   }

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
index c378ab0322e01..368972d0382b5 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
@@ -65,13 +65,13 @@ class CallDescription {
   /// name regardless the number of arguments.
   CallDescription(CallDescriptionFlags Flags,
   ArrayRef QualifiedName,
-  MaybeCount RequiredArgs = None,
-  MaybeCount RequiredParams = None);
+  MaybeCount RequiredArgs = std::nullopt,
+  MaybeCount RequiredParams = std::nullopt);
 
   /// Construct a CallDescription with default flags.

[clang] 34e0d05 - [Analysis] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:34:25-08:00
New Revision: 34e0d0579a3a6617b9b3212f2bc63d959c8f56c6

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

LOG: [Analysis] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
clang/include/clang/Analysis/AnyCall.h
clang/include/clang/Analysis/CFG.h
clang/include/clang/Analysis/ProgramPoint.h
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/lib/Analysis/MacroExpansionContext.cpp
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/Analysis/UninitializedValues.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h 
b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
index 0b306d14be4d8..8964481ee66c5 100644
--- a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
+++ b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
@@ -54,11 +54,12 @@ class PostOrderCFGView : public ManagedAnalysis {
   // occasionally hand out null pointers for pruned edges, so we catch 
those
   // here.
   if (!Block)
-return std::make_pair(None, false); // if an edge is trivially false.
+return std::make_pair(std::nullopt,
+  false); // if an edge is trivially false.
   if (VisitedBlockIDs.test(Block->getBlockID()))
-return std::make_pair(None, false);
+return std::make_pair(std::nullopt, false);
   VisitedBlockIDs.set(Block->getBlockID());
-  return std::make_pair(None, true);
+  return std::make_pair(std::nullopt, true);
 }
 
 /// Check if the bit for a CFGBlock has been already set.

diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 48593516d8534..385cd02f882c0 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -1464,7 +1464,7 @@ class Return : public Terminator {
   static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
 
   /// Return an empty list.
-  ArrayRef successors() { return None; }
+  ArrayRef successors() { return std::nullopt; }
 
   SExpr *returnValue() { return Retval; }
   const SExpr *returnValue() const { return Retval; }
@@ -1490,7 +1490,7 @@ inline ArrayRef Terminator::successors() {
 case COP_Branch: return cast(this)->successors();
 case COP_Return: return cast(this)->successors();
 default:
-  return None;
+  return std::nullopt;
   }
 }
 

diff  --git a/clang/include/clang/Analysis/AnyCall.h 
b/clang/include/clang/Analysis/AnyCall.h
index 6e5e019ce2632..876d423a21f2d 100644
--- a/clang/include/clang/Analysis/AnyCall.h
+++ b/clang/include/clang/Analysis/AnyCall.h
@@ -123,7 +123,7 @@ class AnyCall {
 } else if (const auto *CXCIE = dyn_cast(E)) {
   return AnyCall(CXCIE);
 } else {
-  return None;
+  return std::nullopt;
 }
   }
 
@@ -136,13 +136,13 @@ class AnyCall {
 } else if (const auto *MD = dyn_cast(D)) {
   return AnyCall(MD);
 }
-return None;
+return std::nullopt;
   }
 
   /// \returns formal parameters for direct calls (including virtual calls)
   ArrayRef parameters() const {
 if (!D)
-  return None;
+  return std::nullopt;
 
 if (const auto *FD = dyn_cast(D)) {
   return FD->parameters();
@@ -151,7 +151,7 @@ class AnyCall {
 } else if (const auto *BD = dyn_cast(D)) {
   return BD->parameters();
 } else {
-  return None;
+  return std::nullopt;
 }
   }
 

diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index f3e005b890662..ecf5906fa1dca 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -108,7 +108,7 @@ class CFGElement {
   template
   Optional getAs() const {
 if (!T::isKind(*this))
-  return None;
+  return std::nullopt;
 T t;
 CFGElement& e = t;
 e = *this;

diff  --git a/clang/include/clang/Analysis/Pro

[clang] eeee3fe - [Basic] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:34:27-08:00
New Revision: 3fee37a65d68ebbfcb6e78b6b2e018180b0c

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

LOG: [Basic] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Basic/SourceManager.h
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/DarwinSDKInfo.cpp
clang/lib/Basic/DiagnosticIDs.cpp
clang/lib/Basic/FileManager.cpp
clang/lib/Basic/ProfileList.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/Basic/TargetID.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/lib/Basic/Targets/ARC.h
clang/lib/Basic/Targets/AVR.h
clang/lib/Basic/Targets/BPF.h
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/Lanai.h
clang/lib/Basic/Targets/Le64.h
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/MSP430.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/PNaCl.cpp
clang/lib/Basic/Targets/PNaCl.h
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/Sparc.h
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/Basic/Targets/XCore.h

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index 46121e491f4f6..c8e10fb88b963 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -272,7 +272,7 @@ class OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr
 
   OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr &
   operator=(std::nullopt_t) {
-Optional::operator=(None);
+Optional::operator=(std::nullopt);
 return *this;
   }
   OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr 
&operator=(DirectoryEntryRef Ref) {

diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index b001422a84404..3a2b9ffab0355 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -315,7 +315,7 @@ class OptionalFileEntryRefDegradesToFileEntryPtr
   : Optional(MaybeRef) {}
 
   OptionalFileEntryRefDegradesToFileEntryPtr &operator=(std::nullopt_t) {
-Optional::operator=(None);
+Optional::operator=(std::nullopt);
 return *this;
   }
   OptionalFileEntryRefDegradesToFileEntryPtr &operator=(FileEntryRef Ref) {

diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 8ab519f8431f0..b482b6a271c21 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -179,8 +179,9 @@ class alignas(8) ContentCache {
   mutable unsigned IsBufferInvalid : 1;
 
   ContentCache()
-  : OrigEntry(None), ContentsEntry(nullptr), BufferOverridden(false),
-IsFileVolatile(false), IsTransient(false), IsBufferInvalid(false) {}
+  : OrigEntry(std::nullopt), ContentsEntry(nullptr),
+BufferOverridden(false), IsFileVolatile(false), IsTransient(false),
+IsBufferInvalid(false) {}
 
   ContentCache(FileEntryRef Ent) : ContentCache(Ent, Ent) {}
 
@@ -236,7 +237,7 @@ class alignas(8) ContentCache {
   llvm::Optional getBufferIfLoaded() const {
 if (Buffer)
   return Buffer->getMemBufferRef();
-return None;
+return std::nullopt;
   }
 
   /// Return a StringRef to the source buffer data, only if it has already
@@ -244,7 +245,7 @@ class alignas(8) ContentCache {
   llvm::Optional getBufferDataIfLoaded() const {
 if (Buffer)
   return Buffer->getBuffer();
-return None;
+return std::nullopt;
   }
 
   /// Set the buffer.
@@ -1025,7 +1026,7 @@ class SourceManager : public 
RefCountedBase {
 if (auto *Entry = getSLocEntryForFile(FID))
   return Entry->getFile().getContentCache().getBufferOrNone(
   Diag, getFileManager(), Loc);
-return None;
+return std::nullopt;
   }
 
   /// Return the buffer for the specified FileID.
@@ -1050,7 +1051,7 @@ class SourceManager : public 
RefCountedBase {
   Optional getFileEntryRefForID(FileID FID) const {
 if (auto *Entry = getSLocEntryForFile(FID))
   return

[clang] 0c2f6e3 - [Driver] llvm::None => std::nullopt. NFC

2022-12-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-03T19:43:25Z
New Revision: 0c2f6e36f9b2d26a2665e38a76ae8a95c158c4c7

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

LOG: [Driver] llvm::None => std::nullopt. NFC

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Arch/CSKY.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 6bd2d38f65744..7765ef0898dc2 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -115,10 +115,10 @@ getOffloadTargetTriple(const Driver &D, const ArgList 
&Args) {
   switch (OffloadTargets.size()) {
   default:
 D.Diag(diag::err_drv_only_one_offload_target_supported);
-return llvm::None;
+return std::nullopt;
   case 0:
 D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << "";
-return llvm::None;
+return std::nullopt;
   case 1:
 break;
   }
@@ -138,10 +138,10 @@ getNVIDIAOffloadTargetTriple(const Driver &D, const 
ArgList &Args,
 if (Args.hasArg(options::OPT_emit_llvm))
   return TT;
 D.Diag(diag::err_drv_cuda_offload_only_emit_bc);
-return llvm::None;
+return std::nullopt;
   }
   D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << TT->str();
-  return llvm::None;
+  return std::nullopt;
 }
 static llvm::Optional
 getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) {
@@ -150,7 +150,7 @@ getHIPOffloadTargetTriple(const Driver &D, const ArgList 
&Args) {
   }
   auto TT = getOffloadTargetTriple(D, Args);
   if (!TT)
-return llvm::None;
+return std::nullopt;
   if (TT->getArch() == llvm::Triple::amdgcn &&
   TT->getVendor() == llvm::Triple::AMD &&
   TT->getOS() == llvm::Triple::AMDHSA)
@@ -158,7 +158,7 @@ getHIPOffloadTargetTriple(const Driver &D, const ArgList 
&Args) {
   if (TT->getArch() == llvm::Triple::spirv64)
 return TT;
   D.Diag(diag::err_drv_invalid_or_unsupported_offload_target) << TT->str();
-  return llvm::None;
+  return std::nullopt;
 }
 
 // static
@@ -1596,7 +1596,7 @@ void Driver::generateCompilationDiagnostics(
 NewLLDInvocation.replaceArguments(std::move(ArgList));
 
 // Redirect stdout/stderr to /dev/null.
-NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
+NewLLDInvocation.Execute({std::nullopt, {""}, {""}}, nullptr, nullptr);
 Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
 Diag(clang::diag::note_drv_command_failed_diag_msg) << TmpName;
 Diag(clang::diag::note_drv_command_failed_diag_msg)
@@ -3128,7 +3128,7 @@ class OffloadingActionBuilder final {
 llvm::Optional>
 getConflictOffloadArchCombination(
 const std::set &GpuArchs) override {
-  return llvm::None;
+  return std::nullopt;
 }
 
 ActionBuilderReturnCode
@@ -4211,7 +4211,7 @@ static llvm::Optional>
 getConflictOffloadArchCombination(const llvm::DenseSet &Archs,
   Action::OffloadKind Kind) {
   if (Kind != Action::OFK_HIP)
-return None;
+return std::nullopt;
 
   std::set ArchSet;
   llvm::copy(Archs, std::inserter(ArchSet, ArchSet.begin()));
@@ -5721,7 +5721,7 @@ std::string Driver::GetFilePath(StringRef Name, const 
ToolChain &TC) const {
   if (llvm::sys::fs::exists(Twine(P)))
 return std::string(P);
 }
-return None;
+return std::nullopt;
   };
 
   if (auto P = SearchPaths(PrefixDirs))

diff  --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 2aaa0179a4948..a21deef7a30a8 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -417,7 +417,7 @@ class BinaryFileHandler final : public FileHandler {
 
   Expected> ReadBundleStart(MemoryBuffer &Input) final {
 if (NextBundleInfo == BundlesInfo.end())
-  return None;
+  return std::nullopt;
 CurBundleInfo = NextBundleInfo++;
 return CurBundleInfo->first();
   }
@@ -545,7 +545,7 @@ class ObjectFileHandler final : public FileHandler {
 
 // If it does not start with the reserved suffix, just skip this section.
 if (!NameOrErr->startswith(OFFLOAD_BUNDLER_MAGIC_STR))
-  return None;
+  return std::nullopt;
 
 // Return the triple that is right after the reserved prefix.
 return NameOrErr->substr(sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1);
@@ -590,7 +590,7 @@ class ObjectFileHandler final : public FileHandler {
   if (*TripleOrErr)
 return *

[PATCH] D139257: [clang-format][NFC] Link braces of a block in UnwrappedLineParser

2022-12-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2714
+
+static void resetOptional(FormatToken *LBrace) {
+  if (!LBrace)

This should be named differently. For me reset means assigning false.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139257

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


[PATCH] D138358: [clang-format] Match all block braces

2022-12-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks abandoned this revision.
HazardyKnusperkeks added a comment.

In D138358#3968610 , @owenpan wrote:

> Please see D139257  for a different 
> approach.

All my hard work... *sniff*.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138358

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


[PATCH] D139095: [clang] Add test for CWG405

2022-12-03 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr4xx.cpp:99
+void test3(A::S as) { using A::f; f(as); } // ok
+void test4(A::S as) { using B::f; f(as); } // ok
+void test5(A::S as) { int f; f(as); } // expected-error {{called object 
type 'int'}}

I'm surprised that local function declaration prevents ADL, but 
//using-declaration// doesn't. It has been working this way all along, so I 
guess I better take a note of this.


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

https://reviews.llvm.org/D139095

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


[clang-tools-extra] 059a23c - [clang-tools-extra] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:54:50-08:00
New Revision: 059a23c0f01fd6e5bcef0e403d8108a761ad66f5

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

LOG: [clang-tools-extra] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp
clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/Config.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/DraftStore.cpp
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/ExpectedTypes.cpp
clang-tools-extra/clangd/FS.cpp
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/FuzzyMatch.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/clangd/GlobalCompilationDatabase.h
clang-tools-extra/clangd/HeaderSourceSwitch.cpp
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/PathMapping.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticSelection.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/SystemIncludeExtractor.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/IndexAction.cpp
clang-tools-extra/clangd/index/StdLib.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/dex/PostingList.cpp
clang-tools-extra/clangd/refactor/InsertionPoint.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/support/FileCache.cpp
clang-tools-extra/clangd/support/ThreadsafeFS.cpp
clang-tools-extra/clangd/tool/Check.cpp
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/DirectiveTree.cpp
clang-tools-extra/pseudo/lib/Forest.cpp
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 11a78ba60e35c..03c698cde0459 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -308,7 +308,7 @@ static std::unique_ptr genLink(const Twine &Text, 
const Twine &Link) {
 
 static std::unique_ptr
 genReference(const Reference &Type, StringRef CurrentDirectory,
- llvm::Optional JumpToSection = None) {
+ llvm::Optional JumpToSection = std::nullopt) {
   if (Type.Path.empty()) {
 if (!JumpToSection)
   return std::make_unique(Type.Name);
@@ -437,7 +437,7 @@ genReferencesBlock(const std::vector &References,
 
 static std::unique_ptr
 writeFileDefinition(const Location &L,
-llvm::Optional RepositoryUrl = None) {
+llvm::Optional RepositoryUrl = std::nullopt) {
   if (!L.IsFileInRootDir || !RepositoryUrl)
 return std::make_unique(
 HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +

diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-symbols/Fin

[clang-tools-extra] cd8702e - [clang-tidy] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T11:54:48-08:00
New Revision: cd8702efe7e6cacfd82cc4909e42718224bcd5d0

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

LOG: [clang-tidy] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/clang-tidy/utils/IncludeInserter.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/clang-tidy/utils/UsingInserter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 83aef0a40c9a1..6bb0b2ac32513 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -58,7 +58,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
   const auto &Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter != CheckOptions.end())
 return StringRef(Iter->getValue().Value);
-  return None;
+  return std::nullopt;
 }
 
 static ClangTidyOptions::OptionMap::const_iterator
@@ -86,7 +86,7 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef 
LocalName) const {
  Context->getOptionsCollector());
   if (Iter != CheckOptions.end())
 return StringRef(Iter->getValue().Value);
-  return None;
+  return std::nullopt;
 }
 
 static Optional getAsBool(StringRef Value,
@@ -99,7 +99,7 @@ static Optional getAsBool(StringRef Value,
   long long Number;
   if (!Value.getAsInteger(10, Number))
 return Number != 0;
-  return None;
+  return std::nullopt;
 }
 
 template <>
@@ -110,7 +110,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) 
const {
   return Result;
 diagnoseBadBooleanOption(NamePrefix + LocalName, *ValueOr);
   }
-  return None;
+  return std::nullopt;
 }
 
 template <>
@@ -123,7 +123,7 @@ 
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
   return Result;
 diagnoseBadBooleanOption(Iter->getKey(), Iter->getValue().Value);
   }
-  r

[clang] a41fbb1 - [clang/unittests] Use std::nullopt instead of None (NFC)

2022-12-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-12-03T12:14:19-08:00
New Revision: a41fbb1fc2126e9791fd0f159f21935f6c2f93c4

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

LOG: [clang/unittests] Use std::nullopt instead of None (NFC)

This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
clang/unittests/Basic/DarwinSDKInfoTest.cpp
clang/unittests/Basic/FileEntryTest.cpp
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
clang/unittests/Frontend/ASTUnitTest.cpp
clang/unittests/Lex/HeaderSearchTest.cpp
clang/unittests/Serialization/SourceLocationEncodingTest.cpp
clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp
clang/unittests/Tooling/ASTSelectionTest.cpp
clang/unittests/Tooling/HeaderAnalysisTest.cpp
clang/unittests/Tooling/SourceCodeBuildersTest.cpp
clang/unittests/Tooling/StandardLibraryTest.cpp
clang/unittests/Tooling/StencilTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index cb8c0bf5dcd5a..865574f0fec6d 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -4818,7 +4818,7 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportSubstTemplateTypeParmType) {
 ASSERT_EQ(Subst->getPackIndex(), PackIndex);
   };
   auto tests = [&](ASTContext &Ctx) {
-testType(Ctx, "void", None);
+testType(Ctx, "void", std::nullopt);
 testType(Ctx, "char", 3);
 testType(Ctx, "float", 2);
 testType(Ctx, "int", 1);

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
index 39a1e1dd0859f..4562a6294b2df 100644
--- a/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
@@ -61,9 +61,10 @@ struct ValueLattice {
   // When `None`, the lattice is either at top or bottom, based on `State`.
   llvm::Optional Value;
 
-  constexpr ValueLattice() : State(ValueState::Undefined), Value(llvm::None) {}
+  constexpr ValueLattice()
+  : State(ValueState::Undefined), Value(std::nullopt) {}
   constexpr ValueLattice(int64_t V) : State(ValueState::Defined), Value(V) {}
-  constexpr ValueLattice(ValueState S) : State(S), Value(llvm::None) {}
+  constexpr ValueLattice(ValueState S) : State(S), Value(std::nullopt) {}
 
   static constexpr ValueLattice bottom() {
 return ValueLattice(ValueState::Undefined);

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
index 60b7860917899..9c52ed1b52e2f 100644
--- 
a/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ 
b/clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -63,7 +63,9 @@ struct ConstantPropagationLattice {
   // `None` is "bottom".
   llvm::Optional Data;
 
-  static constexpr ConstantPropagationLattice bottom() { return {llvm::None}; }
+  static constexpr ConstantPropagationLattice bottom() {
+return {std::nullopt};
+  }
   static constexpr ConstantPropagationLattice top() {
 return {VarValue{nullptr, 0}};
   }

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 01f61cab3716e..7e7be3c9e07ef 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3849,7 +3849,7 @@ TEST(TransferTest, ContextSensitiveOptionDisabled) {
 EXPECT_FALSE(Env.flowConditionImplies(FooVal));
 EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal)));
   },
-  {TransferOptions{/*.ContextSensitiveOpts=*/llvm::None}});
+  {TransferOptions{/*.ContextSensitiveOpts=*/std::nullopt}});
 }
 
 TEST(TransferTest, ContextSensitiveDepthZero) {

diff  --git a/clang/unittests/Basic/DarwinSDKInfoTest.cpp 
b/clang/unittests/Basic/DarwinSDKIn

[clang] 2c5d49c - [Driver] llvm::Optional => std::optional

2022-12-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-12-03T20:17:05Z
New Revision: 2c5d49cffc1f2db52e5119bdbb44f0b10a678fb7

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

LOG: [Driver] llvm::Optional => std::optional

and change a few referenced Basic and llvm/lib/WindowsDriver API

Added: 


Modified: 
clang/include/clang/Basic/DarwinSDKInfo.h
clang/include/clang/Basic/TargetID.h
clang/include/clang/Driver/ToolChain.h
clang/lib/Basic/DarwinSDKInfo.cpp
clang/lib/Basic/TargetID.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/AVR.h
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/CSKY.cpp
clang/lib/Driver/ToolChains/Arch/CSKY.h
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
clang/lib/Driver/ToolChains/HLSL.cpp
clang/lib/Driver/ToolChains/HLSL.h
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/Driver/ToolChains/Hexagon.h
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Driver/ToolChains/MSVC.h
clang/lib/Sema/SemaDeclAttr.cpp
llvm/include/llvm/WindowsDriver/MSVCPaths.h
llvm/lib/WindowsDriver/MSVCPaths.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DarwinSDKInfo.h 
b/clang/include/clang/Basic/DarwinSDKInfo.h
index cac9d22b32a32..8cc10df4924b1 100644
--- a/clang/include/clang/Basic/DarwinSDKInfo.h
+++ b/clang/include/clang/Basic/DarwinSDKInfo.h
@@ -100,9 +100,9 @@ class DarwinSDKInfo {
 /// Returns the mapped key, or the appropriate Minimum / MaximumValue if
 /// they key is outside of the mapping bounds. If they key isn't mapped, 
but
 /// within the minimum and maximum bounds, None is returned.
-Optional map(const VersionTuple &Key,
-   const VersionTuple &MinimumValue,
-   Optional MaximumValue) const;
+std::optional
+map(const VersionTuple &Key, const VersionTuple &MinimumValue,
+std::optional MaximumValue) const;
 
 static Optional
 parseJSON(const llvm::json::Object &Obj,
@@ -145,7 +145,7 @@ class DarwinSDKInfo {
 return Mapping->getSecond() ? &*Mapping->getSecond() : nullptr;
   }
 
-  static Optional
+  static std::optional
   parseDarwinSDKSettingsJSON(const llvm::json::Object *Obj);
 
 private:
@@ -162,8 +162,8 @@ class DarwinSDKInfo {
 ///
 /// \returns an error if the SDKSettings.json file is invalid, None if the
 /// SDK has no SDKSettings.json, or a valid \c DarwinSDKInfo otherwise.
-Expected> parseDarwinSDKInfo(llvm::vfs::FileSystem 
&VFS,
- StringRef SDKRootPath);
+Expected>
+parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath);
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/Basic/TargetID.h 
b/clang/include/clang/Basic/TargetID.h
index a34bebbae1ad4..de24253ec9ed3 100644
--- a/clang/include/clang/Basic/TargetID.h
+++ b/clang/include/clang/Basic/TargetID.h
@@ -49,7 +49,7 @@ std::string getCanonicalTargetID(llvm::StringRef Processor,
 /// Get the conflicted pair of target IDs for a compilation or a bundled code
 /// object, assuming \p TargetIDs are canonicalized. If there is no conflicts,
 /// returns None.
-llvm::Optional>
+std::optional>
 getConflictTargetIDCombination(const std::set &TargetIDs);
 
 /// Check whether the provided target ID is compatible with the requested

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index ec00bf9eb5945..396cf6a9e2fa1 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -181,9 +181,9 @@ class ToolChain {
 EffectiveTriple = std::move(ET);
   }
 
-  mutable llvm::Optional cxxStdlibType;
-  mutable llvm::Optional runtimeLibType;
-  mutable llvm::Optional unwindLibType;
+  mutable std::optional cxxStdlibType;
+  mutable std::optional runtimeLibType;
+  mutable std::optional unwindLibType;
 
 protected:
   MultilibSet Multilibs;

diff  --git a/clang/lib/Basic/DarwinSDKInfo.cpp 
b/clang/lib/Basic/DarwinSDKInfo.cpp
index ca2412008c03a..a1c071c5f620d 100644
--- a/clang/lib/Basic/DarwinSDKInfo.cpp
+++ b/clang/lib/Basic/DarwinSDKInfo.cpp
@@ -14,9 +14,9 @@
 
 using namespace clang;
 
-Optional DarwinSDKInfo::RelatedTargetVersionMapping::map(
+std::optional DarwinSDKInfo::RelatedTargetVersionMapping::map(
 const VersionTuple &Key, const VersionTuple &MinimumValue,
-Optional MaximumValue) const {
+std::optional MaximumValue) const {
   if (Key < MinimumKeyVersion)
 return Min

[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-12-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: tentzen.
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:5402-5411
+if (SanOpts.has(SanitizerKind::ExceptionEscape) &&
+ExceptionEscapeUBLastInvokeSrcLoc) {
+  llvm::Constant *CheckSourceLocation = EmitCheckSourceLocation(Loc);
+  Builder.CreateStore(
+  CheckSourceLocation,
+  Address(ExceptionEscapeUBLastInvokeSrcLoc,
+  CheckSourceLocation->getType(),

lebedev.ri wrote:
> lebedev.ri wrote:
> > rjmccall wrote:
> > > lebedev.ri wrote:
> > > > lebedev.ri wrote:
> > > > > @rjmccall
> > > > > So there are two issues:
> > > > > 1. `getInvokeDest()` isn't necessarily called just before creating an 
> > > > > `invoke`, see e.g. `-EHa` handling in 
> > > > > `CodeGenFunction::PopCleanupBlock()`
> > > > > 2. Even if we ignore that, we need to do this for *every* `invoke`, 
> > > > > not just those going to the our UB landing pad, consider: 
> > > > > https://godbolt.org/z/qTeKor41a <- the invoke leads to a normal 
> > > > > landing pad, yet we immediately rethrow the just-caught exception, 
> > > > > and now end up in the UB landing pad.
> > > > > 
> > > > > So i'm not really seeing an alternative path here?
> > > > @rjmccall do you agree with my reasoning here?
> > > > Perhaps there is some other solution that i'm not seeing,
> > > > other than not having the source location?
> > > I think there are four interesting questions posed by your example.
> > > 
> > > The first is whether we should make an effort to report the original 
> > > source location for the call to `maybe_throws` instead of the rethrow 
> > > location.  To me, the answer is no, and the main reason is that the user 
> > > is explicitly acknowledging the possibility of an exception and is 
> > > (probably) trying to handle it.  That means that the proximate source of 
> > > programmer error is now that their attempt to handle it failed, not that 
> > > an exception was raised in the first place.  That might seem weird for 
> > > your example specifically, 
> > > 
> > > The second is what source location we should report for invokes that 
> > > don't have an obvious source location.  The answer is that I think we 
> > > should always try to have a source location, even if it might be an 
> > > imperfect one.  Synthesized code almost always has a source location that 
> > > triggered the synthesis.  Cleanups are typically associated with some 
> > > variable or temporary that itself should have a source location.  Even 
> > > things like `__cxa_end_catch` are associated with the `catch` clause.  
> > > Hopefully UBSan  has a flexible enough schema in how source locations are 
> > > expressed to it for us to communicate these things down to the runtime, 
> > > like "synthesized code at Foo.cpp:18" or "cleanup for variable at 
> > > Bar.cpp:107".
> > > 
> > > The third is the more general question of whether we need to store a 
> > > source location before every `invoke`.  To ensure that this variable is 
> > > meaningfully initialized, we need to store a source location before every 
> > > invoke that can lead to a UB scope.  But the variable is stateful, so 
> > > it's equally important that we not emit stores that might overwrite the 
> > > source location that we actually want to report.  For example, we want 
> > > the source location reported in your example to be the source location 
> > > for the `throw;`, not something associated with the `__cxa_end_catch` 
> > > cleanup.  This basically boils down to not doing stores within a landing 
> > > pad before it enters a `catch` handler.  Fortunately, landing pad code 
> > > like that should always be in a terminate scope, so I think you can just 
> > > look at the current EH stack and see whether the landing pad can possibly 
> > > reach a UB scope.  (You might need some save-and-restore logic around 
> > > `@finally` blocks in ObjC.)
> > > 
> > > The final question is whether we need to emit cleanups on paths that lead 
> > > to UB scopes at all.  In the simplest cases, I think we don't.  The 
> > > standard says that it's implementation-specified whether the stack is 
> > > unwound on an exception path that leads to termination.  That rule 
> > > doesn't technically apply here, but only because we're dealing with a 
> > > language extension that makes unwinding UB in the first place.  Since we 
> > > have room to choose the semantics, the standard gives us pretty strong 
> > > cover to be just as aggressive about skipping cleanups in contexts where 
> > > throwing is UB as it is in contexts where throwing terminates.  That, in 
> > > turn, means that the landing pad in these contexts will usually just be a 
> > > UB scope with no cleanups in it.  So even if we did need to worry about 
> > > cleanups overwriting the source location, it usually won't be possible 
> > > because we won't be running cleanups.  In fact, if there's a catch-all or 
> > > a ter

[PATCH] D139261: [Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to cover anonymous struct in a union GNU extension

2022-12-03 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
shafik requested review of this revision.

`AggExprEmitter::VisitInitListExpr` sanity checks that an empty union is really 
empty and not a semantic analysis failure. The assert is missing that we allow 
anonymous structs as a GNU extension. I have updated the assert to take that 
into account.

This fixes: https://github.com/llvm/llvm-project/issues/58800


https://reviews.llvm.org/D139261

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/SemaCXX/anonymous-struct.cpp


Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -189,3 +189,20 @@
   }
 } A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
 }
+
+#if __cplusplus > 201103L
+namespace GH58800 {
+struct A {
+  union {
+struct {
+  float red = 0.0f;
+};
+  };
+};
+
+A GetA() {
+  A result{};
+  return result;
+}
+}
+#endif
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1685,7 +1685,7 @@
   // Make sure that it's really an empty and not a failure of
   // semantic analysis.
   for (const auto *Field : record->fields())
-assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed");
+assert((Field->isUnnamedBitfield() || 
Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous 
class allowed");
 #endif
   return;
 }


Index: clang/test/SemaCXX/anonymous-struct.cpp
===
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -189,3 +189,20 @@
   }
 } A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
 }
+
+#if __cplusplus > 201103L
+namespace GH58800 {
+struct A {
+  union {
+struct {
+  float red = 0.0f;
+};
+  };
+};
+
+A GetA() {
+  A result{};
+  return result;
+}
+}
+#endif
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -1685,7 +1685,7 @@
   // Make sure that it's really an empty and not a failure of
   // semantic analysis.
   for (const auto *Field : record->fields())
-assert(Field->isUnnamedBitfield() && "Only unnamed bitfields allowed");
+assert((Field->isUnnamedBitfield() || Field->isAnonymousStructOrUnion()) && "Only unnamed bitfields or ananymous class allowed");
 #endif
   return;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139261: [Clang] Modify sanity check assert in AggExprEmitter::VisitInitListExpr to cover anonymous struct in a union GNU extension

2022-12-03 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I realize I am modifying codegen but the test is in sema, I am happy to move 
the test to somewhere more appropriate if someone has a good suggestion.


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

https://reviews.llvm.org/D139261

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


[PATCH] D139257: [clang-format][NFC] Link braces of a block in UnwrappedLineParser

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 479884.
owenpan added a comment.

Updated `resetOptional()` to make resetting `Optional` more obvious.


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

https://reviews.llvm.org/D139257

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

Index: clang/unittests/Format/BracesRemoverTest.cpp
===
--- clang/unittests/Format/BracesRemoverTest.cpp
+++ clang/unittests/Format/BracesRemoverTest.cpp
@@ -204,6 +204,20 @@
"while (j < 0) { ++j; }",
Style);
 
+  verifyFormat("for (;;) {\n"
+   "  for (;;)\n"
+   "for (;;)\n"
+   "  a;\n"
+   "}",
+   "for (;;) {\n"
+   "  for (;;) {\n"
+   "for (;;) {\n"
+   "  a;\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a)\n"
"  b; // comment\n"
"else if (c)\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -934,6 +934,9 @@
 return IfLBrace;
   }
 
+  Tok->MatchingParen = FormatTok;
+  FormatTok->MatchingParen = Tok;
+
   const bool IsFunctionRBrace =
   FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace);
 
@@ -967,10 +970,7 @@
 }
 return mightFitOnOneLine((*CurrentLines)[Index], Tok);
   };
-  if (RemoveBraces()) {
-Tok->MatchingParen = FormatTok;
-FormatTok->MatchingParen = Tok;
-  }
+  Tok->Optional = RemoveBraces();
 
   size_t PPEndHash = computePPHash();
 
@@ -2707,10 +2707,20 @@
 
   assert(RightBrace->is(tok::r_brace));
   assert(RightBrace->MatchingParen == LeftBrace);
-  assert(LeftBrace->Optional == RightBrace->Optional);
 
-  LeftBrace->Optional = true;
-  RightBrace->Optional = true;
+  RightBrace->Optional = LeftBrace->Optional;
+}
+
+static void resetOptional(FormatToken *LeftBrace) {
+  if (!LeftBrace)
+return;
+
+  const auto *RightBrace = LeftBrace->MatchingParen;
+  const bool IsOptionalRightBrace = RightBrace && RightBrace->Optional;
+  assert(LeftBrace->Optional || !IsOptionalRightBrace);
+
+  if (!IsOptionalRightBrace)
+LeftBrace->Optional = false;
 }
 
 void UnwrappedLineParser::handleAttributes() {
@@ -2770,8 +2780,7 @@
 
   if (Style.RemoveBracesLLVM) {
 assert(!NestedTooDeep.empty());
-KeepIfBraces = KeepIfBraces ||
-   (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
+KeepIfBraces = KeepIfBraces || (IfLeftBrace && !IfLeftBrace->Optional) ||
NestedTooDeep.back() || IfBlockKind == IfStmtKind::IfOnly ||
IfBlockKind == IfStmtKind::IfElseIf;
   }
@@ -2802,8 +2811,9 @@
  ElseBlockKind == IfStmtKind::IfElseIf;
   } else if (FollowedByIf && IfLBrace && !IfLBrace->Optional) {
 KeepElseBraces = true;
+assert(ElseLeftBrace->Optional);
 assert(ElseLeftBrace->MatchingParen);
-markOptionalBraces(ElseLeftBrace);
+ElseLeftBrace->MatchingParen->Optional = true;
   }
   addUnwrappedLine();
 } else if (FormatTok->is(tok::kw_if)) {
@@ -2838,7 +2848,7 @@
 
   assert(!NestedTooDeep.empty());
   KeepElseBraces = KeepElseBraces ||
-   (ElseLeftBrace && !ElseLeftBrace->MatchingParen) ||
+   (ElseLeftBrace && !ElseLeftBrace->Optional) ||
NestedTooDeep.back();
 
   NestedTooDeep.pop_back();
@@ -2846,17 +2856,11 @@
   if (!KeepIfBraces && !KeepElseBraces) {
 markOptionalBraces(IfLeftBrace);
 markOptionalBraces(ElseLeftBrace);
-  } else if (IfLeftBrace) {
-FormatToken *IfRightBrace = IfLeftBrace->MatchingParen;
-if (IfRightBrace) {
-  assert(IfRightBrace->MatchingParen == IfLeftBrace);
-  assert(!IfLeftBrace->Optional);
-  assert(!IfRightBrace->Optional);
-  IfLeftBrace->MatchingParen = nullptr;
-  IfRightBrace->MatchingParen = nullptr;
-}
   }
 
+  resetOptional(IfLeftBrace);
+  resetOptional(ElseLeftBrace);
+
   if (IfKind)
 *IfKind = Kind;
 
@@ -3071,6 +3075,7 @@
   if (!NestedTooDeep.back())
 markOptionalBraces(LeftBrace);
 }
+resetOptional(LeftBrace);
 if (WrapRightBrace)
   addUnwrappedLine();
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138358: [clang-format] Match all block braces

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D138358#3968759 , 
@HazardyKnusperkeks wrote:

> In D138358#3968610 , @owenpan wrote:
>
>> Please see D139257  for a different 
>> approach.
>
> All my hard work... *sniff*.

I can definitely sympathise as I've abandoned a lot patches, the vast majority 
of which were never even submitted.

I had spent a lot of time playing with your patch but couldn't decide if it 
would break removing optional braces. Because I liked your idea of linking 
block braces early in the parser instead but wanted to avoid changing the 
signature of `parseBlock()` in doing so, I came up with a different approach. 
It was only then that I found the litmus test 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138358

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


[PATCH] D139266: Headers: tweak inclusion condition for stdatomic.h

2022-12-03 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: aaron.ballman, Mordante, fsb4000.
Herald added a project: All.
compnerd requested review of this revision.
Herald added a project: clang.

MSVC requires that C++23 be available (`_HAS_CXX23`) else the entire
content is elided.  Conditionalise the inclusion properly so that C/C++
code using `stdatomic.h` for `memory_order_*` constants are able to do
so without changing the C++ standard.  This repairs builds of Swift and
libdispatch after ba49d39b20cc5358da28af2ac82bd336028780bc 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139266

Files:
  clang/lib/Headers/stdatomic.h


Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -17,8 +17,8 @@
  * explicitly disallows `stdatomic.h` in the C mode via an `#error`.  Fallback
  * to the clang resource header until that is fully supported.
  */
-#if __STDC_HOSTED__ && 
\
-__has_include_next() && !(defined(_MSC_VER) && 
!defined(__cplusplus))
+#if __STDC_HOSTED__ && __has_include_next()   
 \
+&& !(defined(_MSC_VER) && __cplusplus-0 < 202002l)
 # include_next 
 #else
 


Index: clang/lib/Headers/stdatomic.h
===
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -17,8 +17,8 @@
  * explicitly disallows `stdatomic.h` in the C mode via an `#error`.  Fallback
  * to the clang resource header until that is fully supported.
  */
-#if __STDC_HOSTED__ && \
-__has_include_next() && !(defined(_MSC_VER) && !defined(__cplusplus))
+#if __STDC_HOSTED__ && __has_include_next()\
+&& !(defined(_MSC_VER) && __cplusplus-0 < 202002l)
 # include_next 
 #else
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138378: [clang-format][NFC] Skip unneeded calculations

2022-12-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

The refactoring `std::max(0, C.Spaces)` part still looks good though, but 
probably it's not worth it to have a patch just for that.


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

https://reviews.llvm.org/D138378

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


[PATCH] D139267: Supporting tbaa.struct metadata generation for bitfields

2022-12-03 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 created this revision.
strimo378 added a project: clang.
Herald added subscribers: jeroen.dobbelaere, kosarev.
Herald added a project: All.
strimo378 requested review of this revision.
Herald added a subscriber: cfe-commits.

Hi all,

this is my first contribution to the LLVM project.

The patch adds support for generating the tbaa.struct metadata for structs 
containing bitfields. The current implementation does not support bitfields and 
even generates wrong tbaa.struct metadata ... see 
https://github.com/llvm/llvm-project/issues/59328 .

The patch is not yet finished. I need some help to create an appropriate test 
case. My first test case looks like that

  struct a {
int : 8;
int b1 : 4;
int b2 : 8;
  };
  a i1,i2;
  void c() { i1 = i2; }

and should generate the following metadata

call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 bitcast (%struct.a* @i1 to 
i8*), i8* align 4 bitcast (%struct.a* @i2 to i8*), i64 4, i1 false), 
!tbaa.struct !3
  ...
!3 = !{i64 1, i64 2, !4}

Furthermore, I am unsure what Type should be used for adding bitfields to 
tbaa.struct. The original type or char? The current implementation uses the 
original type (if not alias).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139267

Files:
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/lib/CodeGen/CodeGenTBAA.h


Index: clang/lib/CodeGen/CodeGenTBAA.h
===
--- clang/lib/CodeGen/CodeGenTBAA.h
+++ clang/lib/CodeGen/CodeGenTBAA.h
@@ -146,6 +146,12 @@
   /// considered to be equivalent to it.
   llvm::MDNode *getChar();
 
+  /// AddCollectedField - Add one collected field to Fields vector
+  void
+  AddCollectedField(SmallVectorImpl &Fields,
+uint64_t Offset, uint64_t Size, QualType QTy, bool 
MayAlias,
+bool FuseOverlapping);
+
   /// CollectFields - Collect information about the fields of a type for
   /// !tbaa.struct metadata formation. Return false for an unsupported type.
   bool CollectFields(uint64_t BaseOffset,
Index: clang/lib/CodeGen/CodeGenTBAA.cpp
===
--- clang/lib/CodeGen/CodeGenTBAA.cpp
+++ clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -272,13 +272,28 @@
 Size);
 }
 
+void CodeGenTBAA::AddCollectedField(
+SmallVectorImpl &Fields, uint64_t Offset,
+uint64_t Size, QualType QTy, bool MayAlias, bool FuseOverlapping) {
+
+  // Fuse fields that overlap in their byte position (e.g. caused by bitfields)
+  if (FuseOverlapping && !Fields.empty() && Offset < Fields.back().Offset + 
Fields.back().Size) {
+Fields.back().Size = Fields.back().Offset - Offset + Size;
+return;
+  }
+
+  llvm::MDNode *TBAAType = MayAlias ? getChar() : getTypeInfo(QTy);
+  llvm::MDNode *TBAATag = getAccessTagInfo(TBAAAccessInfo(TBAAType, Size));
+  Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag));
+}
+
 bool
 CodeGenTBAA::CollectFields(uint64_t BaseOffset,
QualType QTy,
SmallVectorImpl &
  Fields,
bool MayAlias) {
-  /* Things not handled yet include: C++ base classes, bitfields, */
+  /* Things not handled yet include: C++ base classes */
 
   if (const RecordType *TTy = QTy->getAs()) {
 const RecordDecl *RD = TTy->getDecl()->getDefinition();
@@ -300,19 +315,25 @@
   uint64_t Offset = BaseOffset +
 Layout.getFieldOffset(idx) / Context.getCharWidth();
   QualType FieldQTy = i->getType();
-  if (!CollectFields(Offset, FieldQTy, Fields,
- MayAlias || TypeHasMayAlias(FieldQTy)))
-return false;
+  bool FieldMayAlias = MayAlias || TypeHasMayAlias(FieldQTy);
+  if ((*i)->isBitField()) {
+uint64_t EndOffset =
+BaseOffset +
+(Layout.getFieldOffset(idx) + (*i)->getBitWidthValue(Context) - 1) 
/
+Context.getCharWidth();
+
+AddCollectedField(Fields, Offset, EndOffset - Offset + 1, QTy, 
FieldMayAlias, true);
+  } else {
+if (!CollectFields(Offset, FieldQTy, Fields, FieldMayAlias))
+  return false;
+  }
 }
 return true;
   }
 
   /* Otherwise, treat whatever it is as a field. */
-  uint64_t Offset = BaseOffset;
   uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity();
-  llvm::MDNode *TBAAType = MayAlias ? getChar() : getTypeInfo(QTy);
-  llvm::MDNode *TBAATag = getAccessTagInfo(TBAAAccessInfo(TBAAType, Size));
-  Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size, TBAATag));
+  AddCollectedField(Fields, BaseOffset, Size, QTy, MayAlias, false);
   return true;
 }
 


Index: clang/lib/CodeGen/CodeGenTBAA.h
===
--- clang/lib/CodeGen/CodeGenTBAA.h
+++ clang/lib/CodeGen/CodeGenTBAA.h
@@ -146,6 +146,12 @@
   /// considered to be equivalent to it

[PATCH] D136078: Use-after-return sanitizer binary metadata

2022-12-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

` SanitizerBinaryMetadata::createZeroSizedObjectInSection` creates `__dummy_*`, 
but why is it needed? (There is no comment.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136078

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


[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

2022-12-03 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 479898.
lime added a comment.

Rebase.


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

https://reviews.llvm.org/D137531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2692,20 +2692,34 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -319,6 +319,9 @@
   `Issue 58302 `_
   `Issue 58753 `_
   `Issue 59100 `_
+- Fix an issue about ``decltype`` in the members of class templates derived from
+  templates with related parameters.
+  `Issue 58674 `_
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits