[PATCH] D155368: [clang][Interp] __builtin_copysign

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

I can add some basic tests for `__builtin_copysign` here, but there are test 
added in https://reviews.llvm.org/D155369 as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155368

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


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

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



Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:194
+
+  S.Stk.push>(Integral<32, true>::from(Arg.isFinite()));
+  return true;

aaron.ballman wrote:
> We have platforms on which the width of an integer is not 32-bits; because 
> this is pushing values back onto the stack, won't we run into some odd issues 
> where `builtin + 1` would be adding a 32-bit and a 16-bit value?
Yes, you don't even need to add anything for it to fail. I can add a way of 
doing that in a follow-up commit. And/or add an assertion now.

Also, what platform would that be? So I can add a test later.


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

https://reviews.llvm.org/D155372

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


[PATCH] D155545: [clang][Interp] Pass CallExpr to builtin functions

2023-07-17 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, shafik, cor3ntin.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  For some builtins, we need to do quite a bit of type checking ourselves,
  so pass the call expression along. This way we can inspect arguments,
  expected return value, etc.

As discussed with @aaron.ballman on Discord, reject non-StringLiteral inputs 
from `__builtin_isnan()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155545

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/builtin-functions.cpp

Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -41,7 +41,9 @@
 namespace nan {
   constexpr double NaN1 = __builtin_nan("");
 
-  constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}}
+  constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}} \
+   // expected-error {{must be initialized by a constant expression}}
+
 }
 
 namespace inf {
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -52,6 +52,7 @@
 def ArgRoundingMode : ArgType { let Name = "llvm::RoundingMode"; }
 def ArgLETD: ArgType { let Name = "const LifetimeExtendedTemporaryDecl *"; }
 def ArgCastKind : ArgType { let Name = "CastKind"; }
+def ArgCallExpr : ArgType { let Name = "const CallExpr *"; }
 
 //===--===//
 // Classes of types instructions operate on.
@@ -188,7 +189,7 @@
 }
 
 def CallBI : Opcode {
-  let Args = [ArgFunction];
+  let Args = [ArgFunction, ArgCallExpr];
   let Types = [];
 }
 
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -73,7 +73,11 @@
 
 static bool interp__builtin_nan(InterpState , CodePtr OpPC,
 const InterpFrame *Frame, const Function *F,
-bool Signaling) {
+bool Signaling, const CallExpr *Call) {
+
+  if (!isa(Call->getArg(0)->IgnoreParenCasts()))
+return false;
+
   const Pointer  = getParam(Frame, 0);
 
   if (!CheckLoad(S, OpPC, Arg))
@@ -240,10 +244,9 @@
 /// second one is an integral value.
 static bool interp__builtin_isfpclass(InterpState , CodePtr OpPC,
   const InterpFrame *Frame,
-  const Function *Func) {
-  const Expr *E = S.Current->getExpr(OpPC);
-  const CallExpr *CE = cast(E);
-  PrimType FPClassArgT = *S.getContext().classify(CE->getArgs()[1]->getType());
+  const Function *Func,
+  const CallExpr *Call) {
+  PrimType FPClassArgT = *S.getContext().classify(Call->getArg(1)->getType());
   APSInt FPClassArg = peekToAPSInt(S.Stk, FPClassArgT);
   const Floating  =
   S.Stk.peek(align(primSize(FPClassArgT) + primSize(PT_Float)));
@@ -304,10 +307,9 @@
 /// The return type must be the same.
 static bool interp__builtin_arithmetic_fence(InterpState , CodePtr OpPC,
  const InterpFrame *Frame,
- const Function *Func) {
-  const Expr *E = S.Current->getExpr(OpPC);
-  const CallExpr *CE = cast(E);
-  QualType ReturnType = CE->getType();
+ const Function *Func,
+ const CallExpr *Call) {
+  QualType ReturnType = Call->getType();
 
   // TODO: Support vector and complex types.
   if (!ReturnType->isFloatingType())
@@ -319,7 +321,8 @@
   return true;
 }
 
-bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
+bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F,
+  const CallExpr *Call) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
 
@@ -338,7 +341,7 @@
   case Builtin::BI__builtin_nanl:
   case Builtin::BI__builtin_nanf16:
   case Builtin::BI__builtin_nanf128:
-if (interp__builtin_nan(S, OpPC, Frame, F, /*Signaling=*/false))
+if (interp__builtin_nan(S, OpPC, Frame, F, /*Signaling=*/false, Call))
   return Ret(S, OpPC, Dummy);
 break;
   case Builtin::BI__builtin_nans:
@@ -346,7 +349,7 @@
   case 

[PATCH] D154755: [clang-format] Fix formatting of if statements with BlockIndent

2023-07-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:25486
"comment\n"
-   "  return;\n"
"}",

Why remove?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154755

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


[PATCH] D140745: Generate Config {Fragment structure, json schema, docs, YAML parser} from schema spec

2023-07-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D140745#4508559 , @nridge wrote:

> In D140745#4505829 , @sammccall 
> wrote:
>
>> ping on this one for when you have time
>
> (Just wanted to double-check, is this ping directed to me or Kadir (or both)? 
> I haven't looked at this because Kadir has done a round of review and it 
> seemed like duplication of work for me to look at it as well; however, if 
> you'd like me to do a round of review, I'm happy to!)

Oops, indeed it was directed at Kadir, we'd also discussed it offline at length 
a few months ago and I think this is mostly a question of cleaning up the 
details now.

Always happy to have more feedback or hear concerns, but no need unless you're 
interested (and this patch isn't that interesting :-D)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140745

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


[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-17 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1035
 IO.mapOptional("SpaceInEmptyBlock", Style.SpaceInEmptyBlock);
-IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses);
 IO.mapOptional("SpacesBeforeTrailingComments",

By removing the old options don’t you break everyone’s clang format file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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


[PATCH] D155544: [AIX][TLS] Add -maix-small-local-exec-tls option.

2023-07-17 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: PowerPC, stefanp, kamaub, nemanjai, 
hubert.reinterpretcast.
amyk added a project: LLVM.
Herald added subscribers: kbarton, hiraditya.
Herald added a project: All.
amyk requested review of this revision.
Herald added a project: clang.
Herald added subscribers: llvm-commits, cfe-commits.

This patch adds an AIX-specific option to inform the compiler that it can use
a faster access sequence for the local-exec TLS model (formally named
`aix-small-local-exec-tls`).

This patch only adds the option, and the backend implementation for this option
will be added in a follow up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155544

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/aix-small-local-exec-tls.c
  clang/test/OpenMP/target_data_map_codegen_hold.cpp
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll

Index: llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/check-aix-small-local-exec-tls-opt.ll
@@ -0,0 +1,18 @@
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls \
+; RUN:   -ppc-asm-full-reg-names < %s | FileCheck %s
+; RUN: not llc -mtriple powerpc64le-unknown-linux-gnu -mattr=+aix-small-local-exec-tls \
+; RUN:   -ppc-asm-full-reg-names < %s 2>&1 | \
+; RUN:   FileCheck %s --check-prefix=CHECK-NOT-SUPPORTED
+
+define dso_local signext i32 @f() {
+entry:
+  ret i32 0
+}
+
+; Check that the -maix-small-local-exec-tls option is not supported on Linux.
+; CHECK-NOT-SUPPORTED: The aix-small-local-exec-tls attribute is only supported on AIX.
+
+; Make sure that the test was actually compiled successfully after using the
+; -maix-small-local-exec-tls option.
+; CHECK:li r3, 0
+; CHECK-NEXT:   blr
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -123,6 +123,11 @@
 
   // Determine endianness.
   IsLittleEndian = TM.isLittleEndian();
+
+  if ((!TargetTriple.isOSAIX()) && HasAIXSmallLocalExecTLS)
+report_fatal_error(
+  "The aix-small-local-exec-tls attribute is only supported on AIX.\n",
+  false);
 }
 
 bool PPCSubtarget::enableMachineScheduler() const { return true; }
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -318,6 +318,14 @@
   SubtargetFeature<"privileged", "HasPrivileged", "true",
"Add privileged instructions">;
 
+def FeatureAIXLocalExecTLS :
+  SubtargetFeature<"aix-small-local-exec-tls", "HasAIXSmallLocalExecTLS", "true",
+   "Produce a faster access sequence for local-exec TLS "
+   "variables where the offset from the thread pointer value "
+   "is encoded as an immediate operand (AIX 64-bit only). "
+   "This access sequence is not used for variables larger "
+   "than 32KB.">;
+
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
"PredictableSelectIsExpensive",
Index: clang/test/OpenMP/target_data_map_codegen_hold.cpp
===
--- clang/test/OpenMP/target_data_map_codegen_hold.cpp
+++ clang/test/OpenMP/target_data_map_codegen_hold.cpp
@@ -517,7 +517,7 @@
 
 #endif
 //.
-// CHECK-PPC64LE: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx" }
+// CHECK-PPC64LE: attributes #[[ATTR0:[0-9]+]] = { mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-aix-small-local-exec-tls,-altivec,-bpermd,-crbits,-crypto,-direct-move,-extdiv,-htm,-isa-v206-instructions,-isa-v207-instructions,-isa-v30-instructions,-power8-vector,-power9-vector,-privileged,-quadword-atomics,-rop-protect,-spe,-vsx" }
 // CHECK-PPC64LE: attributes #[[ATTR1:[0-9]+]] = { nounwind }
 // CHECK-PPC64LE: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
 //.
Index: clang/test/Driver/aix-small-local-exec-tls.c
===
--- /dev/null
+++ clang/test/Driver/aix-small-local-exec-tls.c
@@ -0,0 +1,29 @@
+// RUN: %clang -target powerpc64-unknown-aix -S 

[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare marked an inline comment as done.
gedare added a comment.

I simplified this to treat the double parens identically, so that it will 
either inject spaces inside both parens, or not.

Note: This option is necessary to disable ``SpacesInParens.Other`` from adding 
spaces inside of ``__attribute__((...))``.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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


[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 541322.
gedare added a comment.

Merge the two options to just one for attribute parens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16718,6 +16718,7 @@
   Spaces.SpacesInParensOptions = {};
   Spaces.SpacesInParensOptions.Other = true;
   Spaces.SpacesInParensOptions.InConditionalStatements = true;
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
   verifyFormat("do_something( ::globalVar );", Spaces);
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
@@ -16744,6 +16745,8 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__( ( naked ) ) foo( int bar )", Spaces);
 
   Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
   Spaces.SpacesInParensOptions = {};
@@ -16785,6 +16788,12 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("SomeType *__attribute__((attr)) *a = NULL;", Spaces);
+
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
+  verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__( ( naked ) ) foo(int bar)", Spaces);
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = false;
 
   // Run the first set of tests again with:
   Spaces.SpaceAfterCStyleCast = true;
@@ -16817,6 +16826,8 @@
   verifyFormat("bool *y = ( bool * ) ( void * ) (x);", Spaces);
   verifyFormat("bool *y = ( bool * ) (x);", Spaces);
   verifyFormat("throw ( int32 ) x;", Spaces);
+  verifyFormat("SomeType *__attribute__((attr)) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__((naked)) foo(int bar)", Spaces);
 
   // Run subset of tests again with:
   Spaces.SpacesInParensOptions.InCStyleCasts = false;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -217,6 +217,7 @@
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
+  CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InAttributeSpecifiers);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InCStyleCasts);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InConditionalStatements);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InEmptyParentheses);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3810,10 +3810,16 @@
   }
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) {
-return (Right.is(TT_CastRParen) ||
-(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
-   ? Style.SpacesInParensOptions.InCStyleCasts
-   : Style.SpacesInParensOptions.Other;
+if (Right.is(TT_CastRParen) ||
+(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) {
+  return Style.SpacesInParensOptions.InCStyleCasts;
+}
+if (Left.is(TT_AttributeParen) || Right.is(TT_AttributeParen) ||
+(Left.Previous && Left.Previous->is(TT_AttributeParen)) ||
+(Right.Next && Right.Next->is(TT_AttributeParen))) {
+  return Style.SpacesInParensOptions.InAttributeSpecifiers;
+}
+return Style.SpacesInParensOptions.Other;
   }
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -713,6 +713,7 @@
 
 template <> struct MappingTraits {
   static void mapping(IO , FormatStyle::SpacesInParensCustom ) {
+IO.mapOptional("InAttributeSpecifiers", Spaces.InAttributeSpecifiers);
 IO.mapOptional("InCStyleCasts", Spaces.InCStyleCasts);
 IO.mapOptional("InConditionalStatements", Spaces.InConditionalStatements);
 IO.mapOptional("InEmptyParentheses", Spaces.InEmptyParentheses);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -4205,6 +4205,12 @@
   /// 

[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare planned changes to this revision.
gedare added inline comments.



Comment at: clang/include/clang/Format/Format.h:4208-4213
+/// Put a space in parentheses inside attribute specifier lists.
+/// \code
+///true:  false:
+///__attribute__(( noreturn ))vs. __attribute__((noreturn))
+/// \endcode
+bool InAttributeSpecifierLists;

owenpan wrote:
> This should be covered by `SpacesInParetheses`, so we really should not have 
> a special option for `__attribute__`.
Currently, the behavior of `SpacesInParentheses` does this:
```
__attribute__( ( noreturn ) )
```
In order to prevent this from happening, it is necessary to add an option to 
disable it somehow, because I don't see that this kind of spacing should ever 
be used by anyone, but probably someone does it, and it should be maintained 
for backward compatibility anyway.



Comment at: clang/include/clang/Format/Format.h:4214-4220
+/// Put a space in parentheses around the outside of attribute specifier
+/// lists.
+/// \code
+///true:  false:
+///__attribute__( (noreturn) )vs. __attribute__((noreturn))
+/// \endcode
+bool InAttributeSpecifiers;

owenpan wrote:
> I'm against this as the double parens, IMO, should never be separated.
I'm happy to consolidate these to a single option, that only allows to toggle 
between all spaces and no spaces, i.e.,
```
__attribute__( ( noreturn ) )  // enabled
__attribute__((noreturn)) // disabled
```
The style I aim for, uses no spaces around attributes, but likes to have spaces 
in other places. I will prepare a revision.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3818
+if (Right.is(TT_AttributeParen) ||
+(Left.MatchingParen && Left.MatchingParen->is(TT_AttributeParen))) {
+  return Style.SpacesInParensOptions.InAttributeSpecifiers;

This logic can be simplified, since the parser labels both the left and right 
parentheses (unlike with the ``CastRParen`` case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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


[PATCH] D153273: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-07-17 Thread Tomasz Kamiński via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd937836ead34: [analyzer] Rework support for CFGScopeBegin, 
CFGScopeEnd, CFGLifetime elements (authored by tomasz-kaminski-sonarsource).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/lifetime-cfg-output.cpp
  clang/test/Analysis/no-exit-cfg.c
  clang/test/Analysis/nonreturn-destructors-cfg-output.cpp
  clang/test/Analysis/scopes-cfg-output.cpp

Index: clang/test/Analysis/scopes-cfg-output.cpp
===
--- clang/test/Analysis/scopes-cfg-output.cpp
+++ clang/test/Analysis/scopes-cfg-output.cpp
@@ -674,30 +674,30 @@
   A f;
 }
 
-// CHECK:  [B8 (ENTRY)]
+// CHECK:  [B9 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B7
 // CHECK:  [B1]
 // CHECK-NEXT:  l1:
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B1.2], A)
 // CHECK-NEXT:   2: A c;
 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   5: [B6.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B6.2].~A() (Implicit destructor)
 // CHECK-NEXT:   6: [B7.3].~A() (Implicit destructor)
 // CHECK-NEXT:   7: CFGScopeEnd(a)
 // CHECK-NEXT:   Preds (2): B2 B3
 // CHECK-NEXT:   Succs (1): B0
 // CHECK:  [B2]
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B2.2], A)
-// CHECK-NEXT:   2: A b;
+// CHECK-NEXT:   2: A nb;
 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   5: CFGScopeEnd(a)
+// CHECK-NEXT:   4: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(na)
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
 // CHECK:  [B3]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: CFGScopeEnd(a)
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
 // CHECK-NEXT:   T: goto l1;
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
@@ -708,33 +708,35 @@
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (2): B3 B2
 // CHECK:  [B5]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   3: [B6.3].~A() (Implicit destructor)
-// CHECK-NEXT:   4: CFGScopeEnd(cb)
-// CHECK-NEXT:   T: goto l0;
 // CHECK-NEXT:   Preds (1): B6
-// CHECK-NEXT:   Succs (1): B6
+// CHECK-NEXT:   Succs (1): B8
 // CHECK:  [B6]
 // CHECK-NEXT:  l0:
-// CHECK-NEXT:   1: CFGScopeBegin(cb)
-// CHECK-NEXT:   2:  (CXXConstructExpr, [B6.3], A)
-// CHECK-NEXT:   3: A cb;
-// CHECK-NEXT:   4:  (CXXConstructExpr, [B6.5], A)
-// CHECK-NEXT:   5: A b;
-// CHECK-NEXT:   6: CFGScopeBegin(a)
-// CHECK-NEXT:   7:  (CXXConstructExpr, [B6.8], A)
-// CHECK-NEXT:   8: A a;
-// CHECK-NEXT:   9: UV
-// CHECK-NEXT:  10: [B6.9] (ImplicitCastExpr, LValueToRValue, _Bool)
-// CHECK-NEXT:   T: if [B6.10]
-// CHECK-NEXT:   Preds (2): B7 B5
+// CHECK-NEXT:   1:  (CXXConstructExpr, [B6.2], A)
+// CHECK-NEXT:   2: A cb;
+// CHECK-NEXT:   3:  (CXXConstructExpr, [B6.4], A)
+// CHECK-NEXT:   4: A b;
+// CHECK-NEXT:   5: CFGScopeBegin(na)
+// CHECK-NEXT:   6:  (CXXConstructExpr, [B6.7], A)
+// CHECK-NEXT:   7: A na;
+// CHECK-NEXT:   8: UV
+// CHECK-NEXT:   9: [B6.8] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK-NEXT:   T: if [B6.9]
+// CHECK-NEXT:   Preds (2): B7 B8
 // CHECK-NEXT:   Succs (2): B5 B4
 // CHECK:  [B7]
 // CHECK-NEXT:   1: CFGScopeBegin(a)
 // CHECK-NEXT:   2:  (CXXConstructExpr, [B7.3], A)
 // CHECK-NEXT:   3: A a;
-// CHECK-NEXT:   Preds (1): B8
+// CHECK-NEXT:   Preds (1): B9
+// CHECK-NEXT:   Succs (1): B6
+// CHECK:  [B8]
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
+// CHECK-NEXT:   3: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.2].~A() (Implicit destructor)
+// CHECK-NEXT:   T: goto l0;
+// CHECK-NEXT:   Preds (1): B5
 // CHECK-NEXT:   Succs (1): B6
 // CHECK:  [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
@@ -743,10 +745,10 @@
 l0:
   A cb;
   A b;
-  { A a;
+  { A na;
 if (UV) goto l0;
 if (UV) goto l1;
-A b;
+A nb;
   }
 l1:
   A c;
@@ -1168,3 +1170,184 @@
 }
   }
 }
+
+// CHECK:   [B4 (ENTRY)]
+// CHECK-NEXT:Succs (1): B3
+// CHECK:   [B1]
+// CHECK-NEXT:   label:
+// CHECK-NEXT:1: CFGScopeEnd(n2t)
+// CHECK-NEXT:2: CFGScopeEnd(n1t)
+// CHECK-NEXT:3: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:4: CFGScopeEnd(a)
+// CHECK-NEXT:Preds (2): B2 B3
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: [B3.9].~A() (Implicit 

[clang] d937836 - [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-07-17 Thread Tomasz Kamiński via cfe-commits

Author: tomasz-kaminski-sonarsource
Date: 2023-07-18T07:03:32+02:00
New Revision: d937836ead34030f4ac016a8eb8a179bd5be10f3

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

LOG: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime 
elements

This patch reworks generation for the `CFGScopeBegin`, `CFGScopeEnd`,
and `CFGLiftimeEnd`, in a way that they are now compatible with each
other and `CFGAutomaticObjDtor`. All of the above elements are now
generated by a single code path, that conditionally inserts elements if
they are requested.

In addition, the handling of `goto` statements is improved.
The `goto` statement may leave multiple scopes (and trigger destruction
and lifetime end for the affected variables) and enter multiple scopes,
for example:
```lang=C++
{
  int s1;
  {
int s2;
goto label; // leaves s1, s2, and enters t1 t1
  }
}
{
  int t1;
  {
int t2;
label:
  }
}
```
This is performed by first determining the shared parent scope of the
source and destination. And then emitting elements for exiting each
scope between the source and the parent, and entering each scope
between the parent and destination. All such elements are appended
to the source block, as one label may be reached from multiple scopes.

Finally, the approach for handling backward jumps is changed. When
connecting a source block to a destination block that requires the
insertion of additional elements, we put this element into a new block,
which is then linked between the source and the destination block.
For example:
```lang=C++
{
  int t;
label:
  // Destination block referred to as 'DB'
}
{
  // Source block referred to as 'SB'
  Obj s;
  goto label;
}
```

The jump between `SB` with terminator `T: goto` and `DB` should be
coupled with the following CFG elements:
```
CFGAutomaticObjDtor(s)
CFGLifetimeEnd(s)
CFGScopeEnd(s)
CFGScopeBegin(t)
```

To handle such situations, we create a new link (`LB`) that is linked as
the predecessor of `DB`, to which we transfer the terminator (`goto`
statement) of `SB`. Then `LB` is handled in the same manner as the
source block in the case of forward jumps.
This produces CFG that looks like this:
```
SB -> LB (T: goto) -> DB
```

Finally, the resulting block is linked as the successor of `SB`. Such an
approach uses existing handling of the `noreturn` destructors.
As a reminder, for each destructor of an automatic object that is
marked as `noreturn`, a new `noreturn` block (marked `NBn`) is
created, at the destructor is inserted at the end of it.
To illustrate, given two `noreturn` destructors, we will have:
```
SB -> NB1 (noreturn)
NB2 (noreturn)
LB (T:goto) -> DB
```

Reviewed By: ymandel, steakhal

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

Added: 
clang/test/Analysis/nonreturn-destructors-cfg-output.cpp

Modified: 
clang/include/clang/Analysis/CFG.h
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
clang/test/Analysis/lifetime-cfg-output.cpp
clang/test/Analysis/no-exit-cfg.c
clang/test/Analysis/scopes-cfg-output.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index bd5658cbdea387..eacebe176dda4c 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -1122,19 +1122,10 @@ class CFGBlock {
 Elements.push_back(CFGScopeBegin(VD, S), C);
   }
 
-  void prependScopeBegin(const VarDecl *VD, const Stmt *S,
- BumpVectorContext ) {
-Elements.insert(Elements.rbegin(), 1, CFGScopeBegin(VD, S), C);
-  }
-
   void appendScopeEnd(const VarDecl *VD, const Stmt *S, BumpVectorContext ) {
 Elements.push_back(CFGScopeEnd(VD, S), C);
   }
 
-  void prependScopeEnd(const VarDecl *VD, const Stmt *S, BumpVectorContext ) 
{
-Elements.insert(Elements.rbegin(), 1, CFGScopeEnd(VD, S), C);
-  }
-
   void appendBaseDtor(const CXXBaseSpecifier *BS, BumpVectorContext ) {
 Elements.push_back(CFGBaseDtor(BS), C);
   }
@@ -1162,44 +1153,6 @@ class CFGBlock {
   void appendDeleteDtor(CXXRecordDecl *RD, CXXDeleteExpr *DE, 
BumpVectorContext ) {
 Elements.push_back(CFGDeleteDtor(RD, DE), C);
   }
-
-  // Destructors must be inserted in reversed order. So insertion is in two
-  // steps. First we prepare space for some number of elements, then we insert
-  // the elements beginning at the last position in prepared space.
-  iterator beginAutomaticObjDtorsInsert(iterator I, size_t Cnt,
-  BumpVectorContext ) {
-return iterator(Elements.insert(I.base(), Cnt,
-CFGAutomaticObjDtor(nullptr, nullptr), C));
-  }
-  iterator insertAutomaticObjDtor(iterator I, VarDecl *VD, Stmt *S) {
-*I = CFGAutomaticObjDtor(VD, S);
-return ++I;
-  

[PATCH] D155356: [clang][Interp] Implement __builtin_nan family of functions

2023-07-17 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 541318.

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

https://reviews.llvm.org/D155356

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

Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify
 // RUN: %clang_cc1 -verify=ref %s -Wno-constant-evaluated
+// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter %s -verify
+// RUN: %clang_cc1 -std=c++20 -verify=ref %s -Wno-constant-evaluated
+
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -34,3 +37,9 @@
 // ref-error {{not an integral constant}} \
 // ref-note {{dereferenced one-past-the-end}}
 }
+
+namespace nan {
+  constexpr double NaN1 = __builtin_nan("");
+
+  constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}}
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -9,6 +9,7 @@
 #include "Interp.h"
 #include "PrimType.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetInfo.h"
 
 namespace clang {
 namespace interp {
@@ -57,6 +58,64 @@
   return true;
 }
 
+static bool interp__builtin_nan(InterpState , CodePtr OpPC,
+const InterpFrame *Frame, const Function *F,
+bool Signaling) {
+  const Pointer  = getParam(Frame, 0);
+
+  if (!CheckLoad(S, OpPC, Arg))
+return false;
+
+  assert(Arg.getFieldDesc()->isPrimitiveArray());
+
+  // Convert the given string to an integer using StringRef's API.
+  llvm::APInt Fill;
+  std::string Str;
+  assert(Arg.getNumElems() >= 1);
+  for (unsigned I = 0, E = Arg.getNumElems() - 1; I != E; ++I) {
+const Pointer  = Arg.atIndex(I);
+
+if (!CheckLoad(S, OpPC, Elem))
+  return false;
+
+Str += Elem.deref();
+  }
+
+  // Treat empty strings as if they were zero.
+  if (Str.empty())
+Fill = llvm::APInt(32, 0);
+  else if (StringRef(Str).getAsInteger(0, Fill))
+return false;
+
+  const llvm::fltSemantics  =
+  S.getCtx().getFloatTypeSemantics(F->getDecl()->getReturnType());
+
+  Floating Result;
+  if (S.getCtx().getTargetInfo().isNan2008()) {
+if (Signaling)
+  Result = Floating(
+  llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, ));
+else
+  Result = Floating(
+  llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, ));
+  } else {
+// Prior to IEEE 754-2008, architectures were allowed to choose whether
+// the first bit of their significand was set for qNaN or sNaN. MIPS chose
+// a different encoding to what became a standard in 2008, and for pre-
+// 2008 revisions, MIPS interpreted sNaN-2008 as qNan and qNaN-2008 as
+// sNaN. This is now known as "legacy NaN" encoding.
+if (Signaling)
+  Result = Floating(
+  llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, ));
+else
+  Result = Floating(
+  llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, ));
+  }
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -70,7 +129,24 @@
   case Builtin::BI__builtin_strcmp:
 if (interp__builtin_strcmp(S, OpPC, Frame))
   return Ret(S, OpPC, Dummy);
-return false;
+break;
+  case Builtin::BI__builtin_nan:
+  case Builtin::BI__builtin_nanf:
+  case Builtin::BI__builtin_nanl:
+  case Builtin::BI__builtin_nanf16:
+  case Builtin::BI__builtin_nanf128:
+if (interp__builtin_nan(S, OpPC, Frame, F, /*Signaling=*/false))
+  return Ret(S, OpPC, Dummy);
+break;
+  case Builtin::BI__builtin_nans:
+  case Builtin::BI__builtin_nansf:
+  case Builtin::BI__builtin_nansl:
+  case Builtin::BI__builtin_nansf16:
+  case Builtin::BI__builtin_nansf128:
+if (interp__builtin_nan(S, OpPC, Frame, F, /*Signaling=*/true))
+  return Ret(S, OpPC, Dummy);
+break;
+
   default:
 return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155356: [clang][Interp] Implement __builtin_nan family of functions

2023-07-17 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 541314.

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

https://reviews.llvm.org/D155356

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

Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify
 // RUN: %clang_cc1 -verify=ref %s -Wno-constant-evaluated
+// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter %s -verify
+// RUN: %clang_cc1 -std=c++20 -verify=ref %s -Wno-constant-evaluated
+
 
 namespace strcmp {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
@@ -34,3 +37,28 @@
 // ref-error {{not an integral constant}} \
 // ref-note {{dereferenced one-past-the-end}}
 }
+
+namespace nan {
+  constexpr double NaN1 = __builtin_nan("");
+
+#if __cplusplus >= 202002
+  /// Reading an uninitialized value as part of the argument.
+  constexpr int foo() { // ref-error {{never produces a constant expression}}
+char f[2];
+f[0] = '1';
+
+double d = __builtin_nan(f); // ref-note 2{{subexpression not valid in a constant expression}} \
+ // expected-note {{read of uninitialized object}} \
+ // expected-note {{in call to '__builtin_nan}}
+return 1;
+  }
+  static_assert(foo() == 1); // ref-error {{not an integral constant expression}} \
+ // ref-note {{in call to}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{in call to}}
+#endif
+
+
+  constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}}
+
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -9,6 +9,7 @@
 #include "Interp.h"
 #include "PrimType.h"
 #include "clang/Basic/Builtins.h"
+#include "clang/Basic/TargetInfo.h"
 
 namespace clang {
 namespace interp {
@@ -57,6 +58,60 @@
   return true;
 }
 
+static bool interp__builtin_nan(InterpState , CodePtr OpPC,
+const InterpFrame *Frame, const Function *F,
+bool Signaling) {
+  const Pointer  = getParam(Frame, 0);
+
+  if (!CheckLoad(S, OpPC, Arg))
+return false;
+
+  assert(Arg.getFieldDesc()->isPrimitiveArray());
+
+  // Convert the given string to an integer using StringRef's API.
+  llvm::APInt Fill;
+  std::string Str;
+  assert(Arg.getNumElems() >= 1);
+  for (unsigned I = 0, E = Arg.getNumElems() - 1; I != E; ++I) {
+const Pointer  = Arg.atIndex(I);
+
+if (!CheckLoad(S, OpPC, Elem))
+  return false;
+
+Str += Elem.deref();
+  }
+  if (StringRef(Str).getAsInteger(0, Fill))
+return false;
+
+  const llvm::fltSemantics  =
+  S.getCtx().getFloatTypeSemantics(F->getDecl()->getReturnType());
+
+  Floating Result;
+  if (S.getCtx().getTargetInfo().isNan2008()) {
+if (Signaling)
+  Result = Floating(
+  llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, ));
+else
+  Result = Floating(
+  llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, ));
+  } else {
+// Prior to IEEE 754-2008, architectures were allowed to choose whether
+// the first bit of their significand was set for qNaN or sNaN. MIPS chose
+// a different encoding to what became a standard in 2008, and for pre-
+// 2008 revisions, MIPS interpreted sNaN-2008 as qNan and qNaN-2008 as
+// sNaN. This is now known as "legacy NaN" encoding.
+if (Signaling)
+  Result = Floating(
+  llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, ));
+else
+  Result = Floating(
+  llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, ));
+  }
+
+  S.Stk.push(Result);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -70,7 +125,24 @@
   case Builtin::BI__builtin_strcmp:
 if (interp__builtin_strcmp(S, OpPC, Frame))
   return Ret(S, OpPC, Dummy);
-return false;
+break;
+  case Builtin::BI__builtin_nan:
+  case Builtin::BI__builtin_nanf:
+  case Builtin::BI__builtin_nanl:
+  case Builtin::BI__builtin_nanf16:
+  case Builtin::BI__builtin_nanf128:
+if (interp__builtin_nan(S, OpPC, Frame, F, /*Signaling=*/false))
+  return Ret(S, OpPC, Dummy);
+break;
+  case Builtin::BI__builtin_nans:
+  case Builtin::BI__builtin_nansf:
+  case 

[PATCH] D155445: [analyzer][docs] Add CSA release notes

2023-07-17 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie accepted this revision.
OikawaKirie added a comment.

LGTM for my part. Thx.

Since I am not very familiar with other changes, I have no detailed suggestions 
for the order.




Comment at: clang/docs/ReleaseNotes.rst:922-923
+- The ``CStringChecker`` will invalidate less if the copy operation is
+  inferable to be bounded. For example, if the argument of ``strcpy`` is known
+  to be of certain length and that is in-bounds.
+

The lengths of both src and dst buffers need to be known.



Comment at: clang/docs/ReleaseNotes.rst:937
+
+  Similarly, functions like ``strsep`` now won't invalidate the source buffer,
+  because it can never overflow.

I think this may be a typo here, as we do not invalidate the source buffer 
originally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155445

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


[PATCH] D155523: [clang] Fix a crash when casting to an array type

2023-07-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:458
+  case InitializationSequence::FK_ParenthesizedListInitFailed:
+// In C++20, if the underlying destination type is a RecordType, then we
+// attempt to perform parentesized aggregate initialization if constructor

Can you quote the sections in the standard that say this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155523

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


[PATCH] D155111: [clangd] Fix build failures observed on build bots for missing libs

2023-07-17 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir added a comment.

In D155111#4495131 , @mstorsjo wrote:

> To clarify the issue - the kind of builds that seems to be broken is builds 
> with `BUILD_SHARED_LIBS=ON`. The reason is that these libraries are needed is 
> because the `clangd` target includes 
> `$`, so all the dependencies of 
> `clangDaemonTweaks` would need to be included here as well. Please include 
> that in the commit message description. (Is there a way to pull in those 
> instead of duplicating the list?)
>
> This looks mostly ok to me, but it does add slightly more libraries than 
> what's needed. As the list of libraries that now are linked into `clangdMain` 
> is the list of libraries that previously was linked for the two components 
> that now are `clangd` and `clangdMain`, so some of the dependencies only need 
> to be moved, not duplicated.
>
> A more minimal set of dependencies, which seems to link successfully with 
> `BUILD_SHARED_LIBS=ON`, is achieved with this diff on top of current git main:
>
>   diff --git a/clang-tools-extra/clangd/tool/CMakeLists.txt 
> b/clang-tools-extra/clangd/tool/CMakeLists.txt
>   index ddf9c2488819..6c21175d7687 100644
>   --- a/clang-tools-extra/clangd/tool/CMakeLists.txt
>   +++ b/clang-tools-extra/clangd/tool/CMakeLists.txt
>   @@ -26,11 +26,7 @@ clang_target_link_libraries(clangdMain
>  clangBasic
>  clangFormat
>  clangFrontend
>   -  clangLex
>   -  clangSema
>  clangTooling
>   -  clangToolingCore
>   -  clangToolingRefactoring
>  clangToolingSyntax
>  )
>
>   @@ -44,7 +40,20 @@ target_link_libraries(clangdMain
>  ${CLANGD_XPC_LIBS}
>  )
>
>   +clang_target_link_libraries(clangd
>   +  PRIVATE
>   +  clangAST
>   +  clangBasic
>   +  clangLex
>   +  clangSema
>   +  clangToolingCore
>   +  clangToolingRefactoring
>   +  clangToolingSyntax
>   +  )
>   +
>target_link_libraries(clangd
>  PRIVATE
>  clangdMain
>   +  clangDaemon
>   +  clangdSupport
>  )
>
> Not sure if it's good hygiene to only link specifically to exactly those 
> libraries that are needed and nothing else, or if it's just making things 
> slightly more brittle?

Thanks for reviewing and providing suggestions. I have put up a follow up patch 
for review: https://reviews.llvm.org/D155540


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155111

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


[PATCH] D155540: [clangd] Move dependancies for clangd

2023-07-17 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
saghir requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This patch moves dependancies for clangd instead of duplicating them.
This is a follow up patch to 915659bfa1e9fe2e2c748ac84d33881e248f9ad5 
,
which was added to fix build failure with BUILD_SHARED_LIBS=ON.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155540

Files:
  clang-tools-extra/clangd/tool/CMakeLists.txt


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax


Index: clang-tools-extra/clangd/tool/CMakeLists.txt
===
--- clang-tools-extra/clangd/tool/CMakeLists.txt
+++ clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -26,11 +26,7 @@
   clangBasic
   clangFormat
   clangFrontend
-  clangLex
-  clangSema
   clangTooling
-  clangToolingCore
-  clangToolingRefactoring
   clangToolingSyntax
   )
 
@@ -48,11 +44,8 @@
   PRIVATE
   clangAST
   clangBasic
-  clangFormat
-  clangFrontend
   clangLex
   clangSema
-  clangTooling
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155539: [CUDA][HIP] Use the same default language std as C++

2023-07-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: mattd, carlosgalvezp.
Herald added a project: All.
yaxunl requested review of this revision.

Currently CUDA/HIP defines their own language standards in 
LanguageStandards.def but they are redundant. They are the same as stdc++14. 
The fact that CUDA/HIP uses c++* in option `-std=` indicates that they have the 
same language standards as C++. The CUDA/HIP specific language features are 
conveyed through language options, not language standards features. It makes 
sense to let CUDA/HIP uses the same default language standard as C++.


https://reviews.llvm.org/D155539

Files:
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Basic/LangStandards.cpp
  clang/test/CodeGenCUDA/long-double.cu
  clang/test/Driver/unknown-std.cpp
  clang/test/Preprocessor/lang-std.cpp

Index: clang/test/Preprocessor/lang-std.cpp
===
--- clang/test/Preprocessor/lang-std.cpp
+++ clang/test/Preprocessor/lang-std.cpp
@@ -1,12 +1,14 @@
-// UNSUPPORTED: target={{.*-(ps4|ps5)}}
 /// Test default standards.
-/// PS4/PS5 default to gnu++14.
+/// CUDA/HIP uses the same default standards as C++.
 
-// RUN: %clang_cc1 -dM -E %s | FileCheck --check-prefix=CXX17 %s
-// RUN: %clang_cc1 -dM -E -x cuda %s | FileCheck --check-prefix=CXX14 %s
-// RUN: %clang_cc1 -dM -E -x hip %s | FileCheck --check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E %s | grep __cplusplus >%T-cpp-std.txt
+// RUN: %clang_cc1 -dM -E -x cuda %s | grep __cplusplus >%T-cuda-cuda.txt
+// RUN: %clang_cc1 -dM -E -x hip %s | grep __cplusplus >%T-hip-std.txt
+// RUN: diff %T-cpp-std.txt %T-cuda-cuda.txt
+// RUN: diff %T-cpp-std.txt %T-hip-std.txt
 
 // RUN: %clang_cc1 -dM -E -x cuda -std=c++14 %s | FileCheck --check-prefix=CXX14 %s
+// RUN: %clang_cc1 -dM -E -x cuda -std=c++17 %s | FileCheck --check-prefix=CXX17 %s
 // RUN: %clang_cc1 -dM -E -x hip -std=c++98 %s | FileCheck --check-prefix=CXX98 %s
 
 // CXX98: #define __cplusplus 199711L
Index: clang/test/Driver/unknown-std.cpp
===
--- clang/test/Driver/unknown-std.cpp
+++ clang/test/Driver/unknown-std.cpp
@@ -4,7 +4,10 @@
 
 // RUN: not %clang %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
 // RUN: not %clang -x objective-c++ %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
-// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s -std=foobar -c 2>&1 | FileCheck --match-full-lines --check-prefix=CHECK --check-prefix=CUDA %s
+// RUN: not %clang -x cuda -nocudainc -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda \
+// RUN:   %s -std=foobar -c 2>&1 | FileCheck --match-full-lines %s
+// RUN: not %clang -x hip -nocudainc -nocudalib %s -std=foobar -c 2>&1 \
+// RUN:   | FileCheck --match-full-lines %s
 
 // CHECK: error: invalid value 'foobar' in '-std=foobar'
 // CHECK-NEXT: note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
Index: clang/test/CodeGenCUDA/long-double.cu
===
--- clang/test/CodeGenCUDA/long-double.cu
+++ clang/test/CodeGenCUDA/long-double.cu
@@ -6,7 +6,7 @@
 // RUN:   -aux-triple x86_64-unknown-gnu-linux -fcuda-is-device \
 // RUN:   -emit-llvm -o - %s 2>&1 | FileCheck %s
 
-// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFD586B834, align 8
+// CHECK: @_ZN15infinity_helperIeE5valueE = {{.*}} double 0x47EFD586B834,{{.*}} align 8
 // CHECK: @size = {{.*}} i32 8
 
 #include "Inputs/cuda.h"
Index: clang/lib/Basic/LangStandards.cpp
===
--- clang/lib/Basic/LangStandards.cpp
+++ clang/lib/Basic/LangStandards.cpp
@@ -54,8 +54,6 @@
 return LangStandard::lang_opencl12;
   case Language::OpenCLCXX:
 return LangStandard::lang_openclcpp10;
-  case Language::CUDA:
-return LangStandard::lang_cuda;
   case Language::Asm:
   case Language::C:
 // The PS4 uses C99 as the default C standard.
@@ -66,13 +64,13 @@
 return LangStandard::lang_gnu11;
   case Language::CXX:
   case Language::ObjCXX:
+  case Language::CUDA:
+  case Language::HIP:
 if (T.isPS())
   return LangStandard::lang_gnucxx14;
 return LangStandard::lang_gnucxx17;
   case Language::RenderScript:
 return LangStandard::lang_c99;
-  case Language::HIP:
-return LangStandard::lang_hip;
   case Language::HLSL:
 return LangStandard::lang_hlsl2021;
   }
Index: clang/include/clang/Basic/LangStandards.def
===
--- clang/include/clang/Basic/LangStandards.def
+++ clang/include/clang/Basic/LangStandards.def
@@ -214,14 +214,6 @@
 LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
 LANGSTANDARD_ALIAS_DEPR(openclcpp2021, "CLC++2021")
 
-// CUDA
-LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",
- LineComment | CPlusPlus | CPlusPlus11 

[PATCH] D144829: [WIP][BPF] Add a few new insns under cpu=v4

2023-07-17 Thread Alexei Starovoitov via Phabricator via cfe-commits
ast accepted this revision.
ast added a comment.
This revision is now accepted and ready to land.

overall looks good. one small nit.




Comment at: llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h:17
+enum FixupKind {
+  // These correspond directly to R_390_* relocations.
+  FK_BPF_PCRel_4 = FirstTargetFixupKind,

a little bit too much of copy paste :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144829

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


[PATCH] D155537: [ASTImporter] Fix import failed when anonymous union defined in class

2023-07-17 Thread Qizhi Hu via Phabricator via cfe-commits
jcsxky created this revision.
jcsxky added a reviewer: danix800.
jcsxky added a project: clang.
Herald added a subscriber: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
jcsxky requested review of this revision.
Herald added a subscriber: cfe-commits.

when import a class contains two anonymous unions, constructor accesses member 
in the second union would lead to import the second union, after that, import 
the first union will lead to conflict, skip when two union are both anonymous.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155537

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -2462,6 +2462,36 @@
 functionDecl(hasName("f"), hasDescendant(declRefExpr()));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportAnnonymousUnionInClassTest) {
+  const char *Code =
+  R"(
+  class B{
+
+  public:
+
+B(){
+  c=1;
+}
+
+void foo1(){}
+
+  private:
+union{
+  int a;
+  int b;
+};
+union {
+  int c;
+  int d;
+};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  EXPECT_TRUE(FromTU);
+}
+
+
 struct ImportFunctionTemplates : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportFunctionTemplates, ImportFunctionTemplateInRecordDeclTwice) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3861,7 +3861,9 @@
   ASTImporter::getFieldIndex(D) !=
   ASTImporter::getFieldIndex(FoundField))
 continue;
-
+  if (D->isAnonymousStructOrUnion() && 
FoundField->isAnonymousStructOrUnion()) {
+continue;
+  }
   if (Importer.IsStructurallyEquivalent(D->getType(),
 FoundField->getType())) {
 Importer.MapImported(D, FoundField);


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -2462,6 +2462,36 @@
 functionDecl(hasName("f"), hasDescendant(declRefExpr()));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportAnnonymousUnionInClassTest) {
+  const char *Code =
+  R"(
+  class B{
+
+  public:
+
+B(){
+  c=1;
+}
+
+void foo1(){}
+
+  private:
+union{
+  int a;
+  int b;
+};
+union {
+  int c;
+  int d;
+};
+  };
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11);
+  EXPECT_TRUE(FromTU);
+}
+
+
 struct ImportFunctionTemplates : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportFunctionTemplates, ImportFunctionTemplateInRecordDeclTwice) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3861,7 +3861,9 @@
   ASTImporter::getFieldIndex(D) !=
   ASTImporter::getFieldIndex(FoundField))
 continue;
-
+  if (D->isAnonymousStructOrUnion() && FoundField->isAnonymousStructOrUnion()) {
+continue;
+  }
   if (Importer.IsStructurallyEquivalent(D->getType(),
 FoundField->getType())) {
 Importer.MapImported(D, FoundField);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104931: [AArch64] Wire up ILP32 ABI support in Clang

2023-07-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: wangpc.

We need some tests. 
https://maskray.me/blog/2021-08-08-toolchain-testing#i-dont-know-whether-a-test-is-needed

Adding some to `clang/test/Preprocessor/init-aarch64.c` should cover many 
changes, but we also need one to cover setDataLayout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104931

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


[PATCH] D153273: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-07-17 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

Thanks! Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

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


[PATCH] D140745: Generate Config {Fragment structure, json schema, docs, YAML parser} from schema spec

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

In D140745#4505829 , @sammccall wrote:

> ping on this one for when you have time

(Just wanted to double-check, is this ping directed to me or Kadir (or both)? I 
haven't looked at this because Kadir has done a round of review and it seemed 
like duplication of work for me to look at it as well; however, if you'd like 
me to do a round of review, I'm happy to!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140745

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


[PATCH] D153310: Add builtin_elementwise_pow

2023-07-17 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 541294.
bob80905 added a comment.

fix void return, and incorrect expectation of arg count


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153310

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/aarch64-sve-vector-pow-ops.c
  clang/test/Sema/builtins-elementwise-math.c
  clang/test/Sema/riscv-sve-vector-pow-ops.c
  clang/test/SemaCXX/builtins-elementwise-math.cpp

Index: clang/test/SemaCXX/builtins-elementwise-math.cpp
===
--- clang/test/SemaCXX/builtins-elementwise-math.cpp
+++ clang/test/SemaCXX/builtins-elementwise-math.cpp
@@ -198,3 +198,11 @@
   static_assert(!is_const::value);
   static_assert(!is_const::value);
 }
+
+void test_builtin_elementwise_pow() {
+  const double a = 2;
+  double b = 1;
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+  static_assert(!is_const::value);
+}
Index: clang/test/Sema/riscv-sve-vector-pow-ops.c
===
--- /dev/null
+++ clang/test/Sema/riscv-sve-vector-pow-ops.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+
+#include 
+
+
+vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) {
+
+  return __builtin_elementwise_pow(v, v);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type}}
+}
\ No newline at end of file
Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -438,6 +438,60 @@
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) {
+  i = __builtin_elementwise_pow(p, d);
+  // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
+
+  struct Foo foo = __builtin_elementwise_pow(i, i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_pow(i);
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
+
+  i = __builtin_elementwise_pow();
+  // expected-error@-1 {{too few arguments to function call, expected 2, have 0}}
+
+  i = __builtin_elementwise_pow(i, i, i);
+  // expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
+
+  i = __builtin_elementwise_pow(v, iv);
+  // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
+
+  i = __builtin_elementwise_pow(uv, iv);
+  // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
+
+  enum e { one,
+   two };
+  i = __builtin_elementwise_pow(one, two);
+
+  enum f { three };
+  enum f x = __builtin_elementwise_pow(one, three);
+
+  _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
+  ext = __builtin_elementwise_pow(ext, ext);
+
+  const int ci;
+  i = __builtin_elementwise_pow(ci, i);
+  i = __builtin_elementwise_pow(i, ci);
+  i = __builtin_elementwise_pow(ci, ci);
+
+  i = __builtin_elementwise_pow(i, int_as_one); // ok (attributes don't match)?
+  i = __builtin_elementwise_pow(i, b);  // ok (sugar doesn't match)?
+
+  int A[10];
+  A = __builtin_elementwise_pow(A, A);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
+
+  int(ii);
+  int j;
+  j = __builtin_elementwise_pow(i, j);
+
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_pow(c1, c2);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
+}
+
+
 void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_roundeven(f);
Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-vector-pow-ops.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \
+// RUN:   -target-feature +v -target-feature +zfh  -target-feature +sve -target-feature +experimental-zvfh \
+// RUN:   -disable-O0-optnone -o - 

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

2023-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4576
+  case RISCVVector::BI__builtin_rvv_vaeskf1_vi_ta:
+  case RISCVVector::BI__builtin_rvv_vsm4k_vi_ta:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);

craig.topper wrote:
> eopXD wrote:
> > Valid range of `vaeskf1`, `vaeskf2` seems to be 0 to 15. [0]
> > Valid range of `vsm4k` seems to be 0 to 7 [1].
> > 
> > 
> > 
> > [0] 
> > https://github.com/riscv/riscv-crypto/blob/master/doc/vector/insns/vaeskf1.adoc
> >  
> > [1] 
> > https://github.com/riscv/riscv-crypto/blob/master/doc/vector/insns/vsm4k.adoc
> I think the field in the instruction is 5 bits, but vaeskf1 and vaeskf2 
> ignore bit 4. The true valid range is 1-10. The other values are aliased to 
> one of the valid values. Should the intrinsic interface expose all 32 
> possible values or just 1-10?
1-10 is the valid range for vaeskf1. vaeskf2 is 2-14.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


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

2023-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c:12
+//
+vint16mf4_t test_vwsll_vv_i16mf4(vint8mf8_t op1, vint8mf8_t op2, size_t vl) {
+  return __riscv_vwsll_vv_i16mf4(op1, op2, vl);

craig.topper wrote:
> It doesn't make sense for op2 to be signed. It's a shift amount, its always a 
> positive number
The spec doesn't define signed versions of these instrinsics from what I can 
see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


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

2023-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2405
+  defvar suffix = !if(IsVV, "vv", "vi");
+  defvar prototype = !if(IsVV, "UvUvUvUv", "UvUvUvKz");
+  defm "" : RVVBuiltinSet;

Can we split this into two classes and get rid of IsVV?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D155534: fix arg validation issue and void return issue, tests pass

2023-07-17 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 created this revision.
Herald added a project: All.
bob80905 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/D155534

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -443,7 +443,7 @@
   // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}}
 
   struct Foo foo = __builtin_elementwise_pow(i, i);
-  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
 
   i = __builtin_elementwise_pow(i);
   // expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
@@ -460,11 +460,6 @@
   i = __builtin_elementwise_pow(uv, iv);
   // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
 
-  v = __builtin_elementwise_pow(v, v);
-  // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
-
-  s = __builtin_elementwise_pow(i, s);
-
   enum e { one,
two };
   i = __builtin_elementwise_pow(one, two);
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -453,52 +453,23 @@
 }
 
 void test_builtin_elementwise_pow(float f1, float f2, double d1, double d2,
-  float4 vf1, float4 vf2, long long int i1,
-  long long int i2, si8 vi1, si8 vi2,
-  unsigned u1, unsigned u2, u4 vu1, u4 vu2,
-  _BitInt(31) bi1, _BitInt(31) bi2,
-  unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2) {
-  // CHECK:  [[I1:%.+]] = load i64, ptr %i1.addr, align 8
-  // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8
-  // CHECK-NEXT: call i64 @llvm.pow.i64(i64 [[I1]], i64 [[I2]])
-  i1 = __builtin_elementwise_pow(i1, i2);
-
-  // CHECK:  [[I1:%.+]] = load i64, ptr %i1.addr, align 8
-  // CHECK-NEXT: call i64 @llvm.pow.i64(i64 [[I1]], i64 10)
-  i1 = __builtin_elementwise_pow(i1, 10);
-
-  // CHECK:  [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16
-  // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16
-  // CHECK-NEXT: call <8 x i16> @llvm.pow.v8i16(<8 x i16> [[VI1]], <8 x i16> [[VI2]])
-  vi1 = __builtin_elementwise_pow(vi1, vi2);
-
-  // CHECK:  [[U1:%.+]] = load i32, ptr %u1.addr, align 4
-  // CHECK-NEXT: [[U2:%.+]] = load i32, ptr %u2.addr, align 4
-  // CHECK-NEXT: call i32 @llvm.pow.i32(i32 [[U1]], i32 [[U2]])
-  u1 = __builtin_elementwise_pow(u1, u2);
+  float4 vf1, float4 vf2) {
 
-  // CHECK:  [[VU1:%.+]] = load <4 x i32>, ptr %vu1.addr, align 16
-  // CHECK-NEXT: [[VU2:%.+]] = load <4 x i32>, ptr %vu2.addr, align 16
-  // CHECK-NEXT: call <4 x i32> @llvm.pow.v4i32(<4 x i32> [[VU1]], <4 x i32> [[VU2]])
-  vu1 = __builtin_elementwise_pow(vu1, vu2);
-
-  // CHECK:  [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4
-  // CHECK-NEXT: [[BI2:%.+]] = load i31, ptr %bi2.addr, align 4
-  // CHECK-NEXT: call i31 @llvm.pow.i31(i31 [[BI1]], i31 [[BI2]])
-  bi1 = __builtin_elementwise_pow(bi1, bi2);
-
-  // CHECK:  [[BU1:%.+]] = load i55, ptr %bu1.addr, align 8
-  // CHECK-NEXT: [[BU2:%.+]] = load i55, ptr %bu2.addr, align 8
-  // CHECK-NEXT: call i55 @llvm.pow.i55(i55 [[BU1]], i55 [[BU2]])
-  bu1 = __builtin_elementwise_pow(bu1, bu2);
+  // CHECK-LABEL: define void @test_builtin_elementwise_pow(
+  // CHECK:  [[F1:%.+]] = load float, ptr %f1.addr, align 4
+  // CHECK:  [[F2:%.+]] = load float, ptr %f2.addr, align 4
+  // CHECK-NEXT:  call float @llvm.pow.f32(float [[F1]], float [[F2]])
+  f2 = __builtin_elementwise_pow(f1, f2);
 
-  // CHECK:  [[IAS1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4
-  // CHECK-NEXT: [[B:%.+]] = load i32, ptr @b, align 4
-  // CHECK-NEXT: call i32 @llvm.pow.i32(i32 [[IAS1]], i32 [[B]])
-  int_as_one = __builtin_elementwise_pow(int_as_one, b);
+  // CHECK:  [[D1:%.+]] = load double, ptr %d1.addr, align 8
+  // CHECK:  [[D2:%.+]] = load double, ptr %d2.addr, align 8
+  // CHECK-NEXT: call double @llvm.pow.f64(double [[D1]], double [[D2]])
+  d2 = __builtin_elementwise_pow(d1, d2);
 
-  // CHECK: call i32 @llvm.pow.i32(i32 1, i32 97)
-  i1 = __builtin_elementwise_pow(1, 'a');
+  // CHECK:  [[VF1:%.+]] = load <4 x 

[PATCH] D155509: Revert "Remove rdar links; NFC"

2023-07-17 Thread Mehdi AMINI 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 rGe0ac46e69d7a: Revert Remove rdar links; NFC 
(authored by mehdi_amini).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155509

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  clang/test/ARCMT/GC-check-warn-nsalloc.m
  clang/test/ARCMT/GC-no-finalize-removal.m
  clang/test/ARCMT/GC-no-finalize-removal.m.result
  clang/test/ARCMT/GC.m
  clang/test/ARCMT/GC.m.result
  clang/test/ARCMT/check-with-pch.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/nonobjc-to-objc-cast-2.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/ARCMT/objcmt-atomic-property.m
  clang/test/ARCMT/objcmt-atomic-property.m.result
  clang/test/ARCMT/objcmt-boxing.m
  clang/test/ARCMT/objcmt-boxing.m.result
  clang/test/ARCMT/objcmt-migrate-all.m
  clang/test/ARCMT/objcmt-migrate-all.m.result
  clang/test/ARCMT/objcmt-ns-macros.m
  clang/test/ARCMT/objcmt-ns-macros.m.result
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
  clang/test/ARCMT/objcmt-property-availability.m
  clang/test/ARCMT/objcmt-property-availability.m.result
  clang/test/ARCMT/objcmt-property-dot-syntax.m
  clang/test/ARCMT/objcmt-property-dot-syntax.m.result
  clang/test/ARCMT/objcmt-property.m
  clang/test/ARCMT/objcmt-property.m.result
  clang/test/ARCMT/objcmt-protocol-conformance.m
  clang/test/ARCMT/objcmt-protocol-conformance.m.result
  clang/test/ARCMT/objcmt-undefined-ns-macros.m
  clang/test/ARCMT/objcmt-undefined-ns-macros.m.result
  clang/test/Analysis/DeallocMissingRelease.m
  clang/test/Analysis/DeallocUseAfterFreeErrors.m
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/inline-plist.c.plist
  clang/test/Analysis/Inputs/expected-plists/malloc-plist.c.plist
  clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/NSString.m
  clang/test/Analysis/OSAtomic_mac.cpp
  clang/test/Analysis/PR46264.cpp
  clang/test/Analysis/UserNullabilityAnnotations.m
  clang/test/Analysis/array-struct-region.c
  clang/test/Analysis/blocks.m
  clang/test/Analysis/call-and-message.m
  clang/test/Analysis/call-invalidation.cpp
  clang/test/Analysis/cfref_rdar6080742.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/default-analyze.m
  clang/test/Analysis/delegates.m
  clang/test/Analysis/edges-new.mm
  clang/test/Analysis/generics.m
  clang/test/Analysis/inline-plist.c
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist
  clang/test/Analysis/inlining/eager-reclamation-path-notes.c
  clang/test/Analysis/inlining/false-positive-suppression.c
  clang/test/Analysis/inlining/path-notes.m
  clang/test/Analysis/malloc-interprocedural.c
  clang/test/Analysis/malloc-plist.c
  clang/test/Analysis/malloc.c
  clang/test/Analysis/misc-ps-64.m
  clang/test/Analysis/misc-ps-arm.m
  clang/test/Analysis/misc-ps-eager-assume.m
  clang/test/Analysis/misc-ps-ranges.m
  clang/test/Analysis/misc-ps-region-store.cpp
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/misc-ps.m
  clang/test/Analysis/mutually_exclusive_null_fp.cpp
  clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
  clang/test/Analysis/null-deref-ps.c
  clang/test/Analysis/objc-arc.m
  clang/test/Analysis/objc-encode.m
  clang/test/Analysis/objc-subscript.m
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/plist-output-alternate.m
  clang/test/Analysis/plist-output.m
  clang/test/Analysis/properties.m
  clang/test/Analysis/properties.mm
  clang/test/Analysis/reference.cpp
  clang/test/Analysis/retain-release-inline.m
  clang/test/Analysis/retain-release-region-store.m
  clang/test/Analysis/retain-release.m
  clang/test/Analysis/retain-release.mm
  clang/test/Analysis/security-syntax-checks.m
  clang/test/Analysis/stack-addr-ps.c
  clang/test/Analysis/stack-addr-ps.cpp
  clang/test/Analysis/templates.cpp
  clang/test/Analysis/uninit-bug-first-iteration-init.c
  

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

2023-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4576
+  case RISCVVector::BI__builtin_rvv_vaeskf1_vi_ta:
+  case RISCVVector::BI__builtin_rvv_vsm4k_vi_ta:
+return SemaBuiltinConstantArgRange(TheCall, 1, 0, 31);

eopXD wrote:
> Valid range of `vaeskf1`, `vaeskf2` seems to be 0 to 15. [0]
> Valid range of `vsm4k` seems to be 0 to 7 [1].
> 
> 
> 
> [0] 
> https://github.com/riscv/riscv-crypto/blob/master/doc/vector/insns/vaeskf1.adoc
>  
> [1] 
> https://github.com/riscv/riscv-crypto/blob/master/doc/vector/insns/vsm4k.adoc
I think the field in the instruction is 5 bits, but vaeskf1 and vaeskf2 ignore 
bit 4. The true valid range is 1-10. The other values are aliased to one of the 
valid values. Should the intrinsic interface expose all 32 possible values or 
just 1-10?



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c:12
+//
+vint16mf4_t test_vwsll_vv_i16mf4(vint8mf8_t op1, vint8mf8_t op2, size_t vl) {
+  return __riscv_vwsll_vv_i16mf4(op1, op2, vl);

It doesn't make sense for op2 to be signed. It's a shift amount, its always a 
positive number



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c:22
+//
+vint16mf4_t test_vwsll_vx_i16mf4(vint8mf8_t op1, int8_t op2, size_t vl) {
+  return __riscv_vwsll_vx_i16mf4(op1, op2, vl);

scalar shift amounts should be size_t


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/include/clang/Format/Format.h:4208-4213
+/// Put a space in parentheses inside attribute specifier lists.
+/// \code
+///true:  false:
+///__attribute__(( noreturn ))vs. __attribute__((noreturn))
+/// \endcode
+bool InAttributeSpecifierLists;

This should be covered by `SpacesInParetheses`, so we really should not have a 
special option for `__attribute__`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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


[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2249
   }
 
   UnsafeOps = groupWarningGadgetsByVar(std::move(WarningGadgets));

Maybe early-return here when there are no gadgets?


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

https://reviews.llvm.org/D155524

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


[PATCH] D155509: Revert "Remove rdar links; NFC"

2023-07-17 Thread Chris Lattner via Phabricator via cfe-commits
lattner accepted this revision.
lattner added a comment.

Thank you, this should have been reverted immediately when concerns were raised.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155509

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


[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

2023-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/include/clang/Format/Format.h:4214-4220
+/// Put a space in parentheses around the outside of attribute specifier
+/// lists.
+/// \code
+///true:  false:
+///__attribute__( (noreturn) )vs. __attribute__((noreturn))
+/// \endcode
+bool InAttributeSpecifiers;

I'm against this as the double parens, IMO, should never be separated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155529

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


[PATCH] D154755: [clang-format] Fix formatting of if statements with BlockIndent

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154755

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


[PATCH] D155529: [clang-format] Add SpaceInParensOption for __attribute__ keyword

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

The __attribute((specifier-list)) currently is formatted based on the
SpacesInParensOptions.Other (previously, SpacesInParentheses). This change
allows finer control over addition of spaces between the consecutive parens,
and between the inner parens and the list of attribute specifiers.

DependsOn: D155239 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155529

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16718,6 +16718,8 @@
   Spaces.SpacesInParensOptions = {};
   Spaces.SpacesInParensOptions.Other = true;
   Spaces.SpacesInParensOptions.InConditionalStatements = true;
+  Spaces.SpacesInParensOptions.InAttributeSpecifierLists = true;
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
   verifyFormat("do_something( ::globalVar );", Spaces);
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
@@ -16744,6 +16746,8 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
+  verifyFormat("void __attribute__( ( naked ) ) foo( int bar )", Spaces);
 
   Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
   Spaces.SpacesInParensOptions = {};
@@ -16785,6 +16789,13 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("SomeType *__attribute__((attr)) *a = NULL;", Spaces);
+
+  Spaces.SpacesInParensOptions.InAttributeSpecifierLists = true;
+  verifyFormat("SomeType *__attribute__(( attr )) *a = NULL;", Spaces);
+  Spaces.SpacesInParensOptions.InAttributeSpecifierLists = false;
+  Spaces.SpacesInParensOptions.InAttributeSpecifiers = true;
+  verifyFormat("SomeType *__attribute__( (attr) ) *a = NULL;", Spaces);
 
   // Run the first set of tests again with:
   Spaces.SpaceAfterCStyleCast = true;
@@ -16817,6 +16828,7 @@
   verifyFormat("bool *y = ( bool * ) ( void * ) (x);", Spaces);
   verifyFormat("bool *y = ( bool * ) (x);", Spaces);
   verifyFormat("throw ( int32 ) x;", Spaces);
+  verifyFormat("SomeType *__attribute__( (attr) ) *a = NULL;", Spaces);
 
   // Run subset of tests again with:
   Spaces.SpacesInParensOptions.InCStyleCasts = false;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -217,6 +217,8 @@
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterIfMacros);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, AfterOverloadedOperator);
   CHECK_PARSE_NESTED_BOOL(SpaceBeforeParensOptions, BeforeNonEmptyParentheses);
+  CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InAttributeSpecifierLists);
+  CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InAttributeSpecifiers);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InCStyleCasts);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InConditionalStatements);
   CHECK_PARSE_NESTED_BOOL(SpacesInParensOptions, InEmptyParentheses);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3810,10 +3810,20 @@
   }
 
   if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) {
-return (Right.is(TT_CastRParen) ||
-(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
-   ? Style.SpacesInParensOptions.InCStyleCasts
-   : Style.SpacesInParensOptions.Other;
+if (Right.is(TT_CastRParen) ||
+(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) {
+  return Style.SpacesInParensOptions.InCStyleCasts;
+}
+if (Right.is(TT_AttributeParen) ||
+(Left.MatchingParen && Left.MatchingParen->is(TT_AttributeParen))) {
+  return Style.SpacesInParensOptions.InAttributeSpecifiers;
+}
+if ((Right.Next && Right.Next->is(TT_AttributeParen)) ||
+(Left.Previous && Left.Previous->MatchingParen &&
+ Left.Previous->MatchingParen->is(TT_AttributeParen))) {
+  return Style.SpacesInParensOptions.InAttributeSpecifierLists;
+}
+return Style.SpacesInParensOptions.Other;
   }
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
Index: clang/lib/Format/Format.cpp

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

2023-07-17 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D151683#4508209 , @MaskRay wrote:

> Reverse ping @philnik :)
>
> The `release/17.x` branch will be created soon 
> (https://discourse.llvm.org/t/llvm-17-0-0-release-planning-and-update/71762).

I know. I just didn't have the time yet. If you want to make sure it's in 17 
feel free to commandeer and fix the last bits.


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] D151047: [clang-format] Fix indent for selective formatting.

2023-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.

LGTM except for D151047#4508359 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D151047: [clang-format] Fix indent for selective formatting.

2023-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTestSelective.cpp:643-646
+  Style.FixNamespaceComments = false;
+  Code = "namespace ns {\n"
+ "#define REF(alias) alias alias_var;\n"
+ "}"; // Format this line only

Then I'd remove `Style.FixNamespaceComments` as a factor by formatting a 
non-brace line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D155506: [clang][JumpDiagnostics] use StmtClass rather than dyn_cast chain NFC

2023-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D155506#4508176 , @gribozavr2 
wrote:

> I'm not sure it is actually an anti-pattern. `dyn_cast` will transparently 
> handle subclasses, should any be added in the future, but a switch wouldn't.

Yeah, I don't think we have a strong style preference either way, here, given 
that this can't be an exhaustive switch anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155506

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


[PATCH] D155525: WIP

2023-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:362
 // it.  This makes the second scan not have to walk the AST again.
+RecordJumpScope:
 LabelAndGotoScopes[S] = ParentScope;

I would indent this at the same level as the `case` labels, and group it with 
them, too, but yeah, this is what I was thinking.  But the helper function 
approach looks pretty clean, too.  Your choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155525

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


[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked an inline comment as done.
ziqingluo-90 added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2346
+  // computed above.  We do not want to generate fix-its for such variables,
+  // since they are neither warned nor reachable from a warned one.
+  for (auto I = FixablesForAllVars.byVar.begin();

t-rasmud wrote:
> Nit: Maybe also mention when a variable is neither warned nor is reachable? 
> Are there scenarios besides variables inside pragmas where this constraint is 
> satisfied? 
good question!  I add some explanation in the comment.


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

https://reviews.llvm.org/D155524

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


[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 541279.

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

https://reviews.llvm.org/D155524

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
@@ -107,3 +107,128 @@
 
   p[5]; // not to note since the associated warning is suppressed
 }
+
+
+// Test suppressing interacts with variable grouping:
+
+// The implication edges are: `a` -> `b` -> `c`.
+// If the unsafe operation on `a` is supressed, none of the variables
+// will be fixed.
+void suppressedVarInGroup() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+#pragma clang unsafe_buffer_usage begin
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// To show that if `a[5]` is not suppressed in the
+// `suppressedVarInGroup` function above, all variables will be fixed.
+void suppressedVarInGroup_control() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `a` is not suppressed. Variable `b` will still be
+// fixed when fixing `a`.
+void suppressedVarInGroup2() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Only variable `c` will be fixed
+// then.
+void suppressedVarInGroup3() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c` -> `a`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Since the implication graph
+// forms a cycle, all variables will be fixed.
+void suppressedVarInGroup4() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+  c = a;
+}
+
+// There are two groups: `a` -> `b` -> `c` and `d` -> `e` -> `f`.
+// Suppressing unsafe operations on variables in one group does not
+// affect other groups.
+void suppressedVarInGroup5() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * d;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span d"
+  int * e;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span e"
+  int * f;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span f"
+
+#pragma clang unsafe_buffer_usage begin
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+  
+  d[5] = 5;
+  d = e;
+  e = f;
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1092,6 +1092,18 @@
 
   M.match(*D->getBody(), D->getASTContext());
 
+  // If no `WarningGadget`s ever matched, there is no unsafe operations in the
+  // function under the analysis.  Thus, there is nothing needs to be fixed.
+  //
+  // Note this claim is based on the assumption that there is no unsafe
+  // variable whose declaration is invisible from the analyzing function.
+  // Otherwise, we need to consider if the uses of those unsafe varuables needs
+  // fix.
+  // So far, we are not fixing any global 

[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 541269.

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

https://reviews.llvm.org/D155524

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
@@ -107,3 +107,128 @@
 
   p[5]; // not to note since the associated warning is suppressed
 }
+
+
+// Test suppressing interacts with variable grouping:
+
+// The implication edges are: `a` -> `b` -> `c`.
+// If the unsafe operation on `a` is supressed, none of the variables
+// will be fixed.
+void suppressedVarInGroup() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+#pragma clang unsafe_buffer_usage begin
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// To show that if `a[5]` is not suppressed in the
+// `suppressedVarInGroup` function above, all variables will be fixed.
+void suppressedVarInGroup_control() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `a` is not suppressed. Variable `b` will still be
+// fixed when fixing `a`.
+void suppressedVarInGroup2() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Only variable `c` will be fixed
+// then.
+void suppressedVarInGroup3() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c` -> `a`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Since the implication graph
+// forms a cycle, all variables will be fixed.
+void suppressedVarInGroup4() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+  c = a;
+}
+
+// There are two groups: `a` -> `b` -> `c` and `d` -> `e` -> `f`.
+// Suppressing unsafe operations on variables in one group does not
+// affect other groups.
+void suppressedVarInGroup5() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * d;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span d"
+  int * e;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span e"
+  int * f;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span f"
+
+#pragma clang unsafe_buffer_usage begin
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+  
+  d[5] = 5;
+  d = e;
+  e = f;
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -1092,6 +1092,18 @@
 
   M.match(*D->getBody(), D->getASTContext());
 
+  // If no `WarningGadget`s ever matched, there is no unsafe operations in the
+  // function under the analysis.  Thus, there is nothing needs to be fixed.
+  //
+  // Note this claim is based on the assumption that there is no unsafe
+  // variable whose declaration is invisible from the analyzing function.
+  // Otherwise, we need to consider if the uses of those unsafe varuables needs
+  // fix.
+  // So far, we are not fixing any global 

[PATCH] D146054: [RISCV] Add --print-supported-extensions support

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

Sorry for the delay.




Comment at: clang/include/clang/Frontend/FrontendOptions.h:286
 
+  /// print the supported extensions for the current target
+  unsigned PrintSupportedExtensions : 1;





Comment at: clang/include/clang/Frontend/FrontendOptions.h:290
+  /// Output time trace profile.
+  unsigned TimeTrace : 1;
+

stray change?



Comment at: clang/test/Driver/print-supported-extensions.c:6
+// RUN: %clang --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck --implicit-check-not=warning --strict-whitespace 
--match-full-lines %s
+





Comment at: clang/test/Driver/print-supported-extensions.c:10
+// CHECK:All available -march extensions for RISC-V
+// CHECK:  NameVersion
+// CHECK-NEXT: i   2.1

For `--strict-whitespace --match-full-lines` testing, we usually right align 
`CHECK` and `CHECK-NEXT`.



Comment at: clang/tools/driver/cc1_main.cpp:187
+/// Print supported extensions of the RISCV target.
+static int print_supported_extensions() {
+  llvm::riscvExtensionsHelp();

`printSupportedExtensions`. Why does this function return a dummy return value?

You can do `return printSupportedExtensions(), 0` below to save some lines.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:202
+void llvm::riscvExtensionsHelp() {
+  errs() << "All available -march extensions for RISC-V\n\n";
+  errs() << '\t' << left_justify("Name", 20) << "Version\n";

I think `outs()` is more conventional. Most `gcc --print-*` options go to 
stdout. `clang --print-supported-cpus` deviates and we should not copy its 
issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:361
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have

nickdesaulniers wrote:
> nickdesaulniers wrote:
> > rjmccall wrote:
> > > nickdesaulniers wrote:
> > > > rjmccall wrote:
> > > > > You can pull the `GCCAsmStmtClass` case right above this, make the 
> > > > > cast unconditional (`if (!cast(S)->isAsmGoto()) break;`), 
> > > > > and then fall through into the GotoStmt case.
> > > > I could hoist + use `[[fallthrough]]` but note that the case above 
> > > > `Stmt::SwitchStmtClass` also currently uses `[[fallthrough]]` here as 
> > > > well; so I would still need the `dyn_cast`.
> > > > 
> > > > With that in mind, do you still prefer the hoisting? I don't have a 
> > > > preference, but wanted to triple check that with you.
> > > Ah, right.  Personally, I would probably put this common path in a helper 
> > > function, but you could also just duplicate it since it's so small.  This 
> > > also seems like an acceptable use-case for `goto` if you can stomach that 
> > > — with a good label, it should still be very readable.
> > Is https://reviews.llvm.org/D155522 what you had in mind? If so, then I'll 
> > squash it into this, otherwise can you state differently what you had in 
> > mind?
> oh, rereading what you wrote, I think I understand what you mean with 
> `goto`s. Let me post a diff of that, for clarification.
https://reviews.llvm.org/D155525 perhaps?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[PATCH] D155525: WIP

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Alternate to D155522  based on
https://reviews.llvm.org/D155342#4507805


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155525

Files:
  clang/lib/Sema/JumpDiagnostics.cpp


Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -331,11 +331,8 @@
 // operand (to avoid recording the address-of-label use), which
 // works only because of the restricted set of expressions which
 // we detect as constant targets.
-if (cast(S)->getConstantTarget()) {
-  LabelAndGotoScopes[S] = ParentScope;
-  Jumps.push_back(S);
-  return;
-}
+if (cast(S)->getConstantTarget())
+  goto RecordJumpScope;
 
 LabelAndGotoScopes[S] = ParentScope;
 IndirectJumps.push_back(S);
@@ -352,15 +349,17 @@
   BuildScopeInformation(Var, ParentScope);
   ++StmtsToSkip;
 }
-[[fallthrough]];
+goto RecordJumpScope;
 
-  case Stmt::GotoStmtClass:
   case Stmt::GCCAsmStmtClass:
-if (auto *GS = dyn_cast(S))
-  if (!GS->isAsmGoto())
-break;
+if (!cast(S)->isAsmGoto())
+  break;
+goto RecordJumpScope;
+
+  case Stmt::GotoStmtClass:
 // Remember both what scope a goto is in as well as the fact that we have
 // it.  This makes the second scan not have to walk the AST again.
+RecordJumpScope:
 LabelAndGotoScopes[S] = ParentScope;
 Jumps.push_back(S);
 break;


Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -331,11 +331,8 @@
 // operand (to avoid recording the address-of-label use), which
 // works only because of the restricted set of expressions which
 // we detect as constant targets.
-if (cast(S)->getConstantTarget()) {
-  LabelAndGotoScopes[S] = ParentScope;
-  Jumps.push_back(S);
-  return;
-}
+if (cast(S)->getConstantTarget())
+  goto RecordJumpScope;
 
 LabelAndGotoScopes[S] = ParentScope;
 IndirectJumps.push_back(S);
@@ -352,15 +349,17 @@
   BuildScopeInformation(Var, ParentScope);
   ++StmtsToSkip;
 }
-[[fallthrough]];
+goto RecordJumpScope;
 
-  case Stmt::GotoStmtClass:
   case Stmt::GCCAsmStmtClass:
-if (auto *GS = dyn_cast(S))
-  if (!GS->isAsmGoto())
-break;
+if (!cast(S)->isAsmGoto())
+  break;
+goto RecordJumpScope;
+
+  case Stmt::GotoStmtClass:
 // Remember both what scope a goto is in as well as the fact that we have
 // it.  This makes the second scan not have to walk the AST again.
+RecordJumpScope:
 LabelAndGotoScopes[S] = ParentScope;
 Jumps.push_back(S);
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144829: [WIP][BPF] Add a few new insns under cpu=v4

2023-07-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 541265.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

- Dropping 'CPUv4' in some variable/function names and also in debug flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144829

Files:
  clang/lib/Basic/Targets/BPF.cpp
  clang/lib/Basic/Targets/BPF.h
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
  llvm/lib/Target/BPF/BPFISelLowering.cpp
  llvm/lib/Target/BPF/BPFISelLowering.h
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIPeephole.cpp
  llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp
  llvm/test/CodeGen/BPF/bswap.ll
  llvm/test/CodeGen/BPF/ldsx.ll
  llvm/test/CodeGen/BPF/movsx.ll
  llvm/test/CodeGen/BPF/sdiv_smod.ll

Index: llvm/test/CodeGen/BPF/sdiv_smod.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sdiv_smod.ll
@@ -0,0 +1,77 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;  int foo(int a, int b, int c) {
+;return a/b + a%c;
+;  }
+;  long bar(long a, long b, long c) {
+;   return a/b + a%c;
+; }
+; Compilation flags:
+;   clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes t.c
+
+; Function Attrs: nounwind
+define dso_local i32 @foo(i32 noundef %a, i32 noundef %b, i32 noundef %c) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  %c.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  store i32 %b, ptr %b.addr, align 4, !tbaa !3
+  store i32 %c, ptr %c.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %1 = load i32, ptr %b.addr, align 4, !tbaa !3
+  %div = sdiv i32 %0, %1
+  %2 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %3 = load i32, ptr %c.addr, align 4, !tbaa !3
+  %rem = srem i32 %2, %3
+  %add = add nsw i32 %div, %rem
+  ret i32 %add
+}
+
+; CHECK:   w0 = w1
+; CHECK-NEXT:  *(u32 *)(r10 - 8) = w2
+; CHECK-NEXT:  *(u32 *)(r10 - 4) = w0
+; CHECK-NEXT:  *(u32 *)(r10 - 12) = w3
+; CHECK-NEXT:  w1 s%= w3  # encoding: [0x9c,0x31,0x01,0x00,0x00,0x00,0x00,0x00]
+; CHECK-NEXT:  w0 s/= w2  # encoding: [0x3c,0x20,0x01,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @bar(i64 noundef %a, i64 noundef %b, i64 noundef %c) #0 {
+entry:
+  %a.addr = alloca i64, align 8
+  %b.addr = alloca i64, align 8
+  %c.addr = alloca i64, align 8
+  store i64 %a, ptr %a.addr, align 8, !tbaa !7
+  store i64 %b, ptr %b.addr, align 8, !tbaa !7
+  store i64 %c, ptr %c.addr, align 8, !tbaa !7
+  %0 = load i64, ptr %a.addr, align 8, !tbaa !7
+  %1 = load i64, ptr %b.addr, align 8, !tbaa !7
+  %div = sdiv i64 %0, %1
+  %2 = load i64, ptr %a.addr, align 8, !tbaa !7
+  %3 = load i64, ptr %c.addr, align 8, !tbaa !7
+  %rem = srem i64 %2, %3
+  %add = add nsw i64 %div, %rem
+  ret i64 %add
+}
+
+; CHECK:   r0 = r1
+; CHECK-NEXT:  *(u64 *)(r10 - 16) = r2
+; CHECK-NEXT:  *(u64 *)(r10 - 8) = r0
+; CHECK-NEXT:  *(u64 *)(r10 - 24) = r3
+; CHECK-NEXT:  r1 s%= r3  # encoding: [0x9f,0x31,0x01,0x00,0x00,0x00,0x00,0x00]
+; CHECK-NEXT:  r0 s/= r2  # encoding: [0x3f,0x20,0x01,0x00,0x00,0x00,0x00,0x00]
+
+attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"frame-pointer", i32 2}
+!2 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 569bd3b841e3167ddd7c6ceeddb282d3c280e761)"}
+!3 = !{!4, !4, i64 0}
+!4 = !{!"int", !5, i64 0}
+!5 = !{!"omnipotent char", !6, i64 0}
+!6 = !{!"Simple C/C++ TBAA"}
+!7 = !{!8, !8, i64 0}
+!8 = !{!"long", !5, i64 0}
Index: llvm/test/CodeGen/BPF/movsx.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/movsx.ll
@@ -0,0 +1,79 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;   short f1(char a) {
+; return a;
+;   }
+;   int f2(char a) {
+; return a;
+;   }
+;   long f3(char a) {
+; return a;
+;   }
+;   int f4(short a) {
+; return a;
+;   }
+;   long f5(short a) {
+; return a;
+;   }
+;   long f6(int a) {
+; return a;
+;   }
+; Compilation flags:
+;   clang -target bpf -O2 -S -emit-llvm t.c
+
+; Function 

[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud accepted this revision.
t-rasmud added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2346
+  // computed above.  We do not want to generate fix-its for such variables,
+  // since they are neither warned nor reachable from a warned one.
+  for (auto I = FixablesForAllVars.byVar.begin();

Nit: Maybe also mention when a variable is neither warned nor is reachable? Are 
there scenarios besides variables inside pragmas where this constraint is 
satisfied? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155524

___
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-07-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Reverse ping @philnik :)

The `release/17.x` branch will be created soon 
(https://discourse.llvm.org/t/llvm-17-0-0-release-planning-and-update/71762).


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] D155509: Revert "Remove rdar links; NFC"

2023-07-17 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar 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/D155509/new/

https://reviews.llvm.org/D155509

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


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-07-17 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: 
libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp:27
   static_assert(!std::is_constant_evaluated(), "");
-  // expected-warning@-1 0-1 {{'std::is_constant_evaluated' will always 
evaluate to 'true' in a manifestly constant-evaluated expression}}
+  // expected-warning@-1 0-1 {{'std::is_constant_evaluated' will always 
evaluate to true in this context}}
 #endif

philnik wrote:
> cor3ntin wrote:
> > Mordante wrote:
> > > hazohelet wrote:
> > > > philnik wrote:
> > > > > Mordante wrote:
> > > > > > Since libc++ support the latest ToT Clang and the last two official 
> > > > > > releases this wont work. The `expected-warning` needs to be a 
> > > > > > `expected-warning-re` that works for both the new and old diagnostic
> > > > > You can also just shorten it to `'std::is_constant_evaluated' will 
> > > > > always evaluate to`. Seems good enough to me.
> > > > Thanks!
> > > I really would like a regex. To me the current message misses an 
> > > important piece of information; the `true` part. I care less about the 
> > > rest of the message, but stripping the `true` means a warning like 
> > > `std::is_constant_evaluated' will always evaluate to FALSE` would be 
> > > valid too.
> > Agreed with Mordante
> We're not in the business of testing the compiler though. Taking a closer 
> look, I'm not actually sure why this test exists at all. It doesn't seem like 
> it tests anything useful w.r.t. the library. This has been added in 2fc5a78, 
> but there the warning isn't checked, so that was clearly not the original 
> intention.
FWIW I agree, in fact I think we could probably use `// 
ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=warning`


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

https://reviews.llvm.org/D155064

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


[PATCH] D155339: Enable zba and zbs for RISCV64 Android

2023-07-17 Thread 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 rGf7623f4f692d: Enable zba and zbs for RISCV64 Android 
(authored by AdityaK 1894981+hiradi...@users.noreply.github.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155339

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -10,7 +10,9 @@
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck 
%s -check-prefix=RELAX
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mno-relax 2>&1 | 
FileCheck %s -check-prefix=NO-RELAX
 
+// ANDROID: "-target-feature" "+zba"
 // ANDROID: "-target-feature" "+zbb"
+// ANDROID: "-target-feature" "+zbs"
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -294,7 +294,7 @@
   return "rv32imafdc";
 else if (MABI.starts_with_insensitive("lp64")) {
   if (Triple.isAndroid())
-return "rv64imafdc_zbb";
+return "rv64imafdc_zba_zbb_zbs";
 
   return "rv64imafdc";
 }
@@ -314,7 +314,7 @@
 if (Triple.getOS() == llvm::Triple::UnknownOS)
   return "rv64imac";
 else if (Triple.isAndroid())
-  return "rv64imafdc_zbb";
+  return "rv64imafdc_zba_zbb_zbs";
 else
   return "rv64imafdc";
   }


Index: clang/test/Driver/riscv-features.c
===
--- clang/test/Driver/riscv-features.c
+++ clang/test/Driver/riscv-features.c
@@ -10,7 +10,9 @@
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck %s -check-prefix=RELAX
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mno-relax 2>&1 | FileCheck %s -check-prefix=NO-RELAX
 
+// ANDROID: "-target-feature" "+zba"
 // ANDROID: "-target-feature" "+zbb"
+// ANDROID: "-target-feature" "+zbs"
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -294,7 +294,7 @@
   return "rv32imafdc";
 else if (MABI.starts_with_insensitive("lp64")) {
   if (Triple.isAndroid())
-return "rv64imafdc_zbb";
+return "rv64imafdc_zba_zbb_zbs";
 
   return "rv64imafdc";
 }
@@ -314,7 +314,7 @@
 if (Triple.getOS() == llvm::Triple::UnknownOS)
   return "rv64imac";
 else if (Triple.isAndroid())
-  return "rv64imafdc_zbb";
+  return "rv64imafdc_zba_zbb_zbs";
 else
   return "rv64imafdc";
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f7623f4 - Enable zba and zbs for RISCV64 Android

2023-07-17 Thread via cfe-commits

Author: AdityaK
Date: 2023-07-17T16:16:13-07:00
New Revision: f7623f4f692d10ef0f764876d670968cba3c9981

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

LOG: Enable zba and zbs for RISCV64 Android

Reviewers: enh, pirama, srhines, asb

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 1c342d5765bfbc..17e1aab961e5a8 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -294,7 +294,7 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList 
,
   return "rv32imafdc";
 else if (MABI.starts_with_insensitive("lp64")) {
   if (Triple.isAndroid())
-return "rv64imafdc_zbb";
+return "rv64imafdc_zba_zbb_zbs";
 
   return "rv64imafdc";
 }
@@ -314,7 +314,7 @@ StringRef riscv::getRISCVArch(const llvm::opt::ArgList 
,
 if (Triple.getOS() == llvm::Triple::UnknownOS)
   return "rv64imac";
 else if (Triple.isAndroid())
-  return "rv64imafdc_zbb";
+  return "rv64imafdc_zba_zbb_zbs";
 else
   return "rv64imafdc";
   }

diff  --git a/clang/test/Driver/riscv-features.c 
b/clang/test/Driver/riscv-features.c
index 78d3b2d3baecf9..f67dd3d46402ba 100644
--- a/clang/test/Driver/riscv-features.c
+++ b/clang/test/Driver/riscv-features.c
@@ -10,7 +10,9 @@
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mrelax 2>&1 | FileCheck 
%s -check-prefix=RELAX
 // RUN: %clang --target=riscv32-unknown-elf -### %s -mno-relax 2>&1 | 
FileCheck %s -check-prefix=NO-RELAX
 
+// ANDROID: "-target-feature" "+zba"
 // ANDROID: "-target-feature" "+zbb"
+// ANDROID: "-target-feature" "+zbs"
 // RELAX: "-target-feature" "+relax"
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT: "-target-feature" "+relax"



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


[PATCH] D155506: [clang][JumpDiagnostics] use StmtClass rather than dyn_cast chain NFC

2023-07-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

I'm not sure it is actually an anti-pattern. `dyn_cast` will transparently 
handle subclasses, should any be added in the future, but a switch wouldn't.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155506

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I do like the look of https://reviews.llvm.org/D155522, yeah, since we have so 
many of these that aren't top-level in a case anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[PATCH] D155387: [Clang] Fix member lookup so that we don't ignore ambiguous lookups in some cases

2023-07-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked an inline comment as done.
shafik added inline comments.



Comment at: clang/include/clang/Sema/Lookup.h:197-200
+DiagnoseAccess(std::move(Other.DiagnoseAccess)),
+DiagnoseAmbiguous(std::move(Other.DiagnoseAmbiguous)),
 AllowHidden(std::move(Other.AllowHidden)),
 Shadowed(std::move(Other.Shadowed)),

cor3ntin wrote:
> these std::move are a bit superfluous :)
Yeah, I was just keeping consistent. I don't think they are doing any harm in 
this case.


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

https://reviews.llvm.org/D155387

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:361
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have

nickdesaulniers wrote:
> rjmccall wrote:
> > nickdesaulniers wrote:
> > > rjmccall wrote:
> > > > You can pull the `GCCAsmStmtClass` case right above this, make the cast 
> > > > unconditional (`if (!cast(S)->isAsmGoto()) break;`), and 
> > > > then fall through into the GotoStmt case.
> > > I could hoist + use `[[fallthrough]]` but note that the case above 
> > > `Stmt::SwitchStmtClass` also currently uses `[[fallthrough]]` here as 
> > > well; so I would still need the `dyn_cast`.
> > > 
> > > With that in mind, do you still prefer the hoisting? I don't have a 
> > > preference, but wanted to triple check that with you.
> > Ah, right.  Personally, I would probably put this common path in a helper 
> > function, but you could also just duplicate it since it's so small.  This 
> > also seems like an acceptable use-case for `goto` if you can stomach that — 
> > with a good label, it should still be very readable.
> Is https://reviews.llvm.org/D155522 what you had in mind? If so, then I'll 
> squash it into this, otherwise can you state differently what you had in mind?
oh, rereading what you wrote, I think I understand what you mean with `goto`s. 
Let me post a diff of that, for clarification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[PATCH] D155524: [-Wunsafe-buffer-usage] Ignore the FixableGadgets that will not be fixed at an earlier stage

2023-07-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

When some unsafe operations are suppressed,   there will be (non-strictly) 
fewer variables being warned about.   `FixableGadget`s  associated with the 
suppressed variables will not be fixed.  
Removing these `FixableGadget` as early as possible could help improve the 
performance and stability of the analysis.

The variable grouping algorithm introduced in D145739 
 nearly completes this task.  
For a variable that is neither warned about nor reachable from a warned 
variable, it does not exist in the graph computed by the algorithm. 
So this patch simply removes `FixableGadget`s whose variables are not present 
in the graph computed for variable grouping.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155524

Files:
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-pragma-fixit.cpp
@@ -107,3 +107,128 @@
 
   p[5]; // not to note since the associated warning is suppressed
 }
+
+
+// Test suppressing interacts with variable grouping:
+
+// The implication edges are: `a` -> `b` -> `c`.
+// If the unsafe operation on `a` is supressed, none of the variables
+// will be fixed.
+void suppressedVarInGroup() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+
+#pragma clang unsafe_buffer_usage begin
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// To show that if `a[5]` is not suppressed in the
+// `suppressedVarInGroup` function above, all variables will be fixed.
+void suppressedVarInGroup_control() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `a` is not suppressed. Variable `b` will still be
+// fixed when fixing `a`.
+void suppressedVarInGroup2() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  a[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Only variable `c` will be fixed
+// then.
+void suppressedVarInGroup3() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+}
+
+// The implication edges are: `a` -> `b` -> `c` -> `a`.
+// The unsafe operation on `b` is supressed, while the unsafe
+// operation on `c` is not suppressed. Since the implication graph
+// forms a cycle, all variables will be fixed.
+void suppressedVarInGroup4() {
+  int * a;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span a"
+  int * b;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span b"
+  int * c;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span c"
+
+  c[5] = 5;
+#pragma clang unsafe_buffer_usage begin
+  b[5] = 5;
+#pragma clang unsafe_buffer_usage end
+  a = b;
+  b = c;
+  c = a;
+}
+
+// There are two groups: `a` -> `b` -> `c` and `d` -> `e` -> `f`.
+// Suppressing unsafe operations on variables in one group does not
+// affect other groups.
+void suppressedVarInGroup5() {
+  int * a;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * b;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * c;
+  // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:
+  int * d;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span d"
+  int * e;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span e"
+  int * f;
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"std::span f"
+

[PATCH] D155523: [clang] Fix a crash when casting to an array type

2023-07-17 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao created this revision.
ayzhao added a reviewer: aaron.ballman.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In C++20, if Clang fails to perform constructor overload on a
RecordType, then Clang will try to perform parentesized aggregate
initialization. If that fails and the initialization was attempted as
part of a cast, then we should get the diagnostics from the failed
constructor overload attempt. However, we don't attempt constructor
overloading for arrays, so previously, if we try to diagnose an
overloaded cast for a parenthesized aggregate initialization of an
array, we crash. To fix this, we now exit tryDiagnoseOverloadedCast(...)
for failed parentesized list initialization if the destination type is
an array.

Fixes #63758


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155523

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaCast.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -294,3 +294,8 @@
 }
 
 }
+
+namespace gh63758 {
+  struct S {} s;
+  auto words = (char[])s; // expected-error {{C-style cast from 'struct S' to 
'char[]' is not allowed}}
+};
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -454,9 +454,18 @@
   switch (sequence.getFailureKind()) {
   default: return false;
 
+  case InitializationSequence::FK_ParenthesizedListInitFailed:
+// In C++20, if the underlying destination type is a RecordType, then we
+// attempt to perform parentesized aggregate initialization if constructor
+// overload fails. If that fails, then we'll generate the diagnostics from
+// the failed overload result from the previous constructor overload. Array
+// initialization, however, is not done after attempting constructor
+// overloading, so we bail out as there won't be a failed overload result.
+if (destType->isArrayType())
+  return false;
+break;
   case InitializationSequence::FK_ConstructorOverloadFailed:
   case InitializationSequence::FK_UserConversionOverloadFailed:
-  case InitializationSequence::FK_ParenthesizedListInitFailed:
 break;
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -634,6 +634,8 @@
   that construct (`#62133 
_`).
 - Fix crash caused by PseudoObjectExprBitfields: NumSubExprs overflow.
   (`#63169 _`)
+- Fix crash when casting an object to an array type.
+  (`#63758 _`)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -294,3 +294,8 @@
 }
 
 }
+
+namespace gh63758 {
+  struct S {} s;
+  auto words = (char[])s; // expected-error {{C-style cast from 'struct S' to 'char[]' is not allowed}}
+};
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -454,9 +454,18 @@
   switch (sequence.getFailureKind()) {
   default: return false;
 
+  case InitializationSequence::FK_ParenthesizedListInitFailed:
+// In C++20, if the underlying destination type is a RecordType, then we
+// attempt to perform parentesized aggregate initialization if constructor
+// overload fails. If that fails, then we'll generate the diagnostics from
+// the failed overload result from the previous constructor overload. Array
+// initialization, however, is not done after attempting constructor
+// overloading, so we bail out as there won't be a failed overload result.
+if (destType->isArrayType())
+  return false;
+break;
   case InitializationSequence::FK_ConstructorOverloadFailed:
   case InitializationSequence::FK_UserConversionOverloadFailed:
-  case InitializationSequence::FK_ParenthesizedListInitFailed:
 break;
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -634,6 +634,8 @@
   that construct (`#62133 _`).
 - Fix crash caused by PseudoObjectExprBitfields: NumSubExprs overflow.
   (`#63169 _`)
+- Fix crash when casting an object 

[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:361
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have

rjmccall wrote:
> nickdesaulniers wrote:
> > rjmccall wrote:
> > > You can pull the `GCCAsmStmtClass` case right above this, make the cast 
> > > unconditional (`if (!cast(S)->isAsmGoto()) break;`), and then 
> > > fall through into the GotoStmt case.
> > I could hoist + use `[[fallthrough]]` but note that the case above 
> > `Stmt::SwitchStmtClass` also currently uses `[[fallthrough]]` here as well; 
> > so I would still need the `dyn_cast`.
> > 
> > With that in mind, do you still prefer the hoisting? I don't have a 
> > preference, but wanted to triple check that with you.
> Ah, right.  Personally, I would probably put this common path in a helper 
> function, but you could also just duplicate it since it's so small.  This 
> also seems like an acceptable use-case for `goto` if you can stomach that — 
> with a good label, it should still be very readable.
Is https://reviews.llvm.org/D155522 what you had in mind? If so, then I'll 
squash it into this, otherwise can you state differently what you had in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[PATCH] D155522: [clang][JumpDiagnostics] refactor helper

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

Posting to phab for separate review from
https://reviews.llvm.org/D155342#4507805

Will squash this into D155342  if it's the 
intended change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155522

Files:
  clang/lib/Sema/JumpDiagnostics.cpp

Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -73,7 +73,7 @@
 
   SmallVector IndirectJumps;
   SmallVector IndirectJumpTargets;
-  SmallVector MustTailStmts;
+  SmallVector MustTailStmts;
 
 public:
   JumpScopeChecker(Stmt *Body, Sema );
@@ -97,6 +97,7 @@
   const Attr *GetMustTailAttr(AttributedStmt *AS);
 
   unsigned GetDeepestCommonScope(unsigned A, unsigned B);
+  void RecordJumpScope(Stmt *S, unsigned Scope, SmallVectorImpl *Jumps);
 };
 } // end anonymous namespace
 
@@ -325,21 +326,19 @@
 return;
   }
 
-  case Stmt::IndirectGotoStmtClass:
+  case Stmt::IndirectGotoStmtClass: {
 // "goto *&" is a special case which we treat as equivalent
 // to a normal goto.  In addition, we don't calculate scope in the
 // operand (to avoid recording the address-of-label use), which
 // works only because of the restricted set of expressions which
 // we detect as constant targets.
-if (cast(S)->getConstantTarget()) {
-  LabelAndGotoScopes[S] = ParentScope;
-  Jumps.push_back(S);
-  return;
-}
-
-LabelAndGotoScopes[S] = ParentScope;
-IndirectJumps.push_back(S);
+bool isConst = cast(S)->getConstantTarget();
+if (isConst)
+  RecordJumpScope(S, ParentScope, );
+else
+  RecordJumpScope(S, ParentScope, );
 break;
+  }
 
   case Stmt::SwitchStmtClass:
 // Evaluate the C++17 init stmt and condition variable
@@ -352,17 +351,18 @@
   BuildScopeInformation(Var, ParentScope);
   ++StmtsToSkip;
 }
-[[fallthrough]];
+RecordJumpScope(S, ParentScope, );
+break;
 
   case Stmt::GotoStmtClass:
-  case Stmt::GCCAsmStmtClass:
-if (auto *GS = dyn_cast(S))
-  if (!GS->isAsmGoto())
-break;
 // Remember both what scope a goto is in as well as the fact that we have
 // it.  This makes the second scan not have to walk the AST again.
-LabelAndGotoScopes[S] = ParentScope;
-Jumps.push_back(S);
+RecordJumpScope(S, ParentScope, );
+break;
+
+  case Stmt::GCCAsmStmtClass:
+if (cast(S)->isAsmGoto())
+  RecordJumpScope(S, ParentScope, );
 break;
 
   case Stmt::IfStmtClass: {
@@ -584,14 +584,10 @@
 LabelAndGotoScopes[S] = ParentScope;
 break;
 
-  case Stmt::AttributedStmtClass: {
-AttributedStmt *AS = cast(S);
-if (GetMustTailAttr(AS)) {
-  LabelAndGotoScopes[AS] = ParentScope;
-  MustTailStmts.push_back(AS);
-}
+  case Stmt::AttributedStmtClass:
+if (GetMustTailAttr(cast(S)))
+  RecordJumpScope(S, ParentScope, );
 break;
-  }
 
   default:
 if (auto *ED = dyn_cast(S)) {
@@ -986,7 +982,7 @@
 }
 
 void JumpScopeChecker::VerifyMustTailStmts() {
-  for (AttributedStmt *AS : MustTailStmts) {
+  for (Stmt *AS : MustTailStmts) {
 for (unsigned I = LabelAndGotoScopes[AS]; I; I = Scopes[I].ParentScope) {
   if (Scopes[I].OutDiag) {
 S.Diag(AS->getBeginLoc(), diag::err_musttail_scope);
@@ -1003,6 +999,12 @@
   return Iter != Attrs.end() ? *Iter : nullptr;
 }
 
+void JumpScopeChecker::RecordJumpScope(Stmt *S, unsigned Scope,
+   SmallVectorImpl *Jumps) {
+  LabelAndGotoScopes[S] = Scope;
+  Jumps->push_back(S);
+}
+
 void Sema::DiagnoseInvalidJumps(Stmt *Body) {
   (void)JumpScopeChecker(Body, *this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155339: Enable zba and zbs for RISCV64 Android

2023-07-17 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: clang/test/Driver/riscv-features.c:13
 
+// ANDROID: "-target-feature" "+zba"
 // ANDROID: "-target-feature" "+zbb"

MaskRay wrote:
> If the features are adjacent, test them on one line. `// ANDROID: 
> "-target-feature" "+zba" "-target-feature" "+zbb" ...`
that's a neat trick. it might work for zba, and zbb. But it could break for zbs 
if something else comes in between. that will make this test dependent on how 
flags are sorted internally. probably not worth micro-optimizing for this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155339

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


[PATCH] D155270: [clang][Interp] Basic support for bit fields

2023-07-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/AST/Interp/bitfields.cpp:36
+  // TODO: +=, -=, etc. operators.
+}

This is an interesting test case:

```
struct A {int c:3;};

constexpr int f() {
  A a1{3};
  return a1.c++;
}

void g() {
constexpr int x = f();
}
```

We are overflowing the bit-field value but it is implementation defined what 
the value is  CC @aaron.ballman 

Might be worth checking the result of conditional operator and comma etc are 
bit-fields when they are supposed to be and therefore sizeof fails for those 
cases. 


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

https://reviews.llvm.org/D155270

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


[PATCH] D155383: [clang][AST] TextNodeDumper learned to output exception specifications

2023-07-17 Thread Timo Stripf via Phabricator via cfe-commits
strimo378 added a comment.

There are many ast-dump tests about decls but there are nearly no other type 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155383

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


[PATCH] D155501: Add new option -fkeep-persistent-storage-variables to Clang release notes

2023-07-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:259-260
+- ``-fkeep-persistent-storage-variables`` has been implemented to keep all
+  variables that have a persistent storage duration, including global, static
+  and thread-local variables, to guarantee that they can be directly addressed.
 

Suggestion: Use em dashes to avoid overuse of commas.

Additionally, I am wondering if the release notes is a reasonable place to add 
something like: Since this inhibits the merging of the affected variables, the 
number of individual relocations in the program will generally increase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155501

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:361
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have

nickdesaulniers wrote:
> rjmccall wrote:
> > You can pull the `GCCAsmStmtClass` case right above this, make the cast 
> > unconditional (`if (!cast(S)->isAsmGoto()) break;`), and then 
> > fall through into the GotoStmt case.
> I could hoist + use `[[fallthrough]]` but note that the case above 
> `Stmt::SwitchStmtClass` also currently uses `[[fallthrough]]` here as well; 
> so I would still need the `dyn_cast`.
> 
> With that in mind, do you still prefer the hoisting? I don't have a 
> preference, but wanted to triple check that with you.
Ah, right.  Personally, I would probably put this common path in a helper 
function, but you could also just duplicate it since it's so small.  This also 
seems like an acceptable use-case for `goto` if you can stomach that — with a 
good label, it should still be very readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[clang] 6c30b78 - Reland "[PS4/PS5] Tidy up driver warnings finding the SDK"

2023-07-17 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2023-07-17T13:57:08-07:00
New Revision: 6c30b7886919eb19289f5ed9216e72de9700c9fb

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

LOG: Reland "[PS4/PS5] Tidy up driver warnings finding the SDK"

Instead of warning possibly up to 3 times about the same problem,
warn only about the actual missing directories.

This reverts commit 9b3323d39f635db870de958f067c672f54d7b192.

The warning will stay DefaultIgnore upstream, because a variety of
tests aren't expecting it and updating the tests isn't worth the
effort.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/frame-pointer-elim.c
clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index d10262826bf292..1b69324d073ab5 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -575,17 +575,13 @@ def 
err_drv_unsupported_fpatchable_function_entry_argument : Error<
   "the second argument of '-fpatchable-function-entry' must be smaller than 
the first argument">;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
-  "unable to find %0 directory, expected to be in '%1'">,
+  "unable to find %0 directory, expected to be in '%1' found via %2">,
   InGroup, DefaultIgnore;
 
 def warn_drv_ps_force_pic : Warning<
   "option '%0' was ignored by the %1 toolchain, using '-fPIC'">,
   InGroup;
 
-def warn_drv_ps_sdk_dir : Warning<
-  "environment variable '%0' is set, but points to invalid or nonexistent 
directory '%1'">,
-  InGroup;
-
 def err_drv_defsym_invalid_format : Error<"defsym must be of the form: 
sym=value: %0">;
 def err_drv_defsym_invalid_symval : Error<"value is not an integer: %0">;
 def warn_drv_msvc_not_found : Warning<

diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 37006dc5d7ed8b..2f43d33bf0f1c8 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -256,30 +256,23 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver , const 
llvm::Triple ,
 D.Diag(clang::diag::err_drv_unsupported_opt_for_target)
 << "-static" << Platform;
 
-  // Determine where to find the PS4/PS5 libraries. We use the EnvVar
-  // if it exists; otherwise use the driver's installation path, which
-  // should be /host_tools/bin.
-
-  SmallString<512> SDKDir;
-  if (const char *EnvValue = getenv(EnvVar)) {
-if (!llvm::sys::fs::exists(EnvValue))
-  D.Diag(clang::diag::warn_drv_ps_sdk_dir) << EnvVar << EnvValue;
-SDKDir = EnvValue;
-  } else {
-SDKDir = D.Dir;
-llvm::sys::path::append(SDKDir, "/../../");
-  }
-
-  // By default, the driver won't report a warning if it can't find the
-  // SDK include or lib directories. This behavior could be changed if
-  // -Weverything or -Winvalid-or-nonexistent-directory options are passed.
+  // Determine where to find the PS4/PS5 libraries.
   // If -isysroot was passed, use that as the SDK base path.
+  // If not, we use the EnvVar if it exists; otherwise use the driver's
+  // installation path, which should be /host_tools/bin.
+  SmallString<80> Whence;
   if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
 SDKRootDir = A->getValue();
 if (!llvm::sys::fs::exists(SDKRootDir))
   D.Diag(clang::diag::warn_missing_sysroot) << SDKRootDir;
-  } else
-SDKRootDir = std::string(SDKDir.str());
+Whence = A->getSpelling();
+  } else if (const char *EnvValue = getenv(EnvVar)) {
+SDKRootDir = EnvValue;
+Whence = { "environment variable '", EnvVar, "'" };
+  } else {
+SDKRootDir = D.Dir + "/../../";
+Whence = "compiler's location";
+  }
 
   SmallString<512> SDKIncludeDir(SDKRootDir);
   llvm::sys::path::append(SDKIncludeDir, "target/include");
@@ -289,7 +282,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver , const 
llvm::Triple ,
   !Args.hasArg(options::OPT__sysroot_EQ) &&
   !llvm::sys::fs::exists(SDKIncludeDir)) {
 D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
-<< Twine(Platform, " system headers").str() << SDKIncludeDir;
+<< Twine(Platform, " system headers").str() << SDKIncludeDir << Whence;
   }
 
   SmallString<512> SDKLibDir(SDKRootDir);
@@ -301,7 +294,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver , const 
llvm::Triple ,
   !Args.hasArg(options::OPT_emit_ast) &&
   !llvm::sys::fs::exists(SDKLibDir)) {
 D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
-<< Twine(Platform, " system libraries").str() << SDKLibDir;
+<< 

[PATCH] D150320: [clang][modules][deps] Avoid checks for relocated modules

2023-07-17 Thread Jan Svoboda 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 rG227f71995804: [clang][modules][deps] Avoid checks for 
relocated modules (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150320

Files:
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/test/ClangScanDeps/header-search-pruning-transitive.c

Index: clang/test/ClangScanDeps/header-search-pruning-transitive.c
===
--- clang/test/ClangScanDeps/header-search-pruning-transitive.c
+++ clang/test/ClangScanDeps/header-search-pruning-transitive.c
@@ -72,8 +72,8 @@
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_X:.*]]",
 // CHECK-NEXT:   "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/./X.h",
-// CHECK-NEXT: "[[PREFIX]]/./module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/X.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "name": "X"
 // CHECK-NEXT: },
@@ -84,11 +84,11 @@
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_Y_WITH_A]]",
 // CHECK-NEXT:   "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/./Y.h",
-// CHECK-NEXT: "[[PREFIX]]/./a/a.h",
-// CHECK-NEXT: "[[PREFIX]]/./begin/begin.h",
-// CHECK-NEXT: "[[PREFIX]]/./end/end.h",
-// CHECK-NEXT: "[[PREFIX]]/./module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Y.h",
+// CHECK-NEXT: "[[PREFIX]]/a/a.h",
+// CHECK-NEXT: "[[PREFIX]]/begin/begin.h",
+// CHECK-NEXT: "[[PREFIX]]/end/end.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "name": "Y"
 // CHECK-NEXT: }
@@ -126,8 +126,8 @@
 // also has a different context hash from the first version of module X.
 // CHECK-NOT:"context-hash": "[[HASH_X]]",
 // CHECK:"file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/./X.h",
-// CHECK-NEXT: "[[PREFIX]]/./module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/X.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "name": "X"
 // CHECK-NEXT: },
@@ -138,10 +138,10 @@
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_Y_WITHOUT_A]]",
 // CHECK-NEXT:   "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/./Y.h",
-// CHECK-NEXT: "[[PREFIX]]/./begin/begin.h",
-// CHECK-NEXT: "[[PREFIX]]/./end/end.h",
-// CHECK-NEXT: "[[PREFIX]]/./module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/Y.h",
+// CHECK-NEXT: "[[PREFIX]]/begin/begin.h",
+// CHECK-NEXT: "[[PREFIX]]/end/end.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "name": "Y"
 // CHECK-NEXT: }
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -253,6 +253,9 @@
 // context hashing.
 ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
 
+// Avoid some checks and module map parsing when loading PCM files.
+ScanInstance.getPreprocessorOpts().ModulesCheckRelocated = false;
+
 std::unique_ptr Action;
 
 if (ModuleName)
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2990,6 +2990,9 @@
   BaseDirectoryAsWritten = Blob;
   assert(!F.ModuleName.empty() &&
  "MODULE_DIRECTORY found before MODULE_NAME");
+  F.BaseDirectory = std::string(Blob);
+  if (!PP.getPreprocessorOpts().ModulesCheckRelocated)
+break;
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
   Module *M = PP.getHeaderSearchInfo().lookupModule(
@@ -3011,8 +3014,6 @@
   }
 }
 F.BaseDirectory = std::string(M->Directory->getName());
-  } else {
-F.BaseDirectory = std::string(Blob);
   }
   break;
 }
@@ -3990,7 +3991,8 @@
   // usable header search context.
   assert(!F.ModuleName.empty() &&
  "MODULE_NAME should come before MODULE_MAP_FILE");
-  if (F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
+  if (PP.getPreprocessorOpts().ModulesCheckRelocated &&
+  F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
 // An implicitly-loaded module file should 

[PATCH] D150479: [clang][modules] Skip submodule & framework re-definitions in module maps

2023-07-17 Thread Jan Svoboda 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 rGdba2b5c9314e: [clang][modules] Skip submodule  
framework re-definitions in module maps (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150479

Files:
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/no-check-relocated-fw-private-sub.c
  clang/test/Modules/shadow-framework.m


Index: clang/test/Modules/shadow-framework.m
===
--- /dev/null
+++ clang/test/Modules/shadow-framework.m
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// This test checks that redefinitions of frameworks are ignored.
+
+//--- include/module.modulemap
+module first { header "first.h" }
+module FW {}
+//--- include/first.h
+
+//--- frameworks/FW.framework/Modules/module.modulemap
+framework module FW { header "FW.h" }
+//--- frameworks/FW.framework/Headers/FW.h
+
+//--- tu.c
+#import "first.h" // expected-remark {{importing module 'first'}}
+#import 
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fimplicit-module-maps \
+// RUN:   -I %t/include -F %t/frameworks -fsyntax-only %t/tu.c -Rmodule-import 
-verify
Index: clang/test/Modules/no-check-relocated-fw-private-sub.c
===
--- /dev/null
+++ clang/test/Modules/no-check-relocated-fw-private-sub.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- frameworks1/FW1.framework/Modules/module.modulemap
+framework module FW1 { header "FW1.h" }
+//--- frameworks1/FW1.framework/Headers/FW1.h
+#import 
+
+//--- frameworks2/FW2.framework/Modules/module.modulemap
+framework module FW2 { header "FW2.h" }
+//--- frameworks2/FW2.framework/Modules/module.private.modulemap
+framework module FW2.Private { header "FW2_Private.h" }
+//--- frameworks2/FW2.framework/Headers/FW2.h
+//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
+
+//--- tu.c
+#import  // expected-remark{{importing module 'FW1'}} \
+// expected-remark{{importing module 'FW2'}}
+#import  // expected-remark{{importing module 'FW2'}}
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fimplicit-module-maps \
+// RUN:   -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
+// RUN:   -fno-modules-check-relocated -Rmodule-import -verify
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -2016,12 +2016,28 @@
   Module *ShadowingModule = nullptr;
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
 // We might see a (re)definition of a module that we already have a
-// definition for in three cases:
+// definition for in four cases:
 //  - If we loaded one definition from an AST file and we've just found a
 //corresponding definition in a module map file, or
 bool LoadedFromASTFile = Existing->IsFromModuleFile;
 //  - If we previously inferred this module from different module map file.
 bool Inferred = Existing->IsInferred;
+//  - If we're building a framework that vends a module map, we might've
+//previously seen the one in intermediate products and now the system
+//one.
+// FIXME: If we're parsing module map file that looks like this:
+//  framework module FW { ... }
+//  module FW.Sub { ... }
+//We can't check the framework qualifier, since it's not attached 
to
+//the definition of Sub. Checking that qualifier on \c Existing is
+//not correct either, since we might've previously seen:
+//  module FW { ... }
+//  module FW.Sub { ... }
+//We should enforce consistency of redefinitions so that we can 
rely
+//that \c Existing is part of a framework iff the redefinition of 
FW
+//we have just skipped had it too. Once we do that, stop checking
+//the local framework qualifier and only rely on \c Existing.
+bool PartOfFramework = Framework || Existing->isPartOfFramework();
 //  - If we're building a (preprocessed) module and we've just loaded the
 //module map file from which it was created.
 bool ParsedAsMainInput =
@@ -2029,7 +2045,8 @@
 Map.LangOpts.CurrentModule == ModuleName &&
 SourceMgr.getDecomposedLoc(ModuleNameLoc).first !=
 SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first;
-if (!ActiveModule && (LoadedFromASTFile || Inferred || ParsedAsMainInput)) 
{
+if (LoadedFromASTFile || Inferred || PartOfFramework || ParsedAsMainInput) 
{
+  ActiveModule = PreviousActiveModule;
   // Skip the module definition.
   

[PATCH] D150478: [clang][modules][deps] Parse "FW_Private" module map even after loading "FW" PCM

2023-07-17 Thread Jan Svoboda 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 rGbe014563f2f4: [clang][modules][deps] Parse 
FW_Private module map even after loading FW PCM 
(authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150478

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/no-check-relocated-fw-private.c


Index: clang/test/Modules/no-check-relocated-fw-private.c
===
--- /dev/null
+++ clang/test/Modules/no-check-relocated-fw-private.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- frameworks1/FW1.framework/Modules/module.modulemap
+framework module FW1 { header "FW1.h" }
+//--- frameworks1/FW1.framework/Headers/FW1.h
+#import 
+
+//--- frameworks2/FW2.framework/Modules/module.modulemap
+framework module FW2 { header "FW2.h" }
+//--- frameworks2/FW2.framework/Modules/module.private.modulemap
+framework module FW2_Private { header "FW2_Private.h" }
+//--- frameworks2/FW2.framework/Headers/FW2.h
+//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
+
+//--- tu.c
+#import  // expected-remark{{importing module 'FW1'}} \
+// expected-remark{{importing module 'FW2'}}
+#import  // expected-remark{{importing module 
'FW2_Private'}}
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fimplicit-module-maps \
+// RUN:   -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
+// RUN:   -fno-modules-check-relocated -Rmodule-import -verify
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1783,9 +1783,6 @@
 
 Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef 
Dir,
   bool IsSystem) {
-  if (Module *Module = ModMap.findModule(Name))
-return Module;
-
   // Try to load a module map file.
   switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/true)) {
   case LMM_InvalidModuleMap:
@@ -1794,10 +1791,10 @@
   ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
 break;
 
-  case LMM_AlreadyLoaded:
   case LMM_NoDirectory:
 return nullptr;
 
+  case LMM_AlreadyLoaded:
   case LMM_NewlyLoaded:
 break;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2588,6 +2588,10 @@
 defm implicit_modules : BoolFOption<"implicit-modules",
   LangOpts<"ImplicitModules">, DefaultTrue,
   NegFlag, PosFlag, 
BothFlags<[NoXarchOption,CoreOption]>>;
+def fno_modules_check_relocated : Joined<["-"], "fno-modules-check-relocated">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Skip checks for relocated modules when loading PCM files">,
+  MarshallingInfoNegativeFlag>;
 def fretain_comments_from_system_headers : Flag<["-"], 
"fretain-comments-from-system-headers">, Group, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def fmodule_header : Flag <["-"], "fmodule-header">, Group,


Index: clang/test/Modules/no-check-relocated-fw-private.c
===
--- /dev/null
+++ clang/test/Modules/no-check-relocated-fw-private.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- frameworks1/FW1.framework/Modules/module.modulemap
+framework module FW1 { header "FW1.h" }
+//--- frameworks1/FW1.framework/Headers/FW1.h
+#import 
+
+//--- frameworks2/FW2.framework/Modules/module.modulemap
+framework module FW2 { header "FW2.h" }
+//--- frameworks2/FW2.framework/Modules/module.private.modulemap
+framework module FW2_Private { header "FW2_Private.h" }
+//--- frameworks2/FW2.framework/Headers/FW2.h
+//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
+
+//--- tu.c
+#import  // expected-remark{{importing module 'FW1'}} \
+// expected-remark{{importing module 'FW2'}}
+#import  // expected-remark{{importing module 'FW2_Private'}}
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache -fimplicit-module-maps \
+// RUN:   -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
+// RUN:   -fno-modules-check-relocated -Rmodule-import -verify
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1783,9 +1783,6 @@
 
 Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
   bool IsSystem) {
-  if (Module *Module = ModMap.findModule(Name))
-return Module;
-
   // Try to load a module map file.
   switch 

[clang] dba2b5c - [clang][modules] Skip submodule & framework re-definitions in module maps

2023-07-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-17T13:50:25-07:00
New Revision: dba2b5c9314e1d127ee5200e739e6c8ca53a9831

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

LOG: [clang][modules] Skip submodule & framework re-definitions in module maps

Before D150478, there were situations when Clang avoided parsing a module map 
because it was likely to re-define an already defined module (either by a PCM 
or by previously-found module map). Since Clang no longer performs that check 
and does parse the extra module map (due to the FW/FW_Private issue described 
in D150478), this patch re-implements the same semantics by skipping the 
duplicate definition of the framework module while parsing the module map.

Depends on D150478.

Reviewed By: benlangmuir

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

Added: 
clang/test/Modules/no-check-relocated-fw-private-sub.c
clang/test/Modules/shadow-framework.m

Modified: 
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index c97642e5c6c87f..4f713fe6e4ad41 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -2016,12 +2016,28 @@ void ModuleMapParser::parseModuleDecl() {
   Module *ShadowingModule = nullptr;
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
 // We might see a (re)definition of a module that we already have a
-// definition for in three cases:
+// definition for in four cases:
 //  - If we loaded one definition from an AST file and we've just found a
 //corresponding definition in a module map file, or
 bool LoadedFromASTFile = Existing->IsFromModuleFile;
 //  - If we previously inferred this module from 
diff erent module map file.
 bool Inferred = Existing->IsInferred;
+//  - If we're building a framework that vends a module map, we might've
+//previously seen the one in intermediate products and now the system
+//one.
+// FIXME: If we're parsing module map file that looks like this:
+//  framework module FW { ... }
+//  module FW.Sub { ... }
+//We can't check the framework qualifier, since it's not attached 
to
+//the definition of Sub. Checking that qualifier on \c Existing is
+//not correct either, since we might've previously seen:
+//  module FW { ... }
+//  module FW.Sub { ... }
+//We should enforce consistency of redefinitions so that we can 
rely
+//that \c Existing is part of a framework iff the redefinition of 
FW
+//we have just skipped had it too. Once we do that, stop checking
+//the local framework qualifier and only rely on \c Existing.
+bool PartOfFramework = Framework || Existing->isPartOfFramework();
 //  - If we're building a (preprocessed) module and we've just loaded the
 //module map file from which it was created.
 bool ParsedAsMainInput =
@@ -2029,7 +2045,8 @@ void ModuleMapParser::parseModuleDecl() {
 Map.LangOpts.CurrentModule == ModuleName &&
 SourceMgr.getDecomposedLoc(ModuleNameLoc).first !=
 SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first;
-if (!ActiveModule && (LoadedFromASTFile || Inferred || ParsedAsMainInput)) 
{
+if (LoadedFromASTFile || Inferred || PartOfFramework || ParsedAsMainInput) 
{
+  ActiveModule = PreviousActiveModule;
   // Skip the module definition.
   skipUntil(MMToken::RBrace);
   if (Tok.is(MMToken::RBrace))

diff  --git a/clang/test/Modules/no-check-relocated-fw-private-sub.c 
b/clang/test/Modules/no-check-relocated-fw-private-sub.c
new file mode 100644
index 00..b2864c40cff665
--- /dev/null
+++ b/clang/test/Modules/no-check-relocated-fw-private-sub.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- frameworks1/FW1.framework/Modules/module.modulemap
+framework module FW1 { header "FW1.h" }
+//--- frameworks1/FW1.framework/Headers/FW1.h
+#import 
+
+//--- frameworks2/FW2.framework/Modules/module.modulemap
+framework module FW2 { header "FW2.h" }
+//--- frameworks2/FW2.framework/Modules/module.private.modulemap
+framework module FW2.Private { header "FW2_Private.h" }
+//--- frameworks2/FW2.framework/Headers/FW2.h
+//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
+
+//--- tu.c
+#import  // expected-remark{{importing module 'FW1'}} \
+// expected-remark{{importing module 'FW2'}}
+#import  // expected-remark{{importing module 'FW2'}}
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fimplicit-module-maps \
+// RUN:   -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
+// RUN:   

[clang] be01456 - [clang][modules][deps] Parse "FW_Private" module map even after loading "FW" PCM

2023-07-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-17T13:50:24-07:00
New Revision: be014563f2f492658abcfa68cfaffc58a4ed7d9a

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

LOG: [clang][modules][deps] Parse "FW_Private" module map even after loading 
"FW" PCM

When Clang loads a PCM that depends on another PCM describing framework module 
"FW", `ModuleMap` registers "FW" as known, without seeing the module map that 
defines it (or the adjacent "FW_Private" module map). Later, when looking at a 
header from "FW_Private", `ModuleMap` returns early due to having knowledge 
about "FW" and never associates that header with "FW_Private", leading to it 
being treated as textual. This behavior is caused by D150292, where the scanner 
stops calling `HeaderSearch::lookupModule()` eagerly for every loaded PCM.

This patch skips an early check when trying to figure out the framework module 
for a header, which ensures the "FW" and (most importantly) "FW_Private" module 
maps can be parsed even after loading "FW" from a PCM. Note that the 
`HeaderSearch::loadModuleMapFile()` function we not call unconditionally has 
caching behavior of its own, meaning it will avoid parsing module map file 
repeatedly.

Depends on D150320.

Reviewed By: benlangmuir

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

Added: 
clang/test/Modules/no-check-relocated-fw-private.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c45eb694a1184c..348d791b8da832 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2588,6 +2588,10 @@ defm modules_search_all : 
BoolFOption<"modules-search-all",
 defm implicit_modules : BoolFOption<"implicit-modules",
   LangOpts<"ImplicitModules">, DefaultTrue,
   NegFlag, PosFlag, 
BothFlags<[NoXarchOption,CoreOption]>>;
+def fno_modules_check_relocated : Joined<["-"], "fno-modules-check-relocated">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Skip checks for relocated modules when loading PCM files">,
+  MarshallingInfoNegativeFlag>;
 def fretain_comments_from_system_headers : Flag<["-"], 
"fretain-comments-from-system-headers">, Group, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def fmodule_header : Flag <["-"], "fmodule-header">, Group,

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 6fe655fb24277c..3200d3d1d0b6ab 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1783,9 +1783,6 @@ HeaderSearch::lookupModuleMapFile(DirectoryEntryRef Dir, 
bool IsFramework) {
 
 Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef 
Dir,
   bool IsSystem) {
-  if (Module *Module = ModMap.findModule(Name))
-return Module;
-
   // Try to load a module map file.
   switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/true)) {
   case LMM_InvalidModuleMap:
@@ -1794,10 +1791,10 @@ Module *HeaderSearch::loadFrameworkModule(StringRef 
Name, DirectoryEntryRef Dir,
   ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
 break;
 
-  case LMM_AlreadyLoaded:
   case LMM_NoDirectory:
 return nullptr;
 
+  case LMM_AlreadyLoaded:
   case LMM_NewlyLoaded:
 break;
   }

diff  --git a/clang/test/Modules/no-check-relocated-fw-private.c 
b/clang/test/Modules/no-check-relocated-fw-private.c
new file mode 100644
index 00..e97100ab238ef1
--- /dev/null
+++ b/clang/test/Modules/no-check-relocated-fw-private.c
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- frameworks1/FW1.framework/Modules/module.modulemap
+framework module FW1 { header "FW1.h" }
+//--- frameworks1/FW1.framework/Headers/FW1.h
+#import 
+
+//--- frameworks2/FW2.framework/Modules/module.modulemap
+framework module FW2 { header "FW2.h" }
+//--- frameworks2/FW2.framework/Modules/module.private.modulemap
+framework module FW2_Private { header "FW2_Private.h" }
+//--- frameworks2/FW2.framework/Headers/FW2.h
+//--- frameworks2/FW2.framework/PrivateHeaders/FW2_Private.h
+
+//--- tu.c
+#import  // expected-remark{{importing module 'FW1'}} \
+// expected-remark{{importing module 'FW2'}}
+#import  // expected-remark{{importing module 
'FW2_Private'}}
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fimplicit-module-maps \
+// RUN:   -F %t/frameworks1 -F %t/frameworks2 -fsyntax-only %t/tu.c \
+// RUN:   -fno-modules-check-relocated -Rmodule-import -verify



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


[clang] 227f719 - [clang][modules][deps] Avoid checks for relocated modules

2023-07-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-17T13:50:24-07:00
New Revision: 227f71995804fa5df3f917ae3a7b1499cd24726c

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

LOG: [clang][modules][deps] Avoid checks for relocated modules

Currently, `ASTReader` performs some checks to diagnose relocated modules. This 
can add quite a bit of overhead to the scanner: it requires looking up, parsing 
and resolving module maps for all transitively loaded module files (and all the 
module maps encountered in the search paths on the way). Most of those checks 
are not really useful in the scanner anyway, since it uses strict context hash 
and immutable filesystem, which prevent those scenarios in the first place.

This can speed up scanning by up to 30%.

Depends on D150292.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/test/ClangScanDeps/header-search-pruning-transitive.c

Removed: 




diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index 432f5dfa9bce95..058194bcde72e5 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -69,6 +69,9 @@ class PreprocessorOptions {
   std::vector Includes;
   std::vector MacroIncludes;
 
+  /// Perform extra checks when loading PCM files for mutable file systems.
+  bool ModulesCheckRelocated = true;
+
   /// Initialize the preprocessor with the compiler and target specific
   /// predefines.
   bool UsePredefines = true;

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0671f791530dd4..5f756961c6e1d0 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2990,6 +2990,9 @@ ASTReader::ReadControlBlock(ModuleFile ,
   BaseDirectoryAsWritten = Blob;
   assert(!F.ModuleName.empty() &&
  "MODULE_DIRECTORY found before MODULE_NAME");
+  F.BaseDirectory = std::string(Blob);
+  if (!PP.getPreprocessorOpts().ModulesCheckRelocated)
+break;
   // If we've already loaded a module map file covering this module, we may
   // have a better path for it (relative to the current build).
   Module *M = PP.getHeaderSearchInfo().lookupModule(
@@ -3011,8 +3014,6 @@ ASTReader::ReadControlBlock(ModuleFile ,
   }
 }
 F.BaseDirectory = std::string(M->Directory->getName());
-  } else {
-F.BaseDirectory = std::string(Blob);
   }
   break;
 }
@@ -3990,7 +3991,8 @@ ASTReader::ReadModuleMapFileBlock(RecordData , 
ModuleFile ,
   // usable header search context.
   assert(!F.ModuleName.empty() &&
  "MODULE_NAME should come before MODULE_MAP_FILE");
-  if (F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
+  if (PP.getPreprocessorOpts().ModulesCheckRelocated &&
+  F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
 // An implicitly-loaded module file should have its module listed in some
 // module map file that we've already loaded.
 Module *M =

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index baf76f01cfb54c..28206dceadd972 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -253,6 +253,9 @@ class DependencyScanningAction : public tooling::ToolAction 
{
 // context hashing.
 ScanInstance.getHeaderSearchOpts().ModulesStrictContextHash = true;
 
+// Avoid some checks and module map parsing when loading PCM files.
+ScanInstance.getPreprocessorOpts().ModulesCheckRelocated = false;
+
 std::unique_ptr Action;
 
 if (ModuleName)

diff  --git a/clang/test/ClangScanDeps/header-search-pruning-transitive.c 
b/clang/test/ClangScanDeps/header-search-pruning-transitive.c
index 512bf5ec5cc6fb..b56e10cac1eeb5 100644
--- a/clang/test/ClangScanDeps/header-search-pruning-transitive.c
+++ b/clang/test/ClangScanDeps/header-search-pruning-transitive.c
@@ -72,8 +72,8 @@ module X { header "X.h" }
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_X:.*]]",
 // CHECK-NEXT:   "file-deps": [
-// CHECK-NEXT: "[[PREFIX]]/./X.h",
-// CHECK-NEXT: "[[PREFIX]]/./module.modulemap"
+// CHECK-NEXT: "[[PREFIX]]/X.h",
+// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "name": "X"
 // CHECK-NEXT: },
@@ -84,11 

[PATCH] D150292: [clang][modules] Serialize `Module::DefinitionLoc`

2023-07-17 Thread Jan Svoboda 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 rGabcf7ce45794: [clang][modules] Serialize 
`Module::DefinitionLoc` (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D150292?vs=539120=541223#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150292

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -200,7 +200,9 @@
 CB(F);
 FileID FID = SourceMgr.translateFile(F);
 SourceLocation Loc = SourceMgr.getIncludeLoc(FID);
-while (Loc.isValid()) {
+// The include location of inferred module maps can point into the header
+// file that triggered the inferring. Cut off the walk if that's the case.
+while (Loc.isValid() && isModuleMap(SourceMgr.getFileCharacteristic(Loc))) {
   FID = SourceMgr.getFileID(Loc);
   CB(*SourceMgr.getFileEntryRefForID(FID));
   Loc = SourceMgr.getIncludeLoc(FID);
@@ -209,11 +211,18 @@
 
   auto ProcessModuleOnce = [&](const Module *M) {
 for (const Module *Mod = M; Mod; Mod = Mod->Parent)
-  if (ProcessedModules.insert(Mod).second)
+  if (ProcessedModules.insert(Mod).second) {
+auto Insert = [&](FileEntryRef F) { ModuleMaps.insert(F); };
+// The containing module map is affecting, because it's being pointed
+// into by Module::DefinitionLoc.
+if (auto ModuleMapFile = MM.getContainingModuleMapFile(Mod))
+  ForIncludeChain(*ModuleMapFile, Insert);
+// For inferred modules, the module map that allowed inferring is not in
+// the include chain of the virtual containing module map file. It did
+// affect the compilation, though.
 if (auto ModuleMapFile = MM.getModuleMapFileForUniquing(Mod))
-  ForIncludeChain(*ModuleMapFile, [&](FileEntryRef F) {
-ModuleMaps.insert(F);
-  });
+  ForIncludeChain(*ModuleMapFile, Insert);
+  }
   };
 
   for (const Module *CurrentModule : ModulesToProcess) {
@@ -2687,6 +2696,7 @@
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // Kind
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Definition location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
@@ -2787,12 +2797,16 @@
   ParentID = SubmoduleIDs[Mod->Parent];
 }
 
+uint64_t DefinitionLoc =
+SourceLocationEncoding::encode(getAdjustedLocation(Mod->DefinitionLoc));
+
 // Emit the definition of the block.
 {
   RecordData::value_type Record[] = {SUBMODULE_DEFINITION,
  ID,
  ParentID,
  (RecordData::value_type)Mod->Kind,
+ DefinitionLoc,
  Mod->IsFramework,
  Mod->IsExplicit,
  Mod->IsSystem,
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5607,7 +5607,7 @@
   break;
 
 case SUBMODULE_DEFINITION: {
-  if (Record.size() < 12)
+  if (Record.size() < 13)
 return llvm::createStringError(std::errc::illegal_byte_sequence,
"malformed module definition");
 
@@ -5616,6 +5616,7 @@
   SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
   SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
   Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++];
+  SourceLocation DefinitionLoc = ReadSourceLocation(F, Record[Idx++]);
   bool IsFramework = Record[Idx++];
   bool IsExplicit = Record[Idx++];
   bool IsSystem = Record[Idx++];
@@ -5636,8 +5637,7 @@
   ModMap.findOrCreateModule(Name, ParentModule, IsFramework, IsExplicit)
   .first;
 
-  // FIXME: set the definition loc for CurrentModule, or call
-  // ModMap.setInferredModuleAllowedBy()
+  // FIXME: Call ModMap.setInferredModuleAllowedBy()
 
   SubmoduleID GlobalIndex = GlobalID - NUM_PREDEF_SUBMODULE_IDS;
   if (GlobalIndex >= SubmodulesLoaded.size() ||
@@ 

[clang] abcf7ce - [clang][modules] Serialize `Module::DefinitionLoc`

2023-07-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-07-17T13:50:23-07:00
New Revision: abcf7ce45794839a473a236d55d163016cde5ba6

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

LOG: [clang][modules] Serialize `Module::DefinitionLoc`

This is a prep patch for avoiding the quadratic number of calls to 
`HeaderSearch::lookupModule()` in `ASTReader` for each (transitively) loaded 
PCM file. (Specifically in the context of `clang-scan-deps`).

This patch explicitly serializes `Module::DefinitionLoc` so that we can stop 
relying on it being filled by the module map parser. This change also required 
change to the module map parser, where we used the absence of `DefinitionLoc` 
to determine whether a file came from a PCM file. We also need to make sure we 
consider the "containing" module map affecting when writing a PCM, so that it's 
not stripped during serialization, which ensures `DefinitionLoc` still ends up 
pointing to the correct offset. This is intended to be a NFC change.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Lex/ModuleMap.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 074d1002913084..2ae9e09998c4c1 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -41,7 +41,7 @@ namespace serialization {
 /// Version 4 of AST files also requires that the version control branch and
 /// revision match exactly, since there is no backward compatibility of
 /// AST files at this time.
-const unsigned VERSION_MAJOR = 26;
+const unsigned VERSION_MAJOR = 27;
 
 /// AST file minor version number supported by this version of
 /// Clang.

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index c480719abc3679..c97642e5c6c87f 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -2016,10 +2016,12 @@ void ModuleMapParser::parseModuleDecl() {
   Module *ShadowingModule = nullptr;
   if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
 // We might see a (re)definition of a module that we already have a
-// definition for in two cases:
+// definition for in three cases:
 //  - If we loaded one definition from an AST file and we've just found a
 //corresponding definition in a module map file, or
-bool LoadedFromASTFile = Existing->DefinitionLoc.isInvalid();
+bool LoadedFromASTFile = Existing->IsFromModuleFile;
+//  - If we previously inferred this module from 
diff erent module map file.
+bool Inferred = Existing->IsInferred;
 //  - If we're building a (preprocessed) module and we've just loaded the
 //module map file from which it was created.
 bool ParsedAsMainInput =
@@ -2027,7 +2029,7 @@ void ModuleMapParser::parseModuleDecl() {
 Map.LangOpts.CurrentModule == ModuleName &&
 SourceMgr.getDecomposedLoc(ModuleNameLoc).first !=
 SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first;
-if (!ActiveModule && (LoadedFromASTFile || ParsedAsMainInput)) {
+if (!ActiveModule && (LoadedFromASTFile || Inferred || ParsedAsMainInput)) 
{
   // Skip the module definition.
   skipUntil(MMToken::RBrace);
   if (Tok.is(MMToken::RBrace))

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 380d117acc4973..0671f791530dd4 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5607,7 +5607,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile ,
   break;
 
 case SUBMODULE_DEFINITION: {
-  if (Record.size() < 12)
+  if (Record.size() < 13)
 return llvm::createStringError(std::errc::illegal_byte_sequence,
"malformed module definition");
 
@@ -5616,6 +5616,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile ,
   SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
   SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
   Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++];
+  SourceLocation DefinitionLoc = ReadSourceLocation(F, Record[Idx++]);
   bool IsFramework = Record[Idx++];
   bool IsExplicit = Record[Idx++];
   bool IsSystem = Record[Idx++];
@@ -5636,8 +5637,7 @@ llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile ,
   ModMap.findOrCreateModule(Name, ParentModule, IsFramework, 
IsExplicit)
   .first;
 
-  // FIXME: set the definition loc for CurrentModule, or 

[PATCH] D155419: [Clang][CMake][WIP] Add CSSPGO support to LLVM_BUILD_INSTRUMENTED

2023-07-17 Thread Amir Ayupov via Phabricator via cfe-commits
Amir updated this revision to Diff 541222.
Amir added a comment.

More plumbing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155419

Files:
  clang/CMakeLists.txt
  clang/utils/perf-training/CMakeLists.txt
  clang/utils/perf-training/lit.cfg
  clang/utils/perf-training/lit.site.cfg.in
  clang/utils/perf-training/perf-helper.py
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1071,7 +1071,7 @@
 option(LLVM_ENABLE_IR_PGO "Build LLVM and tools with IR PGO instrumentation (deprecated)" Off)
 mark_as_advanced(LLVM_ENABLE_IR_PGO)
 
-set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR or Frontend")
+set(LLVM_BUILD_INSTRUMENTED OFF CACHE STRING "Build LLVM and tools with PGO instrumentation. May be specified as IR, Frontend, CSIR, CSSPGO")
 set(LLVM_VP_COUNTERS_PER_SITE "1.5" CACHE STRING "Value profile counters to use per site for IR PGO with Clang")
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED LLVM_VP_COUNTERS_PER_SITE)
 string(TOUPPER "${LLVM_BUILD_INSTRUMENTED}" uppercase_LLVM_BUILD_INSTRUMENTED)
@@ -1104,6 +1104,15 @@
 CMAKE_EXE_LINKER_FLAGS
 CMAKE_SHARED_LINKER_FLAGS)
 endif()
+  elseif(uppercase_LLVM_BUILD_INSTRUMENTED STREQUAL "CSSPGO")
+append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fpseudo-probe-for-profiling"
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
   else()
 append("-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\""
   CMAKE_CXX_FLAGS
@@ -1154,6 +1163,21 @@
   endif()
 endif()
 
+if(LLVM_SPROFDATA_FILE AND EXISTS ${LLVM_SPROFDATA_FILE})
+  if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
+append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS)
+if(NOT LINKER_IS_LLD_LINK)
+  append("-fpseudo-probe-for-profiling -fprofile-sample-use=\"${LLVM_SPROFDATA_FILE}\""
+CMAKE_EXE_LINKER_FLAGS
+CMAKE_SHARED_LINKER_FLAGS)
+endif()
+  else()
+message(FATAL_ERROR "LLVM_SPROFDATA_FILE can only be specified when compiling with clang")
+  endif()
+endif()
+
 option(LLVM_BUILD_INSTRUMENTED_COVERAGE "Build LLVM and tools with Code Coverage instrumentation" Off)
 mark_as_advanced(LLVM_BUILD_INSTRUMENTED_COVERAGE)
 append_if(LLVM_BUILD_INSTRUMENTED_COVERAGE "-fprofile-instr-generate=\"${LLVM_PROFILE_FILE_PATTERN}\" -fcoverage-mapping"
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -849,6 +849,9 @@
 set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
   "Profiling data file to use when compiling in order to improve runtime performance.")
 
+set(LLVM_SPROFDATA_FILE "" CACHE FILEPATH
+  "Sampling profiling data file to use when compiling in order to improve runtime performance.")
+
 if(LLVM_INCLUDE_TESTS)
   # Lit test suite requires at least python 3.6
   set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
Index: clang/utils/perf-training/perf-helper.py
===
--- clang/utils/perf-training/perf-helper.py
+++ clang/utils/perf-training/perf-helper.py
@@ -69,10 +69,16 @@
 
 def perf(args):
 parser = argparse.ArgumentParser(
-prog="perf-helper perf", description="perf wrapper for BOLT profile collection"
+prog="perf-helper perf",
+description="perf wrapper for BOLT/CSSPGO profile collection"
 )
 parser.add_argument(
-"--lbr", required=False, action="store_true", help="Use perf with branch stacks"
+"--lbr", required=False, action="store_true",
+help="Use perf with branch stacks"
+)
+parser.add_argument(
+"--call-graph", required=False, action="store_true",
+help="Collect call graph"
 )
 parser.add_argument("cmd", nargs="*", help="")
 
@@ -97,6 +103,8 @@
 )
 if opts.lbr:
 perf_args += ["--branch-filter=any,u"]
+if opts.call_graph:
+perf_args += ["--call-graph=fp"]
 perf_args.extend(cmd)
 
 start_time = time.time()
@@ -132,6 +140,26 @@
 return 0
 
 
+def perf2prof(args):
+parser = argparse.ArgumentParser(
+prog="perf-helper perf2prof",
+description="perf to CSSPGO prof conversion wrapper",
+)
+parser.add_argument("profgen", help="Path to llvm-profgen binary")
+parser.add_argument("binary", help="Input binary")
+

[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

I addressed the comments, and I have redesigned this option to simplify it 
further. Now there are only two options at the top for `SpacesInParens` to be 
either `Never` or `Custom`. Then within `Custom` the individual behavior of the 
spaces can be controlled. This allows, for example, someone to actually set 
every option `true` and really get a space in every parens that is supported. 
Meanwhile, to get the behavior of what was previously called 
`SpacesInParentheses` a user would set the spaces in parens options for 
`InConditionalStatements` and `Other` to be `true`. If `Other` gets further 
divided in the future, the previous behavior can be retained by simply setting 
its options to `true` as well.




Comment at: clang/include/clang/Format/Format.h:4220
   /// \version 3.7
   bool SpacesInParentheses;
 

HazardyKnusperkeks wrote:
> The deprecated options should be removed from the struct, see 
> `AllowAllConstructorInitializersOnNextLine` for an example.
> 
> You also need to adapt the parsing logic a bit.
Got it, thanks for the hint



Comment at: clang/lib/Format/TokenAnnotator.cpp:4046
+   ? (Style.SpacesInParens == FormatStyle::SIPO_Always ||
+  Style.SpacesInParentheses)
+   : true;

MyDeveloperDay wrote:
> isn't SpacesInParentheses mapped to Style.SpacesInParens == 
> FormatStyle::SIPO_Always?
Yes it was, but I misunderstood how to deprecate options. This is fixed now 
that I removed the deprecated SpacesInParentheses, but it's also been changed 
to map `SpacesInParentheses` to `Style.SpacesInParens == 
FormatStyle::SIPO_Custom`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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


[PATCH] D155383: [clang][AST] TextNodeDumper learned to output exception specifications

2023-07-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think we at least need some tests for this, looks like we have the AST tests 
in `clang/test/AST/ast-dump*`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155383

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


[PATCH] D155414: [Clang][RISCV] Guard RVV intrinsics types that is not available when ELEN < 64

2023-07-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5336
+  // least zve64x
+  if ((Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ false) &&
+   !TI.hasFeature("zve64x")) ||

Can we do

```
if ((Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ false) ||
 Ty->isRVVType(/* ElementCount */ 1)) &&
!TI.hasFeature("zve64x"))
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155414

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


[PATCH] D155239: [clang-format] Add SpacesInParens with SpacesInParensOptions

2023-07-17 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 541219.
gedare marked 3 inline comments as done.
gedare added a comment.

Properly deprecate old options, and simplify top-level to Never and Custom


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155239

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

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -807,7 +807,8 @@
"  if (x)\n"
"x = x;",
Style);
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("if ( x )\n"
"  x = x;\n"
"else if ( x )\n"
@@ -903,7 +904,8 @@
   verifyFormat("repeat (x) begin\n"
"end");
   auto Style = getDefaultStyle();
-  Style.SpacesInConditionalStatement = true;
+  Style.SpacesInParens = FormatStyle::SIPO_Custom;
+  Style.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("foreach ( x[x] )\n"
"  x = x;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11031,14 +11031,16 @@
   verifyFormat("template  void operator=(T) && {}", AlignMiddle);
 
   FormatStyle Spaces = getLLVMStyle();
-  Spaces.SpacesInCStyleCastParentheses = true;
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = {};
+  Spaces.SpacesInParensOptions.InCStyleCasts = true;
   verifyFormat("Deleted =(const Deleted &) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) & = delete;", Spaces);
   verifyFormat("Deleted =(const Deleted &) &;", Spaces);
   verifyFormat("SomeType MemberFunction(const Deleted &) &;", Spaces);
 
-  Spaces.SpacesInCStyleCastParentheses = false;
-  Spaces.SpacesInParentheses = true;
+  Spaces.SpacesInParensOptions.InCStyleCasts = false;
+  Spaces.SpacesInParensOptions.Other = true;
   verifyFormat("Deleted =( const Deleted & ) & = default;", Spaces);
   verifyFormat("SomeType MemberFunction( const Deleted & ) & = delete;",
Spaces);
@@ -13674,7 +13676,8 @@
 
   FormatStyle SpaceBetweenBraces = getLLVMStyle();
   SpaceBetweenBraces.SpacesInAngles = FormatStyle::SIAS_Always;
-  SpaceBetweenBraces.SpacesInParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.Other = true;
   SpaceBetweenBraces.SpacesInSquareBrackets = true;
   verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces);
   verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces);
@@ -13697,7 +13700,8 @@
 "};",
 format("vectorx{1,2,3,4,};", SpaceBetweenBraces));
   verifyFormat("vector< int > x{};", SpaceBetweenBraces);
-  SpaceBetweenBraces.SpaceInEmptyParentheses = true;
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = true;
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
 }
 
@@ -16707,10 +16711,13 @@
   verifyFormat("! ! x", Spaces);
 }
 
-TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
+TEST_F(FormatTest, ConfigurableSpacesInParens) {
   FormatStyle Spaces = getLLVMStyle();
 
-  Spaces.SpacesInParentheses = true;
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = {};
+  Spaces.SpacesInParensOptions.Other = true;
+  Spaces.SpacesInParensOptions.InConditionalStatements = true;
   verifyFormat("do_something( ::globalVar );", Spaces);
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
@@ -16738,8 +16745,9 @@
"}",
Spaces);
 
-  Spaces.SpacesInParentheses = false;
-  Spaces.SpacesInCStyleCastParentheses = true;
+  Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
+  Spaces.SpacesInParensOptions = {};
+  Spaces.SpacesInParensOptions.InCStyleCasts = true;
   verifyFormat("Type *A = ( Type * )P;", Spaces);
   verifyFormat("Type *A = ( vector )P;", Spaces);
   verifyFormat("x = ( int32 )y;", Spaces);
@@ -16750,9 +16758,10 @@
   verifyFormat("#define x (( int )-1)", Spaces);
 
   // Run the first set of tests again with:
-  Spaces.SpacesInParentheses = false;
-  Spaces.SpaceInEmptyParentheses = true;
-  Spaces.SpacesInCStyleCastParentheses = true;
+  Spaces.SpacesInParens = 

[PATCH] D114173: [clang][modules] Apply local submodule visibility to includes

2023-07-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 541218.
jansvoboda11 edited the summary of this revision.
jansvoboda11 added a comment.

Rebase on top of D155503 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114173

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/test/Modules/import-textual-noguard.mm


Index: clang/test/Modules/import-textual-noguard.mm
===
--- clang/test/Modules/import-textual-noguard.mm
+++ clang/test/Modules/import-textual-noguard.mm
@@ -1,7 +1,9 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -fmodules -fimplicit-module-maps 
-I%S/Inputs/import-textual/M2 -fmodules-cache-path=%t -x objective-c++ 
-fmodules-local-submodule-visibility %s -verify
 
-#include "A/A.h" // expected-error {{could not build module 'M'}}
+// expected-no-diagnostics
+
+#include "A/A.h"
 #include "B/B.h"
 
 typedef aint xxx;
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -976,6 +976,9 @@
 /// The macros for the submodule.
 MacroMap Macros;
 
+/// The set of files that have been included in the submodule.
+IncludedFilesSet IncludedFiles;
+
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
@@ -995,9 +998,6 @@
   /// Files included outside of any module (e.g. in PCH) have nullptr key.
   llvm::DenseMap IncludedFilesPerSubmodule;
 
-  /// The files that have been included.
-  IncludedFilesSet IncludedFiles;
-
   /// The set of top-level modules that affected preprocessing, but were not
   /// imported.
   llvm::SmallSetVector AffectingClangModules;
@@ -1486,7 +1486,7 @@
   /// of its dependencies (transitively).
   void markTransitivelyIncluded(const FileEntry *File) {
 HeaderInfo.getFileInfo(File);
-IncludedFiles.insert(File);
+CurSubmoduleState->IncludedFiles.insert(File);
   }
 
   /// Mark the file as included in the current state and attribute it to the
@@ -1500,13 +1500,13 @@
 : getCurrentModule();
 IncludedFilesPerSubmodule[M].insert(File);
 
-return IncludedFiles.insert(File).second;
+return CurSubmoduleState->IncludedFiles.insert(File).second;
   }
 
   /// Return true if this header has already been included.
   bool alreadyIncluded(const FileEntry *File) const {
 HeaderInfo.getFileInfo(File);
-return IncludedFiles.count(File);
+return CurSubmoduleState->IncludedFiles.count(File);
   }
 
   /// Invoke the callback for every module known to include the given file.
@@ -1523,9 +1523,10 @@
 return IncludedFilesPerSubmodule[M];
   }
 
-  /// Get the set of included files.
-  IncludedFilesSet () { return IncludedFiles; }
-  const IncludedFilesSet () const { return IncludedFiles; }
+  /// Get the set of files included in the current state.
+  IncludedFilesSet () {
+return CurSubmoduleState->IncludedFiles;
+  }
 
   /// Return the name of the macro defined before \p Loc that has
   /// spelling \p Tokens.  If there are multiple macros with same spelling,


Index: clang/test/Modules/import-textual-noguard.mm
===
--- clang/test/Modules/import-textual-noguard.mm
+++ clang/test/Modules/import-textual-noguard.mm
@@ -1,7 +1,9 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual/M2 -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s -verify
 
-#include "A/A.h" // expected-error {{could not build module 'M'}}
+// expected-no-diagnostics
+
+#include "A/A.h"
 #include "B/B.h"
 
 typedef aint xxx;
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -976,6 +976,9 @@
 /// The macros for the submodule.
 MacroMap Macros;
 
+/// The set of files that have been included in the submodule.
+IncludedFilesSet IncludedFiles;
+
 /// The set of modules that are visible within the submodule.
 VisibleModuleSet VisibleModules;
 
@@ -995,9 +998,6 @@
   /// Files included outside of any module (e.g. in PCH) have nullptr key.
   llvm::DenseMap IncludedFilesPerSubmodule;
 
-  /// The files that have been included.
-  IncludedFilesSet IncludedFiles;
-
   /// The set of top-level modules that affected preprocessing, but were not
   /// imported.
   llvm::SmallSetVector AffectingClangModules;
@@ -1486,7 +1486,7 @@
   /// of its dependencies (transitively).
   void markTransitivelyIncluded(const FileEntry *File) {
 HeaderInfo.getFileInfo(File);
-IncludedFiles.insert(File);
+

[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-07-17 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

I took the most recent version for a spin against the Linux kernel. The couple 
of issues that a previous revision of the warning flagged 
(https://github.com/ClangBuiltLinux/linux/issues/1806, 
https://github.com/ClangBuiltLinux/linux/issues/1807) are no longer visible 
(that seems intentional because both of those came from macro expressions) but 
I see a new one along a similar line as those:

https://elixir.bootlin.com/linux/v6.5-rc2/source/drivers/gpu/drm/v3d/v3d_drv.h#L343

  In file included from drivers/gpu/drm/v3d/v3d_bo.c:25:
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: warning: use of logical '&&' with 
constant operand [-Wconstant-logical-operand]
343 | if (NSEC_PER_SEC % HZ &&
| ~ ^
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: use '&' for a bitwise operation
343 | if (NSEC_PER_SEC % HZ &&
|   ^~
|   &
  drivers/gpu/drm/v3d/v3d_drv.h:343:24: note: remove constant to silence this 
warning
  1 warning generated.

Another minimized example showing how the warning can trigger with different 
configurations:

  $ cat x.c
  #define A 1000
  #define B 300
  #define C 250
  #define D 100
  
  int bar(void);
  int baz(void);
  
  int foo(void)
  {
  if (A % B && bar()) // 1000 % 300 = 100, warning
  return -3;
  
  if (A % C && bar()) // 1000 % 250 = 0, no warning
  return -2;
  
  if (A % D && bar()) // 1000 % 100 = 0, no warning
  return -1;
  
  return baz();
  }
  
  $ clang -Wall -fsyntax-only x.c
  x.c:11:12: warning: use of logical '&&' with constant operand 
[-Wconstant-logical-operand]
 11 | if (A % B && bar())
| ~ ^
  x.c:11:12: note: use '&' for a bitwise operation
 11 | if (A % B && bar())
|   ^~
|   &
  x.c:11:12: note: remove constant to silence this warning
  1 warning generated.

I am sure we can send a patch making that a boolean expression (although it is 
duplicated in a few places it seems so multiple patches will be needed) but I 
figured I would report it just in case there was something that should be 
changed with the warning, since I see there was already some discussion around 
not warning for macros and this seems along a similar line.


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

https://reviews.llvm.org/D142609

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


[PATCH] D154881: [HIP] Ignore host linker flags for device-only

2023-07-17 Thread Siu Chi Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcbc4bbb85c72: [HIP] Ignore host linker flags for device-only 
(authored by scchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154881

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-phases.hip

Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -219,6 +219,14 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only 2>&1 \
 // RUN: | FileCheck -check-prefixes=DBIN %s
+//
+// Test single gpu architecture with complete compilation in device-only
+// compilation mode with an unused host linker flag.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -Wl,--disable-new-dtags 2>&1 \
+// RUN: | FileCheck -check-prefixes=DBIN %s
+
 // DBIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // DBIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // DBIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -229,6 +237,7 @@
 // DBIN-DAG: [[P7:[0-9]+]]: linker, {[[P6]]}, hip-fatbin, (device-hip, )
 // DBIN-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" {[[P7]]}, hip-fatbin
 // DBIN-NOT: host
+
 //
 // Test single gpu architecture up to the assemble phase in device-only
 // compilation mode.
@@ -251,6 +260,11 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
 // RUN: | FileCheck -check-prefixes=RELOC %s
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable -Wl,--disable-new-dtags \
+// RUN: 2>&1 | FileCheck -check-prefixes=RELOC %s
+//
 // RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -258,6 +272,7 @@
 // RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], [[ARCH]])
 // RELOC-NOT: linker
 // RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+// RELOC-NOT: host
 
 //
 // Test two gpu architectures with compile to relocatable in device-only
@@ -266,6 +281,11 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable 2>&1 \
 // RUN: | FileCheck -check-prefixes=RELOC2 %s
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only -fhip-emit-relocatable \
+// RUN: -Wl,--disable-new-dtags 2>&1 | FileCheck -check-prefixes=RELOC2 %s
+//
 // RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // RELOC2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -280,6 +300,7 @@
 // RELOC2-DAG: [[P10:[0-9]+]]: assembler, {[[P9]]}, object, (device-[[T]], [[ARCH2]])
 // RELOC2-NOT: linker
 // RELOC2-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:[[ARCH2]])" {[[P10]]}, object
+// RELOC2-NOT: host
 
 //
 // Test two gpu architectures with complete compilation in device-only
@@ -288,6 +309,14 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only \
 // RUN: 2>&1 | FileCheck -check-prefixes=DBIN2 %s
+//
+// Test two gpu architectures with complete compilation in device-only
+// compilation mode with an unused host linker flag.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only \
+// RUN: -Wl,--disable-new-dtags 2>&1 | FileCheck -check-prefixes=DBIN2 %s
+
 // DBIN2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], (device-[[T]], [[ARCH:gfx803]])
 // DBIN2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
 // DBIN2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -305,6 +334,7 @@
 // DBIN2-DAG: [[P14:[0-9]+]]: linker, {[[P6]], [[P13]]}, hip-fatbin, (device-hip, )
 // DBIN2-DAG: [[P15:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" {[[P14]]}, hip-fatbin
 // 

[clang] cbc4bbb - [HIP] Ignore host linker flags for device-only

2023-07-17 Thread Siu Chi Chan via cfe-commits

Author: Siu Chi Chan
Date: 2023-07-17T16:29:15-04:00
New Revision: cbc4bbb85c729f34bf0cba84ccd2e116af1454f5

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

LOG: [HIP] Ignore host linker flags for device-only

When compiling in device only mode (e.g. --offload-device-only), the
host linker phase would not happen and therefore, the driver should
ignore all the host linker flags.

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

Change-Id: I8244acef5c33108cf15b1dbb188f974f30099718

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-phases.hip

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index b4a070587901fb..211a65e4cde628 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4146,9 +4146,11 @@ void Driver::BuildActions(Compilation , DerivedArgList 
,
   // Queue linker inputs.
   if (Phase == phases::Link) {
 assert(Phase == PL.back() && "linking must be final compilation 
step.");
-// We don't need to generate additional link commands if emitting AMD 
bitcode
+// We don't need to generate additional link commands if emitting AMD
+// bitcode or compiling only for the offload device
 if (!(C.getInputArgs().hasArg(options::OPT_hip_link) &&
- (C.getInputArgs().hasArg(options::OPT_emit_llvm
+  (C.getInputArgs().hasArg(options::OPT_emit_llvm))) &&
+!offloadDeviceOnly())
   LinkerInputs.push_back(Current);
 Current = nullptr;
 break;

diff  --git a/clang/test/Driver/hip-phases.hip 
b/clang/test/Driver/hip-phases.hip
index 063a16a7939ec6..e976583820ccf7 100644
--- a/clang/test/Driver/hip-phases.hip
+++ b/clang/test/Driver/hip-phases.hip
@@ -219,6 +219,14 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only 2>&1 \
 // RUN: | FileCheck -check-prefixes=DBIN %s
+//
+// Test single gpu architecture with complete compilation in device-only
+// compilation mode with an unused host linker flag.
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -Wl,--disable-new-dtags 
2>&1 \
+// RUN: | FileCheck -check-prefixes=DBIN %s
+
 // DBIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], 
(device-[[T]], [[ARCH:gfx803]])
 // DBIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH]])
 // DBIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -229,6 +237,7 @@
 // DBIN-DAG: [[P7:[0-9]+]]: linker, {[[P6]]}, hip-fatbin, (device-hip, )
 // DBIN-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa:)" 
{[[P7]]}, hip-fatbin
 // DBIN-NOT: host
+
 //
 // Test single gpu architecture up to the assemble phase in device-only
 // compilation mode.
@@ -251,6 +260,11 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 
2>&1 \
 // RUN: | FileCheck -check-prefixes=RELOC %s
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 %s --cuda-device-only -fhip-emit-relocatable 
-Wl,--disable-new-dtags \
+// RUN: 2>&1 | FileCheck -check-prefixes=RELOC %s
+//
 // RELOC-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], 
(device-[[T]], [[ARCH:gfx803]])
 // RELOC-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH]])
 // RELOC-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-[[T]], [[ARCH]])
@@ -258,6 +272,7 @@
 // RELOC-DAG: [[P4:[0-9]+]]: assembler, {[[P3]]}, object, (device-[[T]], 
[[ARCH]])
 // RELOC-NOT: linker
 // RELOC-DAG: [[P5:[0-9]+]]: offload, "device-[[T]] 
(amdgcn-amd-amdhsa:[[ARCH]])" {[[P4]]}, object
+// RELOC-NOT: host
 
 //
 // Test two gpu architectures with compile to relocatable in device-only
@@ -266,6 +281,11 @@
 // RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
 // RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only 
-fhip-emit-relocatable 2>&1 \
 // RUN: | FileCheck -check-prefixes=RELOC2 %s
+//
+// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
+// RUN: --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 %s --cuda-device-only 
-fhip-emit-relocatable \
+// RUN: -Wl,--disable-new-dtags 2>&1 | FileCheck -check-prefixes=RELOC2 %s
+//
 // RELOC2-DAG: [[P0:[0-9]+]]: input, "{{.*}}hip-phases.hip", [[T:hip]], 
(device-[[T]], [[ARCH:gfx803]])
 // RELOC2-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, 
(device-[[T]], [[ARCH]])
 // RELOC2-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, 

[PATCH] D155408: [Driver] Also warn about -mwatchos-version-min and -mtvos-version-min

2023-07-17 Thread Cassie Jones 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 rG45ff63ba6112: [Driver] Also warn about -mwatchos-version-min 
and -mtvos-version-min (authored by porglezomp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155408

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/macho-embedded.c


Index: clang/test/Driver/macho-embedded.c
===
--- clang/test/Driver/macho-embedded.c
+++ clang/test/Driver/macho-embedded.c
@@ -8,12 +8,17 @@
 
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 
-fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 
-mios-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-watchos 
-mwatchos-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mtvos-version-min=5 
-fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mios-version-min=5 
-### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-MIXED
 
 // CHECK-IOS: "-triple" "thumbv7" "thumbv7-apple-ios
 
 // CHECK-AAPCS: "-target-abi" "aapcs"
 // CHECK-APCS: "-target-abi" "apcs-gnu"
 
-// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: 
'-mios-version-min=5'
 // CHECK-MACHO-EMBEDDED: "-triple" "{{thumbv[67]e?m}}-apple-unknown-macho"
 // CHECK-MACHO-EMBEDDED: "-mrelocation-model" "pic"
+// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: 
'-m{{ios|watchos|tvos}}-version-min=5'
+// CHECK-MACHO-EMBEDDED-MIXED: error: unsupported option '-mios-version-min=' 
for target 'thumbv7-apple-tvos'
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
+#include "llvm/TargetParser/Triple.h"
 #include  // ::getenv
 
 using namespace clang::driver;
@@ -85,10 +86,16 @@
   if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
-// Don't reject -mios-version-min= if we have an iOS triple.
-if (T.isiOS())
+// Don't reject these -version-min= if we have the appropriate triple.
+if (T.getOS() == llvm::Triple::IOS)
   for (Arg *A : Args.filtered(options::OPT_mios_version_min_EQ))
 A->ignoreTargetSpecific();
+if (T.getOS() == llvm::Triple::WatchOS)
+  for (Arg *A : Args.filtered(options::OPT_mwatchos_version_min_EQ))
+A->ignoreTargetSpecific();
+if (T.getOS() == llvm::Triple::TvOS)
+  for (Arg *A : Args.filtered(options::OPT_mtvos_version_min_EQ))
+A->ignoreTargetSpecific();
 
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);


Index: clang/test/Driver/macho-embedded.c
===
--- clang/test/Driver/macho-embedded.c
+++ clang/test/Driver/macho-embedded.c
@@ -8,12 +8,17 @@
 
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 -mios-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-watchos -mwatchos-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mtvos-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mios-version-min=5 -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-MIXED
 
 // CHECK-IOS: "-triple" "thumbv7" "thumbv7-apple-ios
 
 // CHECK-AAPCS: "-target-abi" "aapcs"
 // CHECK-APCS: "-target-abi" "apcs-gnu"
 
-// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: '-mios-version-min=5'
 // CHECK-MACHO-EMBEDDED: "-triple" "{{thumbv[67]e?m}}-apple-unknown-macho"
 // CHECK-MACHO-EMBEDDED: "-mrelocation-model" "pic"
+// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: '-m{{ios|watchos|tvos}}-version-min=5'
+// CHECK-MACHO-EMBEDDED-MIXED: error: unsupported option 

[clang] 45ff63b - [Driver] Also warn about -mwatchos-version-min and -mtvos-version-min

2023-07-17 Thread Cassie Jones via cfe-commits

Author: Cassie Jones
Date: 2023-07-17T13:26:52-07:00
New Revision: 45ff63ba6112c199897b4117d54f19d28161b632

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

LOG: [Driver] Also warn about -mwatchos-version-min and -mtvos-version-min

Sometimes users pass this option when targeting embedded architectures like 
armv7m on non-darwin platforms.
This applies to watchOS and tvOS as well as iOS.

Depends on D155407

Reviewed By: MaskRay, ahatanak

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/macho-embedded.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index a73f46bb320294..65bd6c6a7eb35a 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/TargetParser/TargetParser.h"
+#include "llvm/TargetParser/Triple.h"
 #include  // ::getenv
 
 using namespace clang::driver;
@@ -85,10 +86,16 @@ void darwin::setTripleTypeForMachOArchName(llvm::Triple , 
StringRef Str,
   if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
-// Don't reject -mios-version-min= if we have an iOS triple.
-if (T.isiOS())
+// Don't reject these -version-min= if we have the appropriate triple.
+if (T.getOS() == llvm::Triple::IOS)
   for (Arg *A : Args.filtered(options::OPT_mios_version_min_EQ))
 A->ignoreTargetSpecific();
+if (T.getOS() == llvm::Triple::WatchOS)
+  for (Arg *A : Args.filtered(options::OPT_mwatchos_version_min_EQ))
+A->ignoreTargetSpecific();
+if (T.getOS() == llvm::Triple::TvOS)
+  for (Arg *A : Args.filtered(options::OPT_mtvos_version_min_EQ))
+A->ignoreTargetSpecific();
 
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);

diff  --git a/clang/test/Driver/macho-embedded.c 
b/clang/test/Driver/macho-embedded.c
index 14b933ba256de0..bb4971203518b3 100644
--- a/clang/test/Driver/macho-embedded.c
+++ b/clang/test/Driver/macho-embedded.c
@@ -8,12 +8,17 @@
 
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 
-fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
 // RUN: %clang -arch armv7m --target=thumbv7-apple-ios -mios-version-min=5 
-mios-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-watchos 
-mwatchos-version-min=5 -fdriver-only -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mtvos-version-min=5 
-fdriver-only -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-DIAG
+
+// RUN: %clang -arch armv7m --target=thumbv7-apple-tvos -mios-version-min=5 
-### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-MACHO-EMBEDDED-MIXED
 
 // CHECK-IOS: "-triple" "thumbv7" "thumbv7-apple-ios
 
 // CHECK-AAPCS: "-target-abi" "aapcs"
 // CHECK-APCS: "-target-abi" "apcs-gnu"
 
-// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: 
'-mios-version-min=5'
 // CHECK-MACHO-EMBEDDED: "-triple" "{{thumbv[67]e?m}}-apple-unknown-macho"
 // CHECK-MACHO-EMBEDDED: "-mrelocation-model" "pic"
+// CHECK-MACHO-EMBEDDED-DIAG: warning: argument unused during compilation: 
'-m{{ios|watchos|tvos}}-version-min=5'
+// CHECK-MACHO-EMBEDDED-MIXED: error: unsupported option '-mios-version-min=' 
for target 'thumbv7-apple-tvos'



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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-07-17 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:359
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a

mehdi_amini wrote:
> ldionne wrote:
> > smeenai wrote:
> > > aaron.ballman wrote:
> > > > arsenm wrote:
> > > > > I haven't quite figured out what the exact syntaxes which are 
> > > > > automatically recognized. It seems to recognize "Fixes #Nxyz"
> > > > Yup, it does support that form as well. I had heard more than once 
> > > > during code review that folks seem to prefer the full link because it's 
> > > > easier to click on that from the commit message than it is to navigate 
> > > > to the fix from the number alone. That seemed like a pretty good reason 
> > > > to recommend the full form, but I don't have strong opinions.
> > > +1 for encouraging the full link
> > Perhaps we could encourage using `https://llvm.org/PR12345` instead? Does 
> > anybody know whether `llvm.org/PRXXX` is something that we intend to keep 
> > around with the Github transition or not?
> @arsenm: It's documented 
> https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
> And for linking cross-repo: 
> https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls#issues-and-pull-requests
> Perhaps we could encourage using `https://llvm.org/PR12345` instead? Does 
> anybody know whether `llvm.org/PRXXX` is something that we intend to keep 
> around with the Github transition or not?

Currently the PRxxx links are to the old bugzillas, not the Github issues. It 
might be sad to lose that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155081

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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-07-17 Thread Tanya Lattner via Phabricator via cfe-commits
tonic added a comment.

As I mentioned on the Discourse thread, but if this policy change is made, 
there should be some discussion about if this applies retroactively. Making a 
note here, because it probably should be included in the changes to Developer 
Policy if the radar links are not removed but not allowed going forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155081

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


[PATCH] D155509: Revert "Remove rdar links; NFC"

2023-07-17 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini created this revision.
mehdi_amini added reviewers: lattner, aaron.ballman.
Herald added subscribers: steakhal, jdoerfert, martong, pengfei, arphaman.
Herald added a reviewer: NoQ.
Herald added a project: All.
mehdi_amini requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This reverts commit d618f1c3b12effd0c2bdb7d02108d3551f389d3d 
.
This commit wasn't reviewed ahead of time and significant concerns were
raised immediately after it landed. According to our developer policy
this warrants immediate revert of the commit.

https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155509

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
  clang/test/ARCMT/GC-check-warn-nsalloc.m
  clang/test/ARCMT/GC-no-finalize-removal.m
  clang/test/ARCMT/GC-no-finalize-removal.m.result
  clang/test/ARCMT/GC.m
  clang/test/ARCMT/GC.m.result
  clang/test/ARCMT/check-with-pch.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/nonobjc-to-objc-cast-2.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/ARCMT/objcmt-atomic-property.m
  clang/test/ARCMT/objcmt-atomic-property.m.result
  clang/test/ARCMT/objcmt-boxing.m
  clang/test/ARCMT/objcmt-boxing.m.result
  clang/test/ARCMT/objcmt-migrate-all.m
  clang/test/ARCMT/objcmt-migrate-all.m.result
  clang/test/ARCMT/objcmt-ns-macros.m
  clang/test/ARCMT/objcmt-ns-macros.m.result
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
  clang/test/ARCMT/objcmt-property-availability.m
  clang/test/ARCMT/objcmt-property-availability.m.result
  clang/test/ARCMT/objcmt-property-dot-syntax.m
  clang/test/ARCMT/objcmt-property-dot-syntax.m.result
  clang/test/ARCMT/objcmt-property.m
  clang/test/ARCMT/objcmt-property.m.result
  clang/test/ARCMT/objcmt-protocol-conformance.m
  clang/test/ARCMT/objcmt-protocol-conformance.m.result
  clang/test/ARCMT/objcmt-undefined-ns-macros.m
  clang/test/ARCMT/objcmt-undefined-ns-macros.m.result
  clang/test/Analysis/DeallocMissingRelease.m
  clang/test/Analysis/DeallocUseAfterFreeErrors.m
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/inline-plist.c.plist
  clang/test/Analysis/Inputs/expected-plists/malloc-plist.c.plist
  clang/test/Analysis/Inputs/expected-plists/plist-output.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/NSString.m
  clang/test/Analysis/OSAtomic_mac.cpp
  clang/test/Analysis/PR46264.cpp
  clang/test/Analysis/UserNullabilityAnnotations.m
  clang/test/Analysis/array-struct-region.c
  clang/test/Analysis/blocks.m
  clang/test/Analysis/call-and-message.m
  clang/test/Analysis/call-invalidation.cpp
  clang/test/Analysis/cfref_rdar6080742.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/default-analyze.m
  clang/test/Analysis/delegates.m
  clang/test/Analysis/edges-new.mm
  clang/test/Analysis/generics.m
  clang/test/Analysis/inline-plist.c
  clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.m.plist
  clang/test/Analysis/inlining/eager-reclamation-path-notes.c
  clang/test/Analysis/inlining/false-positive-suppression.c
  clang/test/Analysis/inlining/path-notes.m
  clang/test/Analysis/malloc-interprocedural.c
  clang/test/Analysis/malloc-plist.c
  clang/test/Analysis/malloc.c
  clang/test/Analysis/misc-ps-64.m
  clang/test/Analysis/misc-ps-arm.m
  clang/test/Analysis/misc-ps-eager-assume.m
  clang/test/Analysis/misc-ps-ranges.m
  clang/test/Analysis/misc-ps-region-store.cpp
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/misc-ps.m
  clang/test/Analysis/mutually_exclusive_null_fp.cpp
  clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
  clang/test/Analysis/null-deref-ps.c
  clang/test/Analysis/objc-arc.m
  clang/test/Analysis/objc-encode.m
  clang/test/Analysis/objc-subscript.m
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/plist-output-alternate.m
  clang/test/Analysis/plist-output.m
  clang/test/Analysis/properties.m
  

[PATCH] D155480: [HIP] Rename predefined macros

2023-07-17 Thread Yaxun Liu 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 rGf0a955d3fa54: [HIP] Rename predefined macros (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155480

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/Driver/hip-macros.hip


Index: clang/test/Driver/hip-macros.hip
===
--- clang/test/Driver/hip-macros.hip
+++ clang/test/Driver/hip-macros.hip
@@ -61,5 +61,20 @@
 // RUN:   -Xclang -target-feature -Xclang "+image-insts" %s 2>&1 | FileCheck 
--check-prefixes=NOIMAGE,WARN %s
 // NOWARN-NOT: warning
 // WARN: warning: feature flag '{{[+|-]}}image-insts' is ignored since the 
feature is read only [-Winvalid-command-line-argument]
+// IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT__
 // IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT
-// NOIMAGE: #define __HIP_NO_IMAGE_SUPPORT 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT__ 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT 1
+
+// RUN: %clang -E -dM --offload-arch=gfx1100 -nogpuinc -nogpulib \
+// RUN:   -fgpu-default-stream=per-thread %s 2>&1 | FileCheck 
--check-prefixes=PTS %s
+// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc 
-nogpulib \
+// RUN:   -fgpu-default-stream=legacy %s 2>&1 | FileCheck 
--check-prefixes=NOPTS %s
+// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc 
-nogpulib \
+// RUN:   %s 2>&1 | FileCheck --check-prefixes=NOPTS %s
+// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
+// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
+// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
+// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
+// NOPTS-NOT: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__
+// NOPTS-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -35,7 +35,7 @@
 extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
  size_t sharedSize = 0,
  hipStream_t stream = 0);
-#ifndef HIP_API_PER_THREAD_DEFAULT_STREAM
+#ifndef __HIP_API_PER_THREAD_DEFAULT_STREAM__
 extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
   dim3 blockDim, void **args,
   size_t sharedMem,
@@ -45,7 +45,7 @@
   dim3 blockDim, void **args,
   size_t sharedMem,
   hipStream_t stream);
-#endif //HIP_API_PER_THREAD_DEFAULT_STREAM
+#endif // __HIP_API_PER_THREAD_DEFAULT_STREAM__
 #else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -588,12 +588,18 @@
 Builder.defineMacro("__HIP_MEMORY_SCOPE_SYSTEM", "5");
 if (LangOpts.CUDAIsDevice) {
   Builder.defineMacro("__HIP_DEVICE_COMPILE__");
-  if (!TI.hasHIPImageSupport())
+  if (!TI.hasHIPImageSupport()) {
+Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT__", "1");
+// Deprecated.
 Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT", "1");
+  }
 }
 if (LangOpts.GPUDefaultStream ==
-LangOptions::GPUDefaultStreamKind::PerThread)
+LangOptions::GPUDefaultStreamKind::PerThread) {
+  Builder.defineMacro("__HIP_API_PER_THREAD_DEFAULT_STREAM__");
+  // Deprecated.
   Builder.defineMacro("HIP_API_PER_THREAD_DEFAULT_STREAM");
+}
   }
 }
 


Index: clang/test/Driver/hip-macros.hip
===
--- clang/test/Driver/hip-macros.hip
+++ clang/test/Driver/hip-macros.hip
@@ -61,5 +61,20 @@
 // RUN:   -Xclang -target-feature -Xclang "+image-insts" %s 2>&1 | FileCheck --check-prefixes=NOIMAGE,WARN %s
 // NOWARN-NOT: warning
 // WARN: warning: feature flag '{{[+|-]}}image-insts' is ignored since the feature is read only [-Winvalid-command-line-argument]
+// IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT__
 // IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT
-// NOIMAGE: #define __HIP_NO_IMAGE_SUPPORT 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT__ 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT 1
+
+// RUN: %clang -E -dM --offload-arch=gfx1100 -nogpuinc -nogpulib \
+// RUN:   -fgpu-default-stream=per-thread %s 2>&1 | FileCheck --check-prefixes=PTS %s
+// RUN: %clang -E -dM 

[clang] f0a955d - [HIP] Rename predefined macros

2023-07-17 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-07-17T15:45:49-04:00
New Revision: f0a955d3fa54d2b8600e646bbfb6bf3217a18d0c

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

LOG: [HIP] Rename predefined macros

Rename HIP_API_PER_THREAD_DEFAULT_STREAM and __HIP_NO_IMAGE_SUPPORT
so that they follow the convention with prefix and postfix __.

Reviewed by: Artem Belevich

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

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/CodeGenCUDA/Inputs/cuda.h
clang/test/Driver/hip-macros.hip

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 16dd0c01bcb443..2ab9e652b10c3c 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -588,12 +588,18 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo ,
 Builder.defineMacro("__HIP_MEMORY_SCOPE_SYSTEM", "5");
 if (LangOpts.CUDAIsDevice) {
   Builder.defineMacro("__HIP_DEVICE_COMPILE__");
-  if (!TI.hasHIPImageSupport())
+  if (!TI.hasHIPImageSupport()) {
+Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT__", "1");
+// Deprecated.
 Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT", "1");
+  }
 }
 if (LangOpts.GPUDefaultStream ==
-LangOptions::GPUDefaultStreamKind::PerThread)
+LangOptions::GPUDefaultStreamKind::PerThread) {
+  Builder.defineMacro("__HIP_API_PER_THREAD_DEFAULT_STREAM__");
+  // Deprecated.
   Builder.defineMacro("HIP_API_PER_THREAD_DEFAULT_STREAM");
+}
   }
 }
 

diff  --git a/clang/test/CodeGenCUDA/Inputs/cuda.h 
b/clang/test/CodeGenCUDA/Inputs/cuda.h
index 06399659c0b53e..8df425b77ac823 100644
--- a/clang/test/CodeGenCUDA/Inputs/cuda.h
+++ b/clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -35,7 +35,7 @@ int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t 
sharedSize = 0,
 extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
  size_t sharedSize = 0,
  hipStream_t stream = 0);
-#ifndef HIP_API_PER_THREAD_DEFAULT_STREAM
+#ifndef __HIP_API_PER_THREAD_DEFAULT_STREAM__
 extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
   dim3 blockDim, void **args,
   size_t sharedMem,
@@ -45,7 +45,7 @@ extern "C" hipError_t hipLaunchKernel_spt(const void *func, 
dim3 gridDim,
   dim3 blockDim, void **args,
   size_t sharedMem,
   hipStream_t stream);
-#endif //HIP_API_PER_THREAD_DEFAULT_STREAM
+#endif // __HIP_API_PER_THREAD_DEFAULT_STREAM__
 #else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;

diff  --git a/clang/test/Driver/hip-macros.hip 
b/clang/test/Driver/hip-macros.hip
index 6289ef91dd04fa..9954ddf075e66f 100644
--- a/clang/test/Driver/hip-macros.hip
+++ b/clang/test/Driver/hip-macros.hip
@@ -61,5 +61,20 @@
 // RUN:   -Xclang -target-feature -Xclang "+image-insts" %s 2>&1 | FileCheck 
--check-prefixes=NOIMAGE,WARN %s
 // NOWARN-NOT: warning
 // WARN: warning: feature flag '{{[+|-]}}image-insts' is ignored since the 
feature is read only [-Winvalid-command-line-argument]
+// IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT__
 // IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT
-// NOIMAGE: #define __HIP_NO_IMAGE_SUPPORT 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT__ 1
+// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT 1
+
+// RUN: %clang -E -dM --offload-arch=gfx1100 -nogpuinc -nogpulib \
+// RUN:   -fgpu-default-stream=per-thread %s 2>&1 | FileCheck 
--check-prefixes=PTS %s
+// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc 
-nogpulib \
+// RUN:   -fgpu-default-stream=legacy %s 2>&1 | FileCheck 
--check-prefixes=NOPTS %s
+// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc 
-nogpulib \
+// RUN:   %s 2>&1 | FileCheck --check-prefixes=NOPTS %s
+// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
+// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
+// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
+// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
+// NOPTS-NOT: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__
+// NOPTS-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM



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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

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

In D153612#4505307 , @balazske wrote:

> No major problems were indicated with the patch stack, I plan to merge all of 
> these soon. Small problems can be still corrected before or when the checker 
> is put out from the alpha package.

Make sure features are consistent as clang-17 will branch off next Tuesday if 
you want these to be part of that release.
Also, consider fine-tuning the proposed release-notes for the features you 
developed. See D155445 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D155506: [clang][JumpDiagnostics] use StmtClass rather than dyn_cast chain NFC

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Avoid the anti-pattern of:

  if dyn_cast:
...
  elif dyn_cast:
...
  elif dyn_cast:
...

And simply switch on the statement class, as is done elsewhere in this
class. These cases are for classes with no shared inheritance lineage
beyond all inheriting from clang::Stmt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155506

Files:
  clang/lib/Sema/JumpDiagnostics.cpp


Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -643,8 +643,9 @@
   while (!Jumps.empty()) {
 Stmt *Jump = Jumps.pop_back_val();
 
-// With a goto,
-if (GotoStmt *GS = dyn_cast(Jump)) {
+switch (Jump->getStmtClass()) {
+case Stmt::GotoStmtClass: {
+  auto *GS = cast(Jump);
   // The label may not have a statement if it's coming from inline MS ASM.
   if (GS->getLabel()->getStmt()) {
 CheckJump(GS, GS->getLabel()->getStmt(), GS->getGotoLoc(),
@@ -653,10 +654,10 @@
   diag::warn_cxx98_compat_goto_into_protected_scope);
   }
   CheckGotoStmt(GS);
-  continue;
+  break;
 }
-
-if (auto *G = dyn_cast(Jump)) {
+case Stmt::GCCAsmStmtClass: {
+  auto *G = cast(Jump);
   for (AddrLabelExpr *L : G->labels()) {
 LabelDecl *LD = L->getLabel();
 unsigned JumpScope = LabelAndGotoScopes[G];
@@ -664,33 +665,38 @@
 if (JumpScope != TargetScope)
   DiagnoseIndirectOrAsmJump(G, JumpScope, LD, TargetScope);
   }
-  continue;
+  break;
 }
-
-// We only get indirect gotos here when they have a constant target.
-if (IndirectGotoStmt *IGS = dyn_cast(Jump)) {
+case Stmt::IndirectGotoStmtClass: {
+  // We only get indirect gotos here when they have a constant target.
+  auto *IGS = dyn_cast(Jump);
   LabelDecl *Target = IGS->getConstantTarget();
   CheckJump(IGS, Target->getStmt(), IGS->getGotoLoc(),
 diag::err_goto_into_protected_scope,
 diag::ext_goto_into_protected_scope,
 diag::warn_cxx98_compat_goto_into_protected_scope);
-  continue;
+  break;
 }
-
-SwitchStmt *SS = cast(Jump);
-for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
- SC = SC->getNextSwitchCase()) {
-  if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(SC)))
-continue;
-  SourceLocation Loc;
-  if (CaseStmt *CS = dyn_cast(SC))
-Loc = CS->getBeginLoc();
-  else if (DefaultStmt *DS = dyn_cast(SC))
-Loc = DS->getBeginLoc();
-  else
-Loc = SC->getBeginLoc();
-  CheckJump(SS, SC, Loc, diag::err_switch_into_protected_scope, 0,
-diag::warn_cxx98_compat_switch_into_protected_scope);
+case Stmt::SwitchStmtClass: {
+  auto *SS = cast(Jump);
+  for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
+  SC = SC->getNextSwitchCase()) {
+if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(SC)))
+  continue;
+SourceLocation Loc;
+if (const auto *CS = dyn_cast(SC))
+  Loc = CS->getBeginLoc();
+else if (const auto *DS = dyn_cast(SC))
+  Loc = DS->getBeginLoc();
+else
+  Loc = SC->getBeginLoc();
+CheckJump(SS, SC, Loc, diag::err_switch_into_protected_scope, 0,
+diag::warn_cxx98_compat_switch_into_protected_scope);
+  }
+  break;
+}
+default:
+  break;
 }
   }
 }


Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -643,8 +643,9 @@
   while (!Jumps.empty()) {
 Stmt *Jump = Jumps.pop_back_val();
 
-// With a goto,
-if (GotoStmt *GS = dyn_cast(Jump)) {
+switch (Jump->getStmtClass()) {
+case Stmt::GotoStmtClass: {
+  auto *GS = cast(Jump);
   // The label may not have a statement if it's coming from inline MS ASM.
   if (GS->getLabel()->getStmt()) {
 CheckJump(GS, GS->getLabel()->getStmt(), GS->getGotoLoc(),
@@ -653,10 +654,10 @@
   diag::warn_cxx98_compat_goto_into_protected_scope);
   }
   CheckGotoStmt(GS);
-  continue;
+  break;
 }
-
-if (auto *G = dyn_cast(Jump)) {
+case Stmt::GCCAsmStmtClass: {
+  auto *G = cast(Jump);
   for (AddrLabelExpr *L : G->labels()) {
 LabelDecl *LD = L->getLabel();
 unsigned JumpScope = LabelAndGotoScopes[G];
@@ -664,33 +665,38 @@
 if (JumpScope != TargetScope)
   DiagnoseIndirectOrAsmJump(G, JumpScope, LD, TargetScope);
   }
-  continue;
+  break;
 }
-
-// We only get indirect gotos here when they have a constant 

[PATCH] D134678: [Clang][AArch64][SME] Add intrinsics for ZA array load/store (LDR/STR)

2023-07-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

Thanks for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134678

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


[PATCH] D153156: [Clang] CWG1473: do not err on the lack of space after operator""

2023-07-17 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao added a comment.

There seems to be no clear objection to this and 
https://reviews.llvm.org/D152632 and the CI are passing for both.  Any chance 
that I merge these two before llvm 17 branch out (IIRC the next Monday)?


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

https://reviews.llvm.org/D153156

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/JumpDiagnostics.cpp:361
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have

rjmccall wrote:
> You can pull the `GCCAsmStmtClass` case right above this, make the cast 
> unconditional (`if (!cast(S)->isAsmGoto()) break;`), and then 
> fall through into the GotoStmt case.
I could hoist + use `[[fallthrough]]` but note that the case above 
`Stmt::SwitchStmtClass` also currently uses `[[fallthrough]]` here as well; so 
I would still need the `dyn_cast`.

With that in mind, do you still prefer the hoisting? I don't have a preference, 
but wanted to triple check that with you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

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


[PATCH] D155342: [clang][JumpDiagnostics] ignore non-asm goto target scopes

2023-07-17 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 541178.
nickdesaulniers added a comment.

- fix typo in release doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155342

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/test/Sema/asm-goto.cpp
  clang/test/SemaCXX/goto2.cpp

Index: clang/test/SemaCXX/goto2.cpp
===
--- clang/test/SemaCXX/goto2.cpp
+++ clang/test/SemaCXX/goto2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions %s
 // expected-no-diagnostics
 
 //PR9463
@@ -46,3 +46,20 @@
 
 	return 0;
 }
+
+void asm_goto_try_catch() {
+  try {
+__label__ label;
+asm goto("" : : : : label);
+label:;
+  } catch(...) {
+__label__ label;
+asm goto("" : : : : label);
+label:;
+  };
+  if constexpr(false) {
+__label__ label;
+asm goto("" : : : : label);
+label:;
+  }
+}
Index: clang/test/Sema/asm-goto.cpp
===
--- clang/test/Sema/asm-goto.cpp
+++ clang/test/Sema/asm-goto.cpp
@@ -59,3 +59,13 @@
 loop:
   return 0;
 }
+
+void test4cleanup(int*);
+// No errors expected.
+void test4(void) {
+  asm goto(""l0);
+l0:;
+  int x __attribute__((cleanup(test4cleanup)));
+  asm goto(""l1);
+l1:;
+}
Index: clang/lib/Sema/JumpDiagnostics.cpp
===
--- clang/lib/Sema/JumpDiagnostics.cpp
+++ clang/lib/Sema/JumpDiagnostics.cpp
@@ -72,10 +72,9 @@
   SmallVector Jumps;
 
   SmallVector IndirectJumps;
-  SmallVector AsmJumps;
+  SmallVector IndirectJumpTargets;
   SmallVector MustTailStmts;
-  SmallVector IndirectJumpTargets;
-  SmallVector AsmJumpTargets;
+
 public:
   JumpScopeChecker(Stmt *Body, Sema );
 private:
@@ -86,7 +85,7 @@
   void BuildScopeInformation(Stmt *S, unsigned );
 
   void VerifyJumps();
-  void VerifyIndirectOrAsmJumps(bool IsAsmGoto);
+  void VerifyIndirectJumps();
   void VerifyMustTailStmts();
   void NoteJumpIntoScopes(ArrayRef ToScopes);
   void DiagnoseIndirectOrAsmJump(Stmt *IG, unsigned IGScope, LabelDecl *Target,
@@ -115,8 +114,7 @@
 
   // Check that all jumps we saw are kosher.
   VerifyJumps();
-  VerifyIndirectOrAsmJumps(false);
-  VerifyIndirectOrAsmJumps(true);
+  VerifyIndirectJumps();
   VerifyMustTailStmts();
 }
 
@@ -357,24 +355,16 @@
 [[fallthrough]];
 
   case Stmt::GotoStmtClass:
+  case Stmt::GCCAsmStmtClass:
+if (auto *GS = dyn_cast(S))
+  if (!GS->isAsmGoto())
+break;
 // Remember both what scope a goto is in as well as the fact that we have
 // it.  This makes the second scan not have to walk the AST again.
 LabelAndGotoScopes[S] = ParentScope;
 Jumps.push_back(S);
 break;
 
-  case Stmt::GCCAsmStmtClass:
-if (auto *GS = dyn_cast(S))
-  if (GS->isAsmGoto()) {
-// Remember both what scope a goto is in as well as the fact that we
-// have it.  This makes the second scan not have to walk the AST again.
-LabelAndGotoScopes[S] = ParentScope;
-AsmJumps.push_back(GS);
-for (auto *E : GS->labels())
-  AsmJumpTargets.push_back(E->getLabel());
-  }
-break;
-
   case Stmt::IfStmtClass: {
 IfStmt *IS = cast(S);
 if (!(IS->isConstexpr() || IS->isConsteval() ||
@@ -666,6 +656,17 @@
   continue;
 }
 
+if (auto *G = dyn_cast(Jump)) {
+  for (AddrLabelExpr *L : G->labels()) {
+LabelDecl *LD = L->getLabel();
+unsigned JumpScope = LabelAndGotoScopes[G];
+unsigned TargetScope = LabelAndGotoScopes[LD->getStmt()];
+if (JumpScope != TargetScope)
+  DiagnoseIndirectOrAsmJump(G, JumpScope, LD, TargetScope);
+  }
+  continue;
+}
+
 // We only get indirect gotos here when they have a constant target.
 if (IndirectGotoStmt *IGS = dyn_cast(Jump)) {
   LabelDecl *Target = IGS->getConstantTarget();
@@ -694,17 +695,16 @@
   }
 }
 
-/// VerifyIndirectOrAsmJumps - Verify whether any possible indirect goto or
-/// asm goto jump might cross a protection boundary.  Unlike direct jumps,
-/// indirect or asm goto jumps count cleanups as protection boundaries:
-/// since there's no way to know where the jump is going, we can't implicitly
-/// run the right cleanups the way we can with direct jumps.
-/// Thus, an indirect/asm jump is "trivial" if it bypasses no
-/// initializations and no teardowns.  More formally, an indirect/asm jump
-/// from A to B is trivial if the path out from A to DCA(A,B) is
-/// trivial and the path in from DCA(A,B) to B is trivial, where
-/// DCA(A,B) is the deepest common ancestor of A and B.
-/// Jump-triviality is transitive but asymmetric.
+/// VerifyIndirectJumps - Verify whether any possible indirect goto jump might
+/// cross a protection boundary.  Unlike direct jumps, indirect goto 

[PATCH] D155445: [analyzer][docs] Add CSA release notes

2023-07-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 541175.
steakhal marked 4 inline comments as done.
steakhal added a comment.

Currentl look: F28285701: image.png 

let me know if you like it.
Feel free to propose changes.

I'm not sure about the relative ordering. We should consider some semantic 
ordering. Such as perceived impact on the regular user?

IMO the `taint tracking` and the `ArrayBoundCheckerV2` improvements were quite 
impactful, as both of those were up on the table for a really long time now.
Also, for a similar reason, I think `Objective-C` improvements definitely 
deserve the spotlight.

---

@balazske @donat.nagy WDYT about the `StreamChecker` and the 
`StdCLibraryFunctions` entries? I didn't follow those patches, thus I cannot 
write the notes for it either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155445

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -903,6 +903,89 @@
   non-complete destructors when using the Microsoft ABI.
   (`#60465 `_)
 
+- Removed the deprecated
+  ``consider-single-element-arrays-as-flexible-array-members`` analyzer option.
+  Any use of this flag will result in an error.
+  Use `-fstrict-flex-arrays= 
`_
+  (`7cd1f3ad22e4 `_)
+
+- Better modeling of lifetime-extended memory regions. As a result, the
+  ``MoveChecker`` raises more true-positive reports.
+  (`feafbb9fda57 `_)
+
+- Fixed some bugs (including crashes) around the handling of constant global
+  arrays and their initializer expressions.
+  (`ffcf214b5d27 `_,
+  `558b46fde2db `_)
+
+- The ``CStringChecker`` will invalidate less if the copy operation is
+  inferable to be bounded. For example, if the argument of ``strcpy`` is known
+  to be of certain length and that is in-bounds.
+
+   .. code-block:: c++
+
+struct {
+  void *ptr;
+  char arr[4];
+} x;
+x.ptr = malloc(1);
+// extent of 'arr' is 4, and writing "hi\n" (4 characters),
+// thus no buffer overflow can happen
+strcpy(x.arr, "hi\n");
+free(x.ptr); // no longer reports memory leak here
+
+  Similarly, functions like ``strsep`` now won't invalidate the source buffer,
+  because it can never overflow.
+  Note that, ``std::copy`` is still not modeled, and as such, it will still
+  invalidate the enclosing object on call.
+  (`1bd2d335b649 `_)
+  (`#55019 `_)
+
+- Implement ``BufferOverlap`` check for ``sprint``/``snprintf``
+  The ``CStringChecker`` checks for buffer overlaps for ``sprintf`` and
+  ``snprintf``.
+  (`ce97312d109b `_)
+
+- Objective-C support was improved around checking ``_Nonnull`` and
+  ``_Nullable`` including block pointers and literal objects.
+  (`b22a5d46179b `_,
+  `77a599ae5828 `_,
+  `fa6b7dd520fc `_,
+  `993060e1d31d `_)
+
+- Let the ``StreamChecker`` detect ``NULL`` streams instead of by
+  ``StdCLibraryFunctions``.
+  ``StreamChecker`` improved on the ``fseek`` modeling for the ``SEEK_SET``,
+  ``SEEK_END``, ``SEEK_CUR`` arguments.
+  (`2eefd19613b8 `_,
+  `2c60f9c8a4fd `_)
+
+- ``StdCLibraryFunctionArgs`` was merged into the ``StdCLibraryFunctions``.
+  The diagnostics of the ``StdCLibraryFunctions`` was improved.
+  (`4f0436dd1532 `_,
+  `6012cadc400f `_,
+  `258c9bebbdfa `_,
+  `ce1fb03db817 `_,
+  `ddc5d40dd285 `_)
+
+- ``QTimer::singleShot`` now doesn't raise false-positives for memory leaks by
+  the ``MallocChecker``.
+  (`3b6a368d763e `_)
+  (`#39713 `_)
+
+- Fixed the infamous unsigned index false-positives in the
+  

  1   2   3   >