[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-01-27 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: dblaikie, aaron.ballman, erichkeane.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

This patch introduces a new warning flag `-Wcomparison-op-parentheses` in 
`-Wparentheses` to issue warnings with its fixit hint for comparison operators 
within another comparison operator.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142800

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/comparison-op-parentheses.c

Index: clang/test/Sema/comparison-op-parentheses.c
===
--- /dev/null
+++ clang/test/Sema/comparison-op-parentheses.c
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DSILENCE
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wcomparison-op-parentheses
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wparentheses
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -Wcomparison-op-parentheses 2>&1 | FileCheck %s
+
+#ifdef SILENCE
+// expected-no-diagnostics
+#endif
+
+void comparison_op_parentheses(int a, int b, int c) {
+  (void)(a ==
+ b > c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '=='}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  (void)(a ==b == c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'==' within '=='}}
+  // expected-note@-3 {{place parentheses around the '==' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
+
+  (void)(a !=b == c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'!=' within '=='}}
+  // expected-note@-3 {{place parentheses around the '!=' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
+
+  (void)(a !=
+ b < c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'<' within '!='}}
+  // expected-note@-3 {{place parentheses around the '<' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  (void)(a>=b >= c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>=' within '>='}}
+  // expected-note@-3 {{place parentheses around the '>=' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+  (void)(a >b >= c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '>='}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+  (void)(a >b > c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '>'}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+
+
+  (void)(a c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'<' within '>'}}
+  // expected-note@-3 {{place parentheses around the '<' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:13-[[@LINE-6]]:13}:")"
+
+  (void)(a != (b > c));
+  (void)(a == (b > c));
+  (void)((a>b) >= c);
+  (void)((a c);
+  (void)(a != b && a > c);
+  (void)((a c);
+  (void)((a (c > a));
+
+}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -92,6 +92,7 @@
 CHECK-NEXT:-Wlogical-not-parentheses
 CHECK-NEXT:-Wbitwise-conditional-parentheses
 CHECK-NEXT:-Wbitwise-op-parentheses
+CHECK-NEXT:-Wcomparison-op-parentheses
 CHECK-NEXT:-Wshift-op-parentheses
 CHECK-NEXT:-Woverloaded-shift-op-parentheses
 CHECK-NEXT:-Wparentheses-equality
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15534,6 +15534,37 @@
   SourceRange(OCE->getArg(1)->getBeginLoc(), RHSExpr->getEndLoc()));
 }
 
+/// It 

[PATCH] D142799: [Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applicable to a type

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

In `TransformAttributedType(...)` when checking if `_Nullable` can be applied 
to a type it dereferences `TL.getAttr()` unconditionally which we can see from 
the code earlier in the function is not correct since it is expected to be 
`nullptr` in some cases.

It looks like the correct course of action is to use `TL.getModifiedLoc()` over 
`TL.getAttr()->getLocation()` in the case that `TL.getAttr()` returns a 
`nullptr`.

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


https://reviews.llvm.org/D142799

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/nullability.cpp


Index: clang/test/SemaCXX/nullability.cpp
===
--- clang/test/SemaCXX/nullability.cpp
+++ clang/test/SemaCXX/nullability.cpp
@@ -136,3 +136,9 @@
 void testNullabilityCompletenessWithTemplate() {
   Template tip;
 }
+
+namespace GH60344 {
+class a;
+template  using c = b _Nullable; // expected-error {{'_Nullable' 
cannot be applied to non-pointer type 'GH60344::a'}}
+c;  // expected-note {{in instantiation of template type alias 'c' 
requested here}}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6992,7 +6992,8 @@
 // type sugar, and therefore cannot be diagnosed in any other way.
 if (auto nullability = oldType->getImmediateNullability()) {
   if (!modifiedType->canHaveNullability()) {
-SemaRef.Diag(TL.getAttr()->getLocation(),
+SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
+   : TL.getModifiedLoc().getBeginLoc()),
  diag::err_nullability_nonpointer)
 << DiagNullabilityKind(*nullability, false) << modifiedType;
 return QualType();


Index: clang/test/SemaCXX/nullability.cpp
===
--- clang/test/SemaCXX/nullability.cpp
+++ clang/test/SemaCXX/nullability.cpp
@@ -136,3 +136,9 @@
 void testNullabilityCompletenessWithTemplate() {
   Template tip;
 }
+
+namespace GH60344 {
+class a;
+template  using c = b _Nullable; // expected-error {{'_Nullable' cannot be applied to non-pointer type 'GH60344::a'}}
+c;  // expected-note {{in instantiation of template type alias 'c' requested here}}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -6992,7 +6992,8 @@
 // type sugar, and therefore cannot be diagnosed in any other way.
 if (auto nullability = oldType->getImmediateNullability()) {
   if (!modifiedType->canHaveNullability()) {
-SemaRef.Diag(TL.getAttr()->getLocation(),
+SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
+   : TL.getModifiedLoc().getBeginLoc()),
  diag::err_nullability_nonpointer)
 << DiagNullabilityKind(*nullability, false) << modifiedType;
 return QualType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141133: [clang-tidy] Implement CppCoreGuideline F.54

2023-01-27 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 492981.
ccotter added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141133

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCaptureDefaultWhenCapturingThisCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-capture-default-when-capturing-this.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-capture-default-when-capturing-this.cpp
@@ -0,0 +1,92 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-avoid-capture-default-when-capturing-this %t
+
+struct Obj {
+  void lambdas_that_warn_default_capture_copy() {
+int local{};
+int local2{};
+
+auto explicit_this_capture = [=, this]() { };
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture = [this]() { };
+
+auto explicit_this_capture_locals1 = [=, this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_locals1 = [local, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_locals2 = [=, this]() { return (local+local2) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_locals2 = [local, local2, this]() { return (local+local2) > 10; };
+
+auto explicit_this_capture_local_ref = [=, this, ]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref = [this, ]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref2 = [=, , this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref2 = [, this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref3 = [=, , this, ]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref3 = [, this, ]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref4 = [=, , , this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref4 = [, , this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref_extra_whitespace = [=, &  local, , this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:62: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref_extra_whitespace = [&  local, , this]() { return (local+x) > 10; };
+
+auto explicit_this_capture_local_ref_with_comment = [=, & /* byref */ local, , this]() { return (local+x) > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:58: warning: lambdas that capture 'this' should not specify a capture default [cppcoreguidelines-avoid-capture-default-when-capturing-this]
+// CHECK-FIXES: auto explicit_this_capture_local_ref_with_comment = [& /* byref */ local, , this]() { return (local+x) > 10; };
+
+auto implicit_this_capture = [=]() { return x > 10; };
+// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: lambdas that implicitly capture 'this' should not specify a capture default 

[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2023-01-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D14484#4079711 , @HantaoPan wrote:

> Hi,
> I am interesting in this feature too. You know, consistency is crucial to a 
> large program...
>
> regards,

As mentioned above, it has been added in D108752 
. See also 
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#packconstructorinitializers.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D141959: [clang-format] Fix inconsistent identification of operator

2023-01-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2488-2490
+(NextToken && NextToken->Tok.isAnyIdentifier()) &&
+(NextToken->getNextNonComment() &&
+ (NextToken->getNextNonComment()->isOneOf(

dkt01 wrote:
> owenpan wrote:
> > `NextToken` is guarded against null on line 2488 but not on lines 2489-2490.
> If NextToken is null on 2488, 2489-2490 will be short circuited.
You are right. The redundant parens threw me off.



Comment at: clang/lib/Format/TokenAnnotator.cpp:115-117
+   SmallVector )
   : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
+Keywords(Keywords), Scopes(TrackedScopes) {

Something like the above. (I prefer `Scopes` to `TrackedScopes` to be 
consistent with the naming of the other parameters.)



Comment at: clang/lib/Format/TokenAnnotator.cpp:1195-1198
+  // Handle unbalanced braces.
+  if (!Scopes.empty())
+Scopes.pop_back();
   // Lines can start with '}'.

I don't think it's about unbalanced braces here.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2474-2475
+auto IsChainedOperatorAmpOrMember = [](const FormatToken *token) {
+  return token->isOneOf(tok::amp, tok::period, tok::arrow, tok::arrowstar,
+tok::periodstar);
+};

To help simplify the `if` statement below.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2480
+// reference.
+if (Tok.is(tok::amp) && (PrevToken && PrevToken->Tok.isAnyIdentifier()) &&
+(!PrevToken->getPreviousNonComment() ||

Redundant parens.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2481-2482
+if (Tok.is(tok::amp) && (PrevToken && PrevToken->Tok.isAnyIdentifier()) &&
+(!PrevToken->getPreviousNonComment() ||
+ IsChainedOperatorAmpOrMember(PrevToken->getPreviousNonComment())) &&
+(NextToken && NextToken->Tok.isAnyIdentifier()) &&

The lambda would check that `PrevToken` is nonnull.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2483-2487
+(NextToken && NextToken->Tok.isAnyIdentifier()) &&
+(NextToken->getNextNonComment() &&
+ (IsChainedOperatorAmpOrMember(NextToken->getNextNonComment()) ||
+  NextToken->getNextNonComment()->is(tok::semi {
+  return TT_BinaryOperator;

Something like that.



Comment at: clang/lib/Format/TokenAnnotator.h:36
 };
 
 class AnnotatedLine {

Consider moving `ScopeType` out of `TokenAnnotator` and keeping it consistent 
with the style of `LineType` above (and replacing `TokenAnnotator::ScopeType` 
with `ScopeType` everywhere).



Comment at: clang/lib/Format/TokenAnnotator.h:184-191
+  enum class ScopeType : int8_t {
+// Contained in class declaration/definition.
+Class,
+// Contained within function definition.
+Function,
+// Contained within other scope block (loop, if/else, etc).
+Other,

See above.


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

https://reviews.llvm.org/D141959

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-27 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I am sorry I haven't notice this earlier - let's fix this before we land the 
patch.




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:690
+  Val.toString(Txt, 10, true);
+  return Txt.data();
+}

We either need a zero to terminate the string or pass the size of `Txt` to the 
`std::string` constructor here. (While `toString`'s name might sound like it'll 
take care of that it does not.)

Simplified testcase:
```
void local_ptr_to_array() {
  int tmp;
  int a[10];
  int *p = a;
  tmp = p[5];
}
```
what I get is (something like this):
```
void local_ptr_to_array() {
  int tmp;
  int a[10];
  std::span p {a, 10�o};
  tmp = p[5];
}
```
The problem is that `APInt::toString` stores '1' and '0' to `Txt` but is 
missing the terminating `\0` character that `std::string` constructor expects.




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:690
+  Val.toString(Txt, 10, true);
+  return Txt.data();
+}

jkorous wrote:
> We either need a zero to terminate the string or pass the size of `Txt` to 
> the `std::string` constructor here. (While `toString`'s name might sound like 
> it'll take care of that it does not.)
> 
> Simplified testcase:
> ```
> void local_ptr_to_array() {
>   int tmp;
>   int a[10];
>   int *p = a;
>   tmp = p[5];
> }
> ```
> what I get is (something like this):
> ```
> void local_ptr_to_array() {
>   int tmp;
>   int a[10];
>   std::span p {a, 10�o};
>   tmp = p[5];
> }
> ```
> The problem is that `APInt::toString` stores '1' and '0' to `Txt` but is 
> missing the terminating `\0` character that `std::string` constructor expects.
> 



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

https://reviews.llvm.org/D139737

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


[clang] 00ecf3f - Added a note that "%p" is also a Lit token and needs to be escaped.

2023-01-27 Thread Galina Kistanova via cfe-commits

Author: Flash Sheridan
Date: 2023-01-27T17:57:59-08:00
New Revision: 00ecf3f339624dc8b44737a2347076382de3720f

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

LOG: Added a note that "%p" is also a Lit token and needs to be escaped.

Differential revision: https://reviews.llvm.org/D140730

Added: 


Modified: 
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index f92e8d8fc4d6..3a5d1cefb7e5 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -130,7 +130,8 @@ backend during compilation.
 For a program such as the :doc:`Lit ` testing tool which
 invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
 each invocation. The pattern strings "%p" or "%Nm" may help to avoid
-corruption due to concurrency.
+corruption due to concurrency. Note that "%p" is also a Lit token and needs
+to be escaped as "%%p".
 
 .. code-block:: console
 



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


[PATCH] D140730: 59559 Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

2023-01-27 Thread Galina via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01f13f487775: Explain code coverage with Lit in 
docs/SourceBasedCodeCoverage.rst (authored by FlashSheridan, committed by 
gkistanova).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140730

Files:
  clang/docs/SourceBasedCodeCoverage.rst


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -127,6 +127,11 @@
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
+For a program such as the :doc:`Lit ` testing tool which
+invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
+each invocation. The pattern strings "%p" or "%Nm" may help to avoid
+corruption due to concurrency.
+
 .. code-block:: console
 
 % clang++ -fprofile-instr-generate -fcoverage-mapping -mllvm 
-runtime-counter-relocation foo.cc -o foo
@@ -143,6 +148,9 @@
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
+For an example of merging multiple profiles created by testing,
+see the LLVM `coverage build script 
`_.
+
 There are multiple different ways to render coverage reports. The simplest
 option is to generate a line-oriented report:
 


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -127,6 +127,11 @@
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
+For a program such as the :doc:`Lit ` testing tool which
+invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
+each invocation. The pattern strings "%p" or "%Nm" may help to avoid
+corruption due to concurrency.
+
 .. code-block:: console
 
 % clang++ -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation foo.cc -o foo
@@ -143,6 +148,9 @@
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
+For an example of merging multiple profiles created by testing,
+see the LLVM `coverage build script `_.
+
 There are multiple different ways to render coverage reports. The simplest
 option is to generate a line-oriented report:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 01f13f4 - Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

2023-01-27 Thread Galina Kistanova via cfe-commits

Author: Flash Sheridan
Date: 2023-01-27T17:51:18-08:00
New Revision: 01f13f4877751e6d5aa6f07984ebd76f67047839

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

LOG: Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

The documentation for code coverage in clang/docs/SourceBasedCodeCoverage.rst 
omits a couple of crucial steps when using it with Lit.
This patch should fix that.

Differential revision: https://reviews.llvm.org/D140730

Added: 


Modified: 
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 5f4bcf8e0ff09..f92e8d8fc4d65 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -127,6 +127,11 @@ copy that's mapped into memory). This implementation can 
be also enabled for
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
+For a program such as the :doc:`Lit ` testing tool which
+invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
+each invocation. The pattern strings "%p" or "%Nm" may help to avoid
+corruption due to concurrency.
+
 .. code-block:: console
 
 % clang++ -fprofile-instr-generate -fcoverage-mapping -mllvm 
-runtime-counter-relocation foo.cc -o foo
@@ -143,6 +148,9 @@ coverage reports. This is done using the "merge" tool in 
``llvm-profdata``
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
+For an example of merging multiple profiles created by testing,
+see the LLVM `coverage build script 
`_.
+
 There are multiple 
diff erent ways to render coverage reports. The simplest
 option is to generate a line-oriented report:
 



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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thank you!! I think we're almost ready to commit but this concern is still 
hanging:

> I see that the patch doesn't touch `handleFixableVariable()`. Do we still 
> attach fixits to the warning, or did we already change it to be attached to a 
> note associated with the warning? Because fixits with placeholders aren't 
> allowed on warnings, we should make sure it's attached to note before landing 
> this patch.




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:780-781
+  } else {
+// In cases `Init` is of the form `` after stripping of implicit
+// casts, where `&` is the built-in operator, the extent is 1.
+if (auto AddrOfExpr = dyn_cast(Init->IgnoreImpCasts()))

ziqingluo-90 wrote:
> NoQ wrote:
> > ```lang=c
> > int x = 1;
> > char *ptr =  // std::span ptr { , 4 };
> > ```
> > This is valid code. I suspect we want to check types as well, to see that 
> > type sizes match.
> > 
> > Most of the time code like this violates strict aliasing, but `char` is 
> > exceptional, and even if it did violate strict aliasing, people can compile 
> > with `-fno-strict-aliasing` to define away the UB, so we have to respect 
> > that.
> This code is not valid in C++.  An explicit cast is needed in front of ``.  
> I will add a test to show that 
> 
> ```
> int x = 1;
> char * ptr = (char *)
> ```
> will have a place holder for the span size.
Yes you're right! It's only valid in C where these fixits don't apply.


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

https://reviews.llvm.org/D139737

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


[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15265
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  !FD->isInvalidDecl() && !IsFnTemplate && BodyKind != FnBodyKind::Delete 
&&
   BodyKind != FnBodyKind::Default && !FD->isInlined()) {

Would it make sense to use `!isa(D)` here instead of 
adding `IsFnTemplate`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked an inline comment as done.
python3kgae added inline comments.



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:7
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+

jhuber6 wrote:
> Would this be called `dxv.exe` on Windows?
Good catch.
Changed to dxv{{(.exe)?}}"

Thanks a lot for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D123534: [dwarf] Emit a DIGlobalVariable for constant strings.

2023-01-27 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

This patch appears to break CUDA compilation: 
https://github.com/llvm/llvm-project/issues/58491

We apparently emit the symbol with a character (`.`) that can't be used on the 
target. Normally such characters get renamed/escaped, as you can see in the 
generated function name itself.
Search for `.b64 __func__._Z10foo_kernelv` in the dwarf output.
https://godbolt.org/z/8h4rGn1Ka


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123534

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 492941.
python3kgae marked 2 inline comments as done.
python3kgae added a comment.

Fix windows test fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_D.hlsl
  clang/test/Driver/dxc_I.hlsl
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/unittests/Driver/DXCModeTest.cpp

Index: clang/unittests/Driver/DXCModeTest.cpp
===
--- clang/unittests/Driver/DXCModeTest.cpp
+++ clang/unittests/Driver/DXCModeTest.cpp
@@ -34,7 +34,7 @@
 DiagnosticsEngine ) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
   EXPECT_EQ(Diags.getNumErrors(), 0u);
@@ -47,7 +47,7 @@
 unsigned NumOfErrors) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
   EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure report warning.
+// CHECK:dxv not found.
+
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s -Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "-"
+
+// RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s --check-prefix=VD
+// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
+// VD-NOT:dxv not found
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
+// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"], output: "[[DXC]].dxo"
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
+
+// PHASES: 0: input, "[[INPUT:.+]]", hlsl
+// PHASES-NEXT: 1: preprocessor, {0}, c++-cpp-output
+// PHASES-NEXT: 2: compiler, {1}, ir
+// PHASES-NEXT: 3: backend, {2}, assembler
+// PHASES-NEXT: 4: binary-analyzer, {3}, dx-container
Index: clang/test/Driver/dxc_I.hlsl
===
--- clang/test/Driver/dxc_I.hlsl
+++ clang/test/Driver/dxc_I.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
 
 // Make sure -I send to cc1.
 // CHECK:"-I" "test"
Index: clang/test/Driver/dxc_D.hlsl
===
--- clang/test/Driver/dxc_D.hlsl
+++ clang/test/Driver/dxc_D.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
 // RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
Index: clang/lib/Driver/ToolChains/HLSL.h
===
--- clang/lib/Driver/ToolChains/HLSL.h
+++ clang/lib/Driver/ToolChains/HLSL.h
@@ -9,17 +9,37 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 
+#include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 
 namespace clang {
 namespace driver {
 
+namespace tools {
+
+namespace hlsl {
+class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
+public:
+  Validator(const ToolChain ) : Tool("hlsl::Validator", "dxv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char 

[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-01-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 492940.
ahatanak added a comment.

Pass a `KnownNonNull_t` flag to `Address::withPointer`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

Files:
  clang/lib/CodeGen/Address.h
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3164,7 +3164,8 @@
 
 Address getIndirectAddress() const {
   assert(isIndirect());
-  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment));
+  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment),
+ KnownNonNull);
 }
   };
 
@@ -3771,8 +3772,13 @@
   /// an LLVM type of the same size of the lvalue's type.  If the lvalue has a
   /// variable length type, this is not possible.
   ///
-  LValue EmitLValue(const Expr *E);
+  LValue EmitLValue(const Expr *E,
+KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
+private:
+  LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull);
+
+public:
   /// Same as EmitLValue but additionally we generate checking code to
   /// guard against undefined behavior.  This is only suitable when we know
   /// that the address will be used to access the object.
@@ -4783,9 +4789,10 @@
   /// into the address of a local variable.  In such a case, it's quite
   /// reasonable to just ignore the returned alignment when it isn't from an
   /// explicit source.
-  Address EmitPointerWithAlignment(const Expr *Addr,
-   LValueBaseInfo *BaseInfo = nullptr,
-   TBAAAccessInfo *TBAAInfo = nullptr);
+  Address
+  EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr,
+   KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
   /// If \p E references a parameter with pass_object_size info or a constant
   /// array size modifier, emit the object size divided by the size of \p EltTy.
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1104,8 +1104,9 @@
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
   ++AI;
-ReturnValue = Address(&*AI, ConvertType(RetTy),
-  CurFnInfo->getReturnInfo().getIndirectAlign());
+ReturnValue =
+Address(&*AI, ConvertType(RetTy),
+CurFnInfo->getReturnInfo().getIndirectAlign(), KnownNonNull);
 if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
   ReturnValuePointer =
   CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
@@ -1125,8 +1126,8 @@
 cast(Addr)->getResultElementType();
 ReturnValuePointer = Address(Addr, Ty, getPointerAlign());
 Addr = Builder.CreateAlignedLoad(Ty, Addr, getPointerAlign(), "agg.result");
-ReturnValue =
-Address(Addr, ConvertType(RetTy), CGM.getNaturalTypeAlignment(RetTy));
+ReturnValue = Address(Addr, ConvertType(RetTy),
+  CGM.getNaturalTypeAlignment(RetTy), KnownNonNull);
   } else {
 ReturnValue = CreateIRTemp(RetTy, "retval");
 
Index: clang/lib/CodeGen/CGValue.h
===
--- clang/lib/CodeGen/CGValue.h
+++ clang/lib/CodeGen/CGValue.h
@@ -178,7 +178,7 @@
 MatrixElt // This is a matrix element, use getVector*
   } LVType;
 
-  llvm::Value *V;
+  llvm::PointerIntPair V;
   llvm::Type *ElementType;
 
   union {
@@ -238,7 +238,7 @@
 if (isGlobalReg())
   assert(ElementType == nullptr && "Global reg does not store elem type");
 else
-  assert(llvm::cast(V->getType())
+  assert(llvm::cast(V.getPointer()->getType())
  ->isOpaqueOrPointeeTypeMatches(ElementType) &&
  "Pointer element type mismatch");
 
@@ -333,28 +333,36 @@
   LValueBaseInfo getBaseInfo() const { return BaseInfo; }
   void setBaseInfo(LValueBaseInfo Info) { BaseInfo = Info; }
 
+  KnownNonNull_t isKnownNonNull() const { return (KnownNonNull_t)V.getInt(); }
+  LValue setKnownNonNull() {
+V.setInt(true);
+return *this;
+  }
+
   // simple lvalue
   llvm::Value *getPointer(CodeGenFunction ) const {
 assert(isSimple());
-return V;
+return 

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LGTM overall. Thanks for the patch. Others feel free to comment.




Comment at: clang/lib/Driver/Driver.cpp:4214
   }
-
+  // Call validator for dxil when -Vd not in Args.
+  if (C.getDefaultToolChain().getTriple().isDXIL()) {

Extreme nit. whitespace above.



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:7
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+

Would this be called `dxv.exe` on Windows?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked 2 inline comments as done.
python3kgae added inline comments.



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:170
+
+Tool *clang::driver::toolchains::HLSLToolChain::getTool(
+Action::ActionClass AC) const {

jhuber6 wrote:
> python3kgae wrote:
> > jhuber6 wrote:
> > > I feel like this logic should go with the other random `Tool` versions we 
> > > have in `ToolChain.cpp`. See `ToolChain.cpp:440` and there should be 
> > > examples of similar tools.
> > This is following pattern of MachO::getTool for VerifyDebug.
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Darwin.cpp#L1078
> > 
> > I can add getValidator to HLSLToolChain if that helps.
> > 
> Yeah, I guess it's a style thing. Personally I don't mind having everything 
> in one place because you need to handle the ActionClass there anyway. But 
> it's not a huge deal. I'll accept either.
Thanks. I'll keep it as is then.
The validator is only for HLSL now.
If other ToolChain uses it, I'll move it to ToolChain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 492931.
python3kgae marked an inline comment as done.
python3kgae added a comment.

rename to requiresValidation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_D.hlsl
  clang/test/Driver/dxc_I.hlsl
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/unittests/Driver/DXCModeTest.cpp

Index: clang/unittests/Driver/DXCModeTest.cpp
===
--- clang/unittests/Driver/DXCModeTest.cpp
+++ clang/unittests/Driver/DXCModeTest.cpp
@@ -34,7 +34,7 @@
 DiagnosticsEngine ) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
   EXPECT_EQ(Diags.getNumErrors(), 0u);
@@ -47,7 +47,7 @@
 unsigned NumOfErrors) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
   EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure report warning.
+// CHECK:dxv not found.
+
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s -Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+
+// RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s --check-prefix=VD
+// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
+// VD-NOT:dxv not found
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
+// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"], output: "[[DXC]].dxo"
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
+
+// PHASES: 0: input, "[[INPUT:.+]]", hlsl
+// PHASES-NEXT: 1: preprocessor, {0}, c++-cpp-output
+// PHASES-NEXT: 2: compiler, {1}, ir
+// PHASES-NEXT: 3: backend, {2}, assembler
+// PHASES-NEXT: 4: binary-analyzer, {3}, dx-container
Index: clang/test/Driver/dxc_I.hlsl
===
--- clang/test/Driver/dxc_I.hlsl
+++ clang/test/Driver/dxc_I.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
 
 // Make sure -I send to cc1.
 // CHECK:"-I" "test"
Index: clang/test/Driver/dxc_D.hlsl
===
--- clang/test/Driver/dxc_D.hlsl
+++ clang/test/Driver/dxc_D.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
 // RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
Index: clang/lib/Driver/ToolChains/HLSL.h
===
--- clang/lib/Driver/ToolChains/HLSL.h
+++ clang/lib/Driver/ToolChains/HLSL.h
@@ -9,17 +9,37 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 
+#include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 
 namespace clang {
 namespace driver {
 
+namespace tools {
+
+namespace hlsl {
+class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
+public:
+  Validator(const ToolChain ) : Tool("hlsl::Validator", "dxv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char 

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:170
+
+Tool *clang::driver::toolchains::HLSLToolChain::getTool(
+Action::ActionClass AC) const {

python3kgae wrote:
> jhuber6 wrote:
> > I feel like this logic should go with the other random `Tool` versions we 
> > have in `ToolChain.cpp`. See `ToolChain.cpp:440` and there should be 
> > examples of similar tools.
> This is following pattern of MachO::getTool for VerifyDebug.
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Darwin.cpp#L1078
> 
> I can add getValidator to HLSLToolChain if that helps.
> 
Yeah, I guess it's a style thing. Personally I don't mind having everything in 
one place because you need to handle the ActionClass there anyway. But it's not 
a huge deal. I'll accept either.



Comment at: clang/lib/Driver/ToolChains/HLSL.h:53
   static std::optional parseTargetProfile(StringRef 
TargetProfile);
+  bool needValidation(llvm::opt::DerivedArgList ) const;
+

python3kgae wrote:
> jhuber6 wrote:
> > Is `needValidation` a good name here? It's asking more like `hasValidator` 
> > or `supportsValidation`.
> It is combination of hasValidator and requireValidator.
> Maybe create hasValidator and requireValidator then move the warning 
> reporting back to Driver?
> Something like
> 
> ```
> if (TC.requireValidator()) {
> if (TC.hasValidator()) {
> add the action.
> } else {
> report warning.
> }
> }
> ```
> 
I think keeping the logic as-is and calling it `requiresValidation` would be 
fine. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked an inline comment as done.
python3kgae added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4226
+Args.ClaimAllArgs(options::OPT_cl_ignored_Group);
+  }
 

jhuber6 wrote:
> nit. remember to `clang-format`
arc did find some clang-format issue.
But missed this one :(




Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:170
+
+Tool *clang::driver::toolchains::HLSLToolChain::getTool(
+Action::ActionClass AC) const {

jhuber6 wrote:
> I feel like this logic should go with the other random `Tool` versions we 
> have in `ToolChain.cpp`. See `ToolChain.cpp:440` and there should be examples 
> of similar tools.
This is following pattern of MachO::getTool for VerifyDebug.
https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Darwin.cpp#L1078

I can add getValidator to HLSLToolChain if that helps.




Comment at: clang/lib/Driver/ToolChains/HLSL.h:53
   static std::optional parseTargetProfile(StringRef 
TargetProfile);
+  bool needValidation(llvm::opt::DerivedArgList ) const;
+

jhuber6 wrote:
> Is `needValidation` a good name here? It's asking more like `hasValidator` or 
> `supportsValidation`.
It is combination of hasValidator and requireValidator.
Maybe create hasValidator and requireValidator then move the warning reporting 
back to Driver?
Something like

```
if (TC.requireValidator()) {
if (TC.hasValidator()) {
add the action.
} else {
report warning.
}
}
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Thanks for the changes.




Comment at: clang/lib/Driver/Driver.cpp:4226
+Args.ClaimAllArgs(options::OPT_cl_ignored_Group);
+  }
 

nit. remember to `clang-format`



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:170
+
+Tool *clang::driver::toolchains::HLSLToolChain::getTool(
+Action::ActionClass AC) const {

I feel like this logic should go with the other random `Tool` versions we have 
in `ToolChain.cpp`. See `ToolChain.cpp:440` and there should be examples of 
similar tools.



Comment at: clang/lib/Driver/ToolChains/HLSL.h:53
   static std::optional parseTargetProfile(StringRef 
TargetProfile);
+  bool needValidation(llvm::opt::DerivedArgList ) const;
+

Is `needValidation` a good name here? It's asking more like `hasValidator` or 
`supportsValidation`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141338: [-Wunsafe-buffer-usage] Filter out conflicting fix-its

2023-01-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 492918.

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

https://reviews.llvm.org/D141338

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Analysis/UnsafeBufferUsageTest.cpp

Index: clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
@@ -0,0 +1,60 @@
+#include "gtest/gtest.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
+
+using namespace clang;
+
+namespace {
+// The test fixture.
+class UnsafeBufferUsageTest : public ::testing::Test {
+protected:
+  UnsafeBufferUsageTest()
+  : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
+Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
+SourceMgr(Diags, FileMgr) {}
+
+  FileSystemOptions FileMgrOpts;
+  FileManager FileMgr;
+  IntrusiveRefCntPtr DiagID;
+  DiagnosticsEngine Diags;
+  SourceManager SourceMgr;
+};
+} // namespace
+
+TEST_F(UnsafeBufferUsageTest, FixItHintsConflict) {
+  const FileEntry *DummyFile = FileMgr.getVirtualFile("", 100, 0);
+  FileID DummyFileID = SourceMgr.getOrCreateFileID(DummyFile, SrcMgr::C_User);
+  SourceLocation StartLoc = SourceMgr.getLocForStartOfFile(DummyFileID);
+
+#define MkDummyHint(Begin, End)\
+  FixItHint::CreateReplacement(SourceRange(StartLoc.getLocWithOffset((Begin)), \
+   StartLoc.getLocWithOffset((End))),  \
+   "dummy")
+
+  FixItHint H1 = MkDummyHint(0, 5);
+  FixItHint H2 = MkDummyHint(6, 10);
+  FixItHint H3 = MkDummyHint(20, 25);
+  llvm::SmallVector Fixes;
+
+  // Test non-overlapping fix-its:
+  Fixes = {H1, H2, H3};
+  EXPECT_FALSE(internal::anyConflict(Fixes, SourceMgr));
+  Fixes = {H3, H2, H1}; // re-order
+  EXPECT_FALSE(internal::anyConflict(Fixes, SourceMgr));
+
+  // Test overlapping fix-its:
+  Fixes = {H1, H2, H3, MkDummyHint(0, 4) /* included in H1 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(10, 15) /* overlaps H2 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(7, 23) /* overlaps H2, H3 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(2, 23) /* overlaps H1, H2, and H3 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+}
\ No newline at end of file
Index: clang/unittests/Analysis/CMakeLists.txt
===
--- clang/unittests/Analysis/CMakeLists.txt
+++ clang/unittests/Analysis/CMakeLists.txt
@@ -9,6 +9,7 @@
   CloneDetectionTest.cpp
   ExprMutationAnalyzerTest.cpp
   MacroExpansionContextTest.cpp
+  UnsafeBufferUsageTest.cpp
   )
 
 clang_target_link_libraries(ClangAnalysisTests
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -674,6 +674,37 @@
   return FixablesForUnsafeVars;
 }
 
+bool clang::internal::anyConflict(
+const SmallVectorImpl , const SourceManager ) {
+  // A simple interval overlap detection algorithm.  Sorts all ranges by their
+  // begin location then finds the first overlap in one pass.
+  std::vector All; // a copy of `FixIts`
+
+  for (const FixItHint  : FixIts)
+All.push_back();
+  std::sort(All.begin(), All.end(),
+[](const FixItHint *H1, const FixItHint *H2) {
+  return SM.isBeforeInTranslationUnit(H1->RemoveRange.getBegin(),
+  H2->RemoveRange.getBegin());
+});
+
+  const FixItHint *CurrHint = nullptr;
+
+  for (const FixItHint *Hint : All) {
+if (!CurrHint ||
+SM.isBeforeInTranslationUnit(CurrHint->RemoveRange.getEnd(),
+ Hint->RemoveRange.getBegin())) {
+  // Either to initialize `CurrHint` or `CurrHint` does not
+  // overlap with `Hint`:
+  CurrHint = Hint;
+} else
+  // In case `Hint` overlaps the `CurrHint`, we found at least one
+  // conflict:
+  return true;
+  }
+  return false;
+}
+
 Optional
 ULCArraySubscriptGadget::getFixits(const Strategy ) const {
   if (const auto *DRE = dyn_cast(Node->getBase()->IgnoreImpCasts()))
@@ -925,8 +956,12 @@
 else
   FixItsForVariable[VD].insert(FixItsForVariable[VD].end(),
FixItsForVD.begin(), FixItsForVD.end());
-// Fix-it shall not overlap with macros or/and templates:
-if 

[PATCH] D141338: [-Wunsafe-buffer-usage] Filter out conflicting fix-its

2023-01-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 492914.
ziqingluo-90 added a comment.

Rebase the change


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

https://reviews.llvm.org/D141338

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Analysis/UnsafeBufferUsageTest.cpp

Index: clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/UnsafeBufferUsageTest.cpp
@@ -0,0 +1,60 @@
+#include "gtest/gtest.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
+
+using namespace clang;
+
+namespace {
+// The test fixture.
+class UnsafeBufferUsageTest : public ::testing::Test {
+protected:
+  UnsafeBufferUsageTest()
+  : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()),
+Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
+SourceMgr(Diags, FileMgr) {}
+
+  FileSystemOptions FileMgrOpts;
+  FileManager FileMgr;
+  IntrusiveRefCntPtr DiagID;
+  DiagnosticsEngine Diags;
+  SourceManager SourceMgr;
+};
+} // namespace
+
+TEST_F(UnsafeBufferUsageTest, FixItHintsConflict) {
+  const FileEntry *DummyFile = FileMgr.getVirtualFile("", 100, 0);
+  FileID DummyFileID = SourceMgr.getOrCreateFileID(DummyFile, SrcMgr::C_User);
+  SourceLocation StartLoc = SourceMgr.getLocForStartOfFile(DummyFileID);
+
+#define MkDummyHint(Begin, End)\
+  FixItHint::CreateReplacement(SourceRange(StartLoc.getLocWithOffset((Begin)), \
+   StartLoc.getLocWithOffset((End))),  \
+   "dummy")
+
+  FixItHint H1 = MkDummyHint(0, 5);
+  FixItHint H2 = MkDummyHint(6, 10);
+  FixItHint H3 = MkDummyHint(20, 25);
+  llvm::SmallVector Fixes;
+
+  // Test non-overlapping fix-its:
+  Fixes = {H1, H2, H3};
+  EXPECT_FALSE(internal::anyConflict(Fixes, SourceMgr));
+  Fixes = {H3, H2, H1}; // re-order
+  EXPECT_FALSE(internal::anyConflict(Fixes, SourceMgr));
+
+  // Test overlapping fix-its:
+  Fixes = {H1, H2, H3, MkDummyHint(0, 4) /* included in H1 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(10, 15) /* overlaps H2 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(7, 23) /* overlaps H2, H3 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+
+  Fixes = {H1, H2, H3, MkDummyHint(2, 23) /* overlaps H1, H2, and H3 */};
+  EXPECT_TRUE(internal::anyConflict(Fixes, SourceMgr));
+}
\ No newline at end of file
Index: clang/unittests/Analysis/CMakeLists.txt
===
--- clang/unittests/Analysis/CMakeLists.txt
+++ clang/unittests/Analysis/CMakeLists.txt
@@ -9,6 +9,7 @@
   CloneDetectionTest.cpp
   ExprMutationAnalyzerTest.cpp
   MacroExpansionContextTest.cpp
+  UnsafeBufferUsageTest.cpp
   )
 
 clang_target_link_libraries(ClangAnalysisTests
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -674,6 +674,37 @@
   return FixablesForUnsafeVars;
 }
 
+bool clang::internal::anyConflict(
+const SmallVectorImpl , const SourceManager ) {
+  // A simple interval overlap detecting algorithm.  Sorts all ranges by their
+  // begin location then find any overlap in one pass.
+  std::vector All; // a copy of `FixIts`
+
+  for (const FixItHint  : FixIts)
+All.push_back();
+  std::sort(All.begin(), All.end(),
+[](const FixItHint *H1, const FixItHint *H2) {
+  return SM.isBeforeInTranslationUnit(H1->RemoveRange.getBegin(),
+  H2->RemoveRange.getBegin());
+});
+
+  const FixItHint *CurrHint = nullptr;
+
+  for (const FixItHint *Hint : All) {
+if (!CurrHint ||
+SM.isBeforeInTranslationUnit(CurrHint->RemoveRange.getEnd(),
+ Hint->RemoveRange.getBegin())) {
+  // Either to initialize `CurrHint` or `CurrHint` does not
+  // overlap with `Hint`:
+  CurrHint = Hint;
+} else
+  // In case `Hint` overlaps the `CurrHint`, we found at least one
+  // conflict:
+  return true;
+  }
+  return false;
+}
+
 Optional
 ULCArraySubscriptGadget::getFixits(const Strategy ) const {
   if (const auto *DRE = dyn_cast(Node->getBase()->IgnoreImpCasts()))
@@ -925,8 +956,12 @@
 else
   FixItsForVariable[VD].insert(FixItsForVariable[VD].end(),
FixItsForVD.begin(), FixItsForVD.end());
-// Fix-it shall not overlap with macros or/and 

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4217-4218
+// Only add action when needValidation.
+const auto  = getToolChain(Args, C.getDefaultToolChain().getTriple());
+const auto *HLSLTC = static_cast();
+if (HLSLTC->needValidation(Args, *this)) {

jhuber6 wrote:
> This can create a new `ToolChain`. We probably don't want that. Maybe someone 
> more familiar with this compilation mode can chime in. But my guess is that 
> when we created the `Compilation`.
> 
> This code will only fire if the above triple matches for the default 
> ToolChain. So we should be safe in just casting it directly.
Switched to getDefaultToolChain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 492912.
python3kgae marked 2 inline comments as done.
python3kgae added a comment.

switch to getDefaultToolChain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_D.hlsl
  clang/test/Driver/dxc_I.hlsl
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/unittests/Driver/DXCModeTest.cpp

Index: clang/unittests/Driver/DXCModeTest.cpp
===
--- clang/unittests/Driver/DXCModeTest.cpp
+++ clang/unittests/Driver/DXCModeTest.cpp
@@ -34,7 +34,7 @@
 DiagnosticsEngine ) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
   EXPECT_EQ(Diags.getNumErrors(), 0u);
@@ -47,7 +47,7 @@
 unsigned NumOfErrors) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
   EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure report warning.
+// CHECK:dxv not found.
+
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s -Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+
+// RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s --check-prefix=VD
+// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
+// VD-NOT:dxv not found
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
+// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"], output: "[[DXC]].dxo"
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
+
+// PHASES: 0: input, "[[INPUT:.+]]", hlsl
+// PHASES-NEXT: 1: preprocessor, {0}, c++-cpp-output
+// PHASES-NEXT: 2: compiler, {1}, ir
+// PHASES-NEXT: 3: backend, {2}, assembler
+// PHASES-NEXT: 4: binary-analyzer, {3}, dx-container
Index: clang/test/Driver/dxc_I.hlsl
===
--- clang/test/Driver/dxc_I.hlsl
+++ clang/test/Driver/dxc_I.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
 
 // Make sure -I send to cc1.
 // CHECK:"-I" "test"
Index: clang/test/Driver/dxc_D.hlsl
===
--- clang/test/Driver/dxc_D.hlsl
+++ clang/test/Driver/dxc_D.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
 // RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
Index: clang/lib/Driver/ToolChains/HLSL.h
===
--- clang/lib/Driver/ToolChains/HLSL.h
+++ clang/lib/Driver/ToolChains/HLSL.h
@@ -9,17 +9,37 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 
+#include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 
 namespace clang {
 namespace driver {
 
+namespace tools {
+
+namespace hlsl {
+class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
+public:
+  Validator(const ToolChain ) : Tool("hlsl::Validator", "dxv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char 

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4217-4218
+// Only add action when needValidation.
+const auto  = getToolChain(Args, C.getDefaultToolChain().getTriple());
+const auto *HLSLTC = static_cast();
+if (HLSLTC->needValidation(Args, *this)) {

This can create a new `ToolChain`. We probably don't want that. Maybe someone 
more familiar with this compilation mode can chime in. But my guess is that 
when we created the `Compilation`.

This code will only fire if the above triple matches for the default ToolChain. 
So we should be safe in just casting it directly.



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:258
+bool HLSLToolChain::needValidation(DerivedArgList ,
+   const Driver ) const {
+  if (Args.getLastArg(options::OPT_dxc_disable_validation))

We don't need to pass in `D` since this is no longer static. You can use 
`getDriver()`



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:19
+
+// PHASES:+- 0: input, "[[INPUT:.+]]", hlsl
+// PHASES-NEXT:+- 1: preprocessor, {0}, c++-cpp-output

nit. remove the `+-` and add whitespace to make it more readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-01-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/CodeGen/Address.h:146
+return Address(NewPointer, getElementType(), getAlignment(),
+   isKnownNonNull());
   }

This isn't safe. We cannot tell whether the new pointer is non-null or not 
based on whether it's currently non-null.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D142780#4087270 , @benlangmuir 
wrote:

> If compiling a single pcm accesses multiple hard links with the same UID, 
> then it would not be possible to use the set of UIDs to get the "right path". 
>  At best we could make it get a deterministic path -- e.g. if we tracked the 
> order of access.

With you so far. Is there a reason we need to use the UIDs in this case? Would 
it be possible to refactor `GetUniqueIDMapping` to instead populate an array 
with all the `FileEntryRef`s that had been seen and serialize that instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142780

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Sounds like the easies way out is serializing all `FileEntryRef` objects we 
know in deterministic order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142780

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

In D142780#4087250 , @rmaz wrote:

> In that case we are seeing non-deterministic header paths serialized in pcm 
> files. IIUC the header files are serialized based in their unique ID, so it 
> wouldn't be possible to handle this case, is this right?

If compiling a single pcm accesses multiple hard links with the same UID, then 
it would not be possible to use the set of UIDs to get the "right path".  At 
best we could make it get a deterministic path -- e.g. if we tracked the order 
of access.

If compiling a single pcm accesses only one hard link but it's an implicit 
module build and the overall compiler invocation accesses another one with the 
same UID, you are currently in the same situation as above, though in theory 
you could avoid it by not sharing the FileManager across implicit module 
builds.   In clang-scan-deps we don't share the FileManager and we get away 
with it because we have a separate filesystem caching layer.  In a normal 
implicit modules build I don't know how much this would cost.

If you're on a platform that supports `fcntl` with `F_GETPATH` such as Darwin, 
another possible source of non-determinism is that the underlying OS may return 
a non-deterministic `RealPath` from `openFileForRead` when there are multiple 
hard links.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142780

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


[PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Including a link to the RFC 
(https://discourse.llvm.org/t/rfc-optional-a-type-qualifier-to-indicate-pointer-nullability/68004/2)
 in each of the patches in this series would be helpful.

Assuming that we want to go in this direction, it seems quite expensive to 
model this as a fast qualifier rather than an extended qualifier. Are these 
annotations expected to be so common that it's better to increase the alignment 
of all types than perform extra allocations and indirections for `_Optional` 
qualifiers? Have you measured the memory impact of increasing the alignment of 
`Type`? I think that should be a prerequisite to adding any new kind of fast 
qualifier, and if we do add such a qualifier, we should select carefully which 
qualifier gets this precious bit in `QualType`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142733

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz added a comment.

In D142780#4087236 , @benlangmuir 
wrote:

> I think if we want to change this to FileEntryRef it needs to be 
> deterministic which ref you get.

I think this might be the root of the problem we are seeing: depending on build 
configuration sometimes our build inputs are hard links that in the case of 
identical inputs point to the same inode. In that case we are seeing 
non-deterministic header paths serialized in pcm files. IIUC the header files 
are serialized based in their unique ID, so it wouldn't be possible to handle 
this case, is this right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142780

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

Iterating over `SeenFileEntries` and skipping `VirtualFileEntries` looks good 
to me.

I'm not sure about changing this to FileEntryRef though. The way this API works 
you only get one per unique file, which is well suited to `FileEntry *` which 
has the same uniquing behaviour. In this case you're going to get a 
`FileEntryRef`, but *which* ref you get is non-deterministic if there were 
multiple refs for the same file (depends on hash table iteration order).  Also, 
it will never give you a vfs mapped path since it's skipping those 
(`V.dyn_cast()`).

I think if we want to change this to FileEntryRef it needs to be deterministic 
which ref you get.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142780

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 492894.
python3kgae marked 2 inline comments as done.
python3kgae added a comment.

cast ToolChain to HLSLToolChain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_D.hlsl
  clang/test/Driver/dxc_I.hlsl
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/unittests/Driver/DXCModeTest.cpp

Index: clang/unittests/Driver/DXCModeTest.cpp
===
--- clang/unittests/Driver/DXCModeTest.cpp
+++ clang/unittests/Driver/DXCModeTest.cpp
@@ -34,7 +34,7 @@
 DiagnosticsEngine ) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
   EXPECT_EQ(Diags.getNumErrors(), 0u);
@@ -47,7 +47,7 @@
 unsigned NumOfErrors) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
   EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure report warning.
+// CHECK:dxv not found.
+
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s -Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+
+// RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s --check-prefix=VD
+// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
+// VD-NOT:dxv not found
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
+// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"], output: "[[DXC]].dxo"
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
+
+// PHASES:+- 0: input, "[[INPUT:.+]]", hlsl
+// PHASES-NEXT:+- 1: preprocessor, {0}, c++-cpp-output
+// PHASES-NEXT:+- 2: compiler, {1}, ir
+// PHASES-NEXT:3: backend, {2}, assembler
+// PHASES-NEXT:4: binary-analyzer, {3}, dx-container
Index: clang/test/Driver/dxc_I.hlsl
===
--- clang/test/Driver/dxc_I.hlsl
+++ clang/test/Driver/dxc_I.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
 
 // Make sure -I send to cc1.
 // CHECK:"-I" "test"
Index: clang/test/Driver/dxc_D.hlsl
===
--- clang/test/Driver/dxc_D.hlsl
+++ clang/test/Driver/dxc_D.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
 // RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
Index: clang/lib/Driver/ToolChains/HLSL.h
===
--- clang/lib/Driver/ToolChains/HLSL.h
+++ clang/lib/Driver/ToolChains/HLSL.h
@@ -9,17 +9,37 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 
+#include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 
 namespace clang {
 namespace driver {
 
+namespace tools {
+
+namespace hlsl {
+class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
+public:
+  Validator(const ToolChain ) : Tool("hlsl::Validator", "dxv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char 

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked 6 inline comments as done.
python3kgae added inline comments.



Comment at: clang/include/clang/Driver/Types.def:110
 TYPE("api-information",  API_INFO, INVALID, "json",   
phases::Precompile)
+TYPE("dx-container", DX_CONTAINER, INVALID, "dxc",
phases::Compile, phases::Backend)
 TYPE("none", Nothing,  INVALID, nullptr,  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)

beanz wrote:
> The normal dx-container extension is `dxbc` right? not `dxc`?
There's no official extension.
Will go with dxo.



Comment at: clang/lib/Driver/Driver.cpp:4218
+// Only add action when needValidation.
+if (toolchains::HLSLToolChain::needValidation(Args, *this,
+  C.getDefaultToolChain())) {

jhuber6 wrote:
> python3kgae wrote:
> > jhuber6 wrote:
> > > This should work, shouldn't it?
> > > ```
> > > const auto  = static_cast > > &>(getToolChain());
> > > ```
> > I'm not sure getToolChain will return a HLSLToolChain.
> > Is it OK to use dynamic_cast?
> Well, how is the compilation normally invoked? The `Driver::getToolChain()` 
> function clearly returns an `HLSLToolChain` if the triple is `ShaderModel`. 
> I'm assuming that's the only way to create this, and its set in the 
> compilation. So it should be the ToolChain of the main compilation. This is 
> in contract to an offloading compilation that can have multiple toolchains 
> floating around I'm guessing.
> 
> And no, `dynamic_cast` doesn't work in LLVM. LLVM RTTI requires implementing 
> a `classof` function, e.g. 
> https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html, which the ToolChains 
> don't use.

```
const auto  = static_cast(
getToolChain(Args, C.getDefaultToolChain().getTriple()));
```
will hit " no viable conversion from 'const clang::driver::ToolChain' to 'const 
toolchains::HLSLToolChain'"

```
const auto  = getToolChain(Args, C.getDefaultToolChain().getTriple());
const auto *HLSLTC = static_cast();
```
works, is it OK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:19-23
+// PHASES:+- 0: input, "[[INPUT:.+]]", hlsl
+// PHASES:+- 1: preprocessor, {0}, c++-cpp-output
+// PHASES:+- 2: compiler, {1}, ir
+// PHASES:3: backend, {2}, assembler
+// PHASES:4: binary-analyzer, {3}, dx-container

jhuber6 wrote:
> 
Also get rid of the `+-`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4218
+// Only add action when needValidation.
+if (toolchains::HLSLToolChain::needValidation(Args, *this,
+  C.getDefaultToolChain())) {

python3kgae wrote:
> jhuber6 wrote:
> > This should work, shouldn't it?
> > ```
> > const auto  = static_cast > &>(getToolChain());
> > ```
> I'm not sure getToolChain will return a HLSLToolChain.
> Is it OK to use dynamic_cast?
Well, how is the compilation normally invoked? The `Driver::getToolChain()` 
function clearly returns an `HLSLToolChain` if the triple is `ShaderModel`. I'm 
assuming that's the only way to create this, and its set in the compilation. So 
it should be the ToolChain of the main compilation. This is in contract to an 
offloading compilation that can have multiple toolchains floating around I'm 
guessing.

And no, `dynamic_cast` doesn't work in LLVM. LLVM RTTI requires implementing a 
`classof` function, e.g. https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html, 
which the ToolChains don't use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked an inline comment as done.
python3kgae added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4218
+// Only add action when needValidation.
+if (toolchains::HLSLToolChain::needValidation(Args, *this,
+  C.getDefaultToolChain())) {

jhuber6 wrote:
> This should work, shouldn't it?
> ```
> const auto  = static_cast &>(getToolChain());
> ```
I'm not sure getToolChain will return a HLSLToolChain.
Is it OK to use dynamic_cast?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 492882.
ziqingluo-90 added a comment.

Addressing comments


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

https://reviews.llvm.org/D139737

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-local-var-span.cpp
@@ -0,0 +1,149 @@
+// RUN: cp %s %t.cpp
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fixit %t.cpp
+// RUN: grep -v CHECK %t.cpp | FileCheck %s
+typedef int * Int_ptr_t;
+typedef int Int_t;
+
+void local_array_subscript_simple() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: std::span q {new int[10], 10};
+// CHECK: tmp = p[5];
+// CHECK: tmp = q[5];
+  int *p = new int[10];
+  const int *q = new int[10];
+  tmp = p[5];
+  tmp = q[5];
+
+// CHECK: std::span x {new int[10], 10};
+// CHECK: std::span y {new int, 1};
+// CHECK: std::span z {new int[10], 10};
+// CHECK: std::span w {new Int_t[10], 10};
+
+  Int_ptr_t x = new int[10];
+  Int_ptr_t y = new int;
+  Int_t * z = new int[10];
+  Int_t * w = new Int_t[10];
+
+  // CHECK: tmp = x[5];
+  tmp = x[5];
+  // CHECK: tmp = y[5];
+  tmp = y[5]; // y[5] will crash after being span
+  // CHECK: tmp = z[5];
+  tmp = z[5];
+  // CHECK: tmp = w[5];
+  tmp = w[5];
+}
+
+void local_array_subscript_auto() {
+  int tmp;
+// CHECK: std::span p {new int[10], 10};
+// CHECK: tmp = p[5];
+  auto p = new int[10];
+  tmp = p[5];
+}
+
+void local_array_subscript_variable_extent() {
+  int n = 10;
+  int tmp;
+
+  // CHECK: std::span p {new int[n], n};
+  // CHECK: std::span q {new int[n++], <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = new int[n];
+  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  int *q = new int[n++];
+  tmp = p[5];
+  tmp = q[5];
+}
+
+
+void local_ptr_to_array() {
+  int tmp;
+  int n = 10;
+  int a[10];
+  int b[n];  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  // CHECK: std::span p {a, 10};
+  // CHECK: std::span q {b, <# placeholder #>};
+  // CHECK: tmp = p[5];
+  // CHECK: tmp = q[5];
+  int *p = a;
+  int *q = b;
+  tmp = p[5];
+  tmp = q[5];
+}
+
+void local_ptr_addrof_init() {
+  int var;
+// CHECK: std::span q {, 1};
+// CHECK: var = q[5];
+  int * q = 
+  // This expression involves unsafe buffer accesses, which will crash
+  // at runtime after applying the fix-it,
+  var = q[5];
+}
+
+void decl_without_init() {
+  int tmp;
+  // CHECK: std::span p;
+  int * p;
+  // CHECK: std::span q;
+  Int_ptr_t q;
+
+  tmp = p[5];
+  tmp = q[5];
+}
+
+// Explicit casts are required in the following cases. No way to
+// figure out span extent for them automatically.
+void explict_cast() {
+  int tmp;
+  // CHECK: std::span p {(int*) new int[10][10], <# placeholder #>};
+  int * p = (int*) new int[10][10];
+  tmp = p[5];
+
+  int a;
+  // CHECK: std::span q {(char *), <# placeholder #>};
+  char * q = (char *)
+  tmp = (int) q[5];
+
+  void * r = 
+  // CHECK: std::span s {(char *) r, <# placeholder #>};
+  char * s = (char *) r;
+  tmp = (int) s[5];
+}
+
+void unsupported_multi_decl(int * x) {
+  // CHECK: int * p = x, * q = new int[10];
+  int * p = x, * q = new int[10];
+  *p = q[5];
+}
+
+void unsupported_fixit_overlapping_macro(int * x) {
+  int tmp;
+  // In the case below, a tentative fix-it replaces `MY_INT * p =` with `std::span p `.
+  // It overlaps with the use of the macro `MY_INT`.  The fix-it is
+  // discarded then.
+#define MY_INT int
+  // CHECK: MY_INT * p = new int[10];
+  MY_INT * p = new int[10];
+  tmp = p[5];
+
+#define MY_VAR(name) int * name
+  // CHECK: MY_VAR(q) = new int[10];
+  MY_VAR(q) = new int[10];
+  tmp = q[5];
+
+  // In cases where fix-its do not change the original code where
+  // macros are used, those fix-its will be emitted.  For example,
+  // fixits are inserted before and after `new MY_INT[MY_TEN]` below.
+#define MY_TEN 10
+  // CHECK: std::span g {new MY_INT[MY_TEN], <# placeholder #>};
+  int * g = new MY_INT[MY_TEN];
+  tmp = g[5];
+
+#undef MY_INT
+#undef MY_VAR
+#undef MY_TEN
+}
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -9,6 +9,7 @@
 #include "clang/Analysis/Analyses/UnsafeBufferUsage.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -115,6 +116,19 @@
   

[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4214-4216
+  // Call validator for dxil when -Vd not in Args.
+  llvm::Triple T(getTargetTriple());
+  if (T.getArch() == llvm::Triple::dxil) {





Comment at: clang/lib/Driver/Driver.cpp:4218
+// Only add action when needValidation.
+if (toolchains::HLSLToolChain::needValidation(Args, *this,
+  C.getDefaultToolChain())) {

This should work, shouldn't it?
```
const auto  = static_cast(getToolChain());
```



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:14-15
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxc  %s 
2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: 
["[[INPUT:.+]]"], output: "[[DXC:.+]].dxc"
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", 
inputs: ["[[DXC]].dxc"], output: "[[DXC]].dxc"
+

nit



Comment at: clang/test/Driver/dxc_dxv_path.hlsl:19-23
+// PHASES:+- 0: input, "[[INPUT:.+]]", hlsl
+// PHASES:+- 1: preprocessor, {0}, c++-cpp-output
+// PHASES:+- 2: compiler, {1}, ir
+// PHASES:3: backend, {2}, assembler
+// PHASES:4: binary-analyzer, {3}, dx-container




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D138675: [flang] Add -ffast-math and -Ofast

2023-01-27 Thread Usman Nadeem via Phabricator via cfe-commits
mnadeem added inline comments.
Herald added a subscriber: sunshaoce.



Comment at: flang/test/Driver/fast_math.f90:59-62
+! Check that -ffast-math causes us to link to crtfastmath.o
+! UNSUPPORTED: system-windows
+! RUN: %flang -ffast-math -### %s -o %t 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-CRT %s

I think this test should use an explicit sysroot like the clang test does. It 
fails on my system (x86 linux, llvm built for arm target) because it cant find 
the crtfastmath.o library.


> // file linux-ld.c
>
> // RUN:--sysroot=%S/Inputs/basic_linux_tree 2>&1 \
> // RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH %s



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138675

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Driver/Types.def:110
 TYPE("api-information",  API_INFO, INVALID, "json",   
phases::Precompile)
+TYPE("dx-container", DX_CONTAINER, INVALID, "dxc",
phases::Compile, phases::Backend)
 TYPE("none", Nothing,  INVALID, nullptr,  
phases::Compile, phases::Backend, phases::Assemble, phases::Link)

The normal dx-container extension is `dxbc` right? not `dxc`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-27 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked 8 inline comments as done.
ziqingluo-90 added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:637
 
-static Strategy
-getNaiveStrategy(const llvm::SmallVectorImpl ) {

NoQ wrote:
> Hmm, did this need to be moved? I don't think you're calling this function 
> from the new code.
it does look like I moved it.  Will change it back.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:780-781
+  } else {
+// In cases `Init` is of the form `` after stripping of implicit
+// casts, where `&` is the built-in operator, the extent is 1.
+if (auto AddrOfExpr = dyn_cast(Init->IgnoreImpCasts()))

NoQ wrote:
> ```lang=c
> int x = 1;
> char *ptr =  // std::span ptr { , 4 };
> ```
> This is valid code. I suspect we want to check types as well, to see that 
> type sizes match.
> 
> Most of the time code like this violates strict aliasing, but `char` is 
> exceptional, and even if it did violate strict aliasing, people can compile 
> with `-fno-strict-aliasing` to define away the UB, so we have to respect that.
This code is not valid in C++.  An explicit cast is needed in front of ``.  I 
will add a test to show that 

```
int x = 1;
char * ptr = (char *)
```
will have a place holder for the span size.


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

https://reviews.llvm.org/D139737

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


[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz added inline comments.



Comment at: clang/lib/Lex/ModuleMap.cpp:663
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 

jansvoboda11 wrote:
> rmaz wrote:
> > jansvoboda11 wrote:
> > > How much work would be to refactor `File` to be `FileEntryRef`? Would be 
> > > good if we didn't need to resort to `getLastRef()`.
> > It is unfortunately a fair bit. I spent some time on it but hit a roadblock 
> > with the FileManagers VirtualFileEntries:
> > 
> > https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/FileManager.h#L70-L71
> > 
> > We would require this to be refactored to FileEntry too, as it is used here 
> > to provide a UID mapping to FileEntry pointers which needs to be changed to 
> > refs:
> > 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/FileManager.cpp#L614-L633
> > 
> > I can put up a follow on diff once this one is shipped if preferred?
> I was able to refactor the UID mapping to use `FileEntryRef` in D142780. 
> Given that, I think it would be preferable to propagate these into 
> `findOrCreateModuleForHeaderInUmbrellaDir()` and remove `getLastRef()`.
Nice, i'll rebase this and add the remaining changes once its shipped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142724

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked an inline comment as done.
python3kgae added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:4216
+  llvm::Triple T(getTargetTriple());
+  if (T.getArch() == llvm::Triple::dxil && 
!Args.getLastArg(options::OPT_dxc_disable_validation)) {
+// Only add action when 'dxv' exists.

jhuber6 wrote:
> Could we move this logic into the HLSL ToolChain like we do with CUDA / ROCm? 
> You should be able to then cast the toolchain to `HLSLToolChain` and query it 
> here.
Cannot find a cast example :(
Created a static method for HLSLToolChain to put the logic.



Comment at: clang/lib/Driver/ToolChains/HLSL.cpp:171
+// discover the dxv executable.
+getProgramPaths().push_back(getDriver().Dir);
+}

jhuber6 wrote:
> Just to check since I'm not really familiar at all with this toolchain, but 
> does `dxv` exist as a clang tool? This path exists to search in the 
> `/path/to/llvm/install/bin` directory. If it's an external binary this 
> shouldn't be necessary.
It will be external binary for a long time.
Removed the getDriver().Dir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

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


[PATCH] D141705: [HLSL] [Dirver] add dxv as a Driver Action Job

2023-01-27 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 492878.
python3kgae marked 9 inline comments as done.
python3kgae added a comment.

add DX_CONTAINER Driver type.
Code cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141705

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/test/Driver/dxc_D.hlsl
  clang/test/Driver/dxc_I.hlsl
  clang/test/Driver/dxc_dxv_path.hlsl
  clang/unittests/Driver/DXCModeTest.cpp

Index: clang/unittests/Driver/DXCModeTest.cpp
===
--- clang/unittests/Driver/DXCModeTest.cpp
+++ clang/unittests/Driver/DXCModeTest.cpp
@@ -34,7 +34,7 @@
 DiagnosticsEngine ) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_STREQ(TheDriver.getTargetTriple().c_str(), ExpectTriple.data());
   EXPECT_EQ(Diags.getNumErrors(), 0u);
@@ -47,7 +47,7 @@
 unsigned NumOfErrors) {
   Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
   std::unique_ptr C{TheDriver.BuildCompilation(
-  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl"})};
+  {"clang", "--driver-mode=dxc", TargetProfile.data(), "foo.hlsl", "-Vd"})};
   EXPECT_TRUE(C);
   EXPECT_EQ(Diags.getNumErrors(), NumOfErrors);
   EXPECT_STREQ(DiagConsumer->Errors.back().c_str(), ExpectError.data());
Index: clang/test/Driver/dxc_dxv_path.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_dxv_path.hlsl
@@ -0,0 +1,23 @@
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure report warning.
+// CHECK:dxv not found.
+
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s -Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv" "-" "-o" "-"
+
+// RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s --check-prefix=VD
+// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
+// VD-NOT:dxv not found
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxc"
+// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxc"], output: "[[DXC]].dxc"
+
+// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc  %s 2>&1 | FileCheck %s --check-prefix=PHASES
+
+// PHASES:+- 0: input, "[[INPUT:.+]]", hlsl
+// PHASES:+- 1: preprocessor, {0}, c++-cpp-output
+// PHASES:+- 2: compiler, {1}, ir
+// PHASES:3: backend, {2}, assembler
+// PHASES:4: binary-analyzer, {3}, dx-container
Index: clang/test/Driver/dxc_I.hlsl
===
--- clang/test/Driver/dxc_I.hlsl
+++ clang/test/Driver/dxc_I.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
 
 // Make sure -I send to cc1.
 // CHECK:"-I" "test"
Index: clang/test/Driver/dxc_D.hlsl
===
--- clang/test/Driver/dxc_D.hlsl
+++ clang/test/Driver/dxc_D.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_dxc -DTEST=2  -### %s 2>&1 | FileCheck %s
+// RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
 // RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
Index: clang/lib/Driver/ToolChains/HLSL.h
===
--- clang/lib/Driver/ToolChains/HLSL.h
+++ clang/lib/Driver/ToolChains/HLSL.h
@@ -9,17 +9,37 @@
 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_HLSL_H
 
+#include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 
 namespace clang {
 namespace driver {
 
+namespace tools {
+
+namespace hlsl {
+class LLVM_LIBRARY_VISIBILITY Validator : public Tool {
+public:
+  Validator(const ToolChain ) : Tool("hlsl::Validator", "dxv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) 

[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Lex/ModuleMap.cpp:663
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 

rmaz wrote:
> jansvoboda11 wrote:
> > How much work would be to refactor `File` to be `FileEntryRef`? Would be 
> > good if we didn't need to resort to `getLastRef()`.
> It is unfortunately a fair bit. I spent some time on it but hit a roadblock 
> with the FileManagers VirtualFileEntries:
> 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/FileManager.h#L70-L71
> 
> We would require this to be refactored to FileEntry too, as it is used here 
> to provide a UID mapping to FileEntry pointers which needs to be changed to 
> refs:
> 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/FileManager.cpp#L614-L633
> 
> I can put up a follow on diff once this one is shipped if preferred?
I was able to refactor the UID mapping to use `FileEntryRef` in D142780. Given 
that, I think it would be preferable to propagate these into 
`findOrCreateModuleForHeaderInUmbrellaDir()` and remove `getLastRef()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142724

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


[PATCH] D142780: [clang] NFCI: Use FileEntryRef in FileManager's UID mapping

2023-01-27 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: rmaz, benlangmuir, bnbarham.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per the `FileManager` documentation, `VirtualFileEntries` is a subset of 
`SeenFileEntries`. This means we only have to iterate over the latter to create 
complete UID mapping. This allows us to map UID to `FileEntryRef` instead of 
`FileEntry`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142780

Files:
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -169,23 +169,23 @@
 
   const HeaderSearch  = PP.getHeaderSearchInfo();
 
-  SmallVector FilesByUID;
-  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+  SmallVector FilesByUID;
+  HS.getFileMgr().getUniqueIDMapping(FilesByUID);
 
   if (FilesByUID.size() > HS.header_file_size())
 FilesByUID.resize(HS.header_file_size());
 
   for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
-const FileEntry *File = FilesByUID[UID];
+OptionalFileEntryRef File = FilesByUID[UID];
 if (!File)
   continue;
 
 const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/ false);
+HS.getExistingFileInfo(*File, /*WantExternal=*/false);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
-for (const auto  : HS.findAllModulesForHeader(File)) {
+for (const auto  : HS.findAllModulesForHeader(*File)) {
   if (!KH.getModule())
 continue;
   ModulesToProcess.push_back(KH.getModule());
@@ -1918,14 +1918,14 @@
 }
   }
 
-  SmallVector FilesByUID;
-  HS.getFileMgr().GetUniqueIDMapping(FilesByUID);
+  SmallVector FilesByUID;
+  HS.getFileMgr().getUniqueIDMapping(FilesByUID);
 
   if (FilesByUID.size() > HS.header_file_size())
 FilesByUID.resize(HS.header_file_size());
 
   for (unsigned UID = 0, LastUID = FilesByUID.size(); UID != LastUID; ++UID) {
-const FileEntry *File = FilesByUID[UID];
+OptionalFileEntryRef File = FilesByUID[UID];
 if (!File)
   continue;
 
@@ -1936,7 +1936,7 @@
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
 const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HS.getExistingFileInfo(*File, /*WantExternal=*/!Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1951,10 +1951,10 @@
 }
 
 HeaderFileInfoTrait::key_type Key = {
-  Filename, File->getSize(), getTimestampForOutput(File)
+  Filename, File->getSize(), getTimestampForOutput(*File)
 };
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findResolvedModulesForHeader(File), {}
+  *HFI, HS.getModuleMap().findResolvedModulesForHeader(*File), {}
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -611,25 +611,15 @@
   return std::error_code();
 }
 
-void FileManager::GetUniqueIDMapping(
-SmallVectorImpl ) const {
+void FileManager::getUniqueIDMapping(
+SmallVectorImpl ) const {
   UIDToFiles.clear();
   UIDToFiles.resize(NextFileUID);
 
-  // Map file entries
-  for (llvm::StringMap,
-   llvm::BumpPtrAllocator>::const_iterator
-   FE = SeenFileEntries.begin(),
-   FEEnd = SeenFileEntries.end();
-   FE != FEEnd; ++FE)
-if (llvm::ErrorOr Entry = FE->getValue()) {
-  if (const auto *FE = Entry->V.dyn_cast())
-UIDToFiles[FE->getUID()] = FE;
-}
-
-  // Map virtual file entries
-  for (const auto  : VirtualFileEntries)
-UIDToFiles[VFE->getUID()] = VFE;
+  for (const auto  : SeenFileEntries)
+if (llvm::ErrorOr Value = Entry.getValue())
+  if (const auto *FE = Value->V.dyn_cast())
+UIDToFiles[FE->getUID()] = FileEntryRef(Entry);
 }
 
 StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/include/clang/Basic/FileManager.h
@@ -311,9 +311,9 @@
   bool makeAbsolutePath(SmallVectorImpl ) const;
 
   /// Produce an array mapping from the unique IDs assigned to each
-  /// file to the corresponding FileEntry pointer.
-  void GetUniqueIDMapping(
-SmallVectorImpl ) const;
+  /// 

[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2023-01-27 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:127
+static auto isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) 
{
+  auto isLvalueToRvalueCast = [](internal::Matcher M) {
+return implicitCastExpr(hasCastKind(CastKind::CK_LValueToRValue),

Nit: I think we could simplify this to just

```
static auto isInUnspecifiedLvalueContext(internal::Matcher innerMatcher) {
  return implicitCastExpr(hasCastKind(CastKind::CK_LValueToRValue),
  castSubExpr(innerMatcher));
}
```


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

https://reviews.llvm.org/D139737

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


[PATCH] D142430: [Clang] Treat `std::forward_like` as builtin

2023-01-27 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

gentle ping )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142430

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


[PATCH] D142501: [clang][deps] Fix modulemap file path for implementation of module

2023-01-27 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
benlangmuir marked an inline comment as done.
Closed by commit rG73dba2f649a8: [clang][deps] Fix modulemap file path for 
implementation of module (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142501

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-implementation-vfs.m

Index: clang/test/ClangScanDeps/modules-implementation-vfs.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-implementation-vfs.m
@@ -0,0 +1,156 @@
+// Ensure we get the virtual module map path for a module whose implementation
+// file we are compiling.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- real/A.modulemap
+framework module A { umbrella header "A.h" }
+//--- real/A.private.modulemap
+framework module A_Private { umbrella header "A_Private.h" }
+
+//--- frameworks/A.framework/Headers/A.h
+struct A { int x; };
+//--- frameworks/A.framework/PrivateHeaders/A_Private.h
+#import 
+
+//--- frameworks/B.framework/Headers/B.h
+#import 
+//--- frameworks/B.framework/Modules/module.modulemap
+framework module B { umbrella header "B.h" }
+
+//--- overlay.json.template
+{
+  "case-sensitive": "false",
+  "version": 0,
+  "roots": [
+{
+  "external-contents": "DIR/real/A.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.modulemap",
+  "type": "file"
+},
+{
+  "external-contents": "DIR/real/A.private.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
+  "type": "file"
+},
+  ]
+}
+
+//--- cdb.json.template
+[
+{
+  "file": "DIR/tu1.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
+},
+{
+  "file": "DIR/tu2.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
+},
+{
+  "file": "DIR/tu3.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A -ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
+}
+]
+
+//--- tu1.m
+#import 
+
+//--- tu2.m
+#import 
+
+//--- tu3.m
+#import 
+// The following code triggers a note diagnostic pointing to A.h which is
+// resolved relative to the module base directory, which is affected by the
+// modulemap path.
+struct A { float x; }; // expected-error {{incompatible definitions}} expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -j 1 > %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+// CHECK:  {
+// CHECK:"modules": [
+// CHECK:  {
+// CHECK:"clang-module-deps": []
+// CHECK:"command-line": [
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK:  {
+// CHECK:"clang-module-deps": [
+// CHECK:  {
+// CHECK:"module-name": "A"
+// CHECK:  }
+// CHECK:]
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap",
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: "[[PREFIX]]/frameworks/B.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "B"
+// CHECK:  }
+
+// CHECK:"translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK:"input-file": "[[PREFIX]]/tu1.m"
+// CHECK-NEXT: }
+// CHECK:]
+// CHECK:  }
+// CHECK-NEXT: {
+// CHECK-NEXT:   "commands": [
+// CHECK:  {
+// CHECK:"command-line": [
+// CHECK:  "-fmodule-map-file=[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:  "-fmodule-name=A"
+// CHECK:],
+// CHECK: 

[clang] 73dba2f - [clang][deps] Fix modulemap file path for implementation of module

2023-01-27 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-01-27T11:37:35-08:00
New Revision: 73dba2f649a8e8c01e9c8b8df3bdc89cdf0fd7ee

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

LOG: [clang][deps] Fix modulemap file path for implementation of module

Use the name "as requested" for the path of the implemented module's
modulemap file, just as we do for other modulemap file paths. This fixes
fatal errors with modules where we tried to find framework headers
relative to the wrong directory when imported by an implementation file
of the same module.

rdar://104619123

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

Added: 
clang/test/ClangScanDeps/modules-implementation-vfs.m

Modified: 
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index cb1c66b8d63f7..eeeb5c265a7a7 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -233,7 +233,7 @@ void 
ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation ) {
   .getModuleMap()
   .getModuleMapFileForUniquing(CurrentModule))
 CI.getFrontendOpts().ModuleMapFiles.emplace_back(
-CurrentModuleMap->getName());
+CurrentModuleMap->getNameAsRequested());
 
 SmallVector DirectDeps;
 for (const auto  : ModularDeps)

diff  --git a/clang/test/ClangScanDeps/modules-implementation-vfs.m 
b/clang/test/ClangScanDeps/modules-implementation-vfs.m
new file mode 100644
index 0..6bd63d049b238
--- /dev/null
+++ b/clang/test/ClangScanDeps/modules-implementation-vfs.m
@@ -0,0 +1,156 @@
+// Ensure we get the virtual module map path for a module whose implementation
+// file we are compiling.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+//--- real/A.modulemap
+framework module A { umbrella header "A.h" }
+//--- real/A.private.modulemap
+framework module A_Private { umbrella header "A_Private.h" }
+
+//--- frameworks/A.framework/Headers/A.h
+struct A { int x; };
+//--- frameworks/A.framework/PrivateHeaders/A_Private.h
+#import 
+
+//--- frameworks/B.framework/Headers/B.h
+#import 
+//--- frameworks/B.framework/Modules/module.modulemap
+framework module B { umbrella header "B.h" }
+
+//--- overlay.json.template
+{
+  "case-sensitive": "false",
+  "version": 0,
+  "roots": [
+{
+  "external-contents": "DIR/real/A.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.modulemap",
+  "type": "file"
+},
+{
+  "external-contents": "DIR/real/A.private.modulemap",
+  "name": "DIR/frameworks/A.framework/Modules/module.private.modulemap",
+  "type": "file"
+},
+  ]
+}
+
+//--- cdb.json.template
+[
+{
+  "file": "DIR/tu1.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A 
-ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu1.m"
+},
+{
+  "file": "DIR/tu2.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A 
-ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu2.m"
+},
+{
+  "file": "DIR/tu3.m",
+  "directory": "DIR",
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -fmodule-name=A 
-ivfsoverlay DIR/overlay.json -F DIR/frameworks -fsyntax-only DIR/tu3.m"
+}
+]
+
+//--- tu1.m
+#import 
+
+//--- tu2.m
+#import 
+
+//--- tu3.m
+#import 
+// The following code triggers a note diagnostic pointing to A.h which is
+// resolved relative to the module base directory, which is affected by the
+// modulemap path.
+struct A { float x; }; // expected-error {{incompatible definitions}} 
expected-note {{type 'float' here}}
+// expected-note@frameworks/A.framework/Headers/A.h:1 {{type 'int' here}}
+
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format 
experimental-full -j 1 > %t/result.json
+// RUN: cat %t/result.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+// CHECK:  {
+// CHECK:"modules": [
+// CHECK:  {
+// CHECK:"clang-module-deps": []
+// CHECK:"command-line": [
+// CHECK:  "-x"
+// CHECK-NEXT: "objective-c"
+// CHECK-NEXT: 
"[[PREFIX]]/frameworks/A.framework/Modules/module.modulemap"
+// CHECK:]
+// CHECK:"name": "A"
+// CHECK:  }
+// CHECK:  {
+// CHECK:"clang-module-deps": [
+// CHECK:  {
+// CHECK:"module-name": "A"
+// CHECK:  

[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-01-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 492860.
ahatanak added a comment.

Fix a few typos that were causing compile errors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

Files:
  clang/lib/CodeGen/Address.h
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3164,7 +3164,8 @@
 
 Address getIndirectAddress() const {
   assert(isIndirect());
-  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment));
+  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment),
+ KnownNonNull);
 }
   };
 
@@ -3771,8 +3772,13 @@
   /// an LLVM type of the same size of the lvalue's type.  If the lvalue has a
   /// variable length type, this is not possible.
   ///
-  LValue EmitLValue(const Expr *E);
+  LValue EmitLValue(const Expr *E,
+KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
+private:
+  LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull);
+
+public:
   /// Same as EmitLValue but additionally we generate checking code to
   /// guard against undefined behavior.  This is only suitable when we know
   /// that the address will be used to access the object.
@@ -4783,9 +4789,10 @@
   /// into the address of a local variable.  In such a case, it's quite
   /// reasonable to just ignore the returned alignment when it isn't from an
   /// explicit source.
-  Address EmitPointerWithAlignment(const Expr *Addr,
-   LValueBaseInfo *BaseInfo = nullptr,
-   TBAAAccessInfo *TBAAInfo = nullptr);
+  Address
+  EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr,
+   KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
   /// If \p E references a parameter with pass_object_size info or a constant
   /// array size modifier, emit the object size divided by the size of \p EltTy.
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1104,8 +1104,9 @@
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
   ++AI;
-ReturnValue = Address(&*AI, ConvertType(RetTy),
-  CurFnInfo->getReturnInfo().getIndirectAlign());
+ReturnValue =
+Address(&*AI, ConvertType(RetTy),
+CurFnInfo->getReturnInfo().getIndirectAlign(), KnownNonNull);
 if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
   ReturnValuePointer =
   CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
@@ -1125,8 +1126,8 @@
 cast(Addr)->getResultElementType();
 ReturnValuePointer = Address(Addr, Ty, getPointerAlign());
 Addr = Builder.CreateAlignedLoad(Ty, Addr, getPointerAlign(), "agg.result");
-ReturnValue =
-Address(Addr, ConvertType(RetTy), CGM.getNaturalTypeAlignment(RetTy));
+ReturnValue = Address(Addr, ConvertType(RetTy),
+  CGM.getNaturalTypeAlignment(RetTy), KnownNonNull);
   } else {
 ReturnValue = CreateIRTemp(RetTy, "retval");
 
Index: clang/lib/CodeGen/CGValue.h
===
--- clang/lib/CodeGen/CGValue.h
+++ clang/lib/CodeGen/CGValue.h
@@ -178,7 +178,7 @@
 MatrixElt // This is a matrix element, use getVector*
   } LVType;
 
-  llvm::Value *V;
+  llvm::PointerIntPair V;
   llvm::Type *ElementType;
 
   union {
@@ -238,7 +238,7 @@
 if (isGlobalReg())
   assert(ElementType == nullptr && "Global reg does not store elem type");
 else
-  assert(llvm::cast(V->getType())
+  assert(llvm::cast(V.getPointer()->getType())
  ->isOpaqueOrPointeeTypeMatches(ElementType) &&
  "Pointer element type mismatch");
 
@@ -333,28 +333,36 @@
   LValueBaseInfo getBaseInfo() const { return BaseInfo; }
   void setBaseInfo(LValueBaseInfo Info) { BaseInfo = Info; }
 
+  KnownNonNull_t isKnownNonNull() const { return (KnownNonNull_t)V.getInt(); }
+  LValue setKnownNonNull() {
+V.setInt(true);
+return *this;
+  }
+
   // simple lvalue
   llvm::Value *getPointer(CodeGenFunction ) const {
 assert(isSimple());
-return V;
+return V.getPointer();
   }
   Address getAddress(CodeGenFunction ) const {
-return Address(getPointer(CGF), 

[PATCH] D141409: [SystemZ] Fix handling of vectors and their exposure of the vector ABI.

2023-01-27 Thread Jonas Paulsson 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 rG0eff46f87f16: [SystemZ] Fix handling of vectors and their 
exposure of the vector ABI. (authored by jonpa).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141409?vs=492794=492858#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141409

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/SystemZ/vec-abi-gnuattr-03b.c
  clang/test/CodeGen/SystemZ/vec-abi-gnuattr-08b.c
  clang/test/CodeGen/SystemZ/vec-abi-gnuattr-09b.c
  clang/test/CodeGen/SystemZ/vec-abi-gnuattr-17b.c
  clang/test/CodeGen/SystemZ/vec-abi-gnuattr-24.c

Index: clang/test/CodeGen/SystemZ/vec-abi-gnuattr-24.c
===
--- clang/test/CodeGen/SystemZ/vec-abi-gnuattr-24.c
+++ clang/test/CodeGen/SystemZ/vec-abi-gnuattr-24.c
@@ -34,4 +34,20 @@
   return foo(V)[0] + GlobVal + GlobExtVar;
 }
 
+// Globally visible vector variable less than 16 bytes in size.
+typedef __attribute__((vector_size(8))) int v2i32;
+v2i32 NarrowVecVar;
+
+// Global function taking narrow vector array and pointer.
+void bar(v2i32 VArr[4], v2i32 *Dst) { *Dst = VArr[3]; }
+
+// Wide vector parameters via "hidden" pointers.
+typedef __attribute__((vector_size(32))) int v8i32;
+v8i32 bar2(v8i32 Arg) { return Arg; }
+
+// Same but with a single element struct.
+struct SingleElStruct { v8i32 B; };
+struct SingleElStruct bar3(struct SingleElStruct Arg) { return Arg; }
+
+
 //CHECK-NOT: !{i32 2, !"s390x-visible-vector-ABI", i32 1}
Index: clang/test/CodeGen/SystemZ/vec-abi-gnuattr-17b.c
===
--- /dev/null
+++ clang/test/CodeGen/SystemZ/vec-abi-gnuattr-17b.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -fzvector -o - %s 2>&1 \
+// RUN:   | FileCheck  %s
+//
+// Test that the "s390x-visible-vector-ABI" module flag is emitted.
+
+// Globally visible function pointer with narrow vector argument.
+
+typedef __attribute__((vector_size(8))) int v2i32;
+
+void (*bar)(v2i32 Arg);
+
+//CHECK: !llvm.module.flags = !{!0, !1}
+//CHECK: !0 = !{i32 2, !"s390x-visible-vector-ABI", i32 1}
Index: clang/test/CodeGen/SystemZ/vec-abi-gnuattr-09b.c
===
--- /dev/null
+++ clang/test/CodeGen/SystemZ/vec-abi-gnuattr-09b.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -fzvector -o - %s 2>&1 \
+// RUN:   | FileCheck  %s
+//
+// Test the emission of the "s390x-visible-vector-ABI" module flag.
+
+// Call to vararg function with a narrow (8 bytes) vector argument.
+
+typedef __attribute__((vector_size(8))) int v2i32;
+
+void bar(int N, ...);
+
+void foo() {
+  v2i32 Var = {0, 0};
+  bar(0, Var);
+}
+
+//CHECK: !llvm.module.flags = !{!0, !1}
+//CHECK: !0 = !{i32 2, !"s390x-visible-vector-ABI", i32 1}
Index: clang/test/CodeGen/SystemZ/vec-abi-gnuattr-08b.c
===
--- /dev/null
+++ clang/test/CodeGen/SystemZ/vec-abi-gnuattr-08b.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -fzvector -o - %s 2>&1 \
+// RUN:   | FileCheck  %s
+//
+// Test the emission of the "s390x-visible-vector-ABI" module flag.
+
+// Passing a single element struct containing a narrow (8 byte) vector element.
+
+typedef __attribute__((vector_size(8))) int v2i32;
+
+struct S {
+  v2i32 B;
+};
+
+void bar(struct S Arg);
+
+void foo() {
+  struct S Var = {{0, 0}};
+  bar(Var);
+}
+
+//CHECK: !llvm.module.flags = !{!0, !1}
+//CHECK: !0 = !{i32 2, !"s390x-visible-vector-ABI", i32 1}
Index: clang/test/CodeGen/SystemZ/vec-abi-gnuattr-03b.c
===
--- /dev/null
+++ clang/test/CodeGen/SystemZ/vec-abi-gnuattr-03b.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple s390x-ibm-linux -emit-llvm -fzvector -o - %s 2>&1 \
+// RUN:   | FileCheck  %s
+//
+// Test that the "s390x-visible-vector-ABI" module flag is emitted.
+
+// Call to external function with with narrow vector argument.
+
+typedef __attribute__((vector_size(8))) int v2i32;
+
+void bar(v2i32 arg);
+
+void foo() {
+  v2i32 Var = {0, 0};
+  bar(Var);
+}
+
+//CHECK: !llvm.module.flags = !{!0, !1}
+//CHECK: !0 = !{i32 2, !"s390x-visible-vector-ABI", i32 1}
+
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7418,18 +7418,28 @@
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
+  ASTContext 
+
+  const SystemZABIInfo () const {
+return static_cast(TargetCodeGenInfo::getABIInfo());
+  }
+
   // These are used for speeding up the search for a visible vector 

[clang] 0eff46f - [SystemZ] Fix handling of vectors and their exposure of the vector ABI.

2023-01-27 Thread Jonas Paulsson via cfe-commits

Author: Jonas Paulsson
Date: 2023-01-27T20:24:09+01:00
New Revision: 0eff46f87f16772f93bdc584865e945162aff170

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

LOG: [SystemZ] Fix handling of vectors and their exposure of the vector ABI.

- Global vector variables expose the vector ABI through their alignments only
  if they are >=16 bytes in size.

- Vectors passed between functions expose the vector ABI only if they are
  <=16 bytes in size.

LLVM test suite builds with gcc/clang now give the same gnu attributes emitted.

Reviewed By: Ulrich Weigand

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

Added: 
clang/test/CodeGen/SystemZ/vec-abi-gnuattr-03b.c
clang/test/CodeGen/SystemZ/vec-abi-gnuattr-08b.c
clang/test/CodeGen/SystemZ/vec-abi-gnuattr-09b.c
clang/test/CodeGen/SystemZ/vec-abi-gnuattr-17b.c

Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/SystemZ/vec-abi-gnuattr-24.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index be1dbe8480c6e..a9119abad81d8 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7418,18 +7418,28 @@ class SystemZABIInfo : public ABIInfo {
 };
 
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
+  ASTContext 
+
+  const SystemZABIInfo () const {
+return static_cast(TargetCodeGenInfo::getABIInfo());
+  }
+
   // These are used for speeding up the search for a visible vector ABI.
   mutable bool HasVisibleVecABIFlag = false;
   mutable std::set SeenTypes;
 
-  // Returns true (the first time) if Ty is or found to make use of a vector
-  // type (e.g. as a function argument).
-  bool isVectorTypeBased(const Type *Ty) const;
+  // Returns true (the first time) if Ty is, or is found to include, a vector
+  // type that exposes the vector ABI. This is any vector >=16 bytes which
+  // with vector support are aligned to only 8 bytes. When IsParam is true,
+  // the type belongs to a value as passed between functions. If it is a
+  // vector <=16 bytes it will be passed in a vector register (if supported).
+  bool isVectorTypeBased(const Type *Ty, bool IsParam) const;
 
 public:
   SystemZTargetCodeGenInfo(CodeGenTypes , bool HasVector, bool 
SoftFloatABI)
   : TargetCodeGenInfo(
-std::make_unique(CGT, HasVector, SoftFloatABI)) {
+std::make_unique(CGT, HasVector, SoftFloatABI)),
+Ctx(CGT.getContext()) {
 SwiftInfo =
 std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
   }
@@ -7439,9 +7449,9 @@ class SystemZTargetCodeGenInfo : public TargetCodeGenInfo 
{
   // indicating a visible vector ABI is added. Eventually this will result in
   // a GNU attribute indicating the vector ABI of the module.  Ty is the type
   // of a variable or function parameter that is globally visible.
-  void handleExternallyVisibleObjABI(const Type *Ty,
- CodeGen::CodeGenModule ) const {
-if (!HasVisibleVecABIFlag && isVectorTypeBased(Ty)) {
+  void handleExternallyVisibleObjABI(const Type *Ty, CodeGen::CodeGenModule ,
+ bool IsParam) const {
+if (!HasVisibleVecABIFlag && isVectorTypeBased(Ty, IsParam)) {
   M.getModule().addModuleFlag(llvm::Module::Warning,
   "s390x-visible-vector-ABI", 1);
   HasVisibleVecABIFlag = true;
@@ -7457,11 +7467,13 @@ class SystemZTargetCodeGenInfo : public 
TargetCodeGenInfo {
 // variable or function.
 if (const auto *VD = dyn_cast(D)) {
   if (VD->isExternallyVisible())
-handleExternallyVisibleObjABI(VD->getType().getTypePtr(), M);
+handleExternallyVisibleObjABI(VD->getType().getTypePtr(), M,
+  /*IsParam*/false);
 }
 else if (const FunctionDecl *FD = dyn_cast(D)) {
   if (FD->isExternallyVisible())
-handleExternallyVisibleObjABI(FD->getType().getTypePtr(), M);
+handleExternallyVisibleObjABI(FD->getType().getTypePtr(), M,
+  /*IsParam*/false);
 }
   }
 
@@ -7571,17 +7583,18 @@ QualType SystemZABIInfo::GetSingleElementType(QualType 
Ty) const {
 
 // If this is a C++ record, check the bases first.
 if (const CXXRecordDecl *CXXRD = dyn_cast(RD))
-  for (const auto  : CXXRD->bases()) {
-QualType Base = I.getType();
+  if (CXXRD->hasDefinition())
+for (const auto  : CXXRD->bases()) {
+  QualType Base = I.getType();
 
-// Empty bases don't affect things either way.
-if (isEmptyRecord(getContext(), Base, true))
-  continue;
+  // Empty bases don't affect things either way.
+  if (isEmptyRecord(getContext(), Base, true))
+

[libclc] 8040e3a - libclc: Fix building against an llvm build directory

2023-01-27 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2023-01-27T11:16:03-08:00
New Revision: 8040e3a4deeb25edc34fb4f89e032ff58ad50572

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

LOG: libclc: Fix building against an llvm build directory

Reviewed By: thieta

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

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 0e21a861d8985..f712100689b09 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -105,7 +105,10 @@ endif()
 
 enable_language( CLC LLAsm )
 # This needs to be set before any target that needs it
-include_directories( ${LLVM_INCLUDE_DIR} )
+# We need to use LLVM_INCLUDE_DIRS here, because if we are linking to an
+# llvm build directory, this includes $src/llvm/include which is where all the
+# headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to.
+include_directories( ${LLVM_INCLUDE_DIRS} )
 
 # Setup prepare_builtins tools
 set(LLVM_LINK_COMPONENTS



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


[clang] 4266756 - Fix recursive error for constraints depending on itself incorrectly

2023-01-27 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-01-27T11:11:53-08:00
New Revision: 42667563721e139a93ab886119ea2780ebc3fecc

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

LOG: Fix recursive error for constraints depending on itself incorrectly

Fixes: #60323

https://github.com/llvm/llvm-project/issues/60323

The problem is that we are profiling the 'Expr' components directly,
however when they contain an unresolved lookup, those canonicalize
identically.  The result was the two versions of calls to 'go' were
canonicalized identically.

This patch fixes this by ensuring we consider the declaration the
constraint is attached to, when possible.  When not, we skip the
diagnostic.

The result is that we are relaxing our diagnostic in some cases (Of
which I couldn't come up with a reproducer), such that we might see
overflows when evaluating constraints that depend on themselves in a way
that they are not attached to a declaration directly, such as if
they are nested requirements, though the hope is this won't be a
problem, since the 'parent' named constraint would catch this.  I'm
hopeful that the 'worst case' is that we catch recursion 'later' in the
process, instead of immediately.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts-recursive-inst.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e52e853e1df86..66b018d8fba1a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7279,24 +7279,34 @@ class Sema final {
 
 private:
   // The current stack of constraint satisfactions, so we can exit-early.
-  llvm::SmallVector SatisfactionStack;
+  using SatisfactionStackEntryTy =
+  std::pair;
+  llvm::SmallVector
+  SatisfactionStack;
 
 public:
-  void PushSatisfactionStackEntry(const llvm::FoldingSetNodeID ) {
-SatisfactionStack.push_back(ID);
+  void PushSatisfactionStackEntry(const NamedDecl *D,
+  const llvm::FoldingSetNodeID ) {
+const NamedDecl *Can = cast(D->getCanonicalDecl());
+SatisfactionStack.emplace_back(Can, ID);
   }
 
   void PopSatisfactionStackEntry() { SatisfactionStack.pop_back(); }
 
-  bool SatisfactionStackContains(const llvm::FoldingSetNodeID ) const {
-return llvm::find(SatisfactionStack, ID) != SatisfactionStack.end();
+  bool SatisfactionStackContains(const NamedDecl *D,
+ const llvm::FoldingSetNodeID ) const {
+const NamedDecl *Can = cast(D->getCanonicalDecl());
+return llvm::find(SatisfactionStack,
+  SatisfactionStackEntryTy{Can, ID}) !=
+   SatisfactionStack.end();
   }
 
   // Resets the current SatisfactionStack for cases where we are instantiating
   // constraints as a 'side effect' of normal instantiation in a way that is 
not
   // indicative of recursive definition.
   class SatisfactionStackResetRAII {
-llvm::SmallVector BackupSatisfactionStack;
+llvm::SmallVector
+BackupSatisfactionStack;
 Sema 
 
   public:
@@ -7309,8 +7319,8 @@ class Sema final {
 }
   };
 
-  void
-  SwapSatisfactionStack(llvm::SmallVectorImpl ) {
+  void SwapSatisfactionStack(
+  llvm::SmallVectorImpl ) {
 SatisfactionStack.swap(NewSS);
   }
 

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index f163ad294a237..a92bbde113fcd 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -150,11 +150,19 @@ bool Sema::CheckConstraintExpression(const Expr 
*ConstraintExpression,
 namespace {
 struct SatisfactionStackRAII {
   Sema 
-  SatisfactionStackRAII(Sema , llvm::FoldingSetNodeID FSNID)
+  bool Inserted = false;
+  SatisfactionStackRAII(Sema , const NamedDecl *ND,
+llvm::FoldingSetNodeID FSNID)
   : SemaRef(SemaRef) {
-  SemaRef.PushSatisfactionStackEntry(FSNID);
+  if (ND) {
+  SemaRef.PushSatisfactionStackEntry(ND, FSNID);
+  Inserted = true;
+  }
+  }
+  ~SatisfactionStackRAII() {
+if (Inserted)
+  SemaRef.PopSatisfactionStackEntry();
   }
-  ~SatisfactionStackRAII() { SemaRef.PopSatisfactionStackEntry(); }
 };
 } // namespace
 
@@ -273,7 +281,8 @@ calculateConstraintSatisfaction(Sema , const Expr 
*ConstraintExpr,
 }
 
 static bool
-DiagRecursiveConstraintEval(Sema , llvm::FoldingSetNodeID , const Expr *E,
+DiagRecursiveConstraintEval(Sema , llvm::FoldingSetNodeID ,
+const NamedDecl *Templ, const Expr *E,
 const MultiLevelTemplateArgumentList ) {
   E->Profile(ID, S.Context, /*Canonical=*/true);
   for (const auto  : MLTAL)
@@ -286,7 +295,7 @@ DiagRecursiveConstraintEval(Sema , 

[PATCH] D142565: [clang-tidy] Fix warning in portability-simd-intrinsics

2023-01-27 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d02dd241816: [clang-tidy] Fix warning in 
portability-simd-intrinsics (authored by ClockMan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142565

Files:
  clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
  clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics 
%t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: false} \
+// RUN:  ]}' -- -target x86_64
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
 // RUN:  -config='{CheckOptions: [ \
 // RUN:{key: portability-simd-intrinsics.Suggest, value: true} \
 // RUN:  ]}' -- -target x86_64
@@ -21,8 +25,9 @@
   __m256 d0;
 
   _mm_add_epi32(i0, i1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced 
by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can 
be replaced by operator+ on std::experimental::simd objects 
[portability-simd-intrinsics]
   // CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: '_mm_add_epi32' can be 
replaced by operator+ on std::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: '_mm_add_epi32' is a 
non-portable x86_64 intrinsic function [portability-simd-intrinsics]
   d0 = _mm256_load_pd(0);
   _mm256_store_pd(0, d0);
 
Index: 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics 
%t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: false} \
+// RUN:  ]}' -- -target ppc64le -maltivec
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
 // RUN:  -config='{CheckOptions: [ \
 // RUN:{key: portability-simd-intrinsics.Suggest, value: true} \
 // RUN:  ]}' -- -target ppc64le -maltivec
@@ -13,6 +17,7 @@
   vector int i0, i1;
 
   vec_add(i0, i1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by 
operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: 'vec_add' can be 
replaced by operator+ on std::experimental::simd objects 
[portability-simd-intrinsics]
   // CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: 'vec_add' can be replaced 
by operator+ on std::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'vec_add' is a non-portable 
powerpc64le intrinsic function [portability-simd-intrinsics]
 }
Index: clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
===
--- clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
+++ clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
@@ -138,7 +138,7 @@
   << SimdRegex.sub(SmallString<32>({Std, "::simd"}),
StdRegex.sub(Std, New));
 } else {
-  diag("'%0' is a non-portable %1 intrinsic function")
+  diag(Call->getExprLoc(), "'%0' is a non-portable %1 intrinsic function")
   << Old << llvm::Triple::getArchTypeName(Arch);
 }
   }


Index: clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics %t -- \
+// RUN:  -config='{CheckOptions: 

[clang-tools-extra] 1d02dd2 - [clang-tidy] Fix warning in portability-simd-intrinsics

2023-01-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-01-27T18:50:51Z
New Revision: 1d02dd241816e3d5865e7d395ee7310167198b09

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

LOG: [clang-tidy] Fix warning in portability-simd-intrinsics

When portability-simd-intrinsics.Suggest were set to false,
produced warning were missing source location,
and due to that such warning coudn't be NOLINTed.

Added missing tests.

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

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp

clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
index 55ffe2d91cadb..68fd0a4ed5fa4 100644
--- a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
@@ -138,7 +138,7 @@ void SIMDIntrinsicsCheck::check(const 
MatchFinder::MatchResult ) {
   << SimdRegex.sub(SmallString<32>({Std, "::simd"}),
StdRegex.sub(Std, New));
 } else {
-  diag("'%0' is a non-portable %1 intrinsic function")
+  diag(Call->getExprLoc(), "'%0' is a non-portable %1 intrinsic function")
   << Old << llvm::Triple::getArchTypeName(Arch);
 }
   }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
index 942a305e8152e..547301518f575 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-ppc.cpp
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics 
%t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: false} \
+// RUN:  ]}' -- -target ppc64le -maltivec
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
 // RUN:  -config='{CheckOptions: [ \
 // RUN:{key: portability-simd-intrinsics.Suggest, value: true} \
 // RUN:  ]}' -- -target ppc64le -maltivec
@@ -13,6 +17,7 @@ void PPC() {
   vector int i0, i1;
 
   vec_add(i0, i1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'vec_add' can be replaced by 
operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: 'vec_add' can be 
replaced by operator+ on std::experimental::simd objects 
[portability-simd-intrinsics]
   // CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: 'vec_add' can be replaced 
by operator+ on std::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'vec_add' is a non-portable 
powerpc64le intrinsic function [portability-simd-intrinsics]
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
index 28b3fd120263e..3736161dfb495 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp
@@ -1,4 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics %t -- \
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics 
%t -- \
+// RUN:  -config='{CheckOptions: [ \
+// RUN:{key: portability-simd-intrinsics.Suggest, value: false} \
+// RUN:  ]}' -- -target x86_64
+// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s 
portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
 // RUN:  -config='{CheckOptions: [ \
 // RUN:{key: portability-simd-intrinsics.Suggest, value: true} \
 // RUN:  ]}' -- -target x86_64
@@ -21,8 +25,9 @@ void X86() {
   __m256 d0;
 
   _mm_add_epi32(i0, i1);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced 
by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
+  // CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can 
be replaced by operator+ on std::experimental::simd objects 
[portability-simd-intrinsics]
   // CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: '_mm_add_epi32' can be 
replaced by operator+ on std::simd objects [portability-simd-intrinsics]
+  

[libclc] 409f42b - libclc: Set CMAKE_CXX_STANDARD to 17 to match llvm

2023-01-27 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2023-01-27T10:50:29-08:00
New Revision: 409f42b10ac6dc1c6a4e68d20ccd3adf6770e238

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

LOG: libclc: Set CMAKE_CXX_STANDARD to 17 to match llvm

Reviewed By: thieta

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

Added: 


Modified: 
libclc/CMakeLists.txt

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 0a23471537dfd..0e21a861d8985 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.13.4)
 
 project( libclc VERSION 0.2.0 LANGUAGES CXX C)
 
+set(CMAKE_CXX_STANDARD 17)
+
 include( GNUInstallDirs )
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
   amdgcn-amdhsa/lib/SOURCES;



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


[clang] 131b955 - [CMake] Include clang-bolt bootstrap target in BOLT-PGO.cmake

2023-01-27 Thread Amir Ayupov via cfe-commits

Author: Amir Ayupov
Date: 2023-01-27T10:46:34-08:00
New Revision: 131b955a4f7015c718c1780d0320353d488f85be

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

LOG: [CMake] Include clang-bolt bootstrap target in BOLT-PGO.cmake

Preemptively include clang-bolt target in BOLT-PGO CMake cache file,
in preparation of https://reviews.llvm.org/D139454 to avoid breaking
bolt-x86_64-ubuntu-clang-bolt-lto-pgo buildbot.

Added: 


Modified: 
clang/cmake/caches/BOLT-PGO.cmake

Removed: 




diff  --git a/clang/cmake/caches/BOLT-PGO.cmake 
b/clang/cmake/caches/BOLT-PGO.cmake
index 54827c124bcb1..c329415465c94 100644
--- a/clang/cmake/caches/BOLT-PGO.cmake
+++ b/clang/cmake/caches/BOLT-PGO.cmake
@@ -1,9 +1,11 @@
 set(LLVM_ENABLE_PROJECTS "bolt;clang;lld" CACHE STRING "")
 
 set(CLANG_BOOTSTRAP_TARGETS
+  stage2-clang-bolt
   stage2-clang++-bolt
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
+  clang-bolt
   clang++-bolt
   CACHE STRING "")
 



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


[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-01-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

There are more places where we know contextually the pointer can't be null and 
can set the bit to `KnownNonNull` or set the bit of an `LValue` or `Address` 
using an existing `Address`'s KnownNonNull bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

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


[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

2023-01-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 492843.
ahatanak added a comment.

Add a bit to `Address` and `LValue` that tracks whether the pointer is known 
not to be null.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142584

Files:
  clang/lib/CodeGen/Address.h
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGNonTrivialStruct.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3164,7 +3164,8 @@
 
 Address getIndirectAddress() const {
   assert(isIndirect());
-  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment));
+  return Address(Value, ElementType, CharUnits::fromQuantity(Alignment),
+ KnownNonNull);
 }
   };
 
@@ -3771,8 +3772,13 @@
   /// an LLVM type of the same size of the lvalue's type.  If the lvalue has a
   /// variable length type, this is not possible.
   ///
-  LValue EmitLValue(const Expr *E);
+  LValue EmitLValue(const Expr *E,
+KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
+private:
+  LValue EmitLValueHelper(const Expr *E, KnownNonNull_t IsKnownNonNull);
+
+public:
   /// Same as EmitLValue but additionally we generate checking code to
   /// guard against undefined behavior.  This is only suitable when we know
   /// that the address will be used to access the object.
@@ -4783,9 +4789,10 @@
   /// into the address of a local variable.  In such a case, it's quite
   /// reasonable to just ignore the returned alignment when it isn't from an
   /// explicit source.
-  Address EmitPointerWithAlignment(const Expr *Addr,
-   LValueBaseInfo *BaseInfo = nullptr,
-   TBAAAccessInfo *TBAAInfo = nullptr);
+  Address
+  EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo = nullptr,
+   TBAAAccessInfo *TBAAInfo = nullptr,
+   KnownNonNull_t IsKnownNonNull = NotKnownNonNull);
 
   /// If \p E references a parameter with pass_object_size info or a constant
   /// array size modifier, emit the object size divided by the size of \p EltTy.
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1104,8 +1104,9 @@
 auto AI = CurFn->arg_begin();
 if (CurFnInfo->getReturnInfo().isSRetAfterThis())
   ++AI;
-ReturnValue = Address(&*AI, ConvertType(RetTy),
-  CurFnInfo->getReturnInfo().getIndirectAlign());
+ReturnValue =
+Address(&*AI, ConvertType(RetTy),
+CurFnInfo->getReturnInfo().getIndirectAlign(), KnownNonNull);
 if (!CurFnInfo->getReturnInfo().getIndirectByVal()) {
   ReturnValuePointer =
   CreateDefaultAlignTempAlloca(Int8PtrTy, "result.ptr");
@@ -1125,8 +1126,8 @@
 cast(Addr)->getResultElementType();
 ReturnValuePointer = Address(Addr, Ty, getPointerAlign());
 Addr = Builder.CreateAlignedLoad(Ty, Addr, getPointerAlign(), "agg.result");
-ReturnValue =
-Address(Addr, ConvertType(RetTy), CGM.getNaturalTypeAlignment(RetTy));
+ReturnValue = Address(Addr, ConvertType(RetTy),
+  CGM.getNaturalTypeAlignment(RetTy), KnownNonNull);
   } else {
 ReturnValue = CreateIRTemp(RetTy, "retval");
 
Index: clang/lib/CodeGen/CGValue.h
===
--- clang/lib/CodeGen/CGValue.h
+++ clang/lib/CodeGen/CGValue.h
@@ -178,7 +178,7 @@
 MatrixElt // This is a matrix element, use getVector*
   } LVType;
 
-  llvm::Value *V;
+  llvm::PointerIntPair V;
   llvm::Type *ElementType;
 
   union {
@@ -238,7 +238,7 @@
 if (isGlobalReg())
   assert(ElementType == nullptr && "Global reg does not store elem type");
 else
-  assert(llvm::cast(V->getType())
+  assert(llvm::cast(V.getPointer()->getType())
  ->isOpaqueOrPointeeTypeMatches(ElementType) &&
  "Pointer element type mismatch");
 
@@ -333,28 +333,36 @@
   LValueBaseInfo getBaseInfo() const { return BaseInfo; }
   void setBaseInfo(LValueBaseInfo Info) { BaseInfo = Info; }
 
+  KnownNonNull_t isKnownNonNull() const { return (KnownNonNull_t)V.getInt(); }
+  LValue setKnownNonNull() {
+V.setInt(true);
+return *this;
+  }
+
   // simple lvalue
   llvm::Value *getPointer(CodeGenFunction ) const {
 assert(isSimple());
-return V;
+return V.getPointer();
   }
   Address getAddress(CodeGenFunction ) const {

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/tools/include-mapping/cppreference_parser.py:196
+  "std::remove$": "algorithm",
+  "std::atomic.*": "atomic",
+

there's no variant of "std::atomic.*" called "atomic", in 
https://en.cppreference.com/w/cpp/symbol_index. is it something in 2018 version 
of the html book? otherwise there's only the unnamed variant and 
std::shared_ptr variant, and we should be preferring unnamed variant.



Comment at: clang/tools/include-mapping/cppreference_parser.py:107
+  # FIXME: only consider first symbol, assume further symbols are overloads
+  all_headers = sorted(list(all_headers))
+  if len(all_headers) > 0:

VitaNuo wrote:
> hokein wrote:
> > why sort the headers?
> This was a hack to make the generator return `atomic` rather than `memory` 
> for `std::atomic.*` symbols. But I've noticed now that this adds some trouble 
> to the C symbol map. I think now that cutting `all_headers` to the first 
> element is wrong.
> I will special-case the `std::atomic.*` symbols instead, because so far I 
> don't see a way to solve this programmatically without other collateral 
> effects.
> 
> Note that the problem is not `std::atomic` itself (for which Kadir 
> extensively described the solution in some of the other comments), but rather 
> `atomic_bool`, `atomic_char` etc. mentioned further in the page. The headers 
> for them come from `all_headers` rather than `symbol_headers`, and there 
> seems to be no way to limit them to `` without other collateral 
> effects.
> I think now that cutting all_headers to the first element is wrong.

What's exactly breaking once you do that? (I guess by `first element` you still 
mean "all the headers we've seen until the first declaration in the page")

>  but rather atomic_bool, atomic_char etc. mentioned further in the page. The 
> headers for them come from all_headers rather than symbol_headers, and there 
> seems to be no way to limit them to  without other collateral effects.

I guess this is happening because we're trying to find headers that are for the 
declaration block containing the interesting symbol name. Any idea if that 
logic is winning us anything? e.g. if we dropped the `if symbol_name in 
found_symbols:` what does change?



Comment at: clang/tools/include-mapping/cppreference_parser.py:165
   # FIXME: use these as a fallback rather than ignoring entirely.
-  variants_for_symbol = variants_to_accept.get(
-  (namespace or "") + symbol_name, ())
-  if variant and variant not in variants_for_symbol:
+  header_to_accept = variants_to_accept.get(
+  (namespace or "") + symbol_name, "")

VitaNuo wrote:
> kadircet wrote:
> > `variant` is not necessarily the `header`, eg:
> > ```
> > acos()
> > acos<>() (std::complex) (since C++11)
> > acos<>() (std::valarray)
> > ```
> > 
> > in this case variants are `std::complex` and `std::valarray`. 
> > 
> > hence we're not trying to "infer" the header we want to preserve but rather 
> > decide on which symbol page we want to parse. we should still accept "all 
> > the headers" mentioned in that variant symbol page.
> Ah ok, I was mostly looking at `std::remove (algorithm)`. Ok, I will use the 
> term "variant" as before. Thanks.
sorry i wasn't just trying to nitpick on the name of the variable/parameters.

i was trying to say `_ReadSymbolPage` should not be a function of 
`variant_to_accept`.
we should "completely skip" parsing of symbol pages for variants we don't want 
to take in (that's what this `continue` here is trying to achieve)

later on when we're parsing a symbol page, the name of the variant shouldn't 
effect the headers we're picking in any way (especially in the way you're 
relying right now that says variant name and the header name will be the same, 
as i pointed out this might as well be `std::complex`).

Is this trying to work around a different problem? (especially around 
`std::atomic_.*` I assume, i'll follow up on that thread)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142092

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


[PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread River Riddle via Phabricator via cfe-commits
rriddle added a comment.

I don't understand the MLIR changes here, how are they relevant to the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142733

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


[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz marked an inline comment as done.
rmaz added inline comments.



Comment at: clang/lib/Lex/ModuleMap.cpp:663
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 

jansvoboda11 wrote:
> How much work would be to refactor `File` to be `FileEntryRef`? Would be good 
> if we didn't need to resort to `getLastRef()`.
It is unfortunately a fair bit. I spent some time on it but hit a roadblock 
with the FileManagers VirtualFileEntries:

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/FileManager.h#L70-L71

We would require this to be refactored to FileEntry too, as it is used here to 
provide a UID mapping to FileEntry pointers which needs to be changed to refs:

https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/FileManager.cpp#L614-L633

I can put up a follow on diff once this one is shipped if preferred?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142724

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


[PATCH] D142690: [DRAFT][libc++] Fixes the Clang modular build.

2023-01-27 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 492834.
Mordante added a comment.

Removes uninteded include.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

Files:
  libcxx/include/module.modulemap.in
  libcxx/utils/ci/generate-buildkite-pipeline


Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,8 +19,4 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
-else
-  cat libcxx/utils/ci/buildkite-pipeline.yml
-fi
+cat libcxx/utils/ci/buildkite-pipeline-clang.yml
Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header 
"__concepts/derived_from.h" }
   module destructible   { private header 
"__concepts/destructible.h" }
   module different_from { private header 
"__concepts/different_from.h" }
-  module equality_comparable{ private header 
"__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header 
"__concepts/invocable.h" }
   module movable{ private header 
"__concepts/movable.h" }
   module predicate  { private header 
"__concepts/predicate.h" }
   module regular{ private header 
"__concepts/regular.h" }
   module relation   { private header 
"__concepts/relation.h" }
-  module same_as{ private header 
"__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header 
"__concepts/semiregular.h" }
   module swappable  { private header 
"__concepts/swappable.h" }
   module totally_ordered{ private header 
"__concepts/totally_ordered.h" }
@@ -979,7 +985,11 @@
   module back_insert_iterator  { private header 
"__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header 
"__iterator/bounded_iter.h" }
   module common_iterator   { private header 
"__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header 
"__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default_sentinel  { private header 
"__iterator/default_sentinel.h" }


Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,8 +19,4 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
-else
-  cat libcxx/utils/ci/buildkite-pipeline.yml
-fi
+cat libcxx/utils/ci/buildkite-pipeline-clang.yml
Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header "__concepts/derived_from.h" }
   module destructible   { private header "__concepts/destructible.h" }
   module different_from { private header "__concepts/different_from.h" }
-  module equality_comparable{ private header "__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header "__concepts/invocable.h" }
   module movable{ private header "__concepts/movable.h" }
   module predicate  { private header "__concepts/predicate.h" }
   module regular{ private header "__concepts/regular.h" }
   module relation   { private header "__concepts/relation.h" }
-  module same_as{ private header "__concepts/same_as.h" }
+  module same_as {
+private 

[PATCH] D142723: [C2x] Stop diagnosing member and array access in offsetof as an extension

2023-01-27 Thread Alexey Neyman via Phabricator via cfe-commits
stilor added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:2389
   const int ext1 = __builtin_offsetof(struct U { int i; }, i); // C extension
-  const int ext2 = __builtin_offsetof(struct S, t.f[1]); // C & C++ extension
+  const int ext2 = __builtin_offsetof(struct S, t.f[1]);
 

Minor nit: maybe rename from `ext2` to, say, `offset_to_subobject` to avoid 
implying it is an extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142723

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


[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 492829.
rmaz added a comment.

Use FileEntryRef for AddTopHeader()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142724

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8788,7 +8788,7 @@
 return 0;
   Module *Mod = static_cast(CXMod);
   FileManager  = cxtu::getASTUnit(TU)->getFileManager();
-  ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr);
+  auto TopHeaders = Mod->getTopHeaders(FileMgr);
   return TopHeaders.size();
 }
 
@@ -8803,9 +8803,9 @@
   Module *Mod = static_cast(CXMod);
   FileManager  = cxtu::getASTUnit(TU)->getFileManager();
 
-  ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr);
+  auto TopHeaders = Mod->getTopHeaders(FileMgr);
   if (Index < TopHeaders.size())
-return const_cast(TopHeaders[Index]);
+return const_cast([Index].getFileEntry());
 
   return nullptr;
 }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2878,8 +2878,8 @@
 {
   auto TopHeaders = Mod->getTopHeaders(PP->getFileManager());
   RecordData::value_type Record[] = {SUBMODULE_TOPHEADER};
-  for (auto *H : TopHeaders) {
-SmallString<128> HeaderName(H->getName());
+  for (auto H : TopHeaders) {
+SmallString<128> HeaderName(H.getName());
 PreparePathForOutput(HeaderName);
 Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, HeaderName);
   }
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -660,7 +660,7 @@
   Explicit).first;
   InferredModuleAllowedBy[Result] = UmbrellaModuleMap;
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 
   // If inferred submodules export everything they import, add a
   // wildcard to the set of exports.
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -353,7 +353,7 @@
   // Add includes for each of these headers.
   for (auto HK : {Module::HK_Normal, Module::HK_Private}) {
 for (Module::Header  : Module->Headers[HK]) {
-  Module->addTopHeader(H.Entry);
+  Module->addTopHeader(*H.Entry);
   // Use the path as specified in the module map file. We'll look for this
   // file relative to the module build directory (the directory containing
   // the module map file) so this will find the same file that we found
@@ -365,7 +365,7 @@
   // Note that Module->PrivateHeaders will not be a TopHeader.
 
   if (Module::Header UmbrellaHeader = Module->getUmbrellaHeader()) {
-Module->addTopHeader(UmbrellaHeader.Entry);
+Module->addTopHeader(*UmbrellaHeader.Entry);
 if (Module->Parent)
   // Include the umbrella header for submodules.
   addHeaderInclude(UmbrellaHeader.PathRelativeToRootModuleDirectory,
@@ -423,7 +423,7 @@
 llvm::sort(Headers, llvm::less_first());
 for (auto  : Headers) {
   // Include this header as part of the umbrella directory.
-  Module->addTopHeader(H.second);
+  Module->addTopHeader(*H.second);
   addHeaderInclude(H.first, Includes, LangOpts, Module->IsExternC);
 }
   }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -269,16 +269,13 @@
   Umbrella.dyn_cast()};
 }
 
-void Module::addTopHeader(const FileEntry *File) {
-  assert(File);
-  TopHeaders.insert(File);
-}
+void Module::addTopHeader(FileEntryRef File) { TopHeaders.insert(File); }
 
-ArrayRef Module::getTopHeaders(FileManager ) {
+ArrayRef Module::getTopHeaders(FileManager ) {
   if (!TopHeaderNames.empty()) {
 for (std::vector::iterator
I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) {
-  if (auto FE = FileMgr.getFile(*I))
+  if (auto FE = FileMgr.getFileRef(*I))
 TopHeaders.insert(*FE);
 }
 TopHeaderNames.clear();
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -189,7 +189,7 @@
   OptionalFileEntryRef ASTFile;
 
   /// The top-level headers associated with this module.
-  

[PATCH] D142690: [DRAFT][libc++] Fixes the Clang modular build.

2023-01-27 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 492828.
Mordante added a comment.

Finalized patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

Files:
  clang/lib/run_the_clang_CI
  libcxx/include/module.modulemap.in


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header 
"__concepts/derived_from.h" }
   module destructible   { private header 
"__concepts/destructible.h" }
   module different_from { private header 
"__concepts/different_from.h" }
-  module equality_comparable{ private header 
"__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header 
"__concepts/invocable.h" }
   module movable{ private header 
"__concepts/movable.h" }
   module predicate  { private header 
"__concepts/predicate.h" }
   module regular{ private header 
"__concepts/regular.h" }
   module relation   { private header 
"__concepts/relation.h" }
-  module same_as{ private header 
"__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header 
"__concepts/semiregular.h" }
   module swappable  { private header 
"__concepts/swappable.h" }
   module totally_ordered{ private header 
"__concepts/totally_ordered.h" }
@@ -979,7 +985,11 @@
   module back_insert_iterator  { private header 
"__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header 
"__iterator/bounded_iter.h" }
   module common_iterator   { private header 
"__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header 
"__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default_sentinel  { private header 
"__iterator/default_sentinel.h" }
@@ -1416,7 +1426,10 @@
 module extent  { private header 
"__type_traits/extent.h" }
 module has_unique_object_representation{ private header 
"__type_traits/has_unique_object_representation.h" }
 module has_virtual_destructor  { private header 
"__type_traits/has_virtual_destructor.h" }
-module integral_constant   { private header 
"__type_traits/integral_constant.h" }
+module integral_constant   {
+  private header "__type_traits/integral_constant.h"
+  export type_traits.common_reference
+}
 module is_abstract { private header 
"__type_traits/is_abstract.h" }
 module is_aggregate{ private header 
"__type_traits/is_aggregate.h" }
 module is_allocator{ private header 
"__type_traits/is_allocator.h" }


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header "__concepts/derived_from.h" }
   module destructible   { private header "__concepts/destructible.h" }
   module different_from { private header "__concepts/different_from.h" }
-  module equality_comparable{ private header "__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header "__concepts/invocable.h" }
   module movable{ private header "__concepts/movable.h" }
   module predicate  { private header "__concepts/predicate.h" }
   module regular{ private header "__concepts/regular.h" }
   module relation   { private header "__concepts/relation.h" }
-  module same_as{ private header "__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ 

[PATCH] D142440: [clangd] Don't show 'auto' type hint when type deduction fails

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

thanks!




Comment at: clang-tools-extra/clangd/InlayHints.cpp:307
+if (auto *AT = D->getType()->getContainedAutoType()) {
+  if (!AT->getDeducedType().isNull() && !D->getType()->isDependentType()) {
 // Our current approach is to place the hint on the variable

nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142440

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


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#4086450 , @stilor wrote:

>>> I posted https://reviews.llvm.org/D142723 to address this.
>>
>> and 63d6b8be6cf248a1a8800d85a11be469c6e2 
>>  should 
>> hopefully resolve it.
>
> Thank you for sorting this out so quickly!

Any time, thank you for raising the issue so quickly!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-27 Thread Alexey Neyman via Phabricator via cfe-commits
stilor added a comment.

>> I posted https://reviews.llvm.org/D142723 to address this.
>
> and 63d6b8be6cf248a1a8800d85a11be469c6e2 
>  should 
> hopefully resolve it.

Thank you for sorting this out so quickly!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D142757: [clang][driver] Do not warn about position of `/clang:-xc` in cl mode

2023-01-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

In CL mode values of `/clang:` arguments end up at the end of
arguments list which makes the warning always emitted.
Just do not emit the warning in cl mode since it was implemented to
match gcc.

Fixes #59307


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142757

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/x-args.c


Index: clang/test/Driver/x-args.c
===
--- clang/test/Driver/x-args.c
+++ clang/test/Driver/x-args.c
@@ -5,3 +5,7 @@
 // RUN: %clang -fsyntax-only -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
 // CHECK: '-x c++' after last input file has no effect
+//
+// RUN: %clang_cl /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | FileCheck 
-check-prefix=CL %s
+// RUN: %clang_cl /WX /clang:-E /clang:-dM %s /clang:-xc 2>&1 | FileCheck 
-check-prefix=CL %s
+// CL-NOT: '-x c' after last input file has no effect
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2572,10 +2572,11 @@
   }
 
   // Warn -x after last input file has no effect
-  {
+  if (!IsCLMode()) {
 Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x);
 Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT);
-if (LastXArg && LastInputArg && LastInputArg->getIndex() < 
LastXArg->getIndex())
+if (LastXArg && LastInputArg &&
+LastInputArg->getIndex() < LastXArg->getIndex())
   Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue();
   }
 


Index: clang/test/Driver/x-args.c
===
--- clang/test/Driver/x-args.c
+++ clang/test/Driver/x-args.c
@@ -5,3 +5,7 @@
 // RUN: %clang -fsyntax-only -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
 // CHECK: '-x c++' after last input file has no effect
+//
+// RUN: %clang_cl /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | FileCheck -check-prefix=CL %s
+// RUN: %clang_cl /WX /clang:-E /clang:-dM %s /clang:-xc 2>&1 | FileCheck -check-prefix=CL %s
+// CL-NOT: '-x c' after last input file has no effect
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2572,10 +2572,11 @@
   }
 
   // Warn -x after last input file has no effect
-  {
+  if (!IsCLMode()) {
 Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x);
 Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT);
-if (LastXArg && LastInputArg && LastInputArg->getIndex() < LastXArg->getIndex())
+if (LastXArg && LastInputArg &&
+LastInputArg->getIndex() < LastXArg->getIndex())
   Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue();
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142596: [RISCV] Bump Zca, Zcd, Zcf version to 1.0.

2023-01-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 492810.
craig.topper added a comment.

Add Zcb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142596

Files:
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -176,11 +176,17 @@
 .attribute arch, "rv32if_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
 
-.attribute arch, "rv32izca0p70"
-# CHECK: attribute  5, "rv32i2p0_zca0p70"
+.attribute arch, "rv32izca1p0"
+# CHECK: attribute  5, "rv32i2p0_zca1p0"
 
-.attribute arch, "rv32izcb0p70"
-# CHECK: attribute  5, "rv32i2p0_zca0p70_zcb0p70"
+.attribute arch, "rv32izcd1p0"
+# CHECK: attribute  5, "rv32i2p0_zcd1p0"
+
+.attribute arch, "rv32izcf1p0"
+# CHECK: attribute  5, "rv32i2p0_zcf1p0"
+
+.attribute arch, "rv32izcb1p0"
+# CHECK: attribute  5, "rv32i2p0_zca1p0_zcb1p0"
 
 .attribute arch, "rv32izawrs1p0"
 # CHECK: attribute  5, "rv32i2p0_zawrs1p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -42,6 +42,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck --check-prefix=RV32SVINVAL %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zca %s -o - | FileCheck --check-prefix=RV32ZCA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefix=RV32ZCB %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefix=RV32ZCD %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefix=RV32ZCF %s
 
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zmmul %s -o - | FileCheck --check-prefix=RV64ZMMUL %s
@@ -89,6 +91,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck --check-prefix=RV64ZTSO %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefix=RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefix=RV64ZCB %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefix=RV64ZCD %s
 
 ; RV32M: .attribute 5, "rv32i2p0_m2p0"
 ; RV32ZMMUL: .attribute 5, "rv32i2p0_zmmul1p0"
@@ -130,8 +133,10 @@
 ; RV32SVNAPOT: .attribute 5, "rv32i2p0_svnapot1p0"
 ; RV32SVPBMT: .attribute 5, "rv32i2p0_svpbmt1p0"
 ; RV32SVINVAL: .attribute 5, "rv32i2p0_svinval1p0"
-; RV32ZCA: .attribute 5, "rv32i2p0_zca0p70"
-; RV32ZCB: .attribute 5, "rv32i2p0_zca0p70_zcb0p70"
+; RV32ZCA: .attribute 5, "rv32i2p0_zca1p0"
+; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
+; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
+; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0"
@@ -177,8 +182,9 @@
 ; RV64XVENTANACONDOPS: .attribute 5, "rv64i2p0_xventanacondops1p0"
 ; RV64XTHEADVDOT: .attribute 5, "rv64i2p0_f2p0_d2p0_v1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_xtheadvdot1p0"
 ; RV64ZTSO: .attribute 5, "rv64i2p0_ztso0p1"
-; RV64ZCA: .attribute 5, "rv64i2p0_zca0p70"
-; RV64ZCB: .attribute 5, "rv64i2p0_zca0p70_zcb0p70"
+; RV64ZCA: .attribute 5, "rv64i2p0_zca1p0"
+; RV64ZCB: .attribute 5, "rv64i2p0_zca1p0_zcb1p0"
+; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -7,7 +7,7 @@
 //===--===//
 ///
 /// This file describes the RISC-V instructions from the 'Zc*' compressed
-/// instruction extensions, version 0.70.4.
+/// instruction extensions, version 1.0.1.
 /// This version is still experimental as the 'Zc*' extensions haven't been
 /// ratified yet.
 ///
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -114,10 +114,10 @@
 static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
 {"zihintntl", RISCVExtensionVersion{0, 2}},
 
-{"zca", RISCVExtensionVersion{0, 70}},
-{"zcb", RISCVExtensionVersion{0, 70}},
-{"zcd", 

[clang] 4f99647 - [LinkerWrapper] Add support for --[no-]whole-archive into the linker wrapper

2023-01-27 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-27T11:30:50-06:00
New Revision: 4f9964738b9c01f16bc962aac68e441377c8c842

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

LOG: [LinkerWrapper] Add support for --[no-]whole-archive into the linker 
wrapper

Summary:
This patch adds support for `--[no-]whole-archive` to the linker
wrapper. This allows us to bypass the symbol resolution logic that is
normally used for static archives. For multi-architecture binaries this
also allows us to build for every single member.

Added: 


Modified: 
clang/test/Driver/linker-wrapper-libs.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper-libs.c 
b/clang/test/Driver/linker-wrapper-libs.c
index a97420c34162c..65d4c2546ba9c 100644
--- a/clang/test/Driver/linker-wrapper-libs.c
+++ b/clang/test/Driver/linker-wrapper-libs.c
@@ -132,3 +132,28 @@ int bar() { return weak; }
 // LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img 
--target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
 // LIBRARY-GLOBAL-DEFINED-NOT: {{.*}}gfx1030{{.*}}.o
 // LIBRARY-GLOBAL-DEFINED: clang{{.*}} -o {{.*}}.img 
--target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.s {{.*}}.o
+
+//
+// Check that we can use --[no-]whole-archive to control extraction.
+//
+// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -DGLOBAL -o 
%t.nvptx.global.bc
+// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -DGLOBAL -o 
%t.amdgpu.global.bc
+// RUN: clang-offload-packager -o %t-lib.out \
+// RUN:   
--image=file=%t.nvptx.global.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
+// RUN:   
--image=file=%t.nvptx.global.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_52
 \
+// RUN:   
--image=file=%t.amdgpu.global.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
 \
+// RUN:   
--image=file=%t.amdgpu.global.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t-lib.out
+// RUN: llvm-ar rcs %t.a %t.o
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   
--image=file=%t.elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx1030
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o --whole-archive %t.a -o a.out 2>&1 
\
+// RUN: | FileCheck %s --check-prefix=LIBRARY-WHOLE-ARCHIVE
+
+// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx1030 {{.*}}.o {{.*}}.o
+// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img 
--target=nvptx64-nvidia-cuda -march=sm_52 {{.*}}.s
+// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx90a {{.*}}.o
+// LIBRARY-WHOLE-ARCHIVE: clang{{.*}} -o {{.*}}.img 
--target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.s {{.*}}.o

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index d479b5a6cccef..3c92d34571044 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1267,7 +1267,15 @@ Expected> getDeviceInput(const 
ArgList ) {
   // Try to extract device code from the linker input files.
   SmallVector InputFiles;
   DenseMap> Syms;
-  for (const opt::Arg *Arg : Args.filtered(OPT_INPUT, OPT_library)) {
+  bool WholeArchive = false;
+  for (const opt::Arg *Arg : Args.filtered(
+   OPT_INPUT, OPT_library, OPT_whole_archive, OPT_no_whole_archive)) {
+if (Arg->getOption().matches(OPT_whole_archive) ||
+Arg->getOption().matches(OPT_no_whole_archive)) {
+  WholeArchive = Arg->getOption().matches(OPT_whole_archive);
+  continue;
+}
+
 std::optional Filename =
 Arg->getOption().matches(OPT_library)
 ? searchLibrary(Arg->getValue(), Root, LibraryPaths)
@@ -1306,7 +1314,7 @@ Expected> getDeviceInput(const 
ArgList ) {
 
 // If we don't have an object file for this architecture do not
 // extract.
-if (IsArchive && !Syms.count(Binary))
+if (IsArchive && !WholeArchive && !Syms.count(Binary))
   continue;
 
 Expected ExtractOrErr =
@@ -1314,9 +1322,9 @@ Expected> getDeviceInput(const 
ArgList ) {
 if (!ExtractOrErr)
   return ExtractOrErr.takeError();
 
-Extracted = IsArchive && *ExtractOrErr;
+Extracted = IsArchive && !WholeArchive && *ExtractOrErr;
 
-if (!IsArchive || 

[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:452-454
+
 - Now diagnoses use of a member access expression or array subscript expression
   within ``__builtin_offsetof`` and ``offsetof`` as being a Clang extension.

Assuming https://github.com/llvm/llvm-project/issues/60337 gets ported to the 
16.0 branch, this bullet can be removed entirely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D142724: [clang] use FileEntryRef for SUBMODULE_TOPHEADER

2023-01-27 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Basic/Module.cpp:273
+void Module::addTopHeader(OptionalFileEntryRef File) {
   assert(File);
+  TopHeaders.insert(*File);

If we assert that `File` is not empty right away, why take 
`OptionalFileEntryRef` instead of `FileEntryRef`?



Comment at: clang/lib/Lex/ModuleMap.cpp:663
   Result->IsInferred = true;
-  Result->addTopHeader(File);
+  Result->addTopHeader(File->getLastRef());
 

How much work would be to refactor `File` to be `FileEntryRef`? Would be good 
if we didn't need to resort to `getLastRef()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142724

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


[PATCH] D142744: Re-analyze functions as top-level

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley added a comment.

This change is admittedly a hack. It might be better to check the function 
parameter types, or maybe the list of exceptions in this function is now so 
long that it no longer serves any purpose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142744

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


[PATCH] D138122: Lift EHPersonalities from Analysis to IR (NFC)

2023-01-27 Thread Stefan Gränitz 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 rG3b387d10707d: Lift EHPersonalities from Analysis to IR (NFC) 
(authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138122

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/include/llvm/Analysis/EHPersonalities.h
  llvm/include/llvm/Analysis/MustExecute.h
  llvm/include/llvm/CodeGen/MachineFunction.h
  llvm/include/llvm/IR/EHPersonalities.h
  llvm/lib/Analysis/CMakeLists.txt
  llvm/lib/Analysis/EHPersonalities.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/DwarfEHPrepare.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/EHPersonalities.cpp
  llvm/lib/Target/M68k/M68kCollapseMOVEMPass.cpp
  llvm/lib/Target/M68k/M68kExpandPseudo.cpp
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86WinEHState.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARC.h
  llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
  llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
  llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
@@ -34,6 +34,7 @@
 "DiagnosticInfo.cpp",
 "DiagnosticPrinter.cpp",
 "Dominators.cpp",
+"EHPersonalities.cpp",
 "FPEnv.cpp",
 "Function.cpp",
 "GCStrategy.cpp",
Index: llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
@@ -49,7 +49,6 @@
 "DomPrinter.cpp",
 "DomTreeUpdater.cpp",
 "DominanceFrontier.cpp",
-"EHPersonalities.cpp",
 "FunctionPropertiesAnalysis.cpp",
 "GlobalsModRef.cpp",
 "GuardUtils.cpp",
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -25,7 +25,6 @@
 #include "llvm/Analysis/AssumeBundleQueries.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/DomTreeUpdater.h"
-#include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/MemoryBuiltins.h"
 #include "llvm/Analysis/MemorySSAUpdater.h"
@@ -47,6 +46,7 @@
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/IR/EHPersonalities.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GetElementPtrTypeIterator.h"
 #include "llvm/IR/GlobalObject.h"
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
===
--- llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -23,7 +23,6 @@
 #include "llvm/Analysis/BlockFrequencyInfo.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Analysis/CaptureTracking.h"
-#include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/MemoryProfileInfo.h"
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
@@ -42,6 +41,7 @@
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/IR/EHPersonalities.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
Index: llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
===
--- llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
+++ llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
@@ -13,7 +13,7 @@
 
 #include "llvm/Transforms/Utils/EscapeEnumerator.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/Analysis/EHPersonalities.h"
+#include "llvm/IR/EHPersonalities.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Transforms/Utils/Local.h"
 
Index: llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp

[clang] 3b387d1 - Lift EHPersonalities from Analysis to IR (NFC)

2023-01-27 Thread Stefan Gränitz via cfe-commits

Author: Stefan Gränitz
Date: 2023-01-27T18:05:13+01:00
New Revision: 3b387d10707d3ec5f4786812cc055c89c3eaa161

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

LOG: Lift EHPersonalities from Analysis to IR (NFC)

Computing EH-related information was only relevant for analysis passes so far. 
Lifting it to IR will allow the IR Verifier to calculate EH funclet coloring 
and validate funclet operand bundles in a follow-up step.

Reviewed By: rnk, compnerd

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

Added: 
llvm/include/llvm/IR/EHPersonalities.h
llvm/lib/IR/EHPersonalities.cpp

Modified: 
clang/docs/tools/clang-formatted-files.txt
llvm/include/llvm/Analysis/MustExecute.h
llvm/include/llvm/CodeGen/MachineFunction.h
llvm/lib/Analysis/CMakeLists.txt
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/DwarfEHPrepare.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/lib/CodeGen/StackProtector.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/IR/CMakeLists.txt
llvm/lib/Target/M68k/M68kCollapseMOVEMPass.cpp
llvm/lib/Target/M68k/M68kExpandPseudo.cpp
llvm/lib/Target/X86/X86ExpandPseudo.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86WinEHState.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.h
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Removed: 
llvm/include/llvm/Analysis/EHPersonalities.h
llvm/lib/Analysis/EHPersonalities.cpp



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index 42798e5183a82..cbac961982e6a 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -4991,7 +4991,6 @@ llvm/include/llvm/Analysis/Delinearization.h
 llvm/include/llvm/Analysis/DependenceGraphBuilder.h
 llvm/include/llvm/Analysis/DivergenceAnalysis.h
 llvm/include/llvm/Analysis/DomTreeUpdater.h
-llvm/include/llvm/Analysis/EHPersonalities.h
 llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
 llvm/include/llvm/Analysis/IndirectCallPromotionAnalysis.h
 llvm/include/llvm/Analysis/IndirectCallVisitor.h
@@ -5330,6 +5329,7 @@ llvm/include/llvm/IR/DebugInfo.h
 llvm/include/llvm/IR/DebugInfoMetadata.h
 llvm/include/llvm/IR/DiagnosticHandler.h
 llvm/include/llvm/IR/DiagnosticPrinter.h
+llvm/include/llvm/IR/EHPersonalities.h
 llvm/include/llvm/IR/GlobalIFunc.h
 llvm/include/llvm/IR/GlobalObject.h
 llvm/include/llvm/IR/GVMaterializer.h

diff  --git a/llvm/include/llvm/Analysis/MustExecute.h 
b/llvm/include/llvm/Analysis/MustExecute.h
index b83705cb61115..9c97bd1725ac2 100644
--- a/llvm/include/llvm/Analysis/MustExecute.h
+++ b/llvm/include/llvm/Analysis/MustExecute.h
@@ -25,8 +25,8 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/InstructionPrecedenceTracking.h"
+#include "llvm/IR/EHPersonalities.h"
 #include "llvm/IR/PassManager.h"
 
 namespace llvm {

diff  --git a/llvm/include/llvm/CodeGen/MachineFunction.h 
b/llvm/include/llvm/CodeGen/MachineFunction.h
index 220d18d15821c..b83ccc32e438a 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -24,10 +24,10 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/ilist.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineMemOperand.h"
+#include "llvm/IR/EHPersonalities.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ArrayRecycler.h"
 #include "llvm/Support/AtomicOrdering.h"

diff  --git a/llvm/include/llvm/Analysis/EHPersonalities.h 
b/llvm/include/llvm/IR/EHPersonalities.h
similarity index 96%
rename from llvm/include/llvm/Analysis/EHPersonalities.h
rename to llvm/include/llvm/IR/EHPersonalities.h
index 660d431bb063e..bd768440bfb9a 100644
--- a/llvm/include/llvm/Analysis/EHPersonalities.h
+++ 

[PATCH] D142744: Re-analyze functions as top-level

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If a function with a _Nullable parameter has at least
one caller, the checker behaves as though no other
parameter value is possible. This is because the static
analyzer doesn't re-analyse functions as top level
(with the exception of C++ copy and move operators, and
ObjC methods).

Fixed by modifying shouldSkipFunction to return false.

After this change, Clang-tidy even emits different
warnings for the same line of code, if appropriate:
"Nullable pointer is dereferenced" for a (simulated)
top-level call and "Dereference of null pointer"
for a call to the same function with a known null value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142744

Files:
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp


Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -408,6 +408,12 @@
   //   Count naming convention errors more aggressively.
   if (isa(D))
 return false;
+
+  // If a function with a _Nullable parameter has at least one caller, the
+  // checker behaves as though no other parameter value is possible. This is
+  // because the static analyzer doesn't re-analyse functions as top level.
+  return false;
+
   // We also want to reanalyze all C++ copy and move assignment operators to
   // separately check the two cases where 'this' aliases with the parameter and
   // where it may not. (cplusplus.SelfAssignmentChecker)


Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -408,6 +408,12 @@
   //   Count naming convention errors more aggressively.
   if (isa(D))
 return false;
+
+  // If a function with a _Nullable parameter has at least one caller, the
+  // checker behaves as though no other parameter value is possible. This is
+  // because the static analyzer doesn't re-analyse functions as top level.
+  return false;
+
   // We also want to reanalyze all C++ copy and move assignment operators to
   // separately check the two cases where 'this' aliases with the parameter and
   // where it may not. (cplusplus.SelfAssignmentChecker)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142743: Fix nullability checking of top-level functions

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The existing nullability checker is so limited
when applied to top-level functions that a casual
observer might assume it doesn't work at all:

void test1(int *_Nullable x)
{

  *x = 5; // no warning!

}

Added a NullabilityChecker::checkBeginFunction method
to honour any _Nullable annotation of parameters in
a top-level call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142743

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -26,12 +26,13 @@
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 
+#include "clang/Analysis/AnyCall.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
@@ -78,10 +79,11 @@
 };
 
 class NullabilityChecker
-: public Checker,
- check::PostCall, check::PostStmt,
- check::PostObjCMessage, check::DeadSymbols, eval::Assume,
- check::Location, check::Event> {
+: public Checker, check::PostCall,
+ check::PostStmt, check::PostObjCMessage,
+ check::DeadSymbols, eval::Assume, check::Location,
+ check::Event> {
 
 public:
   // If true, the checker will not diagnose nullabilility issues for calls
@@ -104,6 +106,7 @@
  CheckerContext ) const;
   ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
  bool Assumption) const;
+  void checkBeginFunction(CheckerContext ) const;
 
   void printState(raw_ostream , ProgramStateRef State, const char *NL,
   const char *Sep) const override;
@@ -1344,6 +1347,59 @@
   }
 }
 
+/// We want to trust developer annotations and consider all 'nullable'
+/// parameters as potentially null. Each marked parameter will get a
+/// corresponding constraint.
+///
+/// \code
+///   void foo(int *_Nullable x) {
+/// // . . .
+/// *x = 42;// we want to consider this as an error...
+/// // . . .
+///   }
+/// \endcode
+void NullabilityChecker::checkBeginFunction(CheckerContext ) const {
+  // Planned assumption makes sense only for top-level functions.
+  if (!Context.inTopFrame())
+return;
+
+  const LocationContext *LocContext = Context.getLocationContext();
+
+  const Decl *FD = LocContext->getDecl();
+  // AnyCall helps us here to avoid checking for FunctionDecl and ObjCMethodDecl
+  // separately and aggregates interfaces of these classes.
+  auto AbstractCall = AnyCall::forDecl(FD);
+  if (!AbstractCall)
+return;
+
+  ProgramStateRef State = Context.getState();
+
+  for (const ParmVarDecl *Parameter : AbstractCall->parameters()) {
+Nullability RequiredNullability =
+getNullabilityAnnotation(Parameter->getType());
+
+if (RequiredNullability != Nullability::Nullable)
+  continue;
+
+Loc ParameterLoc = State->getLValue(Parameter, LocContext);
+// We never consider top-level function parameters undefined.
+auto StoredVal =
+State->getSVal(ParameterLoc).castAs();
+
+const MemRegion *Region = getTrackRegion(StoredVal);
+if (!Region)
+  continue;
+
+const Stmt *NullabilitySource = Parameter->getBody();
+if (ProgramStateRef NewState = State->set(
+Region, NullabilityState(RequiredNullability, NullabilitySource))) {
+  State = NewState;
+}
+  }
+
+  Context.addTransition(State);
+}
+
 void ento::registerNullabilityBase(CheckerManager ) {
   mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142673: [clang-tidy] Refactor HeaderGuardCheck to add HeaderGuardStyle

2023-01-27 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware added a comment.

In D142673#4086018 , @carlosgalvezp 
wrote:

> Note: I do not have possibility to add code comments - is there some too 
> strict permissions set for this patch? It has not happened to other patches.

I accidentally set the permissions too strict, I've fixed it here and on all my 
other diffs.

> I think the design choice in clang-tidy is that checks from different modules 
> should not depend on each other like this, that's why a common `utils` folder 
> exists.
> What is the difference between `llvm-header-guard` and 
> `readability-header-guard`? Could one be the alias of the other, possibly 
> with some added configuration options?

See the discussion in D142123 . We decided it 
would be best to have a single `readability-header-guard` which can select one 
of several different styles. `llvm-header-guard` temporarily exists as a 
deprecated alias to `readability-header-guard` with the `llvm` style selected, 
and will be removed in a future version.


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

https://reviews.llvm.org/D142673

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


[PATCH] D142742: Generate ImplicitNullDerefEvent from CallAndMessageChecker

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Without this change, the following code does
not generate "warning: Nullable pointer is dereferenced":

void test(void (*_Nullable fn)(void))
{

  fn();

}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142742

Files:
  clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -32,7 +32,7 @@
 
 class CallAndMessageChecker
 : public Checker {
+ check::PreCall, EventDispatcher> {
   mutable std::unique_ptr BT_call_null;
   mutable std::unique_ptr BT_call_undef;
   mutable std::unique_ptr BT_cxx_call_null;
@@ -389,16 +389,30 @@
   ProgramStateRef StNonNull, StNull;
   std::tie(StNonNull, StNull) = 
State->assume(L.castAs());
 
-  if (StNull && !StNonNull) {
-if (!ChecksEnabled[CK_FunctionPointer]) {
-  C.addSink(StNull);
+  if (StNull) {
+if (!StNonNull) {
+  if (!ChecksEnabled[CK_FunctionPointer]) {
+C.addSink(StNull);
+return nullptr;
+  }
+  if (!BT_call_null)
+BT_call_null.reset(new BuiltinBug(
+OriginalName,
+"Called function pointer is null (null dereference)"));
+  emitBadCall(BT_call_null.get(), C, Callee);
   return nullptr;
 }
-if (!BT_call_null)
-  BT_call_null.reset(new BuiltinBug(
-  OriginalName, "Called function pointer is null (null dereference)"));
-emitBadCall(BT_call_null.get(), C, Callee);
-return nullptr;
+
+// Otherwise, we have the case where the location could either be
+// null or not-null.  Record the error node as an "implicit" null
+// dereference.
+if (ExplodedNode *N = C.generateSink(StNull, C.getPredecessor())) {
+  printf("\nimplicit null dereference\n");
+  ImplicitNullDerefEvent event = {L, /*isLoad=*/true, N,
+  (),
+  /*IsDirectDereference=*/true};
+  dispatchEvent(event);
+}
   }
 
   return StNonNull;


Index: clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -32,7 +32,7 @@
 
 class CallAndMessageChecker
 : public Checker {
+ check::PreCall, EventDispatcher> {
   mutable std::unique_ptr BT_call_null;
   mutable std::unique_ptr BT_call_undef;
   mutable std::unique_ptr BT_cxx_call_null;
@@ -389,16 +389,30 @@
   ProgramStateRef StNonNull, StNull;
   std::tie(StNonNull, StNull) = State->assume(L.castAs());
 
-  if (StNull && !StNonNull) {
-if (!ChecksEnabled[CK_FunctionPointer]) {
-  C.addSink(StNull);
+  if (StNull) {
+if (!StNonNull) {
+  if (!ChecksEnabled[CK_FunctionPointer]) {
+C.addSink(StNull);
+return nullptr;
+  }
+  if (!BT_call_null)
+BT_call_null.reset(new BuiltinBug(
+OriginalName,
+"Called function pointer is null (null dereference)"));
+  emitBadCall(BT_call_null.get(), C, Callee);
   return nullptr;
 }
-if (!BT_call_null)
-  BT_call_null.reset(new BuiltinBug(
-  OriginalName, "Called function pointer is null (null dereference)"));
-emitBadCall(BT_call_null.get(), C, Callee);
-return nullptr;
+
+// Otherwise, we have the case where the location could either be
+// null or not-null.  Record the error node as an "implicit" null
+// dereference.
+if (ExplodedNode *N = C.generateSink(StNull, C.getPredecessor())) {
+  printf("\nimplicit null dereference\n");
+  ImplicitNullDerefEvent event = {L, /*isLoad=*/true, N,
+  (),
+  /*IsDirectDereference=*/true};
+  dispatchEvent(event);
+}
   }
 
   return StNonNull;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142741: Fix ProgramState::isNull for non-region symbols

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This method was good at telling that a pointer
definitely is null, but bad at telling that it
definitely isn't null. For example, it returned
'not sure' in the following trivial case:

int main(void)
{

  int p;
  int _Optional *q = 
  if (q) {
*q = 0; // spurious warning
  }
  return 0;

}

When analyzing the above program, the statement
if (q) does not create a constraint such as range
[1, 18446744073709551615] for use in future
inferences about the value of q. The reason is
that SimpleConstraintManager::assumeInternal
replaces the condition specified by its caller with
1 if invoked on a symbol (such as q) that lacks an
associated memory region. Constraints are not
recorded for integer constants.

Added fallback in ProgramState::isNull to do the same
conversion and check for a zero result if invoked
on an expression which is not a constant and does
not wrap a symbol (or wraps a symbol that lacks a
memory region).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142741

Files:
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -386,8 +386,24 @@
 return false;
 
   SymbolRef Sym = V.getAsSymbol(/* IncludeBaseRegion */ true);
-  if (!Sym)
+  if (!Sym) {
+if (Optional LV = V.getAs()) {
+  SValBuilder  = stateMgr->getSValBuilder();
+  QualType T;
+  const MemRegion *MR = LV->getAsRegion();
+  if (const TypedRegion *TR = dyn_cast_or_null(MR))
+T = TR->getLocationType();
+  else
+T = SVB.getContext().VoidPtrTy;
+
+  V = SVB.evalCast(*LV, SVB.getContext().BoolTy, T);
+  auto const integer = V.getAsInteger();
+  if (integer) {
+return integer->isZero();
+  }
+}
 return ConditionTruthVal();
+  }
 
   return getStateManager().ConstraintMgr->isNull(this, Sym);
 }


Index: clang/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- clang/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ clang/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -386,8 +386,24 @@
 return false;
 
   SymbolRef Sym = V.getAsSymbol(/* IncludeBaseRegion */ true);
-  if (!Sym)
+  if (!Sym) {
+if (Optional LV = V.getAs()) {
+  SValBuilder  = stateMgr->getSValBuilder();
+  QualType T;
+  const MemRegion *MR = LV->getAsRegion();
+  if (const TypedRegion *TR = dyn_cast_or_null(MR))
+T = TR->getLocationType();
+  else
+T = SVB.getContext().VoidPtrTy;
+
+  V = SVB.evalCast(*LV, SVB.getContext().BoolTy, T);
+  auto const integer = V.getAsInteger();
+  if (integer) {
+return integer->isZero();
+  }
+}
 return ConditionTruthVal();
+  }
 
   return getStateManager().ConstraintMgr->isNull(this, Sym);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142740: [WIP] [WebAssembly] Enable MemorySanitizer for emscripten

2023-01-27 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: Enna1, pmatos, asb, wingo, ecnelises, sunfish, 
hiraditya, jgravelle-google, dschuff.
Herald added a project: All.
sbc100 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, aheejin.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142740

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -466,6 +466,22 @@
 0x1000, // OriginBase
 };
 
+// wasm32 Emscripten
+static const MemoryMapParams Emscripten_wasm32_MemoryMapParams = {
+0x8000, // AndMask
+0,  // XorMask (not used)
+0,  // ShadowBase (not used)
+0x4000, // OriginBase
+};
+
+// wasm64 Emscripten
+static const MemoryMapParams Emscripten_wasm64_MemoryMapParams = {
+0,  // AndMask (not used)
+0x5000, // XorMask
+0,  // ShadowBase (not used)
+0x1000, // OriginBase
+};
+
 static const PlatformMemoryMapParams Linux_X86_MemoryMapParams = {
 _I386_MemoryMapParams,
 _X86_64_MemoryMapParams,
@@ -506,6 +522,11 @@
 _X86_64_MemoryMapParams,
 };
 
+static const PlatformMemoryMapParams Emscripten_wasm_MemoryMapParams = {
+_wasm32_MemoryMapParams,
+_wasm64_MemoryMapParams,
+};
+
 namespace {
 
 /// Instrument functions of a module to detect uninitialized reads.
@@ -990,6 +1011,18 @@
 report_fatal_error("unsupported architecture");
   }
   break;
+case Triple::Emscripten:
+  switch (TargetTriple.getArch()) {
+  case Triple::wasm32:
+MapParams = Emscripten_wasm_MemoryMapParams.bits32;
+break;
+  case Triple::wasm64:
+MapParams = Emscripten_wasm_MemoryMapParams.bits64;
+break;
+  default:
+report_fatal_error("unsupported architecture");
+  }
+  break;
 default:
   report_fatal_error("unsupported operating system");
 }
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -457,7 +457,10 @@
 SanitizerMask WebAssembly::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (getTriple().isOSEmscripten()) {
-Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address;
+Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Leak;
+Res |= SanitizerKind::Address;
+Res |= SanitizerKind::Memory;
   }
   return Res;
 }


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -466,6 +466,22 @@
 0x1000, // OriginBase
 };
 
+// wasm32 Emscripten
+static const MemoryMapParams Emscripten_wasm32_MemoryMapParams = {
+0x8000, // AndMask
+0,  // XorMask (not used)
+0,  // ShadowBase (not used)
+0x4000, // OriginBase
+};
+
+// wasm64 Emscripten
+static const MemoryMapParams Emscripten_wasm64_MemoryMapParams = {
+0,  // AndMask (not used)
+0x5000, // XorMask
+0,  // ShadowBase (not used)
+0x1000, // OriginBase
+};
+
 static const PlatformMemoryMapParams Linux_X86_MemoryMapParams = {
 _I386_MemoryMapParams,
 _X86_64_MemoryMapParams,
@@ -506,6 +522,11 @@
 _X86_64_MemoryMapParams,
 };
 
+static const PlatformMemoryMapParams Emscripten_wasm_MemoryMapParams = {
+_wasm32_MemoryMapParams,
+_wasm64_MemoryMapParams,
+};
+
 namespace {
 
 /// Instrument functions of a module to detect uninitialized reads.
@@ -990,6 +1011,18 @@
 report_fatal_error("unsupported architecture");
   }
   break;
+case Triple::Emscripten:
+  switch (TargetTriple.getArch()) {
+  case Triple::wasm32:
+MapParams = Emscripten_wasm_MemoryMapParams.bits32;
+break;
+  case Triple::wasm64:
+MapParams = Emscripten_wasm_MemoryMapParams.bits64;
+break;
+  default:
+report_fatal_error("unsupported architecture");
+  }
+  break;
 default:
   report_fatal_error("unsupported operating system");
 }
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -457,7 +457,10 @@
 SanitizerMask 

[PATCH] D142739: Standalone checker for use of _Optional qualifier

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This checker tries to find violations in use of
pointers to _Optional objects which cannot be
detected by the type system alone. This requires
detection of null pointer dereferences at the
expression level, rather than at the level of
simulated memory accesses (which is already
implemented by other checkers).

Such expressions include those which implicitly
remove the _Optional qualifier from pointer
targets without actually accessing the pointed-to
object.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142739

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/OptionalityChecker.cpp
  llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn
@@ -97,6 +97,7 @@
 "ObjCSelfInitChecker.cpp",
 "ObjCSuperDeallocChecker.cpp",
 "ObjCUnusedIVarsChecker.cpp",
+"OptionalityChecker.cpp",
 "PaddingChecker.cpp",
 "PointerArithChecker.cpp",
 "PointerIterationChecker.cpp",
Index: clang/lib/StaticAnalyzer/Checkers/OptionalityChecker.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/OptionalityChecker.cpp
@@ -0,0 +1,138 @@
+//===-- OptionalityChecker.cpp - Optionality checker --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This checker tries to find violations in use of pointers to _Optional
+// objects which cannot be detected by the type system alone. This requires
+// detection of null pointer dereferences at the expression level, rather than
+// at the level of simulated memory accesses (which is already implemented by
+// other checkers).
+//
+// Such expressions include those which implicitly remove the _Optional
+// qualifier from pointer targets without actually accessing the pointed-to
+// object.
+//
+//===--===//
+
+#include "Iterator.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class OptionalityChecker
+: public Checker<
+  check::PreStmt, check::PreStmt,
+  check::PreStmt, check::PreStmt> {
+
+  void verifyAccess(CheckerContext , const Expr *E) const;
+
+public:
+  void checkPreStmt(const UnaryOperator *UO, CheckerContext ) const;
+  void checkPreStmt(const BinaryOperator *BO, CheckerContext ) const;
+  void checkPreStmt(const ArraySubscriptExpr *ASE, CheckerContext ) const;
+  void checkPreStmt(const MemberExpr *ME, CheckerContext ) const;
+
+  CheckerNameRef CheckName;
+  mutable std::unique_ptr BT;
+
+  const std::unique_ptr () const {
+if (!BT)
+  BT.reset(new BugType(CheckName, "Optionality", categories::MemoryError));
+return BT;
+  }
+
+private:
+  void reportBug(StringRef Msg, ExplodedNode *N, BugReporter ) const {
+const std::unique_ptr  = getBugType();
+auto R = std::make_unique(*BT, Msg, N);
+BR.emitReport(std::move(R));
+  }
+};
+
+} // end anonymous namespace
+
+void OptionalityChecker::checkPreStmt(const UnaryOperator *UO,
+  CheckerContext ) const {
+  if (isa(UO->getSubExpr()))
+return;
+
+  UnaryOperatorKind OK = UO->getOpcode();
+
+  if (clang::ento::iterator::isAccessOperator(OK)) {
+verifyAccess(C, UO->getSubExpr());
+  }
+}
+
+void OptionalityChecker::checkPreStmt(const BinaryOperator *BO,
+  CheckerContext ) const {
+  BinaryOperatorKind OK = BO->getOpcode();
+
+  if (clang::ento::iterator::isAccessOperator(OK)) {
+verifyAccess(C, BO->getLHS());
+  }
+}
+
+void OptionalityChecker::checkPreStmt(const ArraySubscriptExpr *ASE,
+

[PATCH] D142565: [clang-tidy] Fix warning in portability-simd-intrinsics

2023-01-27 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142565

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


[PATCH] D142738: Warn if _Optional used at top-level of decl

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Parameter declarations using [] syntax can be
written more naturally using an _Optional
qualifier than using Clang's _Nullable
annotation, e.g.

void myfunc(_Optional const char s[]);
// s may be a null pointer

With the above exception, it isn't useful to
declare a non-pointed-to object as _Optional
(although so-qualified types exist during
expression evaluation). Such declarations are
therefore disallowed, like equivalent abuse of
the restrict qualifier, to avoid confusion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142738

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5807,6 +5807,16 @@
 }
   }
 
+  // Types other than those of a pointed-to object or pointed-to incomplete 
type
+  // shall not be _Optional-qualified in a declaration.
+  if (T.isOptionalQualified() && !IsTypedefName &&
+  (!T->isArrayType() || !D.isPrototypeContext())) {
+S.Diag(D.getDeclSpec().getOptionalSpecLoc(),
+   diag::err_typecheck_invalid_optional_not_pointee)
+<< T;
+Context.getNonOptionalType(T);
+  }
+
   // Apply any undistributed attributes from the declaration or declarator.
   ParsedAttributesView NonSlidingAttrs;
   for (ParsedAttr  : D.getDeclarationAttributes()) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5088,6 +5088,13 @@
   Diag(DS.getRestrictSpecLoc(),
diag::err_typecheck_invalid_restrict_not_pointer_noarg)
<< DS.getSourceRange();
+
+// Types other than those of a pointed-to object or pointed-to incomplete
+// type shall not be _Optional-qualified in a declaration.
+if (TypeQuals & DeclSpec::TQ_optional)
+  Diag(DS.getOptionalSpecLoc(),
+   diag::err_typecheck_invalid_optional_not_pointee_noarg)
+  << DS.getSourceRange();
   }
 
   if (DS.isInlineSpecified())
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5930,6 +5930,10 @@
   "restrict requires a pointer or reference">;
 def err_typecheck_invalid_restrict_invalid_pointee : Error<
   "pointer to function type %0 may not be 'restrict' qualified">;
+def err_typecheck_invalid_optional_not_pointee : Error<
+  "_Optional is only valid on a pointed-to object or incomplete type (%0 is 
invalid)">;
+def err_typecheck_invalid_optional_not_pointee_noarg : Error<
+  "_Optional is only valid on a pointed-to object or incomplete type">;
 def ext_typecheck_zero_array_size : Extension<
   "zero size arrays are an extension">, InGroup;
 def err_typecheck_zero_array_size : Error<


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5807,6 +5807,16 @@
 }
   }
 
+  // Types other than those of a pointed-to object or pointed-to incomplete type
+  // shall not be _Optional-qualified in a declaration.
+  if (T.isOptionalQualified() && !IsTypedefName &&
+  (!T->isArrayType() || !D.isPrototypeContext())) {
+S.Diag(D.getDeclSpec().getOptionalSpecLoc(),
+   diag::err_typecheck_invalid_optional_not_pointee)
+<< T;
+Context.getNonOptionalType(T);
+  }
+
   // Apply any undistributed attributes from the declaration or declarator.
   ParsedAttributesView NonSlidingAttrs;
   for (ParsedAttr  : D.getDeclarationAttributes()) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -5088,6 +5088,13 @@
   Diag(DS.getRestrictSpecLoc(),
diag::err_typecheck_invalid_restrict_not_pointer_noarg)
<< DS.getSourceRange();
+
+// Types other than those of a pointed-to object or pointed-to incomplete
+// type shall not be _Optional-qualified in a declaration.
+if (TypeQuals & DeclSpec::TQ_optional)
+  Diag(DS.getOptionalSpecLoc(),
+   diag::err_typecheck_invalid_optional_not_pointee_noarg)
+  << DS.getSourceRange();
   }
 
   if (DS.isInlineSpecified())
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5930,6 +5930,10 @@
   "restrict requires a pointer or 

[PATCH] D136886: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I have a fix for the AArch64 problems in test `ImportCorrectTemplatedDecl`, 
dcl-58-cpp, and the "Declaration not emitted!" assertion. I can not find at 
which tests the `error: reference to 'std' is ambiguous` appears. Probably the 
AArch64 (and Arm) tests could be run again with the current fixes applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136886

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


[PATCH] D142673: [clang-tidy] Refactor HeaderGuardCheck to add HeaderGuardStyle

2023-01-27 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Also, in general the design choice is that checks should be independent and 
authors should not need to care about whether they conflict with other checks. 
In this particular case, if both checks are providing different results, users 
should choose one and disable the other. Header guard style is a purely 
stylistic matter, so it's no surprise different checks will lead to different 
results.


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

https://reviews.llvm.org/D142673

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


[PATCH] D142737: Updated getNullabilityAnnotation for checkers

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: steakhal, martong, JDevlieghere.
Herald added a reviewer: NoQ.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

NullabilityChecker and TrustNonnullChecker use
a pre-existing helper function,
getNullabilityAnnotation() to get a Nullability
value from a QualType.

That function is now updated to return
Nullability::Nullable if the given type is a
pointer to an _Optional-qualified type. The
purpose is to allow declarations such as

_Optional int *x;

to be treated (for static analysis purposes) as
equivalent to

int *_Nullable x;

thereby removing one barrier to adoption of the
_Optional type qualifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142737

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
  clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp


Index: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
@@ -100,7 +100,21 @@
   return std::make_pair(VD, RHS);
 }
 
+bool pointeeIsOptional(QualType Type) {
+  if (const PointerType *PT = Type->getAs()) {
+auto PointeeType = PT->getPointeeType();
+if (PointeeType.isOptionalQualified()) {
+  return true;
+}
+  }
+  return false;
+}
+
 Nullability getNullabilityAnnotation(QualType Type) {
+  if (pointeeIsOptional(Type)) {
+return Nullability::Nullable;
+  }
+
   const auto *AttrType = Type->getAs();
   if (!AttrType)
 return Nullability::Unspecified;
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
@@ -62,6 +62,10 @@
   Nonnull
 };
 
+/// Find out whether the given type is a pointer to an optional value.
+/// If true then the pointer value should be treated as nullable.
+bool pointeeIsOptional(QualType Type);
+
 /// Get nullability annotation for a given type.
 Nullability getNullabilityAnnotation(QualType Type);
 


Index: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp
@@ -100,7 +100,21 @@
   return std::make_pair(VD, RHS);
 }
 
+bool pointeeIsOptional(QualType Type) {
+  if (const PointerType *PT = Type->getAs()) {
+auto PointeeType = PT->getPointeeType();
+if (PointeeType.isOptionalQualified()) {
+  return true;
+}
+  }
+  return false;
+}
+
 Nullability getNullabilityAnnotation(QualType Type) {
+  if (pointeeIsOptional(Type)) {
+return Nullability::Nullable;
+  }
+
   const auto *AttrType = Type->getAs();
   if (!AttrType)
 return Nullability::Unspecified;
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
@@ -62,6 +62,10 @@
   Nonnull
 };
 
+/// Find out whether the given type is a pointer to an optional value.
+/// If true then the pointer value should be treated as nullable.
+bool pointeeIsOptional(QualType Type);
+
 /// Get nullability annotation for a given type.
 Nullability getNullabilityAnnotation(QualType Type);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7d4ce70 - [LinkerWrapper][NFC] Remove unused options

2023-01-27 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-01-27T10:49:31-06:00
New Revision: 7d4ce7050505baadd0d40c30d0726a136a64c717

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

LOG: [LinkerWrapper][NFC] Remove unused options

Summary:
These options are no longer used, we don't need to keep them.

Added: 


Modified: 
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td 
b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
index c12aac77c3b69..ce37a6d4821c5 100644
--- a/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ b/clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -111,14 +111,8 @@ def library_S : Separate<["--", "-"], "library">, 
Flags<[HelpHidden]>,
 def library_EQ : Joined<["--", "-"], "library=">, Flags<[HelpHidden]>,
   Alias;
 
-def as_needed : Flag<["--", "-"], "as-needed">;
-def no_as_needed : Flag<["--", "-"], "no-as-needed">;
-
 def rpath : Separate<["--", "-"], "rpath">;
 def rpath_EQ : Joined<["--", "-"], "rpath=">, Flags<[HelpHidden]>, 
Alias;
 
-def dynamic_linker : Separate<["--", "-"], "dynamic-linker">;
-def dynamic_linker_EQ : Joined<["--", "-"], "dynamic-linker=">, 
Alias;
-
 def v : Flag<["--", "-"], "v">, HelpText<"Display the version number and 
exit">;
 def version : Flag<["--", "-"], "version">, Flags<[HelpHidden]>, Alias;



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


[PATCH] D142673: [clang-tidy] Refactor HeaderGuardCheck to add HeaderGuardStyle

2023-01-27 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Note: I do not have possibility to add code comments - is there some too strict 
permissions set for this patch? It has not happened to other patches.

Review comment:

I think the design choice in clang-tidy is that checks from different modules 
should not depend on each other like this, that's why a common `utils` folder 
exists.
What is the difference between `llvm-header-guard` and 
`readability-header-guard`? Could one be the alias of the other, possibly with 
some added configuration options?


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

https://reviews.llvm.org/D142673

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


[PATCH] D142736: Add QualType::getNullability for _Optional

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

The purpose of this change is to ensure that a
qualified declaration such as '_Optional int *' is
treated as equivalent to the annotated declaration
'int *_Nullable' in all situations where type
qualifiers are available.

The new method falls back to Type::getNullability() if
called for a QualType which is not a pointer to an
_Optional-qualified type.

Updated all of the callers which previously invoked
Type::getNullability() via QualType::operator->() so
that they call the new method directly on the QualType
instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142736

Files:
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaType.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -1332,7 +1332,7 @@
   if (T.isNull())
 return CXTypeNullability_Invalid;
 
-  if (auto nullability = T->getNullability()) {
+  if (auto nullability = T.getNullability()) {
 switch (*nullability) {
   case NullabilityKind::NonNull:
 return CXTypeNullability_NonNull;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4713,7 +4713,7 @@
 complainAboutMissingNullability = CAMN_InnerPointers;
 
 if (T->canHaveNullability(/*ResultIfUnknown*/ false) &&
-!T->getNullability()) {
+!T.getNullability()) {
   // Note that we allow but don't require nullability on dependent types.
   ++NumPointersRemaining;
 }
@@ -4935,7 +4935,7 @@
   // nullability and perform consistency checking.
   if (S.CodeSynthesisContexts.empty()) {
 if (T->canHaveNullability(/*ResultIfUnknown*/ false) &&
-!T->getNullability()) {
+!T.getNullability()) {
   if (isVaList(T)) {
 // Record that we've seen a pointer, but do nothing else.
 if (NumPointersRemaining > 0)
@@ -4959,7 +4959,7 @@
 }
 
 if (complainAboutMissingNullability == CAMN_Yes && T->isArrayType() &&
-!T->getNullability() && !isVaList(T) && D.isPrototypeContext() &&
+!T.getNullability() && !isVaList(T) && D.isPrototypeContext() &&
 !hasOuterPointerLikeChunk(D, D.getNumTypeObjects())) {
   checkNullabilityConsistency(S, SimplePointerKind::Array,
   D.getDeclSpec().getTypeSpecTypeLoc());
@@ -7415,7 +7415,7 @@
   // This (unlike the code above) looks through typedefs that might
   // have nullability specifiers on them, which means we cannot
   // provide a useful Fix-It.
-  if (auto existingNullability = desugared->getNullability()) {
+  if (auto existingNullability = desugared.getNullability()) {
 if (nullability != *existingNullability) {
   S.Diag(nullabilityLoc, diag::err_nullability_conflicting)
 << DiagNullabilityKind(nullability, isContextSensitive)
@@ -7514,7 +7514,7 @@
   // If we started with an object pointer type, rebuild it.
   if (ptrType) {
 equivType = S.Context.getObjCObjectPointerType(equivType);
-if (auto nullability = type->getNullability()) {
+if (auto nullability = type.getNullability()) {
   // We create a nullability attribute from the __kindof attribute.
   // Make sure that will make sense.
   assert(attr.getAttributeSpellingListIndex() == 0 &&
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -2754,7 +2754,7 @@
 
   if (Attributes & ObjCPropertyAttribute::kind_weak) {
 // 'weak' and 'nonnull' are mutually exclusive.
-if (auto nullability = PropertyTy->getNullability()) {
+if (auto nullability = PropertyTy.getNullability()) {
   if (*nullability == NullabilityKind::NonNull)
 Diag(Loc, diag::err_objc_property_attr_mutually_exclusive)
   << "nonnull" << "weak";
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -777,8 +777,8 @@
 if 

[PATCH] D142734: Updated CheckAddressOfOperand

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The semantics of the unary & operator are modified
so that if its  operand has type "type" then its
result has type "pointer to type", with the omission
of any _Optional qualifier of the pointed-to type.

Also added a new helper method,
ASTContext::getNonOptionalType.

Rationale:

A new idiom &* is proposed to allow removal of the
_Optional qualifier from a pointee whilst allowing
static analyzers to check the validity of such
conversions. This is merely the simplest expression
that incorporates a semantic dereference without
actually accessing the pointed-to object.

There is only one way to get the address of an object
(excepting arithmetic), whereas there are many ways
to dereference a pointer. This is why the semantics
of & are modified rather than modifying *, [] and ->.
The operand of  & is already treated specially, being
exempt from implicit conversion of an array type into
a pointer, for example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142734

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/Sema/SemaExpr.cpp

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14585,10 +14585,18 @@
   if (getLangOpts().C99) {
 // Implement C99-only parts of addressof rules.
 if (UnaryOperator* uOp = dyn_cast(op)) {
-  if (uOp->getOpcode() == UO_Deref)
+  if (uOp->getOpcode() == UO_Deref) {
 // Per C99 6.5.3.2, the address of a deref always returns a valid result
 // (assuming the deref expression is valid).
-return uOp->getSubExpr()->getType();
+auto Result = uOp->getSubExpr()->getType();
+if (const PointerType *PT = Result->getAs()) {
+  // A dereferenced pointer is not a null pointer (by definition).
+  auto PointeeType = PT->getPointeeType();
+  Result =
+  Context.getPointerType(Context.getNonOptionalType(PointeeType));
+}
+return Result;
+  }
 }
 // Technically, there should be a check for array subscript
 // expressions here, but the result of one is always an lvalue anyway.
@@ -14602,6 +14610,7 @@
 
   Expr::LValueClassification lval = op->ClassifyLValue(Context);
   unsigned AddressOfError = AO_No_Error;
+  QualType Ty = Context.getNonOptionalType(op->getType());
 
   if (lval == Expr::LV_ClassTemporary || lval == Expr::LV_ArrayTemporary) {
 bool sfinae = (bool)isSFINAEContext();
@@ -14611,10 +14620,9 @@
 if (sfinae)
   return QualType();
 // Materialize the temporary as an lvalue so that we can take its address.
-OrigOp = op =
-CreateMaterializeTemporaryExpr(op->getType(), OrigOp.get(), true);
+OrigOp = op = CreateMaterializeTemporaryExpr(Ty, OrigOp.get(), true);
   } else if (isa(op)) {
-return Context.getPointerType(op->getType());
+return Context.getPointerType(Ty);
   } else if (lval == Expr::LV_MemberFunction) {
 // If it's an instance method, make a member pointer.
 // The expression must have exactly the form ::foo.
@@ -14652,7 +14660,7 @@
   Diag(OpLoc, diag::err_typecheck_addrof_dtor) << op->getSourceRange();
 
 QualType MPTy = Context.getMemberPointerType(
-op->getType(), Context.getTypeDeclType(MD->getParent()).getTypePtr());
+Ty, Context.getTypeDeclType(MD->getParent()).getTypePtr());
 // Under the MS ABI, lock down the inheritance model now.
 if (Context.getTargetInfo().getCXXABI().isMicrosoft())
   (void)isCompleteType(OpLoc, MPTy);
@@ -14660,7 +14668,7 @@
   } else if (lval != Expr::LV_Valid && lval != Expr::LV_IncompleteVoidType) {
 // C99 6.5.3.2p1
 // The operand must be either an l-value or a function designator
-if (!op->getType()->isFunctionType()) {
+if (!Ty->isFunctionType()) {
   // Use a special diagnostic for loads from property references.
   if (isa(op)) {
 AddressOfError = AO_Property_Expansion;
@@ -14711,8 +14719,7 @@
 Ctx = Ctx->getParent();
 
   QualType MPTy = Context.getMemberPointerType(
-  op->getType(),
-  Context.getTypeDeclType(cast(Ctx)).getTypePtr());
+  Ty, Context.getTypeDeclType(cast(Ctx)).getTypePtr());
   // Under the MS ABI, lock down the inheritance model now.
   if (Context.getTargetInfo().getCXXABI().isMicrosoft())
 (void)isCompleteType(OpLoc, MPTy);
@@ -14737,12 +14744,12 @@
   }
 
   // If the operand has type "type", the result has type "pointer to type".
-  if (op->getType()->isObjCObjectType())
-return Context.getObjCObjectPointerType(op->getType());
+  if (Ty->isObjCObjectType())
+return Context.getObjCObjectPointerType(Ty);
 
   CheckAddressOfPackedMember(op);
 
-  return 

[PATCH] D142690: [DRAFT][libc++] Fixes the Clang modular build.

2023-01-27 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 492779.
Mordante added a comment.

Rebased and improve fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

Files:
  clang/lib/run_the_clang_CI
  libcxx/include/module.modulemap.in
  libcxx/utils/ci/generate-buildkite-pipeline


Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,7 +19,7 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
+if [[ "${CLANG_CHANGED}" == "true" ]]; then
   cat libcxx/utils/ci/buildkite-pipeline-clang.yml
 else
   cat libcxx/utils/ci/buildkite-pipeline.yml
Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header 
"__concepts/derived_from.h" }
   module destructible   { private header 
"__concepts/destructible.h" }
   module different_from { private header 
"__concepts/different_from.h" }
-  module equality_comparable{ private header 
"__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header 
"__concepts/invocable.h" }
   module movable{ private header 
"__concepts/movable.h" }
   module predicate  { private header 
"__concepts/predicate.h" }
   module regular{ private header 
"__concepts/regular.h" }
   module relation   { private header 
"__concepts/relation.h" }
-  module same_as{ private header 
"__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header 
"__concepts/semiregular.h" }
   module swappable  { private header 
"__concepts/swappable.h" }
   module totally_ordered{ private header 
"__concepts/totally_ordered.h" }
@@ -979,7 +985,11 @@
   module back_insert_iterator  { private header 
"__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header 
"__iterator/bounded_iter.h" }
   module common_iterator   { private header 
"__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header 
"__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default_sentinel  { private header 
"__iterator/default_sentinel.h" }
@@ -1416,7 +1426,10 @@
 module extent  { private header 
"__type_traits/extent.h" }
 module has_unique_object_representation{ private header 
"__type_traits/has_unique_object_representation.h" }
 module has_virtual_destructor  { private header 
"__type_traits/has_virtual_destructor.h" }
-module integral_constant   { private header 
"__type_traits/integral_constant.h" }
+module integral_constant   {
+  private header "__type_traits/integral_constant.h"
+  export type_traits.common_reference
+}
 module is_abstract { private header 
"__type_traits/is_abstract.h" }
 module is_aggregate{ private header 
"__type_traits/is_aggregate.h" }
 module is_allocator{ private header 
"__type_traits/is_allocator.h" }


Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,7 +19,7 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
+if [[ "${CLANG_CHANGED}" == "true" ]]; then
   cat libcxx/utils/ci/buildkite-pipeline-clang.yml
 else
   cat libcxx/utils/ci/buildkite-pipeline.yml
Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header "__concepts/derived_from.h" }
   module destructible   { private 

[PATCH] D142092: [include-mapping] Allow multiple headers for the same symbol. Choose the first header of available ones.

2023-01-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo marked an inline comment as done.
VitaNuo added a comment.

Thanks for the comments! AFAICS I've addressed all of them.
Re tests, thanks for the reminder @hokein! I've fixed them now, everything is 
green.




Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:205
 SYMBOL(basic_syncbuf, std::, )
 SYMBOL(begin, std::, )
 SYMBOL(bernoulli_distribution, std::, )

kadircet wrote:
> i think we should have other providers here, 
> https://en.cppreference.com/w/cpp/iterator/begin. do we know why they're 
> dropped?
Yes, this list is the regeneration of the 2018 html book. It's explicitly _not_ 
generated from the 2022 book in order to have a clear diff related to the topic 
of this patch.
In the 2018 book, the only provider for `std::begin` is `iterator`.



Comment at: clang/include/clang/Tooling/Inclusions/StdSymbolMap.inc:1162
 SYMBOL(subtract_with_carry_engine, std::, )
+SYMBOL(swap, std::, )
 SYMBOL(swap_ranges, std::, )

hokein wrote:
> Is this intended? it seems to me the cppparser doesn't handle this case 
> correctly, in the swap symbol page, we have two headers in a single 
> `t-dsc-header` tr, the parser should consider both (like the above `size_t`).
> 
> ```
> Defined in header 
> Defined in header 
> ```
You're right. There's another random class name (`t-dcl-rev-aux`) that needs to 
be skipped. I've changed the condition in line 81 of cppreference_parser.py 
(the loop that skips unneeded rows between the header block and the symbol 
block) to negation in order to make it more robust and avoid listing all these 
unneeded classes unnecessarily.  



Comment at: clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:57
+// ordered alpahbetically in the map.
+unsigned SymIndex = NextAvailSymIndex;
+if (NextAvailSymIndex > 0 &&

hokein wrote:
> We can avoid a local variable by
> 
> ```
> auto Add = [.. SymIndex(-1)] () {
> if (SymIndex >=0 &&
> SymbolNames[SymIndex].first == NS && ...) {
> } else {
> // the first symbol, or new symbol.
> ++SymIndex;
> }
> 
> SymbolNames[SymIndex] = {NS, Name};
> 
> }
> ```
Ok, sure.



Comment at: clang/tools/include-mapping/cppreference_parser.py:39
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, header_to_accept):
   """Parse symbol page and retrieve the include header defined in this page.

hokein wrote:
> If the `header_to_accept` is set, I think we can just return 
> {header_to_accept} directly.
We'd need to add `<>` then. It needs a couple of extra lines here or there 
anyways, I don't think it makes a difference.



Comment at: clang/tools/include-mapping/cppreference_parser.py:96
+if symbol_name in found_symbols:
+  # FIXME: only update symbol headers on first symbol discovery, assume
+  # same symbol occurence in a subsequent header block is an overload.

hokein wrote:
> IIUC, this is the major and intended change of the function, this is not a 
> FIXME.
I guess it depends on how you view it: I meant it as FIXME in the context of 
overloads, i.e., we might want to remove this and add infrastructure to 
differentiate between overloads explicitly. 
I can remove the FIXME part, no problem.



Comment at: clang/tools/include-mapping/cppreference_parser.py:105
+
+  # If the symbol was never named, consider all named headers.  
+  # FIXME: only consider first symbol, assume further symbols are overloads

hokein wrote:
> The comment doesn't match the current behavior. IIUC, iof the symbol was 
> never named, we only consider the first header now.
I've removed all the hacking with `all_headers` now, so the comment is valid 
again.



Comment at: clang/tools/include-mapping/cppreference_parser.py:107
+  # FIXME: only consider first symbol, assume further symbols are overloads
+  all_headers = sorted(list(all_headers))
+  if len(all_headers) > 0:

hokein wrote:
> why sort the headers?
This was a hack to make the generator return `atomic` rather than `memory` for 
`std::atomic.*` symbols. But I've noticed now that this adds some trouble to 
the C symbol map. I think now that cutting `all_headers` to the first element 
is wrong.
I will special-case the `std::atomic.*` symbols instead, because so far I don't 
see a way to solve this programmatically without other collateral effects.

Note that the problem is not `std::atomic` itself (for which Kadir extensively 
described the solution in some of the other comments), but rather 
`atomic_bool`, `atomic_char` etc. mentioned further in the page. The headers 
for them come from `all_headers` rather than `symbol_headers`, and there seems 
to be no way to limit them to `` without other collateral effects.



Comment at: 

[PATCH] D142733: Add _Optional as fast qualifier

2023-01-27 Thread Christopher Bazley via Phabricator via cfe-commits
chrisbazley created this revision.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, jdoerfert, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, 
arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, thopre, martong, 
hiraditya.
Herald added a reviewer: shafik.
Herald added a reviewer: shafik.
Herald added a reviewer: rriddle.
Herald added a project: All.
chrisbazley requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, 
stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, LLDB, MLIR, LLVM.

A new pointee type qualifier for the purpose of
adding pointer nullability information to C
programs. Its goal is to provide value not only
for static analysis and documentation, but also
for compilers which report errors based only on
existing type-compatibility rules. The syntax
and semantics are designed to be as familiar (to
C programmers) and ergonomic as possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142733

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  lldb/include/lldb/Symbol/Type.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Symbol/Type.cpp
  llvm/docs/LangRef.rst
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/BinaryFormat/Dwarf.def
  llvm/include/llvm/DebugInfo/CodeView/CodeView.h
  llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
  llvm/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeSymbolEnumerator.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeArray.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeBuiltin.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeEnum.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeFunctionSig.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypePointer.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeUDT.h
  llvm/include/llvm/DebugInfo/PDB/Native/NativeTypeVTShape.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolData.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolFunc.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolThunk.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeArray.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTable.h
  llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypeVTableShape.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/lib/DWARFLinker/DWARFLinker.cpp
  llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
  llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
  llvm/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSymbolEnumerator.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeArray.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeBuiltin.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypePointer.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeUDT.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeTypeVTShape.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
  llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
  llvm/lib/Target/BPF/BPFPreserveDIType.cpp
  llvm/lib/Target/BPF/BTF.def
  llvm/lib/Target/BPF/BTFDebug.cpp
  

  1   2   >