[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-05-29 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added inline comments.
Herald added subscribers: Michael137, JDevlieghere.



Comment at: clang/test/ParserHLSL/group_shared.hlsl:14
-// expected-error@+1 {{expected expression}}
 float groupshared [[]] i = 12;
 

Should this also get an extension warning/should attributes be disabled for 
HLSL?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line

2023-05-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:119
 if (CollectInactiveRegions) {
-  ServerCallbacks->onInactiveRegionsReady(
-  Path, std::move(AST.getMacros().SkippedRanges));
+  std::vector SkippedRanges(
+  std::move(AST.getMacros().SkippedRanges));

this part of code becomes non-trivial now, I suggest pulling out a function and 
moving it to `SemanticHighlighting.cpp`. The old inactive-as-comment 
implementation can share it as well.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:153
+  }
+  ServerCallbacks->onInactiveRegionsReady(Path, InactiveRegions);
 }

nit: std::move(InactiveRegions).



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:478
   for (int Line = R.start.line; Line <= R.end.line; ++Line) {
 // If the end of the inactive range is at the beginning
 // of a line, that line is not inactive.

I think we should do the same thing for the old implementation as well (or just 
delete it at all), otherwise, we will have inconsistent behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151190

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


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-05-29 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik created this revision.
philnik added reviewers: aaron.ballman, erichkeane.
Herald added subscribers: wlei, wenlei, jdoerfert, dmgreen.
Herald added a project: All.
philnik requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits, jplehr, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLDB.

This also removes the `-fdouble-square-bracket-attributes` command line flag, 
which seems to not be used anywhere. At least a code search exclusively found 
mentions of it in documentation: 
https://sourcegraph.com/search?q=context:global+-fdouble-square-bracket-attributes+-file:clang/*+-file:test/Sema/*+-file:test/Parser/*+-file:test/AST/*+-file:test/Preprocessor/*+-file:test/Misc/*+archived:yes=standard=0=repo


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151683

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/ast-dump-attr.m
  clang/test/AST/ast-dump-c-attr.c
  clang/test/AST/attr-annotate-type.c
  clang/test/CodeGen/attr-btf_type_tag-func.c
  clang/test/CodeGen/attr-btf_type_tag-var.c
  clang/test/Frontend/noderef.c
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/openmp_attribute_compat.cpp
  clang/test/Parser/asm.c
  clang/test/Parser/c2x-attributes.c
  clang/test/Parser/c2x-attributes.m
  clang/test/Parser/cxx-decl.cpp
  clang/test/Parser/objc-attr.m
  clang/test/ParserHLSL/group_shared.hlsl
  clang/test/Preprocessor/has_c_attribute.c
  clang/test/Sema/annotate-type.c
  clang/test/Sema/annotate.c
  clang/test/Sema/attr-availability-square-brackets.c
  clang/test/Sema/attr-external-source-symbol-cxx.cpp
  clang/test/Sema/attr-external-source-symbol.c
  clang/test/Sema/attr-likelihood.c
  clang/test/Sema/attr-objc-bridge-related.m
  clang/test/Sema/attr-regparm.c
  clang/test/Sema/attr-type-safety.c
  clang/test/Sema/c2x-noreturn.c
  clang/test/Sema/internal_linkage.c
  clang/test/Sema/matrix-type-builtins.c
  clang/test/Sema/neon-vector-types.c
  clang/test/Sema/overload-arm-mve.c
  clang/test/Sema/overloadable.c
  clang/test/Sema/vector-gcc-compat.c
  clang/test/SemaCXX/attr-cxx-disabled.cpp
  clang/test/SemaObjC/attr-objc-gc.m
  clang/unittests/AST/AttrTest.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -575,7 +575,6 @@
 // FIXME: We should ask the driver for the appropriate default flags.
 lang_opts.GNUMode = true;
 lang_opts.GNUKeywords = true;
-lang_opts.DoubleSquareBracketAttributes = true;
 lang_opts.CPlusPlus11 = true;
 
 // The Darwin libc expects this macro to be set.
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3387,14 +3387,10 @@
   // If this is the C++11 variety, also add in the LangOpts test.
   if (Variety == "CXX11")
 Test += " && LangOpts.CPlusPlus11";
-  else if (Variety == "C2x")
-Test += " && LangOpts.DoubleSquareBracketAttributes";
 } else if (Variety == "CXX11")
   // C++11 mode should be checked against LangOpts, which is presumed to be
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
-else if (Variety == "C2x")
-  Test = "LangOpts.DoubleSquareBracketAttributes";
 
 std::string TestStr = !Test.empty()
   ? Test + " ? " + llvm::itostr(Version) + " : 0"
Index: clang/unittests/AST/AttrTest.cpp
===
--- clang/unittests/AST/AttrTest.cpp
+++ clang/unittests/AST/AttrTest.cpp
@@ -157,7 +157,7 @@
   AST = buildASTFromCodeWithArgs(R"c(
 __auto_type [[clang::annotate_type("auto")]] auto_var = 1;
   )c",
- {"-fdouble-square-bracket-attributes"},
+ {},
  "input.c");
 
   {
Index: clang/test/SemaObjC/attr-objc-gc.m
===
--- clang/test/SemaObjC/attr-objc-gc.m
+++ clang/test/SemaObjC/attr-objc-gc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only 

[PATCH] D148827: -fsanitize=function: support C

2023-05-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D148827#4379560 , @glandium wrote:

> This breaks sqlite:
>
>   /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:137791:5: 
> runtime error: call to function sqlite3DeleteTable through pointer to 
> incorrect function type 'void (*)(struct sqlite3 *, void *)'
>   /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:118360: 
> note: sqlite3DeleteTable defined here
>
> The function is declared as `void sqlite3DeleteTable(sqlite3 *db, Table 
> *pTable)` so technically, it's not wrong, but is it really a problem that 
> needs to be caught? (when the difference is between `type*` and `void*`)
>
> This also breaks NSS:
>
>   /builds/worker/checkouts/gecko/security/nss/lib/freebl/loader.c:95:12: 
> runtime error: call to function BL_Init through pointer to incorrect function 
> type 'enum _SECStatus (*)(void)'
>   /builds/worker/checkouts/gecko/security/nss/lib/freebl/blinit.c:557: note: 
> BL_Init defined here
>
> Pointer type is:
>
>   SECStatus (*p_BL_Init)(void);
>
> and BL_Init is declared as:
>
>   SECStatus BL_Init()
>
> I guess it's tripping on the missing `void`... should that be an error?

These cases are UB and should be caught. It's not an excuse that they use C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D150645: [Driver] Support multi /guard: options

2023-05-29 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D150645#4379536 , @glandium wrote:

> In D150645#4351266 , @aeubanks 
> wrote:
>
>> this causes `./build/rel/bin/clang-cl /c /tmp/a.cc /Fo/tmp/a 
>> /guard:cf,nochecks` to go from no warnings to
>>
>>   clang-cl: warning: argument unused during compilation: 
>> '/guard:cf,nochecks' [-Wunused-command-line-argument]
>
> This affects 16.0.4

Sorry for making the trouble. I have made a backport request targeting 16.0.5: 
https://github.com/llvm/llvm-project/issues/62921


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150645

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


[PATCH] D148827: -fsanitize=function: support C

2023-05-29 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

This breaks sqlite:

  /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:137791:5: 
runtime error: call to function sqlite3DeleteTable through pointer to incorrect 
function type 'void (*)(struct sqlite3 *, void *)'
  /builds/worker/checkouts/gecko/third_party/sqlite3/src/sqlite3.c:118360: 
note: sqlite3DeleteTable defined here

The function is declared as `void sqlite3DeleteTable(sqlite3 *db, Table 
*pTable)` so technically, it's not wrong, but is it really a problem that needs 
to be caught? (when the difference is between `type*` and `void*`)

This also breaks NSS:

  /builds/worker/checkouts/gecko/security/nss/lib/freebl/loader.c:95:12: 
runtime error: call to function BL_Init through pointer to incorrect function 
type 'enum _SECStatus (*)(void)'
  /builds/worker/checkouts/gecko/security/nss/lib/freebl/blinit.c:557: note: 
BL_Init defined here

Pointer type is:

  SECStatus (*p_BL_Init)(void);

and BL_Init is declared as:

  SECStatus BL_Init()

I guess it's tripping on the missing `void`... should that be an error?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-29 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

There seem to still be two problems with this change, with mingw:

- with `-fms-extensions`:

  echo '#include "cpuid.h"' | ./clang/bin/clang++ 
--target=x86_64-w64-windows-gnu -xc++ - -fms-extensions
  In file included from :1:
  /tmp/clang/lib/clang/17/include/cpuid.h:334:22: error: definition of builtin 
function '__cpuidex'
  static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
   ^
  1 error generated.

- conflict with mingw headers without the extensions:

  $ echo '#include "intrin.h"' | ./clang/bin/x86_64-w64-mingw32-clang++ -xc++ -
  In file included from :1:
  In file included from /tmp/clang/lib/clang/17/include/intrin.h:12:
  In file included from 
/tmp/clang/bin/../x86_64-w64-mingw32/include/intrin.h:70:
  /tmp/clang/lib/clang/17/include/cpuid.h:334:22: error: static declaration of 
'__cpuidex' follows non-static declaration
  static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
   ^
  /tmp/clang/bin/../x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h:2031:6: 
note: previous definition is here
  void __cpuidex(int CPUInfo[4], int function_id, int subfunction_id) {
   ^
  1 error generated.

Although, for the latter, this was "fixed" in 
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/2b6c9247613aa830374e3686e09d3b8d582a92a6/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150645: [Driver] Support multi /guard: options

2023-05-29 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D150645#4351266 , @aeubanks wrote:

> this causes `./build/rel/bin/clang-cl /c /tmp/a.cc /Fo/tmp/a 
> /guard:cf,nochecks` to go from no warnings to
>
>   clang-cl: warning: argument unused during compilation: '/guard:cf,nochecks' 
> [-Wunused-command-line-argument]

This affects 16.0.4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150645

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci added a comment.

Hi @PiotrZSL if you are happy with the changes, could you commit the diff for 
me as I don't have commit access to LLVM repo?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[clang-tools-extra] 32fc78c - [cland] Remove unused declaration getCurrentPreamble

2023-05-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-29T14:17:01-07:00
New Revision: 32fc78c26ff591f627d3a6d4f8e0ab7c2092f1e5

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

LOG: [cland] Remove unused declaration getCurrentPreamble

The corresponding function definition was removed by:

  commit 2214b9076f1d3a4784820c4479e2417685e5c980
  Author: Kadir Cetinkaya 
  Date:   Thu Apr 2 10:53:23 2020 +0200

Added: 


Modified: 
clang-tools-extra/clangd/TUScheduler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index 126937ff49e90..5fc98eec3a2fd 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -635,10 +635,6 @@ class ASTWorker {
   std::shared_ptr Preamble,
   std::vector CIDiags, WantDiagnostics WantDiags);
 
-  /// Obtain a preamble reflecting all updates so far. Threadsafe.
-  /// It may be delivered immediately, or later on the worker thread.
-  void getCurrentPreamble(
-  llvm::unique_function)>);
   /// Returns compile command from the current file inputs.
   tooling::CompileCommand getCurrentCompileCommand() const;
 



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


[clang-tools-extra] 5bbb66c - [clangd] Remove unused variable IsBroadcasting

2023-05-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-29T14:17:03-07:00
New Revision: 5bbb66cae7d19836b0177f453fe6633a491f9590

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

LOG: [clangd] Remove unused variable IsBroadcasting

The variable was introduced without a use by:

  commit 2bebc3d0602b407b3f351e782940959da5808f97
  Author: Sam McCall 
  Date:   Tue Nov 20 10:56:03 2018 +

Added: 


Modified: 
clang-tools-extra/clangd/support/Function.h

Removed: 




diff  --git a/clang-tools-extra/clangd/support/Function.h 
b/clang-tools-extra/clangd/support/Function.h
index 5437729d91b62..a0bce839a77d8 100644
--- a/clang-tools-extra/clangd/support/Function.h
+++ b/clang-tools-extra/clangd/support/Function.h
@@ -97,7 +97,6 @@ template  class Event {
 "use a plain type: event values are always passed by const&");
 
   std::recursive_mutex ListenersMu;
-  bool IsBroadcasting = false;
   std::vector> Listeners;
   unsigned ListenerCount = 0;
 };



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


[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst:53
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, 
`::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, 
`::std::expected`, `::boost::system::error_code`
 

should be break into 2 lines, 80 characters limit per line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151650

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


[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-05-29 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin added inline comments.



Comment at: clang/test/Driver/aix-integrated-as.c:9
+// CHECK-IAS32: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0" "-emit-obj"
+// CHECK-IAS32: "aix-integrated-as.o"
+

both -fno-integrated-as and -fintegrated-as output the same file name 
"aix-integrated-as.o" , do you want to check "aix-integrated-as.o" here 



Comment at: clang/test/Driver/aix-integrated-as.c:17
+// CHECK-IAS64: "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0" "-emit-obj"
+// CHECK-IAS64: "aix-integrated-as.o"

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

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


[PATCH] D151662: [clang] [test] Fix test failures due to -Wbuiltin-macro-redefined in MinGW mode

2023-05-29 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: john.brawn, aaron.ballman.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

These tests undefine __declspec or __stdcall, both which are
builtin macros in MinGW mode. Therefore, build those cases with
-Wno-builtin-macro-redefined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151662

Files:
  clang/test/PCH/single-token-macro.c
  clang/test/Rewriter/objc-modern-boxing.mm
  clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm
  clang/test/Rewriter/rewrite-modern-block-consts.mm
  clang/test/Rewriter/rewrite-modern-block.mm
  clang/test/Rewriter/rewrite-modern-default-property-synthesis.mm
  clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
  clang/test/Rewriter/rewrite-modern-ivar-access.mm
  clang/test/Rewriter/rewrite-modern-ivars-1.mm
  clang/test/Rewriter/rewrite-modern-private-ivars.mm
  clang/test/Rewriter/rewrite-modern-struct-ivar-1.mm
  clang/test/Rewriter/rewrite-modern-struct-ivar.mm
  clang/test/Rewriter/rewrite-rewritten-initializer.mm

Index: clang/test/Rewriter/rewrite-rewritten-initializer.mm
===
--- clang/test/Rewriter/rewrite-rewritten-initializer.mm
+++ clang/test/Rewriter/rewrite-rewritten-initializer.mm
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-builtin-macro-redefined -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-builtin-macro-redefined -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw-modern.cpp
 // radar 7669784
 
 typedef unsigned long size_t;
Index: clang/test/Rewriter/rewrite-modern-struct-ivar.mm
===
--- clang/test/Rewriter/rewrite-modern-struct-ivar.mm
+++ clang/test/Rewriter/rewrite-modern-struct-ivar.mm
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -E %s -o %t.mm
 // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp 
 // RUN: FileCheck --input-file=%t-rw.cpp %s
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-c++11-narrowing -Wno-builtin-macro-redefined -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
 
 struct S {
 int i1;
Index: clang/test/Rewriter/rewrite-modern-struct-ivar-1.mm
===
--- clang/test/Rewriter/rewrite-modern-struct-ivar-1.mm
+++ clang/test/Rewriter/rewrite-modern-struct-ivar-1.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp
-// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -Wno-builtin-macro-redefined -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
 // rdar://11323187
 
 typedef unsigned long NSUInteger;
Index: clang/test/Rewriter/rewrite-modern-private-ivars.mm
===
--- clang/test/Rewriter/rewrite-modern-private-ivars.mm
+++ clang/test/Rewriter/rewrite-modern-private-ivars.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp
-// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -Wno-builtin-macro-redefined -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
 // rdar://11351299
 
 struct Q {
Index: clang/test/Rewriter/rewrite-modern-ivars-1.mm
===
--- clang/test/Rewriter/rewrite-modern-ivars-1.mm
+++ clang/test/Rewriter/rewrite-modern-ivars-1.mm
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror 

[PATCH] D151661: [clang] [test] Narrow down an MSVC specific behaviour to only not covever MinGW

2023-05-29 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: Endill, hans, aaron.ballman.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

This uses the same logic as in c2b256a990590dc8b69930259650cfeb085add03 
;
we can't check defined(_MSC_VER) invoked as %clang_cc1, therefore
check for !defined(__MINGW32__) instead.

This fixes the same issue in a new testcase that was added after this
issue was fixed last time in c2b256a990590dc8b69930259650cfeb085add03 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151661

Files:
  clang/test/CXX/drs/dr9xx.cpp


Index: clang/test/CXX/drs/dr9xx.cpp
===
--- clang/test/CXX/drs/dr9xx.cpp
+++ clang/test/CXX/drs/dr9xx.cpp
@@ -92,7 +92,7 @@
 
 namespace dr977 { // dr977: yes
 enum E { e = E() };
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__MINGW32__)
 // expected-error@-2 {{invalid use of incomplete type 'E'}}
 // expected-note@-3 {{definition of 'dr977::E' is not complete until the 
closing '}'}}
 #endif


Index: clang/test/CXX/drs/dr9xx.cpp
===
--- clang/test/CXX/drs/dr9xx.cpp
+++ clang/test/CXX/drs/dr9xx.cpp
@@ -92,7 +92,7 @@
 
 namespace dr977 { // dr977: yes
 enum E { e = E() };
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__MINGW32__)
 // expected-error@-2 {{invalid use of incomplete type 'E'}}
 // expected-note@-3 {{definition of 'dr977::E' is not complete until the closing '}'}}
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 40af06c - [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2023-05-29T23:02:32+03:00
New Revision: 40af06ccc7bf9989b8deb410ed78a4795c22aa73

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

LOG: [clang-tidy] Update UnusedReturnValueCheck types

Update the types for UnusedReturnValueCheck after D151383.

1. Add std::errc, std:error_condition
2. Remove `absl::Status` - it's marked as `[[nodiscard]]` anyway so it's 
redundant (and might create double warnings) to check it.

Reviewed By: PiotrZSL

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
index f8139381d7e01..bdc601c2445f5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@ 
UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
index 89c781b0fe714..c9b24dbcbb94f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -50,7 +50,7 @@ Options
 
Semicolon-separated list of function return types to check.
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, 
`::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, 
`::std::expected`, `::boost::system::error_code`
 
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.



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


[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Roy Jacobson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40af06ccc7bf: [clang-tidy] Update UnusedReturnValueCheck 
types (authored by royjacobson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151650

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst


Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -50,7 +50,7 @@
 
Semicolon-separated list of function return types to check.
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, 
`::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, 
`::std::expected`, `::boost::system::error_code`
 
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);


Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -50,7 +50,7 @@
 
Semicolon-separated list of function return types to check.
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, `::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, `::std::expected`, `::boost::system::error_code`
 
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 526468.
royjacobson added a comment.

Update docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151650

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst


Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -50,7 +50,7 @@
 
Semicolon-separated list of function return types to check.
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, 
`::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, 
`::std::expected`, `::boost::system::error_code`
 
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);


Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -50,7 +50,7 @@
 
Semicolon-separated list of function return types to check.
By default the following function return types are checked:
-   `::std::error_code`, `::std::expected`, `::boost::system::error_code`, `::abseil::Status`
+   `::std::error_code`, `::std::error_condition`, `::std::errc`, `::std::expected`, `::boost::system::error_code`
 
 `cert-err33-c <../cert/err33-c.html>`_ is an alias of this check that checks a
 fixed and large set of standard library functions.
Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-29 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: 
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:927-933
+if (I->getOperand(0) != I->getOperand(1)) {
+  APInt DemandedMaskLHS(DemandedMask.lshr(ShiftAmt));
+  APInt DemandedMaskRHS(DemandedMask.shl(BitWidth - ShiftAmt));
+  if (SimplifyDemandedBits(I, 0, DemandedMaskLHS, LHSKnown, Depth + 1) 
||
+  SimplifyDemandedBits(I, 1, DemandedMaskRHS, RHSKnown, Depth + 1))
+return I;
+}

You should be able to do something along these lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-29 Thread Arnaud Bienner via Phabricator via cfe-commits
ArnaudBienner updated this revision to Diff 526463.
ArnaudBienner added a comment.

- Code review comments: change back the string buffer check + run clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/buffer-overlap.c

Index: clang/test/Analysis/buffer-overlap.c
===
--- /dev/null
+++ clang/test/Analysis/buffer-overlap.c
@@ -0,0 +1,98 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+//
+// RUN: %clang_analyze_cc1 -verify %s -DVARIANT -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap
+
+// This provides us with four possible sprintf() definitions.
+
+#ifdef USE_BUILTINS
+#define BUILTIN(f) __builtin_##f
+#else /* USE_BUILTINS */
+#define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+typedef typeof(sizeof(int)) size_t;
+
+#ifdef VARIANT
+
+#define __sprintf_chk BUILTIN(__sprintf_chk)
+#define __snprintf_chk BUILTIN(__snprintf_chk)
+int __sprintf_chk (char * __restrict str, int flag, size_t os,
+const char * __restrict fmt, ...);
+int __snprintf_chk (char * __restrict str, size_t len, int flag, size_t os,
+const char * __restrict fmt, ...);
+
+#define sprintf(str, ...) __sprintf_chk(str, 0, __builtin_object_size(str, 0), __VA_ARGS__)
+#define snprintf(str, len, ...) __snprintf_chk(str, len, 0, __builtin_object_size(str, 0), __VA_ARGS__)
+
+#else /* VARIANT */
+
+#define sprintf BUILTIN(sprintf)
+int sprintf(char *restrict buffer, const char *restrict format, ... );
+int snprintf(char *restrict buffer, size_t bufsz,
+ const char *restrict format, ... );
+#endif /* VARIANT */
+
+void test_sprintf1() {
+  char a[4] = {0};
+  sprintf(a, "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf2() {
+  char a[4] = {0};
+  sprintf(a, "%s", a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf3() {
+  char a[4] = {0};
+  sprintf(a, "%s/%s", a, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_sprintf4() {
+  char a[4] = {0};
+  sprintf(a, "%d", 42); // no-warning
+}
+
+void test_sprintf5() {
+  char a[4] = {0};
+  char b[4] = {0};
+  sprintf(a, "%s", b); // no-warning
+}
+
+void test_snprintf1() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf2() {
+  char a[4] = {0};
+  snprintf(a+1, sizeof(a)-1, "%d/%s", 1, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf3() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%s", a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf4() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%s/%s", a, a); // expected-warning{{Arguments must not be overlapping buffers}}
+}
+
+void test_snprintf5() {
+  char a[4] = {0};
+  snprintf(a, sizeof(a), "%d", 42); // no-warning
+}
+
+void test_snprintf6() {
+  char a[4] = {0};
+  char b[4] = {0};
+  snprintf(a, sizeof(a), "%s", b); // no-warning
+}
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "InterCheckerAPI.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -175,6 +176,8 @@
std::bind(::evalMemcmp, _1, _2, _3, CK_Regular)},
   {{CDF_MaybeBuiltin, {"bzero"}, 2}, ::evalBzero},
   {{CDF_MaybeBuiltin, {"explicit_bzero"}, 2}, ::evalBzero},
+  {{CDF_MaybeBuiltin, {"sprintf"}, 2}, ::evalSprintf},
+  {{CDF_MaybeBuiltin, {"snprintf"}, 2}, ::evalSnprintf},
   };
 
   // These require a bit of special handling.
@@ -228,6 +231,11 @@
   void evalMemset(CheckerContext , const CallExpr *CE) const;
   void evalBzero(CheckerContext , const CallExpr *CE) const;
 
+  void evalSprintf(CheckerContext , const CallExpr *CE) const;
+  void evalSnprintf(CheckerContext , const CallExpr *CE) const;
+  void evalSprintfCommon(CheckerContext , const CallExpr *CE, bool IsBounded,
+ bool IsBuiltin) const;
+
   // Utility methods
   std::pair
   static assumeZero(CheckerContext ,

[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

LGTM but update documentation for this check abseil::Status is listed there.


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

https://reviews.llvm.org/D151650

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


[PATCH] D150212: [clang][Sema] Improve diagnostics for auto return type

2023-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/Sema/TemplateDeduction.h:338
 public:
-  TemplateSpecCandidateSet(SourceLocation Loc, bool ForTakingAddress = false)
   : Loc(Loc), ForTakingAddress(ForTakingAddress) {}

Do we need to allow the location to be set after the set is created? Giving 
this type an additional state where the location is absent seems error prone, 
and in the uses below it looks easy to set the location in the caller instead 
of the callee.


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

https://reviews.llvm.org/D150212

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


[PATCH] D151651: [StaticAnalyzer] Fix block pointer type nullability check

2023-05-29 Thread tripleCC via Phabricator via cfe-commits
tripleCC added a comment.

In D151651#4379144 , @steakhal wrote:

> Looks good.
> That pesky ObjC :D

I don't have commit access, could you help me to commit it? thanks
--author "tripleCC "


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151651

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


[PATCH] D151651: [StaticAnalyzer] Fix block pointer type nullability check

2023-05-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Looks good.
That pesky ObjC :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151651

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


[PATCH] D151651: [StaticAnalyzer] Fix block pointer type nullability check

2023-05-29 Thread tripleCC via Phabricator via cfe-commits
tripleCC created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, szepet, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
tripleCC requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151651

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  clang/test/Analysis/nullability.mm

Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -46,10 +46,13 @@
 - (int *_Nullable)returnsNullable;
 - (int *)returnsUnspecified;
 - (void)takesNonnull:(int *_Nonnull)p;
+- (void)takesNonnullBlock:(void (^ _Nonnull)(void))block;
 - (void)takesNullable:(int *_Nullable)p;
 - (void)takesUnspecified:(int *)p;
 @property(readonly, strong) NSString *stuff;
 @property(readonly, nonnull) int *propReturnsNonnull;
+@property(readonly, nonnull) void (^propReturnsNonnullBlock)(void);
+@property(readonly, nullable) void (^propReturnsNullableBlock)(void);
 @property(readonly, nullable) int *propReturnsNullable;
 @property(readonly) int *propReturnsUnspecified;
 @end
@@ -65,6 +68,7 @@
 void takesNullable(Dummy *_Nullable);
 void takesNonnull(Dummy *_Nonnull);
 void takesUnspecified(Dummy *);
+void takesNonnullBlock(void (^ _Nonnull)(void));
 
 Dummy *_Nullable returnsNullable();
 Dummy *_Nonnull returnsNonnull();
@@ -197,6 +201,7 @@
   switch (getRandom()) {
   case 0:
 [o takesNonnull:o.propReturnsNonnull]; // no-warning
+[o takesNonnullBlock:o.propReturnsNonnullBlock]; // no-warning
 break;
   case 1:
 [o takesNonnull:o.propReturnsUnspecified]; // no-warning
@@ -236,6 +241,9 @@
 assert(o.propReturnsNullable);
 [o takesNonnull:o.propReturnsNullable]; // no-warning
 break;
+  case 8:
+[o takesNonnullBlock:o.propReturnsNullableBlock]; // expected-warning {{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+break;
   }
 }
 
@@ -308,6 +316,11 @@
   takesNonnull(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
 }
 
+void testBlockIndirectNilPassToNonnull() {
+  void (^p)(void) = nil;
+  takesNonnullBlock(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
+}
+
 void testConditionalNilPassToNonnull(Dummy *p) {
   if (!p) {
 takesNonnull(p);  // expected-warning {{Null passed to a callee that requires a non-null 1st parameter}}
Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -306,6 +306,10 @@
   return NullConstraint::Unknown;
 }
 
+static bool isValidPointerType(QualType T) {
+  return T->isAnyPointerType() || T->isBlockPointerType();
+}
+
 const SymbolicRegion *
 NullabilityChecker::getTrackRegion(SVal Val, bool CheckSuperRegion) const {
   if (!NeedTracking)
@@ -621,7 +625,7 @@
   if (!RetExpr)
 return;
 
-  if (!RetExpr->getType()->isAnyPointerType())
+  if (!isValidPointerType(RetExpr->getType()))
 return;
 
   ProgramStateRef State = C.getState();
@@ -754,7 +758,7 @@
 if (!ArgSVal)
   continue;
 
-if (!Param->getType()->isAnyPointerType() &&
+if (!isValidPointerType(Param->getType()) &&
 !Param->getType()->isReferenceType())
   continue;
 
@@ -841,7 +845,7 @@
   if (!FuncType)
 return;
   QualType ReturnType = FuncType->getReturnType();
-  if (!ReturnType->isAnyPointerType())
+  if (!isValidPointerType(ReturnType))
 return;
   ProgramStateRef State = C.getState();
   if (State->get())
@@ -935,7 +939,7 @@
   if (!Decl)
 return;
   QualType RetType = Decl->getReturnType();
-  if (!RetType->isAnyPointerType())
+  if (!isValidPointerType(RetType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1089,9 +1093,9 @@
CheckerContext ) const {
   QualType OriginType = CE->getSubExpr()->getType();
   QualType DestType = CE->getType();
-  if (!OriginType->isAnyPointerType())
+  if (!isValidPointerType(OriginType))
 return;
-  if (!DestType->isAnyPointerType())
+  if (!isValidPointerType(DestType))
 return;
 
   ProgramStateRef State = C.getState();
@@ -1215,7 +1219,7 @@
 return;
 
   QualType LocType = TVR->getValueType();
-  if (!LocType->isAnyPointerType())
+  if (!isValidPointerType(LocType))
 return;
 
   ProgramStateRef State = C.getState();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 526440.

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

https://reviews.llvm.org/D151650

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -127,9 +127,10 @@
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
   Options.get("CheckedReturnTypes", "::std::error_code;"
+"::std::error_condition;"
+"::std::errc;"
 "::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+"::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151650: [clang-tidy] Update UnusedReturnValueCheck types

2023-05-29 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
royjacobson added reviewers: chaitanyav, PiotrZSL.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Update the types for UnusedReturnValueCheck after D151383 
.

1. Add std::errc, std:error_condition
2. Remove `absl::Status` - it's marked as `[[nodiscard]]` anyway so it's 
redundant (and might create double warnings) to check it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151650

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -126,10 +126,12 @@
"::strsignal;"
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
-  Options.get("CheckedReturnTypes", "::std::error_code;"
-"::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+  Options.get("CheckedReturnTypes",
+  "::std::error_code;",
+  "::std::error_condition;",
+  "::std::errc;",
+  "::std::expected;",
+  "::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);


Index: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -126,10 +126,12 @@
"::strsignal;"
"::ttyname")),
   CheckedReturnTypes(utils::options::parseStringList(
-  Options.get("CheckedReturnTypes", "::std::error_code;"
-"::std::expected;"
-"::boost::system::error_code;"
-"::abseil::Status"))) {}
+  Options.get("CheckedReturnTypes",
+  "::std::error_code;",
+  "::std::error_condition;",
+  "::std::errc;",
+  "::std::expected;",
+  "::boost::system::error_code"))) {}
 
 void UnusedReturnValueCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "CheckedFunctions", CheckedFunctions);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 526438.
denizevrenci added a comment.

- Rebase on trunk
- Remove unused helpers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang/include/clang/AST/StmtCXX.h

Index: clang/include/clang/AST/StmtCXX.h
===
--- clang/include/clang/AST/StmtCXX.h
+++ clang/include/clang/AST/StmtCXX.h
@@ -443,6 +443,17 @@
NumParams);
   }
 
+  child_range childrenExclBody() {
+return child_range(getStoredStmts() + SubStmt::Body + 1,
+   getStoredStmts() + SubStmt::FirstParamMove + NumParams);
+  }
+
+  const_child_range childrenExclBody() const {
+return const_child_range(getStoredStmts() + SubStmt::Body + 1,
+ getStoredStmts() + SubStmt::FirstParamMove +
+ NumParams);
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CoroutineBodyStmtClass;
   }
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -0,0 +1,711 @@
+// RUN: %check_clang_tidy -std=c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+namespace std {
+
+template  struct coroutine_traits {
+  using promise_type = typename Ret::promise_type;
+};
+
+template  struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise );
+  constexpr void *address() const noexcept;
+};
+
+template <> struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+} // namespace std
+
+template 
+struct Promise;
+
+template <
+typename T, bool ThrowInTaskConstructor = false,
+bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  bool await_ready() { return true; }
+
+  void await_suspend(std::coroutine_handle<> h) {}
+
+  void await_resume() {}
+
+  T value;
+};
+
+template 
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  bool await_ready() { return true; }
+
+  void await_suspend(std::coroutine_handle<> h) {}
+
+  void await_resume() {}
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  template  void return_value(U &) {
+return_val->value = static_cast(val);
+  }
+
+  template  std::suspend_never yield_value(U &) {
+return_val->value = static_cast(val);
+return {};
+  }
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  void return_void() {}
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+struct Evil {
+  ~Evil() noexcept(false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an 

[PATCH] D151590: [Driver] Add ClangFlags::TargetSpecific to simplify err_drv_unsupported_opt_for_target processing

2023-05-29 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

Thanks for the patch!

Recently we added the options `mxcoff-roptr` and `mno-xcoff-roptr` 
https://reviews.llvm.org/D144190 that fall into this the scope of this patch 
(e.g. 
https://github.com/llvm/llvm-project/blob/0508ac32cfcc1a9fc5a81d16de8d418dc5a0666b/clang/lib/Driver/ToolChains/Clang.cpp#LL5278C19-L5278C19),
 since they are only supported on AIX. Could you add the handling of options 
`mxcoff-roptr` and `mno-xcoff-roptr`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151590

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


[PATCH] D151503: [CUDA] correctly install cuda_wrappers/bits/shared_ptr_base.h

2023-05-29 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:516
   COMPONENT cuda-resource-headers)
 
 install(

tra wrote:
> qiongsiwu1 wrote:
> > qiongsiwu1 wrote:
> > > tra wrote:
> > > > qiongsiwu1 wrote:
> > > > > Do we need an install target for `${cuda_wrapper_bits_files}` for the 
> > > > > `cuda-resource-headers` component as well? It seems to be the case 
> > > > > because this patch is treating `${cuda_wrapper_bits_files}` as part 
> > > > > of `cuda-resource-headers`.
> > > > > 
> > > > > ```
> > > > > add_header_target("cuda-resource-headers" 
> > > > > "${cuda_files};${cuda_wrapper_files};${cuda_wrapper_bits_files}")
> > > > > ```
> > > > > 
> > > > > 
> > > > I'm not sure I understand the question. Are you saying that a separate 
> > > > `install()` for the 'bits' is not necessary and we could just install 
> > > > all headers with a single `install` above?
> > > > 
> > > > If that's the case, then, AFAICT, the answer is that we do need a 
> > > > separate `install`. 
> > > > `install(FILES)` does not preserve the directory structure and dumps 
> > > > all files listed in `FILES`, regardless if they are in different 
> > > > directories into the same DESTINATION directory.
> > > > That is exactly the problem this patch is intended to fix. We do need 
> > > > to place the file under `cuda_wrappers/bits/` directory and that's why 
> > > > we have separate `install(DESTINATION 
> > > > ${header_install_dir}/cuda_wrappers/bits)` here.
> > > > 
> > > > `install(DIRECTORY)` would presumably preserve the source directory 
> > > > structure, but we lose per-file granularity. It may work for the files 
> > > > under cuda_wrappers for now, but I think there's some merit in 
> > > > explicitly controlling which headers we ship and where we put them. 
> > > > While we do have 1:1 mapping between the source tree and install tree, 
> > > > it may not always be the case.
> > > > 
> > > > 
> > > > 
> > > Ah sorry for the confusion. 
> > > 
> > > > Are you saying that a separate install() for the 'bits' is not 
> > > > necessary and we could just install all headers with a single install 
> > > > above?
> > > 
> > > No I am trying to say the opposite. I am suggesting we //add// the 
> > > separate install target as a component of `clang-resource-headers` 
> > > //and// as a component of `cuda-resource-headers`, as shown in the code 
> > > change suggested in the comment above. I am not suggesting any code form 
> > > this patch to be removed. The `cuda-resource-headers` can be used to 
> > > install the cuda related headers only, in the case when a user do not 
> > > want to install all the headers (e.g. if a user only want to install 
> > > support for Intel and Nvidia headers, but not the PowerPC headers, the 
> > > user can select `core-resource-headers`, `x86_files` and 
> > > `cuda-resource-headers` during a distribution build/install). I think 
> > > without the code change suggested above, if a user select to install 
> > > `cuda-resource-headers` only without specifying `clang-resource-headers`, 
> > > we will miss the file `cuda_wrappers/bits/shared_ptr_base.h`. 
> > Sorry I made a typo in the previous comment. I meant `x86-resource-headers` 
> > when I said `x86_files`. 
> I think understand now.
> `cmake -DCOMPONENT=cuda-resource-headers -P ./cmake_install.cmake` indeed 
> does not install the bits component.
> 
> I've added the install with `COMPONENT clang-resource-headers` and verified 
> that the bits header is installed during individual component installation.
Thanks for the changes! One thing I realized after seeing the most recent 
update is that I mixed up the term "install target" with "install rules" in my 
previous comments. Apologies for the confusion. 

I think we will need the following new target code only if we intend to specify 
`cuda-resource-bits-headers` as a separate installation target (e.g. if we do 
`cmake -DCOMPONENT=cuda-resource-bits-headers -P ./cmake_install.cmake`). 

```
add_header_target("cuda-resource-bits-headers" "${cuda_wrapper_bits_files}")
add_dependencies("clang-resource-headers"
  ... 
  "cuda-resource-bits-headers"
 ...
add_llvm_install_targets(install-cuda-resource-bits-headers
 DEPENDS cuda-resource-bits-headers
COMPONENT cuda-resource-headers)
```
In other words, we do not need these three code changes above if we do not 
intend to install `cuda-resource-bits-headers` as a standalone target. If our 
intention is to always use it as a component of `cuda-resource-headers`, adding 
install rule
```
install(
   FILES ${cuda_wrapper_bits_files}
   DESTINATION ${header_install_dir}/cuda_wrappers/bits
   EXCLUDE_FROM_ALL
   COMPONENT cuda-resource-headers)
```
should be sufficient when installing `cuda-resource-headers` by itself. We 
still need the install rule for `clang-resource-headers` which was initially 

[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-29 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 526436.
pmatos marked an inline comment as done.
pmatos added a comment.

Address the comments wrt the documentation. Added link to Wasm spec.

@aaron.ballman What do you think? I added the reference to the top level of the 
WebAssembly section, rather than to the documentation in each builtin since it 
makes more sense imo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/builtins-table.c
  clang/test/Sema/builtins-wasm.c
  clang/test/Sema/wasm-refs-and-table-ped.c
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/test/SemaCXX/wasm-refs.cpp
  llvm/include/llvm/CodeGen/WasmAddressSpaces.h
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.cpp
  llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerRefTypesIntPtrConv.cpp
@@ -62,8 +62,9 @@
   for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
 PtrToIntInst *PTI = dyn_cast(&*I);
 IntToPtrInst *ITP = dyn_cast(&*I);
-if (!(PTI && WebAssembly::isRefType(PTI->getPointerOperand()->getType())) &&
-!(ITP && WebAssembly::isRefType(ITP->getDestTy(
+if (!(PTI && WebAssembly::isWebAssemblyReferenceType(
+ PTI->getPointerOperand()->getType())) &&
+!(ITP && WebAssembly::isWebAssemblyReferenceType(ITP->getDestTy(
   continue;
 
 UndefValue *U = UndefValue::get(I->getType());
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1203,7 +1203,7 @@
   // Lastly, if this is a call to a funcref we need to add an instruction
   // table.set to the chain and transform the call.
   if (CLI.CB &&
-  WebAssembly::isFuncrefType(CLI.CB->getCalledOperand()->getType())) {
+  WebAssembly::isWebAssemblyFuncrefType(CLI.CB->getCalledOperand()->getType())) {
 // In the absence of function references proposal where a funcref call is
 // lowered to call_ref, using reference types we generate a table.set to set
 // the funcref to a special table used solely for this purpose, followed by
Index: llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
===
--- llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
+++ llvm/lib/Target/WebAssembly/Utils/WebAssemblyTypeUtilities.h
@@ -18,6 +18,7 @@
 #include "MCTargetDesc/WebAssemblyMCTypeUtilities.h"
 #include "llvm/BinaryFormat/Wasm.h"
 #include "llvm/CodeGen/MachineValueType.h"
+#include "llvm/CodeGen/WasmAddressSpaces.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/MC/MCSymbolWasm.h"
 
@@ -27,41 +28,21 @@
 
 namespace WebAssembly {
 
-enum WasmAddressSpace : unsigned {
-  // Default address space, for pointers to linear memory (stack, heap, data).
-  WASM_ADDRESS_SPACE_DEFAULT = 0,
-  // A non-integral address space for pointers to named objects outside of
-  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores
-  // to these pointers are lowered to global.get / global.set or local.get /
-  // local.set, as appropriate.
-  WASM_ADDRESS_SPACE_VAR = 1,
-  // A non-integral address space for externref values
-  WASM_ADDRESS_SPACE_EXTERNREF = 10,
-  // A non-integral address space for funcref values
-  WASM_ADDRESS_SPACE_FUNCREF = 20,
-};
-
-inline bool isDefaultAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_DEFAULT;
-}
-inline bool isWasmVarAddressSpace(unsigned AS) {
-  return AS == WASM_ADDRESS_SPACE_VAR;
-}
-inline bool isValidAddressSpace(unsigned AS) {
-  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);
+/// Return true 

[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci added a comment.

Addressed 1 and 3. As for the new methods in StmtCXX.h, I think they may be 
used elsewhere too where we need to make a distinction between the visible body 
of the coroutine and the desugared version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 526430.
denizevrenci added a comment.

- Update release notes
- Remove checks for no messages


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang/include/clang/AST/StmtCXX.h

Index: clang/include/clang/AST/StmtCXX.h
===
--- clang/include/clang/AST/StmtCXX.h
+++ clang/include/clang/AST/StmtCXX.h
@@ -443,6 +443,17 @@
NumParams);
   }
 
+  child_range childrenExclBody() {
+return child_range(getStoredStmts() + SubStmt::Body + 1,
+   getStoredStmts() + SubStmt::FirstParamMove + NumParams);
+  }
+
+  const_child_range childrenExclBody() const {
+return const_child_range(getStoredStmts() + SubStmt::Body + 1,
+ getStoredStmts() + SubStmt::FirstParamMove +
+ NumParams);
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CoroutineBodyStmtClass;
   }
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -0,0 +1,731 @@
+// RUN: %check_clang_tidy -std=c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+namespace std {
+
+template  struct enable_if {};
+
+template  struct enable_if {
+  typedef T type;
+};
+
+template 
+using enable_if_t = typename enable_if::type;
+
+template  struct is_same {
+  static constexpr bool value = false;
+};
+
+template  struct is_same {
+  static constexpr bool value = false;
+};
+
+template 
+inline constexpr bool is_same_v = is_same::value;
+
+template  struct coroutine_traits {
+  using promise_type = typename Ret::promise_type;
+};
+
+template  struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise );
+  constexpr void *address() const noexcept;
+};
+
+template <> struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+} // namespace std
+
+template 
+struct Promise;
+
+template <
+typename T, bool ThrowInTaskConstructor = false,
+bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  bool await_ready() { return true; }
+
+  void await_suspend(std::coroutine_handle<> h) {}
+
+  void await_resume() {}
+
+  T value;
+};
+
+template 
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  bool await_ready() { return true; }
+
+  void await_suspend(std::coroutine_handle<> h) {}
+
+  void await_resume() {}
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  template  void return_value(U &) {
+return_val->value = static_cast(val);
+  }
+
+  template  std::suspend_never yield_value(U &) {
+return_val->value = static_cast(val);
+return {};
+  }
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+

[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-29 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 3 inline comments as done.
pmatos added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2288
+argument is the index to which to store the value into, and the
+third argument is a value of reference type to store in the table.
+It returns nothing.

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > This sounds like any reference type will work, e.g.,
> > > ```
> > > static __externref_t table[0];
> > > void func(int i) {
> > >   int  = i;
> > >   __builtin_wasm_table_set(table, i, ref);
> > > }
> > > ```
> > > so might want to say "value of ``_externref_t`` type" instead?
> > Any reference type will work, i.e. externref or funcref. You can also store 
> > funcrefs in a wasm table. But of course, it needs to be well-typed. You 
> > cannot store a funcref value in an externref table and vice-versa.
> My point is more that "any reference type" suggests you can use an arbitrary 
> C++ reference type like `int &` and I think we mean something more specific 
> than that, right?
Yes, of course, I always mean a WebAssembly reference type in this context.



Comment at: clang/docs/LanguageExtensions.rst:2364-2365
+range, the third argument is the value to set in the new entries, and 
+the fourth and the last argument is the size of the range. It returns 
+nothing.
+

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > What happens if the range is invalid for the table size? e.g., the user 
> > > never called `__builtin_wasm_table_grow` before calling 
> > > `__builtin_wasm_table_fill`?
> > The host executing the WebAssembly instance will trap. This is part of the 
> > WebAssembly spec.
> Hmmm, do you think we should mention that here? Alternatively, should we have 
> a link to other WebAssembly documentation so we can say "see  for more 
> details?" to avoid replicating docs too much?
Good idea. I will handle that.



Comment at: clang/test/SemaCXX/wasm-refs-and-tables.cpp:35
+task<__externref_t[]> g() {
+  co_return table;
+}

aaron.ballman wrote:
> pmatos wrote:
> > aaron.ballman wrote:
> > > pmatos wrote:
> > > > @aaron.ballman I tried and failed to create a good testcase for 
> > > > co_return. However creating coroutines seems to be an stdlib thing 
> > > > which I am not sure how to test here. Do you have any suggestions here?
> > > ```
> > > #include "Inputs/std-coroutine.h"
> > > 
> > > using std::suspend_always;
> > > 
> > > struct promise_table {
> > >   __externref_t[] get_return_object();
> > >   suspend_always initial_suspend();
> > >   suspend_always final_suspend() noexcept;
> > >   void return_value(__externref_t[]);
> > >   void unhandled_exception();
> > > };
> > > 
> > > template 
> > > struct std::coroutine_traits<__externref_t[], T...> { using promise_type 
> > > = promise_table; };
> > > 
> > > static __externref_t table[0];
> > > __externref_t[] func() {
> > >   co_return table; // Cannot return a WebAssembly table?
> > > }
> > > ```
> > > Perhaps something along these lines?
> > But you cannot write promise_table because a table cannot be an argument in 
> > return_value. Also, you cannot return a table in get_return_object. Doesn't 
> > this invalidate straight away the use of a table with co-routines?
> Ah! Yeah, I think that does. Okay, let's punt on coroutines, that's turning 
> out to be a slog.
OK - thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Ah, I can see that pre-merge bots failed due to clang-format violations.
Please make all the touched lines as clang-formatted prior to committing 
anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

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


[PATCH] D150430: Implement BufferOverlap check for sprint/snprintf

2023-05-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Yea, it still looks okay. Let me know if you don't have commit access. In that 
case, also let me know what should be used for the commit author.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150430

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-29 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added inline comments.



Comment at: llvm/test/Transforms/InstCombine/fsh.ll:664
+; CHECK-NEXT:[[T1:%.*]] = and i32 [[A:%.*]], -65536
+; CHECK-NEXT:[[T2:%.*]] = call i32 @llvm.fshl.i32(i32 [[T1]], i32 [[T1]], 
i32 16)
 ; CHECK-NEXT:ret i32 [[T2]]

pmatos wrote:
> nikic wrote:
> > We still want to simplify this case. Could possibly be done by checking 
> > whether all demanded bits are zero for one of the operands in the rotate 
> > case.
> Ah, yes,  right. That should be just a simple shift right. Will see how to 
> still allow that change. Thanks.
I am still looking into the best way to handle this case. The issue is that we 
only know if the demanded bits are zero when analyzing the uses of the value. 
This is done in SimplifyDemandedBits which in turn calls 
SimplifyDemandedUseBits, but we cannot call these functions to obtain demanded 
bits because they'll change the instruction straightaway.  I was seeing if 
there was a way to do the checks inside the block of code already changed, but 
I don't think that'll be possible. I might have to add a check to 
SimplifyDemandedUseBits to only simplify in this specific case we want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line

2023-05-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 526409.
nridge added a comment.

slight simplification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151190

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1332,26 +1332,31 @@
 #define PREAMBLEMACRO 42
 #if PREAMBLEMACRO > 40
   #define ACTIVE
-$inactive1[[#else
-  #define INACTIVE
-#endif]]
+#else
+$inactive1[[  #define INACTIVE]]
+#endif
 int endPreamble;
-$inactive2[[#ifndef CMDMACRO
-int inactiveInt;
-#endif]]
+#ifndef CMDMACRO
+$inactive2[[int inactiveInt;]]
+#endif
 #undef CMDMACRO
-$inactive3[[#ifdef CMDMACRO
-  int inactiveInt2;
-#else]]
-  int activeInt;
+#ifdef CMDMACRO
+$inactive3[[  int inactiveInt2;]]
+#elif PREAMBLEMACRO > 0
+  int activeInt1;
+  int activeInt2;
+#else
+$inactive4[[  int inactiveInt3;]]
 #endif
+#ifdef CMDMACRO
+#endif  // empty inactive range, gets dropped
   )cpp");
   Server.addDocument(testPath("foo.cpp"), Source.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   EXPECT_THAT(Callback.FoundInactiveRegions,
-  ElementsAre(ElementsAre(Source.range("inactive1"),
-  Source.range("inactive2"),
-  Source.range("inactive3";
+  ElementsAre(ElementsAre(
+  Source.range("inactive1"), Source.range("inactive2"),
+  Source.range("inactive3"), Source.range("inactive4";
 }
 
 } // namespace
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -72,6 +72,9 @@
 /// FIXME: This should return an error if the location is invalid.
 Position sourceLocToPosition(const SourceManager , SourceLocation Loc);
 
+/// Get the last Position on a given line.
+llvm::Expected endOfLine(llvm::StringRef Code, int Line);
+
 /// Return the file location, corresponding to \p P. Note that one should take
 /// care to avoid comparing the result with expansion locations.
 llvm::Expected sourceLocationInMainFile(const SourceManager ,
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -228,6 +228,16 @@
   return P;
 }
 
+llvm::Expected endOfLine(llvm::StringRef Code, int Line) {
+  auto StartOfLine = positionToOffset(Code, Position{Line, 0});
+  if (!StartOfLine)
+return StartOfLine.takeError();
+  StringRef LineText = Code.drop_front(*StartOfLine).take_until([](char C) {
+return C == '\n';
+  });
+  return Position{Line, static_cast(lspLength(LineText))};
+}
+
 bool isSpelledInSource(SourceLocation Loc, const SourceManager ) {
   if (Loc.isFileID())
 return true;
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -483,22 +483,15 @@
 for (; It != NonConflicting.end() && It->R.start.line < Line; ++It)
   WithInactiveLines.push_back(std::move(*It));
 // Add a token for the inactive line itself.
-auto StartOfLine = positionToOffset(MainCode, Position{Line, 0});
-if (StartOfLine) {
-  StringRef LineText =
-  MainCode.drop_front(*StartOfLine).take_until([](char C) {
-return C == '\n';
-  });
+auto EndOfLine = endOfLine(MainCode, Line);
+if (EndOfLine) {
   HighlightingToken HT;
   WithInactiveLines.emplace_back();
   WithInactiveLines.back().Kind = HighlightingKind::InactiveCode;
   WithInactiveLines.back().R.start.line = Line;
-  WithInactiveLines.back().R.end.line = Line;
-  WithInactiveLines.back().R.end.character =
-  static_cast(lspLength(LineText));
+  WithInactiveLines.back().R.end = *EndOfLine;
 } else {
-  elog("Failed to convert position to offset: {0}",
-   StartOfLine.takeError());
+  elog("Failed to determine end of line: {0}", EndOfLine.takeError());
 }
 
 // Skip any other tokens on the inactive line. e.g.
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ 

[PATCH] D151190: [clangd] Do not end inactiveRegions range at position 0 of line

2023-05-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 526408.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151190

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1332,26 +1332,31 @@
 #define PREAMBLEMACRO 42
 #if PREAMBLEMACRO > 40
   #define ACTIVE
-$inactive1[[#else
-  #define INACTIVE
-#endif]]
+#else
+$inactive1[[  #define INACTIVE]]
+#endif
 int endPreamble;
-$inactive2[[#ifndef CMDMACRO
-int inactiveInt;
-#endif]]
+#ifndef CMDMACRO
+$inactive2[[int inactiveInt;]]
+#endif
 #undef CMDMACRO
-$inactive3[[#ifdef CMDMACRO
-  int inactiveInt2;
-#else]]
-  int activeInt;
+#ifdef CMDMACRO
+$inactive3[[  int inactiveInt2;]]
+#elif PREAMBLEMACRO > 0
+  int activeInt1;
+  int activeInt2;
+#else
+$inactive4[[  int inactiveInt3;]]
 #endif
+#ifdef CMDMACRO
+#endif  // empty inactive range, gets dropped
   )cpp");
   Server.addDocument(testPath("foo.cpp"), Source.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
   EXPECT_THAT(Callback.FoundInactiveRegions,
-  ElementsAre(ElementsAre(Source.range("inactive1"),
-  Source.range("inactive2"),
-  Source.range("inactive3";
+  ElementsAre(ElementsAre(
+  Source.range("inactive1"), Source.range("inactive2"),
+  Source.range("inactive3"), Source.range("inactive4";
 }
 
 } // namespace
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -72,6 +72,9 @@
 /// FIXME: This should return an error if the location is invalid.
 Position sourceLocToPosition(const SourceManager , SourceLocation Loc);
 
+/// Get the last Position on a given line.
+llvm::Expected endOfLine(llvm::StringRef Code, int Line);
+
 /// Return the file location, corresponding to \p P. Note that one should take
 /// care to avoid comparing the result with expansion locations.
 llvm::Expected sourceLocationInMainFile(const SourceManager ,
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -228,6 +228,16 @@
   return P;
 }
 
+llvm::Expected endOfLine(llvm::StringRef Code, int Line) {
+  auto StartOfLine = positionToOffset(Code, Position{Line, 0});
+  if (!StartOfLine)
+return StartOfLine.takeError();
+  StringRef LineText = Code.drop_front(*StartOfLine).take_until([](char C) {
+return C == '\n';
+  });
+  return Position{Line, static_cast(lspLength(LineText))};
+}
+
 bool isSpelledInSource(SourceLocation Loc, const SourceManager ) {
   if (Loc.isFileID())
 return true;
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -483,22 +483,15 @@
 for (; It != NonConflicting.end() && It->R.start.line < Line; ++It)
   WithInactiveLines.push_back(std::move(*It));
 // Add a token for the inactive line itself.
-auto StartOfLine = positionToOffset(MainCode, Position{Line, 0});
-if (StartOfLine) {
-  StringRef LineText =
-  MainCode.drop_front(*StartOfLine).take_until([](char C) {
-return C == '\n';
-  });
+auto EndOfLine = endOfLine(MainCode, Line);
+if (EndOfLine) {
   HighlightingToken HT;
   WithInactiveLines.emplace_back();
   WithInactiveLines.back().Kind = HighlightingKind::InactiveCode;
   WithInactiveLines.back().R.start.line = Line;
-  WithInactiveLines.back().R.end.line = Line;
-  WithInactiveLines.back().R.end.character =
-  static_cast(lspLength(LineText));
+  WithInactiveLines.back().R.end = *EndOfLine;
 } else {
-  elog("Failed to convert position to offset: {0}",
-   StartOfLine.takeError());
+  elog("Failed to determine end of line: {0}", EndOfLine.takeError());
 }
 
 // Skip any other tokens on the inactive line. e.g.
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ 

[PATCH] D148723: [clang] Restrict Inline Builtin to non-static, non-odr linkage

2023-05-29 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe20931b2ccd1: [clang] Restrict Inline Builtin to non-static, 
non-odr linkage (authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148723

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/inline-builtin-comdat.c


Index: clang/test/CodeGen/inline-builtin-comdat.c
===
--- /dev/null
+++ clang/test/CodeGen/inline-builtin-comdat.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm -disable-llvm-passes 
%s -o - | FileCheck %s
+// Inline builtin are not supported for odr linkage
+// CHECK-NOT: .inline
+
+double __cdecl frexp( double _X, int* _Y);
+inline __attribute__((always_inline))  long double __cdecl frexpl( long double 
__x, int *__exp ) {
+  return (long double) frexp((double)__x, __exp );
+}
+
+long double pain(void)
+{
+long double f = 123.45;
+int i;
+long double f2 = frexpl(f, );
+return f2;
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3314,8 +3314,23 @@
 return false;
 
   const FunctionDecl *Definition;
-  return hasBody(Definition) && Definition->isInlineSpecified() &&
- Definition->hasAttr();
+  if (!hasBody(Definition))
+return false;
+
+  if (!Definition->isInlineSpecified() ||
+  !Definition->hasAttr())
+return false;
+
+  ASTContext  = getASTContext();
+  switch (Context.GetGVALinkageForFunction(this)) {
+  case GVA_Internal:
+  case GVA_DiscardableODR:
+  case GVA_StrongODR:
+return false;
+  case GVA_AvailableExternally:
+  case GVA_StrongExternal:
+return true;
+  }
 }
 
 bool FunctionDecl::isDestroyingOperatorDelete() const {


Index: clang/test/CodeGen/inline-builtin-comdat.c
===
--- /dev/null
+++ clang/test/CodeGen/inline-builtin-comdat.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
+// Inline builtin are not supported for odr linkage
+// CHECK-NOT: .inline
+
+double __cdecl frexp( double _X, int* _Y);
+inline __attribute__((always_inline))  long double __cdecl frexpl( long double __x, int *__exp ) {
+  return (long double) frexp((double)__x, __exp );
+}
+
+long double pain(void)
+{
+long double f = 123.45;
+int i;
+long double f2 = frexpl(f, );
+return f2;
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3314,8 +3314,23 @@
 return false;
 
   const FunctionDecl *Definition;
-  return hasBody(Definition) && Definition->isInlineSpecified() &&
- Definition->hasAttr();
+  if (!hasBody(Definition))
+return false;
+
+  if (!Definition->isInlineSpecified() ||
+  !Definition->hasAttr())
+return false;
+
+  ASTContext  = getASTContext();
+  switch (Context.GetGVALinkageForFunction(this)) {
+  case GVA_Internal:
+  case GVA_DiscardableODR:
+  case GVA_StrongODR:
+return false;
+  case GVA_AvailableExternally:
+  case GVA_StrongExternal:
+return true;
+  }
 }
 
 bool FunctionDecl::isDestroyingOperatorDelete() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e20931b - [clang] Restrict Inline Builtin to non-static, non-odr linkage

2023-05-29 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-05-29T10:02:18+02:00
New Revision: e20931b2ccd10de2fd25d9a6fbe9c166e7430f23

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

LOG: [clang] Restrict Inline Builtin to non-static, non-odr linkage

Inline builtins have a very special behavior compared to other
functions, it's better if we keep them restricted to a minimal set of
functions.

Add a linkage check which prevents considering ODR definitions as inline
builtins.

Fix #62958

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

Added: 
clang/test/CodeGen/inline-builtin-comdat.c

Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 5317b9d805b58..e441c338a2c76 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3314,8 +3314,23 @@ bool FunctionDecl::isInlineBuiltinDeclaration() const {
 return false;
 
   const FunctionDecl *Definition;
-  return hasBody(Definition) && Definition->isInlineSpecified() &&
- Definition->hasAttr();
+  if (!hasBody(Definition))
+return false;
+
+  if (!Definition->isInlineSpecified() ||
+  !Definition->hasAttr())
+return false;
+
+  ASTContext  = getASTContext();
+  switch (Context.GetGVALinkageForFunction(this)) {
+  case GVA_Internal:
+  case GVA_DiscardableODR:
+  case GVA_StrongODR:
+return false;
+  case GVA_AvailableExternally:
+  case GVA_StrongExternal:
+return true;
+  }
 }
 
 bool FunctionDecl::isDestroyingOperatorDelete() const {

diff  --git a/clang/test/CodeGen/inline-builtin-comdat.c 
b/clang/test/CodeGen/inline-builtin-comdat.c
new file mode 100644
index 0..1b00711de43e8
--- /dev/null
+++ b/clang/test/CodeGen/inline-builtin-comdat.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-windows -S -emit-llvm -disable-llvm-passes 
%s -o - | FileCheck %s
+// Inline builtin are not supported for odr linkage
+// CHECK-NOT: .inline
+
+double __cdecl frexp( double _X, int* _Y);
+inline __attribute__((always_inline))  long double __cdecl frexpl( long double 
__x, int *__exp ) {
+  return (long double) frexp((double)__x, __exp );
+}
+
+long double pain(void)
+{
+long double f = 123.45;
+int i;
+long double f2 = frexpl(f, );
+return f2;
+}



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


[PATCH] D151547: [RISCV] Remove experimental for zihintntl.

2023-05-29 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added a comment.

In D151547#4375613 , @asb wrote:

> Thanks for the patch.
>
> Is the __riscv_ntl_* interface finalised and agreed? I'm wary of repeating 
> the mistake we made with the V extension where we exposed intrinsics that 
> weren't yet finalised.

I don't find any information about these two intrinsics, where do they be 
proposed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151547

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


[clang] 46deb40 - [CodeGen] Use llvm::LLVMContext::MD_nontemporal (NFC)

2023-05-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-05-29T00:41:51-07:00
New Revision: 46deb4092d84c02463c5e8ebd664288eab6cdc56

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

LOG: [CodeGen] Use llvm::LLVMContext::MD_nontemporal (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a0bb35d098a5..3a61fdd65592 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14504,7 +14504,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 
 // Unaligned nontemporal store of the scalar value.
 StoreInst *SI = Builder.CreateDefaultAlignedStore(Src, BC);
-SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
+SI->setMetadata(llvm::LLVMContext::MD_nontemporal, Node);
 SI->setAlignment(llvm::Align(1));
 return SI;
   }
@@ -20226,8 +20226,7 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 LoadInst *Load = Builder.CreateLoad(
 Address(Ops[0], ResTy, CharUnits::fromQuantity(Width / 8)));
 
-Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"),
-  NontemporalNode);
+Load->setMetadata(llvm::LLVMContext::MD_nontemporal, NontemporalNode);
 Load->setMetadata(CGM.getModule().getMDKindID("riscv-nontemporal-domain"),
   RISCVDomainNode);
 
@@ -20246,8 +20245,7 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType()), "cast");
 
 StoreInst *Store = Builder.CreateDefaultAlignedStore(Ops[1], BC);
-Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"),
-   NontemporalNode);
+Store->setMetadata(llvm::LLVMContext::MD_nontemporal, NontemporalNode);
 Store->setMetadata(CGM.getModule().getMDKindID("riscv-nontemporal-domain"),
RISCVDomainNode);
 

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index c074732df2a7..35d4a1a62682 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1777,7 +1777,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address 
Addr, bool Volatile,
   if (isNontemporal) {
 llvm::MDNode *Node = llvm::MDNode::get(
 Load->getContext(), 
llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
-Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
+Load->setMetadata(llvm::LLVMContext::MD_nontemporal, Node);
   }
 
   CGM.DecorateInstructionWithTBAA(Load, TBAAInfo);
@@ -1916,7 +1916,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value 
*Value, Address Addr,
 llvm::MDNode *Node =
 llvm::MDNode::get(Store->getContext(),
   llvm::ConstantAsMetadata::get(Builder.getInt32(1)));
-Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
+Store->setMetadata(llvm::LLVMContext::MD_nontemporal, Node);
   }
 
   CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);



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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-29 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

LGTM

- Missing release notes entry.
- I'm not sure about change in StmtCXX.h, do we need it ? Coudn't we just use 
children() + getBody()
- CHECK-MESSAGES-NOT get me a little bit confused. Maybe we dont need those 
entrys, just make sure that test fail when non listed warning show up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

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


[PATCH] D151537: [NFC] Update cpu_specific test to use a newer CPU

2023-05-29 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151537

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-29 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:1
+#include "InterpreterUtils.h"
+#include "clang/AST/ASTContext.h"

Please add the llvm preamble. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-29 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Interpreter/IncrementalParser.h:86
 
+  Parser () { return *P; }
+

Is that used?



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:262
+
+static llvm::Expected CompileDecl(Interpreter ,
+   Decl *D) {

Let's add a FIXME here. The problem `CompileDecl` and `GenModule` intends to 
solve is that when we synthesize AST we need to inform the rest of the Clang 
infrastructure about it and attach the produced `llvm::Module` to the JIT so 
that it can resolve symbols from it.

In cling that is solved with a RAII object which marks a scope where the 
synthesis happens and takes care to inform the rest of the infrastructure. We 
need something similar and a little more robust maybe. Something like 
`ASTSynthesisRAII` which ultimately hides this machinery especially from the 
public API.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:442
+
+REPL_EXTERNAL_VISIBILITY std::string PrintValueRuntime(const char *const *Val) 
{
+  return PrintString(Val);

All of the `PrintValueRuntime` seem to be duplicating code. We could use the 
preprocessor to expand these to but it would require some changes which I 
believe could be done as a separate patch:

* Perhaps we should be compatible with cling here in terms of naming as that's 
a public API - there I believe we use `printValue`.
* We should try to leverage `TemplateBase.cpp::printIntegral` for integral 
types.
* We should not return `std::string` here but a `const char*` and we should 
provide somewhere storage for them. That would probably make porting to 
embedded systems easier since on many the  header is hard to support. 

I believe it would be enough to have a fixme for now.



Comment at: clang/lib/Interpreter/ValuePrinter.cpp:473
+  else if (auto *BT = DesugaredTy.getCanonicalType()->getAs()) {
+switch (BT->getKind()) {
+case BuiltinType::Bool: {

We could use the preprocessor the way we do in `Value.cpp` to expand this 
dispatcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D148490: [AIX] use system assembler for assembly files

2023-05-29 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

gentle ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148490

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-29 Thread Jun Zhang via Phabricator via cfe-commits
junaire added inline comments.



Comment at: clang/tools/clang-repl/CMakeLists.txt:40
+  ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z
+  
??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z
+  
??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z

v.g.vassilev wrote:
> v.g.vassilev wrote:
> > We should check if there is a better way to export a subset of symbols 
> > through the llvm build system. Maybe @lhames, @sunho or @sgraenitz know how.
> I wonder if that's related to https://reviews.llvm.org/D151620 in some way? 
> That is, does D151620 fix our exports and this section becomes redundant?
I haven't tested that but I don't think so. The patch you posted is about 
fixing issues on particular platforms like MinGW.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-29 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 526383.
junaire added a comment.

Make CreateUniqName a static helper


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/PartialTranslationUnit.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/DeviceOffload.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -29,6 +29,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace caas;
 
 #if defined(_AIX)
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
@@ -46,12 +47,12 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgs);
   auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
===
--- clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -27,6 +27,7 @@
 
 using namespace llvm;
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 
@@ -52,12 +53,12 @@
 
 TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) {
   std::vector ClangArgv = {"-Xclang", "-emit-llvm-only"};
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgv);
   auto CI = cantFail(CB.CreateCpp());
   auto Interp = llvm::cantFail(Interpreter::create(std::move(CI)));
 
-  std::array PTUs;
+  std::array PTUs;
 
   PTUs[0] = ::cantFail(Interp->Parse(TestProgram1));
   ASSERT_TRUE(PTUs[0]->TheModule);
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -30,6 +30,7 @@
 #include "gtest/gtest.h"
 
 using namespace clang;
+using namespace clang::caas;
 
 namespace {
 using Args = std::vector;
@@ -38,12 +39,12 @@
   DiagnosticConsumer *Client = nullptr) {
   Args ClangArgs = {"-Xclang", "-emit-llvm-only"};
   ClangArgs.insert(ClangArgs.end(), ExtraArgs.begin(), ExtraArgs.end());
-  auto CB = clang::IncrementalCompilerBuilder();
+  auto CB = clang::caas::IncrementalCompilerBuilder();
   CB.SetCompilerArgs(ClangArgs);
   auto CI = cantFail(CB.CreateCpp());
   if (Client)
 CI->getDiagnostics().setClient(Client, /*ShouldOwnClient=*/false);
-  return cantFail(clang::Interpreter::create(std::move(CI)));
+  return cantFail(clang::caas::Interpreter::create(std::move(CI)));
 }
 
 TEST(InterpreterTest, CatchException) {
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -97,7 +97,7 @@
 return 0;
   }
 
-  clang::IncrementalCompilerBuilder CB;
+  clang::caas::IncrementalCompilerBuilder CB;
   CB.SetCompilerArgs(ClangArgv);
 
   std::unique_ptr DeviceCI;
@@ -132,10 +132,10 @@
   if (CudaEnabled)
 DeviceCI->LoadRequestedPlugins();
 
-  std::unique_ptr Interp;
+  std::unique_ptr Interp;
   if (CudaEnabled) {
-Interp = ExitOnErr(
-clang::Interpreter::createWithCUDA(std::move(CI), std::move(DeviceCI)));
+