[PATCH] D126061: [clang] [WIP] Reject non-declaration C++11 attributes on declarations

2022-05-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This direction looks good to me. Thanks!

Regarding the possibility of storing the declaration attributes on the 
`DeclSpec` rather than on the `Declarator`, I wonder if a better choice might 
be to make the `Declarator` hold a non-owning reference to the attributes, like 
it does for the `DeclSpec`?




Comment at: clang/include/clang/Sema/DeclSpec.h:1975-1984
   /// Reset the contents of this Declarator.
   void clear() {
+clearExceptDeclarationAttrs();
+DeclarationAttrs.clear();
+  }
+
+  /// Reset the contents of this Declarator, except for the declaration

Note that neither of these functions clear the `DeclSpec`. I suppose that makes 
sense given that the `Declarator` does not own the `DeclSpec` but merely holds 
a reference to it. Perhaps we could do the same thing with the declaration 
attributes?



Comment at: clang/include/clang/Sema/ParsedAttr.h:657-658
+  /// "slides" to the decl-specifier-seq).
+  /// Attributes with GNU, __declspec or keyword syntax generally slide
+  /// to the decl-specifier-seq. C++11 attributes specified ahead of the
+  /// declaration always appertain to the declaration according to the 
standard,

I don't think this sentence is correct: "Attributes with GNU, __declspec or 
keyword syntax generally slide to the decl-specifier-seq." Instead, I think 
those attribute syntaxes are never parsed as declaration attributes in the 
first place, so there is no possibility of "sliding" anywhere -- they simply 
always are decl-spec attributes.



Comment at: clang/lib/Parse/ParseDecl.cpp:1832
   // Parse the common declaration-specifiers piece.
   ParsingDeclSpec DS(*this);
 

Ideally I think we should pass the `DeclSpecAttrs` into `DS` up-front here. 
That'd keep the behavior closer to the behavior we get for attributes we parse 
in the `ParseDeclarationSpecifiers` call below, and will keep attributes in the 
correct order in the case of something like `__attribute__((a)) int 
__attribute__((b)) x;` at block scope.



Comment at: clang/lib/Parse/ParseDecl.cpp:2188
 // Parse the next declarator.
-D.clear();
+D.clearExceptDeclarationAttrs();
 D.setCommaLoc(CommaLoc);

I wonder if a name like `prepareForNextDeclarator` or `clearForComma` would be 
better here -- something that indicates why we're clearing rather than 
describing how.



Comment at: clang/lib/Parse/ParseDecl.cpp:4385
+// can put them on the next field.
+Attrs.takeAllFrom(DeclaratorInfo.D.getDeclarationAttributes());
   }

I think we'd benefit here from the `Declarator` only holding a reference to the 
declaration attributes rather than owning them.



Comment at: clang/lib/Parse/ParseDecl.cpp:6978-6997
 // Parse any C++11 attributes.
-MaybeParseCXX11Attributes(DS.getAttributes());
+ParsedAttributes ArgDeclAttrs(AttrFactory);
+MaybeParseCXX11Attributes(ArgDeclAttrs);
 
-// Skip any Microsoft attributes before a param.
-MaybeParseMicrosoftAttributes(DS.getAttributes());
-
-SourceLocation DSStart = Tok.getLocation();
+ParsedAttributes ArgDeclSpecAttrs(AttrFactory);
 
 // If the caller parsed attributes for the first argument, add them now.

Seems to be mostly pre-existing, but I don't think this is right. The 
`FirstArgAttrs` are all decl-specifier attributes (they're parsed in 
`ParseParenDeclarator`, where we look for GNU attributes and `__declspec` 
attributes), so if we parsed any of those, we should not now parse any syntax 
that is supposed to precede decl-specifier attributes. The current code allows 
attributes to appear in the wrong order in the case where we need to 
disambiguate a paren declarator: https://godbolt.org/z/bzK6n8obM (note that the 
`g` case properly errors, but the `f` case that needs lookahead to determine 
whether the `(` is introducing a function declarator incorrectly accepts 
misplaced attributes).



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:2716
 // Otherwise, it must be a using-declaration or an alias-declaration.
 return ParseUsingDeclaration(DeclaratorContext::Member, TemplateInfo,
+ UsingLoc, DeclEnd, DeclAttrs, AS);

Do we need to `ProhibitAttrs(DeclSpecAttrs)` along this code path? For example:
```
struct A { int a; };
struct B : A { [uuid("1234")] using A::a; };
```
... currently warns (for `-target x86_64-windows`) but I think with this patch 
we'll silently drop the `uuid` attribute on the floor.



Comment at: clang/lib/Parse/ParseObjc.cpp:661
 allTUVariables.push_back(
-ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs));
+ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs, attrs));
 continue;

It's a bit confusing to use the same `attrs` 

[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2022-05-20 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@compnerd Thanks for reporting. I will take a look as soon as possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D116593: Fix `performance-unnecessary-value-param` for template specialization

2022-05-20 Thread Felix Berger via Phabricator via cfe-commits
flx added a comment.

I don't have access to Windows, perhaps rebase and try again? It looks like the 
template specialization related tests are failing there though.


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

https://reviews.llvm.org/D116593

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


[PATCH] D126052: [clang-format] Handle "complex" conditionals in RemoveBracesLLVM

2022-05-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 431100.
owenpan added a comment.

Changed an unnecessary condition to an assertion.


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

https://reviews.llvm.org/D126052

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25451,7 +25451,6 @@
Style);
 
   Style.ColumnLimit = 65;
-
   verifyFormat("if (condition) {\n"
"  ff(Indices,\n"
" [&](unsigned LHSI, unsigned RHSI) { return true; });\n"
@@ -25494,8 +25493,48 @@
"}",
Style);
 
-  Style.ColumnLimit = 0;
+  verifyFormat("if (-b >=\n"
+   "c) { // Keep.\n"
+   "  foo();\n"
+   "} else {\n"
+   "  bar();\n"
+   "}",
+   "if (-b >= c) { // Keep.\n"
+   "  foo();\n"
+   "} else {\n"
+   "  bar();\n"
+   "}",
+   Style);
 
+  verifyFormat("if (a) /* Remove. */\n"
+   "  f();\n"
+   "else\n"
+   "  g();",
+   "if (a) <% /* Remove. */\n"
+   "  f();\n"
+   "%> else <%\n"
+   "  g();\n"
+   "%>",
+   Style);
+
+  verifyFormat("while (\n"
+   "!i--) <% // Keep.\n"
+   "  foo();\n"
+   "%>",
+   "while (!i--) <% // Keep.\n"
+   "  foo();\n"
+   "%>",
+   Style);
+
+  verifyFormat("for (int  : chars)\n"
+   "  ++i;",
+   "for (int  :\n"
+   " chars) {\n"
+   "  ++i;\n"
+   "}",
+   Style);
+
+  Style.ColumnLimit = 0;
   verifyFormat("if (a)\n"
"  b234567890223456789032345678904234567890 = "
"c234567890223456789032345678904234567890;",
@@ -25504,6 +25543,129 @@
"c234567890223456789032345678904234567890;\n"
"}",
Style);
+
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
+  Style.BraceWrapping.BeforeElse = true;
+
+  Style.ColumnLimit = 65;
+
+  verifyFormat("if (condition)\n"
+   "{\n"
+   "  ff(Indices,\n"
+   " [&](unsigned LHSI, unsigned RHSI) { return true; });\n"
+   "}\n"
+   "else\n"
+   "{\n"
+   "  ff(Indices,\n"
+   " [&](unsigned LHSI, unsigned RHSI) { return true; });\n"
+   "}",
+   "if (condition) {\n"
+   "  ff(Indices,\n"
+   " [&](unsigned LHSI, unsigned RHSI) { return true; });\n"
+   "} else {\n"
+   "  ff(Indices,\n"
+   " [&](unsigned LHSI, unsigned RHSI) { return true; });\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a)\n"
+   "{ //\n"
+   "  foo();\n"
+   "}",
+   "if (a) { //\n"
+   "  foo();\n"
+   "}",
+   Style);
+
+  Style.ColumnLimit = 20;
+
+  verifyFormat("int ab = [](int i) {\n"
+   "  if (i > 0)\n"
+   "  {\n"
+   "i = 12345678 -\n"
+   "i;\n"
+   "  }\n"
+   "  return i;\n"
+   "};",
+   "int ab = [](int i) {\n"
+   "  if (i > 0) {\n"
+   "i = 12345678 -\n"
+   "i;\n"
+   "  }\n"
+   "  return i;\n"
+   "};",
+   Style);
+
+  verifyFormat("if (a)\n"
+   "{\n"
+   "  b = c + // 1 -\n"
+   "  d;\n"
+   "}",
+   "if (a) {\n"
+   "  b = c + // 1 -\n"
+   "  d;\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a)\n"
+   "{\n"
+   "  b = c >= 0 ? d\n"
+   " : e;\n"
+   "}",
+   "if (a) {\n"
+   "  b = c >= 0 ? d : e;\n"
+   "}",
+   Style);
+
+  verifyFormat("if (a)\n"
+   "  b = c > 0 ? d : e;",
+   "if (a)\n"
+   "{\n"
+   "  b = c > 0 ? d : e;\n"
+   "}",
+   Style);
+
+  verifyFormat("if (foo + bar <=\n"
+   "baz)\n"
+   "{\n"
+   "  func(arg1, arg2);\n"
+   "}",
+   "if (foo + bar <= baz) {\n"
+   "  func(arg1, arg2);\n"
+   "}",
+   Style);
+
+  verifyFormat("if (foo + bar < 

[PATCH] D126034: [clang-tidy] bugfix in InfiniteLoopCheck to not print warnings for unevaluated loops

2022-05-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thx Dmitry!

Usama, I heard you have plans to make `isUnevaluated()` consume statements so 
that you could feed the entire loop into the machine without separating it into 
parts. You can either update this patch or do that as a follow-up patch.

Also I think it's time for you to ask for commit access, so please do! 
(https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126034

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


[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

2022-05-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Looks awesome!

> add_new_check.py

I'm surprised it wasn't executable already, do we want to keep it?




Comment at: clang-tools-extra/clang-tidy/objc/CMakeLists.txt:13
   NSInvocationArgumentLifetimeCheck.cpp
+  NsdateformatterCheck.cpp
   ObjCTidyModule.cpp

Looks like everybody's respecting CaPiTaLiZaTiOn, I guess we could too?



Comment at: clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.cpp:22
+// Adding matchers.
+Finder->addMatcher(objcMessageExpr(hasSelector("setDateFormat:"), 
hasArgument(0, hasDescendant( stringLiteral().bind("str_lit", this);
+}

Please clang-format this down to 80 column limit 
(https://llvm.org/docs/CodingStandards.html).



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:87
`bugprone-reserved-identifier `_, "Yes"
-   `bugprone-shared-ptr-array-mismatch 
`_, "Yes"
`bugprone-signal-handler `_,

Where did these go?


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

https://reviews.llvm.org/D126097

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


[PATCH] D126100: Add sanitizer-specific GlobalValue attributes.

2022-05-20 Thread Mitch Phillips via Phabricator via cfe-commits
hctim created this revision.
hctim added reviewers: vitalybuka, kstoimenov.
Herald added subscribers: ormris, jdoerfert, steven_wu, hiraditya.
Herald added a project: All.
hctim requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Plan is the migrate the global variable metadata for sanitizers, that's
currently carried around generally in the 'llvm.asan.globals' section,
onto the global variable itself.

This patch adds the attribute and plumbs it through the LLVM IR and
bitcode formats, but is a no-op other than that so far.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126100

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/CodeGen/SanitizerMetadata.h
  clang/test/CodeGen/asan-globals-alias.cpp
  clang/test/CodeGen/asan-globals-odr.cpp
  clang/test/CodeGen/asan-static-odr.cpp
  clang/test/CodeGen/asan-strings.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/AsmParser/LLParser.h
  llvm/include/llvm/AsmParser/LLToken.h
  llvm/include/llvm/IR/GlobalValue.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/LLVMContextImpl.h

Index: llvm/lib/IR/LLVMContextImpl.h
===
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -1503,6 +1503,9 @@
   /// Collection of per-GlobalValue partitions used in this context.
   DenseMap GlobalValuePartitions;
 
+  DenseMap
+  GlobalValueSanitizerMetadata;
+
   /// DiscriminatorTable - This table maps file:line locations to an
   /// integer representing the next DWARF path discriminator to assign to
   /// instructions in different blocks at the same location.
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -67,6 +67,8 @@
   setDLLStorageClass(Src->getDLLStorageClass());
   setDSOLocal(Src->isDSOLocal());
   setPartition(Src->getPartition());
+  if (Src->hasSanitizerMetadata())
+setSanitizerMetadata(Src->getSanitizerMetadata());
 }
 
 void GlobalValue::removeFromParent() {
@@ -217,6 +219,18 @@
   HasPartition = !S.empty();
 }
 
+using SanitizerMetadata = GlobalValue::SanitizerMetadata;
+using GlobalSanitizer = GlobalValue::SanitizerMetadata::GlobalSanitizer;
+const SanitizerMetadata ::getSanitizerMetadata() const {
+  assert(hasSanitizerMetadata());
+  return getContext().pImpl->GlobalValueSanitizerMetadata[this];
+}
+
+void GlobalValue::setSanitizerMetadata(const SanitizerMetadata ) {
+  getContext().pImpl->GlobalValueSanitizerMetadata[this] = Meta;
+  HasSanitizerMetadata = true;
+}
+
 StringRef GlobalObject::getSectionImpl() const {
   assert(hasSection());
   return getContext().pImpl->GlobalObjectSections[this];
Index: llvm/lib/IR/AsmWriter.cpp
===
--- llvm/lib/IR/AsmWriter.cpp
+++ llvm/lib/IR/AsmWriter.cpp
@@ -100,6 +100,9 @@
 using UseListOrderMap =
 DenseMap>>;
 
+using SanitizerMetadata = llvm::GlobalValue::SanitizerMetadata;
+using GlobalSanitizer = SanitizerMetadata::GlobalSanitizer;
+
 /// Look for a value that might be wrapped as metadata, e.g. a value in a
 /// metadata operand. Returns the input value as-is if it is not wrapped.
 static const Value *skipMetadataWrapper(const Value *V) {
@@ -3537,6 +3540,28 @@
 Out << '"';
   }
 
+  if (GV->hasSanitizerMetadata()) {
+SanitizerMetadata MD = GV->getSanitizerMetadata();
+if (MD.HasSanitizer(SanitizerMetadata::NoSanitize)) {
+  Out << ", no_sanitize";
+} else {
+  if (MD.HasSanitizer(SanitizerMetadata::Address))
+Out << ", sanitize_address";
+  if (MD.HasSanitizer(SanitizerMetadata::HWAddress))
+Out << ", sanitize_hwaddress";
+  if (MD.HasSanitizer(SanitizerMetadata::Memtag))
+Out << ", sanitize_address";
+  if (MD.HasSanitizer(SanitizerMetadata::NoAddress))
+Out << ", no_sanitize_address";
+  if (MD.HasSanitizer(SanitizerMetadata::NoHWAddress))
+Out << ", no_sanitize_hwaddress";
+  if (MD.HasSanitizer(SanitizerMetadata::NoMemtag))
+Out << ", no_sanitize_memtag";
+  if (MD.HasSanitizer(GlobalSanitizer::Address) && MD.IsDynInit)
+Out << ", sanitize_address_dyninit";
+}
+  }
+
   maybePrintComdat(Out, *GV);
   if (MaybeAlign A = GV->getAlign())
 Out << ", align " << A->value();
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1344,7 +1344,8 @@
 // GLOBALVAR: [strtab offset, strtab size, type, isconst, initid,
 // linkage, 

[PATCH] D126093: Sema: adjust assertion to account for deduced types

2022-05-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 431084.
compnerd added a comment.

git-clang-format


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

https://reviews.llvm.org/D126093

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/test/Sema/typerep-typespec.c


Index: clang/test/Sema/typerep-typespec.c
===
--- /dev/null
+++ clang/test/Sema/typerep-typespec.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c11 -x c %s -fsyntax-only -verify
+// REQUIRES: asserts
+
+struct dispatch_object_s;
+void _dispatch_queue_get_head(struct dispatch_object_s *volatile 
dq_items_head) {
+  (_Atomic __typeof__(dq_items_head) *)0; // expected-warning{{expression 
result unused}}
+}
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -516,7 +516,8 @@
   SourceLocation getTypeSpecSatLoc() const { return TSSatLoc; }
 
   SourceLocation getTypeSpecTypeNameLoc() const {
-assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
+assert(isDeclRep((TST)TypeSpecType) || isTypeRep((TST)TypeSpecType) ||
+   isExprRep((TST)TypeSpecType));
 return TSTNameLoc;
   }
 


Index: clang/test/Sema/typerep-typespec.c
===
--- /dev/null
+++ clang/test/Sema/typerep-typespec.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c11 -x c %s -fsyntax-only -verify
+// REQUIRES: asserts
+
+struct dispatch_object_s;
+void _dispatch_queue_get_head(struct dispatch_object_s *volatile dq_items_head) {
+  (_Atomic __typeof__(dq_items_head) *)0; // expected-warning{{expression result unused}}
+}
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -516,7 +516,8 @@
   SourceLocation getTypeSpecSatLoc() const { return TSSatLoc; }
 
   SourceLocation getTypeSpecTypeNameLoc() const {
-assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
+assert(isDeclRep((TST)TypeSpecType) || isTypeRep((TST)TypeSpecType) ||
+   isExprRep((TST)TypeSpecType));
 return TSTNameLoc;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126097: Adds the NSDateFormatter checker to clang-tidy

2022-05-20 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud created this revision.
t-rasmud added a reviewer: NoQ.
Herald added subscribers: carlosgalvezp, mgorny.
Herald added a project: All.
t-rasmud requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Reports incorrect string patterns in the date format specifier.


https://reviews.llvm.org/D126097

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/objc/CMakeLists.txt
  clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.cpp
  clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.h
  clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/objc-NSDateFormatter.rst
  clang-tools-extra/test/clang-tidy/checkers/objc-NSDateFormatter.m

Index: clang-tools-extra/test/clang-tidy/checkers/objc-NSDateFormatter.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/objc-NSDateFormatter.m
@@ -0,0 +1,280 @@
+// RUN: %check_clang_tidy %s objc-NSDateFormatter %t
+
+#import 
+
+@interface TestClass : NSObject{
+}
++(void)testMethod1;
++(void)testMethod2;
++(void)testMethod3;
+@end
+
+@implementation TestClass
+
++(void)testMethod1{
+// Reproducing incorrect behavior from Radar
+NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+[formatter setDateFormat:@"_MM_dd_HH_mm_ss_SSS_ZZZ"];
+// CHECK-MESSAGES: :[[@LINE-1]]:17:31: warning: use of week year(Y) with month(M); did you mean to use calendar year(y) instead? [objc-NSDateFormatter]
+NSDateComponents *comps = [[NSDateComponents alloc] init];
+[comps setDay:29];
+[comps setMonth:12];
+[comps setYear:2014];
+NSDate *date_radar = [[NSCalendar currentCalendar] dateFromComponents:comps];
+NSLog(@"_MM_dd_HH_mm_ss_SSS_ZZZ %@",[formatter stringFromDate:date_radar]);
+
+// Radar correct behavior
+[formatter setDateFormat:@"_MM_dd_HH_mm_ss_SSS_ZZZ"];
+NSLog(@"_MM_dd_HH_mm_ss_SSS_ZZZ %@",[formatter stringFromDate:date_radar]);
+
+// Radar correct behavior - week year
+[formatter setDateFormat:@"_ww_dd_HH_mm_ss_SSS_ZZZ"];
+NSLog(@"_ww_dd_HH_mm_ss_SSS_ZZZ %@",[formatter stringFromDate:date_radar]);
+
+// Radar incorrect behavior
+[formatter setDateFormat:@"_ww_dd_HH_mm_ss_SSS_ZZZ"];
+// CHECK-MESSAGES: :[[@LINE-1]]:35:31: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-NSDateFormatter]
+NSLog(@"_ww_dd_HH_mm_ss_SSS_ZZZ %@",[formatter stringFromDate:date_radar]);
+
+NSLog(@"==");
+// Correct
+[formatter setDateFormat:@"_MM"];
+NSLog(@"_MM %@",[formatter stringFromDate:date_radar]);
+
+// Correct
+[formatter setDateFormat:@"_dd"];
+NSLog(@"_dd %@",[formatter stringFromDate:date_radar]);
+
+// Correct
+[formatter setDateFormat:@"_DD"];
+NSLog(@"_DD %@",[formatter stringFromDate:date_radar]);
+
+// Incorrect
+[formatter setDateFormat:@"_ww"];
+// CHECK-MESSAGES: :[[@LINE-1]]:53:31: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-NSDateFormatter]
+NSLog(@"_ww %@",[formatter stringFromDate:date_radar]);
+
+// Incorrect
+[formatter setDateFormat:@"_WW"];
+// CHECK-MESSAGES: :[[@LINE-1]]:58:31: warning: Week of Month(W) used without the month(M); did you forget M in the format string? [objc-NSDateFormatter]
+NSLog(@"_WW %@",[formatter stringFromDate:date_radar]);
+
+NSLog(@"==");
+// Correct
+[formatter setDateFormat:@"_MM_dd"];
+NSLog(@"_MM_dd %@",[formatter stringFromDate:date_radar]);
+
+// Potentially Incorrect
+[formatter setDateFormat:@"_MM_DD"];
+NSLog(@"_MM_DD %@",[formatter stringFromDate:date_radar]);
+
+// Incorrect
+[formatter setDateFormat:@"_MM_ww"];
+// CHECK-MESSAGES: :[[@LINE-1]]:72:31: warning: use of calendar year(y) with week of the year(w); did you mean to use week-year(Y) instead? [objc-NSDateFormatter]
+NSLog(@"_MM_ww %@",[formatter stringFromDate:date_radar]);
+
+NSLog(@"===WEEK YEAR==");
+// Incorrect
+[formatter setDateFormat:@"_MM"];
+// CHECK-MESSAGES: :[[@LINE-1]]:78:31: warning: use of week year(Y) with month(M); did you mean to use calendar year(y) instead? [objc-NSDateFormatter]
+NSLog(@"_MM %@",[formatter stringFromDate:date_radar]);
+
+// Correct
+[formatter setDateFormat:@"_ww"];
+NSLog(@"_ww %@",[formatter stringFromDate:date_radar]);
+
+// Incorrect
+[formatter setDateFormat:@"_WW"];
+// CHECK-MESSAGES: :[[@LINE-1]]:87:31: 

[PATCH] D126096: [clang-format] Fix QualifierAlignment with global namespace qualified types.

2022-05-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

If you can think of other cases that may misbehave, I'll be happy to test (and 
fix) these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126096

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


[PATCH] D126096: [clang-format] Fix QualifierAlignment with global namespace qualified types.

2022-05-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay.
Herald added a project: All.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126096

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -318,6 +318,8 @@
   verifyFormat("Foo const ", "const Foo ", Style);
   verifyFormat("Foo::iterator const ", "const Foo::iterator ",
Style);
+  verifyFormat("::Foo::iterator const ", "const ::Foo::iterator ",
+   Style);
 
   verifyFormat("Foo(int a, "
"unsigned b, // c-style args\n"
@@ -355,6 +357,8 @@
 
   verifyFormat("void fn(Foo const );", "void fn(const Foo );", Style);
   verifyFormat("void fns(ns::S const );", "void fns(const ns::S );", Style);
+  verifyFormat("void fns(::ns::S const );", "void fns(const ::ns::S );",
+   Style);
   verifyFormat("void fn(ns::Foo const );", "void fn(const ns::Foo );",
Style);
   verifyFormat("void fns(ns::ns2::S const );",
@@ -445,6 +449,8 @@
   verifyFormat("const Foo ", "Foo const ", Style);
   verifyFormat("const Foo::iterator ", "Foo::iterator const ",
Style);
+  verifyFormat("const ::Foo::iterator ", "::Foo::iterator const ",
+   Style);
 
   verifyFormat("const int a;", "int const a;", Style);
   verifyFormat("const int *a;", "int const *a;", Style);
@@ -508,6 +514,8 @@
 
   verifyFormat("void fn(const Foo );", "void fn(Foo const );", Style);
   verifyFormat("void fns(const ns::S );", "void fns(ns::S const );", Style);
+  verifyFormat("void fns(const ::ns::S );", "void fns(::ns::S const );",
+   Style);
   verifyFormat("void fn(const ns::Foo );", "void fn(ns::Foo const );",
Style);
   verifyFormat("void fns(const ns::ns2::S );",
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -214,6 +214,28 @@
   if (LeftRightQualifierAlignmentFixer::isPossibleMacro(Tok->Next))
 return Tok;
 
+  auto AnalyzeTemplate =
+  [&](const FormatToken *Tok,
+  const FormatToken *StartTemplate) -> const FormatToken * {
+// Read from the TemplateOpener to TemplateCloser.
+FormatToken *EndTemplate = StartTemplate->MatchingParen;
+if (EndTemplate) {
+  // Move to the end of any template class members e.g.
+  // `Foo::iterator`.
+  if (EndTemplate->startsSequence(TT_TemplateCloser, tok::coloncolon,
+  tok::identifier))
+EndTemplate = EndTemplate->Next->Next;
+}
+if (EndTemplate && EndTemplate->Next &&
+!EndTemplate->Next->isOneOf(tok::equal, tok::l_paren)) {
+  insertQualifierAfter(SourceMgr, Fixes, EndTemplate, Qualifier);
+  // Remove the qualifier.
+  removeToken(SourceMgr, Fixes, Tok);
+  return Tok;
+}
+return nullptr;
+  };
+
   FormatToken *Qual = Tok->Next;
   FormatToken *LastQual = Qual;
   while (Qual && isQualifierOrType(Qual, ConfiguredQualifierTokens)) {
@@ -231,26 +253,24 @@
 return Tok;
   } else if (Tok->startsSequence(QualifierType, tok::identifier,
  TT_TemplateOpener)) {
-// Read from the TemplateOpener to
-// TemplateCloser as in const ArrayRef a; const ArrayRef 
-FormatToken *EndTemplate = Tok->Next->Next->MatchingParen;
-if (EndTemplate) {
-  // Move to the end of any template class members e.g.
-  // `Foo::iterator`.
-  if (EndTemplate->startsSequence(TT_TemplateCloser, tok::coloncolon,
-  tok::identifier))
-EndTemplate = EndTemplate->Next->Next;
-}
-if (EndTemplate && EndTemplate->Next &&
-!EndTemplate->Next->isOneOf(tok::equal, tok::l_paren)) {
-  insertQualifierAfter(SourceMgr, Fixes, EndTemplate, Qualifier);
-  // Remove the qualifier.
-  removeToken(SourceMgr, Fixes, Tok);
-  return Tok;
-}
-  } else if (Tok->startsSequence(QualifierType, tok::identifier)) {
+// `const ArrayRef a;`
+// `const ArrayRef `
+const FormatToken *NewTok = AnalyzeTemplate(Tok, Tok->Next->Next);
+if (NewTok)
+  return NewTok;
+  } else if (Tok->startsSequence(QualifierType, tok::coloncolon,
+ tok::identifier, TT_TemplateOpener)) {
+// `const ::ArrayRef a;`
+// `const ::ArrayRef `
+const FormatToken *NewTok = AnalyzeTemplate(Tok, Tok->Next->Next->Next);
+if (NewTok)
+

[PATCH] D124093: [PowerPC] Fixing implicit castings in altivec for -fno-lax-vector-conversions

2022-05-20 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

I was wondering where are the test cases in this patch. Did they get missed 
when updating the revision?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124093

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


[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

2022-05-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish updated this revision to Diff 431067.
sunfish added a comment.

Add tests for -mcpu=mvp and -mcpu=bleeding-edge.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125728

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/test/Driver/wasm-features.c


Index: clang/test/Driver/wasm-features.c
===
--- clang/test/Driver/wasm-features.c
+++ clang/test/Driver/wasm-features.c
@@ -0,0 +1,43 @@
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | 
FileCheck %s
+
+// CHECK: "-fvisibility" "hidden"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=mvp 2>&1 | 
FileCheck %s -check-prefix=MVP
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=bleeding-edge 
2>&1 | FileCheck %s -check-prefix=BLEEDING-EDGE
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | 
FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-bulk-memory 2>&1 | 
FileCheck %s -check-prefix=NO-BULK-MEMORY
+
+// BULK-MEMORY: "-target-feature" "+bulk-memory"
+// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
+// DEFAULT-NOT: "-target-feature" "-bulk-memory"
+// MVP-NOT: "-target-feature" "+bulk-memory"
+// BLEEDING-EDGE-NOT: "-target-feature" "-bulk-memory"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 
| FileCheck %s -check-prefix=MUTABLE-GLOBALS
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-mutable-globals 
2>&1 | FileCheck %s -check-prefix=NO-MUTABLE-GLOBALS
+
+// MUTABLE-GLOBALS: "-target-feature" "+mutable-globals"
+// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
+// DEFAULT-NOT: "-target-feature" "-mutable-globals"
+// MVP-NOT: "-target-feature" "+mutable-globals"
+// BLEEDING-EDGE-NOT: "-target-feature" "-mutable-globals"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | 
FileCheck %s -check-prefix=SIGN-EXT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-sign-ext 2>&1 | 
FileCheck %s -check-prefix=NO-SIGN-EXT
+
+// SIGN-EXT: "-target-feature" "+sign-ext"
+// NO-SIGN-EXT: "-target-feature" "-sign-ext"
+// DEFAULT-NOT: "-target-feature" "-sign-ext"
+// MVP-NOT: "-target-feature" "+sign-ext"
+// BLEEDING-EDGE-NOT: "-target-feature" "-sign-ext"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 
2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 
-mno-nontrapping-fptoint 2>&1 | FileCheck %s 
-check-prefix=NO-NONTRAPPING-FPTOINT
+
+// NONTRAPPING-FPTOINT: "-target-feature" "+nontrapping-fptoint"
+// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
+// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
+// MVP-NOT: "-target-feature" "+nontrapping-fptoint"
+// BLEEDING-EDGE-NOT: "-target-feature" "-nontrapping-fptoint"
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -147,6 +147,11 @@
 Features["mutable-globals"] = true;
 Features["tail-call"] = true;
 setSIMDLevel(Features, SIMD128, true);
+  } else if (CPU == "generic") {
+Features["nontrapping-fptoint"] = true;
+Features["sign-ext"] = true;
+Features["bulk-memory"] = true;
+Features["mutable-globals"] = true;
   }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -437,6 +437,13 @@
 X86 Support in Clang
 
 
+WebAssembly Support in Clang
+
+
+The -mcpu=generic configuration now enables nontrapping-fptoint, sign-ext,
+bulk-memory, and mutable-globals. These proposals are standardized and
+available in all major engines.
+
 DWARF Support in Clang
 --
 


Index: clang/test/Driver/wasm-features.c
===
--- clang/test/Driver/wasm-features.c
+++ clang/test/Driver/wasm-features.c
@@ -0,0 +1,43 @@
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: "-fvisibility" "hidden"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=mvp 2>&1 | FileCheck %s -check-prefix=MVP
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=bleeding-edge 2>&1 | FileCheck %s -check-prefix=BLEEDING-EDGE
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 

[PATCH] D126024: [MSVC, ARM64] Add __readx18 intrinsics

2022-05-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D126024/new/

https://reviews.llvm.org/D126024

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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D126023/new/

https://reviews.llvm.org/D126023

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


[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

2022-05-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish updated this revision to Diff 431064.
sunfish added a comment.

Add a driver test, and add release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125728

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/test/Driver/wasm-features.c


Index: clang/test/Driver/wasm-features.c
===
--- clang/test/Driver/wasm-features.c
+++ clang/test/Driver/wasm-features.c
@@ -0,0 +1,33 @@
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | 
FileCheck %s
+
+// CHECK: "-fvisibility" "hidden"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | 
FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-bulk-memory 2>&1 | 
FileCheck %s -check-prefix=NO-BULK-MEMORY
+
+// BULK-MEMORY: "-target-feature" "+bulk-memory"
+// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
+// DEFAULT-NOT: "-target-feature" "-bulk-memory"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 
| FileCheck %s -check-prefix=MUTABLE-GLOBALS
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-mutable-globals 
2>&1 | FileCheck %s -check-prefix=NO-MUTABLE-GLOBALS
+
+// MUTABLE-GLOBALS: "-target-feature" "+mutable-globals"
+// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
+// DEFAULT-NOT: "-target-feature" "-mutable-globals"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | 
FileCheck %s -check-prefix=SIGN-EXT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-sign-ext 2>&1 | 
FileCheck %s -check-prefix=NO-SIGN-EXT
+
+// SIGN-EXT: "-target-feature" "+sign-ext"
+// NO-SIGN-EXT: "-target-feature" "-sign-ext"
+// DEFAULT-NOT: "-target-feature" "-sign-ext"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 
2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 
-mno-nontrapping-fptoint 2>&1 | FileCheck %s 
-check-prefix=NO-NONTRAPPING-FPTOINT
+
+// NONTRAPPING-FPTOINT: "-target-feature" "+nontrapping-fptoint"
+// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
+// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -147,6 +147,11 @@
 Features["mutable-globals"] = true;
 Features["tail-call"] = true;
 setSIMDLevel(Features, SIMD128, true);
+  } else if (CPU == "generic") {
+Features["nontrapping-fptoint"] = true;
+Features["sign-ext"] = true;
+Features["bulk-memory"] = true;
+Features["mutable-globals"] = true;
   }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -437,6 +437,13 @@
 X86 Support in Clang
 
 
+WebAssembly Support in Clang
+
+
+The -mcpu=generic configuration now enables nontrapping-fptoint, sign-ext,
+bulk-memory, and mutable-globals. These proposals are standardized and
+available in all major engines.
+
 DWARF Support in Clang
 --
 


Index: clang/test/Driver/wasm-features.c
===
--- clang/test/Driver/wasm-features.c
+++ clang/test/Driver/wasm-features.c
@@ -0,0 +1,33 @@
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: "-fvisibility" "hidden"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-bulk-memory 2>&1 | FileCheck %s -check-prefix=NO-BULK-MEMORY
+
+// BULK-MEMORY: "-target-feature" "+bulk-memory"
+// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
+// DEFAULT-NOT: "-target-feature" "-bulk-memory"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 | FileCheck %s -check-prefix=MUTABLE-GLOBALS
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-mutable-globals 2>&1 | FileCheck %s -check-prefix=NO-MUTABLE-GLOBALS
+
+// MUTABLE-GLOBALS: "-target-feature" "+mutable-globals"
+// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
+// DEFAULT-NOT: "-target-feature" "-mutable-globals"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: 

[PATCH] D126093: Sema: adjust assertion to account for deduced types

2022-05-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added a reviewer: aaron.ballman.
compnerd added a project: clang.
Herald added a project: All.
compnerd requested review of this revision.

Previous changes for the BTF attributes introduced a new sub-tree
visitation.  That uncovered that when accessing the typespec location we
would assert that the type specification is either a type declaration or
`typename`.  However, `typename` was explicitly permitted.  This change
predates the introduction of newer deduced type representations such as
`__underlying_type` from C++ and the addition of the GNU `__typeof__`
expression.

Thanks to aaron.ballman for the valuable discussion and pointer to
`isTypeRep`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126093

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/test/Sema/typerep-typespec.c


Index: clang/test/Sema/typerep-typespec.c
===
--- /dev/null
+++ clang/test/Sema/typerep-typespec.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c11 -x c %s -fsyntax-only -verify
+// REQUIRES: asserts
+
+struct dispatch_object_s;
+void _dispatch_queue_get_head(struct dispatch_object_s * volatile 
dq_items_head) {
+  (_Atomic __typeof__(dq_items_head) *)0; // expected-warning{{expression 
result unused}}
+}
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -516,7 +516,8 @@
   SourceLocation getTypeSpecSatLoc() const { return TSSatLoc; }
 
   SourceLocation getTypeSpecTypeNameLoc() const {
-assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
+assert(isDeclRep((TST)TypeSpecType) || isTypeRep((TST)TypeSpecType) ||
+   isExprRep((TST)TypeSpecType));
 return TSTNameLoc;
   }
 


Index: clang/test/Sema/typerep-typespec.c
===
--- /dev/null
+++ clang/test/Sema/typerep-typespec.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c11 -x c %s -fsyntax-only -verify
+// REQUIRES: asserts
+
+struct dispatch_object_s;
+void _dispatch_queue_get_head(struct dispatch_object_s * volatile dq_items_head) {
+  (_Atomic __typeof__(dq_items_head) *)0; // expected-warning{{expression result unused}}
+}
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -516,7 +516,8 @@
   SourceLocation getTypeSpecSatLoc() const { return TSSatLoc; }
 
   SourceLocation getTypeSpecTypeNameLoc() const {
-assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
+assert(isDeclRep((TST)TypeSpecType) || isTypeRep((TST)TypeSpecType) ||
+   isExprRep((TST)TypeSpecType));
 return TSTNameLoc;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125350: [RFC][Clang] Add a check if the target supports atomicrmw instruction with specific operator and type

2022-05-20 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 abandoned this revision.
tianshilei1992 added a comment.

Do it in BE.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125350

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


[PATCH] D124836: [AArch64] Add support for -fzero-call-used-regs

2022-05-20 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D124836#3528521 , @vvereschaka 
wrote:

> got it. Yes, looks like it fixed. The test got passed during the last build: 
> https://lab.llvm.org/buildbot/#/builders/104/builds/7812
> Thank you.

I'm sorry for the failure. I thought I had reverted the offending change, but 
didn't push it. :-/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124836

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


[PATCH] D125911: [pseudo] (trivial) bracket-matching

2022-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/pseudo/unittests/BracketTest.cpp:103
+TEST(Bracket, SimplePair) {
+  verifyBrackets("^{ ^[ ^( ^)  ^( ^) ^] ^}");
+  verifyBrackets(") ^{ ^[ ^] ^} (");

hokein wrote:
> For this simple case, just using `^` is fine.
> 
> I think in the near future, we would need more to verify that e.g. which two 
> brackets are paired. And since we're defining some  some common functions 
> used by the tests, I wonder what's the plan here (using something like `{ 
> $1^( $1^)`?)
> I think in the near future, we would need more to verify that e.g. which two 
> brackets are paired.

I thought about the simplest way to specify these tests, and I think the `^` is 
sufficient.

The combination of:
a) the set of brackets that are paired
b) for each bracket, knowing whether it is paired forwards or backwards
c) certainty that brackets are well-nested
fully determines the bracket pairing.

The test specifies a) and we check it, and b) and c) can be verified with no 
extra information.

Does this make sense? It's a little implicit, but makes the testcases much more 
readable than having to specifiy `$1^` etc.
If so, I'll explain this in a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125911

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


[PATCH] D124836: [AArch64] Add support for -fzero-call-used-regs

2022-05-20 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

got it. Yes, looks like it fixed. The test got passed during the last build: 
https://lab.llvm.org/buildbot/#/builders/104/builds/7812
Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124836

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


[PATCH] D124836: [AArch64] Add support for -fzero-call-used-regs

2022-05-20 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D124836#3528109 , @vvereschaka 
wrote:

> Hi @void ,
>
> the `zero-call-used-regs.ll` test gets failed on 
> `llvm-clang-x86_64-expensive-checks-ubuntu` builder with the following errors:
>
>   ...
>   *** Bad machine code: Illegal physical register for instruction ***
>   - function:all_arg
>   - basic block: %bb.0 entry (0x555be568bb88)
>   - instruction: $q0 = MOVID 0
>   - operand 0:   $q0
>   $q0 is not a FPR64 register.
>   ...

I think this is actually the verifier highlighting a codegen issue with the 
patch. Looks like it just got fixed though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124836

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


[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/check_clang_tidy.py:31
+  -std=c++(98|11|14|17|20)[-or-later]:
+This flag will cause multiple runs within the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.

It's only the `-or-later` variants that cause multiple runs, so we should 
explain this more explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125771

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


[PATCH] D125911: [pseudo] (trivial) bracket-matching

2022-05-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, this looks a good start version!




Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Bracket.h:9
+//
+// Bracket structure (particularly brackes) is key to isolating broken regions
+// of code and preventing parsing from going "off the rails".

brackes => braces



Comment at: clang-tools-extra/pseudo/lib/Bracket.cpp:84
+// Find brackets in the stream and convert to Bracket struct.
+std::vector parseBrackets(const TokenStream ) {
+  std::vector Brackets;

this is not really parsing, maybe `findBrackets`?



Comment at: clang-tools-extra/pseudo/unittests/BracketTest.cpp:103
+TEST(Bracket, SimplePair) {
+  verifyBrackets("^{ ^[ ^( ^)  ^( ^) ^] ^}");
+  verifyBrackets(") ^{ ^[ ^] ^} (");

For this simple case, just using `^` is fine.

I think in the near future, we would need more to verify that e.g. which two 
brackets are paired. And since we're defining some  some common functions used 
by the tests, I wonder what's the plan here (using something like `{ $1^( 
$1^)`?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125911

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


[clang] acec070 - [OpenMP] Fix partial unrolling off-by-one.

2022-05-20 Thread Michael Kruse via cfe-commits

Author: Michael Kruse
Date: 2022-05-20T15:19:52-05:00
New Revision: acec07005e038ab2891f235ae60ba2f0236bb952

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

LOG: [OpenMP] Fix partial unrolling off-by-one.

Even though the comment description is ".unroll_inner.iv < NumIterations", the 
code emitted a BO_LE ('<=') operator for the inner loop that is to be unrolled. 
This lead to one additional copy of the body code in a partially unrolled. It 
only manifests when the unrolled loop is consumed by another loop-associated 
construct. Fix by using the BO_LT operator instead.

The condition for the outer loop and the corresponding code for tiling 
correctly used BO_LT already.

Fixes #55236

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
clang/test/OpenMP/unroll_codegen_for_partial.cpp
clang/test/OpenMP/unroll_codegen_parallel_for_factor.cpp
clang/test/OpenMP/unroll_codegen_tile_for.cpp
clang/test/OpenMP/unroll_codegen_unroll_for.cpp
clang/test/OpenMP/unroll_codegen_unroll_for_attr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index e4305ba8c1718..42c3dbc181911 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14483,11 +14483,11 @@ StmtResult 
Sema::ActOnOpenMPUnrollDirective(ArrayRef Clauses,
   if (!EndOfTile.isUsable())
 return StmtError();
   ExprResult InnerCond1 = BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(),
- BO_LE, MakeInnerRef(), EndOfTile.get());
+ BO_LT, MakeInnerRef(), EndOfTile.get());
   if (!InnerCond1.isUsable())
 return StmtError();
   ExprResult InnerCond2 =
-  BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LE, 
MakeInnerRef(),
+  BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT, 
MakeInnerRef(),
  MakeNumIterations());
   if (!InnerCond2.isUsable())
 return StmtError();

diff  --git a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c 
b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
index 0bfed911077bf..94d7a14a0bb87 100644
--- a/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
+++ b/clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
@@ -106,12 +106,12 @@
 // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 
4
 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 4
-// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]]
+// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]]
 // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label 
%[[LAND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_RHS]]:
 // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
-// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8
+// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8
 // CHECK-NEXT:br label %[[LAND_END]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_END]]:

diff  --git 
a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c 
b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
index 1a2bd117bf98c..c44b2b3202694 100644
--- a/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
+++ b/clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
@@ -114,12 +114,12 @@ double sind(double);
 // CHECK-NEXT:%[[TMP15:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
 // CHECK-NEXT:%[[TMP16:.+]] = load i32, i32* %[[DOTUNROLLED_IV_J7]], align 
4
 // CHECK-NEXT:%[[ADD21:.+]] = add nsw i32 %[[TMP16]], 2
-// CHECK-NEXT:%[[CMP22:.+]] = icmp sle i32 %[[TMP15]], %[[ADD21]]
+// CHECK-NEXT:%[[CMP22:.+]] = icmp slt i32 %[[TMP15]], %[[ADD21]]
 // CHECK-NEXT:br i1 %[[CMP22]], label %[[LAND_RHS:.+]], label 
%[[LAND_END:.+]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_RHS]]:
 // CHECK-NEXT:%[[TMP17:.+]] = load i32, i32* %[[DOTUNROLL_INNER_IV_J]], 
align 4
-// CHECK-NEXT:%[[CMP24:.+]] = icmp sle i32 %[[TMP17]], 8
+// CHECK-NEXT:%[[CMP24:.+]] = icmp slt i32 %[[TMP17]], 8
 // CHECK-NEXT:br label %[[LAND_END]]
 // CHECK-EMPTY:
 // CHECK-NEXT:  [[LAND_END]]:

diff  --git a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp 
b/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
index cafda811d0d0c..693cbf851b991 100644
--- a/clang/test/OpenMP/unroll_codegen_for_collapse_outer.cpp
+++ 

[clang] ade5b55 - Add a page to track C defect report status

2022-05-20 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-05-20T16:07:48-04:00
New Revision: ade5b55af5747413dab8dd57896532fdee19cdf5

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

LOG: Add a page to track C defect report status

We currently have a page for tracking defects against the C++ standard,
but we don't have the same information for the C standard. This starts
us down the path of being able to track that in a way our users can see.

There are *a lot* of entries marked as "Unknown". As we validate
Clang's behavior for a given DR by adding a test case for it, we can
slowly begin to improve this page over time.

This page is now linked from the existing C status page, which was
updated slightly as a result of these changes as well.

Note, unlike with the C++ defect report page, this content is not auto-
generated from a source document and is not automatically updated from
test comments. It may be worthwhile to automate the updates based on
our test coverage, but that can happen later.

Added: 
clang/www/c_dr_status.html

Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
new file mode 100644
index 0..b92cf60604955
--- /dev/null
+++ b/clang/www/c_dr_status.html
@@ -0,0 +1,2620 @@
+http://www.w3.org/TR/html4/strict.dtd;>
+
+
+  
+  Clang - C Defect Report Status
+  
+  
+  
+.none { background-color: #FF }
+.partial { background-color: #FFE0B0 }
+.unreleased { background-color: #99 }
+.full { background-color: #CCFF99 }
+.na { background-color: #DD }
+.unknown { background-color: #FF55FF }
+.open * { color: #AA }
+//.open { filter: opacity(0.2) }
+tr:target { background-color: #BB }
+th { background-color: #FFDDAA }
+  
+
+
+
+
+
+
+
+
+C Defect Report Support in Clang
+
+
+C defect report implementation status
+
+This page tracks which C defect reports are implemented within Clang.
+
+The implementation status for defect reports against the C Standard are
+currently under investigation. Any defect report whose status in Clang is
+currently unknown will be marked in magenta.
+
+The https://github.com/llvm/llvm-project/issues/;>LLVM bug 
tracker uses
+the "c", "c99", "c11", "c17", and "c2x" labels to track known bugs with 
Clang's language
+conformance.
+
+
+  
+Number
+Status
+Issue title
+Available in Clang?
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_001.html;>1
+C89
+Do functions return values by copying?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_002.html;>2
+NAD
+Subclause 6.8.3.2: Semantics of #
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_003.html;>3
+NAD
+Subclause 6.1.8: Preprocessing numbers
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_004.html;>4
+NAD
+Are multiple definitions of unused identifiers with external linkage 
permitted?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_005.html;>5
+C89
+May a conforming implementation define and recognize a pragma which 
would change the semantics of the language?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_006.html;>7
+C89
+It is unclear how the strtoul function behaves when presented with a 
subject sequence that begins with a minus sign
+N/A
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_007.html;>7
+NAD
+Are declarations of the form struct-or-union identifier ; permitted 
after the identifier tag has already been declared?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_008.html;>8
+NAD
+Can a conforming C compiler to perform dead-store elimination?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_009.html;>9
+C89
+Use of typedef names in parameter declarations
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_010.html;>10
+NAD
+Is a typedef to an incomplete type legal?
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_011.html;>11
+C89
+Merging of declarations for linked identifier
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_012.html;>12
+NAD
+Questions on the validity of various expressions
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_013.html;>13
+C89
+Compatible and composite function types
+Unknown
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_014.html;>14
+C89
+Issues with setjmp and fscanf descriptions
+N/A
+  
+  
+

[PATCH] D125506: [PowerPC] Implement XL compat __fnabs and __fnabss builtins.

2022-05-20 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added subscribers: nickdesaulniers, nathanchance.
nathanchance added a comment.

I bisected a crash when compiling the Linux kernel to this change.

A reduced C reproducer:

  enum {
OP_CB_GETATTR = 3,
OP_CB_RECALL,
OP_CB_RECALL_ANY = 8,
OP_CB_RECALL_SLOT = 10,
OP_CB_NOTIFY_LOCK = 13,
OP_CB_NOTIFY_DEVICEID,
OP_CB_OFFLOAD
  } static callback_ops_0;
  int preprocess_nfs42_op_op_nr, preprocess_nfs42_op_op;
  void preprocess_nfs42_op() {
switch (preprocess_nfs42_op_op_nr)
case OP_CB_GETATTR:
case OP_CB_RECALL:
case OP_CB_RECALL_ANY:
case OP_CB_RECALL_SLOT:
case OP_CB_NOTIFY_DEVICEID:
case OP_CB_NOTIFY_LOCK:
  preprocess_nfs42_op_op = preprocess_nfs42_op_op_nr;
if (preprocess_nfs42_op_op_nr == OP_CB_OFFLOAD)
  preprocess_nfs42_op_op = callback_ops_0;
  }



  $ clang --version | head -1
  ClangBuiltLinux clang version 15.0.0 (https://github.com/llvm/llvm-project 
559b8fc17ef6f5a65ccf9a11fce5f91c0a011b00)
  
  $ clang --target=powerpc64le-linux-gnu -O2 -Wall -Wextra -c -o /dev/null 
callback_xdr.i



  $ clang --version | head -1
  ClangBuiltLinux clang version 15.0.0 (https://github.com/llvm/llvm-project 
c35ca3a1c78f693b749ad11742350b7fc6c5cd89)
  
  $ clang --target=powerpc64le-linux-gnu -O2 -Wall -Wextra -c -o /dev/null 
callback_xdr.i
  Impossible reg-to-reg copy
  UNREACHABLE executed at 
/home/nathan/cbl/src/llvm-project/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1861!
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: clang --target=powerpc64le-linux-gnu -O2 -Wall 
-Wextra -c -o /dev/null callback_xdr.i
  1.   parser at end of file
  2.  Code generation
  3.  Running pass 'Function Pass Manager' on module 'callback_xdr.i'.
  4.  Running pass 'Post-RA pseudo instruction expansion pass' on function 
'@preprocess_nfs42_op'
   #0 0x55a3bcb4e583 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x3351583)
   #1 0x55a3bcb4c50e llvm::sys::RunSignalHandlers() 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x334f50e)
   #2 0x55a3bcad2923 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
CrashRecoveryContext.cpp:0:0
   #3 0x55a3bcad2a9e CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #4 0x7f4af3152b00 __restore_rt (/lib64/libc.so.6+0x3eb00)
   #5 0x7f4af31a2d0c __pthread_kill_implementation 
(/lib64/libc.so.6+0x8ed0c)
   #6 0x7f4af3152a56 gsignal (/lib64/libc.so.6+0x3ea56)
   #7 0x7f4af313c7f4 abort (/lib64/libc.so.6+0x287f4)
   #8 0x55a3bcad787f 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x32da87f)
   #9 0x55a3bb83b308 
llvm::PPCInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, 
llvm::MachineInstrBundleIterator, llvm::DebugLoc 
const&, llvm::MCRegister, llvm::MCRegister, bool) const PPCInstrInfo.cpp:0:0
  #10 0x55a3bc1242bb (anonymous 
namespace)::ExpandPostRA::runOnMachineFunction(llvm::MachineFunction&) 
ExpandPostRAPseudos.cpp:0:0
  #11 0x55a3bbf62d4d 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x2765d4d)
  #12 0x55a3bc3fc107 llvm::FPPassManager::runOnFunction(llvm::Function&) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x2bff107)
  #13 0x55a3bc403b81 llvm::FPPassManager::runOnModule(llvm::Module&) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x2c06b81)
  #14 0x55a3bc3fcafc llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x2bffafc)
  #15 0x55a3bd2fd16d clang::EmitBackendOutput(clang::DiagnosticsEngine&, 
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, 
clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, 
llvm::Module*, clang::BackendAction, std::unique_ptr>) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x3b0016d)
  #16 0x55a3bd6a27ee 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) 
CodeGenAction.cpp:0:0
  #17 0x55a3bdf46cb4 clang::ParseAST(clang::Sema&, bool, bool) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x4749cb4)
  #18 0x55a3bd5f0f50 clang::FrontendAction::Execute() 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x3df3f50)
  #19 0x55a3bd565d1f 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x3d68d1f)
  #20 0x55a3bd69be92 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
(/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x3e9ee92)
  #21 0x55a3bb785028 cc1_main(llvm::ArrayRef, char const*, 
void*) (/home/nathan/tmp/build/llvm-bisect/stage1/bin/clang-15+0x1f88028)
  #22 0x55a3bb782f2f 

[PATCH] D125770: [clang-tidy] modernize-deprecated-headers should ignore system headers

2022-05-20 Thread Balázs Benics 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 rG6fa82e344c29: [clang-tidy] modernize-deprecated-headers 
should ignore system headers (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125770

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@
 #include 
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has 
no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include  // FIXME: We should have no warning into system 
headers.
-// CHECK-MESSAGES-CHECK-HEADER-FILE: mysystemlib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]
+#include  // no-warning: Don't warn into system headers.
 
 #include 
 // CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -188,6 +188,10 @@
   if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
 return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@
 #include 
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include  // FIXME: We should have no warning into system headers.
-// CHECK-MESSAGES-CHECK-HEADER-FILE: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+#include  // no-warning: Don't warn into system headers.
 
 #include 
 // CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -188,6 +188,10 @@
   if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
 return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125769: [clang-tidy] Introduce the CheckHeaderFile option to modernize-deprecated-headers

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
steakhal marked an inline comment as done.
Closed by commit rG0606467ea122: [clang-tidy] Introduce the WarnIntoHeaders 
option to modernize-deprecated… (authored by steakhal).

Changed prior to commit:
  https://reviews.llvm.org/D125769?vs=430303=431029#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125769

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -8,6 +8,13 @@
 // RUN:   && cp %S/Inputs/modernize-deprecated-headers/mylib.h   %t/usr/mylib.h
 
 // RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   -check-suffixes=DEFAULT \
+// RUN:   --header-filter='.*' --system-headers \
+// RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
+
+// RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   -check-suffixes=DEFAULT,CHECK-HEADER-FILE \
+// RUN:   -config="{CheckOptions: [{key: modernize-deprecated-headers.CheckHeaderFile, value: 'true'}]}" \
 // RUN:   --header-filter='.*' --system-headers \
 // RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
 
@@ -18,20 +25,20 @@
 extern "C++" {
 // We should still have the warnings here.
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 }
 
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 #include 
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
 
 #include  // FIXME: We should have no warning into system headers.
-// CHECK-MESSAGES: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-CHECK-HEADER-FILE: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 #include 
-// CHECK-MESSAGES: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+// CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
 
 namespace wrapping {
 extern "C" {
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst
@@ -10,6 +10,17 @@
 This check replaces C standard library headers with their C++ alternatives and
 removes redundant ones.
 
+.. code-block:: c++
+
+  // C++ source file...
+  #include 
+  #include 
+
+  // becomes
+
+  #include 
+  // No 'stdbool.h' here.
+
 Important note: the Standard doesn't guarantee that the C++ headers declare all
 the same functions in the global namespace. The check in its current form can
 break the code that uses library symbols from the global namespace.
@@ -47,3 +58,26 @@
 * ``
 * ``
 * ``
+
+The checker ignores `include` directives within `extern "C" { ... }` blocks,
+since a library might want to expose some API for C and C++ libraries.
+
+.. code-block:: c++
+
+  // C++ source file...
+  extern "C" {
+  #include   // Left intact.
+  #include  // Left intact.
+  }
+
+Options
+---
+
+.. option:: CheckHeaderFile
+
+   `clang-tidy` cannot know if the header file included by the 

[clang-tools-extra] 6fa82e3 - [clang-tidy] modernize-deprecated-headers should ignore system headers

2022-05-20 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-05-20T21:41:25+02:00
New Revision: 6fa82e344c291cf0e1134b357b1f09fd2dcd3f4f

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

LOG: [clang-tidy] modernize-deprecated-headers should ignore system headers

The end-user has no way of 'fixing' bugs in the system library anyway.
Let's suppress these as well.

Reviewed By: LegalizeAdulthood

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 72508a99e4a1..64e70ad746c5 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -188,6 +188,10 @@ void IncludeModernizePPCallbacks::InclusionDirective(
   if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
 return;
 
+  // Ignore system headers.
+  if (SM.isInSystemHeader(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
index 98d66ce00ceb..1193c2ad0a99 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -34,8 +34,7 @@ extern "C++" {
 #include 
 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has 
no effect in C++; consider removing it [modernize-deprecated-headers]
 
-#include  // FIXME: We should have no warning into system 
headers.
-// CHECK-MESSAGES-CHECK-HEADER-FILE: mysystemlib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]
+#include  // no-warning: Don't warn into system headers.
 
 #include 
 // CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of 
deprecated C++ header 'assert.h'; consider using 'cassert' instead 
[modernize-deprecated-headers]



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


[clang-tools-extra] 0606467 - [clang-tidy] Introduce the WarnIntoHeaders option to modernize-deprecated-headers

2022-05-20 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-05-20T21:41:25+02:00
New Revision: 0606467ea122da5cb23a588e1222a4140445734a

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

LOG: [clang-tidy] Introduce the WarnIntoHeaders option to 
modernize-deprecated-headers

Unfortunately, we must restrict the checker to warn for deprecated headers
only if the header is included directly from a c++ source file.

For header files, we cannot know if the project has a C source file
that also directly/indirectly includes the offending header file
otherwise. Thus, it's better to be on the safe side and suppress those
reports.

One can opt-in the old behavior, emitting diagnostics into header files,
if one explicitly sets the WarnIntoHeaders=true, in which case nothing
will be changed.

Reviewed By: LegalizeAdulthood

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-deprecated-headers.rst

clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index ee78747d397ff..72508a99e4a1a 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -27,7 +27,8 @@ namespace {
 class IncludeModernizePPCallbacks : public PPCallbacks {
 public:
   explicit IncludeModernizePPCallbacks(
-  std::vector , LangOptions LangOpts);
+  std::vector , LangOptions LangOpts,
+  const SourceManager , bool CheckHeaderFile);
 
   void InclusionDirective(SourceLocation HashLoc, const Token ,
   StringRef FileName, bool IsAngled,
@@ -41,6 +42,8 @@ class IncludeModernizePPCallbacks : public PPCallbacks {
   LangOptions LangOpts;
   llvm::StringMap CStyledHeaderToCxx;
   llvm::StringSet<> DeleteHeaders;
+  const SourceManager 
+  bool CheckHeaderFile;
 };
 
 class ExternCRefutationVisitor
@@ -75,12 +78,18 @@ class ExternCRefutationVisitor
 
 DeprecatedHeadersCheck::DeprecatedHeadersCheck(StringRef Name,
ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+  CheckHeaderFile(Options.get("CheckHeaderFile", false)) {}
+
+void DeprecatedHeadersCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "CheckHeaderFile", CheckHeaderFile);
+}
 
 void DeprecatedHeadersCheck::registerPPCallbacks(
 const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
   PP->addPPCallbacks(std::make_unique(
-  IncludesToBeProcessed, getLangOpts()));
+  IncludesToBeProcessed, getLangOpts(), PP->getSourceManager(),
+  CheckHeaderFile));
 }
 void DeprecatedHeadersCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
@@ -124,8 +133,10 @@ void DeprecatedHeadersCheck::check(
 }
 
 IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(
-std::vector , LangOptions LangOpts)
-: IncludesToBeProcessed(IncludesToBeProcessed), LangOpts(LangOpts) {
+std::vector , LangOptions LangOpts,
+const SourceManager , bool CheckHeaderFile)
+: IncludesToBeProcessed(IncludesToBeProcessed), LangOpts(LangOpts), SM(SM),
+  CheckHeaderFile(CheckHeaderFile) {
   for (const auto  :
std::vector>(
{{"assert.h", "cassert"},
@@ -171,6 +182,12 @@ void IncludeModernizePPCallbacks::InclusionDirective(
 bool IsAngled, CharSourceRange FilenameRange, Optional File,
 StringRef SearchPath, StringRef RelativePath, const Module *Imported,
 SrcMgr::CharacteristicKind FileType) {
+
+  // If we don't want to warn for non-main file reports and this is one, skip
+  // it.
+  if (!CheckHeaderFile && !SM.isInMainFile(HashLoc))
+return;
+
   // FIXME: Take care of library symbols from the global namespace.
   //
   // Reasonable options for the check:

diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
index 2af626d42129b..e5023c3f47ed5 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
@@ -38,6 +38,7 @@ class DeprecatedHeadersCheck : public ClangTidyCheck {
   bool isLanguageVersionSupported(const LangOptions ) const override {
 return LangOpts.CPlusPlus;
   }
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void 

[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 431028.
steakhal marked 2 inline comments as done.
steakhal added a comment.

Generalized the flag help text to all supported standard versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125771

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=c++(98|11|14|17|20)[-or-later]] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++(98|11|14|17|20)[-or-later]:
+This flag will cause multiple runs within the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -19,11 +19,17 @@
 [-assume-filename=] \
 [-check-suffix=] \
 [-check-suffixes=] \
+[-std=c++(98|11|14|17|20)[-or-later]] \
\
 -- [optional clang-tidy arguments]
 
 Example:
   // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs
+
+Notes:
+  -std=c++(98|11|14|17|20)[-or-later]:
+This flag will cause multiple runs within the same check_clang_tidy
+execution. Make sure you don't have shared state across these runs.
 """
 
 import argparse
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-05-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:418
+  if (const auto *ME = dyn_cast(E))
+if (const auto *TE = dyn_cast(ME->getBase()))
+  if (TE->isImplicit())

sammccall wrote:
> dgoldman wrote:
> > sammccall wrote:
> > > oops, I forgot one detail: we want ME->getBase()->IgnoreImpCasts()
> > > 
> > > (in `void nonConstMethod() { constMethod(); }` there's an 
> > > ImplicitCastExpr in there...
> > Hmm, is this right, I tested out that example and it seems like that's 
> > actually a `CXXMemberCallExpr` which this doesn't handle?
> The callee of the CXXMemberCallExpr is the MemberExpr i'm talking about here.
Right but this code here doesn't handle CXXMemberCallExpr, only MemberExpr - so 
we don't even see the callee here. If I add the following above:

```
  if (const auto *MCE = dyn_cast(E))
E = MCE->getCallee();
```

and do `ME->getBase()->IgnoreImpCasts()` then:


```
class Test {
  int constMethod() const { return 1; }
  int nonConstMethod() { return [[constMethod()]]; }
};
```

will be unavailable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D126084: [Sema] Reject implicit conversions between different scoped enum types in list initialization

2022-05-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

The assertion `assert(FromType->isIntegralOrUnscopedEnumerationType())` in 
`StandardConversionSequence::getNarrowingKind` fails when the invalid 
initialization is performed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126084

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


[PATCH] D126084: [Sema] Reject implicit conversions between different scoped enum types in list initialization

2022-05-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, aaron.ballman.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

rdar://93660425


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126084

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/enum-scoped.cpp


Index: clang/test/SemaCXX/enum-scoped.cpp
===
--- clang/test/SemaCXX/enum-scoped.cpp
+++ clang/test/SemaCXX/enum-scoped.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple 
x86_64-apple-darwin %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++17 -verify -triple 
x86_64-apple-darwin %s
 
 enum class E1 {
   Val1 = 1L
@@ -31,10 +32,22 @@
 int x2 = Val2;
 
 int a1[Val2];
-int a2[E1::Val1]; // expected-error{{size of array has non-integer type}}
+int a2[E1::Val1];
+
+#if __cplusplus >= 201703L
+// expected-error@-3 {{type 'E1' is not implicitly convertible to 'unsigned 
long'}}
+#else
+// expected-error@-5 {{size of array has non-integer type}}
+#endif
 
 int* p1 = new int[Val2];
-int* p2 = new int[E1::Val1]; // expected-error{{array size expression must 
have integral or unscoped enumeration type, not 'E1'}}
+int* p2 = new int[E1::Val1];
+
+#if __cplusplus >= 201703L
+// expected-error@-3 {{converting 'E1' to incompatible type 'unsigned long'}}
+#else
+// expected-error@-5 {{array size expression must have integral or unscoped 
enumeration type, not 'E1'}}
+#endif
 
 enum class E4 {
   e1 = -2147483648, // ok
@@ -317,3 +330,11 @@
   enum C { R, G, B };
   enum B { F = (enum C) -1, T}; // this should compile cleanly, it used to 
assert.
 };
+
+namespace test12 {
+// Check that clang rejects this code without crashing in c++17.
+enum class A;
+enum class B;
+A a;
+B b{a}; // expected-error {{cannot initialize}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4503,7 +4503,7 @@
 Kind.getKind() == InitializationKind::IK_DirectList &&
 ET && ET->getDecl()->isFixed() &&
 !S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
-(E->getType()->isIntegralOrEnumerationType() ||
+(E->getType()->isIntegralOrUnscopedEnumerationType() ||
  E->getType()->isFloatingType())) {
   // There are two ways that T(v) can work when T is an enumeration type.
   // If there is either an implicit conversion sequence from v to T or


Index: clang/test/SemaCXX/enum-scoped.cpp
===
--- clang/test/SemaCXX/enum-scoped.cpp
+++ clang/test/SemaCXX/enum-scoped.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++17 -verify -triple x86_64-apple-darwin %s
 
 enum class E1 {
   Val1 = 1L
@@ -31,10 +32,22 @@
 int x2 = Val2;
 
 int a1[Val2];
-int a2[E1::Val1]; // expected-error{{size of array has non-integer type}}
+int a2[E1::Val1];
+
+#if __cplusplus >= 201703L
+// expected-error@-3 {{type 'E1' is not implicitly convertible to 'unsigned long'}}
+#else
+// expected-error@-5 {{size of array has non-integer type}}
+#endif
 
 int* p1 = new int[Val2];
-int* p2 = new int[E1::Val1]; // expected-error{{array size expression must have integral or unscoped enumeration type, not 'E1'}}
+int* p2 = new int[E1::Val1];
+
+#if __cplusplus >= 201703L
+// expected-error@-3 {{converting 'E1' to incompatible type 'unsigned long'}}
+#else
+// expected-error@-5 {{array size expression must have integral or unscoped enumeration type, not 'E1'}}
+#endif
 
 enum class E4 {
   e1 = -2147483648, // ok
@@ -317,3 +330,11 @@
   enum C { R, G, B };
   enum B { F = (enum C) -1, T}; // this should compile cleanly, it used to assert.
 };
+
+namespace test12 {
+// Check that clang rejects this code without crashing in c++17.
+enum class A;
+enum class B;
+A a;
+B b{a}; // expected-error {{cannot initialize}}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4503,7 +4503,7 @@
 Kind.getKind() == InitializationKind::IK_DirectList &&
 ET && ET->getDecl()->isFixed() &&
 !S.Context.hasSameUnqualifiedType(E->getType(), DestType) &&
-(E->getType()->isIntegralOrEnumerationType() ||
+(E->getType()->isIntegralOrUnscopedEnumerationType() ||
  E->getType()->isFloatingType())) {
   // There are two ways that T(v) can work when T is an enumeration type.
   // If there is either an implicit conversion sequence from v to T or
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 665bfbb - Reland "[clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks""

2022-05-20 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-05-20T21:12:39+02:00
New Revision: 665bfbb98daa0e40a2e6cecfbbfd6949980d8f2f

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

LOG: Reland "[clang-tidy] modernize-deprecated-headers check should respect 
extern "C" blocks""

This partially reverts commit e8cae487022c2216182ae1ec24f248f287a614b7.
Changes since that commit:
 - Use `SourceManager::isBeforeInTranslationUnit` instead of the fancy
   decomposed decl logarithmic search.
 - Add a test for including a system header containing a deprecated
   include.
 - Add `REQUIRES: system-linux` clause to the test.

Reviewed By: LegalizeAdulthood, whisperity

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h

clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h

clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 0b44bdaafe23e..ee78747d397ff 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -7,23 +7,27 @@
 
//===--===//
 
 #include "DeprecatedHeadersCheck.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 
+#include 
 #include 
 
+using IncludeMarker =
+clang::tidy::modernize::DeprecatedHeadersCheck::IncludeMarker;
 namespace clang {
 namespace tidy {
 namespace modernize {
-
 namespace {
+
 class IncludeModernizePPCallbacks : public PPCallbacks {
 public:
-  explicit IncludeModernizePPCallbacks(ClangTidyCheck ,
-   LangOptions LangOpts);
+  explicit IncludeModernizePPCallbacks(
+  std::vector , LangOptions LangOpts);
 
   void InclusionDirective(SourceLocation HashLoc, const Token ,
   StringRef FileName, bool IsAngled,
@@ -33,22 +37,95 @@ class IncludeModernizePPCallbacks : public PPCallbacks {
   SrcMgr::CharacteristicKind FileType) override;
 
 private:
-  ClangTidyCheck 
+  std::vector 
   LangOptions LangOpts;
   llvm::StringMap CStyledHeaderToCxx;
   llvm::StringSet<> DeleteHeaders;
 };
+
+class ExternCRefutationVisitor
+: public RecursiveASTVisitor {
+  std::vector 
+  const SourceManager 
+
+public:
+  ExternCRefutationVisitor(std::vector ,
+   SourceManager )
+  : IncludesToBeProcessed(IncludesToBeProcessed), SM(SM) {}
+  bool shouldWalkTypesOfTypeLocs() const { return false; }
+  bool shouldVisitLambdaBody() const { return false; }
+
+  bool VisitLinkageSpecDecl(LinkageSpecDecl *LinkSpecDecl) const {
+if (LinkSpecDecl->getLanguage() != LinkageSpecDecl::lang_c ||
+!LinkSpecDecl->hasBraces())
+  return true;
+
+auto ExternCBlockBegin = LinkSpecDecl->getBeginLoc();
+auto ExternCBlockEnd = LinkSpecDecl->getEndLoc();
+auto IsWrapped = [=,  = SM](const IncludeMarker ) -> bool {
+  return SM.isBeforeInTranslationUnit(ExternCBlockBegin, Marker.DiagLoc) &&
+ SM.isBeforeInTranslationUnit(Marker.DiagLoc, ExternCBlockEnd);
+};
+
+llvm::erase_if(IncludesToBeProcessed, IsWrapped);
+return true;
+  }
+};
 } // namespace
 
+DeprecatedHeadersCheck::DeprecatedHeadersCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
+
 void DeprecatedHeadersCheck::registerPPCallbacks(
 const SourceManager , Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
-PP->addPPCallbacks(
-::std::make_unique(*this, getLangOpts()));
+  PP->addPPCallbacks(std::make_unique(
+  IncludesToBeProcessed, getLangOpts()));
+}
+void DeprecatedHeadersCheck::registerMatchers(
+ast_matchers::MatchFinder *Finder) {
+  // Even though the checker operates on a "preprocessor" level, we still need
+  // to act on a "TranslationUnit" to acquire the AST where we can walk each
+  // Decl and look for `extern "C"` blocks where we will suppress the report we
+  // collected during the preprocessing phase.
+  // The `onStartOfTranslationUnit()` won't suffice, since we need some handle
+  // to 

[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG665bfbb98daa: Reland [clang-tidy] 
modernize-deprecated-headers check should respect extern… (authored by 
steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125209

Files:
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp
@@ -0,0 +1,66 @@
+
+// Copy the 'mylib.h' to a directory under the build directory. This is
+// required, since the relative order of the emitted diagnostics depends on the
+// absolute file paths which is sorted by clang-tidy prior emitting.
+//
+// RUN: mkdir -p %t/sys && mkdir -p %t/usr \
+// RUN:   && cp %S/Inputs/modernize-deprecated-headers/mysystemlib.h %t/sys/mysystemlib.h \
+// RUN:   && cp %S/Inputs/modernize-deprecated-headers/mylib.h   %t/usr/mylib.h
+
+// RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
+// RUN:   --header-filter='.*' --system-headers \
+// RUN:   -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/modernize-deprecated-headers
+
+// REQUIRES: system-linux
+
+#define EXTERN_C extern "C"
+
+extern "C++" {
+// We should still have the warnings here.
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+}
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+#include 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
+
+#include  // FIXME: We should have no warning into system headers.
+// CHECK-MESSAGES: mysystemlib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+#include 
+// CHECK-MESSAGES: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
+
+namespace wrapping {
+extern "C" {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+}
+} // namespace wrapping
+
+extern "C" {
+namespace wrapped {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+} // namespace wrapped
+}
+
+namespace wrapping {
+extern "C" {
+namespace wrapped {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+} // namespace wrapped
+}
+} // namespace wrapping
+
+EXTERN_C {
+#include   // no-warning
+#include// no-warning
+#include  // no-warning
+}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mysystemlib.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-deprecated-headers/mylib.h
@@ -0,0 +1 @@
+#include 
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -170,6 +170,11 @@
   ` involving assignments in
   conditions. This fixes `Issue 35853 `_.
 
+- Fixed a false positive in :doc:`modernize-deprecated-headers
+  ` involving including
+  C header files from C++ files wrapped by ``extern "C" { ... }`` blocks.
+  Such includes will be ignored by now.
+
 - Improved :doc:`performance-inefficient-vector-operation
   ` to work when
   the vector is a member of a structure.
Index: clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
+++ clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.h
@@ -34,13 +34,25 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-headers.html
 class 

[PATCH] D111548: [Clang] Add the `annotate_type` attribute

2022-05-20 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: clang/test/SemaCXX/annotate-type.cpp:2
+// RUN: %clang_cc1 %s -std=c++17 -fsyntax-only -verify
+
+struct S1 {

mboehme wrote:
> mboehme wrote:
> > rsmith wrote:
> > > mboehme wrote:
> > > > rsmith wrote:
> > > > > mboehme wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > mboehme wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > mboehme wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > > mboehme wrote:
> > > > > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > > > > Can you also add some test coverage for 
> > > > > > > > > > > > > > > > > applying the attribute to a declaration 
> > > > > > > > > > > > > > > > > instead of a type or not giving it any 
> > > > > > > > > > > > > > > > > arguments? Also, should test arguments which 
> > > > > > > > > > > > > > > > > are not a constant expression.
> > > > > > > > > > > > > > > > I've added tests as you suggested, though I put 
> > > > > > > > > > > > > > > > most of them in Sema/annotate-type.c, as 
> > > > > > > > > > > > > > > > they're not specific to C++.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Thanks for prompting me to do this -- the tests 
> > > > > > > > > > > > > > > > caused me to notice and fix a number of bugs.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > I haven't managed to diagnose the case when the 
> > > > > > > > > > > > > > > > attribute appears at the beginning of the 
> > > > > > > > > > > > > > > > declaration. It seems to me that, at the point 
> > > > > > > > > > > > > > > > where I've added the check, this case is 
> > > > > > > > > > > > > > > > indistinguishable from an attribute that 
> > > > > > > > > > > > > > > > appears on the type. In both cases, the `TAL` 
> > > > > > > > > > > > > > > > is `TAL_DeclSpec`, and the attribute is 
> > > > > > > > > > > > > > > > contained in `DeclSpec::getAttributes()`. This 
> > > > > > > > > > > > > > > > is because `Parser::ParseSimpleDeclaration` 
> > > > > > > > > > > > > > > > forwards the declaration attributes to the 
> > > > > > > > > > > > > > > > `DeclSpec`:
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseDecl.cpp#L1851
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > I believe if I wanted to prohibit this case, I 
> > > > > > > > > > > > > > > > would need to add a check to 
> > > > > > > > > > > > > > > > `Parser::ParseStatementOrDeclaration` and 
> > > > > > > > > > > > > > > > prohibit any occurrences of `annotate_type` 
> > > > > > > > > > > > > > > > there. However, this seems the wrong place to 
> > > > > > > > > > > > > > > > do this because it doesn't contain any specific 
> > > > > > > > > > > > > > > > processing for other attributes.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > I've noticed that Clang also doesn't prohibit 
> > > > > > > > > > > > > > > > other type attributes (even ones with C++ 11 
> > > > > > > > > > > > > > > > syntax) from being applied to declarations. For 
> > > > > > > > > > > > > > > > example: https://godbolt.org/z/Yj1zWY7nn
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > How do you think I should proceed here? I think 
> > > > > > > > > > > > > > > > the underlying issue is that Clang doesn't 
> > > > > > > > > > > > > > > > always distinguish cleanly between declaration 
> > > > > > > > > > > > > > > > attributes and type attributes, and fixing this 
> > > > > > > > > > > > > > > > might be nontrivial.
> > > > > > > > > > > > > > > > How do you think I should proceed here? I think 
> > > > > > > > > > > > > > > > the underlying issue is that Clang doesn't 
> > > > > > > > > > > > > > > > always distinguish cleanly between declaration 
> > > > > > > > > > > > > > > > attributes and type attributes, and fixing this 
> > > > > > > > > > > > > > > > might be nontrivial.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > This is a general issue with attribute 
> > > > > > > > > > > > > > > processing. I would imagine that SemaDeclAttr.cpp 
> > > > > > > > > > > > > > > should be able to diagnose that case when the 
> > > > > > > > > > > > > > > attribute only applies to types and not 
> > > > > > > > > > > > > > > declarations, but it'd take some investigation 
> > > > > > > > > > > > > > > for me to be sure.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Because this issue isn't new to your situation, 
> > > > > > > > > > > > > > > I'd recommend filing an issue about the general 
> > > > > > > > > > > > > > > problem and then we can solve that later.
> > > > > > > > > > > > > > I've done some more investigation myself, and I 
> > > > > > 

[PATCH] D126024: [MSVC, ARM64] Add __readx18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 431021.
steplong added a comment.

- Use `CharUnits::One()` instead of `getTypeAlignInChars()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126024

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,65 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+unsigned char check__readx18byte(unsigned long offset) {
+  return __readx18byte(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[RETVAL:.*]] = load i8, i8* %[[PTR]], align 1
+// CHECK-MSVC: ret i8 %[[RETVAL]]
+
+unsigned short check__readx18word(unsigned long offset) {
+  return __readx18word(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i16*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i16, i16* %[[BITCAST_PTR]], align 1
+// CHECK-MSVC: ret i16 %[[RETVAL]]
+
+unsigned long check__readx18dword(unsigned long offset) {
+  return __readx18dword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i32*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i32, i32* %[[BITCAST_PTR]], align 1
+// CHECK-MSVC: ret i32 %[[RETVAL]]
+
+unsigned __int64 check__readx18qword(unsigned long offset) {
+  return __readx18qword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i64*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i64, i64* %[[BITCAST_PTR]], align 1
+// CHECK-MSVC: ret i64 %[[RETVAL]]
+
 // CHECK-MSVC: ![[MD2]] = !{!"x18"}
 // CHECK-MSVC: ![[MD3]] = !{!"sp"}
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -562,6 +562,11 @@
 unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 
 void __break(int);
+
+unsigned char __readx18byte(unsigned long offset);
+unsigned short __readx18word(unsigned long offset);
+unsigned long __readx18dword(unsigned long offset);
+unsigned __int64 __readx18qword(unsigned long offset);
 #endif
 
 /**\
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9952,6 +9952,30 @@
 return HigherBits;
   }
 
+  if (BuiltinID == AArch64::BI__readx18byte ||
+  BuiltinID == AArch64::BI__readx18word ||
+  BuiltinID == AArch64::BI__readx18dword ||
+  BuiltinID == AArch64::BI__readx18qword) {
+llvm::Type *IntTy = 

[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 431019.
steplong added a comment.

- Switch to `CharUnits::One()` instead of `getContext().getTypeInChars()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,73 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+void check__writex18byte(unsigned long offset, unsigned char data) {
+  __writex18byte(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i8, align 1
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i8 %data, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[DATA:.*]] = load i8, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i8 %[[DATA]], i8* %[[PTR]], align 1
+
+void check__writex18word(unsigned long offset, unsigned short data) {
+  __writex18word(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i16, align 2
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i16 %data, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i16*
+// CHECK-MSVC: %[[DATA:.*]] = load i16, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i16 %[[DATA]], i16* %[[BITCAST_PTR]], align 1
+
+void check__writex18dword(unsigned long offset, unsigned long data) {
+  __writex18dword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %data, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i32*
+// CHECK-MSVC: %[[DATA:.*]] = load i32, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %[[DATA]], i32* %[[BITCAST_PTR]], align 1
+
+void check__writex18qword(unsigned long offset, unsigned __int64 data) {
+  __writex18qword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i64, align 8
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i64 %data, i64* %[[DATA_ADDR]], align 8
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i64*
+// CHECK-MSVC: %[[DATA:.*]] = load i64, i64* %[[DATA_ADDR]], align 8
+// CHECK-MSVC: store i64 %[[DATA]], i64* %[[BITCAST_PTR]], align 1
+
 // CHECK-MSVC: ![[MD2]] = !{!"x18"}
 // CHECK-MSVC: ![[MD3]] = !{!"sp"}
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -562,6 +562,11 @@
 unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 
 void __break(int);
+
+void __writex18byte(unsigned long offset, unsigned char data);
+void __writex18word(unsigned long offset, unsigned short 

[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2022-05-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.
Herald added a project: All.

The sema portions of this change are still causing an issue.  Although the 
revert (rGf95bd18b5faa6a5af4b5786312c373c5b2dce687 
) and the 
subsequent re-application in rG3466e00716e12e32fdb100e3fcfca5c2b3e8d784 
  
addressed the debug info issue, the Sema issue remains.

  // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c11 -x c %s
  struct dispatch_object_s;
  void _dispatch_queue_get_head(struct dispatch_object_s * volatile 
dq_items_head) {
(_Atomic __typeof__(dq_items_head) *)dq_items_head;
  }

will trigger an assertion failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9977
+StoreInst *Store = Builder.CreateAlignedStore(
+Val, Ptr, getContext().getTypeAlignInChars(E->getType()));
+return Store;

I think I'd prefer just "CharUnits::One()", rather than getTypeAlignInChars(); 
given the lack of documentation, it's not clear if the offset is required to be 
properly aligned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

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


[PATCH] D125094: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-05-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:1863
   // to combine multiple loads / stores.
-  bool CanEliminateFrame = true;
+  bool CanEliminateFrame = !requiresAAPCSFrameRecord(MF);
   bool CS1Spilled = false;

Should this also check hasFP?



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:2110
+  if ((requiresAAPCSFrameRecord(MF) ||
+   MF.getTarget().Options.DisableFramePointerElim(MF)) &&
+  !LRSpilled) {

pratlucas wrote:
> efriedma wrote:
> > Should requiresAAPCSFrameRecord() be orthogonal to 
> > DisableFramePointerElim()?  I mean, we have a complete set of flags 
> > controlling frame pointer elimination; the only part that's "new" here is 
> > that the frame pointer is stored in r11, instead of r7.
> For cases where a function's codegen requires the use of a frame pointer, we 
> want an AAPCS compliant frame record to be generated even when the frame 
> pointer elimination is enabled. For that reason we need the two options to be 
> orthogonal on some level.
> I've updated this check to be more strict and only consider 
> `requiresAAPCSFrameRecord()` when the function has a frame pointer.
> For cases where a function's codegen requires the use of a frame pointer, we 
> want an AAPCS compliant frame record to be generated even when the frame 
> pointer elimination is enabled.

That's... hmm.  Feels a little weird, but I guess it makes sense.

The `hasFP(MF)` here is redundant; this is already inside an `if (HasFP) {` 
block.



Comment at: llvm/lib/Target/ARM/Thumb1FrameLowering.cpp:1167
+   STI.hasV5TOps());
+  // Only unused return registers can be used as copy regs at this point
+  popRegsFromStack(MBB, MI, TII, FrameRecord, UnusedReturnRegs, IsVarArg,

Are we actually guaranteed to have any unused return registers at this point?  
The calling convention uses r0-r3 to return values.



Comment at: llvm/test/CodeGen/Thumb/frame-access.ll:73
+; CHECK-AAPCS: mov r0, r11
+; CHECK-AAPCS: str r1, [r0, #8]
+; CHECK-AAPCS: mov r0, r11

pratlucas wrote:
> efriedma wrote:
> > Can we use sp-relative accesses here?  If we're not doing dynamic 
> > allocations, it should be a fixed offset.
> The current criteria for the Arm and Thumb backends is that fixed  frame 
> indices are always accessed through FP whenever it is available (See [[ 
> https://github.com/llvm/llvm-project/blob/aed49eac87b8aa77298252ea781bae4725ae8046/llvm/lib/Target/ARM/ARMFrameLowering.cpp#L1083
>  | ARMFrameLowering.cpp ]]).
> I guess that could be changed, but I feel it would fall outside the scope of 
> this patch.
This patch does make it much more likely that fp-relative accesses are going to 
be out of range, but sure, I guess we can treat it as a separate issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125094

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


[PATCH] D123235: [OpenMP] atomic compare fail : Parser & AST support

2022-05-20 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

LGTM, but please fix the build error first.




Comment at: clang/include/clang/AST/ASTNodeTraverser.h:228
 
+  void Visit(const OMPFailClause *C) {
+getNodeDelegate().AddChild([=] {

koops wrote:
> tianshilei1992 wrote:
> > koops wrote:
> > > tianshilei1992 wrote:
> > > > Why would we want a dedicated function since it is only called once?
> > > The code for this method cannot be put into any other method because it 
> > > handles only OMPFailClause. All other Visit methods handle either the 
> > > generalized OMPClause or other types of Clauses.
> > I mean, it's only used by the function above, no?
> I agree with you but, I cannot understand any better way of coding it.
Initially I thought to merge them, but this looks fine.



Comment at: clang/include/clang/AST/OpenMPClause.h:2305
+OpenMPClauseKind *MOCK = getTrailingObjects();
+//*getTrailingObjects() = memOrder;
+*MOCK = MemOrder;

If the code is commented out, plz remove it.


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

https://reviews.llvm.org/D123235

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


[clang-tools-extra] 1fef69d - Avoid uninitialized Diag.ID (which we pass but never read)

2022-05-20 Thread via cfe-commits

Author: Sam McCall
Date: 2022-05-20T20:29:47+02:00
New Revision: 1fef69da0bfd51de916f0a869f97740c51211cc1

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

LOG: Avoid uninitialized Diag.ID (which we pass but never read)

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.h 
b/clang-tools-extra/clangd/Diagnostics.h
index 14627ea3d6a0..6004bb147361 100644
--- a/clang-tools-extra/clangd/Diagnostics.h
+++ b/clang-tools-extra/clangd/Diagnostics.h
@@ -69,7 +69,7 @@ struct DiagBase {
   // Since File is only descriptive, we store a separate flag to distinguish
   // diags from the main file.
   bool InsideMainFile = false;
-  unsigned ID; // e.g. member of clang::diag, or clang-tidy assigned ID.
+  unsigned ID = 0; // e.g. member of clang::diag, or clang-tidy assigned ID.
   // Feature modules can make use of this field to propagate data from a
   // diagnostic to a CodeAction request. Each module should only append to the
   // list.



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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 431013.
steplong added a comment.

- Changed addrspace(256) to the default addrspace 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,73 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+void check__writex18byte(unsigned long offset, unsigned char data) {
+  __writex18byte(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i8, align 1
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i8 %data, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[DATA:.*]] = load i8, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i8 %[[DATA]], i8* %[[PTR]], align 1
+
+void check__writex18word(unsigned long offset, unsigned short data) {
+  __writex18word(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i16, align 2
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i16 %data, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i16*
+// CHECK-MSVC: %[[DATA:.*]] = load i16, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i16 %[[DATA]], i16* %[[BITCAST_PTR]], align 1
+
+void check__writex18dword(unsigned long offset, unsigned long data) {
+  __writex18dword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %data, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i32*
+// CHECK-MSVC: %[[DATA:.*]] = load i32, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %[[DATA]], i32* %[[BITCAST_PTR]], align 1
+
+void check__writex18qword(unsigned long offset, unsigned __int64 data) {
+  __writex18qword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i64, align 8
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i64 %data, i64* %[[DATA_ADDR]], align 8
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i64*
+// CHECK-MSVC: %[[DATA:.*]] = load i64, i64* %[[DATA_ADDR]], align 8
+// CHECK-MSVC: store i64 %[[DATA]], i64* %[[BITCAST_PTR]], align 1
+
 // CHECK-MSVC: ![[MD2]] = !{!"x18"}
 // CHECK-MSVC: ![[MD3]] = !{!"sp"}
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -562,6 +562,11 @@
 unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 
 void __break(int);
+
+void __writex18byte(unsigned long offset, unsigned char data);
+void __writex18word(unsigned long offset, unsigned short data);
+void 

[PATCH] D125847: LTO: Decide upfront whether to use opaque/non-opaque pointer types

2022-05-20 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D125847#3528111 , @aeubanks wrote:

> I'm still looking into a whole program devirtualization bug that only repros 
> with opaque pointers, and there are still potential performance issues to 
> look into

Thanks. Maybe here is another way to look at this problem, instead of giving 
people a temporary switch to use opaque_pointer if their first bitcode is 
no_opaque_pointer, we opt as aggressive as possible into opaque_pointer and 
give people a temporary switch to go back to old behavior just like how clang 
is configured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125847

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


[PATCH] D126024: [MSVC, ARM64] Add __readx18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 431011.
steplong added a comment.

- Change addrspace(256) to the default addrspace 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126024

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,65 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+unsigned char check__readx18byte(unsigned long offset) {
+  return __readx18byte(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[RETVAL:.*]] = load i8, i8* %[[PTR]], align 1
+// CHECK-MSVC: ret i8 %[[RETVAL]]
+
+unsigned short check__readx18word(unsigned long offset) {
+  return __readx18word(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i16*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i16, i16* %[[BITCAST_PTR]], align 2
+// CHECK-MSVC: ret i16 %[[RETVAL]]
+
+unsigned long check__readx18dword(unsigned long offset) {
+  return __readx18dword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i32*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i32, i32* %[[BITCAST_PTR]], align 4
+// CHECK-MSVC: ret i32 %[[RETVAL]]
+
+unsigned __int64 check__readx18qword(unsigned long offset) {
+  return __readx18qword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8* %[[PTR]] to i64*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i64, i64* %[[BITCAST_PTR]], align 8
+// CHECK-MSVC: ret i64 %[[RETVAL]]
+
 // CHECK-MSVC: ![[MD2]] = !{!"x18"}
 // CHECK-MSVC: ![[MD3]] = !{!"sp"}
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -562,6 +562,11 @@
 unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 
 void __break(int);
+
+unsigned char __readx18byte(unsigned long offset);
+unsigned short __readx18word(unsigned long offset);
+unsigned long __readx18dword(unsigned long offset);
+unsigned __int64 __readx18qword(unsigned long offset);
 #endif
 
 /**\
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -9952,6 +9952,31 @@
 return HigherBits;
   }
 
+  if (BuiltinID == AArch64::BI__readx18byte ||
+  BuiltinID == AArch64::BI__readx18word ||
+  BuiltinID == AArch64::BI__readx18dword ||
+  BuiltinID == AArch64::BI__readx18qword) {
+llvm::Type *IntTy = 

[PATCH] D125847: LTO: Decide upfront whether to use opaque/non-opaque pointer types

2022-05-20 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

I'm still looking into a whole program devirtualization bug that only repros 
with opaque pointers, and there are still potential performance issues to look 
into


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125847

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


[PATCH] D125847: LTO: Decide upfront whether to use opaque/non-opaque pointer types

2022-05-20 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Is there any issues currently if we just always use opaque pointer in LTO?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125847

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


[PATCH] D124836: [AArch64] Add support for -fzero-call-used-regs

2022-05-20 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka added a comment.

Hi @void ,

the `zero-call-used-regs.ll` test gets failed on 
`llvm-clang-x86_64-expensive-checks-ubuntu` builder with the following errors:

  ...
  *** Bad machine code: Illegal physical register for instruction ***
  - function:all_arg
  - basic block: %bb.0 entry (0x555be568bb88)
  - instruction: $q0 = MOVID 0
  - operand 0:   $q0
  $q0 is not a FPR64 register.
  ...

see more details here 
https://lab.llvm.org/buildbot/#/builders/104/builds/7797/steps/6/logs/FAIL__LLVM__zero-call-used-regs_ll

Looks like you need to limit this test with `REQURES: 
aarch64-registered-target` or something similar.

The first failed build: https://lab.llvm.org/buildbot/#/builders/104/builds/7797


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124836

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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D126023#3528077 , @rnk wrote:

> I was unable to find any documentation for the meaning of AArch64 
> addrspace(256), and I wasn't able to figure it out after studying the code in 
> llvm/lib/Target/AArch64 for ten minutes or so. The change seems fine, but 
> please add some documentation as a follow-up. X86 has some of its address 
> spaces documented here, not that this is the best place:
> https://llvm.org/docs/CodeGenerator.html#x86-address-spaces-supported

Hmm yea I don't think addrspace(256) is correct. I was using D31248 
 as a reference and addrspace(256) makes sense 
for that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I was unable to find any documentation for the meaning of AArch64 
addrspace(256), and I wasn't able to figure it out after studying the code in 
llvm/lib/Target/AArch64 for ten minutes or so. The change seems fine, but 
please add some documentation as a follow-up. X86 has some of its address 
spaces documented here, not that this is the best place:
https://llvm.org/docs/CodeGenerator.html#x86-address-spaces-supported


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

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


[PATCH] D117460: [clang-tidy][NFC] Reduce map lookups in IncludeSorter

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.
Herald added a project: All.

Are we waiting on some sort of benchmark before accepting/rejecting this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117460

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


[PATCH] D117409: [clang-tidy] Move IncludeInserter into ClangTidyContext

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood added a comment.
This revision is now accepted and ready to land.
Herald added a project: All.

If the only thing holding this up is my comments about following the Law of 
Demeter, I don't think that should block submitting this change.

I don't feel strongly about it enough to block submission and the style guide 
doesn't say anything about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117409

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


[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood 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/D125209/new/

https://reviews.llvm.org/D125209

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


[PATCH] D125769: [clang-tidy] Introduce the CheckHeaderFile option to modernize-deprecated-headers

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood added a comment.
This revision is now accepted and ready to land.

LGTM
Address one nit and ship.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125769

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


[PATCH] D125769: [clang-tidy] Introduce the CheckHeaderFile option to modernize-deprecated-headers

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:180
+  the ``CheckHeaderFile=true`` option if header files of the project only
+  included by c++ source files.
 

Capitalize to `C++`



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-extern-c.cpp:2-4
 // Copy the 'mylib.h' to a directory under the build directory. This is
 // required, since the relative order of the emitted diagnostics depends on the
 // absolute file paths which is sorted by clang-tidy prior emitting.

steakhal wrote:
> LegalizeAdulthood wrote:
> > IMO, all of this hackery is simply ducking the issue, which is that 
> > `check_clang_tidy.py` doesn't have proper support for validating fixits 
> > applied to header files.
> > 
> > See https://reviews.llvm.org/D17482
> I agree that this is nasty, but this was the only way I found to still test 
> the feature I'm about to introduce.
Agreed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125769

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


[PATCH] D126077: Fix stack crash in classIsDerivedFrom triggered by clang-tidy

2022-05-20 Thread Anton Fedorov via Phabricator via cfe-commits
datacompboy created this revision.
datacompboy added reviewers: bixia, aartbik.
Herald added a project: All.
datacompboy requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Protect classIsDerivedFrom from run-out-of-stack crash and infinity loop.

  

Rewrite recursion to loop-over-stack and add checks for complexity to avoid 
crash on deep definition or infinify recursion.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126077

Files:
  clang-tools-extra/test/clang-tidy/infrastructure/recursive-templates.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -44,6 +44,12 @@
 // optimize this on.
 static const unsigned MaxMemoizationEntries = 1;
 
+// The maximum number of steps thru ancestors allowed to run before
+// give up. The limit could only be hit by infinity / too deep
+// recursion or very complicated automatically generated types
+// inheritance.
+static const unsigned MaxDerivationComplexity = 1;
+
 enum class MatchType {
   Ancestors,
 
@@ -1357,35 +1363,47 @@
 // Returns true if the given C++ class is directly or indirectly derived
 // from a base type with the given name.  A class is not considered to be
 // derived from itself.
-bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *Declaration,
+bool MatchASTVisitor::classIsDerivedFrom(const CXXRecordDecl *DeclarationIn,
  const Matcher ,
  BoundNodesTreeBuilder *Builder,
  bool Directly) {
-  if (!Declaration->hasDefinition())
-return false;
-  for (const auto  : Declaration->bases()) {
-const Type *TypeNode = It.getType().getTypePtr();
+  SmallVector DeclarationsStack;
+  int iterations = 0;
+  DeclarationsStack.push_back(DeclarationIn);
+  while (!DeclarationsStack.empty()) {
+const CXXRecordDecl *Declaration = DeclarationsStack.pop_back_val();
+if (++iterations > MaxDerivationComplexity ||
+DeclarationsStack.size() > MaxDerivationComplexity) {
+  // This can happen in case of too deep derivation chain or recursion.
+  return false;
+}
+if (!Declaration->hasDefinition())
+  return false;
+for (const auto  : Declaration->bases()) {
+  const Type *TypeNode = It.getType().getTypePtr();
 
-if (typeHasMatchingAlias(TypeNode, Base, Builder))
-  return true;
+  if (typeHasMatchingAlias(TypeNode, Base, Builder))
+return true;
 
-// FIXME: Going to the primary template here isn't really correct, but
-// unfortunately we accept a Decl matcher for the base class not a Type
-// matcher, so it's the best thing we can do with our current interface.
-CXXRecordDecl *ClassDecl = getAsCXXRecordDeclOrPrimaryTemplate(TypeNode);
-if (!ClassDecl)
-  continue;
-if (ClassDecl == Declaration) {
-  // This can happen for recursive template definitions.
-  continue;
-}
-BoundNodesTreeBuilder Result(*Builder);
-if (Base.matches(*ClassDecl, this, )) {
-  *Builder = std::move(Result);
-  return true;
+  // FIXME: Going to the primary template here isn't really correct, but
+  // unfortunately we accept a Decl matcher for the base class not a Type
+  // matcher, so it's the best thing we can do with our current interface.
+  CXXRecordDecl *ClassDecl = getAsCXXRecordDeclOrPrimaryTemplate(TypeNode);
+  if (!ClassDecl)
+continue;
+  if (ClassDecl == Declaration) {
+// This can happen for recursive template definitions.
+continue;
+  }
+  BoundNodesTreeBuilder Result(*Builder);
+  if (Base.matches(*ClassDecl, this, )) {
+*Builder = std::move(Result);
+return true;
+  }
+  if (!Directly) {
+DeclarationsStack.push_back(ClassDecl);
+  }
 }
-if (!Directly && classIsDerivedFrom(ClassDecl, Base, Builder, Directly))
-  return true;
   }
   return false;
 }
Index: clang-tools-extra/test/clang-tidy/infrastructure/recursive-templates.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/recursive-templates.cpp
@@ -0,0 +1,14 @@
+// Regression test: shouldn't crash.
+// RUN: clang-tidy %s -checks='*' -- | FileCheck %s
+template struct t1;
+template struct t2: t1< T > {};
+template struct t1: t2< T > {};
+
+int main() {
+  return 0;
+}
+
+namespace i {
+}
+// CHECK: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-05-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:418
+  if (const auto *ME = dyn_cast(E))
+if (const auto *TE = dyn_cast(ME->getBase()))
+  if (TE->isImplicit())

dgoldman wrote:
> sammccall wrote:
> > oops, I forgot one detail: we want ME->getBase()->IgnoreImpCasts()
> > 
> > (in `void nonConstMethod() { constMethod(); }` there's an ImplicitCastExpr 
> > in there...
> Hmm, is this right, I tested out that example and it seems like that's 
> actually a `CXXMemberCallExpr` which this doesn't handle?
The callee of the CXXMemberCallExpr is the MemberExpr i'm talking about here.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:170
+  if (E->hasPlaceholderType(BuiltinType::PseudoObject)) {
+if (const auto *PR = dyn_cast(E)) {
+  if (PR->isMessagingSetter()) {

dgoldman wrote:
> dgoldman wrote:
> > sammccall wrote:
> > > dgoldman wrote:
> > > > sammccall wrote:
> > > > > E->getObjCProperty()?
> > > > Hmm I'm not sure when that would be useful looking at the logic there, 
> > > > can you give an example just to make sure I understand what it would 
> > > > handle?
> > > it's similar to the cast you have, but in addition to handling `foo.bar` 
> > > it handles parens like `(foo.bar)`, commas like `(0, foo.bar)` and casts. 
> > > All together I think this covers more cases where a pseudo-object can be 
> > > used as an lvalue and potentially modified.
> > Gotcha, thanks. That makes sense, but it doesn't look like that has any 
> > usages and I'm not sure if it's safe to call from this context (e.g. if we 
> > can have a non ObjC property PseudoObject expr).  I guess I could modify 
> > getObjCProperty to return nullptr in those invalid cases, WDYT?
> @sammccall WDYT about this? Leave as is?
Yeah, that function is not ideal. Leaving as-is sounds fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D125771: [clang-tidy] Add a useful note about -std=c++11-or-later

2022-05-20 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/check_clang_tidy.py:22
 [-check-suffixes=] \
+[-std=(c++11-or-later|c++17)] \
\

These aren't the only two valid options for this argument  Valid values are:


  - `c++98-or-later`
  - `c++11-or-later`
  - `c++14-or-later`
  - `c++17-or-later`
  - `c++20-or-later`

and of course all the specific standard versions:

  - `c++98`
  - `c++11`
  - `c++14`
  - `c++17`
  - `c++20`




Comment at: clang-tools-extra/test/clang-tidy/check_clang_tidy.py:30
+Notes:
+  -std=c++11-or-later:
+This flag will cause multiple runs within the same check_clang_tidy

Probably need to explain the `-or-later` argument option more generally here 
and not just for C++11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125771

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


[PATCH] D126031: [libclang] add supporting for indexing/visiting C++ concepts

2022-05-20 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

Looks like `index-concepts.cpp` is failing on Windows, @arphaman could you 
please take a look?


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

https://reviews.llvm.org/D126031

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


[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-05-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:418
+  if (const auto *ME = dyn_cast(E))
+if (const auto *TE = dyn_cast(ME->getBase()))
+  if (TE->isImplicit())

sammccall wrote:
> oops, I forgot one detail: we want ME->getBase()->IgnoreImpCasts()
> 
> (in `void nonConstMethod() { constMethod(); }` there's an ImplicitCastExpr in 
> there...
Hmm, is this right, I tested out that example and it seems like that's actually 
a `CXXMemberCallExpr` which this doesn't handle?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D126002: [clang] Fixing arm-common, windows only and openmp header install targets

2022-05-20 Thread Qiongsi Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f12718ccfd6: [clang] Fixing arm-common, windows only and 
openmp header install targets (authored by qiongsiwu1).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126002

Files:
  clang/lib/Headers/CMakeLists.txt


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -366,7 +366,7 @@
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 add_dependencies("clang-resource-headers"
  "core-resource-headers"
- "arm-common-headers"
+ "arm-common-resource-headers"
  "arm-resource-headers"
  "aarch64-resource-headers"
  "cuda-resource-headers"
@@ -387,7 +387,7 @@
 
 # Core/common headers
 add_header_target("core-resource-headers" ${core_files})
-add_header_target("arm-common-headers" 
"${arm_common_files};${arm_common_generated_files}")
+add_header_target("arm-common-resource-headers" 
"${arm_common_files};${arm_common_generated_files}")
 
 # Architecture/platform specific targets
 add_header_target("arm-resource-headers" 
"${arm_only_files};${arm_only_generated_files}")
@@ -546,7 +546,7 @@
 
 install(
   FILES ${openmp_wrapper_files}
-  DESTINATION ${header_install_dir}
+  DESTINATION ${header_install_dir}/openmp_wrappers
   EXCLUDE_FROM_ALL
   COMPONENT openmp-resource-headers)
 
@@ -557,7 +557,7 @@
   COMPONENT utility-resource-headers)
 
 install(
-  FILES ${windows_files}
+  FILES ${windows_only_files}
   DESTINATION ${header_install_dir}
   EXCLUDE_FROM_ALL
   COMPONENT windows-resource-headers)
@@ -621,7 +621,7 @@
DEPENDS openmp-resource-headers
COMPONENT openmp-resource-headers)
   add_llvm_install_targets(install-windows-resource-headers
-   DEPENDS window-resource-headers
+   DEPENDS windows-resource-headers
COMPONENT windows-resource-headers)
   add_llvm_install_targets(install-utility-resource-headers
DEPENDS utility-resource-headers


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -366,7 +366,7 @@
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 add_dependencies("clang-resource-headers"
  "core-resource-headers"
- "arm-common-headers"
+ "arm-common-resource-headers"
  "arm-resource-headers"
  "aarch64-resource-headers"
  "cuda-resource-headers"
@@ -387,7 +387,7 @@
 
 # Core/common headers
 add_header_target("core-resource-headers" ${core_files})
-add_header_target("arm-common-headers" "${arm_common_files};${arm_common_generated_files}")
+add_header_target("arm-common-resource-headers" "${arm_common_files};${arm_common_generated_files}")
 
 # Architecture/platform specific targets
 add_header_target("arm-resource-headers" "${arm_only_files};${arm_only_generated_files}")
@@ -546,7 +546,7 @@
 
 install(
   FILES ${openmp_wrapper_files}
-  DESTINATION ${header_install_dir}
+  DESTINATION ${header_install_dir}/openmp_wrappers
   EXCLUDE_FROM_ALL
   COMPONENT openmp-resource-headers)
 
@@ -557,7 +557,7 @@
   COMPONENT utility-resource-headers)
 
 install(
-  FILES ${windows_files}
+  FILES ${windows_only_files}
   DESTINATION ${header_install_dir}
   EXCLUDE_FROM_ALL
   COMPONENT windows-resource-headers)
@@ -621,7 +621,7 @@
DEPENDS openmp-resource-headers
COMPONENT openmp-resource-headers)
   add_llvm_install_targets(install-windows-resource-headers
-   DEPENDS window-resource-headers
+   DEPENDS windows-resource-headers
COMPONENT windows-resource-headers)
   add_llvm_install_targets(install-utility-resource-headers
DEPENDS utility-resource-headers
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1f12718 - [clang] Fixing arm-common, windows only and openmp header install targets

2022-05-20 Thread Qiongsi Wu via cfe-commits

Author: Qiongsi Wu
Date: 2022-05-20T12:29:10-04:00
New Revision: 1f12718ccfd660f01ac0e444d4632cf8ce6b98e2

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

LOG: [clang] Fixing arm-common, windows only and openmp header install targets

https://reviews.llvm.org/D123498 contains a few errors resulting in incorrect 
target contents or mismatched target/list names. This patch fixes all the known 
errors.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/lib/Headers/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index 08c5dccb3b77a..8bf7dd570384f 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -366,7 +366,7 @@ set_target_properties("clang-resource-headers" PROPERTIES
   RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
 add_dependencies("clang-resource-headers"
  "core-resource-headers"
- "arm-common-headers"
+ "arm-common-resource-headers"
  "arm-resource-headers"
  "aarch64-resource-headers"
  "cuda-resource-headers"
@@ -387,7 +387,7 @@ add_dependencies("clang-resource-headers"
 
 # Core/common headers
 add_header_target("core-resource-headers" ${core_files})
-add_header_target("arm-common-headers" 
"${arm_common_files};${arm_common_generated_files}")
+add_header_target("arm-common-resource-headers" 
"${arm_common_files};${arm_common_generated_files}")
 
 # Architecture/platform specific targets
 add_header_target("arm-resource-headers" 
"${arm_only_files};${arm_only_generated_files}")
@@ -546,7 +546,7 @@ install(
 
 install(
   FILES ${openmp_wrapper_files}
-  DESTINATION ${header_install_dir}
+  DESTINATION ${header_install_dir}/openmp_wrappers
   EXCLUDE_FROM_ALL
   COMPONENT openmp-resource-headers)
 
@@ -557,7 +557,7 @@ install(
   COMPONENT utility-resource-headers)
 
 install(
-  FILES ${windows_files}
+  FILES ${windows_only_files}
   DESTINATION ${header_install_dir}
   EXCLUDE_FROM_ALL
   COMPONENT windows-resource-headers)
@@ -621,7 +621,7 @@ if (NOT LLVM_ENABLE_IDE)
DEPENDS openmp-resource-headers
COMPONENT openmp-resource-headers)
   add_llvm_install_targets(install-windows-resource-headers
-   DEPENDS window-resource-headers
+   DEPENDS windows-resource-headers
COMPONENT windows-resource-headers)
   add_llvm_install_targets(install-utility-resource-headers
DEPENDS utility-resource-headers



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


[PATCH] D126024: [MSVC, ARM64] Add __readx18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 430994.
steplong added a comment.

The assembly for LLVM is now:

  __readx18byte:
 ldrbw0, [x18, w0, uxtw]
  __readx18word:
 ldrhw0, [x18, w0, uxtw]
  __readx18dword:
 ldr w0, [x18, w0, uxtw]
  __readx18qword:
 ldr x0, [x18, w0, uxtw]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126024

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,65 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+unsigned char check__readx18byte(unsigned long offset) {
+  return __readx18byte(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[RETVAL:.*]] = load i8, i8 addrspace(256)* %[[PTR]], align 1
+// CHECK-MSVC: ret i8 %[[RETVAL]]
+
+unsigned short check__readx18word(unsigned long offset) {
+  return __readx18word(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to i16 addrspace(256)*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i16, i16 addrspace(256)* %[[BITCAST_PTR]], align 2
+// CHECK-MSVC: ret i16 %[[RETVAL]]
+
+unsigned long check__readx18dword(unsigned long offset) {
+  return __readx18dword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to i32 addrspace(256)*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i32, i32 addrspace(256)* %[[BITCAST_PTR]], align 4
+// CHECK-MSVC: ret i32 %[[RETVAL]]
+
+unsigned __int64 check__readx18qword(unsigned long offset) {
+  return __readx18qword(offset);
+}
+
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to i64 addrspace(256)*
+// CHECK-MSVC: %[[RETVAL:.*]] = load i64, i64 addrspace(256)* %[[BITCAST_PTR]], align 8
+// CHECK-MSVC: ret i64 %[[RETVAL]]
+
 // CHECK-MSVC: ![[MD2]] = !{!"x18"}
 // CHECK-MSVC: ![[MD3]] = !{!"sp"}
Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -562,6 +562,11 @@
 unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b);
 
 void __break(int);
+
+unsigned char __readx18byte(unsigned long offset);
+unsigned short __readx18word(unsigned long offset);
+unsigned long __readx18dword(unsigned long offset);
+unsigned __int64 __readx18qword(unsigned long offset);
 #endif
 
 /**\

[PATCH] D124486: [clangd] ExtractVariable support for C and Objective-C

2022-05-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:170
+  if (E->hasPlaceholderType(BuiltinType::PseudoObject)) {
+if (const auto *PR = dyn_cast(E)) {
+  if (PR->isMessagingSetter()) {

dgoldman wrote:
> sammccall wrote:
> > dgoldman wrote:
> > > sammccall wrote:
> > > > E->getObjCProperty()?
> > > Hmm I'm not sure when that would be useful looking at the logic there, 
> > > can you give an example just to make sure I understand what it would 
> > > handle?
> > it's similar to the cast you have, but in addition to handling `foo.bar` it 
> > handles parens like `(foo.bar)`, commas like `(0, foo.bar)` and casts. All 
> > together I think this covers more cases where a pseudo-object can be used 
> > as an lvalue and potentially modified.
> Gotcha, thanks. That makes sense, but it doesn't look like that has any 
> usages and I'm not sure if it's safe to call from this context (e.g. if we 
> can have a non ObjC property PseudoObject expr).  I guess I could modify 
> getObjCProperty to return nullptr in those invalid cases, WDYT?
@sammccall WDYT about this? Leave as is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124486

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


[PATCH] D125094: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-05-20 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 430991.
pratlucas marked 2 inline comments as done.
pratlucas added a comment.

Addressing review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125094

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMFrameLowering.cpp
  llvm/lib/Target/ARM/ARMMachineFunctionInfo.h
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
  llvm/lib/Target/ARM/ThumbRegisterInfo.cpp
  llvm/test/CodeGen/ARM/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/ARM/frame-chain.ll
  llvm/test/CodeGen/Thumb/frame-access.ll
  llvm/test/CodeGen/Thumb/frame-chain-reserved-fp.ll
  llvm/test/CodeGen/Thumb/frame-chain.ll

Index: llvm/test/CodeGen/Thumb/frame-chain.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb/frame-chain.ll
@@ -0,0 +1,304 @@
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all | FileCheck %s --check-prefixes=FP,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=all -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-FP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf | FileCheck %s --check-prefixes=FP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=non-leaf -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=FP-AAPCS,LEAF-NOFP-AAPCS
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none | FileCheck %s --check-prefixes=NOFP,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP
+; RUN: llc -mtriple thumb-arm-none-eabi -filetype asm -o - %s -frame-pointer=none -mattr=+aapcs-frame-chain-leaf | FileCheck %s --check-prefixes=NOFP-AAPCS,LEAF-NOFP-AAPCS
+
+define dso_local noundef i32 @leaf(i32 noundef %0) {
+; LEAF-FP-LABEL: leaf:
+; LEAF-FP:   @ %bb.0:
+; LEAF-FP-NEXT:.pad #4
+; LEAF-FP-NEXT:sub sp, #4
+; LEAF-FP-NEXT:str r0, [sp]
+; LEAF-FP-NEXT:adds r0, r0, #4
+; LEAF-FP-NEXT:add sp, #4
+; LEAF-FP-NEXT:bx lr
+;
+; LEAF-FP-AAPCS-LABEL: leaf:
+; LEAF-FP-AAPCS:   @ %bb.0:
+; LEAF-FP-AAPCS-NEXT:.save {lr}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:mov lr, r11
+; LEAF-FP-AAPCS-NEXT:.save {r11}
+; LEAF-FP-AAPCS-NEXT:push {lr}
+; LEAF-FP-AAPCS-NEXT:.setfp r11, sp
+; LEAF-FP-AAPCS-NEXT:mov r11, sp
+; LEAF-FP-AAPCS-NEXT:.pad #4
+; LEAF-FP-AAPCS-NEXT:sub sp, #4
+; LEAF-FP-AAPCS-NEXT:str r0, [sp]
+; LEAF-FP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-FP-AAPCS-NEXT:add sp, #4
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:mov r11, r1
+; LEAF-FP-AAPCS-NEXT:pop {r1}
+; LEAF-FP-AAPCS-NEXT:bx r1
+;
+; LEAF-NOFP-LABEL: leaf:
+; LEAF-NOFP:   @ %bb.0:
+; LEAF-NOFP-NEXT:.pad #4
+; LEAF-NOFP-NEXT:sub sp, #4
+; LEAF-NOFP-NEXT:str r0, [sp]
+; LEAF-NOFP-NEXT:adds r0, r0, #4
+; LEAF-NOFP-NEXT:add sp, #4
+; LEAF-NOFP-NEXT:bx lr
+;
+; LEAF-NOFP-AAPCS-LABEL: leaf:
+; LEAF-NOFP-AAPCS:   @ %bb.0:
+; LEAF-NOFP-AAPCS-NEXT:.save {lr}
+; LEAF-NOFP-AAPCS-NEXT:push {lr}
+; LEAF-NOFP-AAPCS-NEXT:mov lr, r11
+; LEAF-NOFP-AAPCS-NEXT:.save {r11}
+; LEAF-NOFP-AAPCS-NEXT:push {lr}
+; LEAF-NOFP-AAPCS-NEXT:.setfp r11, sp
+; LEAF-NOFP-AAPCS-NEXT:mov r11, sp
+; LEAF-NOFP-AAPCS-NEXT:.pad #4
+; LEAF-NOFP-AAPCS-NEXT:sub sp, #4
+; LEAF-NOFP-AAPCS-NEXT:str r0, [sp]
+; LEAF-NOFP-AAPCS-NEXT:adds r0, r0, #4
+; LEAF-NOFP-AAPCS-NEXT:add sp, #4
+; LEAF-NOFP-AAPCS-NEXT:pop {r1}
+; LEAF-NOFP-AAPCS-NEXT:mov r11, r1
+; LEAF-NOFP-AAPCS-NEXT:pop {r1}
+; LEAF-NOFP-AAPCS-NEXT:bx r1
+  %2 = alloca i32, align 4
+  store i32 %0, i32* %2, align 4
+  %3 = load i32, i32* %2, align 4
+  %4 = add nsw i32 %3, 4
+  ret i32 %4
+}
+
+define dso_local noundef i32 @non_leaf(i32 noundef %0) {
+; FP-LABEL: non_leaf:
+; FP:   @ %bb.0:
+; FP-NEXT:.save {r7, lr}
+; FP-NEXT:push {r7, lr}
+; FP-NEXT:.setfp r7, sp
+; FP-NEXT:add r7, sp, #0
+; FP-NEXT:.pad #8
+; FP-NEXT:sub sp, #8
+; FP-NEXT:str r0, [sp, #4]
+; FP-NEXT:bl leaf
+; FP-NEXT:adds r0, r0, #1
+; FP-NEXT:add sp, #8
+; FP-NEXT:pop {r7}
+; FP-NEXT:pop {r1}
+; FP-NEXT: 

[PATCH] D125986: [clang][ASTImporter] Add support for import of UsingPackDecl.

2022-05-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 430990.
balazske added a comment.

Use of addDeclToContexts, added new test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125986

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
@@ -910,6 +910,20 @@
  functionDecl(hasDescendant(usingEnumDecl(hasName("bar");
 }
 
+const internal::VariadicDynCastAllOfMatcher usingPackDecl;
+
+TEST_P(ImportDecl, ImportUsingPackDecl) {
+  MatchVerifier Verifier;
+  testImport(
+  "struct A { int operator()() { return 1; } };"
+  "struct B { int operator()() { return 2; } };"
+  "template struct C : T... { using T::operator()...; };"
+  "C declToImport;",
+  Lang_CXX20, "", Lang_CXX20, Verifier,
+  varDecl(hasType(templateSpecializationType(hasDeclaration(
+  classTemplateSpecializationDecl(hasDescendant(usingPackDecl(;
+}
+
 /// \brief Matches shadow declarations introduced into a scope by a
 ///(resolved) using declaration.
 ///
@@ -1022,6 +1036,31 @@
  has(fieldDecl(hasType(dependentSizedArrayType(;
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportUsingPackDecl) {
+  Decl *FromTU = getTuDecl(
+  "struct A { int operator()() { return 1; } };"
+  "struct B { int operator()() { return 2; } };"
+  "template struct C : T... { using T::operator()...; };"
+  "C Var;",
+  Lang_CXX20);
+
+  auto From = FirstDeclMatcher().match(FromTU, usingPackDecl());
+  ASSERT_TRUE(From);
+  auto To = cast(Import(From, Lang_CXX20));
+  ASSERT_TRUE(To);
+
+  ArrayRef FromExpansions = From->expansions();
+  ArrayRef ToExpansions = To->expansions();
+  ASSERT_EQ(FromExpansions.size(), ToExpansions.size());
+  for (unsigned int I = 0; I < FromExpansions.size(); ++I) {
+auto ImportedExpansion = Import(FromExpansions[I], Lang_CXX20);
+EXPECT_EQ(ImportedExpansion, ToExpansions[I]);
+  }
+
+  auto ImportedDC = cast(Import(From->getDeclContext(), Lang_CXX20));
+  EXPECT_EQ(ImportedDC, cast(To->getDeclContext()));
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, TemplateTypeParmDeclNoDefaultArg) {
   Decl *FromTU = getTuDecl("template struct X {};", Lang_CXX03);
   auto From = FirstDeclMatcher().match(
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -548,6 +548,7 @@
 ExpectedDecl VisitUsingDecl(UsingDecl *D);
 ExpectedDecl VisitUsingShadowDecl(UsingShadowDecl *D);
 ExpectedDecl VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
+ExpectedDecl VisitUsingPackDecl(UsingPackDecl *D);
 ExpectedDecl ImportUsingShadowDecls(BaseUsingDecl *D, BaseUsingDecl *ToSI);
 ExpectedDecl VisitUsingEnumDecl(UsingEnumDecl *D);
 ExpectedDecl VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
@@ -4832,6 +4833,35 @@
   return ToUsingDir;
 }
 
+ExpectedDecl ASTNodeImporter::VisitUsingPackDecl(UsingPackDecl *D) {
+  DeclContext *DC, *LexicalDC;
+  DeclarationName Name;
+  SourceLocation Loc;
+  NamedDecl *ToD = nullptr;
+  if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
+return std::move(Err);
+  if (ToD)
+return ToD;
+
+  auto ToInstantiatedFromUsingOrErr =
+  Importer.Import(D->getInstantiatedFromUsingDecl());
+  if (!ToInstantiatedFromUsingOrErr)
+return ToInstantiatedFromUsingOrErr.takeError();
+  SmallVector Expansions(D->expansions().size());
+  if (Error Err = ImportArrayChecked(D->expansions(), Expansions.begin()))
+return std::move(Err);
+
+  UsingPackDecl *ToUsingPack;
+  if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.getToContext(), DC,
+  cast(*ToInstantiatedFromUsingOrErr),
+  Expansions))
+return ToUsingPack;
+
+  addDeclToContexts(D, ToUsingPack);
+
+  return ToUsingPack;
+}
+
 ExpectedDecl ASTNodeImporter::VisitUnresolvedUsingValueDecl(
 UnresolvedUsingValueDecl *D) {
   DeclContext *DC, *LexicalDC;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125094: [ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records

2022-05-20 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked 4 inline comments as done.
pratlucas added inline comments.



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:1844
+for (const auto  : MBB)
+  if (MI.getOpcode() == ARM::tSTRspi || MI.getOpcode() == ARM::tSTRi)
+for (const auto  : MI.operands())

efriedma wrote:
> How do you end up with tSTRi with a frameindex operand?  SelectionDAG won't 
> generate that, I think.
Indeed I didn't hit any case where tSTRi was emitted during my tests, but I 
included it here to be on the safe side given the contents of the comment on 
line 2050. I'm happy to remove it if it's indeed not necessary.



Comment at: llvm/lib/Target/ARM/ARMFrameLowering.cpp:2110
+  if ((requiresAAPCSFrameRecord(MF) ||
+   MF.getTarget().Options.DisableFramePointerElim(MF)) &&
+  !LRSpilled) {

efriedma wrote:
> Should requiresAAPCSFrameRecord() be orthogonal to DisableFramePointerElim()? 
>  I mean, we have a complete set of flags controlling frame pointer 
> elimination; the only part that's "new" here is that the frame pointer is 
> stored in r11, instead of r7.
For cases where a function's codegen requires the use of a frame pointer, we 
want an AAPCS compliant frame record to be generated even when the frame 
pointer elimination is enabled. For that reason we need the two options to be 
orthogonal on some level.
I've updated this check to be more strict and only consider 
`requiresAAPCSFrameRecord()` when the function has a frame pointer.



Comment at: llvm/test/CodeGen/Thumb/frame-access.ll:73
+; CHECK-AAPCS: mov r0, r11
+; CHECK-AAPCS: str r1, [r0, #8]
+; CHECK-AAPCS: mov r0, r11

efriedma wrote:
> Can we use sp-relative accesses here?  If we're not doing dynamic 
> allocations, it should be a fixed offset.
The current criteria for the Arm and Thumb backends is that fixed  frame 
indices are always accessed through FP whenever it is available (See [[ 
https://github.com/llvm/llvm-project/blob/aed49eac87b8aa77298252ea781bae4725ae8046/llvm/lib/Target/ARM/ARMFrameLowering.cpp#L1083
 | ARMFrameLowering.cpp ]]).
I guess that could be changed, but I feel it would fall outside the scope of 
this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125094

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


[PATCH] D125986: [clang][ASTImporter] Add support for import of UsingPackDecl.

2022-05-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a reviewer: martong.
balazske added inline comments.
Herald added a subscriber: rnkovacs.



Comment at: clang/lib/AST/ASTImporter.cpp:4861
+  ToUsingPack->setLexicalDeclContext(LexicalDC);
+  LexicalDC->addDeclInternal(ToUsingPack);
+

martong wrote:
> Why don't we use `addDeclToContexts`?
I do not know, it is not used in the other import functions of `using` related 
declarations. Probably only lexical DC is applicable for these, or the code is 
older than `addDeclToContexts` and was not updated. But then the other import 
functions should be changed too.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:925
+  classTemplateSpecializationDecl(hasDescendant(usingPackDecl(;
+}
+

martong wrote:
> Should we also check if the DeclContext and the Extensions are properly set?
I will add a more detailed test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125986

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


[PATCH] D124637: [clangd][ObjC] Filter ObjC method completions on the remaining selector

2022-05-20 Thread David Goldman 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 rG322e2a3b40fa: [clangd][ObjC] Filter ObjC method completions 
on the remaining selector (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124637

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Sema/CodeCompleteConsumer.cpp

Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -346,6 +346,15 @@
   return nullptr;
 }
 
+std::string CodeCompletionString::getAllTypedText() const {
+  std::string Res;
+  for (const Chunk  : *this)
+if (C.Kind == CK_TypedText)
+  Res += C.Text;
+
+  return Res;
+}
+
 const char *CodeCompletionAllocator::CopyString(const Twine ) {
   SmallString<128> Data;
   StringRef Ref = String.toStringRef(Data);
Index: clang/include/clang/Sema/CodeCompleteConsumer.h
===
--- clang/include/clang/Sema/CodeCompleteConsumer.h
+++ clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -606,9 +606,12 @@
 return begin()[I];
   }
 
-  /// Returns the text in the TypedText chunk.
+  /// Returns the text in the first TypedText chunk.
   const char *getTypedText() const;
 
+  /// Returns the combined text from all TypedText chunks.
+  std::string getAllTypedText() const;
+
   /// Retrieve the priority of this code completion result.
   unsigned getPriority() const { return Priority; }
 
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -58,6 +58,7 @@
 MATCHER_P(nameStartsWith, Prefix, "") {
   return llvm::StringRef(arg.Name).startswith(Prefix);
 }
+MATCHER_P(filterText, F, "") { return arg.FilterText == F; }
 MATCHER_P(scope, S, "") { return arg.Scope == S; }
 MATCHER_P(qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(labeled, Label, "") {
@@ -1918,6 +1919,7 @@
 TEST(CompletionTest, Render) {
   CodeCompletion C;
   C.Name = "x";
+  C.FilterText = "x";
   C.Signature = "(bool) const";
   C.SnippetSuffix = "(${0:bool})";
   C.ReturnType = "int";
@@ -1950,6 +1952,11 @@
   EXPECT_FALSE(R.deprecated);
   EXPECT_EQ(R.score, .5f);
 
+  C.FilterText = "xtra";
+  R = C.render(Opts);
+  EXPECT_EQ(R.filterText, "xtra");
+  EXPECT_EQ(R.sortText, sortText(1.0, "xtra"));
+
   Opts.EnableSnippets = true;
   R = C.render(Opts);
   EXPECT_EQ(R.insertText, "Foo::x(${0:bool})");
@@ -3051,6 +3058,25 @@
   EXPECT_THAT(C, ElementsAre(snippetSuffix("${1:(unsigned int)}")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  + (id)player:(id)player willRun:(id)run;
+  @end
+  id val = [Foo wi^]
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("player:")));
+  EXPECT_THAT(C, ElementsAre(filterText("player:willRun:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(returnType("id")));
+  EXPECT_THAT(C, ElementsAre(signature("(id) willRun:(id)")));
+  EXPECT_THAT(C, ElementsAre(snippetSuffix("${1:(id)} willRun:${2:(id)}")));
+}
+
 TEST(CompletionTest, ObjectiveCSimpleMethodDeclaration) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -155,6 +155,10 @@
 struct CodeCompletion {
   // The unqualified name of the symbol or other completion item.
   std::string Name;
+  // The name of the symbol for filtering and sorting purposes. Typically the
+  // same as `Name`, but may be different e.g. for ObjC methods, `Name` is the
+  // first selector fragment but the `FilterText` is the entire selector.
+  std::string FilterText;
   // The scope qualifier for the symbol name. e.g. "ns1::ns2::"
   // Empty for non-symbol completions. Not inserted, but may be displayed.
   std::string Scope;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -303,6 +303,7 @@
   assert(ASTCtx);
   Completion.Origin |= SymbolOrigin::AST;
   

[clang-tools-extra] 322e2a3 - [clangd][ObjC] Filter ObjC method completions on the remaining selector

2022-05-20 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-05-20T11:49:16-04:00
New Revision: 322e2a3b40fa5f6bfcb868e827960c812b185710

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

LOG: [clangd][ObjC] Filter ObjC method completions on the remaining selector

Previously, clangd would filter completions only on the first part of
the selector (first typed chunk) instead of all remaining selector
fragments (all typed chunks).

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeComplete.h
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/lib/Sema/CodeCompleteConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 920fb77f07dee..527b6cdc304db 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -303,6 +303,7 @@ struct CodeCompletionBuilder {
   assert(ASTCtx);
   Completion.Origin |= SymbolOrigin::AST;
   Completion.Name = std::string(llvm::StringRef(SemaCCS->getTypedText()));
+  Completion.FilterText = SemaCCS->getAllTypedText();
   if (Completion.Scope.empty()) {
 if ((C.SemaResult->Kind == CodeCompletionResult::RK_Declaration) ||
 (C.SemaResult->Kind == CodeCompletionResult::RK_Pattern))
@@ -335,6 +336,8 @@ struct CodeCompletionBuilder {
 Completion.Kind = toCompletionItemKind(C.IndexResult->SymInfo.Kind);
   if (Completion.Name.empty())
 Completion.Name = std::string(C.IndexResult->Name);
+  if (Completion.FilterText.empty())
+Completion.FilterText = Completion.Name;
   // If the completion was visible to Sema, no qualifier is needed. This
   // avoids unneeded qualifiers in cases like with `using ns::X`.
   if (Completion.RequiredQualifier.empty() && !C.SemaResult) {
@@ -352,6 +355,7 @@ struct CodeCompletionBuilder {
   Completion.Origin |= SymbolOrigin::Identifier;
   Completion.Kind = CompletionItemKind::Text;
   Completion.Name = std::string(C.IdentifierResult->Name);
+  Completion.FilterText = Completion.Name;
 }
 
 // Turn absolute path into a literal string that can be #included.
@@ -860,7 +864,15 @@ struct CompletionRecorder : public CodeCompleteConsumer {
   return Result.Pattern->getTypedText();
 }
 auto *CCS = codeCompletionString(Result);
-return CCS->getTypedText();
+const CodeCompletionString::Chunk *OnlyText = nullptr;
+for (auto  : *CCS) {
+  if (C.Kind != CodeCompletionString::CK_TypedText)
+continue;
+  if (OnlyText)
+return CCAllocator->CopyString(CCS->getAllTypedText());
+  OnlyText = 
+}
+return OnlyText ? OnlyText->Text : llvm::StringRef();
   }
 
   // Build a CodeCompletion string for R, which must be from Results.
@@ -1980,6 +1992,7 @@ CodeCompleteResult codeCompleteComment(PathRef FileName, 
unsigned Offset,
   continue;
 CodeCompletion Item;
 Item.Name = Name.str() + "=";
+Item.FilterText = Item.Name;
 Item.Kind = CompletionItemKind::Text;
 Result.Completions.push_back(Item);
   }
@@ -2118,8 +2131,8 @@ CompletionItem CodeCompletion::render(const 
CodeCompleteOptions ) const {
   Doc.append(*Documentation);
 LSP.documentation = renderDoc(Doc, Opts.DocumentationFormat);
   }
-  LSP.sortText = sortText(Score.Total, Name);
-  LSP.filterText = Name;
+  LSP.sortText = sortText(Score.Total, FilterText);
+  LSP.filterText = FilterText;
   LSP.textEdit = {CompletionTokenRange, RequiredQualifier + Name};
   // Merge continuous additionalTextEdits into main edit. The main motivation
   // behind this is to help LSP clients, it seems most of them are confused 
when

diff  --git a/clang-tools-extra/clangd/CodeComplete.h 
b/clang-tools-extra/clangd/CodeComplete.h
index b76dd642943a9..73139ba40e765 100644
--- a/clang-tools-extra/clangd/CodeComplete.h
+++ b/clang-tools-extra/clangd/CodeComplete.h
@@ -155,6 +155,10 @@ struct CodeCompleteOptions {
 struct CodeCompletion {
   // The unqualified name of the symbol or other completion item.
   std::string Name;
+  // The name of the symbol for filtering and sorting purposes. Typically the
+  // same as `Name`, but may be 
diff erent e.g. for ObjC methods, `Name` is the
+  // first selector fragment but the `FilterText` is the entire selector.
+  std::string FilterText;
   // The scope qualifier for the symbol name. e.g. "ns1::ns2::"
   // Empty for non-symbol completions. Not inserted, but may be displayed.
   std::string Scope;

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 

[PATCH] D125773: [Driver] Do not auto-enable header modules with -std=c++20

2022-05-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D125773#3525215 , @tahonermann 
wrote:

>> So the proposal is that -fheader-modules=parse would parse #include of 
>> header unit in the same TU, and import .pcm on import, right?
>
> Per cpp.includep7 , "If the header 
> identified by the //header-name// denotes an importable header 
> ([module.import]), it is implementation-defined whether the #include 
> preprocessing directive is instead replaced by an import directive 
> ([cpp.import]) of the form
> import header-name ; new-line"
>
> For Clang, I would expect the implementation-defined behavior to derive from 
> the existence of a module map that nominates a header as being importable.

Sure, that's what Clang does now. It's totally reasonable.
It seems we can get away with our use-case by passing `-fno-modules` flag as we 
don't really use C++20 modules. It should still provide the layering check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125773

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


[PATCH] D107082: [X86][RFC][WIP] Enable `_Float16` type support on X86 following the psABI

2022-05-20 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 430985.
pengfei retitled this revision from "[X86][RFC] Enable `_Float16` type support 
on X86 following the psABI" to "[X86][RFC][WIP] Enable `_Float16` type support 
on X86 following the psABI".
pengfei added a comment.

Fix a few minor issues. I think it's mature for review now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86InstrVecCompiler.td
  llvm/lib/Target/X86/X86InstructionSelector.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/Analysis/CostModel/X86/fptoi_sat.ll
  llvm/test/CodeGen/MIR/X86/inline-asm-registers.mir
  llvm/test/CodeGen/X86/atomic-non-integer.ll
  llvm/test/CodeGen/X86/avx512-insert-extract.ll
  llvm/test/CodeGen/X86/avx512-masked_memop-16-8.ll
  llvm/test/CodeGen/X86/callbr-asm-bb-exports.ll
  llvm/test/CodeGen/X86/cvt16-2.ll
  llvm/test/CodeGen/X86/cvt16.ll
  llvm/test/CodeGen/X86/fastmath-float-half-conversion.ll
  llvm/test/CodeGen/X86/fmf-flags.ll
  llvm/test/CodeGen/X86/fp-round.ll
  llvm/test/CodeGen/X86/fp-roundeven.ll
  llvm/test/CodeGen/X86/fp128-cast-strict.ll
  llvm/test/CodeGen/X86/fpclamptosat.ll
  llvm/test/CodeGen/X86/fpclamptosat_vec.ll
  llvm/test/CodeGen/X86/fptosi-sat-scalar.ll
  llvm/test/CodeGen/X86/fptosi-sat-vector-128.ll
  llvm/test/CodeGen/X86/fptoui-sat-scalar.ll
  llvm/test/CodeGen/X86/fptoui-sat-vector-128.ll
  llvm/test/CodeGen/X86/freeze.ll
  llvm/test/CodeGen/X86/half-constrained.ll
  llvm/test/CodeGen/X86/half.ll
  llvm/test/CodeGen/X86/pr31088.ll
  llvm/test/CodeGen/X86/pr38533.ll
  llvm/test/CodeGen/X86/pr47000.ll
  llvm/test/CodeGen/X86/scheduler-asm-moves.mir
  llvm/test/CodeGen/X86/shuffle-extract-subvector.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16-fma.ll
  llvm/test/CodeGen/X86/stack-folding-fp-avx512fp16.ll
  llvm/test/CodeGen/X86/statepoint-invoke-ra-enter-at-end.mir
  llvm/test/CodeGen/X86/vec_fp_to_int.ll
  llvm/test/CodeGen/X86/vector-half-conversions.ll
  llvm/test/CodeGen/X86/vector-reduce-fmax-nnan.ll
  llvm/test/CodeGen/X86/vector-reduce-fmin-nnan.ll
  llvm/test/MC/X86/x86_64-asm-match.s

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


[PATCH] D126023: [MSVC, ARM64] Add __writex18 intrinsics

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 430979.
steplong added a comment.

The assembly for LLVM now looks like:

  __writex18byte:
  strbw1, [x18, w0, uxtw]
  ret
  
  __writex18word:
  strhw1, [x18, w0, uxtw]
  ret
  
  __writex18dword:
  str w1, [x18, w0, uxtw]
  ret
  
  __writex18qword:
  str x1, [x18, w0, uxtw]
  ret


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126023

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/arm64-microsoft-intrinsics.c

Index: clang/test/CodeGen/arm64-microsoft-intrinsics.c
===
--- clang/test/CodeGen/arm64-microsoft-intrinsics.c
+++ clang/test/CodeGen/arm64-microsoft-intrinsics.c
@@ -119,5 +119,73 @@
 
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD2:.*]])
 // CHECK-MSVC: call i64 @llvm.read_register.i64(metadata ![[MD3:.*]])
+
+void check__writex18byte(unsigned long offset, unsigned char data) {
+  __writex18byte(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i8, align 1
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i8 %data, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[DATA:.*]] = load i8, i8* %[[DATA_ADDR]], align 1
+// CHECK-MSVC: store i8 %[[DATA]], i8 addrspace(256)* %[[PTR]], align 1
+
+void check__writex18word(unsigned long offset, unsigned short data) {
+  __writex18word(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i16, align 2
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i16 %data, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to i16 addrspace(256)*
+// CHECK-MSVC: %[[DATA:.*]] = load i16, i16* %[[DATA_ADDR]], align 2
+// CHECK-MSVC: store i16 %[[DATA]], i16 addrspace(256)* %[[BITCAST_PTR]], align 1
+
+void check__writex18dword(unsigned long offset, unsigned long data) {
+  __writex18dword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i32 %data, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to i32 addrspace(256)*
+// CHECK-MSVC: %[[DATA:.*]] = load i32, i32* %[[DATA_ADDR]], align 4
+// CHECK-MSVC: store i32 %[[DATA]], i32 addrspace(256)* %[[BITCAST_PTR]], align 1
+
+void check__writex18qword(unsigned long offset, unsigned __int64 data) {
+  __writex18qword(offset, data);
+}
+
+// CHECK-MSVC: %[[DATA_ADDR:.*]] = alloca i64, align 8
+// CHECK-MSVC: %[[OFFSET_ADDR:.*]] = alloca i32, align 4
+// CHECK-MSVC: store i64 %data, i64* %[[DATA_ADDR]], align 8
+// CHECK-MSVC: store i32 %offset, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[X18:.*]] = call i64 @llvm.read_register.i64(metadata ![[MD2]])
+// CHECK-MSVC: %[[X18_AS_PTR:.*]] = inttoptr i64 %[[X18]] to i8 addrspace(256)*
+// CHECK-MSVC: %[[OFFSET:.*]] = load i32, i32* %[[OFFSET_ADDR]], align 4
+// CHECK-MSVC: %[[ZEXT_OFFSET:.*]] = zext i32 %[[OFFSET]] to i64
+// CHECK-MSVC: %[[PTR:.*]] = getelementptr i8, i8 addrspace(256)* %[[X18_AS_PTR]], i64 %[[ZEXT_OFFSET]]
+// CHECK-MSVC: %[[BITCAST_PTR:.*]] = bitcast i8 addrspace(256)* %[[PTR]] to 

[PATCH] D126067: [analyzer] Drop the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 430978.
steakhal added a comment.

Mention this removal in the release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126067

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Analysis/OSAtomic_mac.cpp
  clang/test/Analysis/analyzer-stats.c
  clang/test/Analysis/blocks.m
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/misc-ps-arm.m
  clang/test/Analysis/misc-ps-region-store.cpp
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/misc-ps-region-store.mm
  clang/test/Analysis/objc-arc.m
  clang/test/Analysis/unreachable-code-path.c

Index: clang/test/Analysis/unreachable-code-path.c
===
--- clang/test/Analysis/unreachable-code-path.c
+++ clang/test/Analysis/unreachable-code-path.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -Wno-unused-value %s
 
 extern void foo(int a);
 
Index: clang/test/Analysis/objc-arc.m
===
--- clang/test/Analysis/objc-arc.m
+++ clang/test/Analysis/objc-arc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -analyzer-opt-analyze-nested-blocks -fobjc-arc -analyzer-output=plist-multi-file -analyzer-config deadcode.DeadStores:ShowFixIts=true -o %t.plist %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -fobjc-arc -analyzer-output=plist-multi-file -analyzer-config deadcode.DeadStores:ShowFixIts=true -o %t.plist %s
 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/objc-arc.m.plist -
 
 typedef signed char BOOL;
Index: clang/test/Analysis/misc-ps-region-store.mm
===
--- clang/test/Analysis/misc-ps-region-store.mm
+++ clang/test/Analysis/misc-ps-region-store.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks   %s
 // expected-no-diagnostics
 
 //===--===//
Index: clang/test/Analysis/misc-ps-region-store.m
===
--- clang/test/Analysis/misc-ps-region-store.m
+++ clang/test/Analysis/misc-ps-region-store.m
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes -Wno-error=implicit-function-declaration %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class -Wno-strict-prototypes -Wno-error=implicit-function-declaration %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -Wno-objc-root-class -Wno-strict-prototypes -Wno-error=implicit-function-declaration %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks   -Wno-objc-root-class -Wno-strict-prototypes -Wno-error=implicit-function-declaration %s
 
 typedef long unsigned int size_t;
 void *memcpy(void *, const void *, size_t);
Index: clang/test/Analysis/misc-ps-region-store.cpp
===
--- clang/test/Analysis/misc-ps-region-store.cpp
+++ 

[PATCH] D124637: [clangd][ObjC] Filter ObjC method completions on the remaining selector

2022-05-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 430974.
dgoldman marked an inline comment as done.
dgoldman added a comment.

Go through chunks in getName and add missed FilterText place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124637

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Sema/CodeCompleteConsumer.cpp

Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -346,6 +346,15 @@
   return nullptr;
 }
 
+std::string CodeCompletionString::getAllTypedText() const {
+  std::string Res;
+  for (const Chunk  : *this)
+if (C.Kind == CK_TypedText)
+  Res += C.Text;
+
+  return Res;
+}
+
 const char *CodeCompletionAllocator::CopyString(const Twine ) {
   SmallString<128> Data;
   StringRef Ref = String.toStringRef(Data);
Index: clang/include/clang/Sema/CodeCompleteConsumer.h
===
--- clang/include/clang/Sema/CodeCompleteConsumer.h
+++ clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -606,9 +606,12 @@
 return begin()[I];
   }
 
-  /// Returns the text in the TypedText chunk.
+  /// Returns the text in the first TypedText chunk.
   const char *getTypedText() const;
 
+  /// Returns the combined text from all TypedText chunks.
+  std::string getAllTypedText() const;
+
   /// Retrieve the priority of this code completion result.
   unsigned getPriority() const { return Priority; }
 
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -58,6 +58,7 @@
 MATCHER_P(nameStartsWith, Prefix, "") {
   return llvm::StringRef(arg.Name).startswith(Prefix);
 }
+MATCHER_P(filterText, F, "") { return arg.FilterText == F; }
 MATCHER_P(scope, S, "") { return arg.Scope == S; }
 MATCHER_P(qualifier, Q, "") { return arg.RequiredQualifier == Q; }
 MATCHER_P(labeled, Label, "") {
@@ -1918,6 +1919,7 @@
 TEST(CompletionTest, Render) {
   CodeCompletion C;
   C.Name = "x";
+  C.FilterText = "x";
   C.Signature = "(bool) const";
   C.SnippetSuffix = "(${0:bool})";
   C.ReturnType = "int";
@@ -1950,6 +1952,11 @@
   EXPECT_FALSE(R.deprecated);
   EXPECT_EQ(R.score, .5f);
 
+  C.FilterText = "xtra";
+  R = C.render(Opts);
+  EXPECT_EQ(R.filterText, "xtra");
+  EXPECT_EQ(R.sortText, sortText(1.0, "xtra"));
+
   Opts.EnableSnippets = true;
   R = C.render(Opts);
   EXPECT_EQ(R.insertText, "Foo::x(${0:bool})");
@@ -3051,6 +3058,25 @@
   EXPECT_THAT(C, ElementsAre(snippetSuffix("${1:(unsigned int)}")));
 }
 
+TEST(CompletionTest, ObjectiveCMethodFilterOnEntireSelector) {
+  auto Results = completions(R"objc(
+  @interface Foo
+  + (id)player:(id)player willRun:(id)run;
+  @end
+  id val = [Foo wi^]
+)objc",
+ /*IndexSymbols=*/{},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, ElementsAre(named("player:")));
+  EXPECT_THAT(C, ElementsAre(filterText("player:willRun:")));
+  EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
+  EXPECT_THAT(C, ElementsAre(returnType("id")));
+  EXPECT_THAT(C, ElementsAre(signature("(id) willRun:(id)")));
+  EXPECT_THAT(C, ElementsAre(snippetSuffix("${1:(id)} willRun:${2:(id)}")));
+}
+
 TEST(CompletionTest, ObjectiveCSimpleMethodDeclaration) {
   auto Results = completions(R"objc(
   @interface Foo
Index: clang-tools-extra/clangd/CodeComplete.h
===
--- clang-tools-extra/clangd/CodeComplete.h
+++ clang-tools-extra/clangd/CodeComplete.h
@@ -155,6 +155,10 @@
 struct CodeCompletion {
   // The unqualified name of the symbol or other completion item.
   std::string Name;
+  // The name of the symbol for filtering and sorting purposes. Typically the
+  // same as `Name`, but may be different e.g. for ObjC methods, `Name` is the
+  // first selector fragment but the `FilterText` is the entire selector.
+  std::string FilterText;
   // The scope qualifier for the symbol name. e.g. "ns1::ns2::"
   // Empty for non-symbol completions. Not inserted, but may be displayed.
   std::string Scope;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -303,6 +303,7 @@
   assert(ASTCtx);
   Completion.Origin |= SymbolOrigin::AST;
   Completion.Name = std::string(llvm::StringRef(SemaCCS->getTypedText()));
+  

[PATCH] D126065: [clangd] Provide links to clang-tidy and include-cleaner diagnostic docs

2022-05-20 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedc7a0814575: [clangd] Provide links to clang-tidy and 
include-cleaner diagnostic docs (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D126065?vs=430952=430966#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126065

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/diagnostics-tidy.test
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1828,13 +1828,17 @@
   Cfg.Diagnostics.Includes.IgnoreHeader.emplace_back(
   [](llvm::StringRef Header) { return Header.endswith("ignore.h"); });
   WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  auto AST = TU.build();
   EXPECT_THAT(
-  *TU.build().getDiagnostics(),
+  *AST.getDiagnostics(),
   UnorderedElementsAre(AllOf(
   Diag(Test.range("diag"),
"included header unused.h is not used directly"),
   withTag(DiagnosticTag::Unnecessary), diagSource(Diag::Clangd),
   withFix(Fix(Test.range("fix"), "", "remove #include directive");
+  auto  = AST.getDiagnostics()->front();
+  EXPECT_EQ(getDiagnosticDocURI(Diag.Source, Diag.ID, Diag.Name),
+std::string("https://clangd.llvm.org/guides/include-cleaner;));
   Cfg.Diagnostics.SuppressAll = true;
   WithContextValue SuppressAllWithCfg(Config::Key, std::move(Cfg));
   EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -8,6 +8,9 @@
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
+# CHECK-NEXT:"codeDescription": {
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html;
+# CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -835,6 +835,13 @@
 };
 llvm::json::Value toJSON(DiagnosticTag Tag);
 
+/// Structure to capture a description for an error code.
+struct CodeDescription {
+  /// An URI to open with more information about the diagnostic error.
+  std::string href;
+};
+llvm::json::Value toJSON(const CodeDescription &);
+
 struct CodeAction;
 struct Diagnostic {
   /// The range at which the message applies.
@@ -847,6 +854,9 @@
   /// The diagnostic's code. Can be omitted.
   std::string code;
 
+  /// An optional property to describe the error code.
+  llvm::Optional codeDescription;
+
   /// A human-readable string describing the source of this
   /// diagnostic, e.g. 'typescript' or 'super lint'.
   std::string source;
@@ -874,7 +884,7 @@
 
   /// A data entry field that is preserved between a
   /// `textDocument/publishDiagnostics` notification
-  /// and`textDocument/codeAction` request.
+  /// and `textDocument/codeAction` request.
   /// Mutating users should associate their data with a unique key they can use
   /// to retrieve later on.
   llvm::json::Object data;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -592,6 +592,10 @@
 
 llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
 
+llvm::json::Value toJSON(const CodeDescription ) {
+  return llvm::json::Object{{"href", D.href}};
+}
+
 llvm::json::Value toJSON(const Diagnostic ) {
   llvm::json::Object Diag{
   {"range", D.range},
@@ -604,6 +608,8 @@
 Diag["codeActions"] = D.codeActions;
   if (!D.code.empty())
 Diag["code"] = D.code;
+  if (D.codeDescription.hasValue())
+Diag["codeDescription"] = *D.codeDescription;
   if (!D.source.empty())
 Diag["source"] = D.source;
   if (D.relatedInformation)
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -126,6 +126,10 @@
 /// Convert from clang 

[clang-tools-extra] edc7a08 - [clangd] Provide links to clang-tidy and include-cleaner diagnostic docs

2022-05-20 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-20T16:33:48+02:00
New Revision: edc7a0814575002abecb8ac7b49c669bf5f5ab7a

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

LOG: [clangd] Provide links to clang-tidy and include-cleaner diagnostic docs

LSP supports Diagnostic.codeInformation since 3.16.
In VSCode, this turns the code (e.g. "unused-includes" or "bugprone-foo") into
a clickable link that opens the docs in a web browser.

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

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/diagnostics-tidy.test
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 46a16a9f2eeb..316bc7d1ac66 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -477,6 +477,10 @@ void toLSPDiags(
   }
 
   Main.code = D.Name;
+  if (auto URI = getDiagnosticDocURI(D.Source, D.ID, D.Name)) {
+Main.codeDescription.emplace();
+Main.codeDescription->href = std::move(*URI);
+  }
   switch (D.Source) {
   case Diag::Clang:
 Main.source = "clang";
@@ -903,5 +907,31 @@ llvm::StringRef normalizeSuppressedCode(llvm::StringRef 
Code) {
   return Code;
 }
 
+llvm::Optional getDiagnosticDocURI(Diag::DiagSource Source,
+unsigned ID,
+llvm::StringRef Name) {
+  switch (Source) {
+  case Diag::Unknown:
+break;
+  case Diag::Clang:
+// There is a page listing many warning flags, but it provides too little
+// information to be worth linking.
+// https://clang.llvm.org/docs/DiagnosticsReference.html
+break;
+  case Diag::ClangTidy:
+return {("https://clang.llvm.org/extra/clang-tidy/checks/; + Name + 
".html")
+.str()};
+  case Diag::Clangd:
+if (Name == "unused-includes")
+  return {"https://clangd.llvm.org/guides/include-cleaner"};
+break;
+  case Diag::ClangdConfig:
+// FIXME: we should link to https://clangd.llvm.org/config
+// However we have no diagnostic codes, which the link should describe!
+break;
+  }
+  return llvm::None;
+}
+
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/Diagnostics.h 
b/clang-tools-extra/clangd/Diagnostics.h
index 0c8af97e6695..14627ea3d6a0 100644
--- a/clang-tools-extra/clangd/Diagnostics.h
+++ b/clang-tools-extra/clangd/Diagnostics.h
@@ -126,6 +126,10 @@ CodeAction toCodeAction(const Fix , const URIForFile 
);
 /// Convert from clang diagnostic level to LSP severity.
 int getSeverity(DiagnosticsEngine::Level L);
 
+/// Returns a URI providing more information about a particular diagnostic.
+llvm::Optional getDiagnosticDocURI(Diag::DiagSource, unsigned ID,
+llvm::StringRef Name);
+
 /// StoreDiags collects the diagnostics that can later be reported by
 /// clangd. It groups all notes for a diagnostic into a single Diag
 /// and filters out diagnostics that don't mention the main file (i.e. neither

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 5f8e4938c65a..aed4ac09d486 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -592,6 +592,10 @@ llvm::json::Value toJSON(const 
DiagnosticRelatedInformation ) {
 
 llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
 
+llvm::json::Value toJSON(const CodeDescription ) {
+  return llvm::json::Object{{"href", D.href}};
+}
+
 llvm::json::Value toJSON(const Diagnostic ) {
   llvm::json::Object Diag{
   {"range", D.range},
@@ -604,6 +608,8 @@ llvm::json::Value toJSON(const Diagnostic ) {
 Diag["codeActions"] = D.codeActions;
   if (!D.code.empty())
 Diag["code"] = D.code;
+  if (D.codeDescription.hasValue())
+Diag["codeDescription"] = *D.codeDescription;
   if (!D.source.empty())
 Diag["source"] = D.source;
   if (D.relatedInformation)

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 3f66cb2a5fcd..fd3b671d15f3 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -835,6 +835,13 @@ enum DiagnosticTag {
 };
 llvm::json::Value toJSON(DiagnosticTag Tag);
 
+/// Structure to capture a description for an error code.
+struct CodeDescription {
+  /// An URI to open with more information about the diagnostic error.
+  std::string href;
+};
+llvm::json::Value toJSON(const CodeDescription &);
+
 struct 

[PATCH] D126068: [llvm][clang][bolt][NFC] Use llvm::less_first() when applicable

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: aaron.ballman, lattner.
Herald added subscribers: ayermolo, jdoerfert, martong, mgrang, hiraditya.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: jhenderson.
Herald added a reviewer: Szelethus.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
steakhal requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, yota9, MaskRay.
Herald added projects: clang, LLVM.

One could reuse this functor instead of rolling out your own version.
There were a couple other cases where the code was similar, but not
quite the same, such as it might have an assertion in the lambda or other
constructs. Thus, I've not touched any of those, as it might change the
behavior in some way.

As per 
https://discourse.llvm.org/t/submitting-simple-nfc-patches/62640/3?u=steakhal
Chris Lattner

> LLVM intentionally has a “yes, you can apply common sense judgement to
> things” policy when it comes to code review. If you are doing mechanical
> patches (e.g. adopting less_first) that apply to the entire monorepo,
> then you don’t need everyone in the monorepo to sign off on it. Having
> some +1 validation from someone is useful, but you don’t need everyone
> whose code you touch to weigh in.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126068

Files:
  bolt/lib/Passes/LongJmp.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
  clang/unittests/Introspection/IntrospectionTest.cpp
  llvm/include/llvm/ExecutionEngine/Orc/Core.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/ObjCopy/MachO/MachOWriter.cpp
  llvm/tools/dsymutil/DebugMap.cpp
  llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp

Index: llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
===
--- llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceAttributes.cpp
@@ -158,10 +158,8 @@
   V.first, convertAttributeRefToAttributeSet(C, V.second));
 });
 
-  sort(SetVec, [](const std::pair ,
-  const std::pair ) {
-return LHS.first < RHS.first; // All values are unique.
-  });
+  // All values are unique.
+  sort(SetVec, llvm::less_first());
 
   return AttributeList::get(C, SetVec);
 }
Index: llvm/tools/dsymutil/DebugMap.cpp
===
--- llvm/tools/dsymutil/DebugMap.cpp
+++ llvm/tools/dsymutil/DebugMap.cpp
@@ -62,9 +62,7 @@
   Entries.reserve(Symbols.getNumItems());
   for (const auto  : Symbols)
 Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue()));
-  llvm::sort(Entries, [](const Entry , const Entry ) {
-return LHS.first < RHS.first;
-  });
+  llvm::sort(Entries, llvm::less_first());
   for (const auto  : Entries) {
 if (Sym.second.ObjectAddress)
   OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
Index: llvm/lib/ObjCopy/MachO/MachOWriter.cpp
===
--- llvm/lib/ObjCopy/MachO/MachOWriter.cpp
+++ llvm/lib/ObjCopy/MachO/MachOWriter.cpp
@@ -634,9 +634,7 @@
 }
   }
 
-  llvm::sort(Queue, [](const WriteOperation , const WriteOperation ) {
-return LHS.first < RHS.first;
-  });
+  llvm::sort(Queue, llvm::less_first());
 
   for (auto WriteOp : Queue)
 (this->*WriteOp.second)();
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -1018,11 +1018,7 @@
   if (Attrs.empty())
 return {};
 
-  assert(llvm::is_sorted(Attrs,
- [](const std::pair ,
-const std::pair ) {
-   return LHS.first < RHS.first;
- }) &&
+  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
  "Misordered Attributes list!");
   assert(llvm::all_of(Attrs,
   [](const std::pair ) {
@@ -1055,11 +1051,7 @@
   if (Attrs.empty())
 return {};
 
-  assert(llvm::is_sorted(Attrs,
- [](const std::pair ,
-const std::pair ) {
-   return LHS.first < RHS.first;
- }) &&
+  assert(llvm::is_sorted(Attrs, llvm::less_first()) &&
  "Misordered Attributes list!");
   assert(llvm::none_of(Attrs,
[](const std::pair ) {
Index: llvm/include/llvm/ExecutionEngine/Orc/Core.h
===
--- llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -339,11 +339,7 @@
   /// Sort the lookup set by pointer value. This sort is fast but sensitive to
   /// 

[PATCH] D125931: [clang][dataflow] Add support for correlated branches to optional model

2022-05-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D125931#3527584 , @ymandel wrote:

> 1. In this patch, we go with a widening operation, but put the relevant logic 
> in the core, so it can be reused for booleans in general.

Depending on how much simplicity are we willing to sacrifice, doing a merge 
here might be OK. We only need widening to ensure the convergence of loops. 
Some frameworks are doing the regular merge operator for joins in the CFG and 
only use the widening operator along the back edges. This way they can be a bit 
more precise while preserving convergence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125931

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


[PATCH] D126067: [analyzer] Drop the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag

2022-05-20 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Uhh, ohh, don't forget to reflect this change in the ReleaseNotes.rst, so urers 
will be notified!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126067

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


[PATCH] D126067: [analyzer] Drop the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag

2022-05-20 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

> However, this arises a couple of burning questions.
>
> Should the cc1 frontend still accept this flag - to keep tools/users passing 
> this flag directly to cc1 (which is unsupported, unadvertised) working.
> If we should remain backward compatible, how long?
> How can we get rid of deprecated and obsolete flags at some point?

The answer might be similar to what we do in case of a checker rename (or when 
we move out from alpha). Such a rename have the same problems, but we have not 
made much efforts to combat these problem. Users had to comply.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126067

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


[PATCH] D125970: [amdgpu] Add amdgpu_kernel calling conv attribute to clang

2022-05-20 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

If it was adding a calling convention, sure - caution warranted. There's no 
llvm change here though, an existing CC is exposed to C++. No change to the 
type system either.

I'll propose a patch with some documentation for it if you wish, but it'll just 
say "For ad hoc debugging of the amdgpu backend". Undocumented seems to state 
that more clearly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125970

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


[PATCH] D125749: [analyzer][NFC] Introduce SVal::isa

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

There is one minor problem with this patch.

At `SVal` member function's context one needs to call `llvm::isa<...>()` with 
by the qualified name, otherwise, the `isa` is ambiguous.
The compiler won't know if we want to refer to the free-function or the 
variadic member function; and the error message is not particularly helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125749

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


[PATCH] D125961: [clang-format] Don't break lines after pragma region

2022-05-20 Thread Tobias Hieta 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 rG749fb33e82ff: [clang-format] Dont break lines after 
pragma region (authored by thieta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125961

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19597,6 +19597,13 @@
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption   -C   -A"));
 }
 
+TEST_F(FormatTest, UnderstandPragmaRegion) {
+  auto Style = getLLVMStyleWithColumns(0);
+  verifyFormat("#pragma region TEST(FOO : BAR)", Style);
+
+  EXPECT_EQ("#pragma region TEST(FOO : BAR)", format("#pragma region TEST(FOO 
: BAR)", Style));
+}
+
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
   FormatStyle Style = getLLVMStyleWithColumns(20);
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1251,9 +1251,9 @@
   void parsePragma() {
 next(); // Consume "pragma".
 if (CurrentToken &&
-CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option, 
Keywords.kw_region)) {
   bool IsMark = CurrentToken->is(Keywords.kw_mark);
-  next(); // Consume "mark".
+  next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
 if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -930,6 +930,7 @@
 kw___has_include_next = ("__has_include_next");
 
 kw_mark = ("mark");
+kw_region = ("region");
 
 kw_extend = ("extend");
 kw_option = ("option");
@@ -1053,6 +1054,7 @@
 
   // Pragma keywords.
   IdentifierInfo *kw_mark;
+  IdentifierInfo *kw_region;
 
   // Proto keywords.
   IdentifierInfo *kw_extend;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19597,6 +19597,13 @@
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption   -C   -A"));
 }
 
+TEST_F(FormatTest, UnderstandPragmaRegion) {
+  auto Style = getLLVMStyleWithColumns(0);
+  verifyFormat("#pragma region TEST(FOO : BAR)", Style);
+
+  EXPECT_EQ("#pragma region TEST(FOO : BAR)", format("#pragma region TEST(FOO : BAR)", Style));
+}
+
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
   FormatStyle Style = getLLVMStyleWithColumns(20);
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1251,9 +1251,9 @@
   void parsePragma() {
 next(); // Consume "pragma".
 if (CurrentToken &&
-CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option, Keywords.kw_region)) {
   bool IsMark = CurrentToken->is(Keywords.kw_mark);
-  next(); // Consume "mark".
+  next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
 if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -930,6 +930,7 @@
 kw___has_include_next = ("__has_include_next");
 
 kw_mark = ("mark");
+kw_region = ("region");
 
 kw_extend = ("extend");
 kw_option = ("option");
@@ -1053,6 +1054,7 @@
 
   // Pragma keywords.
   IdentifierInfo *kw_mark;
+  IdentifierInfo *kw_region;
 
   // Proto keywords.
   IdentifierInfo *kw_extend;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 749fb33 - [clang-format] Don't break lines after pragma region

2022-05-20 Thread Tobias Hieta via cfe-commits

Author: Tobias Hieta
Date: 2022-05-20T16:11:20+02:00
New Revision: 749fb33e82ff19d656af9c9205f3ac81c1ce52d8

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

LOG: [clang-format] Don't break lines after pragma region

We have autogenerated pragma regions in our code
which where awkwardly broken up like this:

```
#pragma region foo(bar : hello)
```
becomes

```
#pragma region foo(bar \
   : hello)
```

This fixes the problem by adding region as a keyword
and handling it the same way as pragma mark

Reviewed By: curdeius

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 9990933fcb20..71acdf2f094b 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -930,6 +930,7 @@ struct AdditionalKeywords {
 kw___has_include_next = ("__has_include_next");
 
 kw_mark = ("mark");
+kw_region = ("region");
 
 kw_extend = ("extend");
 kw_option = ("option");
@@ -1053,6 +1054,7 @@ struct AdditionalKeywords {
 
   // Pragma keywords.
   IdentifierInfo *kw_mark;
+  IdentifierInfo *kw_region;
 
   // Proto keywords.
   IdentifierInfo *kw_extend;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 68f35643bbf2..9afe4f8fb086 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1251,9 +1251,9 @@ class AnnotatingParser {
   void parsePragma() {
 next(); // Consume "pragma".
 if (CurrentToken &&
-CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option)) {
+CurrentToken->isOneOf(Keywords.kw_mark, Keywords.kw_option, 
Keywords.kw_region)) {
   bool IsMark = CurrentToken->is(Keywords.kw_mark);
-  next(); // Consume "mark".
+  next();
   next(); // Consume first token (so we fix leading whitespace).
   while (CurrentToken) {
 if (IsMark || CurrentToken->Previous->is(TT_BinaryOperator))

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e54a6db2ca46..762ccf7dbd8d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -19597,6 +19597,13 @@ TEST_F(FormatTest, UnderstandPragmaOption) {
   EXPECT_EQ("#pragma option -C -A", format("#pragmaoption   -C   -A"));
 }
 
+TEST_F(FormatTest, UnderstandPragmaRegion) {
+  auto Style = getLLVMStyleWithColumns(0);
+  verifyFormat("#pragma region TEST(FOO : BAR)", Style);
+
+  EXPECT_EQ("#pragma region TEST(FOO : BAR)", format("#pragma region TEST(FOO 
: BAR)", Style));
+}
+
 TEST_F(FormatTest, OptimizeBreakPenaltyVsExcess) {
   FormatStyle Style = getLLVMStyleWithColumns(20);
 



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


[PATCH] D125209: [clang-tidy] modernize-deprecated-headers check should respect extern "C" blocks

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

WDYT, are there any blocker issues with this patch stack?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125209

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


[PATCH] D125920: [analyzer][NFC] Remove the unused LocAsInteger::getPersistentLoc()

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5450db5f54b8: [analyzer][NFC] Remove the unused 
LocAsInteger::getPersistentLoc() (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125920

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -432,13 +432,6 @@
 return D->first.castAs();
   }
 
-  Loc getPersistentLoc() const {
-const std::pair *D =
-  static_cast *>(Data);
-const SVal& V = D->first;
-return V.castAs();
-  }
-
   unsigned getNumBits() const {
 const std::pair *D =
   static_cast *>(Data);


Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -432,13 +432,6 @@
 return D->first.castAs();
   }
 
-  Loc getPersistentLoc() const {
-const std::pair *D =
-  static_cast *>(Data);
-const SVal& V = D->first;
-return V.castAs();
-  }
-
   unsigned getNumBits() const {
 const std::pair *D =
   static_cast *>(Data);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5450db5 - [analyzer][NFC] Remove the unused LocAsInteger::getPersistentLoc()

2022-05-20 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-05-20T16:06:46+02:00
New Revision: 5450db5f54b86f908ce67cb681fbdf86b88abc54

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

LOG: [analyzer][NFC] Remove the unused LocAsInteger::getPersistentLoc()

Reviewed By: martong

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index f4b229070d67..60a59cbeecf9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -432,13 +432,6 @@ class LocAsInteger : public NonLoc {
 return D->first.castAs();
   }
 
-  Loc getPersistentLoc() const {
-const std::pair *D =
-  static_cast *>(Data);
-const SVal& V = D->first;
-return V.castAs();
-  }
-
   unsigned getNumBits() const {
 const std::pair *D =
   static_cast *>(Data);



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


[PATCH] D125920: [analyzer][NFC] Remove the unused LocAsInteger::getPersistentLoc()

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

In D125920#3524586 , @martong wrote:

> LGTM. Are there any other `getPersistentLoc` function definitions in other 
> SVals? Might they be also unused?

IDK, might be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125920

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


[PATCH] D125893: [RISCV][NFC] Change interface of RVVIntrinsic::getSuffixStr

2022-05-20 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames 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/D125893/new/

https://reviews.llvm.org/D125893

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


[PATCH] D126067: [analyzer] Drop the unused 'analyzer-opt-analyze-nested-blocks' cc1 flag

2022-05-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, martong, Szelethus.
Herald added subscribers: carlosgalvezp, manas, ASDenysPetrov, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added projects: clang, clang-tools-extra.

This flag was introduced by
https://github.com/llvm/llvm-project/commit/6818991d7165f68fe196922d9e5c6648dd57cc47

  commit 6818991d7165f68fe196922d9e5c6648dd57cc47
  Author: Ted Kremenek 
  Date:   Mon Dec 7 22:06:12 2009 +
  
  Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat
  block literals as an entry point for analyzer checks.

The last reference was removed by this commit:
https://github.com/llvm/llvm-project/commit/5c32dfc5fb1cfcff8ae3671284e17daa8da3a188

  commit 5c32dfc5fb1cfcff8ae3671284e17daa8da3a188
  Author: Anna Zaks 
  Date:   Fri Dec 21 01:19:15 2012 +
  
  [analyzer] Add blocks and ObjC messages to the call graph.
  This paves the road for constructing a better function dependency graph.
  If we analyze a function before the functions it calls and inlines,
  there is more opportunity for optimization.
  Note, we add call edges to the called methods that correspond to
  function definitions (declarations with bodies).

Consequently, we should remove this dead flag.
However, this arises a couple of burning questions.

- Should the `cc1` frontend still accept this flag - to keep tools/users 
passing this flag directly to `cc1` (which is unsupported, unadvertised) 
working.
- If we should remain backward compatible, how long?
- How can we get rid of deprecated and obsolete flags at some point?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126067

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Analysis/OSAtomic_mac.cpp
  clang/test/Analysis/analyzer-stats.c
  clang/test/Analysis/blocks.m
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/misc-ps-arm.m
  clang/test/Analysis/misc-ps-region-store.cpp
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/misc-ps-region-store.mm
  clang/test/Analysis/objc-arc.m
  clang/test/Analysis/unreachable-code-path.c

Index: clang/test/Analysis/unreachable-code-path.c
===
--- clang/test/Analysis/unreachable-code-path.c
+++ clang/test/Analysis/unreachable-code-path.c
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -Wno-unused-value %s
 
 extern void foo(int a);
 
Index: clang/test/Analysis/objc-arc.m
===
--- clang/test/Analysis/objc-arc.m
+++ clang/test/Analysis/objc-arc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -analyzer-opt-analyze-nested-blocks -fobjc-arc -analyzer-output=plist-multi-file -analyzer-config deadcode.DeadStores:ShowFixIts=true -o %t.plist %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -fobjc-arc -analyzer-output=plist-multi-file -analyzer-config deadcode.DeadStores:ShowFixIts=true -o %t.plist %s
 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/objc-arc.m.plist -
 
 typedef signed char BOOL;
Index: clang/test/Analysis/misc-ps-region-store.mm
===
--- clang/test/Analysis/misc-ps-region-store.mm
+++ clang/test/Analysis/misc-ps-region-store.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks   -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks   %s
 // expected-no-diagnostics
 
 //===--===//
Index: clang/test/Analysis/misc-ps-region-store.m
===
--- clang/test/Analysis/misc-ps-region-store.m
+++ 

[PATCH] D125970: [amdgpu] Add amdgpu_kernel calling conv attribute to clang

2022-05-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D125970#3527624 , @aaron.ballman 
wrote:

>> The primary application is for more rapid debugging of the amdgpu backend by 
>> permuting a C or C++ test file instead of manually updating an IR file.
>
> Given that this is adding a calling convention, which has significant impacts 
> on our type system: is this use case important enough to steal a bit for this 
> CC? This sounds *super* special case to me, but maybe it's a common need?

Btw, I'd appreciate if you gave code reviewers more than one day to review a 
change to the type system before landing -- I'm in WG14 meetings all week, so I 
don't have much time to do a thorough review of something like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125970

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


[PATCH] D125970: [amdgpu] Add amdgpu_kernel calling conv attribute to clang

2022-05-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> The primary application is for more rapid debugging of the amdgpu backend by 
> permuting a C or C++ test file instead of manually updating an IR file.

Given that this is adding a calling convention, which has significant impacts 
on our type system: is this use case important enough to steal a bit for this 
CC? This sounds *super* special case to me, but maybe it's a common need?




Comment at: clang/include/clang/Basic/Attr.td:1862
+  let Spellings = [Clang<"amdgpu_kernel">];
+  let Documentation = [Undocumented];
+}

No new undocumented attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125970

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


[PATCH] D125683: [runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice

2022-05-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:124
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "")

phosek wrote:
> ldionne wrote:
> > phosek wrote:
> > > ldionne wrote:
> > > > Note that I am removing these options here because I don't think they 
> > > > are required -- since we specify `LIBCXXABI_ENABLE_SHARED=OFF`, there 
> > > > is no shared libc++abi to link against, so we should already be linking 
> > > > against `libc++abi.a` regardless of this change.
> > > This option was set to merge `libc++abi.a` into `libc++.a` so to achieve 
> > > the same effect, presumably we would need to set 
> > > `-DLIBCXX_CXX_ABI=libcxxabi-objects`?
> > I agree this is suspicious, but why is there no 
> > `LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY` specified here then? I can 
> > add `-DLIBCXX_CXX_ABI=libcxxabi-objects`, I just want to make sure we both 
> > understand what's going on.
> This is intentional. We are merging `libc++abi.a` into `libc++.a` but we ship 
> `libc++abi.so` and `libc++.so` as separate (and use the generated linker 
> script to pull in `libc++abi.so` when you pass `-lc++` to linker). I'd be 
> fine merging `libc++abi.so` into `libc++.so` as well, but we'll need to 
> figure out a transition plan since there are several places in our build 
> right now that expect `libc++abi.so` to exist. We cannot land this change as 
> is because that would break the `-static-libstdc++` use case, since Clang 
> driver only passes `-lc++` to the linker and not `-lc++abi` and there's 
> nothing that would pull `libc++abi.a` in.
I see, so to summarize, basically you want to use `libcxxabi-objects` for the 
static `libc++.a`, but `libcxxabi` for the dynamic `libc++.so`. This change as 
currently laid out does not permit that to happen, since `libcxxabi-objects` 
implies that the objects are merged both in the static and in the shared 
library. I guess we could introduce a new `libcxxabi-objects-static` option, 
however that would be kind of strange. We can either do that, or wait for you 
to stop relying on `libc++abi.so` existing and switch to `libcxxabi-objects` 
wholesale for Fuchsia. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125683

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


[PATCH] D126066: [clang] Don't plumb access specifier attributes through Parser unnecessarily.

2022-05-20 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

I noticed that a lot of functions in the parser take an `AccessAttrs` parameter,
even though, as far as I can tell, it's sufficient to handle access specifier
attributes locally where the access specifier is parsed.

I have removed all of this plumbing, and tests still pass. Much of the code
involved is pretty old, so I suspect this plumbing was required at some point
but that the underlying reason has now been eliminated. It may also be that at
some point people started simply following the pattern of "pass `AccessAttrs`
wherever an `AccessSpecifier` is passed".

However, I would appreciate a close look from someone who's more familiar with
the code than I am.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126066

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/Parser.cpp

Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -819,7 +819,7 @@
   case tok::annot_attr_openmp:
   case tok::annot_pragma_openmp: {
 AccessSpecifier AS = AS_none;
-return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
+return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS);
   }
   case tok::annot_pragma_ms_pointers_to_members:
 HandlePragmaMSPointersToMembers();
@@ -974,7 +974,7 @@
  diag::ext_extern_template) << SourceRange(ExternLoc, TemplateLoc);
   SourceLocation DeclEnd;
   return Actions.ConvertDeclToDeclGroup(ParseExplicitInstantiation(
-  DeclaratorContext::File, ExternLoc, TemplateLoc, DeclEnd, Attrs));
+  DeclaratorContext::File, ExternLoc, TemplateLoc, DeclEnd));
 }
 goto dont_know;
 
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -35,17 +35,16 @@
 
 /// Parse a template declaration, explicit instantiation, or
 /// explicit specialization.
-Decl *Parser::ParseDeclarationStartingWithTemplate(
-DeclaratorContext Context, SourceLocation ,
-ParsedAttributes , AccessSpecifier AS) {
+Decl *Parser::ParseDeclarationStartingWithTemplate(DeclaratorContext Context,
+   SourceLocation ,
+   AccessSpecifier AS) {
   ObjCDeclContextSwitch ObjCDC(*this);
 
   if (Tok.is(tok::kw_template) && NextToken().isNot(tok::less)) {
 return ParseExplicitInstantiation(Context, SourceLocation(), ConsumeToken(),
-  DeclEnd, AccessAttrs, AS);
+  DeclEnd, AS);
   }
-  return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AccessAttrs,
-  AS);
+  return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AS);
 }
 
 /// Parse a template declaration or an explicit specialization.
@@ -73,8 +72,7 @@
 ///   explicit-specialization: [ C++ temp.expl.spec]
 /// 'template' '<' '>' declaration
 Decl *Parser::ParseTemplateDeclarationOrSpecialization(
-DeclaratorContext Context, SourceLocation ,
-ParsedAttributes , AccessSpecifier AS) {
+DeclaratorContext Context, SourceLocation , AccessSpecifier AS) {
   assert(Tok.isOneOf(tok::kw_export, tok::kw_template) &&
  "Token does not start a template declaration.");
 
@@ -170,7 +168,7 @@
   return ParseSingleDeclarationAfterTemplate(
   Context,
   ParsedTemplateInfo(, isSpecialization, LastParamListWasEmpty),
-  ParsingTemplateParams, DeclEnd, AccessAttrs, AS);
+  ParsingTemplateParams, DeclEnd, AS);
 }
 
 /// Parse a single declaration that declares a template,
@@ -186,7 +184,7 @@
 Decl *Parser::ParseSingleDeclarationAfterTemplate(
 DeclaratorContext Context, const ParsedTemplateInfo ,
 ParsingDeclRAIIObject , SourceLocation ,
-ParsedAttributes , AccessSpecifier AS) {
+AccessSpecifier AS) {
   assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
  "Template information required");
 
@@ -200,8 +198,7 @@
 
   if (Context == DeclaratorContext::Member) {
 // We are parsing a member template.
-ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
-   );
+ParseCXXClassMemberDeclaration(AS, TemplateInfo, );
 return nullptr;
   }
 
@@ -1640,7 +1637,6 @@
  SourceLocation ExternLoc,
  SourceLocation TemplateLoc,

[PATCH] D124701: [clang] Honor __attribute__((no_builtin("foo"))) on functions

2022-05-20 Thread Stephen Long via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae80024fbe51: [clang] Honor 
__attribute__((no_builtin(foo))) on functions (authored by 
steplong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124701

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/no-builtin-2.c

Index: clang/test/CodeGen/no-builtin-2.c
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin-2.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef typeof(sizeof(0)) size_t;
+
+void bar(char *s);
+void *memset(void *s, int c, size_t n);
+void *memcpy(void *d, const void *s, size_t n);
+void *memmove(void *d, const void *s, size_t n);
+
+// CHECK: define{{.*}} void @foo1({{.*}}) #[[NO_NOBUILTIN:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   call void @llvm.memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo1(char *s, char *d, size_t n) {
+  bar(s);
+  memset(s, 0, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo2({{.*}}) #[[NOBUILTIN_MEMSET:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo2(char *s, char *d, size_t n) __attribute__((no_builtin("memset"))) {
+  bar(s);
+  memset(s, 1, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo3({{.*}}) #[[NOBUILTIN_MEMSET_MEMCPY:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   {{.*}}call {{.*}} @memcpy
+// CHECK:   call void @llvm.memmove
+void foo3(char *s, char *d, size_t n) __attribute__((no_builtin("memset", "memcpy"))) {
+  bar(s);
+  memset(s, 2, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo4({{.*}}) #[[NOBUILTINS:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   {{.*}}call {{.*}} @memcpy
+// CHECK:   {{.*}}call {{.*}} @memmove
+void foo4(char *s, char *d, size_t n) __attribute__((no_builtin)) {
+  bar(s);
+  memset(s, 2, n);
+  memcpy(d, s, n);
+  memmove(s, d, n);
+}
+
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK-NOT: attributes #[[NO_NOBUILTIN]] = {{{.*}}"no-builtins"{{.*}}}
+// CHECK: attributes #[[NOBUILTIN_MEMSET]] = {{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK: attributes #[[NOBUILTIN_MEMSET_MEMCPY]] = {{{.*}}"no-builtin-memcpy"{{.*}}"no-builtin-memset"{{.*}}}
+// CHECK: attributes #[[NOBUILTINS]] = {{{.*}}"no-builtins"{{.*}}}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5034,7 +5034,16 @@
   const FunctionDecl *FD = cast(GD.getDecl());
 
   if (auto builtinID = FD->getBuiltinID()) {
+std::string NoBuiltinFD = ("no-builtin-" + FD->getName()).str();
+std::string NoBuiltins = "no-builtins";
 std::string FDInlineName = (FD->getName() + ".inline").str();
+
+bool IsPredefinedLibFunction =
+CGF.getContext().BuiltinInfo.isPredefinedLibFunction(builtinID);
+bool HasAttributeNoBuiltin =
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltinFD) ||
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltins);
+
 // When directing calling an inline builtin, call it through it's mangled
 // name to make it clear it's not the actual builtin.
 if (CGF.CurFn->getName() != FDInlineName &&
@@ -5054,8 +5063,11 @@
 
 // Replaceable builtins provide their own implementation of a builtin. If we
 // are in an inline builtin implementation, avoid trivial infinite
-// recursion.
-else
+// recursion. Honor __attribute__((no_builtin("foo"))) or
+// __attribute__((no_builtin)) on the current function unless foo is
+// not a predefined library function which means we must generate the
+// builtin no matter what.
+else if (!IsPredefinedLibFunction || !HasAttributeNoBuiltin)
   return CGCallee::forBuiltin(builtinID, FD);
   }
 
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -6000,9 +6000,6 @@
 def NoBuiltinDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-.. Note:: This attribute is not yet fully implemented, it is validated but has
-  no effect on the generated code.
-
 The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
 except it is specific to the body of a function. The attribute may also be
 applied to a virtual 

[clang] ae80024 - [clang] Honor __attribute__((no_builtin("foo"))) on functions

2022-05-20 Thread Stephen Long via cfe-commits

Author: Stephen Long
Date: 2022-05-20T06:41:47-07:00
New Revision: ae80024fbe51339afabfa2ff43ae532356fa3c93

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

LOG: [clang] Honor __attribute__((no_builtin("foo"))) on functions

Support for `__attribute__((no_builtin("foo")))` was added in 
https://reviews.llvm.org/D68028,
but builtins were still being used even when the attribute was placed on a 
function.

Reviewed By: hans

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

Added: 
clang/test/CodeGen/no-builtin-2.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 69b5dc1dd1fd..5d1b12504f78 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -318,6 +318,10 @@ Attribute Changes in Clang
 - The ``__declspec(naked)`` attribute can no longer be written on a member
   function in Microsoft compatibility mode, matching the behavior of cl.exe.
 
+- Attribute ``no_builtin`` should now affect the generated code. It now 
disables
+  builtins (corresponding to the specific names listed in the attribute) in the
+  body of the function the attribute is on.
+
 Windows Support
 ---
 

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d635da6b84b8..aedf11a70753 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6000,9 +6000,6 @@ attribute `clang_builtin_alias`.
 def NoBuiltinDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-.. Note:: This attribute is not yet fully implemented, it is validated but has
-  no effect on the generated code.
-
 The ``__attribute__((no_builtin))`` is similar to the ``-fno-builtin`` flag
 except it is specific to the body of a function. The attribute may also be
 applied to a virtual function but has no effect on the behavior of overriding

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index fbe1586001b1..3d7f13aed0ab 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5034,7 +5034,16 @@ static CGCallee EmitDirectCallee(CodeGenFunction , 
GlobalDecl GD) {
   const FunctionDecl *FD = cast(GD.getDecl());
 
   if (auto builtinID = FD->getBuiltinID()) {
+std::string NoBuiltinFD = ("no-builtin-" + FD->getName()).str();
+std::string NoBuiltins = "no-builtins";
 std::string FDInlineName = (FD->getName() + ".inline").str();
+
+bool IsPredefinedLibFunction =
+CGF.getContext().BuiltinInfo.isPredefinedLibFunction(builtinID);
+bool HasAttributeNoBuiltin =
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltinFD) ||
+CGF.CurFn->getAttributes().hasFnAttr(NoBuiltins);
+
 // When directing calling an inline builtin, call it through it's mangled
 // name to make it clear it's not the actual builtin.
 if (CGF.CurFn->getName() != FDInlineName &&
@@ -5054,8 +5063,11 @@ static CGCallee EmitDirectCallee(CodeGenFunction , 
GlobalDecl GD) {
 
 // Replaceable builtins provide their own implementation of a builtin. If 
we
 // are in an inline builtin implementation, avoid trivial infinite
-// recursion.
-else
+// recursion. Honor __attribute__((no_builtin("foo"))) or
+// __attribute__((no_builtin)) on the current function unless foo is
+// not a predefined library function which means we must generate the
+// builtin no matter what.
+else if (!IsPredefinedLibFunction || !HasAttributeNoBuiltin)
   return CGCallee::forBuiltin(builtinID, FD);
   }
 

diff  --git a/clang/test/CodeGen/no-builtin-2.c 
b/clang/test/CodeGen/no-builtin-2.c
new file mode 100644
index ..f236f29779e0
--- /dev/null
+++ b/clang/test/CodeGen/no-builtin-2.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef typeof(sizeof(0)) size_t;
+
+void bar(char *s);
+void *memset(void *s, int c, size_t n);
+void *memcpy(void *d, const void *s, size_t n);
+void *memmove(void *d, const void *s, size_t n);
+
+// CHECK: define{{.*}} void @foo1({{.*}}) #[[NO_NOBUILTIN:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   call void @llvm.memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo1(char *s, char *d, size_t n) {
+  bar(s);
+  memset(s, 0, n);
+  memcpy(d, s, n);
+  memmove(d, s, n);
+}
+
+// CHECK: define{{.*}} void @foo2({{.*}}) #[[NOBUILTIN_MEMSET:[0-9]+]]
+// CHECK:   call void @bar
+// CHECK:   {{.*}}call {{.*}} @memset
+// CHECK:   call void @llvm.memcpy
+// CHECK:   call void @llvm.memmove
+void foo2(char *s, char *d, size_t n) __attribute__((no_builtin("memset"))) {
+  bar(s);
+  

  1   2   >