[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Mac and windows, see eg 
http://45.33.8.238/macm1/43791/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D132550: Changes to code ownership in clang and clang-tidy

2022-09-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/CodeOwners.rst:226
+| Alexey Bataev
+| a.bataev\@hotmail.com (email), ABataev (Phabricator), cilkplus (GitHub)
+




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

https://reviews.llvm.org/D132550

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


[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-02 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Will there be eventually a way to build a fully optimised clang/lld with 
ThinLTO, PGO, and Bolt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-09-02 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5340
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new

Maybe we can make a new `error` diagnostic definition and fire that here?



Comment at: clang/test/Parser/c2x-attributes.c:146
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}

Could we improve this diagnostic message? 
```
expected ';' after top level declarator}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133248

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


[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-09-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2592
 
-  if (FormatTok->is(tok::l_brace)) {
+  if (Keywords.isBlockBegin(*FormatTok, Style)) {
 FormatTok->setFinalizedType(TT_ControlStatementLBrace);

owenpan wrote:
> This is likely the culprit of 
> https://github.com/llvm/llvm-project/issues/57509. @sstwcw can you have a 
> look?
My bad, but see https://reviews.llvm.org/D123450#inline-1282841.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450

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


[PATCH] D133248: [clang] Fix crash upon stray coloncolon token in C2x mode

2022-09-02 Thread Hu Jialun via Phabricator via cfe-commits
SuibianP created this revision.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
SuibianP requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The parser assumes that the lexer never emits coloncolon token for
C code, but this assumption no longer holds in C2x attribute namespaces.
As a result, stray coloncolon tokens out of attributes cause assertion
failures and hangs in release build, which this patch tries to handle.

Crash input minimal example: T n::v


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133248

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Parser/c2x-attributes.c


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot 
appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as 
scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2060,9 +2060,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope 
either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5336,6 +5336,8 @@
 return isDeclarationSpecifier();
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// ::new
 NextToken().is(tok::kw_delete))   // ::delete
   return false;
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -860,10 +860,11 @@
   bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
 
   bool MightBeCXXScopeToken() {
-return Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
-   (Tok.is(tok::annot_template_id) &&
-NextToken().is(tok::coloncolon)) ||
-   Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super);
+return (getLangOpts().CPlusPlus) &&
+   (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+(Tok.is(tok::annot_template_id) &&
+ NextToken().is(tok::coloncolon)) ||
+Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super));
   }
   bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext = false) {
 return MightBeCXXScopeToken() && TryAnnotateCXXScopeToken(EnteringContext);


Index: clang/test/Parser/c2x-attributes.c
===
--- clang/test/Parser/c2x-attributes.c
+++ clang/test/Parser/c2x-attributes.c
@@ -141,3 +141,6 @@
 struct [[]] S4 *s; // expected-error {{an attribute list cannot appear here}}
 struct S5 {};
 int c = sizeof(struct [[]] S5); // expected-error {{an attribute list cannot appear here}}
+
+// Ensure that '::' outside of attributes does not crash and is not treated as scope
+double n::v; // expected-error {{expected ';' after top level declarator}}
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -2060,9 +2060,9 @@
 }
 
 if (!getLangOpts().CPlusPlus) {
-  // If we're in C, we can't have :: tokens at all (the lexer won't return
-  // them).  If the identifier is not a type, then it can't be scope either,
-  // just early exit.
+  // If we're in C, the only place we can have :: tokens is C2x
+  // attribute which is parsed elsewhere. If the identifier is not a type,
+  // then it can't be scope either, just early exit.
   return false;
 }
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5336,6 +5336,8 @@
 return isDeclarationSpecifier();
 
   case tok::coloncolon:   // ::foo::bar
+if (!getLangOpts().CPlusPlus)
+  return false;
 if (NextToken().is(tok::kw_new) ||// 

[PATCH] D123450: [clang-format] Parse Verilog if statements

2022-09-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/FormatToken.h:1550
+  bool isBlockBegin(const FormatToken , const FormatStyle ) const {
+return Tok.is(TT_MacroBlockBegin) ||
+   (Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace));

Due of what `isBlockBegin()` is replacing in this patch, `TT_MacroBlockBegin` 
should be added in a separate patch (if it's correct to add it) along with 
corresponding unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450

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


[PATCH] D133087: [clang-format][NFC][Docs] fix wrong example of warping class definitions

2022-09-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.

LGTM


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

https://reviews.llvm.org/D133087

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


[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:4
+// RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=control-flow %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
+

this code does not use assertions, so this this flag is not needed



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:4
+// RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=control-flow %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
+

vitalybuka wrote:
> this code does not use assertions, so this this flag is not needed
similar tests set

// REQUIRES: has_sancovcc,stable-runtime
// UNSUPPORTED: i386-darwin, x86_64-darwin



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:11
+foo(recurse - 1);
+}
+

Could you please move this test into a separate patch, I suspect this one 
likely than the rest will be reverted  of platforms with limited runtime



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:38
+// TODO(navidem): make sure this is all to be checked for the collected 
control flow
\ No newline at end of file


you can use
// RUN: llvm-objdump ... | FIleCheck %s



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1063
+}
+
+CFs.push_back((Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 
0), IntptrPtrTy));

wouldn't be better to prefix with count instead of separator?



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1064
+
+CFs.push_back((Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 
0), IntptrPtrTy));
+





Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1077
+
+CFs.push_back((Constant *)IRB.CreateIntToPtr(ConstantInt::get(IntptrTy, 
0), IntptrPtrTy));
+  }

getNullValue



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1057
+if ( == ())
+  CFs.push_back((Constant *)IRB.CreatePointerCast(, IntptrPtrTy));
+else

Navidem wrote:
> vitalybuka wrote:
> > static_cast or dyn_cast
> Please check lines 739-746. This usage pattern is already there. Should we 
> change those as well?
Then keep as-is in this patch
you are welcome to fix this in followup patch :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D131469#3768308 , @dongjunduo 
wrote:

> In D131469#3768288 , @dyung wrote:
>
>> In D131469#3768283 , @dongjunduo 
>> wrote:
>>
>>> In D131469#3768282 , @dyung wrote:
>>>
 In D131469#3768274 , @dongjunduo 
 wrote:

> In D131469#3768260 , @dyung 
> wrote:
>
>> The test you added is failing on the PS4 linux bot because the PS4 
>> platform requires an external linker that isn't present. Is linking 
>> necessary for your test? Or can -S or even -c work instead to accomplish 
>> what you are trying to test?
>
> Yeah the new test case is designed to test the compiling jobs with a 
> linking stage.
>
> Are there any options or measures to avoid this test running on the PS4?

 You could mark it as XFAIL: ps4

 Your change also seems to have possibly the same issue when run on our PS5 
 Windows bot:
 https://lab.llvm.org/buildbot/#/builders/216/builds/9260

   $ ":" "RUN: at line 2"
   $ "z:\test\build\bin\clang.exe" "--driver-mode=g++" "-ftime-trace" 
 "-ftime-trace-granularity=0" "-o" 
 "Z:\test\build\tools\clang\test\Driver\Output/exe/check-time-trace" 
 "Z:\test\llvm-project\clang\test\Driver\check-time-trace.cpp"
   # command stderr:
   clang: error: unable to execute command: program not executable
   clang: error: linker command failed with exit code 1 (use -v to see 
 invocation)
>>>
>>> How about "**UNSUPPORTED: ps4, ps5**"
>>
>> That would likely work I think.
>
> Done with the commit 39221ad 
> .

I don't like how this done. This generally won't work for Darwin platform as 
well since you don't know where SDK is. Whether you have a linker or not has 
nothing to do with the host platform, you need to check for if the linker is 
available.

This is also a regression in test coverage since all the supported tests in 
lines after you added are no longer executed on the platform you excludes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

In D131469#3768288 , @dyung wrote:

> In D131469#3768283 , @dongjunduo 
> wrote:
>
>> In D131469#3768282 , @dyung wrote:
>>
>>> In D131469#3768274 , @dongjunduo 
>>> wrote:
>>>
 In D131469#3768260 , @dyung 
 wrote:

> The test you added is failing on the PS4 linux bot because the PS4 
> platform requires an external linker that isn't present. Is linking 
> necessary for your test? Or can -S or even -c work instead to accomplish 
> what you are trying to test?

 Yeah the new test case is designed to test the compiling jobs with a 
 linking stage.

 Are there any options or measures to avoid this test running on the PS4?
>>>
>>> You could mark it as XFAIL: ps4
>>>
>>> Your change also seems to have possibly the same issue when run on our PS5 
>>> Windows bot:
>>> https://lab.llvm.org/buildbot/#/builders/216/builds/9260
>>>
>>>   $ ":" "RUN: at line 2"
>>>   $ "z:\test\build\bin\clang.exe" "--driver-mode=g++" "-ftime-trace" 
>>> "-ftime-trace-granularity=0" "-o" 
>>> "Z:\test\build\tools\clang\test\Driver\Output/exe/check-time-trace" 
>>> "Z:\test\llvm-project\clang\test\Driver\check-time-trace.cpp"
>>>   # command stderr:
>>>   clang: error: unable to execute command: program not executable
>>>   clang: error: linker command failed with exit code 1 (use -v to see 
>>> invocation)
>>
>> How about "**UNSUPPORTED: ps4, ps5**"
>
> That would likely work I think.

Done with the commit 39221ad 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[clang] 39221ad - [driver][clang] remove the check-time-trace test on the platform "PS4/PS5/Hexagon"

2022-09-02 Thread Junduo Dong via cfe-commits

Author: Junduo Dong
Date: 2022-09-02T20:27:35-07:00
New Revision: 39221ad55752c246bb8448a181847103432e12b2

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

LOG: [driver][clang] remove the check-time-trace test on the platform 
"PS4/PS5/Hexagon"

One of the test cases in that test is designed to test the compiling
jobs with a linking stage, but the PS4/PS5/Hexagon platform requires
an external linker that isn't present.

So this test do not support the "PS4/PS5/Hexagon".

Added: 


Modified: 
clang/test/Driver/check-time-trace.cpp

Removed: 




diff  --git a/clang/test/Driver/check-time-trace.cpp 
b/clang/test/Driver/check-time-trace.cpp
index e0d1e935a733..3ff12981a97c 100644
--- a/clang/test/Driver/check-time-trace.cpp
+++ b/clang/test/Driver/check-time-trace.cpp
@@ -1,3 +1,5 @@
+// UNSUPPORTED: ps4, ps5, hexagon
+
 // RUN: rm -rf %T/exe && mkdir %T/exe
 // RUN: %clangxx -ftime-trace -ftime-trace-granularity=0 -o 
%T/exe/check-time-trace %s
 // RUN: cat %T/exe/check-time-trace*.json \



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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1534-1538
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);

aaron.ballman wrote:
> Let's get fancy!
You would use `getContainedDeducedType` if you expected to handle DeducedTypes 
in general, not just AutoTypes.

So if you only want to handle AutoTypes, there is no point in using 
`getContainedDeducedType`.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp:3-8
+namespace GH57362 {
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};

I don't understand why these cases are grouped under GH57362 issue, they are 
cases that worked fine without this patch, we just didn't have tests for them.


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

https://reviews.llvm.org/D132990

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2022-09-02 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
felix642 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133244

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h


Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
@@ -37,6 +37,9 @@
   llvm::Optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const std::vector IgnoredContainers;
 };
 } // namespace readability
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "ContainerDataPointerCheck.h"
 
+#include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -22,14 +23,18 @@
 constexpr llvm::StringLiteral AddrOfContainerExprName =
 "addr-of-container-expr";
 constexpr llvm::StringLiteral AddressOfName = "address-of";
+const auto DefaultIgnoredContainers = "::std::array";
 
 ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+  IgnoredContainers(utils::options::parseStringList(
+  Options.get("IgnoredContainers", DefaultIgnoredContainers))) {}
 
 void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto Record =
   cxxRecordDecl(
+  unless(hasAnyName(IgnoredContainers)),
   isSameOrDerivedFrom(
   namedDecl(
   has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))


Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
@@ -37,6 +37,9 @@
   llvm::Optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const std::vector IgnoredContainers;
 };
 } // namespace readability
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "ContainerDataPointerCheck.h"
 
+#include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -22,14 +23,18 @@
 constexpr llvm::StringLiteral AddrOfContainerExprName =
 "addr-of-container-expr";
 constexpr llvm::StringLiteral AddressOfName = "address-of";
+const auto DefaultIgnoredContainers = "::std::array";
 
 ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+  IgnoredContainers(utils::options::parseStringList(
+  Options.get("IgnoredContainers", DefaultIgnoredContainers))) {}
 
 void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto Record =
   cxxRecordDecl(
+  unless(hasAnyName(IgnoredContainers)),
   isSameOrDerivedFrom(
   namedDecl(
   has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D131469#3768283 , @dongjunduo 
wrote:

> In D131469#3768282 , @dyung wrote:
>
>> In D131469#3768274 , @dongjunduo 
>> wrote:
>>
>>> In D131469#3768260 , @dyung wrote:
>>>
 The test you added is failing on the PS4 linux bot because the PS4 
 platform requires an external linker that isn't present. Is linking 
 necessary for your test? Or can -S or even -c work instead to accomplish 
 what you are trying to test?
>>>
>>> Yeah the new test case is designed to test the compiling jobs with a 
>>> linking stage.
>>>
>>> Are there any options or measures to avoid this test running on the PS4?
>>
>> You could mark it as XFAIL: ps4
>>
>> Your change also seems to have possibly the same issue when run on our PS5 
>> Windows bot:
>> https://lab.llvm.org/buildbot/#/builders/216/builds/9260
>>
>>   $ ":" "RUN: at line 2"
>>   $ "z:\test\build\bin\clang.exe" "--driver-mode=g++" "-ftime-trace" 
>> "-ftime-trace-granularity=0" "-o" 
>> "Z:\test\build\tools\clang\test\Driver\Output/exe/check-time-trace" 
>> "Z:\test\llvm-project\clang\test\Driver\check-time-trace.cpp"
>>   # command stderr:
>>   clang: error: unable to execute command: program not executable
>>   clang: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>
> How about "**UNSUPPORTED: ps4, ps5**"

That would likely work I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

In D131469#3768282 , @dyung wrote:

> In D131469#3768274 , @dongjunduo 
> wrote:
>
>> In D131469#3768260 , @dyung wrote:
>>
>>> The test you added is failing on the PS4 linux bot because the PS4 platform 
>>> requires an external linker that isn't present. Is linking necessary for 
>>> your test? Or can -S or even -c work instead to accomplish what you are 
>>> trying to test?
>>
>> Yeah the new test case is designed to test the compiling jobs with a linking 
>> stage.
>>
>> Are there any options or measures to avoid this test running on the PS4?
>
> You could mark it as XFAIL: ps4
>
> Your change also seems to have possibly the same issue when run on our PS5 
> Windows bot:
> https://lab.llvm.org/buildbot/#/builders/216/builds/9260
>
>   $ ":" "RUN: at line 2"
>   $ "z:\test\build\bin\clang.exe" "--driver-mode=g++" "-ftime-trace" 
> "-ftime-trace-granularity=0" "-o" 
> "Z:\test\build\tools\clang\test\Driver\Output/exe/check-time-trace" 
> "Z:\test\llvm-project\clang\test\Driver\check-time-trace.cpp"
>   # command stderr:
>   clang: error: unable to execute command: program not executable
>   clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)

How about "**UNSUPPORTED: ps4, ps5**"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D131469#3768274 , @dongjunduo 
wrote:

> In D131469#3768260 , @dyung wrote:
>
>> The test you added is failing on the PS4 linux bot because the PS4 platform 
>> requires an external linker that isn't present. Is linking necessary for 
>> your test? Or can -S or even -c work instead to accomplish what you are 
>> trying to test?
>
> Yeah the new test case is designed to test the compiling jobs with a linking 
> stage.
>
> Are there any options or measures to avoid this test running on the PS4?

You could mark it as XFAIL: ps4

Your change also seems to have possibly the same issue when run on our PS5 
Windows bot:
https://lab.llvm.org/buildbot/#/builders/216/builds/9260

  $ ":" "RUN: at line 2"
  $ "z:\test\build\bin\clang.exe" "--driver-mode=g++" "-ftime-trace" 
"-ftime-trace-granularity=0" "-o" 
"Z:\test\build\tools\clang\test\Driver\Output/exe/check-time-trace" 
"Z:\test\llvm-project\clang\test\Driver\check-time-trace.cpp"
  # command stderr:
  clang: error: unable to execute command: program not executable
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-02 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem updated this revision to Diff 457754.
Navidem added a comment.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Added an initial run-time test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
@@ -0,0 +1,22 @@
+; Test -sanitizer-coverage-control-flow
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(i32* %a) sanitize_address {
+entry:
+  %tobool = icmp eq i32* %a, null
+  br i1 %tobool, label %if.end, label %if.then
+
+  if.then:  ; preds = %entry
+  store i32 0, i32* %a, align 4
+  call void @foo(i32* %a)
+  br label %if.end
+
+  if.end:   ; preds = %entry, %if.then
+  ret void
+}
+
+; CHECK: private constant [17 x i64*] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}@foo{{.*}}null{{.*}}null], section "__sancov_cfs", comdat($foo), align 8
+; CHECK:  @__start___sancov_cfs = extern_weak hidden global i64*
+; CHECK-NEXT: @__stop___sancov_cfs = extern_weak hidden global i64*
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -80,6 +80,7 @@
 const char SanCovCountersSectionName[] = "sancov_cntrs";
 const char SanCovBoolFlagSectionName[] = "sancov_bools";
 const char SanCovPCsSectionName[] = "sancov_pcs";
+const char SanCovCFsSectionName[] = "sancov_cfs";
 
 const char SanCovLowestStackName[] = "__sancov_lowest_stack";
 
@@ -147,6 +148,10 @@
   cl::desc("max stack depth tracing"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClCollectCF("sanitizer-coverage-control-flow",
+  cl::desc("collect control flow for each function"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -193,6 +198,7 @@
   !Options.Inline8bitCounters && !Options.StackDepth &&
   !Options.InlineBoolFlag && !Options.TraceLoads && !Options.TraceStores)
 Options.TracePCGuard = true; // TracePCGuard is default.
+  Options.CollectControlFlow |= ClCollectCF;
   return Options;
 }
 
@@ -212,6 +218,7 @@
 PostDomTreeCallback PDTCallback);
 
 private:
+  void CollectFunctionControlFlow(Function );
   void instrumentFunction(Function , DomTreeCallback DTCallback,
   PostDomTreeCallback PDTCallback);
   void InjectCoverageForIndirectCalls(Function ,
@@ -270,6 +277,7 @@
   GlobalVariable *Function8bitCounterArray;  // for inline-8bit-counters.
   GlobalVariable *FunctionBoolArray; // for inline-bool-flag.
   GlobalVariable *FunctionPCsArray;  // for pc-table.
+  GlobalVariable *FunctionCFsArray;  // for control flow table
   SmallVector GlobalsToAppendToUsed;
   SmallVector GlobalsToAppendToCompilerUsed;
 
@@ -378,6 +386,7 @@
   Function8bitCounterArray = nullptr;
   FunctionBoolArray = nullptr;
   FunctionPCsArray = nullptr;
+  FunctionCFsArray = nullptr;
   IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   IntptrPtrTy = PointerType::getUnqual(IntptrTy);
   Type *VoidTy = Type::getVoidTy(*C);
@@ -502,6 +511,10 @@
 IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
   }
+
+  if (Options.CollectControlFlow)
+CreateSecStartEnd(M, SanCovCFsSectionName, IntptrPtrTy);
+
   appendToUsed(M, GlobalsToAppendToUsed);
   appendToCompilerUsed(M, GlobalsToAppendToCompilerUsed);
   return true;
@@ -671,6 +684,9 @@
 }
   }
 
+  if (Options.CollectControlFlow)
+

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

In D131469#3768260 , @dyung wrote:

> The test you added is failing on the PS4 linux bot because the PS4 platform 
> requires an external linker that isn't present. Is linking necessary for your 
> test? Or can -S or even -c work instead to accomplish what you are trying to 
> test?

Yeah the new test case is designed to test the compiling jobs with a linking 
stage.

Are there any options or measures to avoid this test running on the PS4?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[clang] 632e1e9 - Work around Windows buildbot failure.

2022-09-02 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-09-02T19:09:15-07:00
New Revision: 632e1e9fd81d899ffa01300eb47fd417b76bbae5

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

LOG: Work around Windows buildbot failure.

-fmodules-local-submodule-visibility and -fdelayed-template-parsing
don't work properly together because the template is parsed in the
visibility context of the wrong module.

Added: 


Modified: 
clang/test/Modules/submodule-visibility.cpp

Removed: 




diff  --git a/clang/test/Modules/submodule-visibility.cpp 
b/clang/test/Modules/submodule-visibility.cpp
index ad22903da078..6a1a816ed67e 100644
--- a/clang/test/Modules/submodule-visibility.cpp
+++ b/clang/test/Modules/submodule-visibility.cpp
@@ -6,8 +6,9 @@
 // RUN: %clang_cc1 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -verify %s
 //
 // Ensure the driver forwards the relevant flags when -fmodules is disabled.
-// RUN: %clang -fimplicit-module-maps -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s
-// RUN: %clang 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s
+// FIXME: -fdelayed-template-parsing doesn't properly interact with module 
visibility yet.
+// RUN: %clang -fimplicit-module-maps -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s -fno-delayed-template-parsing
+// RUN: %clang 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s -fno-delayed-template-parsing
 //
 // Explicit module builds.
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -emit-module 
-x c++-module-map %S/Inputs/submodule-visibility/module.modulemap 
-fmodule-name=other -o %t/other.pcm



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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

The test you added is failing on the PS4 linux bot because the PS4 platform 
requires an external linker that isn't present. Is linking necessary for your 
test? Or can -S or even -c work instead to accomplish what you are trying to 
test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D133177: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-02 Thread Shafik Yaghmour 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 rG9f6b3199d33c: [Clang] Fix lambda 
CheckForDefaultedFunction(...) so that it checks the… (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133177

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9f6b319 - [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-02 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2022-09-02T18:59:15-07:00
New Revision: 9f6b3199d33c146937f29feb62e123f34138f770

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

LOG: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the 
CXXMethodDecl is not deleted before attempting to call 
DefineDefaultedFunction(...)

I discovered this additional bug at the end of working on D132906

In Sema::CheckCompletedCXXClass(...)  uses a lambda CheckForDefaultedFunction to
verify each CXXMethodDecl holds to the expected invariants before passing them
on to CheckForDefaultedFunction.

It is currently missing a check that it is not deleted, this adds that check and
a test that crashed without this check.

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

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 41371fe0e04f2..146b2149f9d7e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@ Bug Fixes
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 76db4e5a7a3b9..7c70255fd3e5d 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl 
*Record) {
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)

diff  --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp 
b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
index 63ea42995582e..34881d7446e58 100644
--- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@ class D : B {
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}



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


[clang] 38941da - [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Junduo Dong via cfe-commits

Author: Junduo Dong
Date: 2022-09-02T18:49:11-07:00
New Revision: 38941da066a7b785ba4771710189172e94e37824

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

LOG: [Clang] change default storing path of `-ftime-trace`

1. This implementation change the default storing behavior of -ftime-trace only.

That is, if the compiling job contains the linking action, the executable file' 
s directory may be seem as the main work directory.
Thus the time trace files would be stored in the same directory of linking 
result.

By this approach, the user can easily get the time-trace files in the main work 
directory. The improved demo results:

```
$ clang++ -ftime-trace -o main.out /demo/main.cpp
$ ls .
main.out   main-[random-string].json
```

2. In addition, the main codes of time-trace files' path inference have been 
refactored.

* The  of -ftime-trace= is infered in clang driver
* After that, -ftime-trace= can be added into clang's options

By this approach, the dirty work of path processing and judging can be 
implemented in driver layer, so that the clang may focus on its main work.

 #   $ clang -ftime-trace -o xxx.out xxx.cpp

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/check-time-trace.cpp
clang/tools/driver/cc1_main.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index ba359a1d31a53..5f5655fbc34a8 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4510,6 +4510,102 @@ Action *Driver::ConstructPhaseAction(
   llvm_unreachable("invalid phase in ConstructPhaseAction");
 }
 
+// Infer data storing path of the options `-ftime-trace`, `-ftime-trace=`
+void InferTimeTracePath(Compilation ) {
+  bool HasTimeTrace =
+  C.getArgs().getLastArg(options::OPT_ftime_trace) != nullptr;
+  bool HasTimeTraceFile =
+  C.getArgs().getLastArg(options::OPT_ftime_trace_EQ) != nullptr;
+  // Whether `-ftime-trace` or `-ftime-trace=` are specified
+  if (!HasTimeTrace && !HasTimeTraceFile)
+return;
+
+  // If `-ftime-trace=` is specified, TracePath is the .
+  // Else if there is a linking job, TracePath is the parent path of .exe,
+  // then the OutputFile's name may be appended to it.
+  // Else, TracePath is "",
+  // then the full OutputFile's path may be appended to it.
+  SmallString<128> TracePath("");
+
+  if (HasTimeTraceFile) {
+TracePath = SmallString<128>(
+C.getArgs().getLastArg(options::OPT_ftime_trace_EQ)->getValue());
+  } else {
+// Get linking executable file's parent path as TracePath's parent path,
+// default is ".". Filename may be determined and added into TracePath 
then.
+//
+// e.g. executable file's path: /usr/local/a.out
+//  its parent's path:  /usr/local
+for (auto  : C.getJobs()) {
+  if (J.getSource().getKind() == Action::LinkJobClass) {
+assert(!J.getOutputFilenames().empty() &&
+   "linking output filename is empty");
+auto OutputFilePath =
+SmallString<128>(J.getOutputFilenames()[0].c_str());
+if (llvm::sys::path::has_parent_path(OutputFilePath)) {
+  TracePath = llvm::sys::path::parent_path(OutputFilePath);
+} else {
+  TracePath = SmallString<128>(".");
+}
+break;
+  }
+}
+  }
+
+  // Add or replace the modified -ftime-trace=` to all clang jobs
+  for (auto  : C.getJobs()) {
+if (J.getSource().getKind() == Action::AssembleJobClass ||
+J.getSource().getKind() == Action::BackendJobClass ||
+J.getSource().getKind() == Action::CompileJobClass) {
+  SmallString<128> TracePathReal = TracePath;
+  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());
+  std::string arg = std::string("-ftime-trace=");
+  if (!HasTimeTraceFile) {
+if (TracePathReal.empty()) {
+  // /xxx/yyy.o => /xxx/yyy.json
+  llvm::sys::path::replace_extension(OutputPath, "json");
+  arg += std::string(OutputPath.c_str());
+} else {
+  // /xxx/yyy.o => /executable_file_parent_path/yyy.json
+  llvm::sys::path::append(TracePathReal,
+  llvm::sys::path::filename(OutputPath));
+  llvm::sys::path::replace_extension(TracePathReal, "json");
+  arg += std::string(TracePathReal.c_str());
+}
+  } else {
+// /full_file_path_specified or /path_specified/yyy.json
+if (llvm::sys::fs::is_directory(TracePathReal))
+  llvm::sys::path::append(TracePathReal,
+  llvm::sys::path::filename(OutputPath));
+llvm::sys::path::replace_extension(TracePathReal, "json");
+arg += 

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread dongjunduo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38941da066a7: [Clang] change default storing path of 
`-ftime-trace` (authored by dongjunduo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -256,17 +256,10 @@
   llvm::TimerGroup::clearAll();
 
   if (llvm::timeTraceProfilerEnabled()) {
-SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
-if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
-  // replace the suffix to '.json' directly
-  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
-  if (llvm::sys::fs::is_directory(TracePath))
-llvm::sys::path::append(TracePath, llvm::sys::path::filename(Path));
-  Path.assign(TracePath);
-}
+SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+assert(!TracePath.empty() && "`-ftime-trace=` is empty");
 if (auto profilerOutput = Clang->createOutputFile(
-Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
+TracePath.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
   llvm::timeTraceProfilerWrite(*profilerOutput);
   profilerOutput.reset();
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -1,3 +1,8 @@
+// RUN: rm -rf %T/exe && mkdir %T/exe
+// RUN: %clangxx -ftime-trace -ftime-trace-granularity=0 -o %T/exe/check-time-trace %s
+// RUN: cat %T/exe/check-time-trace*.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 // RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o %T/check-time-trace %s
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4510,6 +4510,102 @@
   llvm_unreachable("invalid phase in ConstructPhaseAction");
 }
 
+// Infer data storing path of the options `-ftime-trace`, `-ftime-trace=`
+void InferTimeTracePath(Compilation ) {
+  bool HasTimeTrace =
+  C.getArgs().getLastArg(options::OPT_ftime_trace) != nullptr;
+  bool HasTimeTraceFile =
+  C.getArgs().getLastArg(options::OPT_ftime_trace_EQ) != nullptr;
+  // Whether `-ftime-trace` or `-ftime-trace=` are specified
+  if (!HasTimeTrace && !HasTimeTraceFile)
+return;
+
+  // If `-ftime-trace=` is specified, TracePath is the .
+  // Else if there is a linking job, TracePath is the parent path of .exe,
+  // then the OutputFile's name may be appended to it.
+  // Else, TracePath is "",
+  // then the full OutputFile's path may be appended to it.
+  SmallString<128> TracePath("");
+
+  if (HasTimeTraceFile) {
+TracePath = SmallString<128>(
+C.getArgs().getLastArg(options::OPT_ftime_trace_EQ)->getValue());
+  } else {
+// Get linking executable file's parent path as TracePath's parent path,
+// default is ".". Filename may be determined and added into TracePath then.
+//
+// e.g. executable file's path: /usr/local/a.out
+//  its parent's path:  /usr/local
+for (auto  : C.getJobs()) {
+  if (J.getSource().getKind() == Action::LinkJobClass) {
+assert(!J.getOutputFilenames().empty() &&
+   "linking output filename is empty");
+auto OutputFilePath =
+SmallString<128>(J.getOutputFilenames()[0].c_str());
+if (llvm::sys::path::has_parent_path(OutputFilePath)) {
+  TracePath = llvm::sys::path::parent_path(OutputFilePath);
+} else {
+  TracePath = SmallString<128>(".");
+}
+break;
+  }
+}
+  }
+
+  // Add or replace the modified -ftime-trace=` to all clang jobs
+  for (auto  : C.getJobs()) {
+if (J.getSource().getKind() == Action::AssembleJobClass ||
+J.getSource().getKind() == Action::BackendJobClass ||
+J.getSource().getKind() == Action::CompileJobClass) {
+  SmallString<128> TracePathReal = TracePath;
+  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());
+  std::string arg = std::string("-ftime-trace=");
+  if (!HasTimeTraceFile) {
+if (TracePathReal.empty()) {
+  // /xxx/yyy.o => 

[clang] 220c2cb - Attempt to make AIX bot happier.

2022-09-02 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-09-02T18:43:27-07:00
New Revision: 220c2cb0a88f0f1cc97ea657018abbffb8697a73

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

LOG: Attempt to make AIX bot happier.

Added: 


Modified: 
clang/test/Modules/declare-use1.cpp
clang/test/Modules/submodule-visibility.cpp

Removed: 




diff  --git a/clang/test/Modules/declare-use1.cpp 
b/clang/test/Modules/declare-use1.cpp
index 2763e0c5703e..58eb317afc09 100644
--- a/clang/test/Modules/declare-use1.cpp
+++ b/clang/test/Modules/declare-use1.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -fimplicit-module-maps -fmodules-decluse -fmodule-name=XG 
-I %S/Inputs/declare-use %s -verify
 //
 // Check these flags get properly passed through the driver even when 
-fmodules is disabled.
-// RUN: %clang -fimplicit-module-maps -fmodules-decluse -fmodule-name=XG -I 
%S/Inputs/declare-use -c -o /dev/null -Xclang -verify %s
+// RUN: %clang -fimplicit-module-maps -fmodules-decluse -fmodule-name=XG -I 
%S/Inputs/declare-use -fsyntax-only -Xclang -verify %s
 
 #include "g.h"
 #include "e.h"

diff  --git a/clang/test/Modules/submodule-visibility.cpp 
b/clang/test/Modules/submodule-visibility.cpp
index f218c3399b5e..ad22903da078 100644
--- a/clang/test/Modules/submodule-visibility.cpp
+++ b/clang/test/Modules/submodule-visibility.cpp
@@ -6,8 +6,8 @@
 // RUN: %clang_cc1 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -verify %s
 //
 // Ensure the driver forwards the relevant flags when -fmodules is disabled.
-// RUN: %clang -fimplicit-module-maps -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -c -o 
/dev/null -Xclang -verify %s
-// RUN: %clang 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -c -o 
/dev/null -Xclang -verify %s
+// RUN: %clang -fimplicit-module-maps -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s
+// RUN: %clang 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility 
-fsyntax-only -Xclang -verify %s
 //
 // Explicit module builds.
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -emit-module 
-x c++-module-map %S/Inputs/submodule-visibility/module.modulemap 
-fmodule-name=other -o %t/other.pcm



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


[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-02 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem added inline comments.



Comment at: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll:2
+; Test -sanitizer-coverage-control-flow
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 
-sanitizer-coverage-control-flow -S | FileCheck %s
+

vitalybuka wrote:
> you don't have to, but may try to generate test with
> llvm/utils/update_test_checks.py --opt-binary bin/opt 
> llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
> 
> It could be reasonable, or not
Thanks! I tried it and it added many more checks, which does not seem very 
useful? Please let me know if you see some value in having these:

```
+; CHECK-LABEL: @foo(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:call void @__sanitizer_cov_trace_pc_guard(i32* getelementptr 
inbounds ([3 x i32], [3 x i32]* @__sancov_gen_.1, i32 0, i32 0)) 
#[[ATTR2:[0-9]+]]
+; CHECK-NEXT:[[TOBOOL:%.*]] = icmp eq i32* [[A:%.*]], null
+; CHECK-NEXT:br i1 [[TOBOOL]], label [[ENTRY_IF_END_CRIT_EDGE:%.*]], label 
[[IF_THEN:%.*]]
+; CHECK:   entry.if.end_crit_edge:
+; CHECK-NEXT:call void @__sanitizer_cov_trace_pc_guard(i32* inttoptr (i64 
add (i64 ptrtoint ([3 x i32]* @__sancov_gen_.1 to i64), i64 4) to i32*)) 
#[[ATTR2]]
+; CHECK-NEXT:br label [[IF_END:%.*]]
+; CHECK:   if.then:
+; CHECK-NEXT:call void @__sanitizer_cov_trace_pc_guard(i32* inttoptr (i64 
add (i64 ptrtoint ([3 x i32]* @__sancov_gen_.1 to i64), i64 8) to i32*)) 
#[[ATTR2]]
+; CHECK-NEXT:store i32 0, i32* [[A]], align 4
+; CHECK-NEXT:call void @foo(i32* [[A]])
+; CHECK-NEXT:br label [[IF_END]]
+; CHECK:   if.end:
+; CHECK-NEXT:ret void
+;

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D132779: Enforce module decl-use restrictions and private header restrictions in textual headers

2022-09-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:126
+  `_ are now
+  diagnosed even when the includer is a textual header.
 

aaron.ballman wrote:
> You should mention `-fno-modules-validate-textual-header-includes` here so 
> that users know there's a transition flag available. Do you expect we'd like 
> to remove that flag in the future, or do you expect we'll need to carry it 
> around "forever"?
I'm hopeful that we only need to keep the flag around while the affected users 
are transitioning. We know we need it inside Google because with this patch we 
find a bunch of layering issues that we thought we were already diagnosing, but 
weren't; I don't know how many other Clang users are actually making use of 
this part of the module maps functionality. My aim would be to remove the flag 
after the next release, if possible.

Extended documentation to mention the flag and that it's going away.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132779

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


[PATCH] D132779: Enforce module decl-use restrictions and private header restrictions in textual headers

2022-09-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 457742.
rsmith added a comment.

Document the flag to undo the behavior, and mention that it's going away.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132779

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Modules/Inputs/declare-use/module.map
  clang/test/Modules/Inputs/declare-use/textual.h
  clang/test/Modules/declare-use-textual.cpp

Index: clang/test/Modules/declare-use-textual.cpp
===
--- /dev/null
+++ clang/test/Modules/declare-use-textual.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=Textual -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-cache-path=%t -fmodules-decluse -fmodule-name=Textual -I %S/Inputs/declare-use %s -fno-modules-validate-textual-header-includes
+
+// expected-error@textual.h:* {{module Textual does not depend on a module exporting 'a.h'}}
+#include "textual.h"
Index: clang/test/Modules/Inputs/declare-use/textual.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/declare-use/textual.h
@@ -0,0 +1 @@
+#include "a.h"
Index: clang/test/Modules/Inputs/declare-use/module.map
===
--- clang/test/Modules/Inputs/declare-use/module.map
+++ clang/test/Modules/Inputs/declare-use/module.map
@@ -73,3 +73,7 @@
 
 module XS {
 }
+
+module Textual {
+  textual header "textual.h"
+}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -856,7 +856,8 @@
 Tok.getLocation());
 }
 
-Module *Preprocessor::getModuleForLocation(SourceLocation Loc) {
+Module *Preprocessor::getModuleForLocation(SourceLocation Loc,
+   bool AllowTextual) {
   if (!SourceMgr.isInMainFile(Loc)) {
 // Try to determine the module of the include directive.
 // FIXME: Look into directly passing the FileEntry from LookupFile instead.
@@ -864,7 +865,7 @@
 if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {
   // The include comes from an included file.
   return HeaderInfo.getModuleMap()
-  .findModuleForHeader(EntryOfIncl)
+  .findModuleForHeader(EntryOfIncl, AllowTextual)
   .getModule();
 }
   }
@@ -879,7 +880,8 @@
 const FileEntry *
 Preprocessor::getHeaderToIncludeForDiagnostics(SourceLocation IncLoc,
SourceLocation Loc) {
-  Module *IncM = getModuleForLocation(IncLoc);
+  Module *IncM = getModuleForLocation(
+  IncLoc, LangOpts.ModulesValidateTextualHeaderIncludes);
 
   // Walk up through the include stack, looking through textual headers of M
   // until we hit a non-textual header that we can #include. (We assume textual
@@ -953,7 +955,8 @@
   ConstSearchDirIterator CurDirLocal = nullptr;
   ConstSearchDirIterator  = CurDirArg ? *CurDirArg : CurDirLocal;
 
-  Module *RequestingModule = getModuleForLocation(FilenameLoc);
+  Module *RequestingModule = getModuleForLocation(
+  FilenameLoc, LangOpts.ModulesValidateTextualHeaderIncludes);
   bool RequestingModuleIsModuleInterface = !SourceMgr.isInMainFile(FilenameLoc);
 
   // If the header lookup mechanism may be relative to the current inclusion
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -2546,7 +2546,7 @@
   /// Find the module that owns the source or header file that
   /// \p Loc points to. If the location is in a file that was included
   /// into a module, or is outside any module, returns nullptr.
-  Module *getModuleForLocation(SourceLocation Loc);
+  Module *getModuleForLocation(SourceLocation Loc, bool AllowTextual);
 
   /// We want to produce a diagnostic at location IncLoc concerning an
   /// unreachable effect at location MLoc (eg, where a desired entity was
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2283,6 +2283,11 @@
   HeaderSearchOpts<"ModulesValidateSystemHeaders">, DefaultFalse,
   PosFlag,
   NegFlag>, Group;
+def fno_modules_validate_textual_header_includes :
+  Flag<["-"], "fno-modules-validate-textual-header-includes">,
+  Group, Flags<[CC1Option, NoXarchOption]>,
+  MarshallingInfoNegativeFlag>,
+  HelpText<"Do not enforce -fmodules-decluse and 

[clang] a887d9e - [NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]

2022-09-02 Thread via cfe-commits

Author: Sheng
Date: 2022-09-03T08:58:31+08:00
New Revision: a887d9efd696da42dd8bf19a63a3db4140361c07

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

LOG: [NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]

Added: 


Modified: 
clang/lib/Parse/ParseStmt.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index fc515f192a727..d785c393fef96 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -272,7 +272,7 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 << Tok.getIdentifierInfo()->getName() << 0;
 goto ParseIdentifier;
   }
-  LLVM_FALLTHROUGH;
+  [[fallthrough]];
 default:
   return ParseExprStatement(StmtCtx);
 }



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


[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-02 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1055
+  for (auto : F) {
+// blockaddress may not be used on function's entry block.
+if ( == ())

Navidem wrote:
> kcc wrote:
> > vitalybuka wrote:
> > > what does happen?
> > "can not" ?
> Actually I started with "can not", but saw the error message from opt saying 
> "may not". Changing anyways :)
Gives invalid IR error if `blockaddress` is used with function entry as arg.



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1057
+if ( == ())
+  CFs.push_back((Constant *)IRB.CreatePointerCast(, IntptrPtrTy));
+else

vitalybuka wrote:
> static_cast or dyn_cast
Please check lines 739-746. This usage pattern is already there. Should we 
change those as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133177: [Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is not deleted before attempting to call DefineDefaultedFunction(...)

2022-09-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 457736.
shafik added a comment.

- Add Release note.


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

https://reviews.llvm.org/D133177

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member 
functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function 
is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a 
non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base 
class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics


Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -1483,3 +1483,12 @@
   virtual int constexpr f() = default; // expected-error {{only special member functions and comparison operators may be defaulted}}
 };
 }
+
+namespace GH57516 {
+class B{
+  virtual constexpr ~B() = 0; // expected-note {{overridden virtual function is here}}
+};
+
+class D : B{}; // expected-error {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note@-1 {{destructor of 'D' is implicitly deleted because base class 'B' has an inaccessible destructor}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -6954,8 +6954,8 @@
 // Define defaulted constexpr virtual functions that override a base class
 // function right away.
 // FIXME: We can defer doing this until the vtable is marked as used.
-if (CSM != CXXInvalid && M->isDefaulted() && M->isConstexpr() &&
-M->size_overridden_methods())
+if (CSM != CXXInvalid && !M->isDeleted() && M->isDefaulted() &&
+M->isConstexpr() && M->size_overridden_methods())
   DefineDefaultedFunction(*this, M, M->getLocation());
 
 if (!Incomplete)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -89,6 +89,8 @@
 - Fix a crash when attempting to default a virtual constexpr non-special member
   function in a derived class. This fixes
   `Issue 57431 `_
+- Fix a crash where we attempt to define a deleted destructor. This fixes
+  `Issue 57516 `_
 
 
 Improvements to Clang's diagnostics
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-02 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 457735.
python3kgae added a comment.

Merge fix from Chris.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/Inputs/pch.hlsl
  clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
  clang/test/AST/HLSL/pch.hlsl
  clang/test/AST/HLSL/pch_with_buf.hlsl

Index: clang/test/AST/HLSL/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// Make sure buffer defined in PCH works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}}  col:17 imported Buf 'RWBuffer':'hlsl::RWBuffer<>'
+// Make sure declare a RWBuffer in current file works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buf2;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s \
+// RUN: | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buffer;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
@@ -0,0 +1,6 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
+
+RWBuffer Buf;
Index: clang/test/AST/HLSL/Inputs/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch.hlsl
@@ -0,0 +1,4 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -30,6 +30,7 @@
 struct BuiltinTypeDeclBuilder {
   CXXRecordDecl *Record = nullptr;
   ClassTemplateDecl *Template = nullptr;
+  ClassTemplateDecl *PrevTemplate = nullptr;
   NamespaceDecl *HLSLNamespace = nullptr;
   llvm::StringMap Fields;
 
@@ -43,48 +44,46 @@
 ASTContext  = S.getASTContext();
 IdentifierInfo  = AST.Idents.get(Name, tok::TokenKind::identifier);
 
+LookupResult Result(S, , SourceLocation(), Sema::LookupTagName);
+CXXRecordDecl *PrevDecl = nullptr;
+if (S.LookupQualifiedName(Result, HLSLNamespace)) {
+  NamedDecl *Found = Result.getFoundDecl();
+  if (auto *TD = dyn_cast(Found)) {
+PrevDecl = TD->getTemplatedDecl();
+PrevTemplate = TD;
+  } else
+PrevDecl = dyn_cast(Found);
+  assert(PrevDecl && "Unexpected lookup result type.");
+}
+
+if (PrevDecl && PrevDecl->isCompleteDefinition()) {
+  Record = PrevDecl;
+  return;
+}
+
 Record = CXXRecordDecl::Create(AST, TagDecl::TagKind::TTK_Class,
HLSLNamespace, SourceLocation(),
-   SourceLocation(), , nullptr, true);
+   

[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-02 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem updated this revision to Diff 457734.
Navidem added a comment.
Herald added subscribers: cfe-commits, ormris, MaskRay.
Herald added a project: clang.

Updated docs, lit test, and added clang option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
@@ -0,0 +1,22 @@
+; Test -sanitizer-coverage-control-flow
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(i32* %a) sanitize_address {
+entry:
+  %tobool = icmp eq i32* %a, null
+  br i1 %tobool, label %if.end, label %if.then
+
+  if.then:  ; preds = %entry
+  store i32 0, i32* %a, align 4
+  call void @foo(i32* %a)
+  br label %if.end
+
+  if.end:   ; preds = %entry, %if.then
+  ret void
+}
+
+; CHECK: private constant [17 x i64*] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}@foo{{.*}}null{{.*}}null], section "__sancov_cfs", comdat($foo), align 8
+; CHECK:  @__start___sancov_cfs = extern_weak hidden global i64*
+; CHECK-NEXT: @__stop___sancov_cfs = extern_weak hidden global i64*
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -80,6 +80,7 @@
 const char SanCovCountersSectionName[] = "sancov_cntrs";
 const char SanCovBoolFlagSectionName[] = "sancov_bools";
 const char SanCovPCsSectionName[] = "sancov_pcs";
+const char SanCovCFsSectionName[] = "sancov_cfs";
 
 const char SanCovLowestStackName[] = "__sancov_lowest_stack";
 
@@ -147,6 +148,10 @@
   cl::desc("max stack depth tracing"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClCollectCF("sanitizer-coverage-control-flow",
+  cl::desc("collect control flow for each function"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -193,6 +198,7 @@
   !Options.Inline8bitCounters && !Options.StackDepth &&
   !Options.InlineBoolFlag && !Options.TraceLoads && !Options.TraceStores)
 Options.TracePCGuard = true; // TracePCGuard is default.
+  Options.CollectControlFlow |= ClCollectCF;
   return Options;
 }
 
@@ -212,6 +218,7 @@
 PostDomTreeCallback PDTCallback);
 
 private:
+  void CollectFunctionControlFlow(Function );
   void instrumentFunction(Function , DomTreeCallback DTCallback,
   PostDomTreeCallback PDTCallback);
   void InjectCoverageForIndirectCalls(Function ,
@@ -270,6 +277,7 @@
   GlobalVariable *Function8bitCounterArray;  // for inline-8bit-counters.
   GlobalVariable *FunctionBoolArray; // for inline-bool-flag.
   GlobalVariable *FunctionPCsArray;  // for pc-table.
+  GlobalVariable *FunctionCFsArray;  // for control flow table
   SmallVector GlobalsToAppendToUsed;
   SmallVector GlobalsToAppendToCompilerUsed;
 
@@ -378,6 +386,7 @@
   Function8bitCounterArray = nullptr;
   FunctionBoolArray = nullptr;
   FunctionPCsArray = nullptr;
+  FunctionCFsArray = nullptr;
   IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   IntptrPtrTy = PointerType::getUnqual(IntptrTy);
   Type *VoidTy = Type::getVoidTy(*C);
@@ -502,6 +511,10 @@
 IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
   }
+
+  if (Options.CollectControlFlow)
+CreateSecStartEnd(M, SanCovCFsSectionName, IntptrPtrTy);
+
   appendToUsed(M, GlobalsToAppendToUsed);
   appendToCompilerUsed(M, GlobalsToAppendToCompilerUsed);
   return true;
@@ -671,6 +684,9 @@
 }
   }
 
+  if (Options.CollectControlFlow)
+CollectFunctionControlFlow(F);
+
   InjectCoverage(F, BlocksToInstrument, 

[PATCH] D133229: [driver] Prune module-map related flags, if they are not going to be needed

2022-09-02 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

In D133229#3768101 , @rsmith wrote:

> I think the approach you're taking here is probably doomed -- too many things 
> in Clang depend on whether we've read module map files, and it seems unlikely 
> to me that you'll be able to catch all of them from the driver.

I see, the driver approach does seem like a non-starter, thank you for the 
feedback! This needs reevaluation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133229

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


[PATCH] D130867: [clang] adds builtin `std::invoke` and `std::invoke_r`

2022-09-02 Thread Konstantin Varlamov via Phabricator via cfe-commits
var-const added a comment.

Out of curiosity, would it be possible to do a benchmark to see how adding 
`_LIBCPP_NODEBUG` to `std::invoke` would compare to using builtins?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130867

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


[PATCH] D128490: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-09-02 Thread Volodymyr Sapsai 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 rG246c5a994b75: [ODRHash diagnostics] Transform method 
`ASTReader::diagnoseOdrViolations` into… (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128490

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -9186,19 +9186,6 @@
   }
 }
 
-std::string ASTReader::getOwningModuleNameForDiagnostic(const Decl *D) {
-  // If we know the owning module, use it.
-  if (Module *M = D->getImportedOwningModule())
-return M->getFullModuleName();
-
-  // Otherwise, use the name of the top-level module the decl is within.
-  if (ModuleFile *M = getOwningModuleFile(D))
-return M->ModuleName;
-
-  // Not from a module.
-  return {};
-}
-
 void ASTReader::finishPendingActions() {
   while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
  !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
@@ -9446,6 +9433,114 @@
   PendingMergedDefinitionsToDeduplicate.clear();
 }
 
+namespace clang {
+class ODRDiagsEmitter {
+public:
+  ODRDiagsEmitter(DiagnosticsEngine , const ASTContext ,
+  const LangOptions )
+  : Diags(Diags), Context(Context), LangOpts(LangOpts) {}
+
+  /// Diagnose ODR mismatch between 2 FunctionDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const FunctionDecl *FirstFunction,
+const FunctionDecl *SecondFunction) const;
+
+  /// Diagnose ODR mismatch between 2 EnumDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const EnumDecl *FirstEnum,
+const EnumDecl *SecondEnum) const;
+
+  /// Diagnose ODR mismatch between 2 CXXRecordDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  /// To compare 2 declarations with merged and identical definition data
+  /// you need to provide pre-merge definition data in \p SecondDD.
+  bool
+  diagnoseMismatch(const CXXRecordDecl *FirstRecord,
+   const CXXRecordDecl *SecondRecord,
+   const struct CXXRecordDecl::DefinitionData *SecondDD) const;
+
+  /// Get the best name we know for the module that owns the given
+  /// declaration, or an empty string if the declaration is not from a module.
+  static std::string getOwningModuleNameForDiagnostic(const Decl *D);
+
+private:
+  using DeclHashes = llvm::SmallVector, 4>;
+
+  // Used with err_module_odr_violation_mismatch_decl and
+  // note_module_odr_violation_mismatch_decl
+  // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
+  enum ODRMismatchDecl {
+EndOfClass,
+PublicSpecifer,
+PrivateSpecifer,
+ProtectedSpecifer,
+StaticAssert,
+Field,
+CXXMethod,
+TypeAlias,
+TypeDef,
+Var,
+Friend,
+FunctionTemplate,
+Other
+  };
+
+  struct DiffResult {
+const Decl *FirstDecl = nullptr, *SecondDecl = nullptr;
+ODRMismatchDecl FirstDiffType = Other, SecondDiffType = Other;
+  };
+
+  // If there is a diagnoseable difference, FirstDiffType and
+  // SecondDiffType will not be Other and FirstDecl and SecondDecl will be
+  // filled in if not EndOfClass.
+  static DiffResult FindTypeDiffs(DeclHashes ,
+  DeclHashes );
+
+  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const {
+return Diags.Report(Loc, DiagID);
+  }
+
+  // Use this to diagnose that an unexpected Decl was encountered
+  // or no difference was detected. This causes a generic error
+  // message to be emitted.
+  void diagnoseSubMismatchUnexpected(DiffResult ,
+ const NamedDecl *FirstRecord,
+ StringRef FirstModule,
+ const NamedDecl *SecondRecord,
+ StringRef SecondModule) const;
+
+  void diagnoseSubMismatchDifferentDeclKinds(DiffResult ,
+ const NamedDecl *FirstRecord,
+ StringRef FirstModule,
+ const NamedDecl *SecondRecord,
+ StringRef SecondModule) const;
+
+  bool diagnoseSubMismatchField(const NamedDecl *FirstRecord,
+StringRef FirstModule, StringRef SecondModule,
+const FieldDecl *FirstField,
+const FieldDecl *SecondField) const;
+
+  bool 

[clang] 246c5a9 - [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-09-02 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-09-02T16:20:05-07:00
New Revision: 246c5a994b753fb52b2d3b70687039afef7a106e

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

LOG: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` 
into a class `ODRDiagsEmitter`. NFC.

Preparing to use diagnostics about ODR hash mismatches outside of ASTReader.

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

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index c97301957cb60..89c7fb36aa57f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -260,6 +260,7 @@ class CXXRecordDecl : public RecordDecl {
   friend class ASTWriter;
   friend class DeclContext;
   friend class LambdaExpr;
+  friend class ODRDiagsEmitter;
 
   friend void FunctionDecl::setPure(bool);
   friend void TagDecl::startDefinition();

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 19a18a2ef4030..22f317dc6b3f7 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1845,10 +1845,6 @@ class ASTReader
   /// if the declaration is not from a module file.
   ModuleFile *getOwningModuleFile(const Decl *D);
 
-  /// Get the best name we know for the module that owns the given
-  /// declaration, or an empty string if the declaration is not from a module.
-  std::string getOwningModuleNameForDiagnostic(const Decl *D);
-
   /// Returns the source location for the decl \p ID.
   SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID);
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index e7dea40a16100..eef8f9fdb07f1 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -9186,19 +9186,6 @@ void ASTReader::visitTopLevelModuleMaps(
   }
 }
 
-std::string ASTReader::getOwningModuleNameForDiagnostic(const Decl *D) {
-  // If we know the owning module, use it.
-  if (Module *M = D->getImportedOwningModule())
-return M->getFullModuleName();
-
-  // Otherwise, use the name of the top-level module the decl is within.
-  if (ModuleFile *M = getOwningModuleFile(D))
-return M->ModuleName;
-
-  // Not from a module.
-  return {};
-}
-
 void ASTReader::finishPendingActions() {
   while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
  !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
@@ -9446,6 +9433,114 @@ void ASTReader::finishPendingActions() {
   PendingMergedDefinitionsToDeduplicate.clear();
 }
 
+namespace clang {
+class ODRDiagsEmitter {
+public:
+  ODRDiagsEmitter(DiagnosticsEngine , const ASTContext ,
+  const LangOptions )
+  : Diags(Diags), Context(Context), LangOpts(LangOpts) {}
+
+  /// Diagnose ODR mismatch between 2 FunctionDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const FunctionDecl *FirstFunction,
+const FunctionDecl *SecondFunction) const;
+
+  /// Diagnose ODR mismatch between 2 EnumDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const EnumDecl *FirstEnum,
+const EnumDecl *SecondEnum) const;
+
+  /// Diagnose ODR mismatch between 2 CXXRecordDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  /// To compare 2 declarations with merged and identical definition data
+  /// you need to provide pre-merge definition data in \p SecondDD.
+  bool
+  diagnoseMismatch(const CXXRecordDecl *FirstRecord,
+   const CXXRecordDecl *SecondRecord,
+   const struct CXXRecordDecl::DefinitionData *SecondDD) const;
+
+  /// Get the best name we know for the module that owns the given
+  /// declaration, or an empty string if the declaration is not from a module.
+  static std::string getOwningModuleNameForDiagnostic(const Decl *D);
+
+private:
+  using DeclHashes = llvm::SmallVector, 4>;
+
+  // Used with err_module_odr_violation_mismatch_decl and
+  // note_module_odr_violation_mismatch_decl
+  // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
+  enum ODRMismatchDecl {
+EndOfClass,
+PublicSpecifer,
+PrivateSpecifer,
+ProtectedSpecifer,
+StaticAssert,
+Field,
+CXXMethod,
+TypeAlias,
+TypeDef,
+Var,
+Friend,
+FunctionTemplate,
+Other
+  };
+
+  struct DiffResult {
+const Decl *FirstDecl = nullptr, *SecondDecl = 

[PATCH] D133229: [driver] Prune module-map related flags, if they are not going to be needed

2022-09-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I've landed some tests for the specific functionality that intends to use 
modules info under `-fno-modules` in b484256f59850e702df4d4532c5f31f478879bb9 
.

I think the approach you're taking here is probably doomed -- too many things 
in Clang depend on whether we've read module map files, and it seems unlikely 
to me that you'll be able to catch all of them from the driver. For example:

  $ touch a.h
  $ echo 'module a { private header "a.h" }' > module.modulemap
  $ echo '#include "a.h"' > b.cc
  $ clang -fmodule-map-file=module.modulemap b.cc
  b.cc:1:10: error: use of private header from outside its module: 'a.h' 
[-Wprivate-header]
  #include "a.h"
   ^
  1 error generated.

(and that error can be controlled by a `#pragma`, so you can't even do this if 
the driver sees `-Wno-private-header`).

I wonder if we could mark a `Module` as "used" whenever we use information from 
it, and treat module map files as dependencies of the current compilation only 
if they're used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133229

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


[clang] b484256 - Add driver test for -fmodule-name and -fmodule-map-file use without -fmodules.

2022-09-02 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-09-02T16:08:30-07:00
New Revision: b484256f59850e702df4d4532c5f31f478879bb9

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

LOG: Add driver test for -fmodule-name and -fmodule-map-file use without 
-fmodules.

Added: 


Modified: 
clang/test/Modules/declare-use1.cpp
clang/test/Modules/submodule-visibility.cpp

Removed: 




diff  --git a/clang/test/Modules/declare-use1.cpp 
b/clang/test/Modules/declare-use1.cpp
index 492f97a5ebe90..2763e0c5703e3 100644
--- a/clang/test/Modules/declare-use1.cpp
+++ b/clang/test/Modules/declare-use1.cpp
@@ -1,5 +1,8 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-cache-path=%t 
-fmodules-decluse -fmodule-name=XG -I %S/Inputs/declare-use %s -verify
+// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-decluse -fmodule-name=XG 
-I %S/Inputs/declare-use %s -verify
+//
+// Check these flags get properly passed through the driver even when 
-fmodules is disabled.
+// RUN: %clang -fimplicit-module-maps -fmodules-decluse -fmodule-name=XG -I 
%S/Inputs/declare-use -c -o /dev/null -Xclang -verify %s
 
 #include "g.h"
 #include "e.h"

diff  --git a/clang/test/Modules/submodule-visibility.cpp 
b/clang/test/Modules/submodule-visibility.cpp
index cae18d41ad7b5..f218c3399b5e1 100644
--- a/clang/test/Modules/submodule-visibility.cpp
+++ b/clang/test/Modules/submodule-visibility.cpp
@@ -2,7 +2,12 @@
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-I%S/Inputs/submodule-visibility -verify %s -DALLOW_NAME_LEAKAGE
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-local-submodule-visibility -fmodules-cache-path=%t 
-I%S/Inputs/submodule-visibility -verify %s -DIMPORT
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps 
-fmodules-local-submodule-visibility -fmodules-cache-path=%t -fmodule-name=x 
-I%S/Inputs/submodule-visibility -verify %s
-// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-local-submodule-visibility 
-fmodules-cache-path=%t -I%S/Inputs/submodule-visibility -verify %s
+// RUN: %clang_cc1 -fimplicit-module-maps -fmodules-local-submodule-visibility 
-I%S/Inputs/submodule-visibility -verify %s
+// RUN: %clang_cc1 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -verify %s
+//
+// Ensure the driver forwards the relevant flags when -fmodules is disabled.
+// RUN: %clang -fimplicit-module-maps -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -c -o 
/dev/null -Xclang -verify %s
+// RUN: %clang 
-fmodule-map-file=%S/Inputs/submodule-visibility/module.modulemap -Xclang 
-fmodules-local-submodule-visibility -I%S/Inputs/submodule-visibility -c -o 
/dev/null -Xclang -verify %s
 //
 // Explicit module builds.
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -emit-module 
-x c++-module-map %S/Inputs/submodule-visibility/module.modulemap 
-fmodule-name=other -o %t/other.pcm



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


[PATCH] D133066: fix a typo in comment of AddConversionCandidate

2022-09-02 Thread zhouyizhou via Phabricator via cfe-commits
zhouyizhou added a comment.

In D133066#3767146 , @aaron.ballman 
wrote:

> In D133066#3765503 , @zhouyizhou 
> wrote:
>
>> In D133066#3764384 , 
>> @aaron.ballman wrote:
>>
>>> The existing comment is correct according to my copy of the C++11 standard, 
>>> but the standard has changed since C++11 and those words no longer appear 
>>> in http://eel.is/c++draft/dcl.init.ref#5. Some more investigation is 
>>> needed, but I suspect the correct action to take here is to update the 
>>> comment based on the current standards wording or to see if there's a bug 
>>> because the code does not match the comment.
>>
>> thank Aaron for review my patch, 
>> I am a passionate beginner,
>
> Welcome to the community, we're glad to have you here!

Thank Aaron for your encouragement and guidance! Hope I can be some beneficial 
to the community.

>> this is a very good learning experience for me ;-)  I am looking forward to 
>> seeing the final change.
>
> Happy to help, but to be clear on the next steps: are you planning to do the 
> investigation work, or were you hoping someone else would do it?

As an amateur, this is a difficult job for me, but I can't help taking a try.

Following your guidance, I found the original C++11 document on the internet: 
https://raw.githubusercontent.com/yjlintw/book-Coding-Developer/master/%E6%A0%87%E5%87%86%E6%96%87%E6%A1%A3/ISO%20IEC%2014882%202011%20(C%2B%2B11).pdf
 
(the non ASCII code in URL means this document is maintained by a Chinese like 
me). 
And those words are there!

I am eager to do some investigation work in the elementary stage, but I believe 
the final work should be done by someone else.

Thanks again for your enthusiasm and your patience!

Cheers
Zhouyi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133066

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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-02 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

In D53847#3745415 , @royjacobson wrote:

> I looked at this a bit about a week ago and got it down to 3-4 tests failing, 
> but I'm not sure how much time I'll have to continue working on it. If one of 
> you wants to take over I'll be happy to send you what I've currently got. 
> @erichkeane @ilya-biryukov
>
> Also, do you know if having posted this patch is agreement for licensing this 
> code? Or do we need to get explicit agreement from the original author before 
> committing a version of this?

I'm currently looking at this patch; please do send me what you have.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

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


[clang-tools-extra] a7395b8 - [clang-tidy] Skip copy assignment operators with nonstandard return types

2022-09-02 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2022-09-02T22:43:39Z
New Revision: a7395b860bc247c9e4e917bf5786c04d4cccf1d7

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

LOG: [clang-tidy] Skip copy assignment operators with nonstandard return types

Skip copy assignment operators with nonstandard return types
since they cannot be defaulted.

Test plan: ninja check-clang-tools

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

Added: 


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

clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
index f321c0b2e693..2de677d2735f 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "UseEqualsDefaultCheck.h"
 #include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -247,7 +248,12 @@ void UseEqualsDefaultCheck::registerMatchers(MatchFinder 
*Finder) {
 // isCopyAssignmentOperator() allows the parameter to be
 // passed by value, and in this case it cannot be
 // defaulted.
-hasParameter(0, hasType(lValueReferenceType(
+hasParameter(0, hasType(lValueReferenceType())),
+// isCopyAssignmentOperator() allows non lvalue reference
+// return types, and in this case it cannot be defaulted.
+returns(qualType(hasCanonicalType(
+allOf(lValueReferenceType(pointee(type())),
+  unless(matchers::isReferenceToConst()))
   .bind(SpecialFunction),
   this);
 }

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index e0907b23c84c..7c91ea00dca8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,8 @@ Changes in existing checks
   check.
 
   The check now skips unions since in this case a default constructor with 
empty body
-  is not equivalent to the explicitly defaulted one. The check is restricted 
to c++11-or-later.
+  is not equivalent to the explicitly defaulted one. The check also skips copy 
assignment
+  operators with nonstandard return types. The check is restricted to 
c++11-or-later.
 
 Removed checks
 ^^

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
index 78a03f02eed5..70fc521ebb7a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
@@ -444,6 +444,13 @@ IL ::operator=(const WRT ) {
   return *this;
 }
 
+// Wrong return type.
+struct WRTConstRef {
+  const WRTConstRef  = (const WRTConstRef &) {
+return *this;
+  }
+};
+
 // Try-catch.
 struct ITC {
   ITC(const ITC )



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


[PATCH] D133006: [clang-tidy] Skip copy assignment operators with nonstandard return types

2022-09-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7395b860bc2: [clang-tidy] Skip copy assignment operators 
with nonstandard return types (authored by alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D133006?vs=456902=457725#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133006

Files:
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
@@ -444,6 +444,13 @@
   return *this;
 }
 
+// Wrong return type.
+struct WRTConstRef {
+  const WRTConstRef  = (const WRTConstRef &) {
+return *this;
+  }
+};
+
 // Try-catch.
 struct ITC {
   ITC(const ITC )
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,8 @@
   check.
 
   The check now skips unions since in this case a default constructor with 
empty body
-  is not equivalent to the explicitly defaulted one. The check is restricted 
to c++11-or-later.
+  is not equivalent to the explicitly defaulted one. The check also skips copy 
assignment
+  operators with nonstandard return types. The check is restricted to 
c++11-or-later.
 
 Removed checks
 ^^
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "UseEqualsDefaultCheck.h"
 #include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -247,7 +248,12 @@
 // isCopyAssignmentOperator() allows the parameter to be
 // passed by value, and in this case it cannot be
 // defaulted.
-hasParameter(0, hasType(lValueReferenceType(
+hasParameter(0, hasType(lValueReferenceType())),
+// isCopyAssignmentOperator() allows non lvalue reference
+// return types, and in this case it cannot be defaulted.
+returns(qualType(hasCanonicalType(
+allOf(lValueReferenceType(pointee(type())),
+  unless(matchers::isReferenceToConst()))
   .bind(SpecialFunction),
   this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
@@ -444,6 +444,13 @@
   return *this;
 }
 
+// Wrong return type.
+struct WRTConstRef {
+  const WRTConstRef  = (const WRTConstRef &) {
+return *this;
+  }
+};
+
 // Try-catch.
 struct ITC {
   ITC(const ITC )
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,8 @@
   check.
 
   The check now skips unions since in this case a default constructor with empty body
-  is not equivalent to the explicitly defaulted one. The check is restricted to c++11-or-later.
+  is not equivalent to the explicitly defaulted one. The check also skips copy assignment
+  operators with nonstandard return types. The check is restricted to c++11-or-later.
 
 Removed checks
 ^^
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "UseEqualsDefaultCheck.h"
 #include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
@@ -247,7 +248,12 @@
 // isCopyAssignmentOperator() allows the parameter to be
 // passed by value, and in this case it cannot be
 // defaulted.
-

[PATCH] D128490: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-09-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 457723.
vsapsai added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128490

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -9186,19 +9186,6 @@
   }
 }
 
-std::string ASTReader::getOwningModuleNameForDiagnostic(const Decl *D) {
-  // If we know the owning module, use it.
-  if (Module *M = D->getImportedOwningModule())
-return M->getFullModuleName();
-
-  // Otherwise, use the name of the top-level module the decl is within.
-  if (ModuleFile *M = getOwningModuleFile(D))
-return M->ModuleName;
-
-  // Not from a module.
-  return {};
-}
-
 void ASTReader::finishPendingActions() {
   while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
  !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
@@ -9446,6 +9433,114 @@
   PendingMergedDefinitionsToDeduplicate.clear();
 }
 
+namespace clang {
+class ODRDiagsEmitter {
+public:
+  ODRDiagsEmitter(DiagnosticsEngine , const ASTContext ,
+  const LangOptions )
+  : Diags(Diags), Context(Context), LangOpts(LangOpts) {}
+
+  /// Diagnose ODR mismatch between 2 FunctionDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const FunctionDecl *FirstFunction,
+const FunctionDecl *SecondFunction) const;
+
+  /// Diagnose ODR mismatch between 2 EnumDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  bool diagnoseMismatch(const EnumDecl *FirstEnum,
+const EnumDecl *SecondEnum) const;
+
+  /// Diagnose ODR mismatch between 2 CXXRecordDecl.
+  ///
+  /// Returns true if found a mismatch and diagnosed it.
+  /// To compare 2 declarations with merged and identical definition data
+  /// you need to provide pre-merge definition data in \p SecondDD.
+  bool
+  diagnoseMismatch(const CXXRecordDecl *FirstRecord,
+   const CXXRecordDecl *SecondRecord,
+   const struct CXXRecordDecl::DefinitionData *SecondDD) const;
+
+  /// Get the best name we know for the module that owns the given
+  /// declaration, or an empty string if the declaration is not from a module.
+  static std::string getOwningModuleNameForDiagnostic(const Decl *D);
+
+private:
+  using DeclHashes = llvm::SmallVector, 4>;
+
+  // Used with err_module_odr_violation_mismatch_decl and
+  // note_module_odr_violation_mismatch_decl
+  // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
+  enum ODRMismatchDecl {
+EndOfClass,
+PublicSpecifer,
+PrivateSpecifer,
+ProtectedSpecifer,
+StaticAssert,
+Field,
+CXXMethod,
+TypeAlias,
+TypeDef,
+Var,
+Friend,
+FunctionTemplate,
+Other
+  };
+
+  struct DiffResult {
+const Decl *FirstDecl = nullptr, *SecondDecl = nullptr;
+ODRMismatchDecl FirstDiffType = Other, SecondDiffType = Other;
+  };
+
+  // If there is a diagnoseable difference, FirstDiffType and
+  // SecondDiffType will not be Other and FirstDecl and SecondDecl will be
+  // filled in if not EndOfClass.
+  static DiffResult FindTypeDiffs(DeclHashes ,
+  DeclHashes );
+
+  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const {
+return Diags.Report(Loc, DiagID);
+  }
+
+  // Use this to diagnose that an unexpected Decl was encountered
+  // or no difference was detected. This causes a generic error
+  // message to be emitted.
+  void diagnoseSubMismatchUnexpected(DiffResult ,
+ const NamedDecl *FirstRecord,
+ StringRef FirstModule,
+ const NamedDecl *SecondRecord,
+ StringRef SecondModule) const;
+
+  void diagnoseSubMismatchDifferentDeclKinds(DiffResult ,
+ const NamedDecl *FirstRecord,
+ StringRef FirstModule,
+ const NamedDecl *SecondRecord,
+ StringRef SecondModule) const;
+
+  bool diagnoseSubMismatchField(const NamedDecl *FirstRecord,
+StringRef FirstModule, StringRef SecondModule,
+const FieldDecl *FirstField,
+const FieldDecl *SecondField) const;
+
+  bool diagnoseSubMismatchTypedef(const NamedDecl *FirstRecord,
+  StringRef FirstModule, StringRef SecondModule,
+  const TypedefNameDecl 

[PATCH] D131701: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties

2022-09-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 457720.
ahatanak added a comment.

Deactivate the cleanup that was pushed in `EmitParmDecl`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131701

Files:
  clang/lib/CodeGen/CGObjC.cpp
  clang/test/CodeGenObjC/nontrivial-c-struct-property.m

Index: clang/test/CodeGenObjC/nontrivial-c-struct-property.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/nontrivial-c-struct-property.m
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+typedef struct {
+  id x;
+} S0;
+
+@interface C {
+  S0 _p1;
+}
+@property(nonatomic) S0 nonatomic;
+@property S0 atomic0;
+@property S0 p1;
+-(S0)p1;
+-(void)setP1:(S0)s0;
+@end
+
+@implementation C
+-(S0)p1 {
+  return _p1;
+}
+-(void)setP1:(S0)s0 {
+  _p1 = s0;
+}
+@end
+
+// CHECK: %[[STRUCT_S0:.*]] = type { ptr }
+
+// Check that parameters of user-defined setters are destructed.
+
+// CHECK-LABEL: define internal void @"\01-[C setP1:]"(
+// CHECK: %[[S0:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: call void @__copy_assignment_8_8_s0(ptr %{{.*}}, ptr %[[S0]])
+// CHECK: call void @__destructor_8_s0(ptr %[[S0]])
+
+// CHECK: define internal i64 @"\01-[C nonatomic]"(ptr noundef %[[SELF:.*]], {{.*}})
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
+// CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
+// CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
+// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
+// CHECK: call void @__copy_constructor_8_8_s0(ptr %[[RETVAL]], ptr %[[ADD_PTR]])
+// CHECK-NOT: call
+// CHECK: ret i64
+
+// CHECK: define internal void @"\01-[C setNonatomic:]"(ptr noundef %[[SELF:.*]], {{.*}}, i64 %[[NONATOMIC_COERCE:.*]])
+// CHECK: %[[NONATOMIC:.*]] = alloca %[[STRUCT_S0]], align 8
+// CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
+// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_S0]], ptr %[[NONATOMIC]], i32 0, i32 0
+// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[NONATOMIC_COERCE]] to ptr
+// CHECK: store ptr %[[COERCE_VAL_IP]], ptr %[[COERCE_DIVE]], align 8
+// CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
+// CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
+// CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
+// CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
+// CHECK: call void @__move_assignment_8_8_s0(ptr %[[ADD_PTR]], ptr %[[NONATOMIC]])
+// CHECK-NOT: call
+// CHECK: ret void
+
+// CHECK-LABEL: define internal i64 @"\01-[C atomic0]"(
+// CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__copy_constructor_8_8_s0)
+// CHECK-NOT: call
+// CHECK: ret i64
+
+// CHECK-LABEL: define internal void @"\01-[C setAtomic0:]"(
+// CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__move_assignment_8_8_s0)
+// CHECK-NOT: call
+// CHECK: ret void
Index: clang/lib/CodeGen/CGObjC.cpp
===
--- clang/lib/CodeGen/CGObjC.cpp
+++ clang/lib/CodeGen/CGObjC.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/StmtObjC.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/BinaryFormat/MachO.h"
@@ -1115,6 +1116,23 @@
 const ObjCPropertyImplDecl *propImpl,
 const ObjCMethodDecl *GetterMethodDecl,
 llvm::Constant *AtomicHelperFn) {
+
+  ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl();
+
+  if (ivar->getType().isNonTrivialToPrimitiveCopy() == QualType::PCK_Struct) {
+if (!AtomicHelperFn) {
+  LValue Src =
+  EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), ivar, 0);
+  LValue Dst = MakeAddrLValue(ReturnValue, ivar->getType());
+  callCStructCopyConstructor(Dst, Src);
+} else {
+  ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl();
+  emitCPPObjectAtomicGetterCall(*this, ReturnValue.getPointer(), ivar,
+AtomicHelperFn);
+}
+return;
+  }
+
   // If there's a non-trivial 'get' expression, we just have to emit that.
   if (!hasTrivialGetExpr(propImpl)) {
 if (!AtomicHelperFn) {
@@ -1135,8 +1153,6 @@
   QualType propType = prop->getType();
   ObjCMethodDecl *getterMethod = propImpl->getGetterMethodDecl();
 
-  ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl();
-
   // 

Re: [PATCH] D133109: [LLVM][ARM] Remove options for armv2, 2A, 3 and 3M

2022-09-02 Thread Nick Desaulniers via cfe-commits
Arnd mentions on IRC:

1:38 AM  ndesaulniers: I just looked at the patch and found that the
list of supported targets still includes armv5 and armve (both without t),
which never existed in hardware and were removed from gcc a while ago
1:38 AM  might be good to take them out here as well
1:38 AM  the only v5 targets in gcc now are armv5t and armv5te
1:40 AM  not sure about armv5tej, which clang also accepts. I'm
pretty sure that neither clang not gcc actually supported 'j' instructions
as they are not publicly documented, but I don't know if gcc previously
accepted that name as an alias
1:41 AM  OTOH gcc does allow 'armv6j' and a few others that don't
really exist in hardware without additional letters

On Fri, Sep 2, 2022, 3:56 AM Renato Golin via Phabricator <
revi...@reviews.llvm.org> wrote:

> rengolin accepted this revision.
> rengolin added a comment.
>
> Agree. Even 10 years ago we made the concerted effort not to care about
> pre-v4, so I'd be a little surprised if people are actually using modern
> clang to target those platforms.
>
> Projects that rely on it can work in the same way as gcc and pick an older
> version of the toolchains.
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D133109/new/
>
> https://reviews.llvm.org/D133109
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131187: [analyzer] Add more information to the Exploded Graph

2022-09-02 Thread Domján Dániel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb5147937b2a9: [analyzer] Add more information to the 
Exploded Graph (authored by isuckatcs).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131187

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
  clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/program_state_traits.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/topology.dot
  clang/test/Analysis/expr-inspection.c
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -261,48 +261,74 @@
 class ProgramState:
 def __init__(self, state_id, json_ps):
 logging.debug('Adding ProgramState ' + str(state_id))
+
+store_key = 'store'
+env_key = 'environment'
+constraints_key = 'constraints'
+dyn_ty_key = 'dynamic_types'
+ctor_key = 'constructing_objects'
+ind_key = 'index_of_element'
+init_loop_key = 'pending_init_loops'
+dtor_key = 'pending_destructors'
+msg_key = 'checker_messages'
 
 if json_ps is None:
 json_ps = {
-'store': None,
-'environment': None,
-'constraints': None,
-'dynamic_types': None,
-'constructing_objects': None,
-'index_of_element': None,
-'checker_messages': None
+store_key: None,
+env_key: None,
+constraints_key: None,
+dyn_ty_key: None,
+ctor_key: None,
+ind_key: None,
+init_loop_key: None,
+dtor_key: None,
+msg_key: None
 }
 
 self.state_id = state_id
 
-self.store = Store(json_ps['store']) \
-if json_ps['store'] is not None else None
+self.store = Store(json_ps[store_key]) \
+if json_ps[store_key] is not None else None
 
 self.environment = \
-GenericEnvironment(json_ps['environment']['items']) \
-if json_ps['environment'] is not None else None
+GenericEnvironment(json_ps[env_key]['items']) \
+if json_ps[env_key] is not None else None
 
 self.constraints = GenericMap([
-(c['symbol'], c['range']) for c in json_ps['constraints']
-]) if json_ps['constraints'] is not None else None
+(c['symbol'], c['range']) for c in json_ps[constraints_key]
+]) if json_ps[constraints_key] is not None else None
 
 self.dynamic_types = GenericMap([
 (t['region'], '%s%s' % (t['dyn_type'],
 ' (or a sub-class)'
 if t['sub_classable'] else ''))
-for t in json_ps['dynamic_types']]) \
-if json_ps['dynamic_types'] is not None else None
+for t in json_ps[dyn_ty_key]]) \
+if json_ps[dyn_ty_key] is not None else None
+
+self.checker_messages = CheckerMessages(json_ps[msg_key]) \
+if json_ps[msg_key] is not None else None
+
+# State traits
+# 
+# For traits we always check if a key exists because if a trait
+# has no imformation, nothing will be printed in the .dot file 
+# we parse. 
 
 self.constructing_objects = \
-GenericEnvironment(json_ps['constructing_objects']) \
-if json_ps['constructing_objects'] is not None else None
+GenericEnvironment(json_ps[ctor_key]) \
+if ctor_key in json_ps and json_ps[ctor_key] is not None else None
 
 self.index_of_element = \
-GenericEnvironment(json_ps['index_of_element']) \
-if json_ps['index_of_element'] is not None else None
+GenericEnvironment(json_ps[ind_key]) \
+if ind_key in json_ps and json_ps[ind_key] is not None else None
+
+self.pending_init_loops = \
+GenericEnvironment(json_ps[init_loop_key]) \
+if init_loop_key in json_ps and json_ps[init_loop_key] is not 

[clang] b514793 - [analyzer] Add more information to the Exploded Graph

2022-09-02 Thread via cfe-commits

Author: isuckatcs
Date: 2022-09-03T00:21:05+02:00
New Revision: b5147937b2a9ffdc12110a5df5ba4d482f83d2a8

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

LOG: [analyzer] Add more information to the Exploded Graph

This patch dumps every state trait in the egraph. Also
the empty state traits are no longer dumped, instead
they are treated as null by the egraph rewriter script,
which solves reverse compatibility issues.

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

Added: 
clang/test/Analysis/exploded-graph-rewriter/program_state_traits.dot

Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
clang/test/Analysis/exploded-graph-rewriter/constraints.dot
clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
clang/test/Analysis/exploded-graph-rewriter/environment.dot
clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
clang/test/Analysis/exploded-graph-rewriter/store.dot
clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
clang/test/Analysis/exploded-graph-rewriter/topology.dot
clang/test/Analysis/expr-inspection.c
clang/utils/analyzer/exploded-graph-rewriter.py

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 656a7c1fe590a..99aa4c506f4ee 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -693,7 +693,7 @@ printObjectsUnderConstructionJson(raw_ostream , 
ProgramStateRef State,
   continue;
 
 if (!HasItem) {
-  Out << "[" << NL;
+  Out << '[' << NL;
   HasItem = true;
 }
 
@@ -724,12 +724,11 @@ printObjectsUnderConstructionJson(raw_ostream , 
ProgramStateRef State,
 
 static void printIndicesOfElementsToConstructJson(
 raw_ostream , ProgramStateRef State, const char *NL,
-const LocationContext *LCtx, const ASTContext ,
-unsigned int Space = 0, bool IsDot = false) {
+const LocationContext *LCtx, unsigned int Space = 0, bool IsDot = false) {
   using KeyT = std::pair;
 
-  PrintingPolicy PP =
-  LCtx->getAnalysisDeclContext()->getASTContext().getPrintingPolicy();
+  const auto  = LCtx->getAnalysisDeclContext()->getASTContext();
+  PrintingPolicy PP = Context.getPrintingPolicy();
 
   ++Space;
   bool HasItem = false;
@@ -742,7 +741,7 @@ static void printIndicesOfElementsToConstructJson(
   continue;
 
 if (!HasItem) {
-  Out << "[" << NL;
+  Out << '[' << NL;
   HasItem = true;
 }
 
@@ -761,17 +760,17 @@ static void printIndicesOfElementsToConstructJson(
 const Expr *E = Key.first;
 Out << "\"stmt_id\": " << E->getID(Context);
 
-// Kind - hack to display the current index
-Out << ", \"kind\": \"Cur: " << Value - 1 << "\"";
+// Kind
+Out << ", \"kind\": null";
 
 // Pretty-print
 Out << ", \"pretty\": ";
-Out << "\"" << E->getStmtClassName() << " "
+Out << "\"" << E->getStmtClassName() << ' '
 << E->getSourceRange().printToString(Context.getSourceManager()) << " 
'"
 << QualType::getAsString(E->getType().split(), PP);
 Out << "'\"";
 
-Out << ", \"value\": \"Next: " << Value << "\" }";
+Out << ", \"value\": \"Current index: " << Value - 1 << "\" }";
 
 if (Key != LastKey)
   Out << ',';
@@ -785,40 +784,168 @@ static void printIndicesOfElementsToConstructJson(
   }
 }
 
-void ExprEngine::printJson(raw_ostream , ProgramStateRef State,
-   const LocationContext *LCtx, const char *NL,
-   unsigned int Space, bool IsDot) const {
-  Indent(Out, Space, IsDot) << "\"constructing_objects\": ";
+static void printPendingInitLoopJson(raw_ostream , ProgramStateRef State,
+ const char *NL,
+ const LocationContext *LCtx,
+ unsigned int Space = 0,
+ bool IsDot = false) {
+  using KeyT = std::pair;
 
-  if (LCtx && !State->get().isEmpty()) {
-++Space;
-Out << '[' << NL;
-LCtx->printJson(Out, NL, Space, IsDot, [&](const LocationContext *LC) {
-  printObjectsUnderConstructionJson(Out, State, NL, LC, Space, IsDot);
-});
+  const auto  = LCtx->getAnalysisDeclContext()->getASTContext();
+  PrintingPolicy PP = Context.getPrintingPolicy();
 
---Space;
-Indent(Out, Space, IsDot) << "]," << NL; // End of "constructing_objects".
-  } else {
-Out << "null," << NL;
+  ++Space;
+  bool HasItem = false;
+
+  // Store the last key.
+  KeyT LastKey;
+  for (const auto  : State->get()) {
+const 

[PATCH] D132998: [clang-tidy] Restrict use-equals-default to c++11-or-later

2022-09-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47dbacbc8ae2: [clang-tidy] Restrict use-equals-default to 
c++11-or-later (authored by alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D132998?vs=456876=457715#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132998

Files:
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy -std=c++98 %s modernize-use-equals-default %t
+
+struct S {
+  S() {}
+  // CHECK-FIXES: S() {}
+  ~S() {}
+  // CHECK-FIXES: ~S() {}
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,7 @@
   check.
 
   The check now skips unions since in this case a default constructor with 
empty body
-  is not equivalent to the explicitly defaulted one.
+  is not equivalent to the explicitly defaulted one. The check is restricted 
to c++11-or-later.
 
 Removed checks
 ^^
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
@@ -38,7 +38,7 @@
 public:
   UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions ) const override {
-return LangOpts.CPlusPlus;
+return LangOpts.CPlusPlus11;
   }
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy -std=c++98 %s modernize-use-equals-default %t
+
+struct S {
+  S() {}
+  // CHECK-FIXES: S() {}
+  ~S() {}
+  // CHECK-FIXES: ~S() {}
+};
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,7 @@
   check.
 
   The check now skips unions since in this case a default constructor with empty body
-  is not equivalent to the explicitly defaulted one.
+  is not equivalent to the explicitly defaulted one. The check is restricted to c++11-or-later.
 
 Removed checks
 ^^
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
@@ -38,7 +38,7 @@
 public:
   UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions ) const override {
-return LangOpts.CPlusPlus;
+return LangOpts.CPlusPlus11;
   }
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 47dbacb - [clang-tidy] Restrict use-equals-default to c++11-or-later

2022-09-02 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2022-09-02T22:19:11Z
New Revision: 47dbacbc8ae2c13f970096814de8f677d80859af

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

LOG: [clang-tidy] Restrict use-equals-default to c++11-or-later

Restrict use-equals-default to c++11-or-later.

Test plan: ninja check-all

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp

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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
index a992177522f75..4ffed8c406481 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
@@ -38,7 +38,7 @@ class UseEqualsDefaultCheck : public ClangTidyCheck {
 public:
   UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions ) const override {
-return LangOpts.CPlusPlus;
+return LangOpts.CPlusPlus11;
   }
   void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 55c8c341bff3a..e0907b23c84c7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,7 @@ Changes in existing checks
   check.
 
   The check now skips unions since in this case a default constructor with 
empty body
-  is not equivalent to the explicitly defaulted one.
+  is not equivalent to the explicitly defaulted one. The check is restricted 
to c++11-or-later.
 
 Removed checks
 ^^

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
new file mode 100644
index 0..d43c1e58c2606
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy -std=c++98 %s modernize-use-equals-default %t
+
+struct S {
+  S() {}
+  // CHECK-FIXES: S() {}
+  ~S() {}
+  // CHECK-FIXES: ~S() {}
+};



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


[PATCH] D132911: [clang-format] Fix annotating when deleting array of pointers

2022-09-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3bbdf06b2827: [clang-format] Fix annotating when deleting 
array of pointers (authored by jackh jackhuang1...@gmail.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132911

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -120,6 +120,17 @@
   Tokens = annotate("int i = int{42} * 2;");
   EXPECT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[7], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("delete[] *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] **ptr;");
+  EXPECT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[4], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] *(ptr);");
+  EXPECT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10535,6 +10535,11 @@
"} & = {};",
Style);
 
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("delete[] *ptr;", Style);
+  verifyFormat("delete[] **ptr;", Style);
+  verifyFormat("delete[] *(ptr);", Style);
+
   verifyIndependentOfContext("MACRO(int *i);");
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2372,6 +2372,9 @@
 !PrevToken->MatchingParen)
   return TT_PointerOrReference;
 
+if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
+  return TT_UnaryOperator;
+
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
tok::kw_false, tok::r_brace)) {


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -120,6 +120,17 @@
   Tokens = annotate("int i = int{42} * 2;");
   EXPECT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[7], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("delete[] *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] **ptr;");
+  EXPECT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[4], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] *(ptr);");
+  EXPECT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10535,6 +10535,11 @@
"} & = {};",
Style);
 
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("delete[] *ptr;", Style);
+  verifyFormat("delete[] **ptr;", Style);
+  verifyFormat("delete[] *(ptr);", Style);
+
   verifyIndependentOfContext("MACRO(int *i);");
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2372,6 +2372,9 @@
 !PrevToken->MatchingParen)
   return TT_PointerOrReference;
 
+if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
+  return TT_UnaryOperator;
+
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
tok::kw_false, tok::r_brace)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3bbdf06 - [clang-format] Fix annotating when deleting array of pointers

2022-09-02 Thread via cfe-commits

Author: jackh
Date: 2022-09-03T05:56:49+08:00
New Revision: 3bbdf06b28275a56ad36a844d271d84956d1d7e9

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

LOG: [clang-format] Fix annotating when deleting array of pointers

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

The token `*` below should be annotated as `UnaryOperator`.

```
delete[] *ptr;
```

Reviewed By: owenpan, MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 94b897a962056..2a64a3bb9c413 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2372,6 +2372,9 @@ class AnnotatingParser {
 !PrevToken->MatchingParen)
   return TT_PointerOrReference;
 
+if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
+  return TT_UnaryOperator;
+
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
tok::kw_false, tok::r_brace)) {

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 5d1129b851dff..57a6d83578f1d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -10535,6 +10535,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
"} & = {};",
Style);
 
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("delete[] *ptr;", Style);
+  verifyFormat("delete[] **ptr;", Style);
+  verifyFormat("delete[] *(ptr);", Style);
+
   verifyIndependentOfContext("MACRO(int *i);");
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 4e9d5c77f99e5..6a10d679fbc72 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -120,6 +120,17 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
   Tokens = annotate("int i = int{42} * 2;");
   EXPECT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[7], tok::star, TT_BinaryOperator);
+
+  Tokens = annotate("delete[] *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] **ptr;");
+  EXPECT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+  EXPECT_TOKEN(Tokens[4], tok::star, TT_UnaryOperator);
+  Tokens = annotate("delete[] *(ptr);");
+  EXPECT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {



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


[PATCH] D133197: [clang] Fix crash when parsing scanf format string with missing arguments

2022-09-02 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133197

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


[PATCH] D133236: [Clang][Tools] Use utf-8 for JSON object load

2022-09-02 Thread Amy Wang via Phabricator via cfe-commits
kaitingwang created this revision.
kaitingwang added reviewers: djasper, sammccall, ldrumm, vsk.
kaitingwang added a project: clang-format.
Herald added subscribers: Naghasan, Anastasia.
Herald added a project: All.
kaitingwang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

>From Python 3.6 and above, it should be able to automatically select a 
>decoding for the json.loads.  However, with a vim encoding that defaults to 
>utf-8, the clang-format.py runs into the following error.  The patch explicit 
>specifies to use use utf-8 decoding for head.

Traceback (most recent call last):

  File "", line 1, in 
  File 
"/home/k00375917/sycl_workspace/llvm/clang/tools/clang-format/clang-format.py", 
line 156, in 
main()
  File 
"/home/k00375917/sycl_workspace/llvm/clang/tools/clang-format/clang-format.py", 
line 137, in main
header = json.loads(header)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
s.__class__.__name__))

TypeError: the JSON object must be str, not 'bytes'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133236

Files:
  clang/tools/clang-format/clang-format.py


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -10,9 +10,9 @@
 # imap  :py3f /clang-format.py
 #   endif
 #
-# The if-elseif-endif conditional should pick either the python3 or python2 
+# The if-elseif-endif conditional should pick either the python3 or python2
 # integration depending on your vim setup.
-# 
+#
 # The first mapping enables clang-format for NORMAL and VISUAL mode, the second
 # mapping adds support for INSERT mode. Change "C-I" to another binding if you
 # need clang-format on a different key (C-I stands for Ctrl+i).
@@ -134,7 +134,7 @@
 )
   else:
 header, content = stdout.split(b'\n', 1)
-header = json.loads(header)
+header = json.loads(header.decode('utf-8'))
 # Strip off the trailing newline (added above).
 # This maintains trailing empty lines present in the buffer if
 # the -lines specification requests them to remain unchanged.


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -10,9 +10,9 @@
 # imap  :py3f /clang-format.py
 #   endif
 #
-# The if-elseif-endif conditional should pick either the python3 or python2 
+# The if-elseif-endif conditional should pick either the python3 or python2
 # integration depending on your vim setup.
-# 
+#
 # The first mapping enables clang-format for NORMAL and VISUAL mode, the second
 # mapping adds support for INSERT mode. Change "C-I" to another binding if you
 # need clang-format on a different key (C-I stands for Ctrl+i).
@@ -134,7 +134,7 @@
 )
   else:
 header, content = stdout.split(b'\n', 1)
-header = json.loads(header)
+header = json.loads(header.decode('utf-8'))
 # Strip off the trailing newline (added above).
 # This maintains trailing empty lines present in the buffer if
 # the -lines specification requests them to remain unchanged.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-09-02 Thread Palmer Dabbelt via Phabricator via cfe-commits
palmer-dabbelt added a comment.

I was talking to @reames about this.  The spec has changed since I posted these 
patches: there's now two instructions (wrs.nto and wrs.sto) and there's no 
longer a register to encode the timeout.


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

https://reviews.llvm.org/D128235

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


[PATCH] D125419: [Arm64EC 7/?] clang side of Arm64EC varargs ABI.

2022-09-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2457
+/*IsVectorCall=*/false, /*IsRegCall=*/false);
+  }
+

rjmccall wrote:
> Hmm.  Doesn't EC ABI lowering need to preserve this same state, or else 
> you'll get incompatibilities when you exhaust SSE registers?
> 
> Should you just be calling over to this at a higher-level point, like in 
> `computeInfo`?
If both IsVectorCall and IsRegCall are false, WinX86_64ABIInfo doesn't use 
FreeSSERegs, so we don't need to preserve its state.  There isn't any other 
relevant state to preserve.

Return values follow the Arm64 ABI rules, not the x64 rules, so using 
computeInfo() as an entry point doesn't really make sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125419

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1687
+def fexperimental_sanitize_metadata_EQ : CommaJoined<["-"], 
"fexperimental-sanitize-metadata=">,
+  Group,
+  HelpText<"Specify the type of metadata to emit for binary analysis 
sanitizers">;

You can use f_Group instead of f_clang_Group. There are so many clang-specific 
(not in gcc) options, so the group is not useful.

Remove `NoXarchOption`.



Comment at: clang/test/Driver/fsanitize-metadata.c:1
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all 
-fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata

 -fno-experimental-sanitize-metadata= works on bitmasks. You can change this 
run line to remove one bit instead of all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

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


[PATCH] D133082: [clang] Implement setting crash_diagnostics_dir through env variable

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 457685.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133082

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir-3.c
  libcxx/utils/ci/buildkite-pipeline.yml


Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -369,10 +369,12 @@
 artifact_paths:
   - "**/test-results.xml"
   - "**/*.abilist"
+  - "**/crash_diagnostics/*"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}"
+CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
   queue: "libcxx-builders"
   os: "linux"
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: not env CLANG_CRASH_DIAGNOSTICS_DIR=%t %clang -c %s -o - 2>&1 | 
FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: 
{{.*}}{{/|\\}}crash-diagnostics-dir-3.c.tmp{{(/|\\).*}}.c
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5413,15 +5413,18 @@
StringRef BoundArch) const {
   SmallString<128> TmpName;
   Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
-  if (CCGenDiagnostics && A) {
-SmallString<128> CrashDirectory(A->getValue());
-if (!getVFS().exists(CrashDirectory))
-  llvm::sys::fs::create_directories(CrashDirectory);
-llvm::sys::path::append(CrashDirectory, Prefix);
+  Optional CrashDirectory =
+  CCGenDiagnostics && A
+  ? std::string(A->getValue())
+  : llvm::sys::Process::GetEnv("CLANG_CRASH_DIAGNOSTICS_DIR");
+  if (CrashDirectory) {
+if (!getVFS().exists(*CrashDirectory))
+  llvm::sys::fs::create_directories(*CrashDirectory);
+SmallString<128> Path(*CrashDirectory);
+llvm::sys::path::append(Path, Prefix);
 const char *Middle = !Suffix.empty() ? "-%%." : "-%%";
-std::error_code EC = llvm::sys::fs::createUniqueFile(
-CrashDirectory + Middle + Suffix, TmpName);
-if (EC) {
+if (std::error_code EC =
+llvm::sys::fs::createUniqueFile(Path + Middle + Suffix, TmpName)) {
   Diag(clang::diag::err_unable_to_make_temp) << EC.message();
   return "";
 }
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -687,6 +687,11 @@
   Specify where to write the crash diagnostics files; defaults to the
   usual location for temporary files.
 
+.. envvar:: CLANG_CRASH_DIAGNOSTICS_DIR=
+
+   Like :option:`-fcrash-diagnostics-dir=`, specifies where to write the
+   crash diagnostics files, but with lower precedence than the option.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -133,6 +133,9 @@
 
 Non-comprehensive list of changes in this release
 -
+- It's now possible to set the crash diagnostics directory through
+  the environment variable ``CLANG_CRASH_DIAGNOSTICS_DIR``.
+  The ``-fcrash-diagnostics-dir`` flag takes precedence.
 
 New Compiler Flags
 --


Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -369,10 +369,12 @@
 artifact_paths:
   - "**/test-results.xml"
   - "**/*.abilist"
+  - "**/crash_diagnostics/*"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}"
+CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
   queue: "libcxx-builders"
   os: "linux"
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: not env 

[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-02 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:78
+  // ExternalAST path.
+  // PrevRecord->setHasExternalLexicalStorage();
+  if (PrevRecord->isCompleteDefinition()) {

If comment this line out. The test will pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

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


[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-02 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 457684.
python3kgae added a comment.

Rebase to use MultiplexExternalSemaSource.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/Inputs/pch.hlsl
  clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
  clang/test/AST/HLSL/pch.hlsl
  clang/test/AST/HLSL/pch_with_buf.hlsl

Index: clang/test/AST/HLSL/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// Make sure buffer defined in PCH works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}}  col:17 imported Buf 'RWBuffer':'hlsl::RWBuffer<>'
+// Make sure declare a RWBuffer in current file works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buf2;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s \
+// RUN: | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buffer;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
@@ -0,0 +1,6 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
+
+RWBuffer Buf;
Index: clang/test/AST/HLSL/Inputs/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch.hlsl
@@ -0,0 +1,4 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -23,6 +23,17 @@
 using namespace clang;
 using namespace hlsl;
 
+static NamedDecl *findDecl(Sema , IdentifierInfo ,
+   Sema::LookupNameKind Kind) {
+  DeclarationNameInfo NameInfo{DeclarationName{}, SourceLocation()};
+  LookupResult R(S, NameInfo, Kind);
+  S.LookupName(R, S.getCurScope());
+  NamedDecl *D = nullptr;
+  if (!R.isAmbiguous() && !R.empty())
+D = R.getRepresentativeDecl();
+  return D;
+}
+
 namespace {
 
 struct TemplateParameterListBuilder;
@@ -30,10 +41,16 @@
 struct BuiltinTypeDeclBuilder {
   CXXRecordDecl *Record = nullptr;
   ClassTemplateDecl *Template = nullptr;
+  ClassTemplateDecl *PrevTemplate = nullptr;
   NamespaceDecl *HLSLNamespace = nullptr;
   llvm::StringMap Fields;
+  bool ReusePrevDecl = false;
 
   BuiltinTypeDeclBuilder(CXXRecordDecl *R) : Record(R) {
+if (Record->isCompleteDefinition()) {
+  ReusePrevDecl = true;
+  return;
+}
 Record->startDefinition();
 Template = Record->getDescribedClassTemplate();
   }
@@ -42,6 +59,30 @@
   : HLSLNamespace(Namespace) {
 ASTContext  = S.getASTContext();
 IdentifierInfo  = AST.Idents.get(Name, 

[PATCH] D133088: [Clang] Fix wrong diagnostic for scope identifier with internal linkage

2022-09-02 Thread pmor via Phabricator via cfe-commits
pmor13 added a comment.

Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133088

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


[PATCH] D132801: [driver] Additional ignoring of module-map related flags, if modules are disabled

2022-09-02 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

In D132801#3761253 , @akyrtzi wrote:

> In D132801#3760014 , @rsmith wrote:
>
>> This doesn't look right to me -- we still use module maps when modules are 
>> disabled to enforce layering checking, and when 
>> `-fmodules-local-submodule-visibility` is enabled but `-fmodules` is 
>> disabled we'll use them to provide modular semantics without pre-building 
>> modules. I'm going to revert.
>
> Sorry, I wasn't aware of that. Could `-fmodule-map-file=` be pruned out when 
> `-fmodules-local-submodule-visibility` or `-fmodules-decluse` are not enabled?

I've opened https://reviews.llvm.org/D133229 for your consideration, let me 
know whether this addresses your concerns 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132801

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


[PATCH] D133229: [driver] Prune module-map related flags, if they are not going to be needed

2022-09-02 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This is follow-up from https://reviews.llvm.org/D132801, but taking into 
account the conditions
where the module-map flags are still used even when `-fmodules` is disabled.

This useful for removing unnecessary input dependencies from the cc1 invocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133229

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules.m


Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -75,8 +75,13 @@
 // RUN: %clang -fno-modules -fbuild-session-timestamp=123 -### %s 2>&1 | 
FileCheck -check-prefix=SESSION_FLAG %s
 // SESSION_FLAG-NOT: -fbuild-session-timestamp
 
-// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session -### %s 
2>&1 | FileCheck -check-prefix=VALIDATE_ONCE_FLAG %s
-// VALIDATE_ONCE_FLAG-NOT: -fmodules-validate-once-per-build-session
-
-// RUN: %clang -fno-modules -fmodules-validate-system-headers -### %s 2>&1 | 
FileCheck -check-prefix=VALIDATE_SYSTEM_FLAG %s
-// VALIDATE_SYSTEM_FLAG-NOT: -fmodules-validate-system-headers
+// RUN: %clang -fno-modules -fmodules-validate-once-per-build-session 
-fmodules-validate-system-headers -fmodule-map-file=module.modulemap \
+// RUN:   -### %s 2>&1 | FileCheck -check-prefix=IGNORED_FLAGS %s
+// IGNORED_FLAGS-NOT: -fmodules-validate-once-per-build-session
+// IGNORED_FLAGS-NOT: -fmodules-validate-system-headers
+// IGNORED_FLAGS-NOT: -fmodule-map-file
+
+// RUN: %clang -fno-modules -fmodules-decluse 
-fmodule-map-file=module.modulemap -### %s 2>&1 | FileCheck 
-check-prefix=MMAPFILE %s
+// RUN: %clang -fno-modules -fmodules-strict-decluse 
-fmodule-map-file=module.modulemap -### %s 2>&1 | FileCheck 
-check-prefix=MMAPFILE %s
+// RUN: %clang -fno-modules -Xclang -fmodules-local-submodule-visibility 
-fmodule-map-file=module.modulemap -### %s 2>&1 | FileCheck 
-check-prefix=MMAPFILE %s
+// MMAPFILE: -fmodule-map-file
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3735,23 +3735,47 @@
   CmdArgs.push_back("-fvalidate-ast-input-files-content");
   }
 
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
-
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fbuiltin-module-map can be used to load the clang
-  // builtin headers modulemap file.
-  if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
-SmallString<128> BuiltinModuleMap(D.ResourceDir);
-llvm::sys::path::append(BuiltinModuleMap, "include");
-llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
-if (llvm::sys::fs::exists(BuiltinModuleMap))
-  CmdArgs.push_back(
-  Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+  // Check whether any "-fmodule-map-file=" flags are relevant or not. This is
+  // useful for pruning the cc1 arguments and removing unnecessary input
+  // dependencies.
+  bool ModuleMapsAreRelevant = [&]() -> bool {
+if (HaveModules)
+  return true;
+if (Args.hasFlag(options::OPT_fmodules_decluse,
+ options::OPT_fno_modules_decluse, false) ||
+Args.hasFlag(options::OPT_fmodules_strict_decluse,
+ options::OPT_fno_modules_strict_decluse, false))
+  return true;
+for (auto Arg : Args.filtered(options::OPT_Xclang)) {
+  if (StringRef(Arg->getValue()) == "-fmodules-local-submodule-visibility")
+return true;
+}
+return false;
+  }();
+
+  if (ModuleMapsAreRelevant) {
+// -fmodule-name specifies the module that is currently being built (or
+// used for header checking by -fmodule-maps).
+Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+// -fmodule-map-file can be used to specify files containing module
+// definitions.
+Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+// -fbuiltin-module-map can be used to load the clang
+// builtin headers modulemap file.
+if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
+  SmallString<128> BuiltinModuleMap(D.ResourceDir);
+  llvm::sys::path::append(BuiltinModuleMap, "include");
+  llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
+  if (llvm::sys::fs::exists(BuiltinModuleMap))
+CmdArgs.push_back(
+Args.MakeArgString("-fmodule-map-file=" + BuiltinModuleMap));
+}
+  } else {
+Args.ClaimAllArgs(options::OPT_fmodule_name_EQ);
+

[PATCH] D131268: [HLSL] Generate buffer subscript operators

2022-09-02 Thread Chris Bieneman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00ecacca7d90: [HLSL] Generate buffer subscript operators 
(authored by beanz).

Changed prior to commit:
  https://reviews.llvm.org/D131268?vs=456774=457681#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131268

Files:
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/HLSL/RWBuffer-AST.hlsl
  clang/test/CodeGenHLSL/buffer-array-operator.hlsl

Index: clang/test/CodeGenHLSL/buffer-array-operator.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/buffer-array-operator.hlsl
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+const RWBuffer In;
+RWBuffer Out;
+
+void fn(int Idx) {
+  Out[Idx] = In[Idx];
+}
+
+// This test is intended to verify reasonable code generation of the subscript
+// operator. In this test case we should be generating both the const and
+// non-const operators so we verify both cases.
+
+// Non-const comes first.
+// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QBAAAMI@Z"
+// CHECK: %this1 = load ptr, ptr %this.addr, align 4
+// CHECK-NEXT: %h = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0
+// CHECK-NEXT: %0 = load ptr, ptr %h, align 4
+// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4
+// CHECK-NEXT: %arrayidx = getelementptr inbounds float, ptr %0, i32 %1
+// CHECK-NEXT: ret ptr %arrayidx
+
+// Const comes next, and returns the pointer instead of the value.
+// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QMI@Z"
+// CHECK: %this1 = load ptr, ptr %this.addr, align 4
+// CHECK-NEXT: %h = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0
+// CHECK-NEXT: %0 = load ptr, ptr %h, align 4
+// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4
+// CHECK-NEXT: %arrayidx = getelementptr inbounds float, ptr %0, i32 %1
+// CHECK-NEXT: ret ptr %arrayidx
Index: clang/test/AST/HLSL/RWBuffer-AST.hlsl
===
--- clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -39,11 +39,30 @@
 
 // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit UAV
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'void *'
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'element_type *'
+
+// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  operator[] 'element_type  (unsigned int) const'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type' lvalue
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type *' lvalue ->h 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'const RWBuffer *' implicit this
+// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
+
+// CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  operator[] 'element_type &(unsigned int)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type' lvalue
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'element_type *' lvalue ->h 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'RWBuffer *' implicit this
+// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
+
 // CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <>  class RWBuffer definition
 
 // CHECK: TemplateArgument type 'float'
 // CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
 // CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit UAV
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>   implicit referenced h 'void *'
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>   implicit referenced h 'float *'
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2174,7 +2174,7 @@
 return QualType();
   }
 
-  if (getLangOpts().HLSL) {
+  if (getLangOpts().HLSL && Loc.isValid()) {
 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
 return QualType();
   }
@@ -2244,7 +2244,7 @@
 return QualType();
   }
 
-  if (getLangOpts().HLSL) {
+  if (getLangOpts().HLSL && Loc.isValid()) {
 Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
 return QualType();
   }
@@ -3008,7 +3008,7 @@
 return QualType();
   }

[clang] 00ecacc - [HLSL] Generate buffer subscript operators

2022-09-02 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-02T14:55:43-05:00
New Revision: 00ecacca7d90f96a1d54bc3fa38986fdd64e4c72

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

LOG: [HLSL] Generate buffer subscript operators

In HLSL buffer types support array subscripting syntax for loads and
stores. This change fleshes out the subscript operators to become array
accesses on the underlying handle pointer. This will allow LLVM
optimization passes to optimize resource accesses the same way any other
memory access would be optimized.

Reviewed By: aaron.ballman

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

Added: 
clang/test/CodeGenHLSL/buffer-array-operator.hlsl

Modified: 
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/lib/Sema/SemaType.cpp
clang/test/AST/HLSL/RWBuffer-AST.hlsl

Removed: 




diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index fe963fdbf2781..ee3aa4d42a049 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -104,7 +104,14 @@ struct BuiltinTypeDeclBuilder {
 
   BuiltinTypeDeclBuilder &
   addHandleMember(AccessSpecifier Access = AccessSpecifier::AS_private) {
-return addMemberVariable("h", Record->getASTContext().VoidPtrTy, Access);
+QualType Ty = Record->getASTContext().VoidPtrTy;
+if (Template) {
+  if (const auto *TTD = dyn_cast(
+  Template->getTemplateParameters()->getParam(0)))
+Ty = Record->getASTContext().getPointerType(
+QualType(TTD->getTypeForDecl(), 0));
+}
+return addMemberVariable("h", Ty, Access);
   }
 
   BuiltinTypeDeclBuilder &
@@ -158,15 +165,25 @@ struct BuiltinTypeDeclBuilder {
 lookupBuiltinFunction(AST, S, "__builtin_hlsl_create_handle");
 
 Expr *RCExpr = emitResourceClassExpr(AST, RC);
-CallExpr *Call =
-CallExpr::Create(AST, Fn, {RCExpr}, AST.VoidPtrTy, VK_PRValue,
- SourceLocation(), FPOptionsOverride());
+Expr *Call = CallExpr::Create(AST, Fn, {RCExpr}, AST.VoidPtrTy, VK_PRValue,
+  SourceLocation(), FPOptionsOverride());
 
 CXXThisExpr *This = new (AST)
 CXXThisExpr(SourceLocation(), Constructor->getThisType(), true);
-MemberExpr *Handle = MemberExpr::CreateImplicit(
-AST, This, true, Fields["h"], Fields["h"]->getType(), VK_LValue,
-OK_Ordinary);
+Expr *Handle = MemberExpr::CreateImplicit(AST, This, true, Fields["h"],
+  Fields["h"]->getType(), 
VK_LValue,
+  OK_Ordinary);
+
+// If the handle isn't a void pointer, cast the builtin result to the
+// correct type.
+if (Handle->getType().getCanonicalType() != AST.VoidPtrTy) {
+  Call = CXXStaticCastExpr::Create(
+  AST, Handle->getType(), VK_PRValue, CK_Dependent, Call, nullptr,
+  AST.getTrivialTypeSourceInfo(Handle->getType(), SourceLocation()),
+  FPOptionsOverride(), SourceLocation(), SourceLocation(),
+  SourceRange());
+}
+
 BinaryOperator *Assign = BinaryOperator::Create(
 AST, Handle, Call, BO_Assign, Handle->getType(), VK_LValue, 
OK_Ordinary,
 SourceLocation(), FPOptionsOverride());
@@ -179,6 +196,85 @@ struct BuiltinTypeDeclBuilder {
 return *this;
   }
 
+  BuiltinTypeDeclBuilder () {
+addArraySubscriptOperator(true);
+addArraySubscriptOperator(false);
+return *this;
+  }
+
+  BuiltinTypeDeclBuilder (bool IsConst) {
+assert(Fields.count("h") > 0 &&
+   "Subscript operator must be added after the handle.");
+
+FieldDecl *Handle = Fields["h"];
+ASTContext  = Record->getASTContext();
+
+assert(Handle->getType().getCanonicalType() != AST.VoidPtrTy &&
+   "Not yet supported for void pointer handles.");
+
+QualType ElemTy =
+QualType(Handle->getType()->getPointeeOrArrayElementType(), 0);
+QualType ReturnTy = ElemTy;
+
+FunctionProtoType::ExtProtoInfo ExtInfo;
+
+// Subscript operators return references to elements, const makes the
+// reference and method const so that the underlying data is not mutable.
+ReturnTy = AST.getLValueReferenceType(ReturnTy);
+if (IsConst) {
+  ExtInfo.TypeQuals.addConst();
+  ReturnTy.addConst();
+}
+
+QualType MethodTy =
+AST.getFunctionType(ReturnTy, {AST.UnsignedIntTy}, ExtInfo);
+auto *TSInfo = AST.getTrivialTypeSourceInfo(MethodTy, SourceLocation());
+auto *MethodDecl = CXXMethodDecl::Create(
+AST, Record, SourceLocation(),
+DeclarationNameInfo(
+AST.DeclarationNames.getCXXOperatorName(OO_Subscript),
+SourceLocation()),
+MethodTy, TSInfo, 

[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO

2022-09-02 Thread Azat Khuzhin via Phabricator via cfe-commits
azat updated this revision to Diff 457678.
azat added a comment.

v3: test only linux (to avoid failures on windows)
v4: add a comment about SCE


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133092

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -246,7 +246,11 @@
 // RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck 
-check-prefix=NOPUB %s
 //
-// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck 
-check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | 
FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 
| FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 
2>&1 | FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto 
-gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto=thin 
-gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 
\
 // RUN:| FileCheck -check-prefix=FDTS %s
@@ -371,6 +375,8 @@
 // NORNGBSE-NOT: -fdebug-ranges-base-address
 //
 // GARANGE-DAG: -generate-arange-section
+// LDGARANGE-NOT: {{".*ld" .* "-generate-arange-section"}}
+// LLDGARANGE-DAG: {{".*lld" .* "-generate-arange-section"}}
 //
 // FDTS: "-mllvm" "-generate-type-units"
 // FDTSE: error: unsupported option '-fdebug-types-section' for target 
'x86_64-apple-darwin'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -506,6 +506,14 @@
 Suffix,
 Plugin);
 CmdArgs.push_back(Args.MakeArgString(Plugin));
+  } else {
+// NOTE: That it is not possible to use lld for PS4, hence no need to
+// handle SCE (like in Clang.cpp::renderDebugOptions())
+bool NeedAranges = Args.hasArg(options::OPT_gdwarf_aranges);
+if (NeedAranges) {
+  CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+  CmdArgs.push_back(Args.MakeArgString("-generate-arange-section"));
+}
   }
 
   // Try to pass driver level flags relevant to LTO code generation down to


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -246,7 +246,11 @@
 // RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
 //
-// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -fuse-ld=lld -flto=thin -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=LLDGARANGE %s
 //
 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \
 // RUN:| FileCheck -check-prefix=FDTS %s
@@ -371,6 +375,8 @@
 // NORNGBSE-NOT: -fdebug-ranges-base-address
 //
 // GARANGE-DAG: -generate-arange-section
+// LDGARANGE-NOT: {{".*ld" .* "-generate-arange-section"}}
+// LLDGARANGE-DAG: {{".*lld" .* "-generate-arange-section"}}
 //
 // FDTS: "-mllvm" "-generate-type-units"
 // FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -506,6 +506,14 @@
 Suffix,
 Plugin);
 CmdArgs.push_back(Args.MakeArgString(Plugin));
+  } else {
+// NOTE: That it is not possible to use lld for PS4, hence no need to
+// handle SCE (like in Clang.cpp::renderDebugOptions())
+bool NeedAranges = Args.hasArg(options::OPT_gdwarf_aranges);
+if (NeedAranges) {
+  CmdArgs.push_back(Args.MakeArgString("-mllvm"));
+  

[clang] 2f7da9d - [Driver] Remove cc1 Separate form -fvisibility

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T12:40:00-07:00
New Revision: 2f7da9d317c9e390aee1f68cdcf4da48e180aec4

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

LOG: [Driver] Remove cc1 Separate form -fvisibility

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6d08a27c6003..a3134fdae87c 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6066,7 +6066,6 @@ def stack_protector : Separate<["-"], "stack-protector">,
 def stack_protector_buffer_size : Separate<["-"], 
"stack-protector-buffer-size">,
   HelpText<"Lower bound for a buffer to be considered for stack protection">,
   MarshallingInfoInt, "8">;
-def : Separate<["-"], "fvisibility">, Alias;
 def ftype_visibility : Joined<["-"], "ftype-visibility=">,
   HelpText<"Default type visibility">,
   MarshallingInfoVisibility, 
fvisibility_EQ.KeyPath>;



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


[clang] 7474214 - [test] Change cc1 -fvisibility to -fvisibility=

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T12:36:44-07:00
New Revision: 74742147ee27659dc3b0bc713d61ea9218bf29d0

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

LOG: [test] Change cc1 -fvisibility to -fvisibility=

Added: 


Modified: 
clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
clang/test/CodeGen/PowerPC/aix-visibility-inlines-hidden.cpp
clang/test/CodeGen/attr-availability.c
clang/test/CodeGen/available-externally-hidden.cpp
clang/test/CodeGen/cfi-unrelated-cast.cpp
clang/test/CodeGen/construction-vtable-visibility.cpp
clang/test/CodeGen/hidden-visibility.c
clang/test/CodeGen/private-extern.c
clang/test/CodeGen/set-visibility-for-decls.c
clang/test/CodeGen/visibility.c
clang/test/CodeGenCUDA/amdgpu-visibility.cu
clang/test/CodeGenCXX/RelativeVTablesABI/no-alias-when-dso-local.cpp
clang/test/CodeGenCXX/cfi-cast.cpp
clang/test/CodeGenCXX/cfi-ignorelist.cpp
clang/test/CodeGenCXX/cfi-mfcall-incomplete.cpp
clang/test/CodeGenCXX/cfi-mfcall.cpp
clang/test/CodeGenCXX/cfi-multiple-inheritance.cpp
clang/test/CodeGenCXX/cfi-nvcall.cpp
clang/test/CodeGenCXX/cfi-stats.cpp
clang/test/CodeGenCXX/cfi-vcall-check-after-args.cpp
clang/test/CodeGenCXX/cfi-vcall-no-trap.cpp
clang/test/CodeGenCXX/dllstorage-visibility.cpp
clang/test/CodeGenCXX/implicit-record-visibility.cpp
clang/test/CodeGenCXX/lto-visibility-inference.cpp
clang/test/CodeGenCXX/mdefault-visibility-export-mapping-rtti.cpp
clang/test/CodeGenCXX/no-lto-unit.cpp
clang/test/CodeGenCXX/pr11797.cpp
clang/test/CodeGenCXX/pr24097.cpp
clang/test/CodeGenCXX/rtti-fundamental.cpp
clang/test/CodeGenCXX/rtti-linkage.cpp
clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
clang/test/CodeGenCXX/type-metadata-memfun.cpp
clang/test/CodeGenCXX/type-metadata-thinlto.cpp
clang/test/CodeGenCXX/type-metadata.cpp
clang/test/CodeGenCXX/type_visibility.cpp
clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
clang/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp
clang/test/CodeGenCXX/visibility-pr36810.cpp
clang/test/CodeGenCXX/visibility.cpp
clang/test/CodeGenObjC/attr-availability.m
clang/test/CodeGenObjC/attr-exception.m
clang/test/CodeGenObjC/availability-dso-local.m
clang/test/CodeGenObjC/exceptions-asm-attribute.m
clang/test/CodeGenObjC/hidden-visibility.m
clang/test/CodeGenObjC/metadata_symbols.m
clang/test/CodeGenOpenCL/visibility.cl
clang/test/InterfaceStubs/externstatic.c
clang/test/InterfaceStubs/object.c
clang/test/InterfaceStubs/visibility.cpp
clang/test/OpenMP/declare_target_codegen.cpp
clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
clang/test/OpenMP/nvptx_target_pure_deleted_codegen.cpp
clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
clang/test/OpenMP/target_attribute_convergent.cpp

Removed: 




diff  --git a/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp 
b/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
index c5b7c77a78603..baa8ece05e553 100644
--- a/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
+++ b/clang/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.cpp
@@ -4,16 +4,16 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix -emit-llvm 
-round-trip-args -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility=default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - 
-x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-mignore-xcoff-visibility -fvisibility=default -emit-llvm -round-trip-args -o - 
-x c++ %s  | \
 // RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility=default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -no-opaque-pointers -triple powerpc-unknown-aix 
-fvisibility=default 

[PATCH] D132779: Enforce module decl-use restrictions and private header restrictions in textual headers

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The changes look reasonable to me, though if you think the flag is a temporary 
one, we might want to consider changes to document that explicitly.




Comment at: clang/docs/ReleaseNotes.rst:126
+  `_ are now
+  diagnosed even when the includer is a textual header.
 

You should mention `-fno-modules-validate-textual-header-includes` here so that 
users know there's a transition flag available. Do you expect we'd like to 
remove that flag in the future, or do you expect we'll need to carry it around 
"forever"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132779

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-02 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser accepted this revision.
jamieschmeiser added a comment.

If the source is specified with a partial path, I would expect the .json file 
to be in the same directory as the source, so dir1/f.C and dir2/f.C would 
result in dir1/f.json and dir2/f.json.  But this can be a later improvement.  
Let's get this landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D132831: [clang][Interp] Handle SubstNonTypeTemplateParmExprs

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM on the assumption that the extra test coverage doesn't find anything.




Comment at: clang/test/AST/Interp/functions.cpp:68-69
 static_assert(recursion(10) == 0, "");
+
+
+template





Comment at: clang/test/AST/Interp/functions.cpp:70-75
+template
+constexpr decltype(N) getNum() {
+  return N;
+}
+static_assert(getNum<-2>() == -2, "");
+static_assert(getNum<10>() == 10, "");

Can you also add a use where there's a default argument for the NTTP just to 
make sure we get that right too? (I'd be surprised if it didn't.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132831

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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you also add a release note for the changes?




Comment at: clang/lib/Sema/SemaTemplate.cpp:1534-1538
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);

Let's get fancy!



Comment at: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+

Please rename the file to end in cxx17 instead of cxx1z :-)


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

https://reviews.llvm.org/D132990

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


[PATCH] D126172: [clang] Fix comparison of TemplateArgument when they are of template kind

2022-09-02 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D126172#3767188 , @roberteg16 
wrote:

> Hey @mizvekov! Sorry for the late response.
>
> Yes, I am still interested and I am working on this. I'll let you know ASAP 
> if I find something that resembles a valid fix.
>
> I would be very grateful if you could give me some tips for debuging better 
> clang or if you could point me towards documents, links, whatever that could 
> give me nice information about how to reason about the code of the 
> parser/sema of clang.
>
> If you are in a hurry and need to fix it yourself and it happens that you 
> finish the path first, please @ me so I can get to see how an error like this 
> would be fixed, thanks!

Hello! Yeah you were just a bit too late, I have a patch that is accepted and 
should go in soon: https://reviews.llvm.org/D133072
I had run into this problem while making changes around 
CheckTemplateArgumentList, and I have this big patch which I am trying to 
offload into smaller chunks to expedite review.

I don't have any documents to recommend besides the obvious things, like the 
Clang docs auto-generated from the source code.
If you do want to get started, I can only recommend what worked for me, which 
is to try fixing bugs first, much like you tried here.
Though perhaps it's not very productive to get stuck in any one for a very long 
time, instead just ask for help or move on :)

I think that if you want to implement something new or a more substantial 
change, being able to debug quickly certainly helps.
There is no way you are going to be able to understand what is going on early 
on, so you will make a big mess, break hundreds of tests and so on, and being 
able to quickly go over and understand what is going on with them is important.
Invest in isolating bugs before working on them, it always pays off.

When fixing stuff, beware of changing assertions, most of the times the 
assertion is correct.
Also, if a bug fix is too local and seems easy, it's always worth spending some 
extra time to be sure.

And lots and lots and lots of free time, patience and being able to work 
without distractions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126172

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-09-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D132131#3766590 , @MyDeveloperDay 
wrote:

> Is there a technical reason for reusing the struct rather than introducing a 
> new one?

I see, good point. Really only if one would port the implementation to 
`AlignTokens`. If that's feasible (or sensible) I don't know. Otherwise one 
will only reuse the parsing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

2022-09-02 Thread Jonathon Penix via Phabricator via cfe-commits
jpenix-quic added inline comments.



Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : 
!fir.ref, 
!fir.ref> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref, !fir.ref>

peixin wrote:
> Is it possible not to generated this global variable if `fconvert=` is not 
> specified?
I'm not entirely sure--the issue I was running into was how to handle this in 
Fortran_main.c in a way which worked for all of GCC/Clang/Visual Studio (and 
maybe others?). I was originally thinking of doing this by using a weak 
definition of _QQEnvironmentDefaults set to nullptr so fconvert, etc. could 
override this definition without explicitly generating the fallback case. For 
GCC/clang, I think I could use __attribute__((weak)), but I wasn't sure how to 
handle this if someone tried to build with Visual Studio (or maybe another 
toolchain). I saw a few workarounds (ex: 
https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024) but I shied 
away from this since it seems to be an undocumented feature (and presumably 
only helps with Visual Studio). 

Do you know of a better or more general way I could do this? (Or, is there 
non-weak symbol approach that might be better that I'm missing?)


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

https://reviews.llvm.org/D130513

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


[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/CMakeLists.txt:930-937
+-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_CXX_COMPILER=${CLANGXX_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER=${CLANG_INSTRUMENTED}
+-DCMAKE_ASM_COMPILER_ID=Clang
+-DCMAKE_BUILD_TYPE=Release
+-DLLVM_ENABLE_PROJECTS=${CLANG_BOLT_INSTRUMENT_PROJECTS}

I don't think this is sufficient in the general case, we would need to pass 
additional variables like `CMAKE_AR` the same way we do for the existing 
bootstrap logic, see 
https://github.com/llvm/llvm-project/blob/dc549bf0013e11e8fcccba8a8d59c3a4bb052a3b/clang/CMakeLists.txt#L825.

For example, on Fuchsia builders we don't have any system-wide toolchain 
installation, instead we manually set  all necessary `CMAKE_` variables 
for the first stage, so this call will fail for us because it won't be able to 
find tools like the archiver.

Since handling this properly would likely duplicate a lot of the existing logic 
from the existing bootstrap logic, I'm wondering if we should instead try to 
refactor the existing logic and break it up into macros/functions which could 
then be reused here as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman 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 rG5b5329bd41ba: [NFC] Make MultiplexExternalSemaSource own 
sources (authored by beanz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -219,6 +219,8 @@
   void PushWatcher(DiagnosticWatcher *Watcher) { Watchers.push_back(Watcher); }
 };
 
+using llvm::makeIntrusiveRefCnt;
+
 // Make sure that the DiagnosticWatcher is not miscounting.
 TEST(ExternalSemaSource, DiagCheck) {
   auto Installer = std::make_unique();
@@ -234,14 +236,14 @@
 // instead of the usual suggestion we would use above.
 TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider Provider("AAB", "BBB");
+  auto Provider = makeIntrusiveRefCnt("AAB", "BBB");
   DiagnosticWatcher Watcher("AAB", "BBB");
-  Installer->PushSource();
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -249,34 +251,34 @@
 // ExternalSemaSource.
 TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider First("XXX", "BBB");
-  NamespaceTypoProvider Second("AAB", "CCC");
-  NamespaceTypoProvider Third("AAB", "DDD");
+  auto First = makeIntrusiveRefCnt("XXX", "BBB");
+  auto Second = makeIntrusiveRefCnt("AAB", "CCC");
+  auto Third = makeIntrusiveRefCnt("AAB", "DDD");
   DiagnosticWatcher Watcher("AAB", "CCC");
-  Installer->PushSource();
-  Installer->PushSource();
-  Installer->PushSource();
+  Installer->PushSource(First.get());
+  Installer->PushSource(Second.get());
+  Installer->PushSource(Third.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(1, First.CallCount);
-  ASSERT_LE(1, Second.CallCount);
-  ASSERT_EQ(0, Third.CallCount);
+  ASSERT_LE(1, First->CallCount);
+  ASSERT_LE(1, Second->CallCount);
+  ASSERT_EQ(0, Third->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
 TEST(ExternalSemaSource, ExternalDelayedTypoCorrection) {
   auto Installer = std::make_unique();
-  FunctionTypoProvider Provider("aaa", "bbb");
+  auto Provider = makeIntrusiveRefCnt("aaa", "bbb");
   DiagnosticWatcher Watcher("aaa", "bbb");
-  Installer->PushSource();
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } void foo() { AAA::aaa(); }",
   Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -284,8 +286,8 @@
 // solve the problem.
 TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser Diagnoser(false);
-  Installer->PushSource();
+  auto Diagnoser = makeIntrusiveRefCnt(false);
+  Installer->PushSource(Diagnoser.get());
   std::vector Args(1, "-std=c++11");
   // This code hits the class template specialization/class member of a class
   // template specialization checks in Sema::RequireCompleteTypeImpl.
@@ -293,26 +295,26 @@
   std::move(Installer),
   "template  struct S { class C { }; }; S::C SCInst;",
   Args));
-  ASSERT_EQ(0, Diagnoser.CallCount);
+  ASSERT_EQ(0, Diagnoser->CallCount);
 }
 
 // The first ExternalSemaSource where MaybeDiagnoseMissingCompleteType returns
 // true should be the last one called.
 TEST(ExternalSemaSource, FirstDiagnoserTaken) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser First(false);
-  CompleteTypeDiagnoser Second(true);
-  CompleteTypeDiagnoser Third(true);
-  Installer->PushSource();
-  Installer->PushSource();
-  Installer->PushSource();
+  auto First = makeIntrusiveRefCnt(false);
+  auto Second = makeIntrusiveRefCnt(true);
+  auto Third = makeIntrusiveRefCnt(true);
+  

[clang] 5b5329b - [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-02T13:57:39-05:00
New Revision: 5b5329bd41ba977459fcd7abb7cf438fd98c98e0

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

LOG: [NFC] Make MultiplexExternalSemaSource own sources

This change refactors the MuiltiplexExternalSemaSource to take ownership
of the underlying sources. As a result it makes a larger cleanup of
external source ownership in Sema and the ChainedIncludesSource.

Reviewed By: aaron.ballman, aprantl

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

Added: 


Modified: 
clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
clang/include/clang/Sema/MultiplexExternalSemaSource.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ChainedIncludesSource.cpp
clang/lib/Sema/MultiplexExternalSemaSource.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/unittests/Sema/ExternalSemaSourceTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp 
b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 2af1f622aa92f..45fc15619ecab 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -27,13 +27,14 @@ namespace {
 class Action : public clang::ASTFrontendAction {
 public:
   explicit Action(SymbolIndexManager , bool 
MinimizeIncludePaths)
-  : SemaSource(SymbolIndexMgr, MinimizeIncludePaths,
-   /*GenerateDiagnostics=*/false) {}
+  : SemaSource(new IncludeFixerSemaSource(SymbolIndexMgr,
+  MinimizeIncludePaths,
+  /*GenerateDiagnostics=*/false)) 
{}
 
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance ,
 StringRef InFile) override {
-SemaSource.setFilePath(InFile);
+SemaSource->setFilePath(InFile);
 return std::make_unique();
   }
 
@@ -51,8 +52,8 @@ class Action : public clang::ASTFrontendAction {
   CompletionConsumer = >getCodeCompletionConsumer();
 
 Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
-SemaSource.setCompilerInstance(Compiler);
-Compiler->getSema().addExternalSource();
+SemaSource->setCompilerInstance(Compiler);
+Compiler->getSema().addExternalSource(SemaSource.get());
 
 clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
 Compiler->getFrontendOpts().SkipFunctionBodies);
@@ -61,12 +62,12 @@ class Action : public clang::ASTFrontendAction {
   IncludeFixerContext
   getIncludeFixerContext(const clang::SourceManager ,
  clang::HeaderSearch ) const {
-return SemaSource.getIncludeFixerContext(SourceManager, HeaderSearch,
- SemaSource.getMatchedSymbols());
+return SemaSource->getIncludeFixerContext(SourceManager, HeaderSearch,
+  SemaSource->getMatchedSymbols());
   }
 
 private:
-  IncludeFixerSemaSource SemaSource;
+  IntrusiveRefCntPtr SemaSource;
 };
 
 } // namespace

diff  --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 78658dcf990c4..704925577d269 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -40,25 +40,24 @@ class MultiplexExternalSemaSource : public 
ExternalSemaSource {
   static char ID;
 
 private:
-  SmallVector Sources; // doesn't own them.
+  SmallVector Sources;
 
 public:
-
-  ///Constructs a new multiplexing external sema source and appends the
+  /// Constructs a new multiplexing external sema source and appends the
   /// given element to it.
   ///
-  ///\param[in] s1 - A non-null (old) ExternalSemaSource.
-  ///\param[in] s2 - A non-null (new) ExternalSemaSource.
+  ///\param[in] S1 - A non-null (old) ExternalSemaSource.
+  ///\param[in] S2 - A non-null (new) ExternalSemaSource.
   ///
-  MultiplexExternalSemaSource(ExternalSemaSource& s1, ExternalSemaSource& s2);
+  MultiplexExternalSemaSource(ExternalSemaSource *S1, ExternalSemaSource *S2);
 
   ~MultiplexExternalSemaSource() override;
 
-  ///Appends new source to the source list.
+  /// Appends new source to the source list.
   ///
   ///\param[in] source - An ExternalSemaSource.
   ///
-  void addSource(ExternalSemaSource );
+  void AddSource(ExternalSemaSource *Source);
 
   
//======//
   // ExternalASTSource.

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index bd81d3a7e5ee5..459c1109b852e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ 

[PATCH] D133087: [clang-format][NFC][Docs] fix wrong example of warping class definitions

2022-09-02 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

Thanks.


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

https://reviews.llvm.org/D133087

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


[PATCH] D132727: [clang][Interp] Implement array initializers and subscript expressions

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:277
+template 
+bool ByteCodeExprGen::VisitConstantExpr (const ConstantExpr *E) {
+  // TODO: Check if the ConstantExpr already has a value set and if so,





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:246
 
-auto Off = this->allocateLocalPrimitive(VD, *T, DT.isConstQualified());
+auto Offset =
+this->allocateLocalPrimitive(VD, *T, VD->getType().isConstQualified());





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:256
+return this->emitSetLocal(*T, Offset, VD);
   } else {
 // Composite types - allocate storage and initialize it.

You can drop this `else` because of the preceding unconditional `return`.



Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:258
 // Composite types - allocate storage and initialize it.
-if (auto Off = this->allocateLocal(VD)) {
-  return this->visitLocalInitializer(VD->getInit(), *Off);
-} else {
+if (auto Offset = this->allocateLocal(VD))
+  return this->visitLocalInitializer(VD->getInit(), *Offset);





Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:260
+  return this->visitLocalInitializer(VD->getInit(), *Offset);
+else
   return this->bail(VD);

You should drop this `else` as well.



Comment at: clang/lib/AST/Interp/Pointer.cpp:158
+
+  if (Desc->isArray() || Desc->isPrimitiveArray()) {
 if (!Pointee->IsStatic) {

`isArray()` already covers `isPrimitiveArray()` so this change looks 
unnecessary.


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

https://reviews.llvm.org/D132727

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


[clang] 1491282 - [clang] Change cc1 -fvisibility's canonical spelling to -fvisibility=

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T11:49:38-07:00
New Revision: 1491282165bfb87b15bd806ab53b3e9910ee7b29

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

LOG: [clang] Change cc1 -fvisibility's canonical spelling to -fvisibility=

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Driver/ToolChains/HIPSPV.cpp
clang/test/CodeGenCXX/visibility-ms-compat.cpp
clang/test/Driver/amdgpu-visibility.cl
clang/test/Driver/clang-translation.c
clang/test/Driver/hip-rdc-device-only.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc.hip
clang/test/Driver/hipspv-toolchain-rdc.hip
clang/test/Driver/visibility.cpp
clang/test/Driver/wasm-toolchain.c
clang/test/Driver/wasm-toolchain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9949f903ae6f9..6d08a27c60037 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2952,8 +2952,9 @@ def fvisibility_externs_nodllstorageclass_EQ : 
Joined<["-"], "fvisibility-extern
   HelpText<"The visibility for external declarations without an explicit DLL 
dllstorageclass [-fvisibility-from-dllstorageclass]">,
   MarshallingInfoVisibility, 
"HiddenVisibility">,
   ShouldParseIf;
-def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group,
-  HelpText<"Set the default symbol visibility for all global definitions">, 
Values<"default,protected,internal,hidden">;
+def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Set the default symbol visibility for all global definitions">,
+  MarshallingInfoVisibility, 
"DefaultVisibility">;
 defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden",
   LangOpts<"InlineVisibilityHidden">, DefaultFalse,
   PosFlag,
@@ -6065,12 +6066,10 @@ def stack_protector : Separate<["-"], 
"stack-protector">,
 def stack_protector_buffer_size : Separate<["-"], 
"stack-protector-buffer-size">,
   HelpText<"Lower bound for a buffer to be considered for stack protection">,
   MarshallingInfoInt, "8">;
-def fvisibility : Separate<["-"], "fvisibility">,
-  HelpText<"Default type and symbol visibility">,
-  MarshallingInfoVisibility, 
"DefaultVisibility">;
-def ftype_visibility : Separate<["-"], "ftype-visibility">,
+def : Separate<["-"], "fvisibility">, Alias;
+def ftype_visibility : Joined<["-"], "ftype-visibility=">,
   HelpText<"Default type visibility">,
-  MarshallingInfoVisibility, 
fvisibility.KeyPath>;
+  MarshallingInfoVisibility, 
fvisibility_EQ.KeyPath>;
 def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-to-externs">,
   HelpText<"Apply global symbol visibility to external declarations without an 
explicit visibility">,
   MarshallingInfoFlag>;

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 89f8e482ded6f..6246568710916 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -707,8 +707,7 @@ void AMDGPUToolChain::addClangTargetOptions(
   // supported for the foreseeable future.
   if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
  options::OPT_fvisibility_ms_compat)) {
-CC1Args.push_back("-fvisibility");
-CC1Args.push_back("hidden");
+CC1Args.push_back("-fvisibility=hidden");
 CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
 }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index eb7ad39d7edc7..2dd9ac01b3ef9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2386,10 +2386,8 @@ void Clang::AddWebAssemblyTargetArgs(const ArgList ,
  ArgStringList ) const {
   // Default to "hidden" visibility.
   if (!Args.hasArg(options::OPT_fvisibility_EQ,
-   options::OPT_fvisibility_ms_compat)) {
-CmdArgs.push_back("-fvisibility");
-CmdArgs.push_back("hidden");
-  }
+   options::OPT_fvisibility_ms_compat))
+CmdArgs.push_back("-fvisibility=hidden");
 }
 
 void Clang::AddVETargetArgs(const ArgList , ArgStringList ) const 
{
@@ -5982,21 +5980,17 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ,
  options::OPT_fvisibility_ms_compat)) {
 if (A->getOption().matches(options::OPT_fvisibility_EQ)) {
-  CmdArgs.push_back("-fvisibility");
-  

[PATCH] D133191: Driver test: remove `REQUIRES: x86-registered-target` and set `--sysroot=""` to support clang with `DEFAULT_SYSROOT`.

2022-09-02 Thread Warren Ristow via Phabricator via cfe-commits
wristow accepted this revision.
wristow added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133191

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


[PATCH] D132056: [HLSL] Restrict to supported targets

2022-09-02 Thread Chris Bieneman 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 rG10194a51a9d3: [HLSL] Restrict to supported targets (authored 
by beanz).

Changed prior to commit:
  https://reviews.llvm.org/D132056?vs=456746=457655#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132056

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenHLSL/validator_version.hlsl
  clang/test/Driver/hlsl-lang-targets.hlsl
  clang/test/Preprocessor/predefined-macros-hlsl.hlsl


Index: clang/test/Preprocessor/predefined-macros-hlsl.hlsl
===
--- clang/test/Preprocessor/predefined-macros-hlsl.hlsl
+++ clang/test/Preprocessor/predefined-macros-hlsl.hlsl
@@ -29,20 +29,20 @@
 // PIXEL: #define __SHADER_TARGET_STAGE 0
 // VERTEX: #define __SHADER_TARGET_STAGE 1
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2015 | FileCheck -match-full-lines 
%s --check-prefixes=STD2015
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2015 | FileCheck -match-full-lines %s --check-prefixes=STD2015
 // STD2015: #define __HLSL_VERSION 2015
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2016 | FileCheck -match-full-lines 
%s --check-prefixes=STD2016
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2016 | FileCheck -match-full-lines %s --check-prefixes=STD2016
 // STD2016: #define __HLSL_VERSION 2016
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2017 | FileCheck -match-full-lines 
%s --check-prefixes=STD2017
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2017 | FileCheck -match-full-lines %s --check-prefixes=STD2017
 // STD2017: #define __HLSL_VERSION 2017
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2018 | FileCheck -match-full-lines 
%s --check-prefixes=STD2018
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2018 | FileCheck -match-full-lines %s --check-prefixes=STD2018
 // STD2018: #define __HLSL_VERSION 2018
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl2021 | FileCheck -match-full-lines 
%s --check-prefixes=STD2021
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl2021 | FileCheck -match-full-lines %s --check-prefixes=STD2021
 // STD2021: #define __HLSL_VERSION 2021
 
-// RUN: %clang_cc1 %s -E -dM -o - -std=hlsl202x | FileCheck -match-full-lines 
%s --check-prefixes=STD202x
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library %s -E -dM -o - -x 
hlsl -std=hlsl202x | FileCheck -match-full-lines %s --check-prefixes=STD202x
 // STD202x: #define __HLSL_VERSION 2029
Index: clang/test/Driver/hlsl-lang-targets.hlsl
===
--- /dev/null
+++ clang/test/Driver/hlsl-lang-targets.hlsl
@@ -0,0 +1,14 @@
+// RUN: not %clang -target x86_64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=X86
+// RUN: not %clang -target dxil-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=DXIL
+// RUN: not %clang -target x86_64-unknown-shadermodel %s 2>&1 | FileCheck %s 
--check-prefix=SM
+// RUN: not %clang -target spirv64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=SPIRV
+
+
+// A completely unsupported target...
+// X86: error: HLSL code generation is unsupported for target 
'x86_64-unknown-unknown'
+
+// Poorly specified targets
+// DXIL: error: HLSL code generation is unsupported for target 
'dxil-unknown-unknown'
+// SM: error: HLSL code generation is unsupported for target 
'x86_64-unknown-shadermodel'
+
+// FIXME// SPIRV: error: HLSL code generation is unsupported for target 
'spirv64-unknown-unknown'
Index: clang/test/CodeGenHLSL/validator_version.hlsl
===
--- clang/test/CodeGenHLSL/validator_version.hlsl
+++ clang/test/CodeGenHLSL/validator_version.hlsl
@@ -1,5 +1,7 @@
 // RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm 
-xhlsl -validator-version 1.1 -o - %s | FileCheck %s
-// RUN: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl -validator-version 
1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
+
+// FIXME:The following line should work once SPIR-V support for HLSL is added.
+// DISABLED: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl 
-validator-version 1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
 
 // CHECK:!dx.valver = !{![[valver:[0-9]+]]}
 // CHECK:![[valver]] = !{i32 1, i32 1}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4107,6 +4107,14 @@
   if (const Arg *A = 

[clang] 10194a5 - [HLSL] Restrict to supported targets

2022-09-02 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-02T13:36:23-05:00
New Revision: 10194a51a9d304ab9f68432f244749c672f9012a

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

LOG: [HLSL] Restrict to supported targets

Someday we would like to support HLSL on a wider range of targets, but
today targeting anything other than `dxil` is likly to cause lots of
headaches. This adds an error and tests to validate that the expected
target is `dxil-?-shadermodel`.

We will continue to do a best effort to ensure the code we write makes
it easy to support other targets (like SPIR-V), but this error will
prevent users from hitting frustrating errors for unsupported cases.

Reviewed By: jcranmer-intel, Anastasia

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

Added: 
clang/test/Driver/hlsl-lang-targets.hlsl

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenHLSL/validator_version.hlsl
clang/test/Preprocessor/predefined-macros-hlsl.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 63be59082e7e0..df85139c3ca22 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -666,6 +666,8 @@ def err_drv_invalid_directx_shader_module : Error<
   "invalid profile : %0">;
 def err_drv_dxc_missing_target_profile : Error<
   "target profile option (-T) is missing">;
+def err_drv_hlsl_unsupported_target : Error<
+  "HLSL code generation is unsupported for target '%0'">;
 
 def err_drv_invalid_range_dxil_validator_version : Error<
   "invalid validator version : %0\n"

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 574514bdd0b0a..9ac522adfd9a9 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4107,6 +4107,14 @@ bool CompilerInvocation::ParseLangArgs(LangOptions 
, ArgList ,
   if (const Arg *A = Args.getLastArg(OPT_frandomize_layout_seed_EQ))
 Opts.RandstructSeed = A->getValue(0);
 
+  // Validate options for HLSL
+  if (Opts.HLSL) {
+bool SupportedTarget = T.getArch() == llvm::Triple::dxil &&
+   T.getOS() == llvm::Triple::ShaderModel;
+if (!SupportedTarget)
+  Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
+  }
+
   return Diags.getNumErrors() == NumErrorsBefore;
 }
 

diff  --git a/clang/test/CodeGenHLSL/validator_version.hlsl 
b/clang/test/CodeGenHLSL/validator_version.hlsl
index 426918a7221c4..0d2cbb96dbe48 100644
--- a/clang/test/CodeGenHLSL/validator_version.hlsl
+++ b/clang/test/CodeGenHLSL/validator_version.hlsl
@@ -1,5 +1,7 @@
 // RUN: %clang -cc1 -S -triple dxil-pc-shadermodel6.3-library -S -emit-llvm 
-xhlsl -validator-version 1.1 -o - %s | FileCheck %s
-// RUN: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl -validator-version 
1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
+
+// FIXME:The following line should work once SPIR-V support for HLSL is added.
+// DISABLED: %clang -cc1 -S -triple spirv32 -S -emit-llvm -xhlsl 
-validator-version 1.1 -o - %s | FileCheck %s --check-prefix=NOT_DXIL
 
 // CHECK:!dx.valver = !{![[valver:[0-9]+]]}
 // CHECK:![[valver]] = !{i32 1, i32 1}

diff  --git a/clang/test/Driver/hlsl-lang-targets.hlsl 
b/clang/test/Driver/hlsl-lang-targets.hlsl
new file mode 100644
index 0..a757e2a3cdf74
--- /dev/null
+++ b/clang/test/Driver/hlsl-lang-targets.hlsl
@@ -0,0 +1,14 @@
+// RUN: not %clang -target x86_64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=X86
+// RUN: not %clang -target dxil-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=DXIL
+// RUN: not %clang -target x86_64-unknown-shadermodel %s 2>&1 | FileCheck %s 
--check-prefix=SM
+// RUN: not %clang -target spirv64-unknown-unknown %s 2>&1 | FileCheck %s 
--check-prefix=SPIRV
+
+
+// A completely unsupported target...
+// X86: error: HLSL code generation is unsupported for target 
'x86_64-unknown-unknown'
+
+// Poorly specified targets
+// DXIL: error: HLSL code generation is unsupported for target 
'dxil-unknown-unknown'
+// SM: error: HLSL code generation is unsupported for target 
'x86_64-unknown-shadermodel'
+
+// FIXME// SPIRV: error: HLSL code generation is unsupported for target 
'spirv64-unknown-unknown'

diff  --git a/clang/test/Preprocessor/predefined-macros-hlsl.hlsl 
b/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
index 03239fdab18f2..251362cd03c0f 100644
--- a/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
+++ b/clang/test/Preprocessor/predefined-macros-hlsl.hlsl
@@ -29,20 +29,20 @@
 // PIXEL: #define __SHADER_TARGET_STAGE 0
 // VERTEX: #define 

[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I built LLDB and ran its tests. I see no additional failures after applying my 
change, but LLDB's tests do not execute successfully on my local system (22 
failures).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

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


[PATCH] D132829: [clang][Interp] Handle ImplictValueInitExprs

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/test/AST/Interp/arrays.cpp:13
+///   currently evaluate other parts of it.
+#if 0
+struct fred {

I wish we could find some solution that didn't require this so that the test 
case breaks when we do get around to implementing support for the other bits. 
But this is at least a good start!


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

https://reviews.llvm.org/D132829

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


[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D132975#3765541 , @Amir wrote:

> Hi Petr, thank you for your comments!
>
> In D132975#3763264 , @phosek wrote:
>
>> This was already on my list of build system features I'd like to implement 
>> and I'm glad someone else is already looking into it, thank you! I have two 
>> high level comments about your approach.
>>
>> The first one is related to the use of Clang build as the training data. I 
>> think that Clang build is both unnecessarily heavyweight, but also not 
>> particularly representative of typical workloads (most Clang users don't use 
>> it to build Clang). Ideally, we would give vendors the flexibility to supply 
>> their own training data. I'd prefer reusing the existing perf-training 
>>  
>> setup to do so. In fact, I'd imagine most vendors would likely use the same 
>> training data for both PGO and BOLT and that use case should be supported.
>
> Agree that perf-training might be useful for vendors. I'll try to enable it 
> in a follow-up diff.
>
> Please note that the target for profile collection is not hardcoded to clang, 
> it's configurable via CLANG_BOLT_INSTRUMENT_PROJECTS and 
> CLANG_BOLT_INSTRUMENT_TARGETS. Right now it's the llvm/not tool (the smallest 
> possible).
>
>> The second one is related to applicability. I don't think this mechanism 
>> should be limited only to Clang. Ideally, it should be possible to 
>> instrument and optimize other tools in the toolchain distribution as well; 
>> LLD is likely going to be the most common one after Clang.
>
> I thought about it, and I think we can accommodate optimizing arbitrary 
> targets by providing an interface to instrument specified target(s) via 
> `-DBOLT_INSTRUMENT_TARGETS`. For each of the target binaries, CMake would 
> create targets like `bolt-instrument-$TARGET` and `bolt-optimize-$TARGET`. 
> For `bolt-instrument-$TARGET`, BOLT would instrument the target binary, 
> placing instrumented binary next to the original one (e.g. 
> `$target-bolt.inst`). End users would use those instrumented binaries on 
> representative workloads to collect the profile. For `bolt-optimize-$TARGET`, 
> BOLT would post-process the profiles and create optimized binary 
> (`$target-bolt`).
>
> I appreciate your suggestions. Do you think we can move incrementally from 
> this diff towards more general uses in follow-up diffs?

That's fine with me. Do you envision replacing the use of LLVM build for 
training with perf-training or supporting both? I'd lean towards the former for 
simplicity but would be curious to hear about your use cases and plans.




Comment at: clang/CMakeLists.txt:881
 
+if (CLANG_BOLT_INSTRUMENT)
+  set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)

We could consider moving this block to a separate file which would then be 
included here since this file is already getting pretty large and the logic in 
this block is self-contained. That could be done in a follow up change though.



Comment at: clang/CMakeLists.txt:955
+WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+COMMAND sh -c "$ prof.fdata.* -o prof.fdata"
+COMMENT "Preparing BOLT profile"

I'd like to avoid dependency on shell to make this compatible with Windows. Can 
we move this logic into a Python script akin to 
https://github.com/llvm/llvm-project/blob/607f14d9605da801034e7119c297c3f58ebce603/clang/utils/perf-training/perf-helper.py?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D133158: [NFC] Make MultiplexExternalSemaSource own sources

2022-09-02 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 457651.
beanz added a comment.
Herald added a project: clang-tools-extra.

Updating with changes based on review feedback, and fixups for clang-tools-extra


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133158

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang/include/clang/Sema/MultiplexExternalSemaSource.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ChainedIncludesSource.cpp
  clang/lib/Sema/MultiplexExternalSemaSource.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/unittests/Sema/ExternalSemaSourceTest.cpp

Index: clang/unittests/Sema/ExternalSemaSourceTest.cpp
===
--- clang/unittests/Sema/ExternalSemaSourceTest.cpp
+++ clang/unittests/Sema/ExternalSemaSourceTest.cpp
@@ -219,6 +219,8 @@
   void PushWatcher(DiagnosticWatcher *Watcher) { Watchers.push_back(Watcher); }
 };
 
+using llvm::makeIntrusiveRefCnt;
+
 // Make sure that the DiagnosticWatcher is not miscounting.
 TEST(ExternalSemaSource, DiagCheck) {
   auto Installer = std::make_unique();
@@ -234,14 +236,14 @@
 // instead of the usual suggestion we would use above.
 TEST(ExternalSemaSource, ExternalTypoCorrectionPrioritized) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider Provider("AAB", "BBB");
+  auto Provider = makeIntrusiveRefCnt("AAB", "BBB");
   DiagnosticWatcher Watcher("AAB", "BBB");
-  Installer->PushSource();
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -249,34 +251,34 @@
 // ExternalSemaSource.
 TEST(ExternalSemaSource, ExternalTypoCorrectionOrdering) {
   auto Installer = std::make_unique();
-  NamespaceTypoProvider First("XXX", "BBB");
-  NamespaceTypoProvider Second("AAB", "CCC");
-  NamespaceTypoProvider Third("AAB", "DDD");
+  auto First = makeIntrusiveRefCnt("XXX", "BBB");
+  auto Second = makeIntrusiveRefCnt("AAB", "CCC");
+  auto Third = makeIntrusiveRefCnt("AAB", "DDD");
   DiagnosticWatcher Watcher("AAB", "CCC");
-  Installer->PushSource();
-  Installer->PushSource();
-  Installer->PushSource();
+  Installer->PushSource(First.get());
+  Installer->PushSource(Second.get());
+  Installer->PushSource(Third.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } using namespace AAB;", Args));
-  ASSERT_LE(1, First.CallCount);
-  ASSERT_LE(1, Second.CallCount);
-  ASSERT_EQ(0, Third.CallCount);
+  ASSERT_LE(1, First->CallCount);
+  ASSERT_LE(1, Second->CallCount);
+  ASSERT_EQ(0, Third->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
 TEST(ExternalSemaSource, ExternalDelayedTypoCorrection) {
   auto Installer = std::make_unique();
-  FunctionTypoProvider Provider("aaa", "bbb");
+  auto Provider = makeIntrusiveRefCnt("aaa", "bbb");
   DiagnosticWatcher Watcher("aaa", "bbb");
-  Installer->PushSource();
+  Installer->PushSource(Provider.get());
   Installer->PushWatcher();
   std::vector Args(1, "-std=c++11");
   ASSERT_TRUE(clang::tooling::runToolOnCodeWithArgs(
   std::move(Installer), "namespace AAA { } void foo() { AAA::aaa(); }",
   Args));
-  ASSERT_LE(0, Provider.CallCount);
+  ASSERT_LE(0, Provider->CallCount);
   ASSERT_EQ(1, Watcher.SeenCount);
 }
 
@@ -284,8 +286,8 @@
 // solve the problem.
 TEST(ExternalSemaSource, TryOtherTacticsBeforeDiagnosing) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser Diagnoser(false);
-  Installer->PushSource();
+  auto Diagnoser = makeIntrusiveRefCnt(false);
+  Installer->PushSource(Diagnoser.get());
   std::vector Args(1, "-std=c++11");
   // This code hits the class template specialization/class member of a class
   // template specialization checks in Sema::RequireCompleteTypeImpl.
@@ -293,26 +295,26 @@
   std::move(Installer),
   "template  struct S { class C { }; }; S::C SCInst;",
   Args));
-  ASSERT_EQ(0, Diagnoser.CallCount);
+  ASSERT_EQ(0, Diagnoser->CallCount);
 }
 
 // The first ExternalSemaSource where MaybeDiagnoseMissingCompleteType returns
 // true should be the last one called.
 TEST(ExternalSemaSource, FirstDiagnoserTaken) {
   auto Installer = std::make_unique();
-  CompleteTypeDiagnoser First(false);
-  CompleteTypeDiagnoser Second(true);
-  CompleteTypeDiagnoser Third(true);
-  Installer->PushSource();
-  Installer->PushSource();
-  Installer->PushSource();
+  auto First = makeIntrusiveRefCnt(false);
+  auto Second = makeIntrusiveRefCnt(true);
+  auto Third = makeIntrusiveRefCnt(true);
+  Installer->PushSource(First.get());
+  

[PATCH] D125419: [Arm64EC 7/?] clang side of Arm64EC varargs ABI.

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2457
+/*IsVectorCall=*/false, /*IsRegCall=*/false);
+  }
+

Hmm.  Doesn't EC ABI lowering need to preserve this same state, or else you'll 
get incompatibilities when you exhaust SSE registers?

Should you just be calling over to this at a higher-level point, like in 
`computeInfo`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125419

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin added a comment.

In D133202#3767414 , @rjmccall wrote:

> Thanks, LGTM

Thanks for your review John, but I don’t have commit access, can you land this 
patch for me? Please use "yronglin " to commit the 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7697
   // The alignment must be a constant integer.
-  Expr *Arg = TheCall->getArg(1);
+  Expr *SecondArg = TheCall->getArg(1);
 

rjmccall wrote:
> This should be:
> 
> ```
> Expr *SecondArg = TheCall->getArg(1);
> if (convertArgumentToType(*this, SecondArg, Context.getSizeType()))
>   return true;
> TheCall->setArg(1, SecondArg);
> 
> if (!SecondArg->isValueDependent()) {
>   llvm::APSInt Result;
>   
> }
> ```
> 
> Test case is to pass a floating-point expression or something like that.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-02 Thread Lin Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 457643.
yronglin added a comment.

Update patch with john's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -66,6 +66,11 @@
 }
 #endif
 
+int test13(int *a) {
+  a = (int *)__builtin_assume_aligned(a, 2 * 2.0); // expected-error {{argument to '__builtin_assume_aligned' must be a constant integer}}
+  return a[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
===
--- clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
+++ clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
@@ -26,3 +26,9 @@
 void *ignore_volatiles(volatile void * x) {
   return __builtin_assume_aligned(x, 1);
 }
+
+// CHECK-LABEL: ignore_array_volatiles
+void *ignore_array_volatiles() {
+  volatile int arr[] = {1};
+  return __builtin_assume_aligned(arr, 4);
+}
Index: clang/test/CodeGen/catch-alignment-assumption-array.c
===
--- /dev/null
+++ clang/test/CodeGen/catch-alignment-assumption-array.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 31, i32 35 }, {{.*}}* @[[CHAR]] }
+
+void *caller(void) {
+  char str[] = "";
+  // CHECK:   define{{.*}}
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%[[STR:.*]] = alloca [1 x i8], align 1
+  // CHECK-NEXT:%[[BITCAST:.*]] = bitcast [1 x i8]* %[[STR]] to i8*
+  // CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 %[[BITCAST]], i8 0, i64 1, i1 false)
+  // CHECK-NEXT:%[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x i8], [1 x i8]* %[[STR]], i64 0, i64 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 0
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize

[PATCH] D131701: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties

2022-09-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Can we check for the right conditions when emitting the setter body and just 
deactivate the cleanup?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131701

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-02 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 457637.
melver added a comment.

Don't split RUN lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-metadata.c
  clang/test/Driver/fsanitize-metadata.c

Index: clang/test/Driver/fsanitize-metadata.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-metadata.c
@@ -0,0 +1,19 @@
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all -fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=bad_arg %s -### 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-INVALID: error: unsupported argument 'bad_arg' to option '-fexperimental-sanitize-metadata='
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics -fno-experimental-sanitize-metadata=atomics -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// CHECK-COVERED: "-fexperimental-sanitize-metadata=covered"
+// CHECK-COVERED-NOT: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ATOMICS %s
+// CHECK-ATOMICS: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// CHECK-ALL: "-fexperimental-sanitize-metadata=covered"
+// CHECK-ALL: "-fexperimental-sanitize-metadata=atomics"
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+
+int x, y;
+
+void empty() {
+// CHECK-NOT: define dso_local void @empty() {{.*}} !pcsections
+}
+
+int atomics() {
+// ATOMICS-LABEL: define dso_local i32 @atomics()
+// ATOMICS-SAME:  !pcsections ![[ATOMICS_COVERED:[0-9]+]]
+// ATOMICS-NEXT:  entry:
+// ATOMICS-NEXT:atomicrmw add {{.*}} !pcsections ![[ATOMIC_OP:[0-9]+]]
+// ATOMICS-NOT: load {{.*}} !pcsections
+  __atomic_fetch_add(, 1, __ATOMIC_RELAXED);
+  return y;
+}
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_ctor
+// ATOMICS: call void @__sanitizer_metadata_atomics_add(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_dtor
+// ATOMICS: call void @__sanitizer_metadata_atomics_del(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+
+// CHECK-LABEL: __sanitizer_metadata_covered.module_ctor
+// CHECK: call void @__sanitizer_metadata_covered_add(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+// CHECK-LABEL: __sanitizer_metadata_covered.module_dtor
+// CHECK: call void @__sanitizer_metadata_covered_del(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+
+// ATOMICS: ![[ATOMICS_COVERED]] = !{!"sanmd_covered", ![[ATOMICS_COVERED_AUX:[0-9]+]]}
+// ATOMICS: ![[ATOMICS_COVERED_AUX]] = !{i32 1}
+// ATOMICS: ![[ATOMIC_OP]] = !{!"sanmd_atomics"}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -100,6 +100,11 @@
   CoverageTraceStores = 1 << 17,
 };
 
+enum BinaryMetadataFeature {
+  BinaryMetadataCovered = 1 << 0,
+  BinaryMetadataAtomics = 1 << 1,
+};
+
 /// Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any
 /// invalid components. Returns a SanitizerMask.
 static SanitizerMask parseArgValues(const Driver , const llvm::opt::Arg *A,
@@ -110,6 +115,11 @@
 static int parseCoverageFeatures(const Driver , const llvm::opt::Arg 

[PATCH] D133194: rewording note note_constexpr_invalid_cast

2022-09-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I can't find any C tests that exercise this diagnostic. We should add a C test 
as well to confirm that we obtain the diagnostic we expect in a C context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133194

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


[clang] 8899c3c - [docs] -fivisibility= allows protected and internal

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T10:49:10-07:00
New Revision: 8899c3c4e15ea3681b0c423b44313163f5370abd

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

LOG: [docs] -fivisibility= allows protected and internal

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 370a7a327a816..141c1464638a5 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2729,7 +2729,7 @@ The visibility for definitions without an explicit DLL 
export class \[-fvisibili
 
 .. option:: -fvisibility=
 
-Set the default symbol visibility for all global declarations.  must be 
'hidden' or 'default'.
+Set the default symbol visibility for all global definitions.  must be 
'default', 'protected', 'internal' or 'hidden'.
 
 .. option:: -fwasm-exceptions
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1112e0187758e..9949f903ae6f9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2953,7 +2953,7 @@ def fvisibility_externs_nodllstorageclass_EQ : 
Joined<["-"], "fvisibility-extern
   MarshallingInfoVisibility, 
"HiddenVisibility">,
   ShouldParseIf;
 def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group,
-  HelpText<"Set the default symbol visibility for all global declarations">, 
Values<"hidden,default">;
+  HelpText<"Set the default symbol visibility for all global definitions">, 
Values<"default,protected,internal,hidden">;
 defm visibility_inlines_hidden : BoolFOption<"visibility-inlines-hidden",
   LangOpts<"InlineVisibilityHidden">, DefaultFalse,
   PosFlag,



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


[clang] a931edd - [docs] Regenerate clang/docs/ClangCommandLineReference.rst

2022-09-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-02T10:29:38-07:00
New Revision: a931eddd09145c340966db0561159a8e7cdb212e

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

LOG: [docs] Regenerate clang/docs/ClangCommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 7f9ef3783f9d..370a7a327a81 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -76,10 +76,6 @@ Pass  to fatbinary invocation
 
 Pass  to the ptxas assembler
 
-.. option:: -Z
-
-.. option:: -a, --profile-blocks
-
 .. option:: -all\_load
 
 .. option:: -allowable\_client 
@@ -579,10 +575,6 @@ Print the library path for the currently used compiler 
runtime library ("libgcc.
 
 .. option:: -print-multi-lib, --print-multi-lib
 
-.. option:: -print-multiarch, --print-multiarch
-
-Print the multiarch target triple
-
 .. option:: -print-prog-name=, --print-prog-name=, 
--print-prog-name 
 
 Print the full program path of 
@@ -859,9 +851,9 @@ no effect during actions that do not perform compilation.
 
 Pass  to the assembler
 
-.. option:: -Xclang 
+.. option:: -Xclang , -Xclang=
 
-Pass  to the clang compiler
+Pass  to clang -cc1
 
 .. option:: -Xopenmp-target 
 
@@ -947,10 +939,6 @@ Inline suitable functions
 
 Inline functions which are (explicitly or implicitly) marked inline
 
-.. option:: -finline-max-stacksize=
-
-Suppress inlining of functions with a stacksize larger than  bytes.
-
 .. option:: -fno-legacy-pass-manager, -fexperimental-new-pass-manager
 
 .. option:: -fno-sanitize-ignorelist, -fno-sanitize-blacklist
@@ -1913,6 +1901,10 @@ Implicitly search the file system for module map files.
 
 .. option:: -fimplicit-modules, -fno-implicit-modules
 
+.. option:: -finline-max-stacksize=
+
+Suppress inlining of functions whose stack size exceeds the given value
+
 .. option:: -finput-charset=
 
 Specify the default character set for source files
@@ -2785,11 +2777,7 @@ Only instrument 1 of N groups
 
 Don't instrument functions with loops unless they also meet the minimum 
function size
 
-.. option:: -fxray-instruction-threshold
-
-.. program:: clang1
 .. option:: -fxray-instruction-threshold=
-.. program:: clang
 
 Sets the minimum function size to instrument with XRay
 
@@ -3205,6 +3193,10 @@ Not emit the visibility attribute for asm in AIX OS or 
give all symbols 'unspeci
 
 (integrated-as) Emit an object file which can be used with an incremental 
linker
 
+.. option:: -mindirect-branch-cs-prefix
+
+Add cs prefix to call and jmp to indirect thunk
+
 .. option:: -mios-version-min=, -miphoneos-version-min=
 
 Set iOS deployment target
@@ -4301,9 +4293,7 @@ Pass  to the linker
 
 Pass  to the offload linkers or the ones idenfied by -
 
-.. program:: clang1
 .. option:: -Z
-.. program:: clang
 
 .. option:: -b
 
@@ -4390,18 +4380,28 @@ CL.EXE COMPATIBILITY OPTIONS
 dxc compatibility options
 
 .. program:: clang4
+.. option:: --E, /E, -E
+.. program:: clang
+
+Entry point name
+
+.. program:: clang5
 .. option:: /T, -T
 .. program:: clang
 
 Set target profile.  must be 'ps_6_0', ' ps_6_1', ' ps_6_2', ' 
ps_6_3', ' ps_6_4', ' ps_6_5', ' ps_6_6', ' ps_6_7', 'vs_6_0', ' vs_6_1', ' 
vs_6_2', ' vs_6_3', ' vs_6_4', ' vs_6_5', ' vs_6_6', ' vs_6_7', 'gs_6_0', ' 
gs_6_1', ' gs_6_2', ' gs_6_3', ' gs_6_4', ' gs_6_5', ' gs_6_6', ' gs_6_7', 
'hs_6_0', ' hs_6_1', ' hs_6_2', ' hs_6_3', ' hs_6_4', ' hs_6_5', ' hs_6_6', ' 
hs_6_7', 'ds_6_0', ' ds_6_1', ' ds_6_2', ' ds_6_3', ' ds_6_4', ' ds_6_5', ' 
ds_6_6', ' ds_6_7', 'cs_6_0', ' cs_6_1', ' cs_6_2', ' cs_6_3', ' cs_6_4', ' 
cs_6_5', ' cs_6_6', ' cs_6_7', 'lib_6_3', ' lib_6_4', ' lib_6_5', ' lib_6_6', ' 
lib_6_7', ' lib_6_x', 'ms_6_5', ' ms_6_6', ' ms_6_7', 'as_6_5', ' as_6_6' or ' 
as_6_7'.
 
-.. program:: clang5
+.. program:: clang6
 .. option:: /emit-pristine-llvm, -emit-pristine-llvm, /fcgl, -fcgl
 .. program:: clang
 
 Emit pristine LLVM IR from the frontend by not running any LLVM passes at 
all.Same as -S + -emit-llvm + -disable-llvm-passes.
 
-.. program:: clang6
+.. option:: -hlsl-entry 
+
+Entry point name for hlsl
+
+.. program:: clang7
 .. option:: /hlsl-no-stdinc, -hlsl-no-stdinc
 .. program:: clang
 



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


[PATCH] D131268: [HLSL] Generate buffer subscript operators

2022-09-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a nit that was missed. Thanks for switching to static_cast, 
that makes me happier. :-)




Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:109
+if (Template) {
+  if (const auto TTD = dyn_cast(
+  Template->getTemplateParameters()->getParam(0)))

Missed from the previous suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131268

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


  1   2   >